You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Peter Cheung <pe...@quantr.hk> on 2021/11/13 04:35:03 UTC

project files not auto refresh

Hi
    I am developing verilog plugins, i creatre a new project type. When the file is deleted in the fs, the project tree won't auto refresh. Any hints please?
thanks
Peter

/*
 * Copyright 2021 Peter <pe...@quantr.hk>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hk.quantr.netbeans.verilog.projecttype;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.swing.event.ChangeListener;
import org.netbeans.api.project.Project;
import org.netbeans.spi.project.ui.support.NodeFactory;
import org.netbeans.spi.project.ui.support.NodeList;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;

/**
 *
 * @author Peter <pe...@quantr.hk>
 */
@NodeFactory.Registration(projectType = "verilog-project", position = 10)
public class VerilogNodeFactory implements NodeFactory {

@Override
public NodeList<?> createNodes(Project project) {
System.out.println("createNodes");
return new VerilogNodeList(project);
}

private class VerilogNodeList implements NodeList<Node> {

Project project;

public VerilogNodeList(Project project) {
this.project = project;
}

@Override
public List<Node> keys() {
System.out.println("keys");
FileObject folder = project.getProjectDirectory();
List<Node> result = new ArrayList<>();
if (folder != null) {
for (FileObject f : Stream.of(folder.getChildren())
.filter(e -> e.isFolder() && !e.getName().equals(".git"))
.sorted(Comparator.comparing(FileObject::getName))
.collect(Collectors.toList())) {
try {
result.add(DataObject.find(f).getNodeDelegate());
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
for (FileObject f : Stream.of(folder.getChildren())
.filter(e -> !e.isFolder())
.sorted(Comparator.comparing(FileObject::getName))
.collect(Collectors.toList())) {
try {
result.add(DataObject.find(f).getNodeDelegate());
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
}
return result;
}

@Override
public Node node(Node node) {
return new FilterNode(node);
}

@Override
public void addNotify() {
System.out.println("addNotify");
}

@Override
public void removeNotify() {
System.out.println("removeNotify");
}

@Override
public void addChangeListener(ChangeListener cl) {
System.out.println("addChangeListener");
}

@Override
public void removeChangeListener(ChangeListener cl) {
System.out.println("removeChangeListener");
}

}
}

Re: project files not auto refresh

Posted by Peter Cheung <mc...@hotmail.com>.
no need filewatcher, i commented these line out, then it back to work

public VerilogProjectNode(Node node, VerilogProject project) throws DataObjectNotFoundException {
super(node
// new FilterNode.Children(node),
// new ProxyLookup(
// new Lookup[]{Lookups.singleton(project),
// node.getLookup()
// })
);
this.project = project;
}


Thanks
From Peter
________________________________
From: Christian Lenz <ch...@gmx.net>
Sent: Tuesday, November 23, 2021 10:03 PM
To: dev@netbeans.apache.org <de...@netbeans.apache.org>
Subject: AW: project files not auto refresh

Can you please point to a documentation for such a fileWatcher?

Von: Laszlo Kishalmi
Gesendet: Montag, 15. November 2021 06:02
An: dev@netbeans.apache.org
Betreff: Re: project files not auto refresh

Just set up a watcher on your project files.

On 11/12/21 20:35, Peter Cheung wrote:
> Hi
>      I am developing verilog plugins, i creatre a new project type. When the file is deleted in the fs, the project tree won't auto refresh. Any hints please?
> thanks
> Peter
>
> /*
>   * Copyright 2021 Peter <pe...@quantr.hk>.
>   *
>   * Licensed under the Apache License, Version 2.0 (the "License");
>   * you may not use this file except in compliance with the License.
>   * You may obtain a copy of the License at
>   *
>   *      http://www.apache.org/licenses/LICENSE-2.0
>   *
>   * Unless required by applicable law or agreed to in writing, software
>   * distributed under the License is distributed on an "AS IS" BASIS,
>   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>   * See the License for the specific language governing permissions and
>   * limitations under the License.
>   */
> package hk.quantr.netbeans.verilog.projecttype;
>
> import java.util.ArrayList;
> import java.util.Comparator;
> import java.util.List;
> import java.util.stream.Collectors;
> import java.util.stream.Stream;
> import javax.swing.event.ChangeListener;
> import org.netbeans.api.project.Project;
> import org.netbeans.spi.project.ui.support.NodeFactory;
> import org.netbeans.spi.project.ui.support.NodeList;
> import org.openide.filesystems.FileObject;
> import org.openide.loaders.DataObject;
> import org.openide.loaders.DataObjectNotFoundException;
> import org.openide.nodes.FilterNode;
> import org.openide.nodes.Node;
> import org.openide.util.Exceptions;
>
> /**
>   *
>   * @author Peter <pe...@quantr.hk>
>   */
> @NodeFactory.Registration(projectType = "verilog-project", position = 10)
> public class VerilogNodeFactory implements NodeFactory {
>
> @Override
> public NodeList<?> createNodes(Project project) {
> System.out.println("createNodes");
> return new VerilogNodeList(project);
> }
>
> private class VerilogNodeList implements NodeList<Node> {
>
> Project project;
>
> public VerilogNodeList(Project project) {
> this.project = project;
> }
>
> @Override
> public List<Node> keys() {
> System.out.println("keys");
> FileObject folder = project.getProjectDirectory();
> List<Node> result = new ArrayList<>();
> if (folder != null) {
> for (FileObject f : Stream.of(folder.getChildren())
> .filter(e -> e.isFolder() && !e.getName().equals(".git"))
> .sorted(Comparator.comparing(FileObject::getName))
> .collect(Collectors.toList())) {
> try {
> result.add(DataObject.find(f).getNodeDelegate());
> } catch (DataObjectNotFoundException ex) {
> Exceptions.printStackTrace(ex);
> }
> }
> for (FileObject f : Stream.of(folder.getChildren())
> .filter(e -> !e.isFolder())
> .sorted(Comparator.comparing(FileObject::getName))
> .collect(Collectors.toList())) {
> try {
> result.add(DataObject.find(f).getNodeDelegate());
> } catch (DataObjectNotFoundException ex) {
> Exceptions.printStackTrace(ex);
> }
> }
> }
> return result;
> }
>
> @Override
> public Node node(Node node) {
> return new FilterNode(node);
> }
>
> @Override
> public void addNotify() {
> System.out.println("addNotify");
> }
>
> @Override
> public void removeNotify() {
> System.out.println("removeNotify");
> }
>
> @Override
> public void addChangeListener(ChangeListener cl) {
> System.out.println("addChangeListener");
> }
>
> @Override
> public void removeChangeListener(ChangeListener cl) {
> System.out.println("removeChangeListener");
> }
>
> }
> }
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





AW: project files not auto refresh

Posted by Christian Lenz <ch...@gmx.net>.
Can you please point to a documentation for such a fileWatcher?

Von: Laszlo Kishalmi
Gesendet: Montag, 15. November 2021 06:02
An: dev@netbeans.apache.org
Betreff: Re: project files not auto refresh

Just set up a watcher on your project files.

On 11/12/21 20:35, Peter Cheung wrote:
> Hi
>      I am developing verilog plugins, i creatre a new project type. When the file is deleted in the fs, the project tree won't auto refresh. Any hints please?
> thanks
> Peter
>
> /*
>   * Copyright 2021 Peter <pe...@quantr.hk>.
>   *
>   * Licensed under the Apache License, Version 2.0 (the "License");
>   * you may not use this file except in compliance with the License.
>   * You may obtain a copy of the License at
>   *
>   *      http://www.apache.org/licenses/LICENSE-2.0
>   *
>   * Unless required by applicable law or agreed to in writing, software
>   * distributed under the License is distributed on an "AS IS" BASIS,
>   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>   * See the License for the specific language governing permissions and
>   * limitations under the License.
>   */
> package hk.quantr.netbeans.verilog.projecttype;
>
> import java.util.ArrayList;
> import java.util.Comparator;
> import java.util.List;
> import java.util.stream.Collectors;
> import java.util.stream.Stream;
> import javax.swing.event.ChangeListener;
> import org.netbeans.api.project.Project;
> import org.netbeans.spi.project.ui.support.NodeFactory;
> import org.netbeans.spi.project.ui.support.NodeList;
> import org.openide.filesystems.FileObject;
> import org.openide.loaders.DataObject;
> import org.openide.loaders.DataObjectNotFoundException;
> import org.openide.nodes.FilterNode;
> import org.openide.nodes.Node;
> import org.openide.util.Exceptions;
>
> /**
>   *
>   * @author Peter <pe...@quantr.hk>
>   */
> @NodeFactory.Registration(projectType = "verilog-project", position = 10)
> public class VerilogNodeFactory implements NodeFactory {
>
> @Override
> public NodeList<?> createNodes(Project project) {
> System.out.println("createNodes");
> return new VerilogNodeList(project);
> }
>
> private class VerilogNodeList implements NodeList<Node> {
>
> Project project;
>
> public VerilogNodeList(Project project) {
> this.project = project;
> }
>
> @Override
> public List<Node> keys() {
> System.out.println("keys");
> FileObject folder = project.getProjectDirectory();
> List<Node> result = new ArrayList<>();
> if (folder != null) {
> for (FileObject f : Stream.of(folder.getChildren())
> .filter(e -> e.isFolder() && !e.getName().equals(".git"))
> .sorted(Comparator.comparing(FileObject::getName))
> .collect(Collectors.toList())) {
> try {
> result.add(DataObject.find(f).getNodeDelegate());
> } catch (DataObjectNotFoundException ex) {
> Exceptions.printStackTrace(ex);
> }
> }
> for (FileObject f : Stream.of(folder.getChildren())
> .filter(e -> !e.isFolder())
> .sorted(Comparator.comparing(FileObject::getName))
> .collect(Collectors.toList())) {
> try {
> result.add(DataObject.find(f).getNodeDelegate());
> } catch (DataObjectNotFoundException ex) {
> Exceptions.printStackTrace(ex);
> }
> }
> }
> return result;
> }
>
> @Override
> public Node node(Node node) {
> return new FilterNode(node);
> }
>
> @Override
> public void addNotify() {
> System.out.println("addNotify");
> }
>
> @Override
> public void removeNotify() {
> System.out.println("removeNotify");
> }
>
> @Override
> public void addChangeListener(ChangeListener cl) {
> System.out.println("addChangeListener");
> }
>
> @Override
> public void removeChangeListener(ChangeListener cl) {
> System.out.println("removeChangeListener");
> }
>
> }
> }
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





Re: project files not auto refresh

Posted by Laszlo Kishalmi <la...@gmail.com>.
Just set up a watcher on your project files.

On 11/12/21 20:35, Peter Cheung wrote:
> Hi
>      I am developing verilog plugins, i creatre a new project type. When the file is deleted in the fs, the project tree won't auto refresh. Any hints please?
> thanks
> Peter
>
> /*
>   * Copyright 2021 Peter <pe...@quantr.hk>.
>   *
>   * Licensed under the Apache License, Version 2.0 (the "License");
>   * you may not use this file except in compliance with the License.
>   * You may obtain a copy of the License at
>   *
>   *      http://www.apache.org/licenses/LICENSE-2.0
>   *
>   * Unless required by applicable law or agreed to in writing, software
>   * distributed under the License is distributed on an "AS IS" BASIS,
>   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>   * See the License for the specific language governing permissions and
>   * limitations under the License.
>   */
> package hk.quantr.netbeans.verilog.projecttype;
>
> import java.util.ArrayList;
> import java.util.Comparator;
> import java.util.List;
> import java.util.stream.Collectors;
> import java.util.stream.Stream;
> import javax.swing.event.ChangeListener;
> import org.netbeans.api.project.Project;
> import org.netbeans.spi.project.ui.support.NodeFactory;
> import org.netbeans.spi.project.ui.support.NodeList;
> import org.openide.filesystems.FileObject;
> import org.openide.loaders.DataObject;
> import org.openide.loaders.DataObjectNotFoundException;
> import org.openide.nodes.FilterNode;
> import org.openide.nodes.Node;
> import org.openide.util.Exceptions;
>
> /**
>   *
>   * @author Peter <pe...@quantr.hk>
>   */
> @NodeFactory.Registration(projectType = "verilog-project", position = 10)
> public class VerilogNodeFactory implements NodeFactory {
>
> @Override
> public NodeList<?> createNodes(Project project) {
> System.out.println("createNodes");
> return new VerilogNodeList(project);
> }
>
> private class VerilogNodeList implements NodeList<Node> {
>
> Project project;
>
> public VerilogNodeList(Project project) {
> this.project = project;
> }
>
> @Override
> public List<Node> keys() {
> System.out.println("keys");
> FileObject folder = project.getProjectDirectory();
> List<Node> result = new ArrayList<>();
> if (folder != null) {
> for (FileObject f : Stream.of(folder.getChildren())
> .filter(e -> e.isFolder() && !e.getName().equals(".git"))
> .sorted(Comparator.comparing(FileObject::getName))
> .collect(Collectors.toList())) {
> try {
> result.add(DataObject.find(f).getNodeDelegate());
> } catch (DataObjectNotFoundException ex) {
> Exceptions.printStackTrace(ex);
> }
> }
> for (FileObject f : Stream.of(folder.getChildren())
> .filter(e -> !e.isFolder())
> .sorted(Comparator.comparing(FileObject::getName))
> .collect(Collectors.toList())) {
> try {
> result.add(DataObject.find(f).getNodeDelegate());
> } catch (DataObjectNotFoundException ex) {
> Exceptions.printStackTrace(ex);
> }
> }
> }
> return result;
> }
>
> @Override
> public Node node(Node node) {
> return new FilterNode(node);
> }
>
> @Override
> public void addNotify() {
> System.out.println("addNotify");
> }
>
> @Override
> public void removeNotify() {
> System.out.println("removeNotify");
> }
>
> @Override
> public void addChangeListener(ChangeListener cl) {
> System.out.println("addChangeListener");
> }
>
> @Override
> public void removeChangeListener(ChangeListener cl) {
> System.out.println("removeChangeListener");
> }
>
> }
> }
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists