Java 类java.util.prefs.NodeChangeEvent 实例源码

项目:incubator-netbeans    文件:ProxyPreferencesImpl.java   
private void fireNodeEvents(List<EventBag<NodeChangeListener, NodeChangeEvent>> events) {
    if (noEvents) {
        return;
    }

    for(EventBag<NodeChangeListener, NodeChangeEvent> bag : events) {
        for(NodeChangeEvent event : bag.getEvents()) {
            for(NodeChangeListener l : bag.getListeners()) {
                try {
                    if ((event instanceof NodeChangeEventExt) && ((NodeChangeEventExt) event).isRemovalEvent()) {
                        l.childRemoved(event);
                    } else {
                        l.childAdded(event);
                    }
                } catch (Throwable t) {
                    LOG.log(Level.WARNING, null, t);
                }
            }
        }
    }
}
项目:cross-preferences    文件:PreferencesTestSupport.java   
protected ScheduledFuture<?> testNodeAdded(final NodeChangeListener listener,
                                           final Preferences parent, final String childName, final int count) {
    final ArgumentCaptor<NodeChangeEvent> captor = ArgumentCaptor.forClass(NodeChangeEvent.class);

    final Runnable task = new Runnable() {
        @Override public void run() {
            verify(listener, times(count)).childAdded(captor.capture());
            final NodeChangeEvent event = captor.getValue();

            assertEquals(event.getParent(), parent);
            assertEquals(event.getChild().name(), childName);
        }
    };

    return schedule(task);
}
项目:cross-preferences    文件:PreferencesTestSupport.java   
protected ScheduledFuture<?> testNodeRemoved(final NodeChangeListener listener,
                                             final Preferences parent, final String childName, final int count) {
    final ArgumentCaptor<NodeChangeEvent> captor = ArgumentCaptor.forClass(NodeChangeEvent.class);

    final Runnable task = new Runnable() {
        @Override public void run() {
            verify(listener, times(count)).childRemoved(captor.capture());
            final NodeChangeEvent event = captor.getValue();

            assertEquals(event.getParent(), parent);
            assertEquals(event.getChild().name(), childName);
        }
    };

    return schedule(task);

}
项目:In-the-Box-Fork    文件:NodeChangeEventTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies serialization",
    method = "!Serialization",
    args = {}
)
public void testSerialization() throws Exception {

    event = new NodeChangeEvent(Preferences.systemRoot(), null);

    try {
        SerializationTest.copySerializable(event);
        fail("No expected NotSerializableException");
    } catch (NotSerializableException e) {
    }
}
项目:incubator-netbeans    文件:ProxyPreferencesImpl.java   
@Override
public void sync() throws BackingStoreException {
    ArrayList<EventBag<PreferenceChangeListener, PreferenceChangeEvent>> prefEvents = new ArrayList<EventBag<PreferenceChangeListener, PreferenceChangeEvent>>();
    ArrayList<EventBag<NodeChangeListener, NodeChangeEvent>> nodeEvents = new ArrayList<EventBag<NodeChangeListener, NodeChangeEvent>>();

    synchronized (tree.treeLock()) {
        _sync(prefEvents, nodeEvents);
    }

    fireNodeEvents(nodeEvents);
    firePrefEvents(prefEvents);
}
项目:In-the-Box-Fork    文件:NodeChangeEventTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "NodeChangeEvent",
    args = {java.util.prefs.Preferences.class, java.util.prefs.Preferences.class}
)
public void testConstructor() {
    event = new NodeChangeEvent(Preferences.systemRoot(), Preferences
            .userRoot());
    assertSame(Preferences.systemRoot(), event.getParent());
    assertSame(Preferences.userRoot(), event.getChild());
    assertSame(Preferences.systemRoot(), event.getSource());
}
项目:In-the-Box-Fork    文件:NodeChangeListenerTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Testing Interface",
    method = "childAdded",
    args = {java.util.prefs.NodeChangeEvent.class}
)
public void testChildAdded() {
    l.childAdded(new NodeChangeEvent(Preferences.userRoot(), Preferences
            .userRoot()));
}
项目:In-the-Box-Fork    文件:NodeChangeListenerTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Testing Interface",
    method = "childRemoved",
    args = {java.util.prefs.NodeChangeEvent.class}
)
public void testChildRemoved() {
    l.childRemoved(new NodeChangeEvent(Preferences.userRoot(), Preferences
            .userRoot()));
}
项目:In-the-Box-Fork    文件:MockNodeChangeListener.java   
public void childAdded(NodeChangeEvent e) {

        synchronized (addLock) {
            switch (testNum) {
            case TEST_GET_CHILD:
                Preferences child = e.getChild();
                if (child == null) {
                    addResult = false;
                } else {
                    if (child.name() == "mock1") {
                        addResult = true;
                    }
                }
                break;
            case TEST_GET_PARENT:
                Preferences parent = e.getParent();
                if (parent == null) {
                    addResult = false;
                } else {
                    if (parent.name() == "mock") {
                        addResult = true;
                    }
                }

                break;
            }
            ++added;
            addLock.notifyAll();
        }
    }
