Example usage for java.beans EventHandler create

List of usage examples for java.beans EventHandler create

Introduction

In this page you can find the example usage for java.beans EventHandler create.

Prototype

public static <T> T create(Class<T> listenerInterface, Object target, String action) 

Source Link

Document

Creates an implementation of listenerInterface in which all of the methods in the listener interface apply the handler's action to the target .

Usage

From source file:org.orbisgis.view.map.mapsManager.TreeLeafMapContextFile.java

@Override
public void feedPopupMenu(JPopupMenu menu) {
    super.feedPopupMenu(menu);
    if (!isLoaded()) {
        JMenuItem folderRemove = new JMenuItem(I18N.tr("Delete"), OrbisGISIcon.getIcon("remove"));
        folderRemove.setToolTipText(I18N.tr("Remove permanently the map"));
        folderRemove.setActionCommand("delete");
        folderRemove.addActionListener(EventHandler.create(ActionListener.class, this, "onDeleteFile"));
        MenuCommonFunctions.updateOrInsertMenuItem(menu, folderRemove);
    }//from  www. j a  v a2 s.c  om
}

From source file:org.orbisgis.view.sqlconsole.ui.SQLConsolePanel.java

/**
 * Create actions instances/*from  ww w.j av a2 s .  c  om*/
 * 
 * Each action is put in the Popup menu and the tool bar
 * Their shortcuts are registered also in the editor
 */
private void initActions() {
    //Execute Action
    executeAction = new DefaultAction(SQLAction.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Run SQL statements"),
            OrbisGISIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom");
    actions.addAction(executeAction);
    //Clear action
    clearAction = new DefaultAction(SQLAction.A_CLEAR, I18N.tr("Clear"),
            I18N.tr("Erase the content of the editor"), OrbisGISIcon.getIcon("erase"),
            EventHandler.create(ActionListener.class, this, "onClear"), null).setLogicalGroup("custom")
                    .setAfter(SQLAction.A_EXECUTE);
    actions.addAction(clearAction);
    //Find action
    findAction = new DefaultAction(SQLAction.A_SEARCH, I18N.tr("Search.."),
            I18N.tr("Search text in the document"), OrbisGISIcon.getIcon("find"),
            EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"),
            KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK))
                    .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK))
                    .setLogicalGroup("custom");
    actions.addAction(findAction);

    //Quote
    quoteAction = new DefaultAction(SQLAction.A_QUOTE, I18N.tr("Quote"), I18N.tr("Quote selected text"), null,
            EventHandler.create(ActionListener.class, this, "onQuote"),
            KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, InputEvent.SHIFT_DOWN_MASK)).setLogicalGroup("format");
    actions.addAction(quoteAction);
    //unQuote
    unQuoteAction = new DefaultAction(SQLAction.A_UNQUOTE, I18N.tr("Un Quote"),
            I18N.tr("Un Quote selected text"), null,
            EventHandler.create(ActionListener.class, this, "onUnQuote"),
            KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, InputEvent.SHIFT_DOWN_MASK))
                    .setLogicalGroup("format");
    actions.addAction(unQuoteAction);

    //Format SQL
    formatSQLAction = new DefaultAction(SQLAction.A_FORMAT, I18N.tr("Format"), I18N.tr("Format editor content"),
            null, EventHandler.create(ActionListener.class, this, "onFormatCode"),
            KeyStroke.getKeyStroke("alt shift F")).setLogicalGroup("format");
    actions.addAction(formatSQLAction);

    //Save
    saveAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save"),
            I18N.tr("Save the editor content into a file"), OrbisGISIcon.getIcon("save"),
            EventHandler.create(ActionListener.class, this, "onSaveFile"),
            KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom");
    actions.addAction(saveAction);
    //Open action
    actions.addAction(
            new DefaultAction(SQLAction.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"),
                    OrbisGISIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"),
                    KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK))
                            .setLogicalGroup("custom"));
    //ShowHide function list
    actions.addAction(new DefaultAction(SQLAction.A_SQL_LIST, I18N.tr("SQL list"),
            I18N.tr("Show/Hide SQL function list"), OrbisGISIcon.getIcon("builtinfunctionmap"),
            EventHandler.create(ActionListener.class, sqlFunctionsPanel, "switchPanelVisibilityState"), null)
                    .setLogicalGroup("custom"));
}

From source file:org.orbisgis.view.sqlconsole.ui.SQLConsolePanel.java

