Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Add new resource to navigator
Add new resource to navigator [message #199981] Thu, 20 October 2005 10:02 Go to next message
Eclipse UserFriend
Originally posted by: prashanto.chatterjee.softwareag.com

Hi All,
The kind of feature that I am looking for is this - I am inside an
EditPart's performRequest() method. From here I would like to create a new
Resource in the navigator view. Somwhow I cannot find any handle to create
a new resource. My current code looks like this:

------------------------------------------------------------ ------------------
public void performRequest(Request req) {
if(req.getType().equals(REQ_OPEN)){
setSelected(SELECTED_NONE);
try{
IWorkbenchPage page =
((DefaultEditDomain)getViewer().getEditDomain()).getEditorPa rt().getSite().getPage();
IFile newFile =
EditorUtils.createNewFile(((Shape)this.getModel()).hashCode( )+ ".eci");
IViewPart navView =
(ResourceNavigator)page.findView(IPageLayout.ID_RES_NAV);
deactivate();
AppEditor editorPart =
(AppEditor)IDE.openEditor(page,newFile,"appedit",true);
editorPart.addPageSequence((PageSequence)getModel());

}catch(Exception we){
we.printStackTrace();
}
}
}
------------------------------------------------------------ ------------------

I have got the handle to the navigator but cannot find a way to add a new
resource to the navigator. Please help.

Appreciate any help in this regard,
Prashanto Chatterjee
Re: Add new resource to navigator [message #200078 is a reply to message #199981] Thu, 20 October 2005 16:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

You don't create the resource "in the navigator view." The navigator view
shows whatever resources are in the workspace, and you just create a
resource in the workspace.

Here's an example from one of our tests that might prove helpful to you:

// Create the logic file if it doesn't exist
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(prjName);
if (!project.exists())
project.create(null);
if (!project.isOpen())
project.open(null);
file = project.getFile(fileName);
if (!file.exists()) {
LogicDiagram diagram = createLogicDiagram();
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(diagram);
oos.close();
file.create(new ByteArrayInputStream(out.toByteArray()), false, null);
out.close();
}

If you're still having problems, I suggest you post on the platform
newsgroup with more details (about what happens when you execute your code
and such), since this is not GEF's domain.

"Prashanto" <prashanto.chatterjee@softwareag.com> wrote in message
news:37e7165eda181c20c08a40b9007fcdb6$1@www.eclipse.org...
> Hi All,
> The kind of feature that I am looking for is this - I am inside an
> EditPart's performRequest() method. From here I would like to create a new
> Resource in the navigator view. Somwhow I cannot find any handle to create
> a new resource. My current code looks like this:
>
> ------------------------------------------------------------ --------------
----
> public void performRequest(Request req) {
> if(req.getType().equals(REQ_OPEN)){
> setSelected(SELECTED_NONE);
> try{
> IWorkbenchPage page =
>
((DefaultEditDomain)getViewer().getEditDomain()).getEditorPa rt().getSite().g
etPage();
> IFile newFile =
> EditorUtils.createNewFile(((Shape)this.getModel()).hashCode( )+ ".eci");
> IViewPart navView =
> (ResourceNavigator)page.findView(IPageLayout.ID_RES_NAV);
> deactivate();
> AppEditor editorPart =
> (AppEditor)IDE.openEditor(page,newFile,"appedit",true);
> editorPart.addPageSequence((PageSequence)getModel());
>
> }catch(Exception we){
> we.printStackTrace();
> }
> }
> }
> ------------------------------------------------------------ --------------
----
>
> I have got the handle to the navigator but cannot find a way to add a new
> resource to the navigator. Please help.
>
> Appreciate any help in this regard,
> Prashanto Chatterjee
>
Re: Add new resource to navigator [message #200352 is a reply to message #200078] Fri, 21 October 2005 19:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pbeagan.yahoo_dontspamme_.com

Any resource creation/modification should be done using the
WorkspaceModificationOperation class to avoid getting out of sync with the
file system.


Pratik Shah wrote:

> You don't create the resource "in the navigator view." The navigator view
> shows whatever resources are in the workspace, and you just create a
> resource in the workspace.
>
> Here's an example from one of our tests that might prove helpful to you:
>
> // Create the logic file if it doesn't exist
> IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
> IProject project = root.getProject(prjName);
> if (!project.exists())
> project.create(null);
> if (!project.isOpen())
> project.open(null);
> file = project.getFile(fileName);
> if (!file.exists()) {
> LogicDiagram diagram = createLogicDiagram();
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> ObjectOutputStream oos = new ObjectOutputStream(out);
> oos.writeObject(diagram);
> oos.close();
> file.create(new ByteArrayInputStream(out.toByteArray()), false, null);
> out.close();
> }
>
> If you're still having problems, I suggest you post on the platform
> newsgroup with more details (about what happens when you execute your code
> and such), since this is not GEF's domain.
>
> "Prashanto" <prashanto.chatterjee@softwareag.com> wrote in message
> news:37e7165eda181c20c08a40b9007fcdb6$1@www.eclipse.org...
>> Hi All,
>> The kind of feature that I am looking for is this - I am inside an
>> EditPart's performRequest() method. From here I would like to create a
>> new Resource in the navigator view. Somwhow I cannot find any handle to
>> create a new resource. My current code looks like this:
>>
>>
------------------------------------------------------------ --------------
> ----
>> public void performRequest(Request req) {
>> if(req.getType().equals(REQ_OPEN)){
>> setSelected(SELECTED_NONE);
>> try{
>> IWorkbenchPage page =
>>
>
((DefaultEditDomain)getViewer().getEditDomain()).getEditorPa rt().getSite().g
> etPage();
>> IFile newFile =
>> EditorUtils.createNewFile(((Shape)this.getModel()).hashCode( )+ ".eci");
>> IViewPart navView =
>> (ResourceNavigator)page.findView(IPageLayout.ID_RES_NAV);
>> deactivate();
>> AppEditor editorPart =
>> (AppEditor)IDE.openEditor(page,newFile,"appedit",true);
>> editorPart.addPageSequence((PageSequence)getModel());
>>
>> }catch(Exception we){
>> we.printStackTrace();
>> }
>> }
>> }
>>
------------------------------------------------------------ --------------
> ----
>>
>> I have got the handle to the navigator but cannot find a way to add a new
>> resource to the navigator. Please help.
>>
>> Appreciate any help in this regard,
>> Prashanto Chatterjee
>>
Re: Add new resource to navigator [message #200465 is a reply to message #200352] Mon, 24 October 2005 14:58 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

This utility class seems to only provide batched notification of changes to
resource change listeners. How does it relate to things being in sync??

"Patrick" <pbeagan@yahoo_dontspamme_.com> wrote in message
news:djbfgv$19t$1@news.eclipse.org...
> Any resource creation/modification should be done using the
> WorkspaceModificationOperation class to avoid getting out of sync with the
> file system.
Previous Topic:create a connection between a node and a connection
Next Topic:antialiasing affecting thumbnail
Goto Forum:
  


Current Time: Wed Nov 13 16:16:04 GMT 2024

Powered by FUDForum. Page generated in 0.04802 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top