Java Code Examples for org.netbeans.api.java.classpath.ClassPath#PROP_ENTRIES

The following examples show how to use org.netbeans.api.java.classpath.ClassPath#PROP_ENTRIES . 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: MultiModuleUnitTestsCompilerOptionsQueryImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    final Object source = evt.getSource();
    switch (evt.getPropertyName()) {
        case MultiModule.PROP_MODULES:
            if (source == testModules || source == sourceModules) {
                reset();
            }
            break;
        case ClassPath.PROP_ENTRIES:
            if (isActiveClassPath(source)) {
                reset();
            }
            break;
    }
}
 
Example 2
Source File: MultiModuleFileBuiltQueryImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    final String propName = evt.getPropertyName();
    if (propName == null) {
        invalidate();
    } else {
        switch(propName) {
            case ProjectProperties.BUILD_MODULES_DIR:
            case ProjectProperties.BUILD_TEST_MODULES_DIR:
                if (evt.getSource() == this.eval) {
                    invalidate();
                }
                break;
            case MultiModule.PROP_MODULES:
                if (evt.getSource() == this.sourceModules ||
                    evt.getSource() == this.testModules) {
                    invalidate();
                }
                break;
            case ClassPath.PROP_ENTRIES:
                final Object src = evt.getSource();
                if ((src instanceof ClassPath) && isCurrentPath((ClassPath)src)) {
                    invalidate();
                }
        }
    }
}
 
Example 3
Source File: PathRegistry.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override void propertyChange(PropertyChangeEvent evt) {
                if (LOGGER.isLoggable(Level.FINE)) {
                    String msg = "propertyChange: " + evt.getPropertyName() //NOI18N
                            + ", old=" + evt.getOldValue() //NOI18N
                            + ", new=" + evt.getNewValue() //NOI18N
                            + ", source=" + s2s(evt.getSource()); //NOI18N
//                    LOGGER.log(Level.FINE, null, new Throwable(msg));
                    LOGGER.log(Level.FINE, msg);
                }

                final String propName = evt.getPropertyName();
                if (propName != null) {
                    switch (propName) {
                        case ClassPath.PROP_ENTRIES:
                        case ClassPath.PROP_FLAGS:
                            final Object source = evt.getSource();
                            if ((source instanceof ClassPath) &&
                                    classPathChanged((ClassPath)source)) {
                                resetCacheAndFire (EventKind.PATHS_CHANGED, null, null, Collections.singleton((ClassPath)evt.getSource()));
                            }
                            break;
                        case ClassPath.PROP_INCLUDES:
                            final Object newPropagationId = evt.getPropagationId();
                            boolean fire;
                            synchronized (this) {
                                fire = (newPropagationId == null || lastPropagationId == null || lastPropagationId.get() != newPropagationId);
                                lastPropagationId = new WeakReference<>(newPropagationId);
                            }
                            if (fire) {
                                resetCacheAndFire (EventKind.INCLUDES_CHANGED, PathKind.SOURCE, null, Collections.singleton((ClassPath)evt.getSource()));
                            }
                            break;
                        case OpenProjects.PROPERTY_OPEN_PROJECTS:
                            if (!firstProjectOpened) {
                                openProjectChangeTask.schedule(0);
                            }
                            break;
                    }
                }
            }
 
Example 4
Source File: MuxClassPathImplementationTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testEvents() throws IOException {
    final File wd = FileUtil.normalizeFile(getWorkDir());
    final URL cp1r1 = FileUtil.urlForArchiveOrDir(new File(wd, "cp1_root1"));   //NOI18N
    final URL cp1r2 = FileUtil.urlForArchiveOrDir(new File(wd, "cp1_root2"));   //NOI18N
    final URL cp2r1 = FileUtil.urlForArchiveOrDir(new File(wd, "cp2_root1"));   //NOI18N
    final URL cp2r2 = FileUtil.urlForArchiveOrDir(new File(wd, "cp2_root2"));   //NOI18N
    final MutableClassPathImpl cp1 = new MutableClassPathImpl(cp1r1);
    final MutableClassPathImpl cp2 = new MutableClassPathImpl(cp2r1);
    final SelectorImpl selector = new SelectorImpl(
            ClassPathFactory.createClassPath(cp1),
            ClassPathFactory.createClassPath(cp2));
    final ClassPath cp = ClassPathSupport.createMultiplexClassPath(selector);
    List<URL> res = cp.entries().stream()
            .map((e)->e.getURL())
            .collect(Collectors.toList());
    assertEquals(Collections.singletonList(cp1r1), res);
    final MockPropertyChangeListener mpcl = new MockPropertyChangeListener(ClassPath.PROP_ENTRIES);
    mpcl.ignore(ClassPath.PROP_FLAGS);
    mpcl.ignore(ClassPath.PROP_INCLUDES);
    mpcl.ignore(ClassPath.PROP_ROOTS);
    cp.addPropertyChangeListener(mpcl);
    cp1.add(cp1r2);
    res = cp.entries().stream()
            .map((e)->e.getURL())
            .collect(Collectors.toList());
    assertEquals(Arrays.asList(cp1r1, cp1r2), res);
    mpcl.assertEventCount(1);
    cp1.remove(cp1r1);
    res = cp.entries().stream()
            .map((e)->e.getURL())
            .collect(Collectors.toList());
    assertEquals(Collections.singletonList(cp1r2), res);
    mpcl.assertEventCount(1);
    selector.select(1);
    res = cp.entries().stream()
            .map((e)->e.getURL())
            .collect(Collectors.toList());
    assertEquals(Collections.singletonList(cp2r1), res);
    mpcl.assertEventCount(1);
    cp2.add(cp2r2);
    res = cp.entries().stream()
            .map((e)->e.getURL())
            .collect(Collectors.toList());
    assertEquals(Arrays.asList(cp2r1, cp2r2), res);
    mpcl.assertEventCount(1);
    cp2.remove(cp2r1);
    res = cp.entries().stream()
            .map((e)->e.getURL())
            .collect(Collectors.toList());
    assertEquals(Collections.singletonList(cp2r2), res);
    mpcl.assertEventCount(1);
    cp1.remove(cp1r2);
    mpcl.assertEventCount(0);
    cp1.add(cp1r1);
    mpcl.assertEventCount(0);
    res = cp.entries().stream()
            .map((e)->e.getURL())
            .collect(Collectors.toList());
    assertEquals(Collections.singletonList(cp2r2), res);
}