Search in sources :

Example 6 with DocumentEvent

use of javax.swing.event.DocumentEvent in project gephi by gephi.

the class DataTableTopComponent method initEvents.

private void initEvents() {
    //Workspace Listener
    pc.addWorkspaceListener(new WorkspaceListener() {

        @Override
        public void initialize(Workspace workspace) {
            //Prepare DataTablesEvent listener
            Lookup.getDefault().lookup(DataTablesController.class).setDataTablesEventListener(DataTableTopComponent.this);
            if (workspace.getLookup().lookup(DataTablesModel.class) == null) {
                workspace.add(new DataTablesModel(workspace));
            }
        }

        @Override
        public void select(Workspace workspace) {
            activateWorkspace(workspace);
            setAutoRefreshEnabled(true);
        }

        @Override
        public void unselect(Workspace workspace) {
            deactivateAll();
            setAutoRefreshEnabled(false);
        }

        @Override
        public void close(Workspace workspace) {
        }

        @Override
        public void disable() {
            clearAll();
            //No more workspaces active, disable the DataTablesEvent listener
            Lookup.getDefault().lookup(DataTablesController.class).setDataTablesEventListener(null);
            setAutoRefreshEnabled(false);
        }
    });
    if (pc.getCurrentWorkspace() != null) {
        activateWorkspace(pc.getCurrentWorkspace());
        setAutoRefreshEnabled(true);
    }
    observersTimer = new java.util.Timer("DataLaboratoryGraphObservers");
    observersTimer.schedule(new TimerTask() {

        @Override
        public void run() {
            if (!autoRefreshEnabled) {
                return;
            }
            if (dataTablesObservers != null) {
                if (dataTablesObservers.hasChanges()) {
                    //Execute refresh
                    graphChanged();
                }
            }
        }
    }, 0, //Check graph and tables for changes every 100 ms
    AUTO_REFRESH_RATE_MILLISECONDS);
    //Filter
    if (dynamicFiltering) {
        filterTextField.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void insertUpdate(DocumentEvent e) {
                refreshAppliedFilter();
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                refreshAppliedFilter();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
    } else {
        filterTextField.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                refreshAppliedFilter();
            }
        });
    }
    columnComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            refreshAppliedFilter();
        }
    });
    initKeyEventContextMenuActionMappings();
}
Also used : DocumentListener(javax.swing.event.DocumentListener) WorkspaceListener(org.gephi.project.api.WorkspaceListener) TimerTask(java.util.TimerTask) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentEvent(javax.swing.event.DocumentEvent) Workspace(org.gephi.project.api.Workspace)

Example 7 with DocumentEvent

use of javax.swing.event.DocumentEvent in project gradle by gradle.

the class SearchPanel method createTextToMatchField.

