Listening for maximize event in a view [message #300072] |
Wed, 01 March 2006 08:54  |
Eclipse User |
|
|
|
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 #300111 is a reply to message #300108] |
Thu, 02 March 2006 09:31  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 1.06308 seconds