KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > ApplicationWorkbenchAdvisor


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio;
22
23
24 import org.eclipse.jface.dialogs.Dialog;
25 import org.eclipse.jface.dialogs.TrayDialog;
26 import org.eclipse.jface.resource.ImageDescriptor;
27 import org.eclipse.jface.resource.ImageRegistry;
28 import org.eclipse.jface.resource.JFaceResources;
29 import org.eclipse.ui.PlatformUI;
30 import org.eclipse.ui.application.IWorkbenchConfigurer;
31 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
32 import org.eclipse.ui.application.WorkbenchAdvisor;
33 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
34
35
36 /**
37  * This workbench advisor creates the window advisor, and specifies
38  * the perspective id for the initial window.<br />
39  * <br />
40  * - initialize Called first to perform any setup such as parsing the command
41  * line, registering adapters, declaring images, etc.. IWorkbenchConfigurer<br />
42  * - preStartup Called after initialization but before the first window is opened.
43  * May be used to set options affecting which editors and views are initially opened. <br />
44  * - postStartup Called after all windows have been opened or restored, but before
45  * the event loop starts. It can be used to start automatic processes and to open tips or
46  * other windows.<br />
47  * - preShutdown Called after the event loop has terminated but before any windows
48  * have been closed. <br />
49  * - postShutdown Called after all windows are closed during Workbench shutdown.
50  *
51  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
52  * @version $Rev$, $Date$
53  */

54 public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor
55 {
56     // The initial perspective that will be shwown in the workbench
57
private static final String JavaDoc PERSPECTIVE_ID = Application.PLUGIN_ID + ".perspective"; //$NON-NLS-1$
58

59
60     /**
61      * Performs arbitrary initialization before the workbench starts running.<br />
62      * <br />
63      * This method is called during workbench initialization prior to any windows
64      * being opened. Clients must not call this method directly (although super calls
65      * are okay). The default implementation does nothing. Subclasses may override.
66      * Typical clients will use the configurer passed in to tweak the workbench. If
67      * further tweaking is required in the future, the configurer may be obtained using
68      * getWorkbenchConfigurer
69      */

70     public void initialize( IWorkbenchConfigurer configurer )
71     {
72         //enable the save/restore windows size & position feature
73
configurer.setSaveAndRestore( true );
74
75         //enable help button in dialogs
76
TrayDialog.setDialogHelpAvailable( true );
77         ImageRegistry reg = JFaceResources.getImageRegistry();
78         ImageDescriptor helpImage = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
79             "IMGS_LCL_LINKTO_HELP" );
80         reg.put( Dialog.DLG_IMG_HELP, helpImage );
81     }
82
83
84     /**
85      * Creates a new workbench window advisor for configuring a new workbench
86      * window via the given workbench window configurer. Clients should override
87      * to provide their own window configurer. This method replaces all the other
88      * window and action bar lifecycle methods on the workbench advisor.
89      */

90     public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor( IWorkbenchWindowConfigurer configurer )
91     {
92         return new ApplicationWorkbenchWindowAdvisor( configurer );
93     }
94
95
96     /**
97      * Returns the id of the perspective to use for the initial workbench window,
98      * or null if no initial perspective should be shown in the initial workbench
99      * window.<br />
100      * <br />
101      * This method is called during startup when the workbench is creating the first
102      * new window. Subclasses must implement.<br />
103      * <br />
104      * If the IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID preference is
105      * specified, it supercedes the perspective specified here.
106      */

107     public String JavaDoc getInitialWindowPerspectiveId()
108     {
109         return PERSPECTIVE_ID;
110     }
111
112
113     /**
114      * Performs arbitrary finalization before the workbench is about to shut down.<br />
115      * <br />
116      * This method is called immediately prior to workbench shutdown before any
117      * windows have been closed. Clients must not call this method directly (although
118      * super calls are okay). The default implementation returns true. Subclasses may
119      * override.
120      */

121     public boolean preShutdown()
122     {
123         return true;
124     }
125
126 }
127
Popular Tags