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

The following examples show how to use javax.swing.event.ListDataEvent#CONTENTS_CHANGED . 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: KeyedComboBoxModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Replaces the data in this combobox model. The number of keys must be equals to the number of values.
 *
 * @param keys   the keys
 * @param values the values
 */
public void setData( final K[] keys, final V[] values ) {
  if ( values.length != keys.length ) {
    throw new IllegalArgumentException( "Values and text must have the same length." );
  }

  data.clear();
  data.ensureCapacity( keys.length );

  for ( int i = 0; i < values.length; i++ ) {
    add( keys[ i ], values[ i ] );
  }

  selectedItemIndex = -1;
  final ListDataEvent evt = new ListDataEvent
    ( this, ListDataEvent.CONTENTS_CHANGED, 0, data.size() - 1 );
  fireListDataEvent( evt );
}
 
Example 2
Source File: NbCustomizeSelectionDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void fireRowChanged(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);
    }
}
 
Example 3
Source File: DefaultTabDataModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void setTab(int index, TabData data) {
    if (!data.equals(getTab(index))) {
        TabData olddata = getTab(index);
        boolean txtChg = data.getText().equals(olddata.getText());
        boolean compChg = data.getUserObject() != olddata.getUserObject();
        list.set(index, data);
        ComplexListDataEvent lde = new ComplexListDataEvent(this,
                                                            ListDataEvent.CONTENTS_CHANGED,
                                                            index, index,
                                                            txtChg,
                                                            compChg);
        lde.setAffectedItems(new TabData[]{data});
        fireContentsChanged(lde);
    }
}
 
Example 4
Source File: RowHeaderList.java    From CXTouch with GNU General Public License v3.0 6 votes vote down vote up
private void mainModelChanged(ListDataEvent e) {
    RowNumberListModel listModel = (RowNumberListModel) getModel();
    int listRowCount = listModel.getSize();
    int mainRowCount = RowHeaderList.this.getModel().getSize();
    if (mainRowCount == listRowCount) {
        if ( e.getType() == ListDataEvent.CONTENTS_CHANGED ) {
            listModel.fireContentsChanged(e.getIndex0(), e.getIndex1());
        }
        return;
    }

    listModel.setSize(mainRowCount);
    if (mainRowCount == 0) {
        return;
    }

    Insets insets = getInsets();
    ListCellRenderer cellRender = getCellRenderer();
    int with = (int) cellRender.getListCellRendererComponent(this, null, mainRowCount - 1, false, false)
            .getPreferredSize().getWidth() + insets.left + insets.right;
    setFixedCellWidth(with);
}
 
Example 5
Source File: LicenseComboBoxModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 6
Source File: ServerWizardVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 7
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 8
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 9
Source File: KeyedComboBoxModel.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Replaces the data in this combobox model. The number of keys must be
 * equals to the number of values.
 *
 * @param keys   the keys
 * @param values the values
 */
public void setData(final Object[] keys, final Object[] values)
{
  if (values.length != keys.length)
  {
    throw new IllegalArgumentException("Values and text must have the same length.");
  }

  this.data.clear();
  this.data.ensureCapacity(keys.length);

  for (int i = 0; i < values.length; i++)
  {
    add(keys[i], values[i]);
  }

  this.selectedItemIndex = -1;
  final ListDataEvent evt = new ListDataEvent
      (this, ListDataEvent.CONTENTS_CHANGED, 0, this.data.size() - 1);
  fireListDataEvent(evt);
}
 
Example 10
Source File: VerifierFactoryListModel.java    From commons-bcel with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void update(final String s) {
    final Verifier[] verifiers = VerifierFactory.getVerifiers();
    final int num_of_verifiers = verifiers.length;
    cache.clear();
    for (final Verifier verifier : verifiers) {
        cache.add(verifier.getClassName());
    }
    for (final ListDataListener listener : listeners) {
        final ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, num_of_verifiers - 1);
        listener.contentsChanged(e);
    }
}
 
Example 11
Source File: ListModelHolder.java    From blog with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
	ListModelHolder<?> listModelHolder = (ListModelHolder<?>) evt.getSource();
	ListModel<?> listModel = listModelHolder.getModel();
	int size = listModel.getSize();

	ListDataEvent contentsChanged = new ListDataEvent(listModel, ListDataEvent.CONTENTS_CHANGED, 0, size);

	List<ListDataListener> listDataListeners = listModelHolder.getListDataListeners();
	for (ListDataListener listDataListener : listDataListeners) {
		listDataListener.contentsChanged(contentsChanged);
	}

}
 
