javax.swing.DefaultListSelectionModel Java Examples
The following examples show how to use
javax.swing.DefaultListSelectionModel.
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: ComponentUtils.java From desktopclient-java with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") ParticipantsList() { mModel = new DefaultListModel<>(); this.setModel(mModel); this.setFixedCellHeight(25); this.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); this.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { if(super.isSelectedIndex(index0)) { super.removeSelectionInterval(index0, index1); } else { super.addSelectionInterval(index0, index1); } } }); this.setCellRenderer(new CellRenderer()); }
Example #2
Source File: SorterTableColumnModel.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
public SorterTableColumnModel(Sortables[] columnHeaders) { MainFrame mainFrame = MainFrame.getInstance(); int x = 0; for (Sortables c : columnHeaders) { if (!c.isAvailable(mainFrame)) { continue; } shown.add(c); TableColumn tc = makeTableColumn(x, c); columnList.add(tc); x++; } dlsm = new DefaultListSelectionModel(); dlsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); orderUpdate(); check(); }
Example #3
Source File: ProfilerTable.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void setFixedColumnSelection(final int column) { if (fixedSelectionColumn == column) return; if (column == -1) { getColumnModel().setSelectionModel(new DefaultListSelectionModel()); } else { getColumnModel().setSelectionModel(new DefaultListSelectionModel() { public void setSelectionInterval(int index0, int index1) { int index = convertColumnIndexToView(column); super.setSelectionInterval(index, index); } }); } fixedSelectionColumn = column; }
Example #4
Source File: SkillInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override public ModelMap createModels(final CharacterFacade character) { Objects.requireNonNull(character); ModelMap models = new ModelMap(); ListSelectionModel listModel = new DefaultListSelectionModel(); listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); models.put(ListSelectionModel.class, listModel); models.put(SkillPointTableModel.class, new SkillPointTableModel(character)); models.put(SkillTreeViewModel.class, new SkillTreeViewModel(character, listModel)); models.put(FilterHandler.class, new FilterHandler(character, listModel)); models.put(InfoHandler.class, new InfoHandler(character)); models.put(LevelSelectionHandler.class, new LevelSelectionHandler(character, listModel)); models.put(SkillRankSpinnerEditor.class, new SkillRankSpinnerEditor(character, listModel)); SkillSheetHandler skillSheetHandler = new SkillSheetHandler(character); models.put(SkillSheetHandler.class, skillSheetHandler); models.put(SkillFilterHandler.class, new SkillFilterHandler(character, skillSheetHandler)); return models; }
Example #5
Source File: ComponentUtils.java From desktopclient-java with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") MemberList(boolean selectable) { mModel = new DefaultListModel<>(); this.setModel(mModel); this.setFixedCellHeight(25); this.setEnabled(selectable); if (selectable) { this.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); this.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { if(super.isSelectedIndex(index0)) { super.removeSelectionInterval(index0, index1); } else { super.addSelectionInterval(index0, index1); } } }); } this.setCellRenderer(new CellRenderer()); }
Example #6
Source File: AbilityChooserTab.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
public Hashtable<Object, Object> createState(CharacterFacade character, ListFacade<AbilityCategory> categories, ListFacade<AbilityCategory> fullCategoryList, String title) { Hashtable<Object, Object> state = new Hashtable<>(); CategoryTableModel categoryTableModel = new CategoryTableModel(character, fullCategoryList, categoryBar, categoryTable); state.put(CategoryTableModel.class, categoryTableModel); ListSelectionModel listModel = new DefaultListSelectionModel(); listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); state.put(ListSelectionModel.class, listModel); state.put(AbilityTreeTableModel.class, new AbilityTreeTableModel(character, categories)); state.put(AvailableAbilityTreeViewModel.class, new AvailableAbilityTreeViewModel(character, listModel, title)); state.put(InfoHandler.class, new InfoHandler(character)); state.put(TreeRendererHandler.class, new TreeRendererHandler(character)); state.put(AddAction.class, new AddAction(character)); state.put(RemoveAction.class, new RemoveAction(character)); state.put(AbilityFilterHandler.class, new AbilityFilterHandler(character)); state.put(CategoryFilterHandler.class, new CategoryFilterHandler(categoryTableModel)); return state; }
Example #7
Source File: HistoryQuickSearchView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearance table.setRowHeight(22); table.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener((evt) -> pm.setSelected(getSelectedRow())); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); table.getActionMap().put("confirmRow", enterAction); table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "confirmRow"); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.setViewportView(table); return scrollPane; }
Example #8
Source File: SelectEditTableCell.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void createUI(final String lookAndFeelString) throws Exception { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { String[][] data = {{"Foo"}}; String[] cols = {"One"}; table = new JTable(data, cols); table.setSelectionMode( DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); frame = new JFrame(lookAndFeelString); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(table); frame.pack(); frame.setSize(500, frame.getSize().height); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.toFront(); } }); }
Example #9
Source File: EndmemberFormModel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public EndmemberFormModel(AppContext appContext) { this.appContext = appContext; endmemberListModel = new DefaultListModel<>(); endmemberListSelectionModel = new DefaultListSelectionModel(); endmemberListSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); endmemberListModel.addListDataListener(new EndmemberListDataListener()); endmemberListSelectionModel.addListSelectionListener(new EndmemberListSelectionListener()); addAction = new AddAction(); removeAction = new RemoveAction(); clearAction = new ClearAction(); exportAction = new ExportAction(); endmemberDiagram = new Diagram(); endmemberDiagram.setXAxis(new DiagramAxis("Wavelength", "")); endmemberDiagram.setYAxis(new DiagramAxis("Radiation", "")); endmemberDiagram.setDrawGrid(false); propertyChangeSupport = new PropertyChangeSupport(this); }
Example #10
Source File: StatefulActionProcessorTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testCustomContextAwareInstance() { Action a = Actions.forID("Foo", "test.ListAction"); DefaultListSelectionModel model = new DefaultListSelectionModel(); InstanceContent localContent1 = new InstanceContent(); AbstractLookup localLookup1 = new AbstractLookup(localContent1); Action la = ((ContextAwareAction)a).createContextAwareInstance(localLookup1); assertFalse(a.isEnabled()); assertFalse(la.isEnabled()); localContent1.add(model); assertFalse(a.isEnabled()); assertTrue(la.isEnabled()); assertFalse((Boolean)la.getValue(Action.SELECTED_KEY)); // checks that the context-bound instance changes its selected state // if the model changes (relevant property change event is fired) model.setSelectionInterval(1, 2); assertTrue((Boolean)la.getValue(Action.SELECTED_KEY)); }
Example #11
Source File: KeysTableView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearence table.setRowHeight(22); table.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(rowSelectionListener); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); initTableKeyListener(); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.addMouseListener(listMouseListener); scrollPane.setViewportView(table); return scrollPane; }
Example #12
Source File: ProfilerTable.java From netbeans with Apache License 2.0 | 6 votes |
public void setFixedColumnSelection(final int column) { if (fixedSelectionColumn == column) return; if (column == -1) { getColumnModel().setSelectionModel(new DefaultListSelectionModel()); } else { getColumnModel().setSelectionModel(new DefaultListSelectionModel() { public void setSelectionInterval(int index0, int index1) { int index = convertColumnIndexToView(column); super.setSelectionInterval(index, index); } }); } fixedSelectionColumn = column; }
Example #13
Source File: AbilityChooserTab.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
public Hashtable<Object, Object> createState(CharacterFacade character, ListFacade<AbilityCategory> categories, ListFacade<AbilityCategory> fullCategoryList, String title) { Hashtable<Object, Object> state = new Hashtable<>(); CategoryTableModel categoryTableModel = new CategoryTableModel(character, fullCategoryList, categoryBar, categoryTable); state.put(CategoryTableModel.class, categoryTableModel); ListSelectionModel listModel = new DefaultListSelectionModel(); listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); state.put(ListSelectionModel.class, listModel); state.put(AbilityTreeTableModel.class, new AbilityTreeTableModel(character, categories)); state.put(AvailableAbilityTreeViewModel.class, new AvailableAbilityTreeViewModel(character, listModel, title)); state.put(InfoHandler.class, new InfoHandler(character)); state.put(TreeRendererHandler.class, new TreeRendererHandler(character)); state.put(AddAction.class, new AddAction(character)); state.put(RemoveAction.class, new RemoveAction(character)); state.put(AbilityFilterHandler.class, new AbilityFilterHandler(character)); state.put(CategoryFilterHandler.class, new CategoryFilterHandler(categoryTableModel)); return state; }
Example #14
Source File: DefaultTreeSelectionModel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Makes sure the currently selected <code>TreePath</code>s are valid * for the current selection mode. * If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code> * and a <code>RowMapper</code> exists, this will make sure all * the rows are contiguous, that is, when sorted all the rows are * in order with no gaps. * If the selection isn't contiguous, the selection is * reset to contain the first set, when sorted, of contiguous rows. * <p> * If the selection mode is <code>SINGLE_TREE_SELECTION</code> and * more than one TreePath is selected, the selection is reset to * contain the first path currently selected. */ protected void insureRowContinuity() { if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION && selection != null && rowMapper != null) { DefaultListSelectionModel lModel = listSelectionModel; int min = lModel.getMinSelectionIndex(); if(min != -1) { for(int counter = min, maxCounter = lModel.getMaxSelectionIndex(); counter <= maxCounter; counter++) { if(!lModel.isSelectedIndex(counter)) { if(counter == min) { clearSelection(); } else { TreePath[] newSel = new TreePath[counter - min]; int selectionIndex[] = rowMapper.getRowsForPaths(selection); // find the actual selection pathes corresponded to the // rows of the new selection for (int i = 0; i < selectionIndex.length; i++) { if (selectionIndex[i]<counter) { newSel[selectionIndex[i]-min] = selection[i]; } } setSelectionPaths(newSel); break; } } } } } else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION && selection != null && selection.length > 1) { setSelectionPath(selection[0]); } }
Example #15
Source File: AbilityChooserTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void storeState(Hashtable<Object, Object> state) { ((InfoHandler) state.get(InfoHandler.class)).uninstall(); ((AvailableAbilityTreeViewModel) state.get(AvailableAbilityTreeViewModel.class)).uninstall(); categoryTable.setSelectionModel(new DefaultListSelectionModel()); ((CategoryTableModel) state.get(CategoryTableModel.class)).uninstall(); ((AddAction) state.get(AddAction.class)).uninstall(); ((RemoveAction) state.get(RemoveAction.class)).uninstall(); ((TreeRendererHandler) state.get(TreeRendererHandler.class)).uninstall(); }
Example #16
Source File: ErrorList.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
public ErrorList(JByteMod jbm, MyCodeList cl) { super(new DefaultListModel<Mistake>()); this.jbm = jbm; this.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); this.warning = new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/resources/warning.png"))); this.cl = cl; cl.setErrorList(this); this.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { super.setSelectionInterval(-1, -1); } }); this.oldRenderer = this.getCellRenderer(); this.setCellRenderer(new CustomCellRenderer()); this.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int index = locationToIndex(e.getPoint()); Mistake error = getModel().getElementAt(index); if (!(error instanceof EmptyMistake)) { WebPopOver popOver = new WebPopOver(JByteMod.instance); popOver.setMargin(10); popOver.setMovable(false); popOver.setCloseOnFocusLoss(true); popOver.setLayout(new VerticalFlowLayout()); popOver.add(new JLabel(error.getDesc())); popOver.show(jbm, (int) jbm.getMousePosition().getX(), (int) jbm.getMousePosition().getY()); } } }); this.updateErrors(); SwingUtils.disableSelection(this); }
Example #17
Source File: DefaultTreeSelectionModel.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Creates a new instance of DefaultTreeSelectionModel that is * empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION. */ public DefaultTreeSelectionModel() { listSelectionModel = new DefaultListSelectionModel(); selectionMode = DISCONTIGUOUS_TREE_SELECTION; leadIndex = leadRow = -1; uniquePaths = new Hashtable<TreePath, Boolean>(); lastPaths = new Hashtable<TreePath, Boolean>(); tempPaths = new TreePath[1]; }
Example #18
Source File: DefaultTreeSelectionModel.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Makes sure the currently selected <code>TreePath</code>s are valid * for the current selection mode. * If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code> * and a <code>RowMapper</code> exists, this will make sure all * the rows are contiguous, that is, when sorted all the rows are * in order with no gaps. * If the selection isn't contiguous, the selection is * reset to contain the first set, when sorted, of contiguous rows. * <p> * If the selection mode is <code>SINGLE_TREE_SELECTION</code> and * more than one TreePath is selected, the selection is reset to * contain the first path currently selected. */ protected void insureRowContinuity() { if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION && selection != null && rowMapper != null) { DefaultListSelectionModel lModel = listSelectionModel; int min = lModel.getMinSelectionIndex(); if(min != -1) { for(int counter = min, maxCounter = lModel.getMaxSelectionIndex(); counter <= maxCounter; counter++) { if(!lModel.isSelectedIndex(counter)) { if(counter == min) { clearSelection(); } else { TreePath[] newSel = new TreePath[counter - min]; int selectionIndex[] = rowMapper.getRowsForPaths(selection); // find the actual selection pathes corresponded to the // rows of the new selection for (int i = 0; i < selectionIndex.length; i++) { if (selectionIndex[i]<counter) { newSel[selectionIndex[i]-min] = selection[i]; } } setSelectionPaths(newSel); break; } } } } } else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION && selection != null && selection.length > 1) { setSelectionPath(selection[0]); } }
Example #19
Source File: DefaultTreeSelectionModel.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Makes sure the currently selected <code>TreePath</code>s are valid * for the current selection mode. * If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code> * and a <code>RowMapper</code> exists, this will make sure all * the rows are contiguous, that is, when sorted all the rows are * in order with no gaps. * If the selection isn't contiguous, the selection is * reset to contain the first set, when sorted, of contiguous rows. * <p> * If the selection mode is <code>SINGLE_TREE_SELECTION</code> and * more than one TreePath is selected, the selection is reset to * contain the first path currently selected. */ protected void insureRowContinuity() { if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION && selection != null && rowMapper != null) { DefaultListSelectionModel lModel = listSelectionModel; int min = lModel.getMinSelectionIndex(); if(min != -1) { for(int counter = min, maxCounter = lModel.getMaxSelectionIndex(); counter <= maxCounter; counter++) { if(!lModel.isSelectedIndex(counter)) { if(counter == min) { clearSelection(); } else { TreePath[] newSel = new TreePath[counter - min]; int selectionIndex[] = rowMapper.getRowsForPaths(selection); // find the actual selection pathes corresponded to the // rows of the new selection for (int i = 0; i < selectionIndex.length; i++) { if (selectionIndex[i]<counter) { newSel[selectionIndex[i]-min] = selection[i]; } } setSelectionPaths(newSel); break; } } } } } else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION && selection != null && selection.length > 1) { setSelectionPath(selection[0]); } }
Example #20
Source File: AdressList.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
public AdressList(MyCodeList cl) { super(new DefaultListModel<String>()); this.cl = cl; cl.setAdressList(this); this.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); this.updateAdr(); this.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { super.setSelectionInterval(-1, -1); } }); this.setPrototypeCellValue("0000"); SwingUtils.disableSelection(this); }
Example #21
Source File: CheckBoxListDecorator.java From importer-exporter with Apache License 2.0 | 5 votes |
public CheckBoxListDecorator(JList<T> list) { this.list = list; list.setCellRenderer(new CheckBoxListCellRenderer<T>()); list.addMouseListener(this); list.addPropertyChangeListener(this); list.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED); checkBoxSelectionModel = new DefaultListSelectionModel(); checkBoxSelectionModel.addListSelectionListener(this); enabled = new HashMap<Integer, Boolean>(); width = new JCheckBox().getPreferredSize().width; }
Example #22
Source File: DefaultTreeSelectionModel.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { ObjectInputStream.GetField f = s.readFields(); changeSupport = (SwingPropertyChangeSupport) f.get("changeSupport", null); selection = (TreePath[]) f.get("selection", null); EventListenerList newListenerList = (EventListenerList) f.get("listenerList", null); if (newListenerList == null) { throw new InvalidObjectException("Null listenerList"); } listenerList = newListenerList; listSelectionModel = (DefaultListSelectionModel) f.get("listSelectionModel", null); selectionMode = validateSelectionMode(f.get("selectionMode", 0)); leadPath = (TreePath) f.get("leadPath", null); leadIndex = f.get("leadIndex", 0); leadRow = f.get("leadRow", 0); @SuppressWarnings("unchecked") Hashtable<TreePath, Boolean> newUniquePaths = (Hashtable<TreePath, Boolean>) f.get("uniquePaths", null); uniquePaths = newUniquePaths; @SuppressWarnings("unchecked") Hashtable<TreePath, Boolean> newLastPaths = (Hashtable<TreePath, Boolean>) f.get("lastPaths", null); lastPaths = newLastPaths; tempPaths = (TreePath[]) f.get("tempPaths", null); Object[] tValues; tValues = (Object[])s.readObject(); if (tValues.length > 0 && tValues[0].equals("rowMapper")) { RowMapper newRowMapper = (RowMapper) tValues[1]; if (newRowMapper == null) { throw new InvalidObjectException("Null newRowMapper"); } rowMapper = newRowMapper; } }
Example #23
Source File: DefaultTreeSelectionModel.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Creates a new instance of DefaultTreeSelectionModel that is * empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION. */ public DefaultTreeSelectionModel() { listSelectionModel = new DefaultListSelectionModel(); selectionMode = DISCONTIGUOUS_TREE_SELECTION; leadIndex = leadRow = -1; uniquePaths = new Hashtable<TreePath, Boolean>(); lastPaths = new Hashtable<TreePath, Boolean>(); tempPaths = new TreePath[1]; }
Example #24
Source File: DefaultTreeSelectionModel.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Creates a new instance of DefaultTreeSelectionModel that is * empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION. */ public DefaultTreeSelectionModel() { listSelectionModel = new DefaultListSelectionModel(); selectionMode = DISCONTIGUOUS_TREE_SELECTION; leadIndex = leadRow = -1; uniquePaths = new Hashtable<TreePath, Boolean>(); lastPaths = new Hashtable<TreePath, Boolean>(); tempPaths = new TreePath[1]; }
Example #25
Source File: DefaultTreeSelectionModel.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Creates a new instance of DefaultTreeSelectionModel that is * empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION. */ public DefaultTreeSelectionModel() { listSelectionModel = new DefaultListSelectionModel(); selectionMode = DISCONTIGUOUS_TREE_SELECTION; leadIndex = leadRow = -1; uniquePaths = new Hashtable<TreePath, Boolean>(); lastPaths = new Hashtable<TreePath, Boolean>(); tempPaths = new TreePath[1]; }
Example #26
Source File: DefaultTreeSelectionModel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Makes sure the currently selected <code>TreePath</code>s are valid * for the current selection mode. * If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code> * and a <code>RowMapper</code> exists, this will make sure all * the rows are contiguous, that is, when sorted all the rows are * in order with no gaps. * If the selection isn't contiguous, the selection is * reset to contain the first set, when sorted, of contiguous rows. * <p> * If the selection mode is <code>SINGLE_TREE_SELECTION</code> and * more than one TreePath is selected, the selection is reset to * contain the first path currently selected. */ protected void insureRowContinuity() { if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION && selection != null && rowMapper != null) { DefaultListSelectionModel lModel = listSelectionModel; int min = lModel.getMinSelectionIndex(); if(min != -1) { for(int counter = min, maxCounter = lModel.getMaxSelectionIndex(); counter <= maxCounter; counter++) { if(!lModel.isSelectedIndex(counter)) { if(counter == min) { clearSelection(); } else { TreePath[] newSel = new TreePath[counter - min]; int selectionIndex[] = rowMapper.getRowsForPaths(selection); // find the actual selection pathes corresponded to the // rows of the new selection for (int i = 0; i < selectionIndex.length; i++) { if (selectionIndex[i]<counter) { newSel[selectionIndex[i]-min] = selection[i]; } } setSelectionPaths(newSel); break; } } } } } else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION && selection != null && selection.length > 1) { setSelectionPath(selection[0]); } }
Example #27
Source File: DefaultTreeSelectionModel.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Makes sure the currently selected <code>TreePath</code>s are valid * for the current selection mode. * If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code> * and a <code>RowMapper</code> exists, this will make sure all * the rows are contiguous, that is, when sorted all the rows are * in order with no gaps. * If the selection isn't contiguous, the selection is * reset to contain the first set, when sorted, of contiguous rows. * <p> * If the selection mode is <code>SINGLE_TREE_SELECTION</code> and * more than one TreePath is selected, the selection is reset to * contain the first path currently selected. */ protected void insureRowContinuity() { if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION && selection != null && rowMapper != null) { DefaultListSelectionModel lModel = listSelectionModel; int min = lModel.getMinSelectionIndex(); if(min != -1) { for(int counter = min, maxCounter = lModel.getMaxSelectionIndex(); counter <= maxCounter; counter++) { if(!lModel.isSelectedIndex(counter)) { if(counter == min) { clearSelection(); } else { TreePath[] newSel = new TreePath[counter - min]; int selectionIndex[] = rowMapper.getRowsForPaths(selection); // find the actual selection pathes corresponded to the // rows of the new selection for (int i = 0; i < selectionIndex.length; i++) { if (selectionIndex[i]<counter) { newSel[selectionIndex[i]-min] = selection[i]; } } setSelectionPaths(newSel); break; } } } } } else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION && selection != null && selection.length > 1) { setSelectionPath(selection[0]); } }
Example #28
Source File: DefaultTreeSelectionModel.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Makes sure the currently selected <code>TreePath</code>s are valid * for the current selection mode. * If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code> * and a <code>RowMapper</code> exists, this will make sure all * the rows are contiguous, that is, when sorted all the rows are * in order with no gaps. * If the selection isn't contiguous, the selection is * reset to contain the first set, when sorted, of contiguous rows. * <p> * If the selection mode is <code>SINGLE_TREE_SELECTION</code> and * more than one TreePath is selected, the selection is reset to * contain the first path currently selected. */ protected void insureRowContinuity() { if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION && selection != null && rowMapper != null) { DefaultListSelectionModel lModel = listSelectionModel; int min = lModel.getMinSelectionIndex(); if(min != -1) { for(int counter = min, maxCounter = lModel.getMaxSelectionIndex(); counter <= maxCounter; counter++) { if(!lModel.isSelectedIndex(counter)) { if(counter == min) { clearSelection(); } else { TreePath[] newSel = new TreePath[counter - min]; int[] selectionIndex = rowMapper.getRowsForPaths(selection); // find the actual selection pathes corresponded to the // rows of the new selection for (int i = 0; i < selectionIndex.length; i++) { if (selectionIndex[i]<counter) { newSel[selectionIndex[i]-min] = selection[i]; } } setSelectionPaths(newSel); break; } } } } } else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION && selection != null && selection.length > 1) { setSelectionPath(selection[0]); } }
Example #29
Source File: DefaultTreeSelectionModel.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Makes sure the currently selected <code>TreePath</code>s are valid * for the current selection mode. * If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code> * and a <code>RowMapper</code> exists, this will make sure all * the rows are contiguous, that is, when sorted all the rows are * in order with no gaps. * If the selection isn't contiguous, the selection is * reset to contain the first set, when sorted, of contiguous rows. * <p> * If the selection mode is <code>SINGLE_TREE_SELECTION</code> and * more than one TreePath is selected, the selection is reset to * contain the first path currently selected. */ protected void insureRowContinuity() { if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION && selection != null && rowMapper != null) { DefaultListSelectionModel lModel = listSelectionModel; int min = lModel.getMinSelectionIndex(); if(min != -1) { for(int counter = min, maxCounter = lModel.getMaxSelectionIndex(); counter <= maxCounter; counter++) { if(!lModel.isSelectedIndex(counter)) { if(counter == min) { clearSelection(); } else { TreePath[] newSel = new TreePath[counter - min]; int selectionIndex[] = rowMapper.getRowsForPaths(selection); // find the actual selection pathes corresponded to the // rows of the new selection for (int i = 0; i < selectionIndex.length; i++) { if (selectionIndex[i]<counter) { newSel[selectionIndex[i]-min] = selection[i]; } } setSelectionPaths(newSel); break; } } } } } else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION && selection != null && selection.length > 1) { setSelectionPath(selection[0]); } }
Example #30
Source File: DefaultTreeSelectionModel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Creates a new instance of DefaultTreeSelectionModel that is * empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION. */ public DefaultTreeSelectionModel() { listSelectionModel = new DefaultListSelectionModel(); selectionMode = DISCONTIGUOUS_TREE_SELECTION; leadIndex = leadRow = -1; uniquePaths = new Hashtable<TreePath, Boolean>(); lastPaths = new Hashtable<TreePath, Boolean>(); tempPaths = new TreePath[1]; }