Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Closing a View (ViewPart)
Closing a View (ViewPart) [message #290452] Thu, 25 August 2005 15:11 Go to next message
Eclipse UserFriend
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 #290477 is a reply to message #290452] Thu, 25 August 2005 16:59 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Azze wrote:
> 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.


The javadocs for IWorkbenchPart#dispose() says "Clients should not call
this method (the workbench calls this method at appropriate times)."

Check out IWorkbenchPage#showView() and IWorkbenchPage#hideView().

Later,
PW


Re: Closing a View (ViewPart) [message #290491 is a reply to message #290452] Thu, 25 August 2005 18:07 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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


Re: Closing a View (ViewPart) [message #290515 is a reply to message #290510] Thu, 25 August 2005 21:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: azrael.xofx.de

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 #290518 is a reply to message #290515] Thu, 25 August 2005 22:15 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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 :-)
Previous Topic:Minimum hardware requirements
Next Topic:PDE: ILightweightLabelDecorator not refreshing
Goto Forum:
  


Current Time: Fri Apr 19 09:18:56 GMT 2024

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

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

Back to the top