File base Project, not Folder based

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

File base Project, not Folder based

abdielcs
I'm trying to implement a new type of project based on this tutorial (https://platform.netbeans.org/tutorials/nbm-projecttype.html). The problem is that I want that my project be saved as a single file, with a custom extension, so all the content must reside on that file. Like project_name.cep (cep - custom extension project). I don't want to open a new type of file inside project, that file is my project, and I want to write nodes inside it.

This is an example of the ProjectFactory to use:


Code:

@ServiceProvider(service=ProjectFactory.class)
public class CustomProjectFactory implements ProjectFactory{
   
    public static final String PROJECT_EXT = "cep";

    //Specifies when a project is a project, i.e.,
    @Override
    public boolean isProject(FileObject projectDirectory) {
        return PROJECT_EXT.equals(projectDirectory.getExt());//assuming that getExt() give the file extension
    }

    //Specifies when the project will be opened, i.e., if the project exists:
    @Override
    public Project loadProject(FileObject dir, ProjectState state) throws IOException {
        return isProject(dir) ? new CustomProject(dir, state) : null;
    }

    @Override
    public void saveProject(final Project project) throws IOException, ClassCastException {
        // leave unimplemented for the moment
    }
     
}




The problem is that the FileChooser opened when I tried to open the project seems to be a DIRECTORIES_ONLY chooser, so a single file can't be opened. It can be done? I really appreciate some example of how to do this and if is not to much to ask how to write nodes inside this single file and represent it in the explorer (just some advices).




Attachments:
http://forums.netbeans.org//files/image_146.jpg

Reply | Threaded
Open this post in threaded view
|

Re: File base Project, not Folder based

geertjan.wielenga@oracle.com
The project will be defined by a folder that contains your single file.

Gj

> On 16 Aug 2017, at 16:46, abdielcs <[hidden email]> wrote:
>
> I'm trying to implement a new type of project based on this tutorial (https://platform.netbeans.org/tutorials/nbm-projecttype.html). The problem is that I want that my project be saved as a single file, with a custom extension, so all the content must reside on that file. Like project_name.cep (cep - custom extension project). I don't want to open a new type of file inside project, that file is my project, and I want to write nodes inside it.
>
> This is an example of the ProjectFactory to use:
>
>
> Code:
>
> @ServiceProvider(service=ProjectFactory.class)
> public class CustomProjectFactory implements ProjectFactory{
>
>    public static final String PROJECT_EXT = "cep";
>
>    //Specifies when a project is a project, i.e.,
>    @Override
>    public boolean isProject(FileObject projectDirectory) {
>        return PROJECT_EXT.equals(projectDirectory.getExt());//assuming that getExt() give the file extension
>    }
>
>    //Specifies when the project will be opened, i.e., if the project exists:
>    @Override
>    public Project loadProject(FileObject dir, ProjectState state) throws IOException {
>        return isProject(dir) ? new CustomProject(dir, state) : null;
>    }
>
>    @Override
>    public void saveProject(final Project project) throws IOException, ClassCastException {
>        // leave unimplemented for the moment
>    }
>
> }
>
>
>
>
> The problem is that the FileChooser opened when I tried to open the project seems to be a DIRECTORIES_ONLY chooser, so a single file can't be opened. It can be done? I really appreciate some example of how to do this and if is not to much to ask how to write nodes inside this single file and represent it in the explorer (just some advices).
>
>
>
>
> Attachments:
> http://forums.netbeans.org//files/image_146.jpg
>

Reply | Threaded
Open this post in threaded view
|

Re: File base Project, not Folder based

abdielcs
Yes, checking the 431 line seems that there is no way of reading a project from a single file.

chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );

 It should't be, a lot of desktop tools work in that way. I will have to use the folder, but I don't like it.

Thanks any way

2017-08-17 9:56 GMT-04:00 [hidden email] <[hidden email]>:
The project will be defined by a folder that contains your single file.

Gj

