Search in sources :

Example 6 with ActionListener

use of java.awt.event.ActionListener in project antlrworks by antlr.

the class AWPrefsDialog method prepareGeneralTab.

public void prepareGeneralTab() {
    browseOutputPathButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            if (XJFileChooser.shared().displayChooseDirectory(getJavaContainer())) {
                outputPathField.setText(XJFileChooser.shared().getSelectedFilePath());
                AWPrefs.setOutputPath(outputPathField.getText());
            }
        }
    });
    browseDotToolPathButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            if (XJFileChooser.shared().displayOpenDialog(getJavaContainer(), false)) {
                dotToolPathField.setText(XJFileChooser.shared().getSelectedFilePath());
                AWPrefs.setDOTToolPath(dotToolPathField.getText());
            }
        }
    });
    lafCombo.removeAllItems();
    UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo anInfo : info) {
        lafCombo.addItem(anInfo.getName());
    }
    lafCombo.setEnabled(true);
    getPreferences().bindToPreferences(startupActionCombo, AWPrefs.PREF_STARTUP_ACTION, AWPrefs.STARTUP_OPEN_LAST_OPENED_DOC);
    getPreferences().bindToPreferences(restoreWindowsBoundButton, AWPrefs.PREF_RESTORE_WINDOWS, AWPrefs.DEFAULT_RESTORE_WINDOWS);
    getPreferences().bindToPreferences(lafCombo, AWPrefs.PREF_LOOK_AND_FEEL, XJLookAndFeel.getDefaultLookAndFeelName());
    getPreferences().bindToPreferences(desktopModeButton, AWPrefs.PREF_DESKTOP_MODE, AWPrefs.DEFAULT_DESKTOP_MODE);
    getPreferences().bindToPreferences(outputPathField, AWPrefs.PREF_OUTPUT_PATH, AWPrefs.DEFAULT_OUTPUT_PATH);
    getPreferences().bindToPreferences(dotToolPathField, AWPrefs.PREF_DOT_TOOL_PATH, AWPrefs.DEFAULT_DOT_TOOL_PATH);
    getPreferences().bindToPreferences(antlr3OptionsField, AWPrefs.PREF_ANTLR3_OPTIONS, AWPrefs.DEFAULT_ANTLR3_OPTIONS);
// General - debug only
//getPreferences().bindToPreferences(debugVerboseButton, AWPrefs.PREF_DEBUG_VERBOSE, false);
//getPreferences().bindToPreferences(debugDontOptimizeNFA, AWPrefs.PREF_DEBUG_DONT_OPTIMIZE_NFA, false);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 7 with ActionListener

use of java.awt.event.ActionListener in project antlrworks by antlr.

the class FindAndReplaceDialog method addEscapeHandling.

public void addEscapeHandling() {
    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true);
    ActionListener cancelAction = new AbstractAction() {

        public void actionPerformed(ActionEvent ae) {
            setVisible(false);
        }
    };
    getRootPane().registerKeyboardAction(cancelAction, "CancelAction", ks, JComponent.WHEN_IN_FOCUSED_WINDOW);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 8 with ActionListener

use of java.awt.event.ActionListener in project antlrworks by antlr.

the class FindAndReplaceDialog method createActions.

public void createActions() {
    nextButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            delegate.setFindString(findField.getText());
            alertEndOfDocument(this, delegate.next());
        }
    });
    previousButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            delegate.setFindString(findField.getText());
            alertBeginningOfDocument(this, delegate.prev());
        }
    });
    replaceButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            delegate.setReplaceString(replaceField.getText());
            delegate.replace();
        }
    });
    replaceAndFindButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            delegate.setFindString(findField.getText());
            delegate.setReplaceString(replaceField.getText());
            delegate.replace();
            alertEndOfDocument(this, delegate.next());
        }
    });
    replaceAllButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            delegate.setFindString(findField.getText());
            delegate.setReplaceString(replaceField.getText());
            delegate.replaceAll();
        }
    });
    ignoreCaseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            delegate.setIgnoreCase(ignoreCaseButton.isSelected());
        }
    });
    regexButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            delegate.setRegex(regexButton.isSelected());
        }
    });
    optionsCombo.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            delegate.setOptions(optionsCombo.getSelectedIndex());
        }
    });
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 9 with ActionListener

use of java.awt.event.ActionListener in project antlrworks by antlr.

