Closing a View (ViewPart) [message #290452] |
Thu, 25 August 2005 15:11 |
Eclipse User |
|
|
|
Originally posted by: azrael.xofx.de
Hi,
i can´t find any information about how to close a viewpart correctly.
In my example i create a view with one composite. When i use the
this.dispose() method i get a "Graphic is disposed" error.
My Example:
A view which logins in a server through a webservice. Is the user valid,
the view shows a table with data. Is the user not valid, a pop-up
message is shown with the error message an the view should be closed.
thnx a lot
|
|
|
|
Re: Closing a View (ViewPart) [message #290491 is a reply to message #290452] |
Thu, 25 August 2005 18:07 |
Eclipse User |
|
|
|
Originally posted by: macneil.gmail.com
You can try something like this:
IWorkbenchWindow[] windows =
PlatformUI.getWorkbench().getWorkbenchWindows();
for (IWorkbenchWindow window : windows) {
for (IWorkbenchPage page : window.getPages()) {
for (IViewReference ivr : page.getViewReferences()) {
if (ivr is the one you want to close...) {
page.hideView(ivr);
}
}
}
}
For the ivr test, pehaps you can use the primary and or secondary ID.
|
|
|
Re: Closing a View (ViewPart) [message #290501 is a reply to message #290491] |
Thu, 25 August 2005 19:05 |
Eclipse User |
|
|
|
Originally posted by: azrael.xofx.de
Thnx for the hint.
The problem is, that i only get the views from eclipse and not the view
from my plugin:
Reference: Nr. 0 , org.eclipse.jdt.ui.PackageExplorer
Reference: Nr. 1 , org.eclipse.jdt.ui.TypeHierarchy
Reference: Nr. 2 , org.eclipse.ui.views.ProblemView
Reference: Nr. 3 , org.eclipse.jdt.ui.JavadocView
Reference: Nr. 4 , org.eclipse.jdt.ui.SourceView
Reference: Nr. 5 , org.eclipse.ui.views.ContentOutline
???
Azze
|
|
|
Re: Closing a View (ViewPart) [message #290510 is a reply to message #290501] |
Thu, 25 August 2005 19:13 |
|
Azze wrote:
> Thnx for the hint.
>
> The problem is, that i only get the views from eclipse and not the view
> from my plugin:
>
> Reference: Nr. 0 , org.eclipse.jdt.ui.PackageExplorer
> Reference: Nr. 1 , org.eclipse.jdt.ui.TypeHierarchy
> Reference: Nr. 2 , org.eclipse.ui.views.ProblemView
> Reference: Nr. 3 , org.eclipse.jdt.ui.JavadocView
> Reference: Nr. 4 , org.eclipse.jdt.ui.SourceView
> Reference: Nr. 5 , org.eclipse.ui.views.ContentOutline
>
> ???
>
> Azze
How do you create your view?
The only way to create a view is by using IWorkbenchPage#showView(...),
the only way to remove a view is by calling IWorkbenhPage@#hideView(...).
Anything else won't work.
You can extend IWorkbenchPart#dispose() if you want, and then you would
call super.dispose(), but that's the only time.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
Re: Closing a View (ViewPart) [message #290518 is a reply to message #290515] |
Thu, 25 August 2005 22:15 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
That doesn't create a view. It declares that a view is available for
use. Someone must select Windows->Show View to show the view, or it must
be configured to be on a Perspective, and then the next time that
perspective is newly opened the view will be there. Or there must be
some action that explicitly does a show view.
Azze wrote:
> Hi,
>
>> How do you create your view?
>
> i create a view by adding it to the plugin.xml. That´s all.
--
Thanks,
Rich Kulp
|
|
|
Re: Closing a View (ViewPart) [message #290543 is a reply to message #290518] |
Fri, 26 August 2005 07:47 |
Eclipse User |
|
|
|
Originally posted by: azrael.xofx.de
Yes, thats right. Someone opens the view by clicking Windows->Show View.
But my problem is that before the view opens something will be checked.
If it is false, then the view should not be opened.
So i want to close the view in the view class.
Azze
Rich Kulp schrieb:
> That doesn't create a view. It declares that a view is available for
> use. Someone must select Windows->Show View to show the view, or it must
> be configured to be on a Perspective, and then the next time that
> perspective is newly opened the view will be there. Or there must be
> some action that explicitly does a show view.
>
> Azze wrote:
>
>> Hi,
>>
>>> How do you create your view?
>>
>>
>> i create a view by adding it to the plugin.xml. That´s all.
>
>
|
|
|
Re: Closing a View (ViewPart) [message #290550 is a reply to message #290543] |
Fri, 26 August 2005 11:12 |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
There's not an easy way to do that. Why do people want to fight Eclipse instead of working with it?
If a view is there, it should be openable. It might not have the correct context, but it shouldn't prevent it being opened. It should just show an empty area.
There's many reasons why you might want a view to be opened even if you know you can't use it. To customise a Perspective, to drag it into the right place, to resize it, and so forth.
Imagine if the Console or Errors view in Eclipse refused to open just because there weren't any messages available.
Work with Eclipse, and Eclipse gives you wings. Fight Eclipse, and you write crap plugins that no-one will want to use.
|
|
|
Re: Closing a View (ViewPart) [message #290596 is a reply to message #290543] |
Fri, 26 August 2005 15:18 |
Eclipse User |
|
|
|
Originally posted by: sunil_kamath.nohotspammail.com
"Azze" <azrael@xofx.de> wrote in message
news:demhev$9dv$1@news.eclipse.org...
> Yes, thats right. Someone opens the view by clicking Windows->Show View.
> But my problem is that before the view opens something will be checked. If
> it is false, then the view should not be opened.
>
> So i want to close the view in the view class.
>
> Azze
>
Why not just show an error message in the view if the "something"
which was checked fails?
Trying to close a view while it is in the process of opening is
bad practice.
---
Sunil
|
|
|
Re: Closing a View (ViewPart) [message #290599 is a reply to message #290452] |
Fri, 26 August 2005 15:50 |
Eclipse User |
|
|
|
Originally posted by: azrael.xofx.de
Hi,
okay, maybe it is the wrong way.
I will let the view opened till the user close it by himself.
The advantage is that the user can still manipulate the view like
resizing and so on.
Thanks a lot for your answers :-)
|
|
|
Powered by
FUDForum. Page generated in 0.02498 seconds