List of usage examples for java.awt.event KeyEvent VK_ENTER
int VK_ENTER
To view the source code for java.awt.event KeyEvent VK_ENTER.
Click Source Link
From source file:ome.formats.importer.gui.FileQueueChooser.java
/** * @param evt key pressed event//from w w w . java2 s.c o m */ public void keyPressed(KeyEvent evt) { Object src = evt.getSource(); int keyCode = evt.getKeyCode(); if (src == fileList && keyCode == KeyEvent.VK_ENTER) { File[] arr = getSelectedFiles(); if (arr.length == 1 && arr[0].isFile()) { approveSelection(); } } }
From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java
private void actionModifierAxe(MouseEvent e, final int index) { if (index == -1) return;/*from w ww . j a v a2 s.c om*/ Component comp = (Component) e.getSource(); JFrame frame = (JFrame) SwingUtilities.getRoot(comp); this.windowChangeNom = new JWindow(frame); Container container = this.windowChangeNom.getContentPane(); container.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.insets = new Insets(0, 0, 0, 0); c.weightx = 1; this.editedAxeIndex = index; this.text = new JTextField(" " + this.tabAxes.getTitleAt(index) + " "); this.text.setEditable(true); container.add(this.text, c); this.text.setBorder(null); // text.setBackground(this.tabAxes.getBackground()); this.text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_ENTER) { validAxeText(); } } }); this.windowChangeNom.pack(); int ecartY = this.tabAxes.getBoundsAt(index).height - this.text.getBounds().height + 2; int ecartX = this.tabAxes.getBoundsAt(index).width - this.text.getBounds().width; this.windowChangeNom.setLocation( comp.getLocationOnScreen().x + this.tabAxes.getBoundsAt(index).getLocation().x + ecartX / 2, comp.getLocationOnScreen().y + this.tabAxes.getBoundsAt(index).getLocation().y + ecartY / 2); this.windowChangeNom.setVisible(true); }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java
/** * This method initializes jTextFieldNewProjectName * //from w w w. j ava2 s.c o m * @return javax.swing.JTextField */ private JTextField getJTextFieldNewProjectName() { if (jTextFieldNewProjectName == null) { jTextFieldNewProjectName = new JTextField(); jTextFieldNewProjectName.setText(ProjectNamePolicy.getProjectNamePrefix()); jTextFieldNewProjectName.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent e) { setButtonState(); if (e.getKeyCode() == KeyEvent.VK_ENTER) { eventHandler.handleEvent(EventHandler.BTN_CHECK); } else { jTextFieldNewProjectName.setToolTipText(jTextFieldNewProjectName.getText()); } } }); } return jTextFieldNewProjectName; }
From source file:ru.goodfil.catalog.ui.forms.OePanel.java
private void tbSearchOeKeyPressed(KeyEvent e) { if (e != null) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { tbSearchOe.setText(""); }// ww w . j a v a 2 s.c o m if (e.getKeyCode() == KeyEvent.VK_ENTER) { btnSearchOeActionPerformed(null); } } adjustButtonsEnabled(); }
From source file:com.mirth.connect.client.ui.components.MirthTable.java
public void setCustomEditorControls(boolean enabled) { if (enabled) { // An action to toggle cell editing with the 'Enter' key. Action toggleEditing = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (isEditing()) { getCellEditor().stopCellEditing(); } else { boolean success = editCellAt(getSelectedRow(), getSelectedColumn(), e); if (success) { // Request focus for TextFieldCellEditors if (getCellEditor() instanceof TextFieldCellEditor) { ((TextFieldCellEditor) getCellEditor()).getTextField().requestFocusInWindow(); }/*from w w w . jav a2s. c o m*/ } } } }; /* * Don't edit cells on any keystroke. Let the toggleEditing action handle it for 'Enter' * only. Also surrender focus to any activated editor. */ setAutoStartEditOnKeyStroke(false); setSurrendersFocusOnKeystroke(true); getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "toggleEditing"); getActionMap().put("toggleEditing", toggleEditing); } else { setAutoStartEditOnKeyStroke(true); setSurrendersFocusOnKeystroke(false); getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "selectNextRowCell"); } }
From source file:org.mbari.aved.ui.classifier.knowledgebase.ConceptTree.java
/** * Sets up the various listeners needed for GUI interaction with this * <code>ConceptTree</code>. */// w w w. j a v a 2s. co m protected void setupListeners() { // Add context popup menu and right mouse button selection addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { // Selected item before showing popup menu if (event.getModifiers() == MouseEvent.BUTTON3_MASK) { int row = getRowForLocation(event.getX(), event.getY()); setSelectionRow(row); } } }); // Toggle expand/collapse on ENTER addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_ENTER) { int row = getSelectionRows()[0]; if (isCollapsed(row)) { expandRow(row); } else { collapseRow(row); } } } }); }
From source file:com._17od.upm.gui.MainWindow.java
private void addComponentsToPane() { // Ensure the layout manager is a BorderLayout if (!(getContentPane().getLayout() instanceof GridBagLayout)) { getContentPane().setLayout(new GridBagLayout()); }//from w w w . ja v a2 s.c o m // Create the menubar setJMenuBar(createMenuBar()); GridBagConstraints c = new GridBagConstraints(); // The toolbar Row c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; Component toolbar = createToolBar(); getContentPane().add(toolbar, c); // Keep the frame background color consistent getContentPane().setBackground(toolbar.getBackground()); // The seperator Row c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(new JSeparator(), c); // The search field row searchIcon = new JLabel(Util.loadImage("search.gif")); searchIcon.setDisabledIcon(Util.loadImage("search_d.gif")); searchIcon.setEnabled(false); c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(searchIcon, c); searchField = new JTextField(15); searchField.setEnabled(false); searchField.setMinimumSize(searchField.getPreferredSize()); searchField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { // This method never seems to be called } public void insertUpdate(DocumentEvent e) { dbActions.filter(); } public void removeUpdate(DocumentEvent e) { dbActions.filter(); } }); searchField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { dbActions.resetSearch(); } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { // If the user hits the enter key in the search field and // there's only one item // in the listview then open that item (this code assumes // that the one item in // the listview has already been selected. this is done // automatically in the // DatabaseActions.filter() method) if (accountsListview.getModel().getSize() == 1) { viewAccountMenuItem.doClick(); } } } }); c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(searchField, c); resetSearchButton = new JButton(Util.loadImage("stop.gif")); resetSearchButton.setDisabledIcon(Util.loadImage("stop_d.gif")); resetSearchButton.setEnabled(false); resetSearchButton.setToolTipText(Translator.translate(RESET_SEARCH_TXT)); resetSearchButton.setActionCommand(RESET_SEARCH_TXT); resetSearchButton.addActionListener(this); resetSearchButton.setBorder(BorderFactory.createEmptyBorder()); resetSearchButton.setFocusable(false); c.gridx = 2; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(resetSearchButton, c); // The accounts listview row accountsListview = new JList(); accountsListview.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); accountsListview.setSelectedIndex(0); accountsListview.setVisibleRowCount(10); accountsListview.setModel(new SortedListModel()); JScrollPane accountsScrollList = new JScrollPane(accountsListview, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); accountsListview.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { // If the listview gets focus, there is one ore more items in // the listview and there is nothing // already selected, then select the first item in the list if (accountsListview.getModel().getSize() > 0 && accountsListview.getSelectedIndex() == -1) { accountsListview.setSelectionInterval(0, 0); } } }); accountsListview.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { dbActions.setButtonState(); } }); accountsListview.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { viewAccountMenuItem.doClick(); } } }); accountsListview.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { viewAccountMenuItem.doClick(); } } }); // Create a shortcut to delete account functionality with DEL(delete) // key accountsListview.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { try { dbActions.reloadDatabaseBefore(new DeleteAccountAction()); } catch (InvalidPasswordException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ProblemReadingDatabaseFile e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); c.gridx = 0; c.gridy = 3; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1; c.weighty = 1; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; getContentPane().add(accountsScrollList, c); // The "File Changed" panel c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 0, 1); c.ipadx = 3; c.ipady = 3; c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; databaseFileChangedPanel = new JPanel(); databaseFileChangedPanel.setLayout(new BoxLayout(databaseFileChangedPanel, BoxLayout.X_AXIS)); databaseFileChangedPanel.setBackground(new Color(249, 172, 60)); databaseFileChangedPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); JLabel fileChangedLabel = new JLabel("Database file changed"); fileChangedLabel.setAlignmentX(LEFT_ALIGNMENT); databaseFileChangedPanel.add(fileChangedLabel); databaseFileChangedPanel.add(Box.createHorizontalGlue()); JButton reloadButton = new JButton("Reload"); reloadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { dbActions.reloadDatabaseFromDisk(); } catch (Exception ex) { dbActions.errorHandler(ex); } } }); databaseFileChangedPanel.add(reloadButton); databaseFileChangedPanel.setVisible(false); getContentPane().add(databaseFileChangedPanel, c); // Add the statusbar c.gridx = 0; c.gridy = 5; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(statusBar, c); }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java
/** * Creates a panel containing a text field used to search * @return/* ww w. ja va2 s . c om*/ */ private JPanel createSearchStringPanel() { JPanel searchStringPanel = new JPanel(); searchStringPanel.setLayout(new BorderLayout()); searchStringPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-search-string.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(4, 4, 4, 4))); searchStringField = new JTextField(27); searchStringField.setActionCommand("Search String:"); //$NON-NLS-1$ searchStringField.setCaretPosition(0); searchStringField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { executeSearch(); } } }); searchStringPanel.add(searchStringField, BorderLayout.NORTH); return searchStringPanel; }
From source file:xtrememp.PlaylistManager.java
private void initComponents() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);//w w w.ja va 2s.c om openPlaylistButton = new JButton(Utilities.DOCUMENT_OPEN_ICON); openPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.OpenPlaylist")); openPlaylistButton.addActionListener(this); toolBar.add(openPlaylistButton); savePlaylistButton = new JButton(Utilities.DOCUMENT_SAVE_ICON); savePlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.SavePlaylist")); savePlaylistButton.addActionListener(this); toolBar.add(savePlaylistButton); toolBar.addSeparator(); addToPlaylistButton = new JButton(Utilities.LIST_ADD_ICON); addToPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.AddToPlaylist")); addToPlaylistButton.addActionListener(this); toolBar.add(addToPlaylistButton); remFromPlaylistButton = new JButton(Utilities.LIST_REMOVE_ICON); remFromPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.RemoveFromPlaylist")); remFromPlaylistButton.addActionListener(this); remFromPlaylistButton.setEnabled(false); toolBar.add(remFromPlaylistButton); clearPlaylistButton = new JButton(Utilities.EDIT_CLEAR_ICON); clearPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.ClearPlaylist")); clearPlaylistButton.addActionListener(this); clearPlaylistButton.setEnabled(false); toolBar.add(clearPlaylistButton); toolBar.addSeparator(); moveUpButton = new JButton(Utilities.GO_UP_ICON); moveUpButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveUp")); moveUpButton.addActionListener(this); moveUpButton.setEnabled(false); toolBar.add(moveUpButton); moveDownButton = new JButton(Utilities.GO_DOWN_ICON); moveDownButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveDown")); moveDownButton.addActionListener(this); moveDownButton.setEnabled(false); toolBar.add(moveDownButton); toolBar.addSeparator(); mediaInfoButton = new JButton(Utilities.MEDIA_INFO_ICON); mediaInfoButton.setToolTipText(tr("MainFrame.PlaylistManager.MediaInfo")); mediaInfoButton.addActionListener(this); mediaInfoButton.setEnabled(false); toolBar.add(mediaInfoButton); toolBar.add(Box.createHorizontalGlue()); searchTextField = new SearchTextField(15); searchTextField.setMaximumSize(new Dimension(120, searchTextField.getPreferredSize().height)); searchTextField.getTextField().getDocument().addDocumentListener(new SearchFilterListener()); toolBar.add(searchTextField); toolBar.add(Box.createHorizontalStrut(6)); this.add(toolBar, BorderLayout.NORTH); playlistTable = new JTable(playlistTableModel, playlistTableColumnModel); playlistTable.setDefaultRenderer(String.class, new PlaylistCellRenderer()); playlistTable.setActionMap(null); playlistTable.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { if (SwingUtilities.isRightMouseButton(ev) || (MouseInfo.getNumberOfButtons() == 1 && ev.isControlDown())) { playlistTableColumnModel.getPopupMenu().show(playlistTable.getTableHeader(), ev.getX(), ev.getY()); return; } int clickedColumn = playlistTableColumnModel.getColumnIndexAtX(ev.getX()); PlaylistTableColumn playlistColumn = playlistTableColumnModel.getColumn(clickedColumn); playlistTableColumnModel.resetAll(playlistColumn.getModelIndex()); playlistColumn.setSortOrderUp(!playlistColumn.isSortOrderUp()); playlistTableModel.sort(playlistColumn.getComparator()); colorizeRow(); } }); playlistTable.setFillsViewportHeight(true); playlistTable.setShowGrid(false); playlistTable.setRowSelectionAllowed(true); playlistTable.setColumnSelectionAllowed(false); playlistTable.setDragEnabled(false); playlistTable.setFont(playlistTable.getFont().deriveFont(Font.BOLD)); playlistTable.setIntercellSpacing(new Dimension(0, 0)); playlistTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); playlistTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { int selectedRow = playlistTable.rowAtPoint(ev.getPoint()); if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) { if (selectedRow != -1) { playlist.setCursorPosition(selectedRow); controlListener.acOpenAndPlay(); } } } }); playlistTable.getSelectionModel().addListSelectionListener(this); playlistTable.getColumnModel().getSelectionModel().addListSelectionListener(this); playlistTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { // View Media Info if (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK) { viewMediaInfo(); } // Select all else if (e.getKeyCode() == KeyEvent.VK_A && e.getModifiers() == KeyEvent.CTRL_MASK) { playlistTable.selectAll(); } else if (e.getKeyCode() == KeyEvent.VK_UP) { // Move selected track(s) up if (e.getModifiers() == KeyEvent.ALT_MASK) { moveUp(); } // Select previous track else { if (playlistTable.getSelectedRow() > 0) { int previousRowIndex = playlistTable.getSelectedRow() - 1; playlistTable.clearSelection(); playlistTable.addRowSelectionInterval(previousRowIndex, previousRowIndex); makeRowVisible(previousRowIndex); } } } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { // Move selected track(s) down if (e.getModifiers() == KeyEvent.ALT_MASK) { moveDown(); } // Select next track else { if (playlistTable.getSelectedRow() < playlistTable.getRowCount() - 1) { int nextRowIndex = playlistTable.getSelectedRow() + 1; playlistTable.clearSelection(); playlistTable.addRowSelectionInterval(nextRowIndex, nextRowIndex); makeRowVisible(nextRowIndex); } } } // Play selected track else if (e.getKeyCode() == KeyEvent.VK_ENTER) { int selectedRow = playlistTable.getSelectedRow(); if (selectedRow != -1) { playlist.setCursorPosition(selectedRow); controlListener.acOpenAndPlay(); } } // Add new tracks else if (e.getKeyCode() == KeyEvent.VK_INSERT) { addFilesDialog(false); } // Delete selected tracks else if (e.getKeyCode() == KeyEvent.VK_DELETE) { remove(); } } }); XtremeMP.getInstance().getMainFrame().setDropTarget(new DropTarget(playlistTable, this)); JScrollPane ptScrollPane = new JScrollPane(playlistTable); ptScrollPane.setActionMap(null); this.add(ptScrollPane, BorderLayout.CENTER); }
From source file:org.signserver.admin.gui.MainView.java
public MainView(SingleFrameApplication app) { super(app);//from ww w.j av a 2 s. c om initComponents(); final int rowHeights = new JComboBox/*<String>*/().getPreferredSize().height; // workaround a bug in the NetBeans form editor where the download // archive entries button sometimes looses its default disabled state downloadArchiveEntriesButton.setEnabled(false); statusSummaryTextPane.setContentType("text/html"); auditlogConditionsModel.addCondition(AuditlogColumn.EVENTTYPE, RelationalOperator.NEQ, "ACCESS_CONTROL"); auditLogTable.setModel(auditlogModel); archiveTable.setModel(archiveModel); conditionsTable.setModel(auditlogConditionsModel); conditionsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { jButtonAuditConditionRemove.setEnabled(conditionsTable.getSelectedRowCount() > 0); } } }); jTabbedPane1.setSelectedComponent(mainPanel); archiveConditionsTable.setModel(archiveConditionsModel); archiveConditionsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { jButtonArchiveConditionRemove.setEnabled(archiveConditionsTable.getSelectedRowCount() > 0); } } }); tokenEntriesTable.setModel(tokenEntriesModel); tokenEntriesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final boolean exactlyOneSelected = tokenEntriesTable.getSelectedRowCount() == 1; final boolean anySelected = tokenEntriesTable.getSelectedRowCount() > 0; tokenEntriesTestButton.setEnabled(exactlyOneSelected); tokenEntriesGenerateCSRButton.setEnabled(anySelected); tokenEntriesImportButton.setEnabled(anySelected); tokenEntriesRemoveButton.setEnabled(exactlyOneSelected); tokenEntriesDetailsButton.setEnabled(exactlyOneSelected); } } }); final String action = "DetailsOnEnter"; KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); tokenEntriesTable.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(enter, action); tokenEntriesTable.getActionMap().put(action, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (tokenEntriesTable.getSelectedRows().length > 0) { tokenEntriesDetailsButton.doClick(); } } }); workersList.setCellRenderer(new MyListCellRenderer()); workersList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { selectedWorkers = new ArrayList<Worker>(); for (Object o : workersList.getSelectedValues()) { if (o instanceof Worker) { selectedWorkers.add((Worker) o); } } workerComboBox.setModel(new MyComboBoxModel(selectedWorkers)); // removeKey should only be enabled iff one selected removeKeyMenu.setEnabled(selectedWorkers.size() == 1); if (selectedWorkers.size() > 0) { if (LOG.isDebugEnabled()) { LOG.debug("Previously selected: " + selectedWorkerBeforeRefresh); } int comboBoxSelection = 0; // Try to set the previously selected if (selectedWorkerBeforeRefresh != null) { comboBoxSelection = selectedWorkers.indexOf(selectedWorkerBeforeRefresh); if (comboBoxSelection == -1) { comboBoxSelection = 0; } } workerComboBox.setSelectedIndex(comboBoxSelection); } else { displayWorker(null); } } } }); workerComboBox.setRenderer(new SmallWorkerListCellRenderer()); workerComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { if (workerComboBox.getSelectedItem() instanceof Worker) { displayWorker((Worker) workerComboBox.getSelectedItem()); } } }); propertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final int row = propertiesTable.getSelectedRow(); final boolean enable; if (row == -1) { enable = false; } else { final Object o = propertiesTable.getValueAt(row, 1); enable = o instanceof X509Certificate || o instanceof Collection; // TODO: Too weak } statusPropertiesDetailsButton.setEnabled(enable); } } }); propertiesTable.setRowHeight(rowHeights); configurationTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final boolean enable = configurationTable.getSelectedRowCount() == 1; editButton.setEnabled(enable); removeButton.setEnabled(enable); } } }); configurationTable.setRowHeight(rowHeights); authTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final boolean enable = authTable.getSelectedRowCount() == 1; authEditButton.setEnabled(enable); authRemoveButton.setEnabled(enable); } } }); authTable.setRowHeight(rowHeights); archiveTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { downloadArchiveEntriesButton .setEnabled(!fetchArchiveDataInProgress && archiveTable.getSelectedRowCount() > 0); } } }); archiveTable.setRowHeight(rowHeights); auditLogTable.setRowHeight(rowHeights); conditionsTable.setRowHeight(rowHeights); archiveConditionsTable.setRowHeight(rowHeights); tokenEntriesTable.setRowHeight(rowHeights); displayWorker(null); // status bar initialization - message timeout, idle icon and busy // animation, etc ResourceMap resourceMap = getResourceMap(); int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout"); messageTimer = new Timer(messageTimeout, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { statusMessageLabel.setText(""); } }); messageTimer.setRepeats(false); int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate"); for (int i = 0; i < busyIcons.length; i++) { busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]"); } busyIconTimer = new Timer(busyAnimationRate, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { busyIconIndex = (busyIconIndex + 1) % busyIcons.length; statusAnimationLabel.setIcon(busyIcons[busyIconIndex]); } }); idleIcon = resourceMap.getIcon("StatusBar.idleIcon"); statusAnimationLabel.setIcon(idleIcon); progressBar.setVisible(false); // connecting action tasks to status bar via TaskMonitor TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext()); taskMonitor.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if ("started".equals(propertyName)) { if (!busyIconTimer.isRunning()) { statusAnimationLabel.setIcon(busyIcons[0]); busyIconIndex = 0; busyIconTimer.start(); } progressBar.setVisible(true); progressBar.setIndeterminate(true); } else if ("done".equals(propertyName)) { busyIconTimer.stop(); statusAnimationLabel.setIcon(idleIcon); progressBar.setVisible(false); progressBar.setValue(0); } else if ("message".equals(propertyName)) { String text = (String) evt.getNewValue(); statusMessageLabel.setText((text == null) ? "" : text); messageTimer.restart(); } else if ("progress".equals(propertyName)) { int value = (Integer) evt.getNewValue(); progressBar.setVisible(true); progressBar.setIndeterminate(false); progressBar.setValue(value); } } }); getContext().getTaskService().execute(refreshWorkers()); }