项目:In-the-Box-Fork    文件:MockNodeChangeListener.java   
public void childRemoved(NodeChangeEvent e) {
    synchronized (removeLock) {
        switch (testNum) {
        case TEST_GET_CHILD:
            Preferences child = e.getChild();
            if (child == null) {
                removeResult = false;
            } else {
                if (child.name() == "mock1") {
                    removeResult = true;
                }
            }
            break;
        case TEST_GET_PARENT:
            Preferences parent = e.getParent();
            if (parent == null) {
                addResult = false;
            } else {
                if (parent.name() == "mock") {
                    addResult = true;
                }
            }

            break;
        }
        removed++;
        removeLock.notifyAll();
    }
}
项目:cn1    文件:NodeChangeEventTest.java   
public void testConstructor() {
    event = new NodeChangeEvent(Preferences.systemRoot(), Preferences
            .userRoot());
    assertSame(Preferences.systemRoot(), event.getParent());
    assertSame(Preferences.userRoot(), event.getChild());
    assertSame(Preferences.systemRoot(), event.getSource());
}
项目:cn1    文件:NodeChangeEventTest.java   
public void testSerialization() throws Exception {

        event = new NodeChangeEvent(Preferences.systemRoot(), null);

        try {
            SerializationTest.copySerializable(event);
            fail("No expected NotSerializableException");
        } catch (NotSerializableException e) {
        }
    }
项目:cn1    文件:AbstractPreferencesTest.java   
public void childAdded(NodeChangeEvent e) {
    synchronized (addLock) {
        ++added;
        addDispatched = true;
        addLock.notifyAll();
    }
}
项目:cn1    文件:AbstractPreferencesTest.java   
public void childRemoved(NodeChangeEvent e) {
    synchronized (removeLock) {
        removed++;
        removeDispatched = true;
        removeLock.notifyAll();
    }
}
项目:freeVM    文件:NodeChangeEventTest.java   
public void testConstructor() {
    event = new NodeChangeEvent(Preferences.systemRoot(), Preferences
            .userRoot());
    assertSame(Preferences.systemRoot(), event.getParent());
    assertSame(Preferences.userRoot(), event.getChild());
    assertSame(Preferences.systemRoot(), event.getSource());
}
项目:freeVM    文件:NodeChangeEventTest.java   
public void testSerialization() throws Exception {

        event = new NodeChangeEvent(Preferences.systemRoot(), null);

        try {
            SerializationTest.copySerializable(event);
            fail("No expected NotSerializableException");
        } catch (NotSerializableException e) {
        }
    }
项目:freeVM    文件:AbstractPreferencesTest.java   
public void childAdded(NodeChangeEvent e) {
    synchronized (addLock) {
        ++added;
        addDispatched = true;
        addLock.notifyAll();
    }
}
项目:freeVM    文件:AbstractPreferencesTest.java   
public void childRemoved(NodeChangeEvent e) {
    synchronized (removeLock) {
        removed++;
        removeDispatched = true;
        removeLock.notifyAll();
    }
}
项目:freeVM    文件:NodeChangeEventTest.java   
public void testConstructor() {
    event = new NodeChangeEvent(Preferences.systemRoot(), Preferences
            .userRoot());
    assertSame(Preferences.systemRoot(), event.getParent());
    assertSame(Preferences.userRoot(), event.getChild());
    assertSame(Preferences.systemRoot(), event.getSource());
}
项目:freeVM    文件:NodeChangeEventTest.java   
public void testSerialization() throws Exception {

        event = new NodeChangeEvent(Preferences.systemRoot(), null);

        try {
            SerializationTest.copySerializable(event);
            fail("No expected NotSerializableException");
        } catch (NotSerializableException e) {
        }
    }
