Example usage for javax.swing.event ListDataEvent INTERVAL_ADDED

List of usage examples for javax.swing.event ListDataEvent INTERVAL_ADDED

Introduction

In this page you can find the example usage for javax.swing.event ListDataEvent INTERVAL_ADDED.

Prototype

int INTERVAL_ADDED

To view the source code for javax.swing.event ListDataEvent INTERVAL_ADDED.

Click Source Link

Document

Identifies the addition of one or more contiguous items to the list

Usage

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

public void addElement(Object item) {
    if (!itemList.contains(item)) {
        itemList.add(item);/*from w w w  . ja  va 2s .c om*/
        ListDataEvent eve = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, itemList.size() - 1,
                itemList.size() - 1);
        for (ListDataListener listener : listenerList) {
            listener.intervalAdded(eve);
        }
    }
}

From source file:org.drugis.common.beans.FilteredObservableListTest.java

@Test
public void testContentsUpdateAddStart() {
    ListDataListener mock = createStrictMock(ListDataListener.class);
    mock.intervalAdded(ListDataEventMatcher
            .eqListDataEvent(new ListDataEvent(d_outer, ListDataEvent.INTERVAL_ADDED, 0, 0)));
    replay(mock);//from   w  w  w . j a  va  2  s .  c  o  m
    d_outer.addListDataListener(mock);
    d_inner.add(0, "Bart");
    assertEquals("Bart", d_outer.get(0));
    verify(mock);
}

From source file:org.drugis.common.beans.FilteredObservableListTest.java

@Test
public void testContentsUpdateAddEnd() {
    ListDataListener mock = createStrictMock(ListDataListener.class);
    mock.intervalAdded(ListDataEventMatcher
            .eqListDataEvent(new ListDataEvent(d_outer, ListDataEvent.INTERVAL_ADDED, 2, 2)));
    replay(mock);/*from   ww  w . j a  va2 s.  com*/
    d_outer.addListDataListener(mock);
    d_inner.add("Bart");
    assertEquals("Bart", d_outer.get(2));
    verify(mock);
}

From source file:org.drugis.common.beans.FilteredObservableListTest.java

@Test
public void testContentsUpdateAddIndex() {
    ListDataListener mock = createStrictMock(ListDataListener.class);
    mock.intervalAdded(ListDataEventMatcher
            .eqListDataEvent(new ListDataEvent(d_outer, ListDataEvent.INTERVAL_ADDED, 1, 1)));
    replay(mock);/* www  . j a v  a 2 s  .com*/
    d_outer.addListDataListener(mock);
    d_inner.add(2, "Henk");
    assertEquals(Arrays.asList("Gert", "Henk", "Jan"), d_outer);
    verify(mock);
}

From source file:org.drugis.common.beans.FilteredObservableListTest.java

@Test
public void testContentsUpdateAddAllIndex() {
    ListDataListener mock = createStrictMock(ListDataListener.class);
    mock.intervalAdded(ListDataEventMatcher
            .eqListDataEvent(new ListDataEvent(d_outer, ListDataEvent.INTERVAL_ADDED, 1, 2)));
    replay(mock);/*from   ww  w .  j  av a2s  .  c o  m*/
    d_outer.addListDataListener(mock);
    d_inner.addAll(2, Arrays.asList("Henk", "Bart"));
    assertEquals(Arrays.asList("Gert", "Henk", "Bart", "Jan"), d_outer);
    verify(mock);
}

From source file:org.drugis.common.beans.FilteredObservableListTest.java

@Test
public void testContentsUpdateAddAllEnd() {
    ListDataListener mock = createStrictMock(ListDataListener.class);
    mock.intervalAdded(ListDataEventMatcher
            .eqListDataEvent(new ListDataEvent(d_outer, ListDataEvent.INTERVAL_ADDED, 2, 3)));
    replay(mock);//from www . j av  a 2  s.c  o  m
    d_outer.addListDataListener(mock);
    d_inner.addAll(Arrays.asList("Henk", "Bart"));
    assertEquals(Arrays.asList("Gert", "Jan", "Henk", "Bart"), d_outer);
    verify(mock);
}

From source file:org.drugis.common.beans.FilteredObservableListTest.java

@Test
public void testContentsUpdateSetChangeAdd() {
    ListDataListener mock = createStrictMock(ListDataListener.class);
    mock.intervalAdded(ListDataEventMatcher
            .eqListDataEvent(new ListDataEvent(d_outer, ListDataEvent.INTERVAL_ADDED, 1, 1)));
    replay(mock);/*from   w ww  .  j av a  2  s  .c o  m*/
    d_outer.addListDataListener(mock);
    d_inner.set(1, "Kees");
    assertEquals(Arrays.asList("Gert", "Kees", "Jan"), d_outer);
    verify(mock);
}

From source file:org.drugis.common.beans.FilteredObservableListTest.java

@Test
public void testSetFilter() {
    ListDataListener mock = createStrictMock(ListDataListener.class);
    mock.intervalRemoved(ListDataEventMatcher
            .eqListDataEvent(new ListDataEvent(d_outer, ListDataEvent.INTERVAL_REMOVED, 0, 1)));
    mock.intervalAdded(ListDataEventMatcher
            .eqListDataEvent(new ListDataEvent(d_outer, ListDataEvent.INTERVAL_ADDED, 0, 2)));
    replay(mock);/* w w w. j  a  v  a 2s . c om*/
    d_outer.addListDataListener(mock);

    d_outer.setFilter(new Predicate<String>() {
        public boolean evaluate(String str) {
            return !str.equals("Gert");
        }
    });
    assertEquals(Arrays.asList("Daan", "Jan", "Klaas"), d_outer);
    verify(mock);
}

From source file:org.zaproxy.zap.extension.selenium.ExtensionSelenium.java

/**
 * Adds the given WebDriver provider./*from  w w  w  .  j  a  v a  2 s  .c o m*/
 *
 * @param webDriverProvider the WebDriver provider to add
 * @throws IllegalArgumentException if the the given WebDriver provider is {@code null} or its
 *     ID is {@code null} or empty. Also, if the ID already exists.
 * @since 1.1.0
 */
public void addWebDriverProvider(SingleWebDriverProvider webDriverProvider) {
    validateWebDriverProvider(webDriverProvider);

    if (webDriverProviders.containsKey(webDriverProvider.getId())) {
        throw new IllegalArgumentException(
                "A provider with the ID [" + webDriverProvider.getId() + "] already exists.");
    }

    webDriverProviders.put(webDriverProvider.getId(), webDriverProvider);

    ProvidedBrowser providedBrowser = webDriverProvider.getProvidedBrowser();
    providedBrowsers.put(providedBrowser.getId(), providedBrowser);

    ProvidedBrowserUI pbui = new ProvidedBrowserUI(providedBrowser);
    providedBrowserUIList.add(pbui);
    Collections.sort(providedBrowserUIList);

    final int idx = providedBrowserUIList.indexOf(pbui);

    if (getView() != null) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                ListDataEvent ev = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, idx, idx);
                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);
                        }
                    }
                }
            }
        });
    }
}

From source file:put.semantic.fcanew.ui.FilesListModel.java

public void add(File f) {
    if (f == null) {
        return;/*  w  w  w .j av  a 2 s .c o  m*/
    }
    data.add(f);
    int i = data.size() - 1;
    ListDataEvent e = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, i, i);
    for (ListDataListener l : listeners) {
        l.intervalAdded(e);
    }
}