Java Code Examples for javax.swing.event.ListDataListener

The following examples show how to use javax.swing.event.ListDataListener. These examples are extracted from open source projects. 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 Project: netbeans   Source File: FilteredListModel.java    License: 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 Project: netbeans   Source File: ServerWizardVisual.java    License: 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 Project: netbeans   Source File: NbCustomizeSelectionDialog.java    License: 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 Project: visualvm   Source File: PathController.java    License: 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 5
Source Project: constellation   Source File: DragDropList.java    License: 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 6
Source Project: netbeans-mmd-plugin   Source File: GoToFilePanel.java    License: 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 7
/**
 * 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 8
Source Project: FastDMM   Source File: ObjectTree.java    License: 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 9
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 10
Source Project: netbeans   Source File: ListComboBoxModel.java    License: 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 Project: netbeans   Source File: TaskModel.java    License: 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 12
Source Project: netbeans   Source File: TaskModel.java    License: 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 13
Source Project: netbeans   Source File: TaskModel.java    License: 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 14
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 15
/**
 * 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 16
Source Project: zap-extensions   Source File: ExtensionSelenium.java    License: 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 17
Source Project: commons-bcel   Source File: VerifierFactoryListModel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public synchronized void removeListDataListener(final javax.swing.event.ListDataListener l) {
    listeners.remove(l);
}
 
Example 18
Source Project: constellation   Source File: IconChooser.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void addListDataListener(final ListDataListener l) {
    listeners.add(l);
}
 
Example 19
Source Project: constellation   Source File: IconChooser.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void removeListDataListener(final ListDataListener l) {
    listeners.remove(l);
}
 
Example 20
Source Project: constellation   Source File: DragDropList.java    License: Apache License 2.0 4 votes vote down vote up
public void addMyElement(final MyElement element) {
    elements.add(element);
    for (ListDataListener l : listeners) {
        l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize() - 1));
    }
}
 
Example 21
Source Project: constellation   Source File: DragDropList.java    License: Apache License 2.0 4 votes vote down vote up
public void addMyElement(final int index, final MyElement element) {
    elements.add(index, element);
    for (ListDataListener l : listeners) {
        l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize() - 1));
    }
}
 
Example 22
Source Project: visualvm   Source File: ClassMethodSelector.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void removeListDataListener(ListDataListener listener) {
    listeners.remove(listener);
}
 
Example 23
Source Project: ghidra   Source File: EditableParameterAddress.java    License: Apache License 2.0 4 votes vote down vote up
private void buildPanel() {
	setLayout(new BorderLayout());
	final Parameter[] parameters = function.getParameters();
	jList = new JList(new ListModel() {

		@Override
		public void addListDataListener(ListDataListener l) {
			// no-op
		}

		@Override
		public Object getElementAt(int index) {
			if (index == 0) {
				return NO_ADDRESS;
			}
			if (index <= parameters.length) {
				return getDisplayValue(parameters[index - 1]);
			}
			return null;
		}

		@Override
		public int getSize() {
			return parameters.length + 1;
		}

		@Override
		public void removeListDataListener(ListDataListener l) {
			// no-op
		}
	});
	jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	int defaultListIndex = getListIndex(parameterAddress, parameters);
	jList.setSelectedIndex(defaultListIndex);

	JScrollPane scrollPane = new JScrollPane(jList);
	add(scrollPane, BorderLayout.CENTER);

	jList.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseReleased(MouseEvent e) {
			int index = jList.locationToIndex(e.getPoint());
			if (index >= 0) {
				if (e.getClickCount() == 2) {
					if (addressPanelListener != null) {
						addressPanelListener.addressEdited();
					}
				}
			}
		}
	});

	setBorder(BorderFactory.createEmptyBorder(2, 5, 5, 5));
}
 
Example 24
@Override
public void addListDataListener(ListDataListener l) {
    if(! listeners.contains(l)) {
        listeners.add(l);
    }
}
 
Example 25
Source Project: netbeans   Source File: GrowingComboBox.java    License: Apache License 2.0 4 votes vote down vote up
private void fireDataChanged() {
    int stop = getSize() - 1;
    for(ListDataListener l : listeners) {
        l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, stop));
    }
}
 
Example 26
Source Project: netbeans   Source File: ConfigFilesUIs.java    License: Apache License 2.0 4 votes vote down vote up
public void addListDataListener(ListDataListener l) {
}
 
Example 27
Source Project: snap-desktop   Source File: VariableFilter.java    License: GNU General Public License v3.0 4 votes vote down vote up
void addVariables(DAPVariable[] dapVariables) {
    allVariables.addAll(Arrays.asList(dapVariables));
    for (ListDataListener listener : listeners) {
        listener.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize() - 1));
    }
}
 
Example 28
Source Project: netbeans   Source File: CreateDatabasePanel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void removeListDataListener(ListDataListener arg0) {
}
 
Example 29
Source Project: netbeans   Source File: ReferencesPanel.java    License: Apache License 2.0 4 votes vote down vote up
public @Override void addListDataListener(ListDataListener l) {
    // no op
}
 
Example 30
Source Project: Digital   Source File: KarnaughMapDialog.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addListDataListener(ListDataListener listDataListener) {
}