项目:freeVM    文件:AbstractPreferencesTest.java   
public void childAdded(NodeChangeEvent e) {
    synchronized (addLock) {
        ++added;
        addDispatched = true;
        addLock.notifyAll();
    }
}
项目:freeVM    文件:AbstractPreferencesTest.java   
public void childRemoved(NodeChangeEvent e) {
    synchronized (removeLock) {
        removed++;
        removeDispatched = true;
        removeLock.notifyAll();
    }
}
项目:incubator-netbeans    文件:ProxyPreferencesImpl.java   
private ProxyPreferencesImpl node(String pathName, boolean create, List<EventBag<NodeChangeListener, NodeChangeEvent>> events) {
    if (pathName.length() > 0 && pathName.charAt(0) == '/') { //NOI18N
        // absolute path, if this is not the root then find the root
        // and pass the call to it
        if (parent != null) {
            Preferences root = this;
            while (root.parent() != null) {
                root = root.parent();
            }
            return ((ProxyPreferencesImpl) root).node(pathName, create, events);
        } else {
            // this is the root, change the pathName to a relative path and proceed
            pathName = pathName.substring(1);
        }
    }

    if (pathName.length() > 0) {
        String childName;
        String pathFromChild;

        int idx = pathName.indexOf('/'); //NOI18N
        if (idx != -1) {
            childName = pathName.substring(0, idx);
            pathFromChild = pathName.substring(idx + 1);
        } else {
            childName = pathName;
            pathFromChild = null;
        }

        ProxyPreferencesImpl child = children.get(childName);
        if (child == null) {
            if (removedChildren.contains(childName) && !create) {
                // this child has been removed
                return null;
            }

            Preferences childDelegate = null;
            try {
                if (delegate != null && delegate.nodeExists(childName)) {
                    childDelegate = delegate.node(childName);
                }
            } catch (BackingStoreException bse) {
                // ignore
            }

            if (childDelegate != null || create) {
                child = tree.get(this, childName, childDelegate);
                children.put(childName, child);
                removedChildren.remove(childName);

                // fire event if we really created the new child node
                if (childDelegate == null) {
                    EventBag<NodeChangeListener, NodeChangeEvent> bag = new EventBag<NodeChangeListener, NodeChangeEvent>();
                    bag.addListeners(nodeListeners);
                    bag.addEvent(new NodeChangeEventExt(this, child, false));
                    events.add(bag);
                }
            } else {
                // childDelegate == null && !create
                return null;
            }
        } else {
            assert !child.removed;
        }

        return pathFromChild != null ? child.node(pathFromChild, create, events) : child;
    } else {
        return this;
    }
}
项目:incubator-netbeans    文件:FormattingPanelController.java   
public void childAdded(NodeChangeEvent evt) {
    try { callback.call(); } catch (Exception e) { /* ignore */ }
}
项目:incubator-netbeans    文件:FormattingPanelController.java   
public void childRemoved(NodeChangeEvent evt) {
    try { callback.call(); } catch (Exception e) { /* ignore */ }
}
项目:incubator-netbeans    文件:OnSaveTabPanelController.java   
public void childAdded(NodeChangeEvent evt) {
    try { callback.call(); } catch (Exception e) { /* ignore */ }
}
项目:incubator-netbeans    文件:OnSaveTabPanelController.java   
public void childRemoved(NodeChangeEvent evt) {
    try { callback.call(); } catch (Exception e) { /* ignore */ }
}
项目:incubator-netbeans    文件:CodeCompletionOptionsPanelController.java   
public void childAdded(NodeChangeEvent evt) {
    try { callback.call(); } catch (Exception e) { /* ignore */ }
}
项目:incubator-netbeans    文件:CodeCompletionOptionsPanelController.java   
public void childRemoved(NodeChangeEvent evt) {
    try { callback.call(); } catch (Exception e) { /* ignore */ }
}
项目:In-the-Box-Fork    文件:NodeChangeListenerTest.java   
public void childAdded(NodeChangeEvent e) {
}
项目:In-the-Box-Fork    文件:NodeChangeListenerTest.java   
public void childRemoved(NodeChangeEvent e) {
}
项目:In-the-Box-Fork    文件:AbstractPreferencesTest.java   
public void childAdded(NodeChangeEvent arg0) {
    flagAdded = true;
}
项目:In-the-Box-Fork    文件:AbstractPreferencesTest.java   
public void childRemoved(NodeChangeEvent arg0) {
    flagRemoved = true;
}
项目:cn1    文件:NodeChangeListenerTest.java   
public void testChildAdded() {
    l.childAdded(new NodeChangeEvent(Preferences.userRoot(), Preferences
            .userRoot()));
}
项目:cn1    文件:NodeChangeListenerTest.java   
public void testChildRemoved() {
    l.childRemoved(new NodeChangeEvent(Preferences.userRoot(), Preferences
            .userRoot()));
}
项目:cn1    文件:NodeChangeListenerTest.java   
public void childAdded(NodeChangeEvent e) {
}
项目:cn1    文件:NodeChangeListenerTest.java   
public void childRemoved(NodeChangeEvent e) {
}
项目:freeVM    文件:NodeChangeListenerTest.java   
public void testChildAdded() {
    l.childAdded(new NodeChangeEvent(Preferences.userRoot(), Preferences
            .userRoot()));
}
项目:freeVM    文件:NodeChangeListenerTest.java   
public void testChildRemoved() {
    l.childRemoved(new NodeChangeEvent(Preferences.userRoot(), Preferences
            .userRoot()));
}
项目:freeVM    文件:NodeChangeListenerTest.java   
public void childAdded(NodeChangeEvent e) {
}