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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations