1 14 package org.compiere.acct; 15 16 import java.awt.*; 17 import java.awt.event.*; 18 import javax.swing.*; 19 import javax.swing.event.*; 20 import javax.swing.border.*; 21 import java.util.*; 22 import java.sql.*; 23 24 import org.compiere.apps.*; 25 import org.compiere.util.*; 26 import org.compiere.report.core.*; 27 import org.compiere.model.*; 28 import org.compiere.apps.search.*; 29 import org.compiere.grid.ed.*; 30 import org.compiere.plaf.*; 31 import org.compiere.swing.*; 32 33 39 public class AcctViewer extends JFrame implements ActionListener, ChangeListener 40 { 41 44 public AcctViewer() 45 { 46 this (0, 0, 0); 47 } 49 56 public AcctViewer(int AD_Client_ID, int AD_Table_ID, int Record_ID) 57 { 58 super (Msg.getMsg(Env.getCtx(), "AcctViewer")); 59 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 60 m_data = new AcctViewerData(Env.createWindowNo(this), AD_Client_ID); 61 62 try 63 { 64 jbInit(); 65 dynInit(AD_Table_ID, Record_ID); 66 AEnv.showCenterScreen(this); 67 } 68 catch(Exception e) 69 { 70 Log.error("AcctViewer", e); 71 dispose(); 72 } 73 } 75 76 private AcctViewerData m_data = null; 77 78 79 80 private CPanel mainPanel = new CPanel(); 82 private CTabbedPane tabbedPane = new CTabbedPane(); 83 private CPanel query = new CPanel(); 84 private BorderLayout mainLayout = new BorderLayout(); 85 private JScrollPane result = new JScrollPane(); 86 private ResultTable table = new ResultTable(); 87 private CPanel southPanel = new CPanel(); 88 private CButton bQuery = new CButton(); 89 private CLabel statusLine = new CLabel(); 90 private BorderLayout southLayout = new BorderLayout(); 91 private BorderLayout queryLayout = new BorderLayout(); 92 private CPanel selectionPanel = new CPanel(); 93 private CPanel displayPanel = new CPanel(); 94 private TitledBorder displayBorder; 95 private TitledBorder selectionBorder; 96 private GridBagLayout displayLayout = new GridBagLayout(); 97 private CCheckBox displayQty = new CCheckBox(); 98 private CCheckBox displaySourceAmt = new CCheckBox(); 99 private CPanel graphPanel = new CPanel(); 100 private CCheckBox displayDocumentInfo = new CCheckBox(); 101 private CLabel lSort = new CLabel(); 102 private CComboBox sortBy1 = new CComboBox(); 103 private CComboBox sortBy2 = new CComboBox(); 104 private CComboBox sortBy3 = new CComboBox(); 105 private CCheckBox group1 = new CCheckBox(); 106 private CCheckBox group2 = new CCheckBox(); 107 private CCheckBox group3 = new CCheckBox(); 108 private CLabel lGroup = new CLabel(); 109 private GridBagLayout selectionLayout = new GridBagLayout(); 110 private CComboBox selAcctSchema = new CComboBox(); 111 private CCheckBox selDocument = new CCheckBox(); 112 private CComboBox selTable = new CComboBox(); 113 private CButton selRecord = new CButton(); 114 private CLabel lOrg = new CLabel(); 115 private CComboBox selOrg = new CComboBox(); 116 private CLabel lAcct = new CLabel(); 117 private CButton selAcct = new CButton(); 118 private CLabel lDate = new CLabel(); 119 private CLabel lacctSchema = new CLabel(); 120 private VDate selDateFrom = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); 121 private VDate selDateTo = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); 122 private CLabel lsel1 = new CLabel(); 123 private CLabel lsel2 = new CLabel(); 124 private CLabel lsel3 = new CLabel(); 125 private CLabel lsel4 = new CLabel(); 126 private CLabel lsel5 = new CLabel(); 127 private CLabel lsel6 = new CLabel(); 128 private CLabel lsel7 = new CLabel(); 129 private CLabel lsel8 = new CLabel(); 130 private CButton sel1 = new CButton(); 131 private CButton sel2 = new CButton(); 132 private CButton sel3 = new CButton(); 133 private CButton sel4 = new CButton(); 134 private CButton sel5 = new CButton(); 135 private CButton sel6 = new CButton(); 136 private CButton sel7 = new CButton(); 137 private CButton sel8 = new CButton(); 138 private CButton bRePost = new CButton(); 139 private CComboBox sortBy4 = new CComboBox(); 140 private CCheckBox group4 = new CCheckBox(); 141 142 153 private void jbInit() throws Exception 154 { 155 CompiereColor.setBackground(this); 156 ImageIcon ii = new ImageIcon(org.compiere.Compiere.class.getResource("images/InfoAccount16.gif")); 157 setIconImage(ii.getImage()); 158 mainLayout.setHgap(5); 160 mainLayout.setVgap(5); 161 mainPanel.setLayout(mainLayout); 162 selectionPanel.setLayout(selectionLayout); 163 this.getContentPane().add(mainPanel, BorderLayout.CENTER); 164 mainPanel.add(tabbedPane, BorderLayout.CENTER); 165 selectionBorder = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),"Selection"); 167 selectionPanel.setBorder(selectionBorder); 168 lacctSchema.setLabelFor(selAcctSchema); 169 lacctSchema.setText(Msg.translate(Env.getCtx(), "C_AcctSchema_ID")); 170 selDocument.setText(Msg.getMsg(Env.getCtx(), "SelectDocument")); 171 selDocument.addActionListener(this); 172 173 lOrg.setLabelFor(selOrg); 174 lOrg.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); 175 lAcct.setLabelFor(selAcct); 176 lAcct.setText(Msg.translate(Env.getCtx(), "Account_ID")); 177 lDate.setLabelFor(selDateFrom); 178 lDate.setText(Msg.translate(Env.getCtx(), "DateAcct")); 179 lsel1.setLabelFor(sel1); 180 lsel2.setLabelFor(sel2); 181 lsel3.setLabelFor(sel3); 182 lsel4.setLabelFor(sel4); 183 lsel5.setLabelFor(sel5); 184 lsel6.setLabelFor(sel6); 185 lsel7.setLabelFor(sel7); 186 lsel8.setLabelFor(sel8); 187 188 displayBorder = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),"Display"); 190 displayPanel.setBorder(displayBorder); 191 displayPanel.setLayout(displayLayout); 192 displayQty.setText(Msg.getMsg(Env.getCtx(), "DisplayQty")); 193 displaySourceAmt.setText(Msg.getMsg(Env.getCtx(), "DisplaySourceInfo")); 194 displayDocumentInfo.setText(Msg.getMsg(Env.getCtx(), "DisplayDocumentInfo")); 195 lSort.setText(Msg.getMsg(Env.getCtx(), "SortBy")); 196 lGroup.setText(Msg.getMsg(Env.getCtx(), "GroupBy")); 197 displayPanel.add(displaySourceAmt, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0 199 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 200 displayPanel.add(displayDocumentInfo, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0 201 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 202 displayPanel.add(lSort, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 203 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 204 displayPanel.add(sortBy1, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 205 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); 206 displayPanel.add(sortBy2, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 207 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); 208 displayPanel.add(group1, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 209 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 210 displayPanel.add(group2, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 211 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 212 displayPanel.add(lGroup, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 213 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 214 displayPanel.add(displayQty, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 215 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); 216 displayPanel.add(sortBy3, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 217 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); 218 displayPanel.add(group3, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0 219 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 220 displayPanel.add(sortBy4, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0 221 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 222 displayPanel.add(group4, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0 223 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 224 selectionPanel.add(selDocument, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0 226 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 227 selectionPanel.add(selTable, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 228 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); 229 selectionPanel.add(selRecord, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 230 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); 231 selectionPanel.add(lOrg, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 232 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); 233 selectionPanel.add(selOrg, new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0 234 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 235 selectionPanel.add(lAcct, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 236 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 237 selectionPanel.add(selAcct, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0 238 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 239 selectionPanel.add(selAcctSchema, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 240 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); 241 selectionPanel.add(lacctSchema, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 242 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); 243 selectionPanel.add(lDate, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 244 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); 245 selectionPanel.add(selDateFrom, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 246 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); 247 selectionPanel.add(selDateTo, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 248 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); 249 selectionPanel.add(lsel1, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 250 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 251 selectionPanel.add(lsel2, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 252 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 253 selectionPanel.add(lsel3, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0 254 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 255 selectionPanel.add(sel1, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0 256 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 257 selectionPanel.add(sel2, new GridBagConstraints(1, 7, 2, 1, 0.0, 0.0 258 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 259 selectionPanel.add(sel3, new GridBagConstraints(1, 8, 2, 1, 0.0, 0.0 260 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 261 selectionPanel.add(lsel4, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0 262 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 263 selectionPanel.add(sel4, new GridBagConstraints(1, 9, 2, 1, 0.0, 0.0 264 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 265 266 selectionPanel.add(lsel5, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0 267 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 268 selectionPanel.add(sel5, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0 269 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 270 selectionPanel.add(lsel6, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0 271 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 272 selectionPanel.add(sel6, new GridBagConstraints(1, 11, 2, 1, 0.0, 0.0 273 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 274 selectionPanel.add(lsel7, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0 275 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 276 selectionPanel.add(sel7, new GridBagConstraints(1, 12, 2, 1, 0.0, 0.0 277 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 278 selectionPanel.add(lsel8, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0 279 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 280 selectionPanel.add(sel8, new GridBagConstraints(1, 13, 2, 1, 0.0, 0.0 281 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); 282 queryLayout.setHgap(5); 284 queryLayout.setVgap(5); 285 query.setLayout(queryLayout); 286 query.add(selectionPanel, BorderLayout.CENTER); 287 query.add(displayPanel, BorderLayout.EAST); 288 290 tabbedPane.add(query, Msg.getMsg(Env.getCtx(), "ViewerQuery")); 294 tabbedPane.add(result, Msg.getMsg(Env.getCtx(), "ViewerResult")); 295 tabbedPane.addChangeListener(this); 297 result.getViewport().add(table, null); 298 southLayout.setHgap(5); 300 southLayout.setVgap(5); 301 southPanel.setLayout(southLayout); 302 statusLine.setForeground(Color.blue); 303 statusLine.setBorder(BorderFactory.createLoweredBevelBorder()); 304 southPanel.add(statusLine, BorderLayout.CENTER); 305 bQuery.setIcon(new ImageIcon(org.compiere.Compiere.class.getResource("images/Refresh16.gif"))); 306 bQuery.setToolTipText(Msg.getMsg(Env.getCtx(), "QueryExecute")); 307 bQuery.addActionListener(this); 308 bRePost.setText(Msg.getMsg(Env.getCtx(), "RePost")); 309 bRePost.setToolTipText(Msg.getMsg(Env.getCtx(), "RePostInfo")); 310 bRePost.addActionListener(this); 311 bRePost.setVisible(false); 312 southPanel.add(bQuery, BorderLayout.EAST); 313 southPanel.add(bRePost, BorderLayout.WEST); 314 this.getContentPane().add(southPanel, BorderLayout.SOUTH); 315 } 318 324 private void dynInit(int AD_Table_ID, int Record_ID) 325 { 326 ImageIcon iFind = new ImageIcon(org.compiere.Compiere.class.getResource("images/Find16.gif")); 327 328 if (m_data.ASchemas.length > 1) 329 m_data.fillAcctSchema(selAcctSchema); 330 else 331 { 332 lacctSchema.setVisible(false); 333 selAcctSchema.setVisible(false); 334 } 335 m_data.fillTable(selTable); 336 selTable.addActionListener(this); 337 selRecord.addActionListener(this); 338 selRecord.setIcon(iFind); 339 selRecord.setText(""); 340 341 ValueNamePair vn = new ValueNamePair("",""); 343 sortBy1.addItem(vn); sortBy2.addItem(vn); sortBy3.addItem(vn); sortBy4.addItem(vn); 344 vn = new ValueNamePair("DateAcct", Msg.translate(Env.getCtx(), "DateAcct")); 345 sortBy1.addItem(vn); sortBy2.addItem(vn); sortBy3.addItem(vn); sortBy4.addItem(vn); 346 vn = new ValueNamePair("DateTrx", Msg.translate(Env.getCtx(), "DateTrx")); 347 sortBy1.addItem(vn); sortBy2.addItem(vn); sortBy3.addItem(vn); sortBy4.addItem(vn); 348 vn = new ValueNamePair("C_Period_ID", Msg.translate(Env.getCtx(), "C_Period_ID")); 349 sortBy1.addItem(vn); sortBy2.addItem(vn); sortBy3.addItem(vn); sortBy4.addItem(vn); 350 351 m_data.fillOrg(selOrg); 353 selAcct.setActionCommand("Account_ID"); 354 selAcct.addActionListener(this); 355 selAcct.setText(""); 356 selAcct.setIcon(iFind); 357 CLabel[] labels = new CLabel[] {lsel1, lsel2, lsel3, lsel4, lsel5, lsel6, lsel7, lsel8}; 359 CButton[] buttons = new CButton[] {sel1, sel2, sel3, sel4, sel5, sel6, sel7, sel8}; 360 int selectionIndex = 0; 361 ArrayList elements = m_data.AS.getAcctSchemaElementList(); 362 for (int i = 0; i < elements.size() && selectionIndex < labels.length; i++) 363 { 364 AcctSchemaElement ase = (AcctSchemaElement)elements.get(i); 365 String columnName = ase.getColumnName(); 366 vn = new ValueNamePair(columnName, Msg.translate(Env.getCtx(), columnName)); 368 sortBy1.addItem(vn); 369 sortBy2.addItem(vn); 370 sortBy3.addItem(vn); 371 sortBy4.addItem(vn); 372 if (!ase.isSegmentType(AcctSchemaElement.SEGMENT_Org) && !ase.isSegmentType(AcctSchemaElement.SEGMENT_Account)) 374 { 375 labels[selectionIndex].setText(Msg.translate(Env.getCtx(), columnName)); 376 buttons[selectionIndex].setActionCommand(columnName); 377 buttons[selectionIndex].addActionListener(this); 378 buttons[selectionIndex].setIcon(iFind); 379 buttons[selectionIndex].setText(""); 380 selectionIndex++; 381 } 382 } 383 while (selectionIndex < labels.length) 385 { 386 labels[selectionIndex].setVisible(false); 387 buttons[selectionIndex++].setVisible(false); 388 } 389 390 boolean haveDoc = AD_Table_ID != 0 && Record_ID != 0; 392 selDocument.setSelected (haveDoc); 393 actionDocument(); 394 actionTable(); 395 statusLine.setText(" " + Msg.getMsg(Env.getCtx(), "ViewerOptions")); 396 397 if (haveDoc) 399 { 400 m_data.AD_Table_ID = AD_Table_ID; 401 m_data.Record_ID = Record_ID; 402 actionQuery(); 403 } 404 } 406 409 public void dispose() 410 { 411 m_data.dispose(); 412 m_data = null; 413 super.dispose(); 414 } 416 417 418 422 public void stateChanged(ChangeEvent e) 423 { 424 bRePost.setVisible(m_data.documentQuery && tabbedPane.getSelectedIndex() == 1); 426 } 428 429 433 public void actionPerformed(ActionEvent e) 434 { 435 Log.trace(Log.l1_User, "AcctViewer.actionPerformed", e.getActionCommand()); 436 if (e.getSource() == bQuery) 437 actionQuery(); 438 else if (e.getSource() == selDocument) 439 actionDocument(); 440 else if (e.getSource() == selTable) 441 actionTable(); 442 else if (e.getSource() == bRePost) 443 actionRePost(); 444 else if (e.getSource() instanceof CButton) 446 actionButton((CButton)e.getSource()); 447 } 449 452 private void actionQuery() 453 { 454 StringBuffer para = new StringBuffer (); 456 m_data.C_AcctSchema_ID = 0; 458 m_data.AD_Org_ID = 0; 459 460 KeyNamePair kp = (KeyNamePair)selAcctSchema.getSelectedItem(); 462 if (kp != null) 463 m_data.C_AcctSchema_ID = kp.getKey(); 464 para.append("C_AcctSchema_ID=").append(m_data.C_AcctSchema_ID); 465 466 m_data.documentQuery = selDocument.isSelected(); 468 para.append(", DocumentQuery=").append(m_data.documentQuery); 469 if (selDocument.isSelected()) 470 { 471 if (m_data.AD_Table_ID == 0 || m_data.Record_ID == 0) 472 return; 473 para.append(", AD_Table_ID=").append(m_data.AD_Table_ID) 474 .append(", Record_ID=").append(m_data.Record_ID); 475 } 476 else 477 { 478 m_data.DateFrom = (Timestamp)selDateFrom.getValue(); 479 para.append(", DateFrom=").append(m_data.DateFrom); 480 m_data.DateTo = (Timestamp)selDateTo.getValue(); 481 para.append(", DateTo=").append(m_data.DateTo); 482 kp = (KeyNamePair)selOrg.getSelectedItem(); 483 if (kp != null) 484 m_data.AD_Org_ID = kp.getKey(); 485 para.append(", AD_Org_ID=").append(m_data.AD_Org_ID); 486 Iterator it = m_data.whereInfo.values().iterator(); 488 while (it.hasNext()) 489 para.append(", ").append(it.next()); 490 } 491 492 m_data.displayQty = displayQty.isSelected(); 494 para.append(" - Display Qty=").append(m_data.displayQty); 495 m_data.displaySourceAmt = displaySourceAmt.isSelected(); 496 para.append(", Source=").append(m_data.displaySourceAmt); 497 m_data.displayDocumentInfo = displayDocumentInfo.isSelected(); 498 para.append(", Doc=").append(m_data.displayDocumentInfo); 499 m_data.sortBy1 = ((ValueNamePair)sortBy1.getSelectedItem()).getValue(); 501 m_data.group1 = group1.isSelected(); 502 para.append(" - Sorting: ").append(m_data.sortBy1).append("/").append(m_data.group1); 503 m_data.sortBy2 = ((ValueNamePair)sortBy2.getSelectedItem()).getValue(); 504 m_data.group2 = group2.isSelected(); 505 para.append(", ").append(m_data.sortBy2).append("/").append(m_data.group2); 506 m_data.sortBy3 = ((ValueNamePair)sortBy3.getSelectedItem()).getValue(); 507 m_data.group3 = group3.isSelected(); 508 para.append(", ").append(m_data.sortBy3).append("/").append(m_data.group3); 509 m_data.sortBy4 = ((ValueNamePair)sortBy4.getSelectedItem()).getValue(); 510 m_data.group4 = group4.isSelected(); 511 para.append(", ").append(m_data.sortBy4).append("/").append(m_data.group4); 512 513 bQuery.setEnabled(false); 514 statusLine.setText(" " + Msg.getMsg(Env.getCtx(), "Processing")); 515 516 Log.trace(Log.l3_Util, "AcctViewer.actionQuery", para.toString()); 517 Thread.yield(); 518 519 tabbedPane.setSelectedIndex(1); 521 522 table.setModel(m_data.query()); 524 525 bQuery.setEnabled(true); 526 statusLine.setText(" " + Msg.getMsg(Env.getCtx(), "ViewerOptions")); 527 } 529 532 private void actionDocument() 533 { 534 boolean doc = selDocument.isSelected(); 535 selTable.setEnabled(doc); 536 selRecord.setEnabled(doc); 537 selDateFrom.setReadWrite(!doc); 539 selDateTo.setReadWrite(!doc); 540 selOrg.setEnabled(!doc); 541 selAcct.setEnabled(!doc); 542 sel1.setEnabled(!doc); 543 sel2.setEnabled(!doc); 544 sel3.setEnabled(!doc); 545 sel4.setEnabled(!doc); 546 sel5.setEnabled(!doc); 547 sel6.setEnabled(!doc); 548 sel7.setEnabled(!doc); 549 sel8.setEnabled(!doc); 550 } 552 555 private void actionTable() 556 { 557 ValueNamePair vp = (ValueNamePair)selTable.getSelectedItem(); 558 m_data.AD_Table_ID = ((Integer )m_data.tableInfo.get(vp.getValue())).intValue(); 559 Log.trace(Log.l3_Util, "AcctViewer.actionTable", vp.getValue() + " = " + m_data.AD_Table_ID); 560 m_data.Record_ID = 0; 562 selRecord.setText(""); 563 selRecord.setActionCommand(vp.getValue()+"_ID"); 564 } 566 572 private int actionButton(CButton button) 573 { 574 String keyColumn = button.getActionCommand(); 575 String lookupColumn = keyColumn; 576 if (keyColumn.equals("Account_ID") || keyColumn.startsWith("User")) 577 lookupColumn = "C_ElementValue_ID"; 578 String tableName = lookupColumn.substring(0, lookupColumn.length()-3); 579 Info info = Info.create(this, true, m_data.WindowNo, tableName, lookupColumn, "", false, ""); 580 if (!info.loadedOK()) 581 { 582 info.dispose(); 583 info = null; 584 button.setText(""); 585 m_data.whereInfo.put(keyColumn, ""); 586 return 0; 587 } 588 info.show(); 589 String selectSQL = info.getSelectedSQL(); Integer key = (Integer )info.getSelectedKey(); 591 info = null; 592 if (selectSQL == null || selectSQL.length() == 0 || key == null) 593 { 594 button.setText(""); 595 m_data.whereInfo.put(keyColumn, ""); return 0; 597 } 598 599 Log.trace(Log.l3_Util, "AcctViewer.actionButton", keyColumn + " - " + key); 601 if (button == selRecord) m_data.Record_ID = key.intValue(); 603 else 604 m_data.whereInfo.put(keyColumn, keyColumn + "=" + key.intValue()); 605 606 button.setText(m_data.getButtonText(tableName, lookupColumn, selectSQL)); 608 pack(); 609 return key.intValue(); 610 } 612 615 private void actionRePost() 616 { 617 if (m_data.documentQuery && m_data.AD_Table_ID != 0 && m_data.Record_ID != 0 618 && ADialog.ask(m_data.WindowNo, this, "PostImmediate?")) 619 { 620 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 621 AEnv.postImmediate (m_data.WindowNo, m_data.AD_Client_ID, 622 m_data.AD_Table_ID, m_data.Record_ID, true); 623 setCursor(Cursor.getDefaultCursor()); 624 actionQuery(); 625 } 626 } 628 } | Popular Tags |