1 23 24 package org.objectweb.fractal.gui.dialog.view; 25 26 import org.objectweb.fractal.api.control.BindingController; 27 28 import org.objectweb.fractal.gui.Constants; 29 import org.objectweb.fractal.gui.dialog.model.DialogModel; 30 import org.objectweb.fractal.gui.model.ClientInterface; 31 import org.objectweb.fractal.gui.model.Component; 32 import org.objectweb.fractal.gui.model.Configuration; 33 import org.objectweb.fractal.gui.model.ConfigurationListener; 34 import org.objectweb.fractal.gui.model.Interface; 35 import org.objectweb.fractal.gui.model.ServerInterface; 36 import org.objectweb.fractal.swing.JPanelImpl; 37 38 import java.awt.BorderLayout ; 39 import java.awt.Color ; 40 import java.awt.GridBagConstraints ; 41 import java.awt.GridBagLayout ; 42 import java.awt.Insets ; 43 import java.awt.event.ActionEvent ; 44 import java.awt.event.ActionListener ; 45 import java.awt.Dimension ; 46 import java.util.ArrayList ; 47 import java.util.List ; 48 import java.util.Map ; 49 import java.util.HashMap ; 50 51 import javax.swing.BorderFactory ; 52 import javax.swing.DefaultCellEditor ; 53 import javax.swing.JButton ; 54 import javax.swing.JComboBox ; 55 import javax.swing.JComponent ; 56 import javax.swing.JLabel ; 57 import javax.swing.JPanel ; 58 import javax.swing.JScrollPane ; 59 import javax.swing.JTable ; 60 import javax.swing.JTextField ; 61 import javax.swing.ListSelectionModel ; 62 import javax.swing.SwingConstants ; 63 import javax.swing.event.ListSelectionEvent ; 64 import javax.swing.event.ListSelectionListener ; 65 66 70 71 public class BasicDialogView extends JPanelImpl implements 72 ConfigurationListener, 73 BindingController 74 { 75 76 81 82 public final static String CONFIGURATION_BINDING = "configuration"; 83 84 88 89 public final static String DIALOG_MODEL_BINDING = "dialog-model"; 90 91 96 97 public final static String INNER_GRAPH_VIEW_BINDING = "inner-graph-view"; 98 99 103 104 public final static String DIALOG_VIEW_LISTENERS_BINDING = "dialog-listeners"; 105 106 109 110 private Configuration configuration; 111 112 115 116 private DialogModel model; 117 118 121 122 private JComponent innerGraphView; 123 124 127 128 private Map listeners; 129 130 private JPanel innerGraphPanel; 131 132 private JTextField nameField; 133 134 private JTextField typeField; 135 136 private JTextField classField; 137 139 private JTable [] itfTable; 140 141 private JComboBox contingencyComboBox; 142 143 private JComboBox cardinalityComboBox; 144 145 private JButton [] itfAddButton; 146 147 private JButton [] itfRemoveButton; 148 149 private JTable attrTable; 150 151 private JButton attrAddButton; 152 153 private JButton attrRemoveButton; 154 155 private JButton classFieldButton; 156 157 private JTextField attrControllerField; 158 159 private JTextField tmplDescField; 160 161 private JTextField compDescField; 162 163 private ActionListener buttonListener; 164 165 private ListSelectionListener listListener; 166 167 private ClassFieldButtonListener classFieldButtonListener; 168 169 173 176 177 public BasicDialogView () { 178 listeners = new HashMap (); 179 180 itfTable = new JTable [2]; 181 itfAddButton = new JButton [2]; 182 itfRemoveButton = new JButton [2]; 183 buttonListener = new ButtonListener(); 184 classFieldButtonListener = new ClassFieldButtonListener (); 185 listListener = new ListListener(); 186 187 GridBagLayout bagLayout = new GridBagLayout (); 188 setLayout(bagLayout); 189 190 JPanel hPanel = createHeaderPanel(); 191 192 contingencyComboBox = new JComboBox (); 193 contingencyComboBox.addItem("mandatory"); 194 contingencyComboBox.addItem("optional"); 195 196 cardinalityComboBox = new JComboBox (); 197 cardinalityComboBox.addItem("single"); 198 cardinalityComboBox.addItem("collection"); 199 200 JPanel cPanel = new JPanel (); 201 cPanel.setLayout(new BorderLayout ()); 202 cPanel.add(new JLabel ("Client interfaces"), "North"); 203 cPanel.add(createInterfacesPanel(0), "Center"); 204 205 JPanel sPanel = new JPanel (); 206 sPanel.setLayout(new BorderLayout ()); 207 sPanel.add(new JLabel ("Server interfaces"), "North"); 208 sPanel.add(createInterfacesPanel(1), "Center"); 209 210 JPanel aPanel = new JPanel (); 211 aPanel.setLayout(new BorderLayout ()); 212 aPanel.add(new JLabel ("Attributes"), "North"); 213 aPanel.add(createAttributesPanel(), "Center"); 214 215 JPanel bPanel = createControllerPanel(); 216 217 GridBagConstraints constraints = new GridBagConstraints (); 218 constraints.insets = new Insets (3, 3, 3, 3); 219 constraints.gridy = 1; 220 constraints.fill = GridBagConstraints.HORIZONTAL; 221 constraints.weightx = 1; 222 constraints.weighty = 0; 223 bagLayout.setConstraints(hPanel, constraints); 224 add(hPanel); 225 226 constraints.gridy = 2; 227 constraints.fill = GridBagConstraints.BOTH; 228 constraints.weighty = 1; 229 bagLayout.setConstraints(sPanel, constraints); 230 add(sPanel); 231 232 constraints.gridy = 3; 233 constraints.weighty = 2; 234 bagLayout.setConstraints(cPanel, constraints); 235 add(cPanel); 236 237 constraints.gridy = 4; 238 constraints.weighty = 1; 239 bagLayout.setConstraints(aPanel, constraints); 240 add(aPanel); 241 242 constraints.gridy = 5; 243 constraints.fill = GridBagConstraints.HORIZONTAL; 244 constraints.weighty = 0; 245 bagLayout.setConstraints(bPanel, constraints); 246 add(bPanel); 247 } 248 249 254 255 private JPanel createHeaderPanel () { 256 JPanel panel = new JPanel (); 257 258 GridBagLayout bagLayout = new GridBagLayout (); 259 panel.setLayout(bagLayout); 260 261 GridBagConstraints constraints = new GridBagConstraints (); 262 JLabel label = new JLabel ("Name", SwingConstants.LEFT); 263 constraints.fill = GridBagConstraints.NONE; 264 constraints.anchor = GridBagConstraints.NORTHWEST; 265 bagLayout.setConstraints(label, constraints); 266 panel.add(label); 267 268 nameField = new JTextField (30); 269 constraints.fill = GridBagConstraints.HORIZONTAL; 270 constraints.weightx = 1; 271 bagLayout.setConstraints(nameField, constraints); 272 panel.add(nameField); 273 274 label = new JLabel ("Type ", SwingConstants.LEFT); 275 constraints.gridy = 1; 276 constraints.fill = GridBagConstraints.NONE; 277 constraints.anchor = GridBagConstraints.NORTHWEST; 278 constraints.weightx = 0; 279 bagLayout.setConstraints(label, constraints); 280 panel.add(label); 281 282 typeField = new JTextField (30); 283 constraints.fill = GridBagConstraints.HORIZONTAL; 284 constraints.weightx = 1; 285 bagLayout.setConstraints(typeField, constraints); 286 panel.add(typeField); 287 288 label = new JLabel ("Class ", SwingConstants.LEFT); 289 constraints.gridy = 2; 290 constraints.fill = GridBagConstraints.NONE; 291 constraints.weightx = 0; 292 bagLayout.setConstraints(label, constraints); 293 panel.add(label); 294 295 classField = new JTextField (49); 296 305 JPanel classPanel = new JPanel (new BorderLayout ()); 306 classFieldButton = new JButton ("Impl."); 307 classFieldButton.setBackground(new Color (204, 255, 204)); 308 classFieldButton.setPreferredSize(new Dimension (80, 20)); 309 classFieldButton.addActionListener(classFieldButtonListener); 310 classPanel.add(classField, BorderLayout.WEST); 311 classPanel.add(classFieldButton, BorderLayout.EAST); 312 constraints.fill = GridBagConstraints.HORIZONTAL; 313 constraints.weightx = 1; 314 bagLayout.setConstraints(classPanel, constraints); 315 panel.add(classPanel); 316 317 return panel; 318 } 319 320 326 327 private JPanel createInterfacesPanel (final int i) { 328 itfTable[i] = new JTable (); 329 JScrollPane scrollPane = new JScrollPane (itfTable[i]); 330 itfTable[i].setDefaultRenderer( 331 Object .class, 332 new InterfaceTableCellRenderer()); 333 334 itfAddButton[i] = new JButton ("Add"); 335 itfAddButton[i].addActionListener(buttonListener); 336 itfRemoveButton[i] = new JButton ("Remove"); 337 itfRemoveButton[i].addActionListener(buttonListener); 338 itfRemoveButton[i].setEnabled(false); 339 340 JPanel panel = new JPanel (); 341 GridBagLayout bagLayout = new GridBagLayout (); 342 panel.setLayout(bagLayout); 343 344 GridBagConstraints constraints = new GridBagConstraints (); 345 constraints.gridheight = GridBagConstraints.REMAINDER; 346 constraints.fill = GridBagConstraints.BOTH; 347 constraints.weightx = 1; 348 constraints.weighty = 1; 349 bagLayout.setConstraints(scrollPane, constraints); 350 panel.add(scrollPane); 351 352 constraints.gridx = 1; 353 constraints.gridy = 0; 354 constraints.gridheight = 1; 355 constraints.fill = GridBagConstraints.HORIZONTAL; 356 constraints.weightx = 0; 357 constraints.weighty = 0; 358 bagLayout.setConstraints(itfAddButton[i], constraints); 359 panel.add(itfAddButton[i]); 360 361 constraints.gridx = 1; 362 constraints.gridy = 1; 363 bagLayout.setConstraints(itfRemoveButton[i], constraints); 364 panel.add(itfRemoveButton[i]); 365 366 constraints.gridx = 1; 367 constraints.gridy = 2; 368 constraints.gridheight = GridBagConstraints.REMAINDER; 369 constraints.fill = GridBagConstraints.BOTH; 370 JPanel emptyPanel = new JPanel (); 371 bagLayout.setConstraints(emptyPanel, constraints); 372 panel.add(emptyPanel); 373 374 return panel; 375 } 376 377 383 384 private JPanel createAttributesPanel () { 385 attrTable = new JTable (); 386 JScrollPane scrollPane = new JScrollPane (attrTable); 387 388 attrAddButton = new JButton ("Add"); 389 attrAddButton.addActionListener(buttonListener); 390 attrRemoveButton = new JButton ("Remove"); 391 attrRemoveButton.addActionListener(buttonListener); 392 attrRemoveButton.setEnabled(false); 393 394 JPanel panel = new JPanel (); 395 GridBagLayout bagLayout = new GridBagLayout (); 396 panel.setLayout(bagLayout); 397 398 GridBagConstraints constraints = new GridBagConstraints (); 399 constraints.gridheight = GridBagConstraints.REMAINDER; 400 constraints.fill = GridBagConstraints.BOTH; 401 constraints.weightx = 1; 402 constraints.weighty = 1; 403 bagLayout.setConstraints(scrollPane, constraints); 404 panel.add(scrollPane); 405 406 constraints.gridx = 1; 407 constraints.gridy = 0; 408 constraints.gridheight = 1; 409 constraints.fill = GridBagConstraints.HORIZONTAL; 410 constraints.weightx = 0; 411 constraints.weighty = 0; 412 bagLayout.setConstraints(attrAddButton, constraints); 413 panel.add(attrAddButton); 414 415 constraints.gridx = 1; 416 constraints.gridy = 1; 417 bagLayout.setConstraints(attrRemoveButton, constraints); 418 panel.add(attrRemoveButton); 419 420 constraints.gridx = 1; 421 constraints.gridy = 2; 422 constraints.gridheight = GridBagConstraints.REMAINDER; 423 constraints.fill = GridBagConstraints.BOTH; 424 JPanel emptyPanel = new JPanel (); 425 bagLayout.setConstraints(emptyPanel, constraints); 426 panel.add(emptyPanel); 427 428 return panel; 429 } 430 431 437 438 private JPanel createControllerPanel () { 439 JPanel panel = new JPanel (); 440 441 GridBagLayout bagLayout = new GridBagLayout (); 442 panel.setLayout(bagLayout); 443 444 GridBagConstraints constraints = new GridBagConstraints (); 445 446 JLabel label = new JLabel ("Attribute controller:", SwingConstants.LEFT); 447 constraints.fill = GridBagConstraints.NONE; 448 constraints.anchor = GridBagConstraints.NORTHWEST; 449 constraints.insets = new Insets (0, 0, 0, 3); 450 bagLayout.setConstraints(label, constraints); 451 panel.add(label); 452 453 attrControllerField = new JTextField (); 454 constraints.fill = GridBagConstraints.HORIZONTAL; 455 constraints.insets = new Insets (0, 0, 0, 0); 456 constraints.weightx = 1; 457 bagLayout.setConstraints(attrControllerField, constraints); 458 panel.add(attrControllerField); 459 460 label = new JLabel ("Template controller descriptor:", SwingConstants.LEFT); 461 constraints.gridy = 1; 462 constraints.fill = GridBagConstraints.NONE; 463 constraints.anchor = GridBagConstraints.NORTHWEST; 464 constraints.insets = new Insets (0, 0, 0, 3); 465 constraints.weightx = 0; 466 bagLayout.setConstraints(label, constraints); 467 panel.add(label); 468 469 tmplDescField = new JTextField (); 470 constraints.fill = GridBagConstraints.HORIZONTAL; 471 constraints.insets = new Insets (0, 0, 0, 0); 472 constraints.weightx = 1; 473 bagLayout.setConstraints(tmplDescField, constraints); 474 panel.add(tmplDescField); 475 476 label = new JLabel ("Component controller descriptor:", SwingConstants.LEFT); 477 constraints.gridy = 2; 478 constraints.fill = GridBagConstraints.NONE; 479 constraints.insets = new Insets (0, 0, 0, 3); 480 constraints.weightx = 0; 481 bagLayout.setConstraints(label, constraints); 482 panel.add(label); 483 484 compDescField = new JTextField (); 485 constraints.fill = GridBagConstraints.HORIZONTAL; 486 constraints.insets = new Insets (0, 0, 0, 0); 487 constraints.weightx = 1; 488 bagLayout.setConstraints(compDescField, constraints); 489 panel.add(compDescField); 490 491 return panel; 492 } 493 494 498 public String [] listFc () { 499 int size = listeners.size(); 500 String [] names = new String [size + 3]; 501 listeners.keySet().toArray(names); 502 names[size] = CONFIGURATION_BINDING; 503 names[size + 1] = DIALOG_MODEL_BINDING; 504 names[size + 2] = INNER_GRAPH_VIEW_BINDING; 505 return names; 506 } 507 508 public Object lookupFc (final String clientItfName) { 509 if (CONFIGURATION_BINDING.equals(clientItfName)) { 510 return configuration; 511 } else if (DIALOG_MODEL_BINDING.equals(clientItfName)) { 512 return model; 513 } else if (INNER_GRAPH_VIEW_BINDING.equals(clientItfName)) { 514 return innerGraphView; 515 } else if (clientItfName.startsWith(DIALOG_VIEW_LISTENERS_BINDING)) { 516 return listeners.get(clientItfName); 517 } 518 return null; 519 } 520 521 public void bindFc ( 522 final String clientItfName, 523 final Object serverItf) 524 { 525 if (CONFIGURATION_BINDING.equals(clientItfName)) { 526 configuration = (Configuration) serverItf; 527 } else if (DIALOG_MODEL_BINDING.equals(clientItfName)) { 528 model = (DialogModel)serverItf; 529 for (int i = 0; i < 2; ++i) { 530 if (i == 0) { 531 itfTable[i].setModel(model.getClientInterfacesTableModel()); 532 itfTable[i].setSelectionModel( 533 model.getClientInterfacesTableSelectionModel()); 534 } else { 535 itfTable[i].setModel(model.getServerInterfacesTableModel()); 536 itfTable[i].setSelectionModel( 537 model.getServerInterfacesTableSelectionModel()); 538 } 539 itfTable[i].getColumn("Contingency").setCellEditor( 540 new DefaultCellEditor (contingencyComboBox)); 541 itfTable[i].getColumn("Cardinality").setCellEditor( 542 new DefaultCellEditor (cardinalityComboBox)); 543 itfTable[i].getColumn("Name").setPreferredWidth(1000); 547 itfTable[i].getColumn("Signature").setPreferredWidth(4000); 548 itfTable[i].getColumn("Contingency").setPreferredWidth(1000); 549 itfTable[i].getColumn("Cardinality").setPreferredWidth(1000); 550 itfTable[i].getSelectionModel().addListSelectionListener(listListener); 551 } 552 attrTable.setModel(model.getAttributesTableModel()); 553 attrTable.setSelectionModel(model.getAttributesTableSelectionModel()); 554 attrTable.getSelectionModel().addListSelectionListener(listListener); 555 nameField.setDocument(model.getNameFieldModel()); 556 typeField.setDocument(model.getTypeFieldModel()); 557 classField.setDocument(model.getImplementationFieldModel()); 558 attrControllerField.setDocument(model.getAttrControllerFieldModel()); 559 tmplDescField.setDocument(model.getTmplControllerDescFieldModel()); 560 compDescField.setDocument(model.getCompControllerDescFieldModel()); 561 } else if (INNER_GRAPH_VIEW_BINDING.equals(clientItfName)) { 562 innerGraphView = (JComponent )serverItf; 563 564 innerGraphPanel = new JPanel (); 565 innerGraphPanel.setLayout(new BorderLayout ()); 566 innerGraphPanel.setBorder(BorderFactory.createLoweredBevelBorder()); 567 innerGraphPanel.add(innerGraphView, "Center"); 568 569 GridBagLayout bagLayout = (GridBagLayout )getLayout(); 570 GridBagConstraints constraints = new GridBagConstraints (); 571 constraints.insets = new Insets (3, 3, 3, 3); 572 constraints.fill = GridBagConstraints.BOTH; 573 constraints.weightx = 1; 574 constraints.weighty = 6; 575 bagLayout.setConstraints(innerGraphPanel, constraints); 576 add(innerGraphPanel); 577 } else if (clientItfName.startsWith(DIALOG_VIEW_LISTENERS_BINDING)) { 578 listeners.put(clientItfName, serverItf); 579 } 580 } 581 582 public void unbindFc (final String clientItfName) { 583 if (CONFIGURATION_BINDING.equals(clientItfName)) { 584 configuration = null; 585 } else if (DIALOG_MODEL_BINDING.equals(clientItfName)) { 586 model = null; 587 } else if (INNER_GRAPH_VIEW_BINDING.equals(clientItfName)) { 588 innerGraphView = null; 589 remove(innerGraphPanel); 590 } else if (clientItfName.startsWith(DIALOG_VIEW_LISTENERS_BINDING)) { 591 listeners.remove(clientItfName); 592 } 593 } 594 595 599 public void changeCountChanged (Component component, long changeCount) { 600 } 602 603 public void rootComponentChanged (final Component oldValue) { 604 statusChanged(); 605 } 606 607 public void nameChanged (final Component component, final String oldValue) { 608 if (component == configuration.getRootComponent()) { 609 statusChanged(); 610 } 611 } 612 613 public void typeChanged (final Component component, final String oldValue) { 614 if (component == configuration.getRootComponent()) { 615 statusChanged(); 616 } 617 } 618 619 public void implementationChanged ( 620 final Component component, 621 final String oldValue) 622 { 623 if (component == configuration.getRootComponent()) { 624 statusChanged(); 625 } 626 } 627 628 public void interfaceNameChanged (final Interface i, final String oldValue) { 629 } 631 632 public void interfaceSignatureChanged ( 633 final Interface i, 634 final String oldValue) 635 { 636 } 638 639 public void interfaceContingencyChanged ( 640 final Interface i, 641 final boolean oldValue) 642 { 643 } 645 646 public void interfaceCardinalityChanged ( 647 final Interface i, 648 final boolean oldValue) 649 { 650 } 652 653 public void clientInterfaceAdded ( 654 final Component component, 655 final ClientInterface i, 656 final int index) 657 { 658 } 660 661 public void clientInterfaceRemoved ( 662 final Component component, 663 final ClientInterface i, 664 final int index) 665 { 666 } 668 669 public void serverInterfaceAdded ( 670 final Component component, 671 final ServerInterface i, 672 final int index) 673 { 674 } 676 677 public void serverInterfaceRemoved ( 678 final Component component, 679 final ServerInterface i, 680 final int index) 681 { 682 } 684 685 public void interfaceBound ( 686 final ClientInterface citf, 687 final ServerInterface sitf) 688 { 689 } 691 692 public void interfaceRebound ( 693 final ClientInterface citf, 694 final ServerInterface oldSitf) 695 { 696 } 698 699 public void interfaceUnbound ( 700 final ClientInterface citf, 701 final ServerInterface sitf) 702 { 703 } 705 706 public void attributeControllerChanged ( 707 final Component component, 708 final String oldValue) 709 { 710 if (component == configuration.getRootComponent()) { 711 statusChanged(); 712 } 713 } 714 715 public void attributeChanged ( 716 final Component component, 717 final String attributeName, 718 final String oldValue) 719 { 720 if (component == configuration.getRootComponent()) { 721 statusChanged(); 722 } 723 } 724 725 public void templateControllerDescriptorChanged ( 726 final Component component, 727 final String oldValue) 728 { 729 } 731 732 public void componentControllerDescriptorChanged ( 733 final Component component, 734 final String oldValue) 735 { 736 } 738 739 public void subComponentAdded ( 740 final Component parent, 741 final Component child, 742 final int index) 743 { 744 if (parent == configuration.getRootComponent()) { 745 statusChanged(); 746 } 747 } 748 749 public void subComponentRemoved ( 750 final Component parent, 751 final Component child, 752 final int index) 753 { 754 if (parent == configuration.getRootComponent()) { 755 statusChanged(); 756 } 757 } 758 759 764 765 private void statusChanged () { 766 long status = configuration.getRootComponent().getStatus(); 767 nameField.setBackground( 768 (status & Component.NAME_MISSING) == 0 ? 769 Color.white : 770 Constants.ERROR_COLOR); 771 775 classField.setBackground( 776 (status & Component.IMPLEMENTATION_MISSING) == 0 ? 777 Color.white : 778 Constants.ERROR_COLOR); 779 classField.setForeground( 780 (status & Component.IMPLEMENTATION_CLASS_NOT_FOUND) == 0 ? 781 Color.black : 782 Constants.ERROR_COLOR); 783 attrControllerField.setBackground( 784 (status & Component.ATTRIBUTE_CONTROLLER_MISSING) == 0 ? 785 Color.white : 786 Constants.ERROR_COLOR); 787 attrControllerField.setForeground( 788 (status & Component.ATTRIBUTE_CONTROLLER_CLASS_NOT_FOUND) == 0 ? 789 Color.black : 790 Constants.ERROR_COLOR); 791 } 792 793 797 public void setVisible (final boolean visible) { 798 super.setVisible(visible); 799 if (innerGraphView != null) { 800 innerGraphView.setVisible(visible); 801 } 802 } 803 804 808 809 class ButtonListener implements ActionListener { 810 811 public void actionPerformed (final ActionEvent e) { 812 Object o = e.getSource(); 813 List listeners = new ArrayList (BasicDialogView.this.listeners.values()); 814 if (o == itfAddButton[0]) { 815 for (int i = 0; i < listeners.size(); ++i) { 816 DialogViewListener l = (DialogViewListener)listeners.get(i); 817 l.addClientInterfaceButtonClicked(); 818 } 819 } else if (o == itfAddButton[1]) { 820 for (int i = 0; i < listeners.size(); ++i) { 821 DialogViewListener l = (DialogViewListener)listeners.get(i); 822 l.addServerInterfaceButtonClicked(); 823 } 824 } else if (o == itfRemoveButton[0]) { 825 for (int i = 0; i < listeners.size(); ++i) { 826 DialogViewListener l = (DialogViewListener)listeners.get(i); 827 l.removeClientInterfaceButtonClicked(); 828 } 829 itfRemoveButton[0].setEnabled(false); 830 } else if (o == itfRemoveButton[1]) { 831 for (int i = 0; i < listeners.size(); ++i) { 832 DialogViewListener l = (DialogViewListener)listeners.get(i); 833 l.removeServerInterfaceButtonClicked(); 834 } 835 itfRemoveButton[1].setEnabled(false); 836 } else if (o == attrAddButton) { 837 for (int i = 0; i < listeners.size(); ++i) { 838 DialogViewListener l = (DialogViewListener)listeners.get(i); 839 l.addAttributeButtonClicked(); 840 } 841 } else if (o == attrRemoveButton) { 842 for (int i = 0; i < listeners.size(); ++i) { 843 DialogViewListener l = (DialogViewListener)listeners.get(i); 844 l.removeAttributeButtonClicked(); 845 } 846 } 847 } 848 } 849 850 854 855 class ListListener implements ListSelectionListener { 856 857 public void valueChanged (final ListSelectionEvent e) { 858 ListSelectionModel l; 859 l = model.getClientInterfacesTableSelectionModel(); 860 if (e.getSource() == l) { 861 itfRemoveButton[0].setEnabled(!l.isSelectionEmpty()); 862 } 863 l = model.getServerInterfacesTableSelectionModel(); 864 if (e.getSource() == l) { 865 itfRemoveButton[1].setEnabled(!l.isSelectionEmpty()); 866 } 867 l = model.getAttributesTableSelectionModel(); 868 if (e.getSource() == l) { 869 attrRemoveButton.setEnabled(!l.isSelectionEmpty()); 870 } 871 } 872 } 873 874 877 878 class ClassFieldButtonListener implements ActionListener { 879 public void actionPerformed (final ActionEvent e) { 880 if (e.getActionCommand().equals("Impl.")) { 881 String st = ClassSelector.initSelector(); 882 if (st.length() < 1) classField.setText(st); 883 else { 884 int i = st.indexOf(".class"); 885 if (i < 0) { 886 classField.setText(st); 887 } else { 888 classField.setText(st.substring(0, i)); 889 } 890 } 891 statusChanged (); 892 } 893 } 894 } 895 } 896 | Popular Tags |