use of java.awt.event.KeyEvent in project knime-core by knime.
the class JSnippetPanel method initComponents.
private void initComponents() {
m_colList = new JList(new DefaultListModel());
m_colList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_colList.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
Object selected = m_colList.getSelectedValue();
if (selected != null) {
onSelectionInColumnList(selected);
}
}
}
});
m_colList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
Object selected = m_colList.getSelectedValue();
if (selected != null) {
onSelectionInColumnList(selected);
}
}
}
});
m_colList.setCellRenderer(new ListRenderer());
m_flowVarsList = new JList(new DefaultListModel());
m_flowVarsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// enable tooltip
m_flowVarsList.setToolTipText("");
m_flowVarsList.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
Object selected = m_flowVarsList.getSelectedValue();
if (selected != null) {
onSelectionInVariableList(selected);
}
}
}
});
m_flowVarsList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
Object selected = m_flowVarsList.getSelectedValue();
if (selected != null) {
onSelectionInVariableList(selected);
}
}
}
});
m_flowVarsList.setCellRenderer(new FlowVariableListCellRenderer());
m_categories = new JComboBox(m_manipProvider.getCategories().toArray());
m_categories.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
JComboBox cb = (JComboBox) e.getSource();
String category = (String) cb.getSelectedItem();
updateManipulatorList(category);
}
});
m_manipulators = new JList(new DefaultListModel());
m_manipulators.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_manipulators.setCellRenderer(new ManipulatorListCellRenderer());
m_manipulators.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
Object selected = m_manipulators.getSelectedValue();
if (selected != null) {
onSelectionInManipulatorList(selected);
}
}
}
});
m_manipulators.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
Object selected = m_manipulators.getSelectedValue();
if (selected != null) {
onSelectionInManipulatorList(selected);
}
}
}
});
m_manipulators.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(final ListSelectionEvent e) {
Object selected = m_manipulators.getSelectedValue();
if (selected != null) {
Manipulator manipulator = (Manipulator) selected;
m_description.setText(manipulator.getDescription());
m_description.setCaretPosition(0);
} else {
m_description.setText("");
}
}
});
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet css = new StyleSheet();
css.addRule("* { font-family: sans-serif; }");
kit.setStyleSheet(css);
m_description = new JTextPane();
m_description.setEditorKit(kit);
m_description.setEditable(false);
m_description.setBackground(getBackground());
updateManipulatorList(ManipulatorProvider.ALL_CATEGORY);
initSubComponents();
}
use of java.awt.event.KeyEvent in project knime-core by knime.
the class ParameterizedDBQueryPanel method createColumnsAndVariablesPanel.
private JComponent createColumnsAndVariablesPanel() {
/* Create database column list */
final JPanel dbColumnsPanel = new JPanel(new BorderLayout());
dbColumnsPanel.setPreferredSize(new Dimension(200, 150));
final JLabel dbColumnsLabel = new JLabel("Database Column List");
dbColumnsLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
dbColumnsPanel.add(dbColumnsLabel, BorderLayout.NORTH);
dbColumnsPanel.add(new JScrollPane(m_dbColumnsList), BorderLayout.CENTER);
m_dbColumnsList.setCellRenderer(new DataColumnSpecListCellRenderer());
m_dbColumnsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_dbColumnsList.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent evt) {
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
onSelectionInDatabaseList();
}
}
});
m_dbColumnsList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent evt) {
if (evt.getClickCount() == 2) {
onSelectionInDatabaseList();
}
}
});
/* Create Knime column list */
final JPanel knimeColumnsPanel = new JPanel(new BorderLayout());
knimeColumnsPanel.setPreferredSize(new Dimension(200, 150));
final JLabel knimeColumnsLabel = new JLabel("Column List");
knimeColumnsLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
knimeColumnsPanel.add(knimeColumnsLabel, BorderLayout.NORTH);
knimeColumnsPanel.add(new JScrollPane(m_knimeColumnsList), BorderLayout.CENTER);
m_knimeColumnsList.setCellRenderer(new DataColumnSpecListCellRenderer());
m_knimeColumnsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_knimeColumnsList.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent evt) {
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
onSelectionInColumnList();
}
}
});
m_knimeColumnsList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent evt) {
if (evt.getClickCount() == 2) {
onSelectionInColumnList();
}
}
});
final JSplitPane columnsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
columnsSplitPane.setResizeWeight(0.5);
columnsSplitPane.setOneTouchExpandable(true);
columnsSplitPane.setDividerSize(8);
columnsSplitPane.setTopComponent(dbColumnsPanel);
columnsSplitPane.setBottomComponent(knimeColumnsPanel);
columnsSplitPane.setDividerLocation(150);
/* Create flow variables list*/
final JPanel variablesPanel = new JPanel(new BorderLayout());
variablesPanel.setPreferredSize(new Dimension(200, 150));
final JLabel variablesLabel = new JLabel("Flow Variable List");
variablesLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
variablesPanel.add(variablesLabel, BorderLayout.NORTH);
variablesPanel.add(new JScrollPane(m_flowVariablesList), BorderLayout.CENTER);
m_flowVariablesList.setCellRenderer(new FlowVariableListCellRenderer());
m_flowVariablesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_flowVariablesList.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent evt) {
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
onSelectionInFlowVariableList();
}
}
});
m_flowVariablesList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent evt) {
if (evt.getClickCount() == 2) {
onSelectionInFlowVariableList();
}
}
});
final JSplitPane columnsVariableSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
columnsVariableSplitPane.setResizeWeight(0.5);
columnsVariableSplitPane.setOneTouchExpandable(true);
columnsVariableSplitPane.setDividerSize(8);
columnsVariableSplitPane.setTopComponent(columnsSplitPane);
columnsVariableSplitPane.setBottomComponent(variablesPanel);
columnsVariableSplitPane.setDividerLocation(300);
return columnsVariableSplitPane;
}
use of java.awt.event.KeyEvent in project eclipse.platform.swt by eclipse.
the class Bug164015_G2DDrawImage method main.
public static void main(String[] args) {
/**
* create SWT GUI
*/
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("AWT_SWT Test");
Composite swtAwtComponent = new Composite(shell, SWT.EMBEDDED);
java.awt.Frame frame = SWT_AWT.new_Frame(swtAwtComponent);
final Bug164015_G2DDrawImage myJPanel = new Bug164015_G2DDrawImage();
frame.add(myJPanel);
frame.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
myJPanel.scroll(20, 0);
}
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
myJPanel.scroll(-20, 0);
}
if (e.getKeyCode() == KeyEvent.VK_UP) {
myJPanel.scroll(0, 20);
}
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
myJPanel.scroll(0, -20);
}
}
});
shell.setLayout(new FillLayout());
shell.pack();
shell.open();
shell.setMaximized(true);
try {
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} finally {
display.dispose();
System.err.println("EXITING NORMALLY!!");
}
}
use of java.awt.event.KeyEvent in project OsmAnd-tools by osmandapp.
the class OsmExtractionUI method updateStatusField.
private void updateStatusField(final JTextField statusField) {
popup = new JScrollPopupMenu();
popup.setMaximumVisibleRows(25);
popup.setFocusable(false);
searchUICore.setOnResultsComplete(new Runnable() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
updateSearchResult(statusField, searchUICore.getCurrentSearchResult(), true);
}
});
}
});
statusField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
// if(e.getOppositeComponent() != popup) {
// popup.setVisible(false);
// }
}
@Override
public void focusGained(FocusEvent e) {
popup.setFocusable(false);
SearchSettings settings = searchUICore.getPhrase().getSettings().setOriginalLocation(new LatLon(mapPanel.getLatitude(), mapPanel.getLongitude()));
settings = settings.setLang(DataExtractionSettings.getSettings().getSearchLocale(), false);
searchUICore.updateSettings(settings);
}
});
statusField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
super.keyPressed(e);
mapPanel.setStatusField(null);
if (e.getKeyCode() == KeyEvent.VK_DOWN && popup.getComponentCount() > 0) {
popup.setVisible(false);
popup.setFocusable(true);
Point p = statusField.getLocation();
popup.show(e.getComponent(), p.x, p.y - 4);
// popup.show();
popup.requestFocus();
return;
}
}
@Override
public void keyTyped(KeyEvent e) {
mapPanel.setStatusField(null);
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
return;
}
String text = statusField.getText();
int ps = statusField.getCaretPosition();
if (e.getKeyChar() == '\b') {
// nothing
} else if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) {
if (ps >= text.length()) {
text += e.getKeyChar();
} else {
text = text.substring(0, ps) + e.getKeyChar() + text.substring(ps);
}
}
SearchSettings settings = searchUICore.getPhrase().getSettings();
if (settings.getRadiusLevel() != 1) {
searchUICore.updateSettings(settings.setRadiusLevel(1));
}
SearchResultCollection c = null;
if (!text.contains("#map")) {
c = searchUICore.search(text, true, null);
}
if (c != null) {
updateSearchResult(statusField, c, false);
}
}
});
statusField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
mapPanel.setStatusField(statusField);
String txt = statusField.getText();
int i = txt.indexOf("#map=");
if (i != -1) {
String[] vs = txt.substring(i + "#map=".length()).split("/");
mapPanel.setLatLon(Float.parseFloat(vs[1]), Float.parseFloat(vs[2]));
mapPanel.setZoom(Integer.parseInt(vs[0]));
}
mapPanel.refresh();
}
});
}
use of java.awt.event.KeyEvent in project JWildfire by thargor6.
the class OperatorsInternalFrame method getTransformersFilterREd.
/**
* This method initializes transformersFilterREd
*
* @return javax.swing.JTextField
*/
private JTextField getTransformersFilterREd() {
if (transformersFilterREd == null) {
transformersFilterREd = new JTextField();
transformersFilterREd.setText("");
transformersFilterREd.setSize(new Dimension(235, 26));
transformersFilterREd.setLocation(new Point(50, 5));
transformersFilterREd.setFont(new Font("Dialog", Font.PLAIN, 12));
transformersFilterREd.setPreferredSize(new Dimension(200, 26));
transformersFilterREd.addKeyListener(new java.awt.event.KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
Vector<String> list = TransformersList.getItemVector();
Vector<String> filteredList;
String filter = transformersFilterREd.getText();
if ((filter != null) && (filter.length() > 0)) {
filteredList = new Vector<String>();
filter = filter.toLowerCase();
for (String item : list) {
if (((filter.length() <= 2) && (item.toLowerCase().indexOf(filter) == 0)) || ((filter.length() > 2) && (item.toLowerCase().indexOf(filter) >= 0))) {
filteredList.add(item);
}
}
} else
filteredList = list;
String selected = (String) transformersList.getSelectedValue();
if ((selected != null) && (filteredList.indexOf(selected) < 0))
selected = null;
transformersList.setListData(filteredList);
if (selected != null)
transformersList.setSelectedValue(selected, true);
else if (filteredList.size() == 1)
transformersList.setSelectedIndex(0);
else
transformersList.setSelectedIndex(-1);
}
});
}
return transformersFilterREd;
}
Aggregations