javax.swing.event.ListDataListener Java Examples

The following examples show how to use javax.swing.event.ListDataListener. 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: 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 #3
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 #4
Source File: SWFListModel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds url to the list
 *
 * @param replacement URL to add
 */
public void addURL(Replacement replacement) {
    int sizeBefore = replacements.size();
    replacements.add(replacement);
    for (ListDataListener l : listeners) {
        l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, sizeBefore, sizeBefore));
    }
}
 
Example #5
Source File: GoToFilePanel.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
private void processEnteredPattern() {
  this.foundNodeList.clear();
  this.foundNodeList.addAll(this.tree.findForNamePattern(makePattern(this.textFieldMask.getText())));
  for (final ListDataListener l : this.listeners) {
    l.contentsChanged(new ListDataEvent(this.listFoundFiles.getModel(), ListDataEvent.CONTENTS_CHANGED, 0, this.foundNodeList.size()));
  }

  Collections.sort(this.foundNodeList, this);

  if (!this.foundNodeList.isEmpty()) {
    this.listFoundFiles.setSelectedIndex(0);
    this.listFoundFiles.ensureIndexIsVisible(0);
  }
}
 
Example #6
Source File: TaskModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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);
            }
        }
    });
}
 
Example #7
Source File: TaskModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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);
            }
        }
    });
}
 
Example #8
Source File: TaskModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
TaskModel(Executor eventExecutor) {
    selectionModel = new DefaultListSelectionModel();
    model = new DefaultListModel<>();
    dataListeners = new LinkedHashSet<ListDataListener>();
    selectionListeners = new LinkedHashSet<ListSelectionListener>();
    TaskListener list = new TaskListener();
    model.addListDataListener(list);
    selectionModel.addListSelectionListener(list);
    this.eventExecutor = eventExecutor;
}
 
Example #9
Source File: QueryDialogComboBoxModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void fireIntervalRemovedEvent( ListDataEvent event ) {
  ListDataListener[] listeners1 = listeners.getListeners( ListDataListener.class );
  for ( int i = listeners1.length - 1; i >= 0; i -= 1 ) {
    ListDataListener l = listeners1[i];
    l.intervalRemoved( event );
  }
}
 
Example #10
Source File: ListComboBoxModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void fireSelectionChange() {
    if (listeners == null) {
        return;
    }

    ListDataListener[] arrayListeners = listeners.toArray(new ListDataListener[0]);
    for (ListDataListener l : arrayListeners) {
        l.contentsChanged(event);
    }
}
 
Example #11
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 #12
Source File: DragDropList.java    From constellation with Apache License 2.0 5 votes vote down vote up
public MyElement removeMyElement(final int index) {
    final MyElement element = elements.get(index);
    elements.remove(index);
    for (ListDataListener l : listeners) {
        l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize() - 1));
    }

    return element;
}
 
Example #13
Source File: ExtensionSelenium.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the given WebDriver provider.
 *
 * @param webDriverProvider the WebDriver provider to remove
 * @throws IllegalArgumentException if the the given WebDriver provider is {@code null} or its
 *     ID is {@code null} or empty.
 * @since 1.1.0
 */
public void removeWebDriverProvider(SingleWebDriverProvider webDriverProvider) {
    validateWebDriverProvider(webDriverProvider);

    quitWebDrivers(proxiedWebDrivers.remove(webDriverProvider.getId()));
    webDriverProviders.remove(webDriverProvider.getId());
    providedBrowsers.remove(webDriverProvider.getProvidedBrowser().getId());
    buildProvidedBrowserUIList();

    if (getView() != null) {
        SwingUtilities.invokeLater(
                new Runnable() {
                    @Override
                    public void run() {
                        ListDataEvent ev =
                                new ListDataEvent(
                                        this,
                                        ListDataEvent.CONTENTS_CHANGED,
                                        0,
                                        providedBrowserUIList.size());
                        Iterator<WeakReference<ProvidedBrowsersComboBoxModel>> iter =
                                providedBrowserComboBoxModels.iterator();
                        while (iter.hasNext()) {
                            WeakReference<ProvidedBrowsersComboBoxModel> wr = iter.next();
                            ProvidedBrowsersComboBoxModel pb = wr.get();
                            if (pb == null) {
                                iter.remove();
                            } else {
                                for (ListDataListener listener : pb.getListDataListeners()) {
                                    listener.contentsChanged(ev);
                                }
                            }
                        }
                    }
                });
    }
}
 
