The following patch is my idea how to introduce workspaces in Netbeans (as to help introduce solution in 6.7 release I
The short description how it works:
1. Instead of launching NB start patch with --nbexec param pointing to netbeans start script (if no specified
netbeans.exe ./netbeans will be used) (Good start script for workspace is needed!)
2. User choose or create workspace.
3. User clicks select.
4. Workspace start netbeans with --userdir pointing to workspace_dir/.workspace & saves selected workspace to recent
(config file: ~/.netbeans/workspace_config).
Everything was written in pure Java6 (with JAXB). Do you think is good idea?
If you think idea is good I can do more work to introduce workspaces but on behalf of 7.0 release.
Created attachment 77658 [details]
Full source code as NB project.
i think it would be better to integrate user dir selection directly into netbeans launcher - if no '--userdir' is given
on command line then the launcher would execute Main class attached to this issue instead of NetBeans main class.
cc'ing netbeans launcher owner
Launcher needs to know user dir to perform operations like look for updates, check whether restart is required etc.
Running alternative main class specified as command line argument or in netbeans.conf is OK, but user dir needs to be
chosen quite early.
I downloaded and tested the attachment.
I created a JAR distribution and copied the lib folder and the JAR file in NetBeans 6.7M2 bin directory and started the
JAR and created some workspaces. I also tested the create new workspace feature with copying current one. I found
this utility very useful.
Thanks for the creative piece of code. I have voted for this issue.
I'm working on integrating workspaces inside NB launcher. It's possible to do and can only be done in
org.netbeans.MainImpl (or Main, but I prefer MainImpl). It's last place where initial classpath is not set and it seen
that changing user's dir will not affect classes static init or any modules updates.
I have following question:
In MainImpl there is:
// only nbexec.exe puts userdir into netbeans.user
String user = System.getProperty ("netbeans.user");
I haven't seen that this property is setted in .exe. Do you know how this property works or can I ignore it?
NB start scripts always sets --userdir and pass it to Launcher :(
As I already wrote launcher also starts autoupdate so it needs to know userdir. It would be necessary to start your Main
class early to select userdir and then return control to launcher (so it can properly run autoupdate if necessary etc.)
I extracted workspace code to separate module, and added support of workspaces to org.netbeans.MainImpl.
The workspaces works as follow:
1. On first start (no ~/.netbeans/workspcace_config.xml file) or starting NB with --workspace the Workspace window will
2. User can choose workspace or select don't show dialog in future.
I hope extracted code can be enough useful to use it in different workspace related modules.
I include changed MainImpl & source code for basic workspace (core.workspaces). I successfully added this module to
nb6.5-src tree (need to add Workspace dependency to Bootstrap).
Created attachment 78575 [details]
The source for Core Workspaces (extract inside NB src tree)
Created attachment 78576 [details]
The source for Core Workspaces (extract inside NB src tree)
Created attachment 78577 [details]
Changed MainImp from NB 6.5 src
Can this method be included in the main NetBeans distribution for version 6.8? I can help by more testing of the
feature. Last time I tested the files attached and they were working for me.
It not only could but it should be included in 6.8. Today I will try to get Netbeans hg repository (bugged & long work)
and I will try to integrate it fast with new 6.8 sources. I found a simple bug, that makes Workspaces don't works as I
wanted to work. Tomorrow everything should be made & diff files committed.
In the moment I'll post the ziped HG diff from Netbeans trunk. I would like to say sorry for a late in this, but I had
many problems with HG (transmission problems, compress problem...). It taken many days to download sources.
Created attachment 86086 [details]
The zipped diff. You need to put netbeans.png (icon) in proper place of sources.
Tomasi, what do you think about recent Radoslaw's contribution (module & updated org.netbeans.MainImpl)? Thanks for your
Created attachment 86722 [details]
hg diff -g
I've putted new diff, in old was a bug in source preventing running wokrspaces (how it gone there, I don't know).
I don't like the idea of introducing an extra UI which will be presented to all users at every start of NetBeans at all.
A feature like this may be useful to a certain amount of people. There is however an easy workaround already. Any user
can create a set of scripts or desktop icon shortcuts to run NetBeans with different values of "--userdir" parameter.
The user can also easily migrate settings from one userdir to another using the Export/Import functionality in Options
Other users who don't want to start a different instance of the IDE for different sets of projects can use the Project
Groups available via File / Project Group submenu.
Also, because the userdir path is intensively used by the launcher, not only to pass it as a parameter to the Java code
but in more other ways, I don't recommend to do any hacky tricks changing it in the middle of the launcher execution.
Speaking about this particular approach, the cleanest solution in my opinion would be to create a separate program which
would be invoked by the user instead of invoking NetBeans launcher, the separate program would take care of the userdir
management and then it would start the right version of NetBeans launcher with the right userdir parameter. However, I
don't see a point in bundling this extra wrapper program with NetBeans.
I am open to a discussion.
I don't know for how many peoples this feature will be useful. Personally I worked in same time on 3 project sets, each
one differently configured.
I want to emphasize, that workspaces concept goes much more far beyond project groups & import / export options (however
this functionality is similar). Currently we can only configure formatting options per project. You need sometimes to
configure, databases, libraries & modules just for specified solutions. You can't say user can create shortcrust and
scripts. I'm user too and I don't want to create shortcrust (maybe I don't know how to make it, I don't have access
privileges or I'm new user & I don't know --userdir), I don't want to start IDE just to import settings & restart. I
don't want each time remember to import / export configuration and when I forgot about exporting, I can loose some
config work. This what I want is... to do one click & make everything :). As real life isn't so much beautyfull we need
to simplicity this what we can.
Other users don't need to start different instances, and can use project groups still. If they want they can check
"Don't show this dialogue again" & will not see workspaces any more.
In first approach I done it as external program. My reasons to put it in build was:
1) The comment for this bug,
2) Start scripts do realy much more & are more complicated then MainImpl.java
3) Start scripts is splitted in exe & sh script, witch have some special tratment for other systems
4) Few other, but I don't remember...
I think the one thing to discuss is how to implement it. I wanted workspaces in Netbeans long long long time. I realized
this year how to make it. In simple way. This solution is relay, --userdir solutions is persistent for module developers
& Netbeans developers too.
Thanks for all opinions & sugestions
In personal opinion I can't predict for how many user workspaces will be useful (I don't know how many users uses PHP,
C++ in Netbeans too :) ). This what I know, if I do something it's not enough too do it, but I need to present it.
Please bear in mind that Users of Netbeans are form skilled from new to Java up to developers that can write in Notepad.
The concept of "workspacing" Netbeans isn't new. It's many solutions, like shared libraries (useful in CVS sharing too),
formation per projects, import/export of configuration, project groups & relative project references, so "workspacing"
We don't need afraid about changing userdir on the fly & treat Launcher as something mystic never-to-change black box :)
Once again thanks for discussion & interesting in this not-new idea.
(In reply to comment #20)
> Currently we can only configure formatting
> options per project. You need sometimes to
> configure, databases, libraries & modules just for specified solutions.
In general we do not encourage switching the user directory (except for specialized purposes such as demos). Would rather work on particular things you think _currently_ need to be switched at the global level to work effectively with particular projects:
1. Databases I don't know much about, but I would presume it would be straightforward for the NB DB support to associate some database definitions with projects rather than global settings. Or you can just ignore definitions you are not actively using.
2. Libraries can already be associated with projects or sets of projects. (And this is reflected in the Ant build.)
3. You should not need to disable a set of modules just to work with projects which do not happen to make use of them.