List of usage examples for javax.swing.event ListSelectionEvent getValueIsAdjusting
public boolean getValueIsAdjusting()
From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java
public void setOnselect(final String select) { selectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting() == true) { return; }/* ww w .j a v a 2s . co m*/ invoke(select, new Object[] { new Integer(table.getSelectedRow()) }); } }; if (table != null) { table.getSelectionModel().addListSelectionListener(selectionListener); } treeSelectionListener = new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { if (tree != null) { invoke(select, new Object[] { tree.getSelectionRows()[0] }); } } }; if (tree != null) { tree.getSelectionModel().addTreeSelectionListener(treeSelectionListener); } }
From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java
@Override public void layout() { XulComponent primaryColumn = this.getElementByXPath("//treecol[@primary='true']"); //$NON-NLS-1$ XulComponent isaContainer = this.getElementByXPath("treechildren/treeitem[@container='true']"); //$NON-NLS-1$ isHierarchical = (primaryColumn != null) || (isaContainer != null); if (isHierarchical) { tree = new JTree(); if (treeSelectionListener != null) { tree.getSelectionModel().addTreeSelectionListener(treeSelectionListener); }// w w w . ja v a2s. com tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { SwingTree.this.changeSupport.firePropertyChange("selectedRows", null, //$NON-NLS-1$ SwingTree.this.getSelectedRows()); SwingTree.this.changeSupport.firePropertyChange("absoluteSelectedRows", null, //$NON-NLS-1$ SwingTree.this.getAbsoluteSelectedRows()); SwingTree.this.fireSelectedItem(); } }); } else { table = new ScrollableJTable(); if (selectionListener != null) { table.getSelectionModel().addListSelectionListener(selectionListener); } table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting() == true) { return; } SwingTree.this.changeSupport.firePropertyChange("selectedRows", null, //$NON-NLS-1$ SwingTree.this.getSelectedRows()); SwingTree.this.fireSelectedItem(); } }); } JComponent comp = (table != null ? table : tree); ToolTipManager.sharedInstance().unregisterComponent(comp); if (table != null) { ToolTipManager.sharedInstance().unregisterComponent(table.getTableHeader()); table.setRowHeight(18); scrollpane = new JScrollPane(table); setupTable(); } else { setupTree(); scrollpane = new JScrollPane(tree); } setManagedObject(scrollpane.getViewport()); }
From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java
private void setupTable() { // generate table object based on TableModel and TableColumnModel // if(tableModel == null){ tableModel = new XulTableModel(this); // }/*w w w . ja v a2s .c o m*/ table.setModel(this.tableModel); this.setSeltype(getSeltype()); updateColumnModel(); initialized = true; table.addComponentListener(new ComponentListener() { public void componentHidden(ComponentEvent arg0) { } public void componentMoved(ComponentEvent e) { } public void componentShown(ComponentEvent e) { } public void componentResized(ComponentEvent e) { calcColumnWidths(); } }); // Property change on selections table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting() == true) { return; } SwingTree.this.changeSupport.firePropertyChange("selectedRows", null, //$NON-NLS-1$ SwingTree.this.getSelectedRows()); SwingTree.this.changeSupport.firePropertyChange("absoluteSelectedRows", null, //$NON-NLS-1$ SwingTree.this.getAbsoluteSelectedRows()); } }); table.getTableHeader().setReorderingAllowed(this.isEnableColumnDrag()); this.setDisabled(this.isDisabled()); }
From source file:org.piraso.ui.base.ContextMonitorDialog.java
/** * Creates new form ContextMonitorDialog *///from w w w. j a va 2 s . c o m public ContextMonitorDialog() { super(); setTitle("Manage Monitors"); initComponents(); initPreferences(); addButtonRefreshListeners(); lstMonitors.setModel(listModel); cboHost.setModel(cboModel); lstMonitors.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstMonitors.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; initSelection((String) lstMonitors.getSelectedValue()); } }); refresh(); setLocationRelativeTo(getOwner()); }
From source file:org.piraso.ui.base.ContextMonitorTopComponent.java
@Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return;/* w w w .ja v a 2 s. c o m*/ if (e.getSource() != table.getSelectionModel()) return; if (table.getSelectedRow() < 0) return; Entry entry = tableModel.getEntryAt(table.getSelectedRow()).getEntry(); Class<? extends TopComponent> viewClass = EntryViewProviderManager.INSTANCE.getViewClass(entry); entryContent.add(entry); if (viewClass != null) { WindowUtils.selectWindow(viewClass); } }
From source file:org.piraso.ui.base.ProfilesDialog.java
/** * Creates new form ProfilesDialog// w w w .ja v a2 s . co m */ public ProfilesDialog() { super(); setTitle("Manage Profiles"); initComponents(); initTable(); addButtonRefreshListeners(); lstProfiles.setModel(listModel); lstProfiles.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstProfiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; initSelection((String) lstProfiles.getSelectedValue()); } }); refresh(); setLocationRelativeTo(getOwner()); }
From source file:org.signserver.admin.gui.AddWorkerDialog.java
/** Creates new form AddWorkerDialog */ public AddWorkerDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents();/*from ww w . j av a 2 s.co m*/ stage = Stage.INITIAL_CONFIG; mode = Mode.LOAD_FROM_FILE; loadFromFileRadioButton.setSelected(true); updateControls(); // initially set the Next button to be greyed-out, so that it can be // enabled based on the state nextApplyButton.setEnabled(false); invalidWorkerIdStatusLabel.setVisible(false); propertiesTable.setDefaultRenderer(String.class, new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focused, int row, int column) { setEnabled(table == null || table.isEnabled()); super.getTableCellRendererComponent(table, value, selected, focused, row, column); return this; } }); propertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final boolean enable = propertiesTable.getSelectedRowCount() == 1; editPropertyButton.setEnabled(enable); removePropertyButton.setEnabled(enable); } } }); // add a document listner to update the UI when the content of the ID // combobox changes final JTextComponent component = (JTextComponent) workerIdComboBox.getEditor().getEditorComponent(); component.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent ev) { updateControls(); } @Override public void removeUpdate(DocumentEvent ev) { updateControls(); } @Override public void changedUpdate(DocumentEvent ev) { updateControls(); } }); // add a document listner to update the UI on updates of the configuration text configurationTextArea.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent ev) { configurationEdited = true; updateControls(); } @Override public void removeUpdate(DocumentEvent ev) { configurationEdited = true; updateControls(); } @Override public void changedUpdate(DocumentEvent ev) { configurationEdited = true; updateControls(); } }); }
From source file:org.signserver.admin.gui.MainView.java
public MainView(SingleFrameApplication app) { super(app);/*from w ww . j a v a2s . co m*/ 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()); }
From source file:org.signserver.admin.gui.ViewCertificateFrame.java
public ViewCertificateFrame(final List<X509Certificate> certificates) { this.certificates = certificates; this.certificate = certificates.get(0); initComponents();/*from www. ja v a2 s . c o m*/ chainList.setModel(new AbstractListModel() { @Override public int getSize() { return certificates.size(); } @Override public Object getElementAt(int index) { return certificates.get(index); } }); chainList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { if (value instanceof X509Certificate) { final X509Certificate cert = (X509Certificate) value; value = cert.getSubjectDN().getName(); } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); chainList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { viewCertificate((X509Certificate) chainList.getSelectedValue()); } } }); fieldsList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { if (value instanceof Field) { value = ((Field) value).getName(); } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); fieldsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { viewFieldValue((Field) fieldsList.getSelectedValue()); } } }); subjectTextArea.setText(certificate.getSubjectDN().getName()); issuerTextArea.setText(certificate.getIssuerDN().getName()); serialNumberField.setText(certificate.getSerialNumber().toString(16)); notBeforeLabel.setText(String.valueOf(certificate.getNotBefore())); notAfterLabel.setText(String.valueOf(certificate.getNotAfter())); String fingerprint = ""; try { fingerprint = calcFingerprint(certificate.getEncoded()); } catch (CertificateEncodingException ex) { LOG.error("Error calculating certificate fingerprint", ex); } fingerprintLabel.setText(fingerprint); usages = new ArrayList<String>(); boolean[] keyUsages = certificate.getKeyUsage(); if (keyUsages != null) { // digitalSignature (0), if (keyUsages[0]) { usages.add("digitalSignature"); } // nonRepudiation (1), if (keyUsages[1]) { usages.add("nonRepudiation"); } // keyEncipherment (2), if (keyUsages[2]) { usages.add("keyEncipherment"); } // dataEncipherment (3), if (keyUsages[3]) { usages.add("dataEncipherment"); } // keyAgreement (4), if (keyUsages[4]) { usages.add("keyAgreement"); } // keyCertSign (5), if (keyUsages[5]) { usages.add("keyCertSign"); } // cRLSign (6), if (keyUsages[6]) { usages.add("cRLSign"); } // encipherOnly (7), if (keyUsages[7]) { usages.add("encipherOnly"); } // decipherOnly if (keyUsages[8]) { usages.add("decipherOnly"); } } try { final List<String> eku = certificate.getExtendedKeyUsage(); if (eku != null) { usages.addAll(eku); } } catch (CertificateParsingException ex) { LOG.error("Error getting extended key usage", ex); } usagesList.setModel(new AbstractListModel() { @Override public int getSize() { return usages.size(); } @Override public Object getElementAt(int index) { return usages.get(index); } }); chainList.setSelectedIndex(0); }
From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
private void lsAttributeListValueChanged(javax.swing.event.ListSelectionEvent evt) { if (evt.getValueIsAdjusting() == false) { // if this is the final iteration through the value changed handler if (lsAttributeList.getSelectedIndex() >= 0) { // and we have a selected entry bnDeleteAttribute.setEnabled(true); DefaultMutableTreeNode node = (DefaultMutableTreeNode) trRuleList.getLastSelectedPathComponent(); if (node == null) { // Nothing is selected return; }/* w w w . ja va 2s . c om*/ Item ruleInfo = (Item) node.getUserObject(); if (ruleInfo.getItemType() == ItemType.RULE_SET) { return; } Object listItem = lsAttributeList.getSelectedValue(); if (listItem != null) { Rule rule = exportRuleSet.getRules().get(ruleInfo.getRuleName()); if (rule != null) { // find the attribute to select for (ArtifactCondition ac : rule.getArtifactConditions()) { if (ac.getTreeDisplayName().compareTo(listItem.toString()) == 0) { // set selected and expand it TreePath shortPath = findTreePathByRuleName(rule.getName()); TreePath treePath = findTreePathByRuleAndArtifactClauseName(rule.getName(), listItem.toString()); trRuleList.expandPath(shortPath); // Don't let treeSelectionListener respond trRuleList.removeTreeSelectionListener(treeSelectionListener); treeSelectionModel.setSelectionPath(treePath); populateArtifactEditor(ac); setDeleteAttributeButton(); trRuleList.addTreeSelectionListener(treeSelectionListener); localRule = makeRuleFromUserInput(); break; } } } } else { bnDeleteAttribute.setEnabled(false); } } } }