Board index » jbuilder » Jot and getProject

Jot and getProject


2003-08-13 04:10:07 PM
jbuilder7
Hello,
For create JotFile, I need to have the project. And for this, I have
this code :
Browser browser = Browser.getActiveBrowser();
Node node = browser.getActiveNode();
project = (JBProject) node.getProject();
JotPackages pkg = project.getJotPackages();
JotFile jf1 = pkg.getFile(new Url(new File(filename1)));
But when there is no file open in Browser, browser is null and I have
NullPointerException.
My question is; how create JotFile when the browser is empty.
Thanks
Jean
 
 

Re:Jot and getProject

le Wed, 13 Aug 2003 09:14:08 -0400
"Gillmer J. Derge \(TeamB\)" < XXXX@XXXXX.COM >a ecrit :
Quote
I haven't tried this, but I think it ought to work:

Url defaultProjectHome = Project.getDefaultProjectHome();
getDefaultProjectHome returns location for creation of default project,
but not the current project location.
Quote
Project defaultProject = Project.getProject(defaultProjectHome);
For this I need that defaultProjectHome is the current project location.
Quote
JBProject defaultJBProject = (JBProject)defaultProject;
JotPackages jotPackages = defaultJBProject.getJotPackages();
Thanks
Jean
 

Re:Jot and getProject

"Bort Jean" < XXXX@XXXXX.COM >wrote in message
Quote
getDefaultProjectHome returns location for creation of default
project,
but not the current project location.
I'm not sure you can do anything else. If there's no active browser,
what is the "current project?"
--
Gillmer J. Derge (TeamB)
 

{smallsort}

Re:Jot and getProject

le Wed, 13 Aug 2003 11:17:55 -0400
"Gillmer J. Derge \(TeamB\)" < XXXX@XXXXX.COM >a ecrit :
Quote
"Bort Jean" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>getDefaultProjectHome returns location for creation of default
project,
>but not the current project location.

I'm not sure you can do anything else. If there's no active browser,
what is the "current project?"
I open a project. In browser I have my project, but in content pane I
have not files. In this case (Browser browser =
Browser.getActiveBrowser(); ), browser is null.
Jean
 

Re:Jot and getProject

The only way Browser.getActiveBrowser() would return null is if you were
to call the method too soon during startup (typically by having an
OpenTool assigned to the wrong category in the JAR manifest file).
More likely is (the totally normal and understandable behavior) that
calling browser.getActiveNode() when all files are closed as you have
coded it will return null.
Instead call browser.getActiveProject(). This will return null if no
projects are open.
"Bort Jean" < XXXX@XXXXX.COM >wrote in message
Quote
Hello,

For create JotFile, I need to have the project. And for this, I have
this code :
Browser browser = Browser.getActiveBrowser();
Node node = browser.getActiveNode();
project = (JBProject) node.getProject();
JotPackages pkg = project.getJotPackages();
JotFile jf1 = pkg.getFile(new Url(new File(filename1)));

But when there is no file open in Browser, browser is null and I have
NullPointerException.
My question is; how create JotFile when the browser is empty.

Thanks
Jean
 

Re:Jot and getProject

le Wed, 13 Aug 2003 17:33:38 -0700
"Bill Joy" < XXXX@XXXXX.COM >a ecrit :
Quote
The only way Browser.getActiveBrowser() would return null is if you
were to call the method too soon during startup (typically by having
an OpenTool assigned to the wrong category in the JAR manifest file).

More likely is (the totally normal and understandable behavior) that
calling browser.getActiveNode() when all files are closed as you have
coded it will return null.

Instead call browser.getActiveProject(). This will return null if no
projects are open.
I sorry, I commit an error. After search, it's not Browser return null,
but : Node node = browser.getActiveNode();.
When no file open in Browser, getActiveNode() return null.
For reslov this :
Project defaultProject = null;
defaultProject = browser.getActiveProject();
project = (JBProject) defaultProject;
JotPackages pkg = project.getJotPackages();
JotFile jf1 = pkg.getFile(new Url(new File(filename1)));
instead of :
Browser browser = Browser.getActiveBrowser();
Node node = browser.getActiveNode();
project = (JBProject) node.getProject();
JotPackages pkg = project.getJotPackages();
JotFile jf1 = pkg.getFile(new Url(new File(filename1)));
Sorry, and thanks at Bill Joy and illmer J. Derge \(TeamB\) for your
help.
Jean