Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to interact with CNF (Common Navigator Framework) and Editor(Save, open functionality )
How to interact with CNF (Common Navigator Framework) and Editor [message #671212] Tue, 17 May 2011 07:02 Go to next message
Chaitannya  is currently offline Chaitannya Friend
Messages: 14
Registered: May 2010
Junior Member
Hello everyone,

I am developing a GEF based editor and have got the CNF and GEF editor working. I have created the CNF editor from by Michael Elder's tutorial.

First question : When I click on a file lets say test.qml, I want to read the XML file test.qml and load the model into the editor. How do I link it? I have specified a format for editor and I am able to create file and open a GEF editor when clicked on a file. I have attached the screenshot of my application, please have a look.

Second question: How do I handle the save event. I have create a menu save and assigned the command id as "org.eclipse.ui.file.save". Now how to handle the save event for this command id.

Regards,
Chaitannya

Re: How to interact with CNF (Common Navigator Framework) and Editor [message #671417 is a reply to message #671212] Tue, 17 May 2011 19:33 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior Member

Hi Chaitanya,

Look at my suggestions below

1. Loading Model: Override the setInput method and as you have access input to the editor input you can use the same for getting file from the editor input(by casting it to IFileEditorinput). Once you have the file you can implement your own logic to load the model from file.

2. Handling Save: Editor can be saved only when it is modified i.e in dirty state. You need to use command stack for modifying the model. Finally implement the dosave method.

Have a look at the shapes example plugin (File->New-> Gef Plugins ->Shapes) you will get a better idea.

Look for the following methods in ShapesEditor

1. Loading Model:
org.eclipse.gef.examples.shapes.ShapesEditor.setInput(IEdito rInput)
org.eclipse.gef.examples.shapes.ShapesEditor.initializeGraph icalViewer()


2. Save action :
org.eclipse.gef.examples.shapes.ShapesEditor.commandStackCha nged(EventObject)
org.eclipse.gef.examples.shapes.ShapesEditor.doSave(IProgres sMonitor)

Hope this helps you.

Regards,
Prasad


Re: How to interact with CNF (Common Navigator Framework) and Editor [message #671482 is a reply to message #671417] Wed, 18 May 2011 04:27 Go to previous messageGo to next message
Chaitannya  is currently offline Chaitannya Friend
Messages: 14
Registered: May 2010
Junior Member
Thanks Devi,

Actually I should have mentioned more specific details while posting my query.

1. How do I know which file the user has clicked. Once this event is captured, I can do the rest.

2. I have implemented dosave method already. When i close the editor, I get this "Would you like to save, before quitting" message and when I click "OK" the dosave method is executed. The save functionality is working fine, only dilemma is when to call it. I would have to try things you have mentioned.
Also one more thing, when multiple files are opened in tabbed format and when I press "Ctrl +S" how is that handled. Do I have to do something extra to identify for which editor the save functionality has to be implemented?
Re: How to interact with CNF (Common Navigator Framework) and Editor [message #671588 is a reply to message #671482] Wed, 18 May 2011 12:23 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior Member

1. how are you opening the editor using a custom action or default double click?

2.Have a look at this article http://stackoverflow.com/questions/3769896/how-to-use-eclips e-rcp-command-framework-save-command-with-the-default-save-a ctio


Re: How to interact with CNF (Common Navigator Framework) and Editor [message #671820 is a reply to message #671588] Thu, 19 May 2011 05:26 Go to previous messageGo to next message
Chaitannya  is currently offline Chaitannya Friend
Messages: 14
Registered: May 2010
Junior Member
I am opening the editor with default double click.
Re: How to interact with CNF (Common Navigator Framework) and Editor [message #671868 is a reply to message #671820] Thu, 19 May 2011 08:32 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior Member

So then editor input will have information about the file which is clicked.
As i mentioned earlier the below code should return you the file when used in the graphical editor.
((IFileEditorInput)getEditorInput()).getFile()





Re: How to interact with CNF (Common Navigator Framework) and Editor [message #672142 is a reply to message #671868] Fri, 20 May 2011 03:28 Go to previous message
Chaitannya  is currently offline Chaitannya Friend
Messages: 14
Registered: May 2010
Junior Member
Thanks Devi,

The code for editor input worked. I am now working on the "Ctrl+S" functionality.
Previous Topic:I would like to remove windows menu in textbox
Next Topic:How to control the position of contributed menu actions?
Goto Forum:
  


Current Time: Thu Apr 18 02:11:05 GMT 2024

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

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

Back to the top