Example 12
Source File: LineSelectUI.java    From Spark-Reader with GNU General Public License v3.0 5 votes vote down vote up
public void update()
{
    ListDataEvent event = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize());
    for(ListDataListener ldl:listeners)
    {
        ldl.contentsChanged(event);
    }
}
 
Example 13
Source File: UserDefPage.java    From Spark-Reader with GNU General Public License v3.0 5 votes vote down vote up
public void update()
{
    //TODO don't be lazy on listDataEvent here
    ListDataEvent event = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize());
    for(ListDataListener listener:listeners)
    {
        listener.contentsChanged(event);
    }
}
 
Example 14
Source File: ExceptionsListModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void fireListUpdate() {
  final ListDataListener[] listDataListeners = listenerList.getListeners( ListDataListener.class );
  final ListDataEvent event = new ListDataEvent( this, ListDataEvent.CONTENTS_CHANGED, -1, -1 );
  for ( int i = 0; i < listDataListeners.length; i++ ) {
    final ListDataListener listener = listDataListeners[ i ];
    listener.contentsChanged( event );
  }
}
 
Example 15
Source File: KeyedComboBoxModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void update( final int index, final K key, final V cbitem ) {
  final ComboBoxItemPair<K, V> con = new ComboBoxItemPair<K, V>( key, cbitem );
  data.set( index, con );
  final ListDataEvent evt = new ListDataEvent
    ( this, ListDataEvent.CONTENTS_CHANGED, index, index );
  fireListDataEvent( evt );
}
 
Example 16
Source File: ROMEditorDialog.java    From Digital with GNU General Public License v3.0 4 votes vote down vote up
private void fireChanged(int i) {
    ListDataEvent ev = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, i, i);
    for (ListDataListener l : listeners)
        l.contentsChanged(ev);
}
 
Example 17
Source File: ElementOrderer.java    From Digital with GNU General Public License v3.0 4 votes vote down vote up
private void fireEvent(int min, int max) {
    ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, min, max);
    for (ListDataListener l : listener)
        l.contentsChanged(e);
}
 
Example 18
Source File: ChannelFilterSink.java    From clearvolume with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void sendVolume(Volume pVolume)
{
	synchronized (mLock)
	{
		final int lChannelID = pVolume.getChannelID();
		final String lChannelName = pVolume.getChannelName();

		if (mChanneltoVolumeMap.get(lChannelID) != null)
			if (mVolumeSinkForFilteredVolumes != null)
				mVolumeSinkForFilteredVolumes.sendVolume(mChanneltoVolumeMap.get(lChannelID));
		mChanneltoVolumeMap.put(lChannelID, pVolume);

		if (!mSeenChannelList.contains(lChannelID))
		{
			mSeenChannelList.add(lChannelID);
			mActiveChannelMap.put(lChannelID, true);
			final ListDataListener[] lListeners = mChannelListModel.getListeners(ListDataListener.class);
			for (final ListDataListener lListDataListener : lListeners)
			{
				final ListDataEvent lListDataEvent = new ListDataEvent(	lListDataListener,
																		ListDataEvent.CONTENTS_CHANGED,
																		0,
																		mSeenChannelList.size());
				SwingUtilities.invokeLater(new Runnable()
				{

					@Override
					public void run()
					{
						lListDataListener.contentsChanged(lListDataEvent);
					};
				});

			}
		}
		mSeenChannelIdToNameMap.put(lChannelID, lChannelName);

		sendVolumeInternal(lChannelID);
	}
}
 
Example 19
Source File: ReplaceElementsEvent.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
protected ListDataEvent createListDataEvent() {
	return new ListDataEvent(getSource(), ListDataEvent.CONTENTS_CHANGED,
			0, newElements.size() - 1);
}
 
Example 20
Source File: JavaPlatformComponentFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void fireChange() {
    ListDataEvent ev = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, 0);
    for (ListDataListener l : new ArrayList<ListDataListener>(listeners)) {
        l.contentsChanged(ev);
    }
}