ApplicationWorkbenchAdvisor.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.viewer.framework;
00002 
00003 import org.eclipse.ui.IWindowListener;
00004 import org.eclipse.ui.IWorkbench;
00005 import org.eclipse.ui.IWorkbenchWindow;
00006 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
00007 import org.eclipse.ui.application.WorkbenchAdvisor;
00008 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
00009 import org.eclipse.ui.application.IWorkbenchConfigurer;
00010 
00011 import edu.rice.cs.hpc.viewer.window.ViewerWindow;
00012 import edu.rice.cs.hpc.viewer.window.ViewerWindowManager;
00013 
00014 public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
00015 
00016     public static final String PERSPECTIVE_ID = "edu.rice.cs.hpc.perspective";
00017     private String[] args;
00018 
00019     // laks: we need to save and restore the configuration
00020     public void initialize(IWorkbenchConfigurer configurer) {
00021         super.initialize(configurer);
00022         // enable the workbench state save mechanism
00023         configurer.setSaveAndRestore(true);
00024     }
00025     
00026     public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
00027             IWorkbenchWindowConfigurer configurer) {
00028         return new ApplicationWorkbenchWindowAdvisor(configurer, this.args);
00029     }
00030 
00031     public String getInitialWindowPerspectiveId() {
00032         return PERSPECTIVE_ID;
00033     }
00034 
00035     public ApplicationWorkbenchAdvisor() {
00036         super();
00037     }
00038     
00039     public ApplicationWorkbenchAdvisor(String []arguments) {
00040         super();
00041         this.args = arguments;
00042     }
00043     
00044     
00045     /*
00046      * (non-Javadoc)
00047      * @see org.eclipse.ui.application.WorkbenchAdvisor#postStartup()
00048      */
00049     public void postStartup() {
00050         super.postStartup();
00051         
00052         final IWorkbench workbench = this.getWorkbenchConfigurer().getWorkbench();
00053         
00054         // -----------------------------------------------------------------------------
00055         // add listener when a workbench window is activated. 
00056         //  this listener is useful to update the status of "merge" menu when we 
00057         //  have  multiple instances of windows. If one window has only one database
00058         //  and the other has two databases, then the "merge" menu only visible for
00059         //  the latter window, and not the former
00060         // -----------------------------------------------------------------------------
00061         workbench.addWindowListener( new IWindowListener() {
00062 
00063             public void windowActivated(IWorkbenchWindow window) 
00064             {
00065                 ViewerWindow vWin = ViewerWindowManager.getViewerWindow(window);
00066                 if (vWin != null)
00067                 {
00068                     vWin.checkService();
00069                 }
00070             }
00071 
00072             public void windowDeactivated(IWorkbenchWindow window) {}
00073             public void windowClosed(IWorkbenchWindow window) {}
00074             public void windowOpened(IWorkbenchWindow window) {}
00075             
00076         });
00077     }
00078 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1