Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Reusable editor
Reusable editor [message #276964] Thu, 02 December 2004 09:58 Go to next message
Eclipse UserFriend
Originally posted by: berta_hauri.hotmail.com

Hi!
I'm implemented my own editor which should be able to change the
IEditorInput object. So my editor implements IReusableEditor like this:

public class ObjectEditor extends DBFormEditor implements IReusableEditor {
...
public void setInput(IEditorInput obj) {
super.setInput(obj);
}
}

Now I try to reuse an editor by implementing an openEditor method like
this:

public void openEditor(IEditorInput obj, String editorID){
IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
if (dw != null) {
//get active page
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
//check if this obj is already open with a different type
for(int i=0; i < page.getEditorReferences().length; i++){
IReusableEditor editor = (IReusableEditor)
page.getEditorReferences()[i].getEditor(false);
//check if object with same id is open
if(((DBObject)obj).getObjectID() ==((DBObject)editor.
getEditorInput()).getObjectID()){
page.reuseEditor(editor,obj);
//page.closeEditor(editor,false);
//editor.init(editor.getEditorSite(),obj);
//page.openEditor(obj,editorID)
}
}
page.openEditor(obj,editorID);
}
}
} catch (PartInitException e) {
//handle exception
e.printStackTrace();
}
}
Re: Reusable editor - corrected message [message #276965 is a reply to message #276964] Thu, 02 December 2004 10:04 Go to previous message
Eclipse UserFriend
Originally posted by: berta_hauri.hotmail.com

Sorry, I posted the message too early

> Hi!
> I'm implemented my own editor which should be able to change the
> IEditorInput object.

So my editor implements IReusableEditor like this:

> public class ObjectEditor extends DBFormEditor implements IReusableEditor {
> ...
> public void setInput(IEditorInput obj) {
> super.setInput(obj);
> }
> }

> Now I try to reuse an editor by implementing an openEditor method like
> this:

> public void openEditor(IEditorInput obj, String editorID){
> IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
> try {
> if (dw != null) {
> IWorkbenchPage page = dw.getActivePage();
> if (page != null) {
> if (page.getEditorReferences().length > 10){
> IReusableEditor editor = (IReusableEditor)
page.getEditorReferences()[i].getEditor(false);
> page.reuseEditor(editor,obj);
> }
page.openEditor(obj,editorID);
> }
>
}
} catch (PartInitException e) {
}
> }

Unfortunately the content of the editor does not change if the reuseEditor
method is called. Do I need to implement something else?
TIA, Berta
Previous Topic:Calling WebSphere from an Eclipse plug-in
Next Topic:Refresh a project
Goto Forum:
  


Current Time: Wed Jul 24 15:34:36 GMT 2024

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

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

Back to the top