Java Code Examples for javax.swing.event.ListDataEvent#INTERVAL_REMOVED

The following examples show how to use javax.swing.event.ListDataEvent#INTERVAL_REMOVED . 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: FilteredListModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void fireChange (ListDataEvent ev) {
    if (list.getListenerCount () == 0) {
        return ;
    }
    Object[] arr = list.getListenerList ();
    for (int i = arr.length - 1; i >= 0; i -= 2) {
        ListDataListener l = (ListDataListener)arr[i];
        switch (ev.getType ()) {
            case ListDataEvent.CONTENTS_CHANGED: l.contentsChanged (ev); break;
            case ListDataEvent.INTERVAL_ADDED: l.intervalAdded (ev); break;
            case ListDataEvent.INTERVAL_REMOVED: l.intervalRemoved (ev); break;
            default:
                throw new IllegalArgumentException  ("Unknown type: " + ev.getType ());
        }
    }
}
 
Example 2
Source File: LogDevicesComboBoxSupport.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void fireListDataEvent(int type, int index1, int index2) {
    ListDataEvent event = new ListDataEvent(this, type, index1, index2);

    for (ListDataListener listener : dataListeners) {
        switch (type) {
            case ListDataEvent.CONTENTS_CHANGED: {
                listener.contentsChanged(event);
                break;
            }

            case ListDataEvent.INTERVAL_ADDED: {
                listener.intervalAdded(event);
                break;
            }

            case ListDataEvent.INTERVAL_REMOVED: {
                listener.intervalRemoved(event);
                break;
            }
        }

    }
}
 
Example 3
Source File: ObservableList.java    From pumpernickel with MIT License 6 votes vote down vote up
protected void fireListDataListeners(ListDataEvent event) {
	for (ListDataListener listener : listDataListeners) {
		switch (event.getType()) {
		case ListDataEvent.CONTENTS_CHANGED:
			listener.contentsChanged(event);
			break;
		case ListDataEvent.INTERVAL_ADDED:
			listener.intervalAdded(event);
			break;
		case ListDataEvent.INTERVAL_REMOVED:
			listener.intervalRemoved(event);
			break;
		default:
			throw new IllegalArgumentException("Unsupported event: "
					+ event);
		}
	}
}
 
Example 4
Source File: DefaultTabDataModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void removeTab(int index) {
    TabData[] td = new TabData[]{(TabData) list.get(index)};
    list.remove(index);
    ComplexListDataEvent lde = new ComplexListDataEvent(this,
                                                        ListDataEvent.INTERVAL_REMOVED,
                                                        index, index);
    lde.setAffectedItems(td);
    fireIntervalRemoved(lde);
}
 
Example 5
Source File: DefaultTabDataModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Remove a range of tabs from <code>start</code> up to <i>and including</i> 
 * <code>finish</code>.
 */
@Override
public void removeTabs(int start, int end) {
    java.util.List affected = new ArrayList(list.subList(start, end));
    if (start == end) {
        list.remove(start);
    } else {
        list.removeRange(start, end);
    }
    ComplexListDataEvent lde = new ComplexListDataEvent(this,
                                                        ListDataEvent.INTERVAL_REMOVED,
                                                        start, end);
    lde.setAffectedItems((TabData[]) affected.toArray(new TabData[0]));
    fireIntervalRemoved(lde);
}
 
Example 6
Source File: FilteredListModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Notifies removal of inteval from (inclusive) to (exclusive) and
 * updates its structures.
 *
 * !!! as a side effect updates size !!!
 *
 * @return s - number of removals
 */
private void notifyRemoval (int from, int to) {
    ListDataEvent ev = new ListDataEvent (
        this, ListDataEvent.INTERVAL_REMOVED, from, to - 1
    );
    removeInterval (external, from, to);
    int cnt = to - from;
    size -= cnt;

    regenerateCheckedBitSet ();
    fireChange (ev);
}
 
Example 7
Source File: KeyedComboBoxModel.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Removes an entry from the model.
 *
 * @param key the key
 */
public void removeDataElement(final Object key)
{
  final int idx = findDataElementIndex(key);
  if (idx == -1)
  {
    return;
  }

  this.data.remove(idx);
  final ListDataEvent evt = new ListDataEvent
      (this, ListDataEvent.INTERVAL_REMOVED, idx, idx);
  fireListDataEvent(evt);
}
 
Example 8
Source File: KeyedComboBoxModel.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Removes all entries from the model.
 */
public void clear()
{
  final int size = getSize();
  this.data.clear();
  final ListDataEvent evt = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, 0, size - 1);
  fireListDataEvent(evt);
}
 
Example 9
Source File: RemoveElementsEvent.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected ListDataEvent createListDataEvent() {
	int minIndex = removedElements.firstKey();
	int maxIndex = removedElements.lastKey();
	// I'm not entirely sure how ListDataListeners expected to hear about
	// removals?
	// Is this one event sufficient?
	return new ListDataEvent(getSource(), ListDataEvent.INTERVAL_REMOVED,
			minIndex, maxIndex);
}
 
Example 10
Source File: ObjectTree.java    From FastDMM with GNU General Public License v3.0 5 votes vote down vote up
public void removeInstance(ObjInstance instance) {
	int index = instances.indexOf(instance);
	if(index == -1)
		return;
	instances.remove(instance);
	ListDataEvent event = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index);
	for(ListDataListener l : listeners) {
		l.intervalRemoved(event);
	}
}
 
Example 11
Source File: KeyedComboBoxModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Removes an entry from the model.
 *
 * @param key the key
 */
public void removeDataElement( final K key ) {
  final int idx = findDataElementIndex( key );
  if ( idx == -1 ) {
    return;
  }

  data.remove( idx );
  final ListDataEvent evt = new ListDataEvent
    ( this, ListDataEvent.INTERVAL_REMOVED, idx, idx );
  fireListDataEvent( evt );
}
 
Example 12
Source File: ElementOrderer.java    From Digital with GNU General Public License v3.0 4 votes vote down vote up
private void fireEventDeleted(int item) {
    ListDataEvent e = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, item, item);
    for (ListDataListener l : listener)
        l.contentsChanged(e);
}
 
Example 13
Source File: KeyedComboBoxModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void remove( final int index ) {
  data.remove( index );
  final ListDataEvent evt = new ListDataEvent( this, ListDataEvent.INTERVAL_REMOVED, index, index );
  fireListDataEvent( evt );
}