IWorkbenchPage [message #268971] |
Fri, 27 August 2004 07:49  |
Eclipse User |
|
|
|
Originally posted by: pt00mfr.student.bth.se
Hi, I have a plug-in with a tree of objects, and when one node in the tree
is selected, some data in the object is shown as an editor at the
IWorkbenchPage. The problem is that it always open a new page instead of
checking if an object already is open and then only make that page as the
active.
The code used is shown below:
IWorkbenchWindow window =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IStorage storage = new StringStorage(value);
IStorageEditorInput input = new StringInput(storage);
IWorkbenchPage page = window.getActivePage();
if(page != null) {
if(page.findEditor(input) == null || (!value.equals(""))){
try {
page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
}
catch (PartInitException pie) {pie.printStackTrace();}
} else {
page.activate(page.findEditor(input));
}
}
/regards Frasse
|
|
|
|
Re: IWorkbenchPage [message #269183 is a reply to message #268995] |
Mon, 30 August 2004 05:24  |
Eclipse User |
|
|
|
Originally posted by: pt00mfr.student.bth.se
Thanks for the help it works fine now. I implemented hashCode() function.
/Frasse
Nick Edgar wrote:
> Does your editor input implementation implement equals appropriately?
> Note also that the openEditor call will run if (!value.equals("")) is true.
> However, openEditor should not open a second editor if it finds one with the
> same input already open (the find code is redundant), but both findEditor
> and openEditor require equals to work on the editor input (and should
> implement hashCode() too of course).
> Nick
> "Frasse" <pt00mfr@student.bth.se> wrote in message
> news:cgn74b$fbm$1@eclipse.org...
> > Hi, I have a plug-in with a tree of objects, and when one node in the tree
> > is selected, some data in the object is shown as an editor at the
> > IWorkbenchPage. The problem is that it always open a new page instead of
> > checking if an object already is open and then only make that page as the
> > active.
> >
> > The code used is shown below:
> >
> > IWorkbenchWindow window =
> > PlatformUI.getWorkbench().getActiveWorkbenchWindow();
> > IStorage storage = new StringStorage(value);
> > IStorageEditorInput input = new StringInput(storage);
> > IWorkbenchPage page = window.getActivePage();
> > if(page != null) {
> > if(page.findEditor(input) == null || (!value.equals(""))){
> > try {
> > page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
> > }
> > catch (PartInitException pie) {pie.printStackTrace();}
> > } else {
> > page.activate(page.findEditor(input));
> > }
> > }
> >
> > /regards Frasse
> >
|
|
|
Powered by
FUDForum. Page generated in 0.08214 seconds