1 package sellwin.gui; 2 3 import sellwin.domain.*; 4 import sellwin.utils.*; 5 6 import java.awt.*; 7 import java.awt.event.*; 8 import java.util.*; 9 import javax.swing.*; 10 import javax.swing.event.*; 11 import javax.swing.border.*; 12 import javax.swing.table.*; 13 14 18 24 public class QuotesPanel extends JPanel 25 implements InventoryListener,TableModelListener, GUIChars { 26 27 private QuotesPanel thisPanel = null; 28 private JPopupMenu quotePopup = new JPopupMenu(); 29 private JPopupMenu linePopup = new JPopupMenu(); 30 31 private ArrayList quotes; 33 private ProductSelectionDialog addProductSelectionDialog; 34 private Whiteboard wb; 35 private Opportunity currentOpp; 36 37 private QuoteTableModel quoteModel = null; 38 private QuoteLineTableModel lineModel = null; 39 40 private JPanel buttonPanel; 41 private JMenuItem addQuoteMenuItem; 42 private JMenuItem deleteQuoteMenuItem; 43 private JMenuItem addLineMenuItem; 44 private JMenuItem deleteLineMenuItem; 45 private JButton orderButton; 46 private JButton applyButton; 47 48 private JPanel mainPanel; 49 private JScrollPane quotesScrollPane; 50 private final javax.swing.JTable quotesTable = new JTable(); 51 private JLabel lineItemsLabel; 52 private TitledBorder lineItemBorder; 53 private JLabel quotesLabel; 54 55 private JPanel linesPanel = new JPanel(); 56 private JScrollPane linesScrollPane; 57 private final javax.swing.JTable linesTable = new JTable(); 58 59 private JLabel totalLabel; 60 private JTextField totalField; 61 62 private JLabel profitLabel; 63 private JTextField profitField; 64 65 68 public QuotesPanel() { 69 super(); 70 71 thisPanel = this; 72 wb = MainWindow.getWhiteboard(); 73 initComponents(); 74 75 setFonts(); 76 setColors(); 77 78 quoteModel = new QuoteTableModel(new ArrayList()); 79 quotesTable.setModel(quoteModel); 80 lineModel = new QuoteLineTableModel(new ArrayList()); 81 linesTable.setModel(lineModel); 82 83 setLang(); 84 85 linesTable.setPreferredScrollableViewportSize(new Dimension(500,150)); 86 linesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 87 linesTable.getSelectionModel().addListSelectionListener( 88 new ListSelectionListener() { 89 public void valueChanged(ListSelectionEvent e) { 90 if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel)e.getSource(); 92 } 93 } 94 ); 95 96 quotesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 97 quotesTable.getSelectionModel().addListSelectionListener( 98 new ListSelectionListener() { 99 public void valueChanged(ListSelectionEvent e) { 100 101 if (e.getValueIsAdjusting()) return; 103 ListSelectionModel lsm = (ListSelectionModel)e.getSource(); 104 105 if (lsm.isSelectionEmpty()) 106 ; 107 else { 108 Quote quote = quoteModel.getQuote(quotesTable.getSelectedRow()); 109 setLines(quote.getLines()); 110 111 } 112 } 113 } 114 ); 115 116 quotesTable.setDefaultRenderer(Date.class, new DateRenderer()); 117 118 addQuoteMenuItem.addActionListener( 119 new ActionListener() { 120 public void actionPerformed(ActionEvent e) { 121 Opportunity opp = wb.getCurrentOpportunity(); 122 if (opp == null) { 123 JOptionPane.showMessageDialog( thisPanel, 124 wb.getLang().getString("selectOpp"), 125 wb.getLang().getString("error"), 126 JOptionPane.INFORMATION_MESSAGE); 127 return; 128 } 129 String val=JOptionPane.showInputDialog("Please enter a Quote name"); 130 Quote quote = new Quote(); 131 quote.setName(val); 132 try { 133 quote.setModifiedBy(wb.getCurrentUser().getAddress().getFormattedName()); 134 quote.setPK(wb.addQuote(opp.getPK(), quote)); 135 opp.addQuote(quote); 136 quotesTable.tableChanged(new TableModelEvent(quoteModel)); 137 int quoteCt = opp.getQuotes().size(); 138 if (quoteCt > 0) 139 quotesTable.setRowSelectionInterval(quoteCt-1,quoteCt-1); 140 } catch (Exception f) { 141 ErrorHandler.show(thisPanel, f); 142 } 143 } 144 } 145 ); 146 147 deleteQuoteMenuItem.addActionListener( 148 new ActionListener() { 149 public void actionPerformed(ActionEvent e) { 150 Quote quote = quoteModel.getQuote(quotesTable.getSelectedRow()); 151 try { 152 Opportunity opp = wb.getCurrentOpportunity(); 153 wb.deleteQuote(opp.getPK(), quote.getPK()); 154 opp.deleteQuote(quote); 155 quotesTable.tableChanged(new TableModelEvent(quoteModel)); 156 } catch (Exception f) { 157 ErrorHandler.show(thisPanel, f); 158 } 159 } 160 } 161 ); 162 163 164 addLineMenuItem.addActionListener( 165 new ActionListener() { 166 public void actionPerformed(ActionEvent e) { 167 if (addProductSelectionDialog == null) 168 addProductSelectionDialog = new ProductSelectionDialog(thisPanel); 169 addProductSelectionDialog.show(); 170 } 171 } 172 ); 173 174 deleteLineMenuItem.addActionListener( 175 new ActionListener() { 176 public void actionPerformed(ActionEvent e) { 177 Quote quote = quoteModel.getQuote(quotesTable.getSelectedRow()); 178 QuoteLine line = lineModel.getQuoteLine(linesTable.getSelectedRow()); 179 try { 180 Opportunity opp = wb.getCurrentOpportunity(); 181 wb.deleteQuoteLine(opp.getPK(), quote.getPK(), line.getPK()); 182 quote.deleteLine(line.getPK()); 183 linesTable.tableChanged(new TableModelEvent(lineModel)); 184 calcTotal(); 185 } catch (Exception f) { 189 ErrorHandler.show(thisPanel, f); 190 } 191 } 192 } 193 ); 194 195 createPopup(); 196 197 quotesTable.addMouseListener(new MouseAdapter() { 198 public void mousePressed(MouseEvent e) { 199 if (e.isPopupTrigger()) 200 quotePopup.show(quotesTable, e.getX(), e.getY()); 201 } 202 public void mouseReleased(MouseEvent e) { 203 if (e.isPopupTrigger()) 204 quotePopup.show(quotesTable, e.getX(), e.getY()); 205 } 206 public void mouseClicked(MouseEvent e) { 207 if (e.isPopupTrigger()) 208 quotePopup.show(quotesTable, e.getX(), e.getY()); 209 } 210 }); 211 212 quotesTable.getTableHeader().addMouseListener(new MouseAdapter() { 213 public void mousePressed(MouseEvent e) { 214 if (e.isPopupTrigger()) 215 quotePopup.show(quotesTable, e.getX(), e.getY()); 216 } 217 public void mouseReleased(MouseEvent e) { 218 if (e.isPopupTrigger()) 219 quotePopup.show(quotesTable, e.getX(), e.getY()); 220 } 221 public void mouseClicked(MouseEvent e) { 222 if (e.isPopupTrigger()) 223 quotePopup.show(quotesTable, e.getX(), e.getY()); 224 } 225 }); 226 quotesScrollPane.addMouseListener(new MouseAdapter() { 227 public void mousePressed(MouseEvent e) { 228 if (e.isPopupTrigger()) 229 quotePopup.show(quotesTable, e.getX(), e.getY()); 230 } 231 public void mouseReleased(MouseEvent e) { 232 if (e.isPopupTrigger()) 233 quotePopup.show(quotesTable, e.getX(), e.getY()); 234 } 235 public void mouseClicked(MouseEvent e) { 236 if (e.isPopupTrigger()) 237 quotePopup.show(quotesTable, e.getX(), e.getY()); 238 } 239 }); 240 241 242 linesScrollPane.addMouseListener(new MouseAdapter() { 243 public void mousePressed(MouseEvent e) { 244 if (e.isPopupTrigger()) 245 linePopup.show(linesTable, e.getX(), e.getY()); 246 } 247 public void mouseReleased(MouseEvent e) { 248 if (e.isPopupTrigger()) 249 linePopup.show(linesTable, e.getX(), e.getY()); 250 } 251 public void mouseClicked(MouseEvent e) { 252 if (e.isPopupTrigger()) 253 linePopup.show(linesTable, e.getX(), e.getY()); 254 } 255 }); 256 linesTable.addMouseListener(new MouseAdapter() { 257 public void mousePressed(MouseEvent e) { 258 if (e.isPopupTrigger()) 259 linePopup.show(linesTable, e.getX(), e.getY()); 260 } 261 public void mouseReleased(MouseEvent e) { 262 if (e.isPopupTrigger()) 263 linePopup.show(linesTable, e.getX(), e.getY()); 264 } 265 public void mouseClicked(MouseEvent e) { 266 if (e.isPopupTrigger()) 267 linePopup.show(linesTable, e.getX(), e.getY()); 268 } 269 }); 270 271 linesTable.getTableHeader().addMouseListener(new MouseAdapter() { 272 public void mousePressed(MouseEvent e) { 273 if (e.isPopupTrigger()) 274 linePopup.show(linesTable, e.getX(), e.getY()); 275 } 276 public void mouseReleased(MouseEvent e) { 277 if (e.isPopupTrigger()) 278 linePopup.show(linesTable, e.getX(), e.getY()); 279 } 280 public void mouseClicked(MouseEvent e) { 281 if (e.isPopupTrigger()) 282 linePopup.show(linesTable, e.getX(), e.getY()); 283 } 284 }); 285 286 orderButton.addActionListener( 287 new ActionListener() { 288 public void actionPerformed(ActionEvent e) { 289 int opt = JOptionPane.showConfirmDialog(thisPanel, "Select 'Yes' to confirm order.", "Confirm Order Creation", JOptionPane.YES_NO_OPTION); 290 if (opt == JOptionPane.YES_OPTION) 291 createOrder(); 292 } 293 } 294 ); 295 296 applyButton.addActionListener( 297 new ActionListener() { 298 public void actionPerformed(ActionEvent e) { 299 ArrayList quotes = wb.getCurrentOpportunity().getQuotes(); 300 Quote quote; 301 for (int i=0;i<quotes.size();i++) { 302 quote = (Quote)quotes.get(i); 303 if (quote.getModified() == true) { 304 try { 305 wb.updateQuote(quote); 306 } catch (AngError r) { 307 ErrorHandler.show(thisPanel, r); 308 } 309 } 310 } 311 JOptionPane.showMessageDialog( thisPanel, 312 "Update Successful", "Update Successful", 313 JOptionPane.INFORMATION_MESSAGE); 314 } 315 } 316 ); 317 318 319 } 320 321 325 private final void createOrder() { 326 Opportunity opp = wb.getCurrentOpportunity(); 327 Order order = new Order(); 328 329 Quote quote = quoteModel.getQuote(quotesTable.getSelectedRow()); 331 order.setQuoteKey(quote.getPK()); 332 order.setQuote(quote); 333 Date temp = new java.util.Date (); 335 order.setOrderNumber(new Long (temp.getTime())); 336 338 Customer currCust = opp.getCustomer(); 341 order.setShipAddress(currCust.getShipAddress()); 342 System.out.println("ship addr"); 343 currCust.getShipAddress().print(); 344 order.setBillAddress(currCust.getBillAddress()); 345 System.out.println("bill addr"); 346 currCust.getBillAddress().print(); 347 348 try { 349 350 order.setPK( 352 wb.addOrder(order)); 353 354 opp.addOrder(order); 356 357 OrderFulfillPanel p = MainWindow.getOrdersPanel(); 359 p.refreshOpportunity(); 360 361 p.setSelectedOrder(order); 363 364 MainWindow.selectOrderTab(); 366 367 } catch (AngError e) { 368 ErrorHandler.show(thisPanel, e); 369 } 370 } 371 372 377 public final void addQuoteLine(QuoteLine q) { 378 Quote quote = quoteModel.getQuote(quotesTable.getSelectedRow()); 379 int lineCt = quote.getLines().size(); 380 try { 381 wb.addQuoteLine( 382 wb.getCurrentOpportunity().getPK(), 383 quote.getPK(), 384 q); 385 quote.addLine(q); 386 linesTable.tableChanged(new TableModelEvent(lineModel)); 387 linesTable.setRowSelectionInterval(lineCt, lineCt); 388 calcTotal(); 389 } catch (AngError e) { 393 ErrorHandler.show(thisPanel, e); 394 } 395 } 396 397 400 private final void createPopup() { 401 linePopup.add(addLineMenuItem); 402 linePopup.add(deleteLineMenuItem); 403 quotePopup.add(addQuoteMenuItem); 404 quotePopup.add(deleteQuoteMenuItem); 405 } 406 407 413 public final void setEnabled(boolean t) { 414 } 415 416 420 public final void refreshOpportunity() { 421 422 setSecurity(); 423 424 currentOpp = wb.getCurrentOpportunity(); 425 426 Quote quote=null; 427 ArrayList quotes = currentOpp.getQuotes(); 428 for (int i=0;i<quotes.size();i++) { 429 quote = (Quote)(quotes.get(i)); 430 } 431 quoteModel = new QuoteTableModel(currentOpp.getQuotes()); 432 quotesTable.setModel(quoteModel); 433 ArrayList lines = null; 434 Quote firstQuote = null; 435 if (currentOpp.getQuotes().size() > 0) { 436 firstQuote = (Quote)(currentOpp.getQuotes().get(0)); 437 lines = firstQuote.getLines(); 438 quotesTable.setRowSelectionInterval(0,0); 439 } else 440 lines = new ArrayList(); 441 442 setLines(lines); 443 444 linesTable.setDefaultRenderer(Double .class, new MoneyRenderer()); 445 446 } 447 448 452 private final void setLines(ArrayList lines) { 453 lineModel = new QuoteLineTableModel(lines); 454 lineModel.addTableModelListener(this); 455 linesTable.setModel(lineModel); 456 setLinesColumnWidths(); 457 if (lines.size() > 0) 458 linesTable.setRowSelectionInterval(0,0); 459 460 calcTotal(); 461 468 470 } 471 472 478 public final void setDisplayedQuoteLines(int index) { 479 lineModel = new QuoteLineTableModel(((Quote)(quotes.get(index))).getLines()); 480 lineModel.addTableModelListener(this); 481 linesTable.setModel(lineModel); 482 setLinesColumnWidths(); 483 } 484 485 488 public final void setColors() { 489 quotesLabel.setForeground(MainWindow.LETTERS); 490 lineItemsLabel.setForeground(MainWindow.LETTERS); 491 totalLabel.setForeground(MainWindow.LETTERS); 492 profitLabel.setForeground(MainWindow.LETTERS); 493 } 494 495 498 public final void setFonts() { 499 quotesLabel.setFont(MainWindow.LABEL_FONT); 500 lineItemsLabel.setFont(MainWindow.LABEL_FONT); 501 linesTable.setFont(MainWindow.FIELD_FONT); 502 quotesTable.setFont(MainWindow.FIELD_FONT); 503 addQuoteMenuItem.setFont(MainWindow.LABEL_FONT); 504 deleteQuoteMenuItem.setFont(MainWindow.LABEL_FONT); 505 addLineMenuItem.setFont(MainWindow.LABEL_FONT); 506 deleteLineMenuItem.setFont(MainWindow.LABEL_FONT); 507 totalLabel.setFont(MainWindow.LABEL_FONT); 508 profitLabel.setFont(MainWindow.LABEL_FONT); 509 orderButton.setFont(MainWindow.LABEL_FONT); 510 applyButton.setFont(MainWindow.LABEL_FONT); 511 } 512 513 516 private final void initComponents() { 517 buttonPanel = new JPanel(); 518 addQuoteMenuItem = new JMenuItem(); 519 deleteQuoteMenuItem = new JMenuItem(); 520 addLineMenuItem = new JMenuItem(); 521 deleteLineMenuItem = new JMenuItem(); 522 orderButton = new JButton(); 523 applyButton = new JButton(); 524 mainPanel = new JPanel(); 525 quotesScrollPane = new JScrollPane(); 526 lineItemsLabel = new JLabel(); 527 quotesLabel = new JLabel(); 528 linesScrollPane = new JScrollPane(); 529 totalLabel = new JLabel(); 530 totalField = new JTextField(); 531 totalField.setEditable(false); 532 profitLabel = new JLabel(); 533 profitField = new JTextField(); 534 profitField.setEditable(false); 535 536 setLayout(new java.awt.BorderLayout ()); 537 538 addQuoteMenuItem.setText("Add"); 539 deleteQuoteMenuItem.setText("Delete"); 540 addLineMenuItem.setText("Add"); 541 deleteLineMenuItem.setText("Delete"); 542 543 orderButton.setText("Create Order"); 544 buttonPanel.add(orderButton); 545 applyButton.setText("Apply"); 546 buttonPanel.add(applyButton); 547 548 add(buttonPanel, java.awt.BorderLayout.SOUTH); 549 550 mainPanel.setLayout(new java.awt.GridBagLayout ()); 551 java.awt.GridBagConstraints gridBagConstraints1; 552 553 mainPanel.setBorder(new javax.swing.border.EtchedBorder ()); 554 555 quotesScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 557 quotesScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 558 quotesScrollPane.setMinimumSize(new Dimension(500, 100)); 559 quotesScrollPane.setMaximumSize(new Dimension(500, 100)); 560 quotesScrollPane.setPreferredSize(new Dimension(500, 100)); 561 quotesTable.setPreferredSize(new Dimension(500, 100)); 562 quotesTable.setMaximumSize(new Dimension(500, 100)); 563 quotesTable.setMinimumSize(new Dimension(500, 100)); 564 quotesTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); 565 quotesScrollPane.setViewportView(quotesTable); 566 567 gridBagConstraints1 = new java.awt.GridBagConstraints (); 568 gridBagConstraints1.gridx = 0; 569 gridBagConstraints1.gridy = 1; 570 gridBagConstraints1.gridwidth = java.awt.GridBagConstraints.REMAINDER; 571 gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; 572 gridBagConstraints1.ipadx = 9; 573 gridBagConstraints1.ipady = 9; 574 gridBagConstraints1.insets = new Insets(Prefs.I_TOP,Prefs.I_LF,Prefs.I_BOTT,Prefs.I_RT); 575 gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; 576 mainPanel.add(quotesScrollPane, gridBagConstraints1); 577 578 579 linesScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 582 linesScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); 583 linesScrollPane.setMinimumSize(new Dimension(500, 100)); 584 linesScrollPane.setMaximumSize(new Dimension(500, 100)); 585 linesScrollPane.setPreferredSize(new Dimension(500, 100)); 586 linesTable.setPreferredSize(new Dimension(500, 100)); 587 linesTable.setMinimumSize(new Dimension(500, 100)); 588 linesTable.setMaximumSize(new Dimension(500, 100)); 589 linesTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); 590 linesScrollPane.setViewportView(linesTable); 591 592 gridBagConstraints1 = new java.awt.GridBagConstraints (); 593 gridBagConstraints1.gridx = 0; 594 gridBagConstraints1.gridy = 3; 595 gridBagConstraints1.gridwidth = java.awt.GridBagConstraints.REMAINDER; 596 gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; 597 gridBagConstraints1.ipadx = 9; 598 gridBagConstraints1.ipady = 9; 599 gridBagConstraints1.insets = new Insets(Prefs.I_TOP,Prefs.I_LF,Prefs.I_BOTT,Prefs.I_RT); 600 gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; 601 linesPanel.add(linesScrollPane); 603 mainPanel.add(linesPanel, gridBagConstraints1); 604 605 totalLabel.setText("Total"); 606 totalLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 607 gridBagConstraints1 = new java.awt.GridBagConstraints (); 608 gridBagConstraints1.gridx = 0; 609 gridBagConstraints1.gridy = 4; 610 gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; 611 gridBagConstraints1.ipadx = 9; 612 gridBagConstraints1.ipady = 9; 613 gridBagConstraints1.insets = new Insets(Prefs.I_TOP,Prefs.I_LF,Prefs.I_BOTT,Prefs.I_RT); 614 gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST; 615 mainPanel.add(totalLabel, gridBagConstraints1); 616 617 totalField.setText("0.00"); 618 totalField.setMinimumSize(new Dimension(100, Prefs.FIELD_HEIGHT)); 619 totalField.setPreferredSize(new Dimension(100, Prefs.FIELD_HEIGHT)); 620 gridBagConstraints1 = new java.awt.GridBagConstraints (); 621 gridBagConstraints1.gridx = 1; 622 gridBagConstraints1.gridy = 4; 623 gridBagConstraints1.insets = new Insets(Prefs.I_TOP,Prefs.I_LF,Prefs.I_BOTT,Prefs.I_RT); 624 gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; 625 mainPanel.add(totalField, gridBagConstraints1); 626 627 profitLabel.setText("Profit"); 628 profitLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 629 gridBagConstraints1 = new java.awt.GridBagConstraints (); 630 gridBagConstraints1.gridx = 0; 631 gridBagConstraints1.gridy = 5; 632 gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; 633 gridBagConstraints1.ipadx = 9; 634 gridBagConstraints1.ipady = 9; 635 gridBagConstraints1.insets = new Insets(Prefs.I_TOP,Prefs.I_LF,Prefs.I_BOTT,Prefs.I_RT); 636 gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST; 637 mainPanel.add(profitLabel, gridBagConstraints1); 638 639 profitField.setText("0.00"); 640 profitField.setMinimumSize(new Dimension(100, Prefs.FIELD_HEIGHT)); 641 profitField.setPreferredSize(new Dimension(100, Prefs.FIELD_HEIGHT)); 642 gridBagConstraints1 = new java.awt.GridBagConstraints (); 643 gridBagConstraints1.gridx = 1; 644 gridBagConstraints1.gridy = 5; 645 gridBagConstraints1.insets = new Insets(Prefs.I_TOP,Prefs.I_LF,Prefs.I_BOTT,Prefs.I_RT); 646 gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; 647 mainPanel.add(profitField, gridBagConstraints1); 648 649 add(mainPanel, java.awt.BorderLayout.CENTER); 650 } 651 652 655 public final void tableChanged(TableModelEvent e) { 656 calcTotal(); 657 } 658 659 662 public final void calcTotal() { 663 double total=0.00; 665 double profit=0.00; 666 667 if (quotesTable.getSelectedRow() < 0) 668 return; 669 670 Quote quote = quoteModel.getQuote(quotesTable.getSelectedRow()); 671 quote.setModified(true); 672 ArrayList lines = quote.getLines(); 673 QuoteLine line; 674 for (int i=0;i<lines.size();i++) { 675 line = (QuoteLine)lines.get(i); 676 total = total + 677 (line.getProduct().getPrice().doubleValue() 678 * line.getQuantity().intValue()); 679 profit = profit + 680 ((line.getProduct().getPrice().doubleValue() - 681 line.getProduct().getCost().doubleValue()) 682 * line.getQuantity().doubleValue()); 683 } 685 totalField.setText(Prefs.money.format(total)); 686 profitField.setText(Prefs.money.format(profit)); 687 } 689 690 693 private final void setSecurity() { 694 try { 695 if (wb.getLogin().quoteWritable()) { 696 addQuoteMenuItem.setEnabled(true); 697 deleteQuoteMenuItem.setEnabled(true); 698 addLineMenuItem.setEnabled(true); 699 deleteLineMenuItem.setEnabled(true); 700 } else { 701 addQuoteMenuItem.setEnabled(false); 702 deleteQuoteMenuItem.setEnabled(false); 703 addLineMenuItem.setEnabled(false); 704 deleteLineMenuItem.setEnabled(false); 705 } 706 } catch (AngError e) { 707 ErrorHandler.show(thisPanel, e); 708 } 709 } 710 711 714 public final void clearOpportunity() { 715 716 quoteModel = new QuoteTableModel(new ArrayList()); 717 quotesTable.setModel(quoteModel); 718 ArrayList lines = new ArrayList(); 719 setLines(lines); 720 } 721 722 725 public final void setLang() { 726 addQuoteMenuItem.setText(wb.getLang().getString("add")); 727 deleteQuoteMenuItem.setText(wb.getLang().getString("delete")); 728 addLineMenuItem.setText(wb.getLang().getString("add")); 729 deleteLineMenuItem.setText(wb.getLang().getString("delete")); 730 orderButton.setText(wb.getLang().getString("createOrder")); 731 applyButton.setText(wb.getLang().getString("apply")); 732 linesPanel.setBorder( 733 new TitledBorder( 734 null, 735 wb.getLang().getString("lineItems"), 736 TitledBorder.DEFAULT_JUSTIFICATION, 737 TitledBorder.DEFAULT_POSITION, 738 MainWindow.LABEL_FONT, 739 MainWindow.LETTERS 740 ) 741 ); 742 totalLabel.setText(wb.getLang().getString("total")); 743 profitLabel.setText(wb.getLang().getString("profit")); 744 quoteModel.setLang(); 745 lineModel.setLang(); 746 } 747 748 private void setLinesColumnWidths() { 749 TableColumn col = linesTable.getColumnModel().getColumn(0); col.setPreferredWidth(170); 751 col = linesTable.getColumnModel().getColumn(1); col.setPreferredWidth(80); 753 col = linesTable.getColumnModel().getColumn(2); col.setPreferredWidth(80); 755 col = linesTable.getColumnModel().getColumn(3); col.setPreferredWidth(80); 757 col = linesTable.getColumnModel().getColumn(4); col.setPreferredWidth(80); 759 col = linesTable.getColumnModel().getColumn(5); col.setPreferredWidth(80); 761 col = linesTable.getColumnModel().getColumn(6); col.setPreferredWidth(260); 763 } 764 } 765 | Popular Tags |