the class NewWizardDialog method initComponents.

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Ryan Paul Talusan
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    label1 = new JLabel();
    grammarNameField = new JTextField();
    label2 = new JLabel();
    grammarTypeComboBox = new JComboBox();
    lexicalItemPanel = new JPanel();
    lexLeftPanel = new JPanel();
    cbIdentifier = new JCheckBox();
    cbInteger = new JCheckBox();
    cbFloat = new JCheckBox();
    cbComments = new JCheckBox();
    commentsPanel = new JPanel();
    cbSingleLine = new JCheckBox();
    cbMultiLine = new JCheckBox();
    lexRightPanel = new JPanel();
    cbString = new JCheckBox();
    stringPanel = new JPanel();
    singleQuoteRadio = new JRadioButton();
    doubleQuoteRadio = new JRadioButton();
    cbCharacters = new JCheckBox();
    cbWhiteSpace = new JCheckBox();
    wsPanel = new JPanel();
    cbTabChar = new JCheckBox();
    cbNewlineChar = new JCheckBox();
    cbCarriageReturnChar = new JCheckBox();
    buttonBar = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();
    CellConstraints cc = new CellConstraints();
    //======== this ========
    setTitle("New Grammar Wizard");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    //======== dialogPane ========
    {
        dialogPane.setBorder(Borders.DIALOG_BORDER);
        dialogPane.setLayout(new BorderLayout());
        //======== contentPanel ========
        {
            contentPanel.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.RIGHT, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW) }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.UNRELATED_GAP_ROWSPEC, new RowSpec(RowSpec.TOP, Sizes.DEFAULT, RowSpec.DEFAULT_GROW) }));
            //---- label1 ----
            label1.setText("Grammar Name:");
            contentPanel.add(label1, cc.xy(3, 1));
            contentPanel.add(grammarNameField, cc.xywh(5, 1, 3, 1));
            //---- label2 ----
            label2.setText("Type:");
            contentPanel.add(label2, cc.xy(3, 3));
            //---- grammarTypeComboBox ----
            grammarTypeComboBox.setModel(new DefaultComboBoxModel(new String[] { "Parser", "Lexer", "Tree Grammar", "Combined Grammar" }));
            grammarTypeComboBox.setSelectedIndex(3);
            grammarTypeComboBox.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    switch(grammarTypeComboBox.getSelectedIndex()) {
                        case GRAMMAR_TYPE_PARSER:
                        case GRAMMAR_TYPE_TREE_GRAMMAR:
                            cbIdentifier.setEnabled(false);
                            cbInteger.setEnabled(false);
                            cbFloat.setEnabled(false);
                            cbComments.setEnabled(false);
                            cbSingleLine.setEnabled(false);
                            cbMultiLine.setEnabled(false);
                            cbString.setEnabled(false);
                            cbCharacters.setEnabled(false);
                            cbWhiteSpace.setEnabled(false);
                            cbTabChar.setEnabled(false);
                            cbNewlineChar.setEnabled(false);
                            cbCarriageReturnChar.setEnabled(false);
                            break;
                        case GRAMMAR_TYPE_LEXER:
                        case GRAMMAR_TYPE_COMBINED_GRAMMAR:
                            cbIdentifier.setEnabled(true);
                            cbInteger.setEnabled(true);
                            cbFloat.setEnabled(true);
                            cbComments.setEnabled(true);
                            if (cbComments.isSelected()) {
                                cbSingleLine.setEnabled(true);
                                cbMultiLine.setEnabled(true);
                            }
                            cbString.setEnabled(true);
                            cbCharacters.setEnabled(true);
                            cbWhiteSpace.setEnabled(true);
                            if (cbWhiteSpace.isSelected()) {
                                cbTabChar.setEnabled(true);
                                cbNewlineChar.setEnabled(true);
                                cbCarriageReturnChar.setEnabled(true);
                            }
                            break;
                    }
                }
            });
            contentPanel.add(grammarTypeComboBox, cc.xy(5, 3));
            //======== lexicalItemPanel ========
            {
                lexicalItemPanel.setBorder(new TitledBorder(null, "Lexical Items", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION));
                lexicalItemPanel.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW) }, new RowSpec[] { new RowSpec(RowSpec.TOP, Sizes.DEFAULT, RowSpec.DEFAULT_GROW) }));
                //======== lexLeftPanel ========
                {
                    lexLeftPanel.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(ColumnSpec.DEFAULT, Sizes.dluX(10), FormSpec.NO_GROW), new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW) }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC }));
                    //---- cbIdentifier ----
                    cbIdentifier.setText("Identifier");
                    lexLeftPanel.add(cbIdentifier, cc.xywh(1, 1, 2, 1));
                    //---- cbInteger ----
                    cbInteger.setText("Integer");
                    lexLeftPanel.add(cbInteger, cc.xywh(1, 3, 2, 1));
                    //---- cbFloat ----
                    cbFloat.setText("Float");
                    lexLeftPanel.add(cbFloat, cc.xywh(1, 5, 2, 1));
                    //---- cbComments ----
                    cbComments.setText("Comments");
                    lexLeftPanel.add(cbComments, cc.xywh(1, 7, 2, 1));
                    cbComments.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent event) {
                            if (cbComments.isSelected()) {
                                cbSingleLine.setEnabled(true);
                                cbMultiLine.setEnabled(true);
                            } else {
                                cbSingleLine.setEnabled(false);
                                cbMultiLine.setEnabled(false);
                            }
                        }
                    });
                    //======== commentsPanel ========
                    {
                        commentsPanel.setBorder(new TitledBorder(null, null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION));
                        commentsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC }));
                        //---- cbSingleLine ----
                        cbSingleLine.setText("Single-line ( //... )");
                        cbSingleLine.setEnabled(false);
                        cbSingleLine.setSelected(true);
                        commentsPanel.add(cbSingleLine, cc.xy(1, 1));
                        cbSingleLine.addActionListener(new ActionListener() {

                            public void actionPerformed(ActionEvent event) {
                                if (!cbSingleLine.isSelected() && !cbMultiLine.isSelected()) {
                                    cbComments.setSelected(false);
                                    cbSingleLine.setEnabled(false);
                                    cbMultiLine.setEnabled(false);
                                    cbSingleLine.setSelected(true);
                                    cbMultiLine.setSelected(true);
                                }
                            }
                        });
                        //---- cbMultiLine ----
                        cbMultiLine.setText("Multi-line ( /* .. */ )");
                        cbMultiLine.setEnabled(false);
                        cbMultiLine.setSelected(true);
                        commentsPanel.add(cbMultiLine, cc.xy(1, 3));
                        cbMultiLine.addActionListener(new ActionListener() {

                            public void actionPerformed(ActionEvent event) {
                                if (!cbSingleLine.isSelected() && !cbMultiLine.isSelected()) {
                                    cbComments.setSelected(false);
                                    cbSingleLine.setEnabled(false);
                                    cbMultiLine.setEnabled(false);
                                    cbSingleLine.setSelected(true);
                                    cbMultiLine.setSelected(true);
                                }
                            }
                        });
                    }
                    lexLeftPanel.add(commentsPanel, cc.xy(2, 9));
                }
                lexicalItemPanel.add(lexLeftPanel, cc.xy(1, 1));
                //======== lexRightPanel ========
                {
                    lexRightPanel.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(ColumnSpec.DEFAULT, Sizes.dluX(10), FormSpec.NO_GROW), new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW) }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC }));
                    //---- cbString ----
                    cbString.setText("String");
                    lexRightPanel.add(cbString, cc.xywh(1, 1, 2, 1));
                    cbString.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent event) {
                            if (cbString.isSelected()) {
                                singleQuoteRadio.setEnabled(true);
                                doubleQuoteRadio.setEnabled(true);
                            } else {
                                singleQuoteRadio.setEnabled(false);
                                doubleQuoteRadio.setEnabled(false);
                            }
                        }
                    });
                    //======== stringPanel ========
                    {
                        stringPanel.setBorder(new EtchedBorder());
                        stringPanel.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC }));
                        //---- singleQuoteRadio ----
                        singleQuoteRadio.setText("Single quotes ( 'sample string' )");
                        singleQuoteRadio.setEnabled(false);
                        stringPanel.add(singleQuoteRadio, cc.xy(1, 1));
                        //---- doubleQuoteRadio ----
                        doubleQuoteRadio.setText("Double quotes ( \"sample string\" )");
                        doubleQuoteRadio.setEnabled(false);
                        doubleQuoteRadio.setSelected(true);
                        stringPanel.add(doubleQuoteRadio, cc.xy(1, 3));
                    }
                    lexRightPanel.add(stringPanel, cc.xy(2, 3));
                    //---- cbCharacters ----
                    cbCharacters.setText("Character");
                    lexRightPanel.add(cbCharacters, cc.xywh(1, 5, 2, 1));
                    //---- cbWhiteSpace ----
                    cbWhiteSpace.setText("White Space");
                    lexRightPanel.add(cbWhiteSpace, cc.xywh(1, 7, 3, 1));
                    //======== wsPanel ========
                    {
                        wsPanel.setBorder(new EtchedBorder());
                        wsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC }));
                        //---- cbTabChar ----
                        cbTabChar.setText("Tab character ( /t )");
                        cbTabChar.setEnabled(false);
                        cbTabChar.setSelected(true);
                        wsPanel.add(cbTabChar, cc.xy(1, 1));
                        //---- cbNewlineChar ----
                        cbNewlineChar.setText("Newline character ( /n )");
                        cbNewlineChar.setEnabled(false);
                        cbNewlineChar.setSelected(true);
                        wsPanel.add(cbNewlineChar, cc.xy(1, 3));
                        //---- cbCarriageReturnChar ----
                        cbCarriageReturnChar.setText("Carriage-return character ( /r )");
                        cbCarriageReturnChar.setEnabled(false);
                        cbCarriageReturnChar.setSelected(true);
                        wsPanel.add(cbCarriageReturnChar, cc.xy(1, 5));
                    }
                    lexRightPanel.add(wsPanel, cc.xy(2, 9));
                }
                lexicalItemPanel.add(lexRightPanel, cc.xy(3, 1));
            }
            contentPanel.add(lexicalItemPanel, cc.xywh(3, 5, 5, 1));
        }
        dialogPane.add(contentPanel, BorderLayout.CENTER);
        //======== buttonBar ========
        {
            buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER);
            buttonBar.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.GLUE_COLSPEC, FormFactory.BUTTON_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.BUTTON_COLSPEC }, RowSpec.decodeSpecs("pref")));
            //---- okButton ----
            okButton.setText("OK");
            buttonBar.add(okButton, cc.xy(2, 1));
            //---- cancelButton ----
            cancelButton.setText("Cancel");
            buttonBar.add(cancelButton, cc.xy(4, 1));
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    pack();
    //---- buttonGroup1 ----
    ButtonGroup buttonGroup1 = new ButtonGroup();
    buttonGroup1.add(singleQuoteRadio);
    buttonGroup1.add(doubleQuoteRadio);
