Changeset 8840


Ignore:
Timestamp:
2004-12-17T10:35:25+13:00 (19 years ago)
Author:
kjdon
Message:

added the buttons to the SuggestedPLuginsDialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r8835 r8840  
    12401240    private class PluginSuggestionPrompt
    12411241    extends ModalDialog
     1242    implements ActionListener
    12421243    {
    1243     private Dimension size = new Dimension(400, 150);
     1244    private Dimension size = new Dimension(400, 200);
     1245    private GComboBox suitable_plugins_combobox = null;
     1246    private GLIButton add_button = null;
     1247    private GLIButton ignore_button = null;
    12441248
    12451249    public PluginSuggestionPrompt(String filename, ArrayList suitable_plugins)
     
    12651269        suitable_plugins_label.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
    12661270
    1267         GComboBox suitable_plugins_combobox = new GComboBox(suitable_plugins);
     1271        suitable_plugins_combobox = new GComboBox(suitable_plugins);
    12681272        suitable_plugins_combobox.setBackgroundNonSelectionColor(Configuration.getColor("coloring.editable_background", false));
    12691273        suitable_plugins_combobox.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false));
     
    12721276
    12731277        JPanel suitable_plugins_pane = new JPanel();
    1274         suitable_plugins_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
     1278        //suitable_plugins_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
    12751279        suitable_plugins_pane.setLayout(new BorderLayout(5,0));
    12761280        suitable_plugins_pane.add(suitable_plugins_label, BorderLayout.WEST);
    12771281        suitable_plugins_pane.add(suitable_plugins_combobox, BorderLayout.CENTER);
    12781282
     1283        add_button = new GLIButton();
     1284        Dictionary.setBoth(add_button, "CDM.PlugInManager.Add", "CDM.PlugInManager.Add_Tooltip");
     1285        ignore_button = new GLIButton();
     1286        Dictionary.setBoth(ignore_button, "CDM.PlugInManager.Ignore","CDM.PlugInManager.Ignore_tooltip" );
     1287
     1288        add_button.addActionListener(this);
     1289        ignore_button.addActionListener(this);
     1290
     1291        JPanel button_pane = new JPanel();
     1292        button_pane.setLayout(new GridLayout(1,2,5,0));
     1293        button_pane.add(add_button);
     1294        button_pane.add(ignore_button);
     1295
     1296        JPanel controls_pane = new JPanel();
     1297        controls_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
     1298        controls_pane.setLayout(new GridLayout(2,1,0,5));
     1299        controls_pane.add(suitable_plugins_pane);
     1300        controls_pane.add(button_pane);
     1301
    12791302        JPanel content_pane = (JPanel) getContentPane();
    12801303        content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    12811304        content_pane.setLayout(new BorderLayout());
    1282         content_pane.add(instructions_textarea, BorderLayout.NORTH);
    1283         content_pane.add(suitable_plugins_pane, BorderLayout.SOUTH);
     1305        content_pane.add(instructions_textarea, BorderLayout.CENTER);
     1306        content_pane.add(controls_pane, BorderLayout.SOUTH);
    12841307
    12851308        // Show
     
    12881311        setVisible(true);
    12891312    }
     1313
     1314    public void actionPerformed(ActionEvent event) {
     1315       
     1316        if(event.getSource() == add_button) {
     1317        // add the selected plugin to the list
     1318        Object selected_object = suitable_plugins_combobox.getSelectedItem();
     1319        Plugin base_plugin = getBasePlugin(selected_object.toString());
     1320
     1321        // Create a new element in the DOM
     1322        Element element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.PLUGIN_ELEMENT);
     1323        // Remember that the plugin supplied might be a custom string rather than a base plugin
     1324        Plugin new_plugin = null;
     1325        if(base_plugin != null) {
     1326            //DebugStream.println("New Plugin based on existing Plugin");
     1327            element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, base_plugin.getName());
     1328            new_plugin = new Plugin(element, base_plugin);
     1329        }
     1330        else {
     1331            //DebugStream.println("New Custom Plugin");
     1332            element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, selected_object.toString());
     1333            new_plugin = new Plugin(element, null);
     1334        }
     1335        assignPlugin(new_plugin);
     1336        } // else do nothing
     1337       
     1338        // close the dialog
     1339        setVisible(false);
     1340    }
     1341
    12901342    }
    12911343
Note: See TracChangeset for help on using the changeset viewer.