private Component createTextToMatchField() {
    textToMatchField = new JTextField();
    textToMatchField.setMinimumSize(new Dimension(50, 10));
    //escape closes this dialog
    textToMatchField.registerKeyboardAction(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
    //hook up the key strokes that perform the search
    ActionListener performSearchNextAction = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            goToNextMatch();
        }
    };
    //hook up the key strokes that perform the search
    ActionListener performSearchPreviousAction = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            goToPreviousMatch();
        }
    };
    textToMatchField.registerKeyboardAction(performSearchNextAction, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
    //F3 and Shift F3
    textToMatchField.registerKeyboardAction(performSearchNextAction, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
    textToMatchField.registerKeyboardAction(performSearchPreviousAction, KeyStroke.getKeyStroke(KeyEvent.VK_F3, KeyEvent.SHIFT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    //as the user types, perform a 'continue' search.
    textToMatchField.getDocument().addDocumentListener(new DocumentListener() {

        public void insertUpdate(DocumentEvent e) {
            requestSearch();
        }

        public void removeUpdate(DocumentEvent e) {
            requestSearch();
        }

        public void changedUpdate(DocumentEvent e) {
            requestSearch();
        }
    });
    return textToMatchField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentEvent(javax.swing.event.DocumentEvent)

Example 8 with DocumentEvent

use of javax.swing.event.DocumentEvent in project gradle by gradle.

the class SwingEditFavoriteInteraction method createMainPanel.

private Component createMainPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    fullCommandLineTextField = new JTextField();
    displayNameTextField = new JTextField();
    alwaysShowOutputCheckBox = new JCheckBox("Always Show Live Output");
    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Command Line")));
    panel.add(Utility.addLeftJustifiedComponent(fullCommandLineTextField));
    panel.add(Box.createVerticalStrut(10));
    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Display Name")));
    panel.add(Utility.addLeftJustifiedComponent(displayNameTextField));
    panel.add(Box.createVerticalStrut(10));
    panel.add(Utility.addLeftJustifiedComponent(alwaysShowOutputCheckBox));
    panel.add(Box.createVerticalGlue());
    //create some listeners that we can use for synchronization purposes.
    synchronizationDocumentListener = new DocumentListener() {

        public void insertUpdate(DocumentEvent documentEvent) {
            setDisplayNameTextToCommandLineText();
        }

        public void removeUpdate(DocumentEvent documentEvent) {
            setDisplayNameTextToCommandLineText();
        }

        public void changedUpdate(DocumentEvent documentEvent) {
            setDisplayNameTextToCommandLineText();
        }
    };
    synchronizationKeyAdapter = new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent keyEvent) {
            //the user typed something. Remove the document listener
            fullCommandLineTextField.getDocument().removeDocumentListener(synchronizationDocumentListener);
            //and we don't need this anymore either
            displayNameTextField.removeKeyListener(synchronizationKeyAdapter);
        }
    };
    return panel;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) DocumentEvent(javax.swing.event.DocumentEvent)

Example 9 with DocumentEvent

use of javax.swing.event.DocumentEvent in project zaproxy by zaproxy.

the class ManageAddOnsDialog method createFilterPanel.

private static JPanel createFilterPanel(final JXTable table) {
    JPanel filterPanel = new JPanel();
    filterPanel.setLayout(new GridBagLayout());
    JLabel filterLabel = new JLabel(Constant.messages.getString("cfu.label.addons.filter"));
    final JTextField filterTextField = new JTextField();
    filterLabel.setLabelFor(filterTextField);
    filterPanel.add(filterLabel, LayoutHelper.getGBC(0, 0, 1, 0.0D));
    filterPanel.add(filterTextField, LayoutHelper.getGBC(1, 0, 1, 1.0D));
    String tooltipText = Constant.messages.getString("cfu.label.addons.filter.tooltip");
    filterLabel.setToolTipText(tooltipText);
    filterTextField.setToolTipText(tooltipText);
    // Set filter listener
    filterTextField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateFilter();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateFilter();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateFilter();
        }

        public void updateFilter() {
            String filterText = filterTextField.getText();
            if (filterText.isEmpty()) {
                table.setRowFilter(null);
                filterTextField.setForeground(UIManager.getColor("TextField.foreground"));
            } else {
                try {
                    table.setRowFilter(RowFilter.regexFilter("(?i)" + filterText));
                    filterTextField.setForeground(UIManager.getColor("TextField.foreground"));
                } catch (PatternSyntaxException e) {
                    filterTextField.setForeground(Color.RED);
                }
            }
        }
    });
    return filterPanel;
}
Also used : JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 10 with DocumentEvent

use of javax.swing.event.DocumentEvent in project zaproxy by zaproxy.

the class DialogAddToken method getRegexTextField.

protected ZapTextField getRegexTextField() {
    if (regexTextField == null) {
        regexTextField = new ZapTextField(25);
        regexTextField.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void removeUpdate(DocumentEvent e) {
                checkAndEnableConfirmButton();
            }

            @Override
            public void insertUpdate(DocumentEvent e) {
                checkAndEnableConfirmButton();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
                checkAndEnableConfirmButton();
            }

            private void checkAndEnableConfirmButton() {
                setConfirmButtonEnabled(getRegexTextField().getDocument().getLength() > 0);
            }
        });
    }
    return regexTextField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ZapTextField(org.zaproxy.zap.utils.ZapTextField) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

DocumentEvent (javax.swing.event.DocumentEvent)122 DocumentAdapter (com.intellij.ui.DocumentAdapter)64 DocumentListener (javax.swing.event.DocumentListener)53 ActionEvent (java.awt.event.ActionEvent)34 ActionListener (java.awt.event.ActionListener)32 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)13 JPanel (javax.swing.JPanel)12 JTextField (javax.swing.JTextField)12 ItemEvent (java.awt.event.ItemEvent)10 ItemListener (java.awt.event.ItemListener)10 JButton (javax.swing.JButton)10 Document (javax.swing.text.Document)10 NotNull (org.jetbrains.annotations.NotNull)9 JLabel (javax.swing.JLabel)8 ChangeEvent (javax.swing.event.ChangeEvent)8 JCheckBox (javax.swing.JCheckBox)7 JTextComponent (javax.swing.text.JTextComponent)7 ZapTextField (org.zaproxy.zap.utils.ZapTextField)7 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6