private void callListenersRemove(ListEdit<T> edit, ListDataEvent dataEvent) { assert (!editProtection[0]); editProtection[0] = true; try { if (edit != null) { addEdit(edit); } for (ListDataListener l : listDataListeners) { l.intervalRemoved(dataEvent); } } finally { editProtection[0] = false; } }
private void callListenersSet(ListEdit<T> edit, ListDataEvent dataEvent) { assert (!editProtection[0]); editProtection[0] = true; try { if (edit != null) { addEdit(edit); } if (dataEvent != null) { for (ListDataListener l : listDataListeners) { l.contentsChanged(dataEvent); } } } finally { editProtection[0] = false; } }
public void contentsChanged(ListDataEvent e) { if (customWidth < 0) { if (rModel.getContent() == null) { longestText = -1; resultWidth = -1; } else { for (CategoryResult r : rModel.getContent()) { for (ItemResult i : r.getItems()) { int l = i.getDisplayName().length(); if (l > longestText) { longestText = l; resultWidth = -1; } } } } } updatePopup(evalTask != null); }
private void fireContentsChanged(int index) { final ListDataListener[] clone; synchronized (listeners) { clone = listeners.toArray(new ListDataListener[listeners.size()]); } final ListDataEvent event = new ListDataEvent( this, ListDataEvent.CONTENTS_CHANGED, index, index); for (ListDataListener listener: clone) { listener.contentsChanged(event); } }
public void contentsChanged(ListDataEvent e) { PlatformKey selectedPlatform = (PlatformKey) platformComboBoxModel.getSelectedItem(); JavaPlatform platform = getPlatform(selectedPlatform); if (platform != null && !((platformComboBoxModel instanceof PlatformComboBoxModel) && ((PlatformComboBoxModel)platformComboBoxModel).inUpdate)) { SpecificationVersion version = platform.getSpecification().getVersion(); if (selectedSourceLevel != null && selectedSourceLevel.compareTo(version) > 0 && !shouldChangePlatform(selectedSourceLevel, version) && !selectedPlatform.equals(activePlatform)) { // restore original platformComboBoxModel.setSelectedItem(activePlatform); return; } else { originalSourceLevel = null; } } activePlatform = selectedPlatform; resetCache(); }
/** * A new time came in via the connected timer * @param e only use the source of the list event data */ @Override public void intervalAdded(ListDataEvent e) { // Select first item if its brand new and we aren't editing another time TimeStorage s = (TimeStorage)e.getSource(); if ((s.getFinishedCount() == 1) && (time.getText().equals(""))) { Component compFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); while (compFocusOwner != null) { if ((compFocusOwner instanceof TimeEntry) || (compFocusOwner instanceof RunsTable)) { selectNext(0); // only select and pull focus if users isn't 'focused' doing something else break; } compFocusOwner = compFocusOwner.getParent(); } } // regardless, note the last timer data as the announcer panel wants it if (s.getFinishedCount() > 0) // should always be true but just in case { Messenger.sendEvent(MT.TIME_RECEIVED, s.getRun(s.getFinishedCount()-1)); } }
@Override public final void resultChanged(LookupEvent ev) { List<WizardAdapter> fresh = new ArrayList<WizardAdapter>(); for (ServerWizardProvider wizard : result.allInstances()) { // safety precaution shouldn't ever happen - used because of bridging if (wizard.getInstantiatingIterator() != null) { fresh.add(new WizardAdapter(wizard)); } } Collections.sort(fresh); synchronized (serverWizards) { serverWizards.clear(); serverWizards.addAll(fresh); } ListDataEvent event = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, fresh.size() - 1); for (ListDataListener l : listeners) { l.contentsChanged(event); } }
@Override public boolean addAll(int index, Collection<? extends T> c) { if (editProtection[0]) { throw new ConcurrentModificationException(); } list.addAll(index, c); callListenersAdd( new ListEdit<T>(ListEdit.Type.ADD_MULTIPLE, getMainList(), index + offset, c), new ListDataEvent(getMainList(), ListDataEvent.INTERVAL_ADDED, index + offset, index + offset + c.size() - 1) ); return true; }
@Override public void clear() { if (editProtection[0]) { throw new ConcurrentModificationException(); } Collection<T> copy = new ArrayList<T>(list); list.clear(); callListenersRemove( new ListEdit<T>(ListEdit.Type.REMOVE_MULTIPLE, getMainList(), offset, copy), new ListDataEvent(getMainList(), ListDataEvent.INTERVAL_REMOVED, offset, offset + copy.size() - 1) ); }
@Override public T set(int index, T element) { if (editProtection[0]) { throw new ConcurrentModificationException(); } T oldElement = list.set(index, element); callListenersSet( new ListEdit<T>(ListEdit.Type.SET, getMainList(), index + offset, oldElement, element), new ListDataEvent(getMainList(), ListDataEvent.CONTENTS_CHANGED, index + offset, index + offset) ); return oldElement; }
private void undoAdd(ListEdit<T> edit) { assert (edit.list.list.get(edit.index) == edit.item); edit.list.list.remove(edit.index); callListenersRemove( null, new ListDataEvent(edit.list, ListDataEvent.INTERVAL_REMOVED, edit.index, edit.index) ); }
private void undoRemove(ListEdit<T> edit) { edit.list.list.add(edit.index, edit.item); callListenersAdd( null, new ListDataEvent(edit.list, ListDataEvent.INTERVAL_ADDED, edit.index, edit.index) ); }
private void undoRemoveMultiple(ListEdit<T> edit) { int index = edit.index; for (T item : edit.items) { edit.list.list.add(index++, item); } callListenersAdd( null, new ListDataEvent(edit.list, ListDataEvent.INTERVAL_ADDED, edit.index, edit.index + edit.items.size()) ); }
private void redoSet(ListEdit<T> edit) { edit.list.list.set(edit.index, edit.item2); callListenersSet( null, new ListDataEvent(edit.list, ListDataEvent.CONTENTS_CHANGED, edit.index, edit.index) ); }
@Override public void addListDataListener(ListDataListener l) { if (listeners == null) { listeners = new ArrayList<ListDataListener>(3); event = new ListDataEvent(this, CONTENTS_CHANGED, -1, -1); } listeners.add(l); }
/** * Add a new class to the collection of defined classes * * @param classValue * class to be added to the model * @return true if class is new, false otherwise */ public boolean addClass(final String classValue) { if (!m_defClasses.contains(classValue)) { m_defClasses.add(classValue); dispatchListDataEvent(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, 0)); return true; } return false; }
@Override public void contentsChanged(final ListDataEvent e) { final ListDataListener[] lists = getDataListeners(); eventExecutor.execute(new Runnable() { @Override public void run() { for (ListDataListener list : lists) { list.contentsChanged(e); } } }); }
@Override public void addTabs(int start, TabData[] data) { list.addAll(start, Arrays.asList(data)); ComplexListDataEvent lde = new ComplexListDataEvent(this, ListDataEvent.INTERVAL_ADDED, start, start + data.length - 1, true); lde.setAffectedItems(data); fireIntervalAdded(lde); }
/** * Maps {@code JComboBox.intervalAdded(ListDataEvent)} through queue */ public void intervalAdded(final ListDataEvent listDataEvent) { runMapping(new MapVoidAction("intervalAdded") { @Override public void map() { ((JComboBox) getSource()).intervalAdded(listDataEvent); } }); }
private void fireIntervalRemoved(ListDataEvent event) { List<ComplexListDataListener> listeners = null; synchronized( LOCK ) { if (listenerList == null) { return; } listeners = new ArrayList<ComplexListDataListener>(listenerList); } for( ComplexListDataListener l : listeners ) { l.intervalRemoved(event); } cs.fireChange(); }
private void fireContentsChanged(ListDataEvent event) { List<ComplexListDataListener> listeners = null; synchronized( LOCK ) { if (listenerList == null) { return; } listeners = new ArrayList<ComplexListDataListener>(listenerList); } for( ComplexListDataListener l : listeners ) { l.contentsChanged(event); } cs.fireChange(); }
/** * DefaultTabDataModel will always call this method with an instance of * ComplexListDataEvent. */ public void contentsChanged(ListDataEvent e) { //Only need to reread components on setTab (does winsys even use it?) if (e instanceof ComplexListDataEvent) { ComplexListDataEvent clde = (ComplexListDataEvent) e; int index = clde.getIndex0(); if (clde.isUserObjectChanged() && index != -1) { Component comp = contentDisplayer.getComponent( index); Component nue = toComp(tabDisplayer.getModel().getTab(index)); contentDisplayer.remove(comp); boolean add = container.getContentPolicy() == TabbedContainer.CONTENT_POLICY_ADD_ALL || index == container.getSelectionModel().getSelectedIndex(); if (add) { contentDisplayer.add(nue, index); } } if (clde.isTextChanged()) { maybeMakeSelectedTabVisible(clde); } } }
public void intervalRemoved(ListDataEvent e) { // we know that it must be complex data event ComplexListDataEvent clde = (ComplexListDataEvent) e; TabData[] removedTabs = clde.getAffectedItems(); Component curComp; for (int i = 0; i < removedTabs.length; i++) { curComp = toComp(removedTabs[i]); contentDisplayer.remove(curComp); } }
/** * Remove a device from the data model, except it has messages in the log * cache. */ private void remove(String device) { // do we have log events for this device? if (reader.getLogEventsForDevice(device) != null) { // if true, we want to keep it return; } for (int i = devices.size(); --i >= 0;) { if (devices.get(i).equals(device)) { devices.remove(i); fireListDataEvent(ListDataEvent.INTERVAL_REMOVED, i); } } }
public void intervalAdded(ListDataEvent e) { lastListenerCall="intervalAdded"; assertPravda (e.getIndex0() <= e.getIndex1(), "Event start index > end index"); lastEvent = (ComplexListDataEvent)e; if (noEvent) { assertPravda (false, "No event expected but " + e + " receieved"); } }
public void intervalAdded(ListDataEvent e) { lastListenerCall="intervalAdded"; lastEvent = (ComplexListDataEvent)e; if (noEvent) { assertPravda (false, "No event expected but " + e + " receieved"); } }
public void intervalRemoved(ListDataEvent e) { lastListenerCall="intervalRemoved"; lastEvent = (ComplexListDataEvent)e; if (noEvent) { assertPravda (false, "No event expected but " + e + " receieved"); } }
/** * Removes a given class from the model * * @param classLabel * class to be removed * @return true, if class existed */ public boolean removeClass(final String classLabel) { final boolean existed = m_defClasses.remove(classLabel); dispatchListDataEvent( new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, 0)); return existed; }
@Override public void intervalRemoved (ListDataEvent listDataEvent) { if (external == null) { return; } updateYourAssumeptions (); int first = listDataEvent.getIndex0 (); int end = listDataEvent.getIndex1 () + 1; int len = end - first; int newOriginalSize = originalSize - len; int f = findExternalIndex (first); int e = findExternalIndex (end); assert f >= 0 : "First index must be above zero: " + f; // NOI18N assert e >= f : "End index must be above first: " + f + " <= " + e; // NOI18N int outLen = e - f; int[] newExternal = (int[])external.clone (); for (int i = e; i < size; i++) { int v = external[i]; newExternal[i - outLen] = v < 0 ? v : v - len; checked.set (i - outLen, v >= 0); } external = newExternal; size -= outLen; originalSize = newOriginalSize; if (outLen != 0) { fireChange (new ListDataEvent (this, ListDataEvent.INTERVAL_REMOVED, f, e - 1)); } assert externalContraints () : "Constraints failed"; // NOI18N }
/** * Maps {@code JComboBox.intervalRemoved(ListDataEvent)} through queue */ public void intervalRemoved(final ListDataEvent listDataEvent) { runMapping(new MapVoidAction("intervalRemoved") { @Override public void map() { ((JComboBox) getSource()).intervalRemoved(listDataEvent); } }); }
@Override public void intervalAdded(ListDataEvent e) { if (isScrollingToTopOnChange) { Accessible accessibleChild = ExtendedJComboBox.this.getUI().getAccessibleChild(ExtendedJComboBox.this, 0); if (!(accessibleChild instanceof JPopupMenu)) { return; } Object scrollPaneObject = ((JPopupMenu) accessibleChild).getComponent(0); if (scrollPaneObject instanceof JScrollPane) { ((JScrollPane) scrollPaneObject).getVerticalScrollBar().setValue(0); } } }
/** * Remove class at index * * @param index * position of the class to be removed in the models * @return the removed element */ public String removeClassAt(final int index) { final String removed = m_defClasses.remove(index); dispatchListDataEvent(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index)); return removed; }
@Override public void intervalAdded(ListDataEvent e) { for (int i = e.getIndex1(); i >= e.getIndex0(); i--) { Object obj = listModel.getElementAt(i); if (obj instanceof ClassPathSupport.Item) { DefaultMutableTreeNode node = toTreeNode(obj); treeModel.insertNodeInto(node, (MutableTreeNode)treeModel.getRoot(), e.getIndex0()); TreePath path = new TreePath(node.getPath()); tree.setSelectionPath(path); tree.makeVisible(path); } } }
@Override public void intervalAdded(final ListDataEvent e) { final ListDataListener[] lists = getDataListeners(); eventExecutor.execute(new Runnable() { @Override public void run() { for (ListDataListener list : lists) { list.intervalAdded(e); } } }); }
@Override public void intervalRemoved(final ListDataEvent e) { final ListDataListener[] lists = getDataListeners(); eventExecutor.execute(new Runnable() { @Override public void run() { for (ListDataListener list : lists) { list.intervalRemoved(e); } } }); }
@Override public void contentsChanged(ListDataEvent e) { updatePopup(); }
public void add(T toAdd) { values.add(toAdd); listeners.stream().forEach(l -> l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, values.size() - 1, values.size() - 1))); }
public void remove(T toRemove) { int location = indexOf(toRemove); values.remove(toRemove); listeners.stream().forEach(l -> l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, location, location))); }
public void intervalRemoved(ListDataEvent e) { updatePopup(evalTask != null); }
protected void rowsUpdated(int rstart, int rend) { fireChange(new TableModelEvent(this, rstart, rend, TableModelEvent.ALL_COLUMNS, TableModelEvent.UPDATE), new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, rstart, rend)); }