Changeset 6254
- Timestamp:
- 2003-12-12T17:55:02+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java
r6087 r6254 33 33 import javax.swing.*; 34 34 import javax.swing.event.*; 35 import javax.swing.plaf.*; 35 36 import javax.swing.plaf.basic.*; 36 37 import org.apache.xerces.parsers.*; … … 870 871 } 871 872 else { 872 configure.setEnabled(true); 873 // Some buttons are only available for plugins other than ArcPlug and RecPlug 874 PlugIn selected_plugin = (PlugIn) plugin_list.getSelectedValue(); 875 String plugin_name = selected_plugin.getName(); 876 if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR)) { 877 move_top_button.setEnabled(false); 878 move_up_button.setEnabled(false); 879 move_down_button.setEnabled(false); 880 move_bottom_button.setEnabled(false); 881 remove.setEnabled(false); 882 } 883 else { 884 // Move ups are only enabled if the selected plugin isn't already at the top 885 PlugIn first_plugin = (PlugIn) getElementAt(0); 886 if(!first_plugin.equals(selected_plugin)) { 887 move_top_button.setEnabled(true); 888 move_up_button.setEnabled(true); 889 } 890 else { 891 move_top_button.setEnabled(false); 892 move_up_button.setEnabled(false); 893 } 894 // And move downs are only allowed when the selected plugin isn't at an index one less than the separator line. 895 int separator_index = findSeparatorIndex(); 896 int selected_index = plugin_list.getSelectedIndex(); 897 if(selected_index != separator_index - 1) { 898 move_down_button.setEnabled(true); 899 move_bottom_button.setEnabled(true); 900 } 901 else { 902 move_down_button.setEnabled(false); 903 move_bottom_button.setEnabled(false); 904 } 905 remove.setEnabled(true); 906 } 907 selected_plugin = null; 908 plugin_name = null; 873 PlugIn selected_plugin = (PlugIn) plugin_list.getSelectedValue(); 874 if(selected_plugin.isSeparator()) { 875 move_top_button.setEnabled(false); 876 move_up_button.setEnabled(false); 877 move_down_button.setEnabled(false); 878 move_bottom_button.setEnabled(false); 879 configure.setEnabled(false); 880 remove.setEnabled(false); 881 } 882 else { 883 configure.setEnabled(true); 884 String plugin_name = selected_plugin.getName(); 885 // Some buttons are only available for plugins other than ArcPlug and RecPlug 886 if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR)) { 887 move_top_button.setEnabled(false); 888 move_up_button.setEnabled(false); 889 move_down_button.setEnabled(false); 890 move_bottom_button.setEnabled(false); 891 remove.setEnabled(false); 892 } 893 else { 894 // Move ups are only enabled if the selected plugin isn't already at the top 895 PlugIn first_plugin = (PlugIn) getElementAt(0); 896 if(!first_plugin.equals(selected_plugin)) { 897 move_top_button.setEnabled(true); 898 move_up_button.setEnabled(true); 899 } 900 else { 901 move_top_button.setEnabled(false); 902 move_up_button.setEnabled(false); 903 } 904 // And move downs are only allowed when the selected plugin isn't at an index one less than the separator line. 905 int separator_index = findSeparatorIndex(); 906 int selected_index = plugin_list.getSelectedIndex(); 907 if(selected_index != separator_index - 1) { 908 move_down_button.setEnabled(true); 909 move_bottom_button.setEnabled(true); 910 } 911 else { 912 move_down_button.setEnabled(false); 913 move_bottom_button.setEnabled(false); 914 } 915 remove.setEnabled(true); 916 } 917 selected_plugin = null; 918 plugin_name = null; 919 } 909 920 } 910 921 } … … 968 979 } 969 980 970 971 981 /** This listener reacts to changes in the current selection of the plugin combobox. */ 982 private class PlugInComboboxListener 972 983 implements ItemListener { 973 984 /** When a user selects a certain plugin, update the tooltip to show the plugin description. */ … … 989 1000 } 990 1001 } 991 1002 992 1003 /** This class listens for actions upon the remove button in the controls, and if detected calls the <i>removePlugIn()</i> method. 993 1004 */ 994 1005 private class RemoveListener 995 996 1006 implements ActionListener { 1007 /** Any implementation of <i>ActionListener</i> must include this method so that we can be informed when an action has occured on one of our target controls. 997 1008 * @param event An <strong>ActionEvent</strong> containing information garnered from the control action. 998 1009 */ … … 1025 1036 remove.setEnabled(false); 1026 1037 } 1027 /*1028 if(!plugin_list.isSelectionEmpty()) {1029 Object [] objects = plugin_list.getSelectedValues();1030 for(int i = 0; i < objects.length; i++) {1031 if(objects[i] instanceof PlugIn) {1032 removePlugIn((PlugIn)objects[i]);1033 }1034 }1035 // Refresh the available plugins1036 plugin.setModel(new DefaultComboBoxModel(getAvailable()));1037 }1038 */1039 1038 } 1040 1039 } 1041 1040 } 1042 1041 /** Creates a list separator. 1043 * Code courtesy of Farwell, Paul. Contact <a href="mailto:[email protected]">[email protected]</a>1044 */ 1045 staticprivate JPanel getSeparator() {1042 * Found on Google Groups. Code courtesy of Paul Farwell. 1043 */ 1044 private JPanel getSeparator() { 1046 1045 // We put the separator inside a panel to control its appearance 1047 1046 JPanel _sepPanel = new JPanel(); … … 1050 1049 _sepPanel.setLayout(new BoxLayout(_sepPanel, BoxLayout.Y_AXIS)); 1051 1050 _sepPanel.add(Box.createRigidArea(new Dimension(0, 4))); 1052 _sepPanel.add(new JPopupMenu.Separator()); 1051 // We have to be a little careful here, as the default UI for separators under MacOS is a blank box. Instead we force a BasicUI look 1052 _sepPanel.add(new BasicSeparator()); 1053 1053 _sepPanel.add(Box.createRigidArea(new Dimension(0, 4))); 1054 1054 return _sepPanel; 1055 1055 } 1056 1057 /** This class behaves just like a normal JSeparator except that, no matter what the current settings in the UIManager are, it always paints itself with BasicSeparatorUI. */ 1058 private class BasicSeparator 1059 extends JSeparator { 1060 1061 private ComponentUI basic_ui; 1062 1063 public BasicSeparator() { 1064 super(); 1065 basic_ui = new BasicSeparatorUI(); 1066 } 1067 1068 public void paintComponent(Graphics g) { 1069 if (basic_ui != null) { 1070 basic_ui.update(g, this); 1071 } 1072 } 1073 } 1056 1074 } 1075
Note:
See TracChangeset
for help on using the changeset viewer.