Java Code Examples for javax.swing.ListSelectionModel#clearSelection()
The following examples show how to use
javax.swing.ListSelectionModel#clearSelection() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiTableSelectionListener.java From arcusplatform with Apache License 2.0 | 6 votes |
@Override public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()) { return; } ListSelectionModel m = (ListSelectionModel) e.getSource(); if(!m.isSelectionEmpty()) { for(ListSelectionModel delegate: delegates) { if(delegate == m) { continue; } delegate.clearSelection(); } } }
Example 2
Source File: SecurityRoleMappingPanel.java From netbeans with Apache License 2.0 | 6 votes |
/** Remove all selected items from the specified table. */ private void handleRemoveAction(JTable theTable) { int [] selectedIndices = theTable.getSelectedRows(); if(selectedIndices.length > 0) { ListSelectionModel selectionModel = theTable.getSelectionModel(); try { SRMBaseTableModel theModel = (SRMBaseTableModel) theTable.getModel(); selectionModel.setValueIsAdjusting(true); theModel.removeElements(selectedIndices); int numElements = theTable.getModel().getRowCount(); if(numElements > 0) { int newSelectedIndex = selectedIndices[0]; if(newSelectedIndex >= numElements) { newSelectedIndex = numElements-1; } selectionModel.setSelectionInterval(newSelectedIndex, newSelectedIndex); } else { selectionModel.clearSelection(); } } finally { selectionModel.setValueIsAdjusting(false); } } }
Example 3
Source File: SortByPanel.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Sets the text. * * @param value the new text */ public void setText(String value) { Map<String, String> options = new HashMap<>(); ListSelectionModel model = destinationTable.getSelectionModel(); model.clearSelection(); SortBy[] sortArray = null; if (!value.isEmpty()) { options.put(FeatureTypeStyle.SORT_BY, value); sortArray = SLDStyleFactory.getSortBy(options); } destinationModel.populate(sortArray); updateLists(); btnMoveDown.setEnabled(false); btnMoveUp.setEnabled(false); btnDestToSrcButton.setEnabled(false); btnSrcToDestButton.setEnabled(false); }
Example 4
Source File: OutlineView.java From netbeans with Apache License 2.0 | 5 votes |
public void setTo(ListSelectionModel sm) { sm.clearSelection(); sm.setSelectionMode(selectionMode); for (int[] itv : intervals) { sm.addSelectionInterval(itv[0], itv[1]); } sm.setAnchorSelectionIndex(anchor); sm.setLeadSelectionIndex(lead); }
Example 5
Source File: VCSStatusTable.java From netbeans with Apache License 2.0 | 5 votes |
public final void setSelectedNodes (File[] selectedFiles) { Set<File> files = new HashSet<File>(Arrays.asList(selectedFiles)); ListSelectionModel selection = table.getSelectionModel(); selection.setValueIsAdjusting(true); selection.clearSelection(); for (int i = 0; i < table.getRowCount(); ++i) { T node = tableModel.getNode(table.convertRowIndexToModel(i)); if (files.contains(node.getFile())) { selection.addSelectionInterval(i, i); } } selection.setValueIsAdjusting(false); }
Example 6
Source File: OptionsPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void selectRows(int[] selectedRows, int delta) { ListSelectionModel listSelectionModel = mappingsTable.getSelectionModel(); listSelectionModel.clearSelection(); for (int selectedRow : selectedRows) { listSelectionModel.addSelectionInterval(selectedRow + delta, selectedRow + delta); } }
Example 7
Source File: SortByPanel.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** Move source to destination. */ protected void moveSrcToDestination() { List<String> selectedItemList = sourceList.getSelectedValuesList(); for (String item : selectedItemList) { destinationModel.addProperty(item); sourceModel.removeElement(item); } ListSelectionModel model = destinationTable.getSelectionModel(); model.clearSelection(); btnSrcToDestButton.setEnabled(false); }
Example 8
Source File: SortByPanel.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Select destination rows. * * @param selectedIndexes the selected indexes */ protected void selectDestination(int[] selectedIndexes) { ListSelectionModel model = destinationTable.getSelectionModel(); model.clearSelection(); for (int index : selectedIndexes) { model.addSelectionInterval(index, index); } }
Example 9
Source File: KseFrame.java From keystore-explorer with GNU General Public License v3.0 | 5 votes |
public void setSelectedEntriesByAliases(String... aliases) { JTable jtKeyStore = getActiveKeyStoreTable(); jtKeyStore.requestFocusInWindow(); ListSelectionModel selectionModel = jtKeyStore.getSelectionModel(); selectionModel.clearSelection(); Set<String> aliasesToSelect = new HashSet<>(Arrays.asList(aliases)); for (int i = 0; i < jtKeyStore.getRowCount(); i++) { if (aliasesToSelect.contains(jtKeyStore.getValueAt(i, 3))) { selectionModel.addSelectionInterval(i, i); } } }
Example 10
Source File: NamesAssociationDialog.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { final ListSelectionModel selectionModel = aliasNames.getSelectionModel(); final int minSelectionIndex = selectionModel.getMinSelectionIndex(); final int maxSelectionIndex = selectionModel.getMaxSelectionIndex(); selectionModel.clearSelection(); if (minSelectionIndex != -1) { for (int i = maxSelectionIndex; i >= minSelectionIndex; i--) { associationModel.removeAlias(getAliasNameAt(i)); } } removeButton.setEnabled(associationModel.getAliasNames().size() > 0); aliasNameScrollPane.repaint(); }
Example 11
Source File: MosaicExpressionsPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private static void selectRows(final JTable table, final int[] rows) { final ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.clearSelection(); for (int row : rows) { selectionModel.addSelectionInterval(row, row); } }
Example 12
Source File: TableSelectionModel.java From wandora with GNU General Public License v3.0 | 5 votes |
/** * Calls clearSelection() of all ListSelectionModels. */ public void clearSelection() { for(Iterator enu=listSelectionModels.iterator(); enu.hasNext();) { ListSelectionModel lm = (ListSelectionModel)(enu.next()); lm.clearSelection(); } }
Example 13
Source File: Listener.java From tcpmon with Apache License 2.0 | 5 votes |
/** * Method removeAll */ public void removeAll() { ListSelectionModel lsm = connectionTable.getSelectionModel(); lsm.clearSelection(); while (connections.size() > 0) { ((Connection) connections.get(0)).remove(); } lsm.setSelectionInterval(0, 0); }
Example 14
Source File: SourceRootsUi.java From netbeans with Apache License 2.0 | 4 votes |
private void addFolders( File files[] ) { int[] si = rootsList.getSelectedRows(); int lastIndex = si == null || si.length == 0 ? -1 : si[si.length - 1]; ListSelectionModel selectionModel = this.rootsList.getSelectionModel(); selectionModel.clearSelection(); Set<File> rootsFromOtherProjects = new HashSet<File>(); Set<File> rootsFromRelatedSourceRoots = new HashSet<File>(); String type = RootsAccessor.getInstance().getType(sourceRoots); boolean isModule = JavaProjectConstants.SOURCES_TYPE_MODULES.equals(type); out: for( int i = 0; i < files.length; i++ ) { File normalizedFile = FileUtil.normalizeFile(files[i]); Project p; if (ownedFolders.contains(normalizedFile)) { Vector dataVector = rootsModel.getDataVector(); for (int j=0; j<dataVector.size();j++) { //Sequential search in this minor case is faster than update of positions during each modification File f = (File )((Vector)dataVector.elementAt(j)).elementAt(0); if (f.equals(normalizedFile)) { selectionModel.addSelectionInterval(j,j); } } } else if (this.relatedEditMediator != null && this.relatedEditMediator.ownedFolders.contains(normalizedFile)) { rootsFromRelatedSourceRoots.add (normalizedFile); continue; } if ((p=FileOwnerQuery.getOwner(Utilities.toURI(normalizedFile)))!=null && !p.getProjectDirectory().equals(project.getProjectDirectory())) { final Sources sources = p.getLookup().lookup(Sources.class); if (sources == null) { rootsFromOtherProjects.add (normalizedFile); continue; } final SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC); final SourceGroup[] javaGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); final SourceGroup[] groups = new SourceGroup [sourceGroups.length + javaGroups.length]; System.arraycopy(sourceGroups,0,groups,0,sourceGroups.length); System.arraycopy(javaGroups,0,groups,sourceGroups.length,javaGroups.length); final FileObject projectDirectory = p.getProjectDirectory(); final FileObject fileObject = FileUtil.toFileObject(normalizedFile); if (projectDirectory == null || fileObject == null) { rootsFromOtherProjects.add (normalizedFile); continue; } for (int j=0; j<groups.length; j++) { final FileObject sgRoot = groups[j].getRootFolder(); if (fileObject.equals(sgRoot)) { rootsFromOtherProjects.add (normalizedFile); continue out; } if (!projectDirectory.equals(sgRoot) && FileUtil.isParentOf(sgRoot, fileObject)) { rootsFromOtherProjects.add (normalizedFile); continue out; } } } int current = lastIndex + 1 + i; rootsModel.insertRow( current, new Object[] {normalizedFile, isModule ? ((ModuleRoots)sourceRoots).createInitialPath() : sourceRoots.createInitialDisplayName(normalizedFile)}); selectionModel.addSelectionInterval(current,current); this.ownedFolders.add (normalizedFile); } if (rootsFromOtherProjects.size() > 0 || rootsFromRelatedSourceRoots.size() > 0) { rootsFromOtherProjects.addAll(rootsFromRelatedSourceRoots); showIllegalRootsDialog (rootsFromOtherProjects); } // fireActionPerformed(); }