public void addSelectedItem(B toSelect) { Collection<B> oldValue = Lists.newArrayList(selectedValues); selectedValues.add(toSelect); int index = selectedValues.indexOf(toSelect); super.addSelectionInterval(index, index); fireSelectionAdded(Lists.newArrayList(toSelect)); firePropertyChange(PROPERTY_SELECTED_VALUE, oldValue, selectedValues); }
public void addSelectedItem(B toSelect) { Collection<B> oldValue = Lists.newArrayList(selectedValues); selectedValues.add(toSelect); int index = selectedValues.indexOf(toSelect); super.addSelectionInterval(index, index); fireSelectionAdded(Lists.newArrayList(toSelect)); firePropertyChange(PROPERTY_SELECTED_VALUE, oldValue, selectedValues); }
@Override public void addSelectionInterval(int index0, int index1) { Collection<B> oldValue = Lists.newArrayList(selectedValues); addSelectionIntervalWithFire(index0, index1); super.addSelectionInterval(index0, index1); Collection<B> newValue = Lists.newArrayList(selectedValues); newValue.removeAll(oldValue); fireSelectionAdded(newValue); firePropertyChange(PROPERTY_SELECTED_VALUE, oldValue, selectedValues); }
@Override public void addSelectionInterval(int index0, int index1) { Collection<B> oldValue = Lists.newArrayList(selectedValues); addSelectionIntervalWithFire(index0, index1); super.addSelectionInterval(index0, index1); Collection<B> newValue = Lists.newArrayList(selectedValues); newValue.removeAll(oldValue); fireSelectionAdded(newValue); firePropertyChange(PROPERTY_SELECTED_VALUE, oldValue, selectedValues); }
@Override public void addSelectionInterval(int index0, int index1) { if (index0 == index1) { if (isSelectedIndex(index0)) { removeSelectionInterval(index0, index0); return; } super.addSelectionInterval(index0, index1); } } });
public void addSelectionInterval(int index0, int index1) { super.addSelectionInterval(index0, index1); logger.info("addSelectionInterval ix0=" + index0 + " ix1=" + index1); logger.info("addSelectionInterval getValueIsAdjusting=" + getValueIsAdjusting()); // only add if not already selected, this is to prevent partly selected sequence to // be fully selected when a drag event is initiated int minIndex = Math.min(index0, index1); int maxIndex = Math.max(index0, index1); boolean shouldChange = false; for(int n = minIndex; n <= maxIndex; n++){ if(!aliSelectionModel.isSequenceAtLeastPartlySelected(n)){ shouldChange = true; } } if(shouldChange){ aliSelectionModel.addSequenceSelection(index0, index1); } }
private void onMoveUp() { int[] selRows = _panel.tblOrder.getSelectedRows(); if (null == selRows || 0 == selRows.length) { return; } SortedColumnsTableModel model = (SortedColumnsTableModel) _panel.tblOrder.getModel(); int[] newSelRows = model.moveUp(selRows); DefaultListSelectionModel selectionModel = (DefaultListSelectionModel) _panel.tblOrder.getSelectionModel(); selectionModel.clearSelection(); for (int newSelRow : newSelRows) { selectionModel.addSelectionInterval(newSelRow, newSelRow); } _panel.tblOrder.scrollRectToVisible(_panel.tblOrder.getCellRect(newSelRows[0], 0, false)); }
private void onMoveDown() { int[] selRows = _panel.tblOrder.getSelectedRows(); if (null == selRows || 0 == selRows.length) { return; } SortedColumnsTableModel model = (SortedColumnsTableModel) _panel.tblOrder.getModel(); int[] newSelRows = model.moveDown(selRows); DefaultListSelectionModel selectionModel = (DefaultListSelectionModel) _panel.tblOrder.getSelectionModel(); selectionModel.clearSelection(); for (int newSelRow : newSelRows) { selectionModel.addSelectionInterval(newSelRow, newSelRow); } _panel.tblOrder.scrollRectToVisible(_panel.tblOrder.getCellRect(newSelRows[newSelRows.length-1], 0, false)); }
/** * Updates the list of available token properties. */ private void updateProperties() { ArrayList<TokenProperty> sorted = new ArrayList<TokenProperty>(this.canvas.getUsedProperties()); Collections.sort(sorted); int index = 0; listModel.clear(); listModel = new DefaultListModel(); DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); for (TokenProperty p : sorted) { listModel.addElement(p); if (!this.tokenFilter.getForbiddenTokenProperties().contains(p) && !list.isSelectedIndex(index)) selectionModel.addSelectionInterval(index, index); ++index; } list.setModel(listModel); list.setSelectionModel(selectionModel); }
private void selectAllIf() { if (getAllEntryIndex() < 0) { return; } for (int i = getModel().getSize() - 1; i >= 0; i--) { if (i != getAllEntryIndex() && !isSelectedIndex(i)) { return; } } super.addSelectionInterval(getAllEntryIndex(), getAllEntryIndex()); }
@Override public void addSelectionInterval(int index0, int index1) { boolean adjusting = getValueIsAdjusting(); setValueIsAdjusting(true); try { if (!selectAll(index0, index1)) { super.addSelectionInterval(index0, index1); selectAllIf(); } } finally { setValueIsAdjusting(adjusting); } }
"Item 6", "Item 7" }; JComboBox cbox = new JComboBox(list); model.addSelectionInterval(SELECTION_INTERVAL[0], SELECTION_INTERVAL[1]); enableRenderer.setEnabledItems(model); cbox.setRenderer(enableRenderer);
protected void updateFromDja() { if (isInternalUpdate_) { return; } isInternalUpdate_ = true; for (int i = getSize() - 1; i >= 0; i--) { boolean selected = isSelectedInDjaVector(i); if (selected && !model_.isSelectedIndex(i)) { model_.addSelectionInterval(i, i); } else if (!selected && model_.isSelectedIndex(i)) { model_.removeSelectionInterval(i, i); } } isInternalUpdate_ = false; }
@Override public void setSelectionInterval(int index0, int index1) { // Toggle only one element while the user is dragging the mouse if (!gestureStarted) { if (isSelectedIndex(index0)) { super.removeSelectionInterval(index0, index1); } else { if (getSelectionMode() == SINGLE_SELECTION) { super.setSelectionInterval(index0, index1); } else { super.addSelectionInterval(index0, index1); } } } // Disable toggling till the adjusting is over, or keep it // enabled in case setSelectionInterval was called directly. gestureStarted = getValueIsAdjusting(); }
/** * Respond to a change in the view selection by updating the view selection. * * @param firstIndex the first view index that changed, inclusive * @param lastIndex the last view index that changed, inclusive */ private void mapTowardsModel(int firstIndex, int lastIndex) { int safeFirstIndex = Math.max(0, firstIndex); // Fix for #855-swingx: JXList AIOOB on select after remove/add data items int safeLastIndex = getSafeLastIndex(lastIndex); for (int i = safeFirstIndex; i <= safeLastIndex; i++) { int modelIndex = convertToModel(i); if (viewSelection.isSelectedIndex(i)) { modelSelection.addSelectionInterval(modelIndex, modelIndex); } else { modelSelection.removeSelectionInterval(modelIndex, modelIndex); } } int lead = viewSelection.getLeadSelectionIndex(); if (lead >= 0) { modelSelection.moveLeadSelectionIndex(convertToModel(lead)); } }
/** * Populate view selection from model selection. */ private void mapTowardsModel() { if(modelSelection == null) return; clearModelSelection(); int[] selected = getSelectedRows(viewSelection); for (int i = 0; i < selected.length; i++) { int modelIndex = convertToModel(selected[i]); modelSelection.addSelectionInterval(modelIndex, modelIndex); } if (selected.length > 0) { // convert lead selection index to model coordinates modelSelection.moveLeadSelectionIndex(convertToModel(viewSelection.getLeadSelectionIndex())); } }
/** * Renvoie la liste de points de <code>_p </code> contenus dans le polygone <code>_polyRef</code>. * * @return null si aucun point n'appartient a <code>_polyRef</code>. */ public static final DefaultListSelectionModel pointsSelectionnes(final GrPolygone _poly, final GrPolygone _polyolyRef) { final GrBoite polyRefBoite = _polyolyRef.boite(); if (!polyRefBoite.intersectXY(_poly.boite())) { return null; } final int nb = _poly.nombre() - 1; GrPoint p; final DefaultListSelectionModel r = new DefaultListSelectionModel(); r.setValueIsAdjusting(true); for (int i = nb; i >= 0; i--) { p = _poly.sommet(i); if (p == null) { continue; } if (polyRefBoite.contientXY(p) && _polyolyRef.contientXY(p)) { r.addSelectionInterval(i, i); } } r.setValueIsAdjusting(false); return r.isSelectionEmpty() ? null : r; }
/** * Renvoie la liste de points de <code>_p </code> contenus dans le polygone <code>_polyRef</code>. * * @return null si aucun point n'appartient a <code>_polyRef</code>. */ public static final DefaultListSelectionModel pointsSelectionnes(final GrPolyligne _poly, final GrPolygone _polyRef) { final GrBoite polyRefBoite = _polyRef.boite(); if (!polyRefBoite.intersectXY(_poly.boite())) { return null; } final int nb = _poly.nombre() - 1; GrPoint p; final DefaultListSelectionModel r = new DefaultListSelectionModel(); r.setValueIsAdjusting(true); for (int i = nb; i >= 0; i--) { p = _poly.sommet(i); if (p == null) { continue; } if (polyRefBoite.contientXY(p) && _polyRef.contientXY(p)) { r.addSelectionInterval(i, i); } } r.setValueIsAdjusting(false); return r.isSelectionEmpty() ? null : r; } }
@Override public void addSelectionInterval(int index0, int index1) { super.addSelectionInterval(index0, index1); int contentSize = informer.getContentSize(); InsetPart part0 = inset.toInnerSpace(index0, contentSize); InsetPart part1 = inset.toInnerSpace(index1, contentSize); if (part0.getKind() == InsetPart.PartKind.CONTENT || part1.getKind() == InsetPart.PartKind.CONTENT || (part0.getKind() == InsetPart.PartKind.BEFORE && part1.getKind() == InsetPart.PartKind.AFTER)) { if (part0.getKind() == InsetPart.PartKind.BEFORE) { index0 = 0; } else { index0 = part0.getValue(); } if (part1.getKind() == InsetPart.PartKind.AFTER) { index1 = contentSize - 1; } else { index1 = part1.getValue(); } delegate.addSelectionInterval(index0, index1); }//else ... }