Quantcast

How to change the default folder for projects

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to change the default folder for projects

Ibon Urrutia
I want to change the default folder for projects (USER.HOME/NetbeansProjects). I have tried what is said here : http://www.nabble.com/default-project-location-to6849891.html
but it doesn't work in NB6 final.
The wizard created my panel with this code:
void read(WizardDescriptor settings) {
        File projectLocation = (File) settings.getProperty("projdir");
        if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory()) {
            projectLocation = ProjectChooser.getProjectsFolder();
        } else {
            projectLocation = projectLocation.getParentFile();
        }
        this.projectLocationTextField.setText(projectLocation.getAbsolutePath());

How can I set what ProjectChooser.getProjectsFolder() is returning? I tried to create a dir with File.mkdir() and using ProjectChooser.setProjectsFolder(), but mkdir() doesn't create anything (and No exception is thrown, simply return false)... Can I create a folder from that panel?
Thanks in advance
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change the default folder for projects

Tom Wheeler
On 12/13/07, Ibon Urrutia <[hidden email]> wrote:
> I want to change the default folder for projects
...
> but it doesn't work in NB6 final.


Hi Ibon,

I am doing this successfully in NB6.  I set the property (creating the
directory if necessary) from a static block in my project factory.  I
don't recall exactly where I got the idea to do it this way, but it
works.  Here is an example:

public class MyProjectFactory implements ProjectFactory {

    static {
        // override the default "NetBeans Projects" directory used
        // for creating new projects and instead use one for my projects

        File userDir = new File(System.getProperty("user.home"));
        File myProjectsDir = new File(userDir, "My Projects");
        if (! myProjectsDir.exists()) {
            myProjectsDir.mkdirs();
        }

        System.setProperty("netbeans.projects.dir",
myProjectsDir.getAbsolutePath());
    }

Hope that helps-

--
Tom Wheeler
http://www.tomwheeler.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change the default folder for projects

Ibon Urrutia


On Dec 13, 2007 5:11 PM, Tom Wheeler <[hidden email]> wrote:
On 12/13/07, Ibon Urrutia <[hidden email]> wrote:
> I want to change the default folder for projects
...
> but it doesn't work in NB6 final.


Thank you very much!
 


Hi Ibon,

I am doing this successfully in NB6.  I set the property (creating the
directory if necessary) from a static block in my project factory.  I
don't recall exactly where I got the idea to do it this way, but it
works.  Here is an example:

public class MyProjectFactory implements ProjectFactory {

   static {
       // override the default "NetBeans Projects" directory used
       // for creating new projects and instead use one for my projects

       File userDir = new File(System.getProperty("user.home"));
       File myProjectsDir = new File(userDir, "My Projects");
       if (! myProjectsDir.exists()) {
           myProjectsDir.mkdirs ();
       }

       System.setProperty("netbeans.projects.dir",
myProjectsDir.getAbsolutePath());
   }

Hope that helps-

The problem with this approach is that the firs time that any user executes my application, when creating New Project, Project Factory is instantiated after completing the wizard for new Project (at least is what I see in my app). After that, as my panel always search the las project created folder parent, it always shows NetbeansProjects as project Location.
Besides that I don't know what is happening with my user home, but myProjectDir is never created when call mkdirs() or mkdir(), and no exception is thrown. Maybe it is related to permissions, but I always thought that my app is executed with user id... I have to debug what is happening.

Also, is there a more "standard" way of doing this in NB platform?

Thank you very much Tom.



--
Tom Wheeler
http://www.tomwheeler.com/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change the default folder for projects

Ibon Urrutia
Finally, I created that folder and set the system property in a ModuleInstaller, and it works.
After some debugging sessions I found that is necessary that you create the folder, because if you don't, org.netbeans.modules.project.ui.OpenProjectListSettings.getProjectsFolder () will create a folder named "NetbeansProjects", although you had specify netbeans.projects.dir. That value is declared in NbBundle of org.netbeans.modules.project.ui ("DIR_NetBeansProjects"), so maybe another solution is branding that NbBundle.

Regards



Hi Ibon,

I am doing this successfully in NB6.  I set the property (creating the
directory if necessary) from a static block in my project factory.  I
don't recall exactly where I got the idea to do it this way, but it
works.  Here is an example:

public class MyProjectFactory implements ProjectFactory {

   static {
       // override the default "NetBeans Projects" directory used
       // for creating new projects and instead use one for my projects

       File userDir = new File(System.getProperty("user.home"));
       File myProjectsDir = new File(userDir, "My Projects");
       if (! myProjectsDir.exists()) {
           myProjectsDir.mkdirs ();
       }

       System.setProperty("netbeans.projects.dir",
myProjectsDir.getAbsolutePath());
   }

Hope that helps-

The problem with this approach is that the firs time that any user executes my application, when creating New Project, Project Factory is instantiated after completing the wizard for new Project (at least is what I see in my app). After that, as my panel always search the las project created folder parent, it always shows NetbeansProjects as project Location.
Besides that I don't know what is happening with my user home, but myProjectDir is never created when call mkdirs() or mkdir(), and no exception is thrown. Maybe it is related to permissions, but I always thought that my app is executed with user id... I have to debug what is happening.

Also, is there a more "standard" way of doing this in NB platform?

Thank you very much Tom.



--


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to change the default folder for projects

Carsten Schmalhorst
Hi Ibon,

I had the same problem and came across your post here. Branding the application works fine - in my module suite directory, I created the following tree within the subfolder "branding":

modules\org-netbeans-modules-projectui.jar\org\netbeans\modules\project\ui\

Within that directory, I created a Bundle.properties file only containing one single entry:

DIR_NetBeansProjects=Blabla

It now works fine, i.e. if I create a new project, my module suite uses Blabla as default project directory. If this directory exists, it is used to look up existing projects after a fresh installation.

Thanks for the hint,

Carsten

Ibon Urrutia wrote
Finally, I created that folder and set the system property in a
ModuleInstaller, and it works.
After some debugging sessions I found that is necessary that you create the
folder, because if you don't,
org.netbeans.modules.project.ui.OpenProjectListSettings.getProjectsFolder()
will create a folder named "NetbeansProjects", although you had specify
netbeans.projects.dir. That value is declared in NbBundle of
org.netbeans.modules.project.ui ("DIR_NetBeansProjects"), so maybe another
solution is branding that NbBundle.

Regards
Loading...