private RTextScrollPane getCenterPanel() {
    if (centerPanel == null) {
        scriptPanel = new RSyntaxTextArea();
        scriptPanel.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_SQL);
        scriptPanel.setLineWrap(true);//from ww  w. j av  a 2s . co  m
        scriptPanel.setClearWhitespaceLinesEnabled(true);
        scriptPanel.setMarkOccurrences(false);
        actions.setAccelerators(scriptPanel);
        lang = new SQLLanguageSupport();
        lang.install(scriptPanel);

        codeReformator = new CodeReformator(";", COMMENT_SPECS);
        scriptPanel
                .addCaretListener(EventHandler.create(CaretListener.class, this, "onScriptPanelCaretUpdate"));
        scriptPanel.getDocument().addDocumentListener(
                EventHandler.create(DocumentListener.class, this, "onUserSelectionChange"));

        //Add custom actions
        scriptPanel.getPopupMenu().addSeparator();
        actions.registerContainer(scriptPanel.getPopupMenu());
        centerPanel = new RTextScrollPane(scriptPanel);
        onUserSelectionChange();
    }
    return centerPanel;
}

From source file:org.orbisgis.view.toc.actions.cui.legend.ui.PnlAbstractCategorized.java

/**
 * Retrieve the panel that gathers all the components needed to create the classification.
 * @return The panel gathering the graphic elements that can be used to create the classification.
 *//*from   w  w  w  .jav a2s. c om*/
public JPanel getCreateClassificationPanel() {
    if (numberCombo == null) {
        numberCombo = new WideComboBox<>(getThresholdsNumber());
    }
    comboModel = (DefaultComboBoxModel) numberCombo.getModel();
    createCl = new JButton(I18N.tr("Create"));
    createCl.setActionCommand("click");
    createCl.addActionListener(EventHandler.create(ActionListener.class, this, "onComputeClassification"));
    createCl.setEnabled(false);

    JPanel inner = new JPanel(new MigLayout("wrap 2", "[align r][align l]"));

    inner.add(new JLabel(I18N.tr("Method")));
    inner.add(getMethodCombo(), "width ::130");
    inner.add(new JLabel(I18N.tr("Classes")));
    inner.add(numberCombo, "split 2");
    inner.add(createCl, "gapleft push");

    JPanel outside = new JPanel(new MigLayout("wrap 1", "[" + AbsPanel.FIXED_WIDTH + ", align c]"));
    outside.setBorder(BorderFactory.createTitledBorder(I18N.tr(CLASSIFICATION_SETTINGS)));
    if (colorConfig == null) {
        ArrayList<String> names = new ArrayList<String>(ColorScheme.rangeColorSchemeNames());
        names.addAll(ColorScheme.discreteColorSchemeNames());
        colorConfig = new ColorConfigurationPanel(names);
    }
    outside.add(new JLabel(I18N.tr("Color scheme:")), "align l");
    outside.add(colorConfig, "growx");
    outside.add(inner, "growx");
    return outside;
}

From source file:org.orbisgis.view.toc.actions.cui.legend.ui.PnlAbstractCategorized.java

/**
 * Gets the JComboBox used to select the classification method.
 * @return The JComboBox./*from  ww  w  .  j  av a2  s  .  com*/
 */
public JComboBox getMethodCombo() {
    if (methodCombo == null) {
        ContainerItemProperties[] categorizeMethods = getCategorizeMethods();
        methodCombo = new WideComboBox(categorizeMethods);
        methodCombo.addActionListener(EventHandler.create(ActionListener.class, this, "methodChanged"));
        methodCombo.setSelectedItem(CategorizeMethod.MANUAL.toString());
    }
    methodChanged();
    return methodCombo;
}

From source file:org.orbisgis.view.toc.actions.cui.legends.ui.PnlAbstractCategorized.java

/**
 * Retrieve the panel that gathers all the components needed to create the classification.
 * @return The panel gathering the graphic elements that can be used to create the classification.
 *///from   ww  w . j  a  v a2 s.  com
public JPanel getCreateClassificationPanel() {
    if (numberCombo == null) {
        numberCombo = new WideComboBox(getThresholdsNumber());
    }
    comboModel = (DefaultComboBoxModel) numberCombo.getModel();
    createCl = new JButton(I18N.tr("Create"));
    createCl.setActionCommand("click");
    createCl.addActionListener(EventHandler.create(ActionListener.class, this, "onComputeClassification"));
    createCl.setEnabled(false);

    JPanel inner = new JPanel(new MigLayout("wrap 2", "[align r][align l]"));

    inner.add(new JLabel(I18N.tr("Method")));
    inner.add(getMethodCombo(), "width ::130");
    inner.add(new JLabel(I18N.tr("Classes")));
    inner.add(numberCombo, "split 2");
    inner.add(createCl, "gapleft push");

    JPanel outside = new JPanel(new MigLayout("wrap 1", "[" + AbsPanel.FIXED_WIDTH + ", align c]"));
    outside.setBorder(BorderFactory.createTitledBorder(I18N.tr(CLASSIFICATION_SETTINGS)));
    if (colorConfig == null) {
        ArrayList<String> names = new ArrayList<String>(ColorScheme.rangeColorSchemeNames());
        names.addAll(ColorScheme.discreteColorSchemeNames());
        colorConfig = new ColorConfigurationPanel(names);
    }
    outside.add(new JLabel(I18N.tr("Color scheme:")), "align l");
    outside.add(colorConfig, "growx");
    outside.add(inner, "growx");
    return outside;
}