Example #14
Source File: QueryDialogComboBoxModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void fireContentsChangedEvent( ListDataEvent event ) {
  ListDataListener[] listeners1 = listeners.getListeners( ListDataListener.class );
  for ( int i = listeners1.length - 1; i >= 0; i -= 1 ) {
    ListDataListener l = listeners1[i];
    l.contentsChanged( event );
  }
}
 
Example #15
Source File: PathController.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a new instance of PathController */
public PathController(JList l, JLabel label, DefaultListModel model, JButton add, JFileChooser chooser, JButton remove, JButton up, JButton down, ListDataListener lstnr) {
    this.l = l;
    this.label = label;
    this.model = model;
    this.add = add;
    this.remove = remove;
    this.up = up;
    this.down = down;
    this.chooser = chooser;

    this.lstnr = lstnr;

    l.setModel(model);
    if (model != null) {
        model.addListDataListener(this);
    }
    add.setActionCommand("add");// NOI18N
    remove.setActionCommand("remove");// NOI18N
    up.setActionCommand("up");// NOI18N
    down.setActionCommand("down");// NOI18N
    add.addActionListener(this);
    remove.addActionListener(this);
    up.addActionListener(this);
    down.addActionListener(this);
    l.addListSelectionListener(this);

    remove.setEnabled(false);
    up.setEnabled(false);
    down.setEnabled(false);
}
 
Example #16
Source File: SWFListModel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Clears url list
 */
public void clear() {
    int size = replacements.size();
    if (size == 0) {
        return;
    }
    replacements.clear();
    for (ListDataListener l : listeners) {
        l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, 0, size - 1));
    }
}
 
Example #17
Source File: ListComboModel.java    From jclic with GNU General Public License v2.0 4 votes vote down vote up
public void removeListDataListener(ListDataListener l) {
  model.removeListDataListener(l);
}
 
Example #18
Source File: GrowingComboBox.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
final public void addListDataListener(ListDataListener l) {
    listeners.add(l);
}
 
Example #19
Source File: LogDevicesComboBoxSupport.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public void addListDataListener(ListDataListener l) {
    dataListeners.add(l);
}
 
Example #20
Source File: RuntimeComboBox.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void removeListDataListener(ListDataListener l) {
    listeners.remove(l);
}
 
Example #21
Source File: TapeFileReader.java    From zxpoly with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void removeListDataListener(ListDataListener l) {
}
 
Example #22
Source File: QueryDialogComboBoxModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void removeListDataListener( final ListDataListener l ) {
  listeners.remove( ListDataListener.class, l );
}
 
Example #23
Source File: XMLModelCombiner.java    From beast-mcmc with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void addListDataListener(ListDataListener listDataListener) {
    //AUTOGENERATED METHOD IMPLEMENTATION
}
 
Example #24
Source File: HistoryComboBoxModel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addListDataListener(ListDataListener listener) {
    listenerList.add(ListDataListener.class, listener);
}
 
Example #25
Source File: AndroidPlatformCustomizer.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public void removeListDataListener(ListDataListener l) {
    classListeners.remove(l);
}
 
Example #26
Source File: UserDefPage.java    From Spark-Reader with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void removeListDataListener(ListDataListener l)
{
    listeners.remove(l);
}
 
Example #27
Source File: HistoryComboBoxModel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void removeListDataListener(ListDataListener listener) {
    listenerList.remove(ListDataListener.class, listener);
}
 
Example #28
Source File: ApplicationLocationPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void removeListDataListener(ListDataListener listener) {
    synchronized (listeners) {
        listeners.remove(listener);
    }
}
 
Example #29
Source File: ArrayListModel.java    From StringManipulation with Apache License 2.0 4 votes vote down vote up
public final void addListDataListener(ListDataListener l) {
	this.getEventListenerList().add(ListDataListener.class, l);
}
 
Example #30
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);
}