// JFormDesigner - End of component initialization  //GEN-END:initComponents
}
Also used : ActionEvent(java.awt.event.ActionEvent) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener)

Example 10 with ActionListener

use of java.awt.event.ActionListener in project antlrworks by antlr.

the class InterpreterTab method createRunButton.

public JButton createRunButton() {
    JButton button = XJRollOverButton.createMediumButton(IconManager.shared().getIconRun());
    button.setToolTipText("Run");
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            if (AWPrefs.isAlertInterpreterLimitation()) {
                XJAlert alert = XJAlert.createInstance();
                alert.setDisplayDoNotShowAgainButton(true);
                alert.showSimple(getContainer(), "Warning", "The interpreterTab does not run actions nor evaluate syntactic predicates." + "\nUse the debugger if you want to use these ANTLR features.");
                AWPrefs.setAlertInterpreterLimitation(!alert.isDoNotShowAgain());
            }
            StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_INTERPRETER_BUTTON);
            interpret();
        }
    });
    return button;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) XJAlert(org.antlr.xjlib.appkit.utils.XJAlert)

Aggregations

ActionListener (java.awt.event.ActionListener)1347 ActionEvent (java.awt.event.ActionEvent)1303 JButton (javax.swing.JButton)363 JPanel (javax.swing.JPanel)345 JLabel (javax.swing.JLabel)234 JMenuItem (javax.swing.JMenuItem)191 BoxLayout (javax.swing.BoxLayout)150 GridBagConstraints (java.awt.GridBagConstraints)121 Insets (java.awt.Insets)121 GridBagLayout (java.awt.GridBagLayout)114 Dimension (java.awt.Dimension)113 FlowLayout (java.awt.FlowLayout)110 JCheckBox (javax.swing.JCheckBox)103 JScrollPane (javax.swing.JScrollPane)103 JMenu (javax.swing.JMenu)96 BorderLayout (java.awt.BorderLayout)88 JTextField (javax.swing.JTextField)79 JComboBox (javax.swing.JComboBox)73 ButtonGroup (javax.swing.ButtonGroup)64 ArrayList (java.util.ArrayList)60