> On 16 Aug 2017, at 16:46, abdielcs <[hidden email]> wrote:
>
> I'm trying to implement a new type of project based on this tutorial (https://platform.netbeans.org/tutorials/nbm-projecttype.html). The problem is that I want that my project be saved as a single file, with a custom extension, so all the content must reside on that file. Like project_name.cep (cep - custom extension project). I don't want to open a new type of file inside project, that file is my project, and I want to write nodes inside it.
>
> This is an example of the ProjectFactory to use:
>
>
> Code:
>
> @ServiceProvider(service=ProjectFactory.class)
> public class CustomProjectFactory implements ProjectFactory{
>
>    public static final String PROJECT_EXT = "cep";
>
>    //Specifies when a project is a project, i.e.,
>    @Override
>    public boolean isProject(FileObject projectDirectory) {
>        return PROJECT_EXT.equals(projectDirectory.getExt());//assuming that getExt() give the file extension
>    }
>
>    //Specifies when the project will be opened, i.e., if the project exists:
>    @Override
>    public Project loadProject(FileObject dir, ProjectState state) throws IOException {
>        return isProject(dir) ? new CustomProject(dir, state) : null;
>    }
>
>    @Override
>    public void saveProject(final Project project) throws IOException, ClassCastException {
>        // leave unimplemented for the moment
>    }
>
> }
>
>
>
>
> The problem is that the FileChooser opened when I tried to open the project seems to be a DIRECTORIES_ONLY chooser, so a single file can't be opened. It can be done? I really appreciate some example of how to do this and if is not to much to ask how to write nodes inside this single file and represent it in the explorer (just some advices).
>
>
>
>
> Attachments:
> http://forums.netbeans.org//files/image_146.jpg
>


Reply | Threaded
Open this post in threaded view
|

Re: File base Project, not Folder based

geertjan.wielenga@oracle.com
A project is always a folder that is identified by means of a specific file, e.g., with a specific file extension. I think people generally accept that the notion of a ‘project’ is always more than one file, so possibly you need to reconsider the design of your input.

Gj


On 17 Aug 2017, at 18:12, Abdiel Carrazana <[hidden email]> wrote:

Yes, checking the 431 line seems that there is no way of reading a project from a single file.

chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );

 It should't be, a lot of desktop tools work in that way. I will have to use the folder, but I don't like it.

Thanks any way

2017-08-17 9:56 GMT-04:00 [hidden email] <[hidden email]>:
The project will be defined by a folder that contains your single file.

Gj

> On 16 Aug 2017, at 16:46, abdielcs <[hidden email]> wrote:
>
> I'm trying to implement a new type of project based on this tutorial (https://platform.netbeans.org/tutorials/nbm-projecttype.html). The problem is that I want that my project be saved as a single file, with a custom extension, so all the content must reside on that file. Like project_name.cep (cep - custom extension project). I don't want to open a new type of file inside project, that file is my project, and I want to write nodes inside it.
>
> This is an example of the ProjectFactory to use:
>
>
> Code:
>
> @ServiceProvider(service=ProjectFactory.class)
> public class CustomProjectFactory implements ProjectFactory{
>
>    public static final String PROJECT_EXT = "cep";
>
>    //Specifies when a project is a project, i.e.,
>    @Override
>    public boolean isProject(FileObject projectDirectory) {
>        return PROJECT_EXT.equals(projectDirectory.getExt());//assuming that getExt() give the file extension
>    }
>
>    //Specifies when the project will be opened, i.e., if the project exists:
>    @Override
>    public Project loadProject(FileObject dir, ProjectState state) throws IOException {
>        return isProject(dir) ? new CustomProject(dir, state) : null;
>    }
>
>    @Override
>    public void saveProject(final Project project) throws IOException, ClassCastException {
>        // leave unimplemented for the moment
>    }
>
> }
>
>
>
>
> The problem is that the FileChooser opened when I tried to open the project seems to be a DIRECTORIES_ONLY chooser, so a single file can't be opened. It can be done? I really appreciate some example of how to do this and if is not to much to ask how to write nodes inside this single file and represent it in the explorer (just some advices).
>
>
>
>
> Attachments:
> http://forums.netbeans.org//files/image_146.jpg
>



Reply | Threaded
Open this post in threaded view
|

Re: File base Project, not Folder based

Neil C Smith-2
In reply to this post by abdielcs
Hi,

On Fri, Aug 18, 2017 at 9:16 AM Abdiel Carrazana <[hidden email]> wrote:
 It should't be, a lot of desktop tools work in that way. I will have to use the folder, but I don't like it.

I generally agree with Geertjan that the idea of project is a grouping of more than one file, but I'm intrigued why you feel you need the project infrastructure, rather than just opening the file, to support what you're trying to do?  Can you elaborate the use case a bit more?

There's probably a way you can create a fake project inside a memory file system that's created when your file is opened - I'm doing something not entirely dissimilar to that.  Although you'd have to create your own project opening action too I guess.

Best wishes,

Neil
--
Neil C Smith
Artist & Technologist

Praxis LIVE - hybrid visual IDE for creative coding - www.praxislive.org