Handling the last document close in eclipse editor [message #323228] |
Sat, 15 December 2007 12:29 |
Eclipse User |
|
|
|
Originally posted by: prameela.nair.gmail.com
Hi,
Can we keep track of number of open files,browsers,etc in the editor
area of eclipse. I want to set my editor to false as soon as the last
document within the editor is closed.
Any suggestions on how can I achieve this?
/Prameela
|
|
|
|
Re: Handling the last document close in eclipse editor [message #323390 is a reply to message #323244] |
Wed, 19 December 2007 12:08 |
Eclipse User |
|
|
|
Originally posted by: prameela.nair.gmail.com
I am somewhat lost with opening browsers in eclipse. Any links/pointers
/suggestions guiding me would be really helpful
I have to open mutiple web browsers in my plugin. Although I able to
open the browsers my problems are:
0) Every browser replaces an old browser. I want new Browsers for every
click. Should also be able to check if a particular browser is already
open(I think this would be handled programmatically but just wanted to
confirm).
1)The browser opens in the editor area(which is by default invisible in
my plugin). And the editor area opens at some location. Can I control
where my editor area opens by default?
2)When I close all my browsers I should be able to make my editor area
invisible. I understand that Snjezana had replied asking me to use
IPartListener2 but I am lost as to where should this listener be registered?
/Prameela
Snjezana Peco wrote:
> You can register IPartListener2.
> You can get open editors using IWorkbenchPage.getEditorReferences().
>
> Snjeza
>
> Prameela wrote:
>> Hi,
>>
>> Can we keep track of number of open files,browsers,etc in the editor
>> area of eclipse. I want to set my editor to false as soon as the last
>> document within the editor is closed.
>>
>> Any suggestions on how can I achieve this?
>>
>> /Prameela
|
|
|
Re: Handling the last document close in eclipse editor [message #323396 is a reply to message #323390] |
Wed, 19 December 2007 14:29 |
Eclipse User |
|
|
|
Originally posted by: thorsten_schlathoelter.westlb.de
Hi Prameela
0) I think Eclipse will reuse an existing editor if the editor input you
provide for your editor matches the editor input of an existing editor. So
make sure the editor inputs do not match (you may want to look at
org.eclipse.uiIEditorMatchingStrategy)
1) You can specify if the editor area is visible or not in your
perspective factory:
e.g.
public class HomePerspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
layout.addView(IUiPluginIds.FOLDER_VIEW_ID, IPageLayout.LEFT, .28f,
IPageLayout.ID_EDITOR_AREA);
layout.setEditorAreaVisible(false);
}
}
2) You can register a PartListener2 with a workbench window. If you are
using an RCP application, you will have a WorkbenchWindowAdvisor. In the
preWindowOpen method of the advisor you can do the following:
getWindowConfigurer().getWindow().getPartService().addPartLi stener(new
IPartListener() {
....
public void partClosed(IWorkbenchPart part) {
// Add a part listener that takes care of switching perspective if
no
// active editor is available.
// This solves the problem of having an empty editor area in a
// perspective.
if (part instanceof EditorPart) {
IEditorReference[] refs =
part.getSite().getPage().getEditorReferences();
if (refs==null || refs.length==0) {
// do something. e.g. swicth to another perspective
}
}
}
....
}
Of yource you can also register with the active workbench window if you
are running in eclipse.
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPart Service()
.addPartListener(listener);
Hope this helps
Thorsten
Pla
Prameela wrote:
> I am somewhat lost with opening browsers in eclipse. Any links/pointers
> /suggestions guiding me would be really helpful
> I have to open mutiple web browsers in my plugin. Although I able to
> open the browsers my problems are:
> 0) Every browser replaces an old browser. I want new Browsers for every
> click. Should also be able to check if a particular browser is already
> open(I think this would be handled programmatically but just wanted to
> confirm).
> 1)The browser opens in the editor area(which is by default invisible in
> my plugin). And the editor area opens at some location. Can I control
> where my editor area opens by default?
> 2)When I close all my browsers I should be able to make my editor area
> invisible. I understand that Snjezana had replied asking me to use
> IPartListener2 but I am lost as to where should this listener be registered?
> /Prameela
> Snjezana Peco wrote:
>> You can register IPartListener2.
>> You can get open editors using IWorkbenchPage.getEditorReferences().
>>
>> Snjeza
>>
>> Prameela wrote:
>>> Hi,
>>>
>>> Can we keep track of number of open files,browsers,etc in the editor
>>> area of eclipse. I want to set my editor to false as soon as the last
>>> document within the editor is closed.
>>>
>>> Any suggestions on how can I achieve this?
>>>
>>> /Prameela
|
|
|
Re: Handling the last document close in eclipse editor [message #323438 is a reply to message #323396] |
Thu, 20 December 2007 13:04 |
Eclipse User |
|
|
|
Originally posted by: prameela.nair.gmail.com
Hi Thorsten,
Would you please elaborate on how should I check if my editor input for
a browser matches an existing one?
Any links/pointers would be really helpful.
I use the below lines of code to invoke the browser and i see no place
where the editor input is set.
<snippet>
IWorkbenchBrowserSupport support =
PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser = support.createBrowser("someId");
browser.openURL(new URL("https://www.google.com"));
</snippet>
/Prameela
tschlat wrote:
> Hi Prameela
>
> 0) I think Eclipse will reuse an existing editor if the editor input you
> provide for your editor matches the editor input of an existing editor.
> So make sure the editor inputs do not match (you may want to look at
> org.eclipse.uiIEditorMatchingStrategy)
|
|
|
Re: Handling the last document close in eclipse editor [message #323440 is a reply to message #323438] |
Thu, 20 December 2007 13:49 |
Eclipse User |
|
|
|
Originally posted by: prameela.nair.gmail.com
Yup, I think I got it. I had used same Id's while creating 2
browsers...hence it was opening in the same browser -
IWebBrowser browser = support.createBrowser("someId");
Worked as i wanted it to when i changed the Id. This is what happens
when you simple copy paste your working code ;)
/Prameela
Prameela wrote:
> Hi Thorsten,
>
> Would you please elaborate on how should I check if my editor input for
> a browser matches an existing one?
>
> Any links/pointers would be really helpful.
>
> I use the below lines of code to invoke the browser and i see no place
> where the editor input is set.
>
> <snippet>
> IWorkbenchBrowserSupport support =
> PlatformUI.getWorkbench().getBrowserSupport();
>
> IWebBrowser browser = support.createBrowser("someId");
> browser.openURL(new URL("https://www.google.com"));
>
> </snippet>
>
> /Prameela
>
>
>
> tschlat wrote:
>> Hi Prameela
>>
>> 0) I think Eclipse will reuse an existing editor if the editor input
>> you provide for your editor matches the editor input of an existing
>> editor. So make sure the editor inputs do not match (you may want to
>> look at org.eclipse.uiIEditorMatchingStrategy)
|
|
|
Powered by
FUDForum. Page generated in 0.03342 seconds