Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Listening for maximize event in a view
Listening for maximize event in a view [message #300072] Wed, 01 March 2006 08:54 Go to next message
Eclipse UserFriend
Originally posted by: bastewar.cis.strath.ac.uk

I am currently writing an Eclipse plug-in as part of my final year project. Very briefly, the view displays information on the inheritance hierarchy for selected types in a workspace, using features from the Zest plug-in to visualize the hierarchy as a directed graph). My main view class extends org.eclipse.ui.part.ViewPart

My view uses a layout manager which best-fits the hierarchy into the current size of the view. The view launches by default alongside the problems, console, .. views so it's quite small. If I then maximize, and re-apply the layout, it now performs a best-fit to the larger view size. Does anyone know how I can listen for my view being maximized/minimized so I can automatically re-apply the layout?

Another question is about mementos. My view uses an IType as input for calculating the hierarchy (the IType is derived from the current selection in the package explorer). This means that if I close my runtime instance of Eclipse with my view still open, then try to open the runtime instance again, I get an error (as it no longer has the IType as input). What I would like to do is automatically save what IType it was working with. I've tried to do this by looking at Mementos but they don't seem to save objects. Is there any way I can save this IType via mementos?

-Barrie
Re: Listening for maximize event in a view [message #300108 is a reply to message #300072] Thu, 02 March 2006 07:34 Go to previous messageGo to next message
Eclipse UserFriend
re: listening for maximize. I don't think there's a specific event fired
when maximizing a view. What you can do is attach a resize listener to
the control given to you in createPartControl(*). Don't forget to
remove the listener in your dispose() method.

re: IMemento's. You can't save your object to the IMemento. You need
to save enough information that you can go back to the JDT API and
retrieve that IType.

Later,
PW
Re: Listening for maximize event in a view [message #300111 is a reply to message #300108] Thu, 02 March 2006 09:31 Go to previous message
Eclipse UserFriend
Originally posted by: bastewar.cis.strath.ac.uk

Thanks for the reply. I've not tried the maximize thing yet but I've managed to find a point in the API where I can get the IType back from just a String. For future reference, it goes like this:

IType type = .... // The type we want to restore
String fqName = type.getFullyQualifiedName();

We would then save fqName in the memento and when trying to restore, we could retrieve fqName from the memento and do:

// Get the workspace
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
// Find all projects in workspace
IProject[] projects = root.getProjects();

// Cycle through projects
for (int i=0; i < projects.length ; i++)
{
IProject proj = projects[ i ] ;
IJavaProject javaProj = JavaCore.create(proj);
IType type = null;
try {
type = javaProj.findType(fqName);
} catch (JavaModelException e) {}

if (type != null) {return type;}
} // end of for loop
Previous Topic:Refactoring plugin
Next Topic:How to Pop up Internal browser in Eclipse automatically on an action event
Goto Forum:
  


Current Time: Tue Sep 16 17:01:00 EDT 2025

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

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

Back to the top