Java Code Examples for org.netbeans.api.project.Sources#removeChangeListener()

The following examples show how to use org.netbeans.api.project.Sources#removeChangeListener() . 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: EarDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void refreshSourceFolders () {
    ArrayList srcRootList = new ArrayList ();
    
    Project project = FileOwnerQuery.getOwner (getPrimaryFile ());
    if (project != null) {
        Sources sources = ProjectUtils.getSources(project);
        sources.removeChangeListener (this);
        sources.addChangeListener (this);
        SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        for (int i = 0; i < groups.length; i++) {
            org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbModule = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(groups[i].getRootFolder());

            if (ejbModule != null && ejbModule.getDeploymentDescriptor() != null) {
                try {
                    FileObject fo = groups[i].getRootFolder();

                    srcRootList.add(groups[i].getRootFolder());
                    FileSystem fs = fo.getFileSystem();

                    fs.removeFileChangeListener(this);
                    fs.addFileChangeListener(this);
                } catch (FileStateInvalidException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }
    srcRoots = (FileObject []) srcRootList.toArray (new FileObject [srcRootList.size ()]);
}
 
Example 2
Source File: ProjectsRootNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void removeNotify() {
    OpenProjectList.getDefault().removePropertyChangeListener(this);
    for (Sources sources : sources2projects.keySet()) {
        sources.removeChangeListener( this );                
    }
    sources2projects.clear();
    projects2Pairs.clear();
    setKeys(Collections.<Pair>emptySet());
}
 
Example 3
Source File: LookupProviderSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override void resultChanged(LookupEvent ev) {
    synchronized (this) {
        if (currentDelegates != null) {
            for (Sources old : currentDelegates) {
                old.removeChangeListener(this);
            }
            currentDelegates = null;
        }
    }
    changeSupport.fireChange();
}
 
Example 4
Source File: SourcesNodeFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void removeNotify() {
    Sources srcs = ProjectUtils.getSources(project);
    srcs.removeChangeListener(this);
}
 
Example 5
Source File: SourcesNodeFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void removeNotify() {
    Sources srcs = ProjectUtils.getSources(project);
    srcs.removeChangeListener(this);
}
 
Example 6
Source File: ProjectsRootNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NonNull
final Node logicalViewForProject(
        @NonNull final Project project,
        final Union2<LogicalViewProvider,org.openide.util.Pair<Sources,SourceGroup[]>> data,
        final boolean[] projectInLookup) {
    Node node;            
    if (!data.hasFirst()) {
        LOG.log(
                Level.WARNING,
                "Warning - project of {0} in {1} failed to supply a LogicalViewProvider in its lookup",  // NOI18N
                new Object[]{
                    project.getClass(),
                    FileUtil.getFileDisplayName(project.getProjectDirectory())
                });
        final Sources sources = data.second().first();
        final SourceGroup[] groups = data.second().second();
        sources.removeChangeListener(this);
        sources.addChangeListener(this);
        if (groups.length > 0) {
            node = PhysicalView.createNodeForSourceGroup(groups[0], project);
        } else {
            node = Node.EMPTY;
        }
    } else {
        final LogicalViewProvider lvp = data.first();
        node = lvp.createLogicalView();
        if (!project.equals(node.getLookup().lookup(Project.class))) {
            // Various actions, badging, etc. are not going to work.
            LOG.log(
                    Level.WARNING,
                    "Warning - project {0} failed to supply itself in the lookup of the root node of its own logical view",  // NOI18N
                    ProjectUtils.getInformation(project).getName());
            //#114664
            if (projectInLookup != null) {
                projectInLookup[0] = false;
            }
        }
    }                        
    node.addNodeListener(WeakListeners.create(NodeListener.class, this, node));
    return node;
}