Commit | Line | Data |
---|---|---|
9c0ffa34 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2013 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Bernd Hufmann - Initial API and implementation | |
11 | **********************************************************************/ | |
12 | package org.eclipse.linuxtools.internal.tracing.rcp.ui; | |
13 | ||
14 | import java.net.URL; | |
15 | ||
16 | import org.eclipse.core.resources.IWorkspace; | |
17 | import org.eclipse.core.resources.ResourcesPlugin; | |
18 | import org.eclipse.core.runtime.FileLocator; | |
19 | import org.eclipse.core.runtime.IAdaptable; | |
20 | import org.eclipse.core.runtime.Path; | |
21 | import org.eclipse.core.runtime.Platform; | |
22 | import org.eclipse.jface.resource.ImageDescriptor; | |
23 | import org.eclipse.ui.application.IWorkbenchConfigurer; | |
24 | import org.eclipse.ui.application.IWorkbenchWindowConfigurer; | |
25 | import org.eclipse.ui.application.WorkbenchAdvisor; | |
26 | import org.eclipse.ui.application.WorkbenchWindowAdvisor; | |
27 | import org.eclipse.ui.ide.IDE; | |
28 | import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages; | |
29 | import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; | |
30 | import org.osgi.framework.Bundle; | |
31 | ||
32 | ||
33 | /** | |
34 | * WorkbenchAdvisor implementation of the LTTng RCP. | |
35 | * | |
36 | * @author Bernd Hufmann | |
37 | */ | |
38 | @SuppressWarnings("restriction") | |
39 | public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { | |
40 | ||
41 | // ------------------------------------------------------------------------ | |
42 | // Constants | |
43 | // ------------------------------------------------------------------------ | |
44 | // The default perspective | |
45 | private static final String PERSPECTIVE_ID = "org.eclipse.linuxtools.lttng2.kernel.ui.perspective"; //$NON-NLS-1$ | |
46 | ||
47 | ||
48 | private final static String ICONS_PATH = "$nl$/icons/full/"; //$NON-NLS-1$ | |
49 | private final static String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$ | |
50 | private final static String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$ | |
51 | private final static String PATH_ETOOL = ICONS_PATH + "etool16/"; //$NON-NLS-1$ | |
52 | private final static String PATH_DTOOL = ICONS_PATH + "dtool16/"; //$NON-NLS-1$ | |
53 | private final static String PATH_OBJECT = ICONS_PATH + "obj16/"; //$NON-NLS-1$ | |
54 | private final static String PATH_WIZBAN = ICONS_PATH + "wizban/";//$NON-NLS-1$ | |
55 | ||
56 | // ------------------------------------------------------------------------ | |
57 | // Operations | |
58 | // ------------------------------------------------------------------------ | |
59 | @Override | |
60 | public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { | |
61 | return new ApplicationWorkbenchWindowAdvisor(configurer); | |
62 | } | |
63 | ||
64 | @Override | |
65 | public void initialize(IWorkbenchConfigurer configurer) { | |
66 | configurer.setSaveAndRestore(true); | |
67 | declareWorkbenchImages(); | |
68 | } | |
69 | ||
70 | @Override | |
71 | public String getInitialWindowPerspectiveId() { | |
72 | return PERSPECTIVE_ID; | |
73 | } | |
74 | ||
75 | @Override | |
76 | public IAdaptable getDefaultPageInput() { | |
77 | IWorkspace workspace = ResourcesPlugin.getWorkspace(); | |
78 | return workspace.getRoot(); | |
79 | } | |
80 | ||
81 | @Override | |
82 | public void preStartup() { | |
83 | IDE.registerAdapters(); | |
84 | } | |
85 | ||
86 | // ------------------------------------------------------------------------ | |
87 | // Helper methods | |
88 | // ------------------------------------------------------------------------ | |
89 | private void declareWorkbenchImages() { | |
90 | ||
91 | Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH); | |
92 | ||
93 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, | |
94 | PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$ | |
95 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER, | |
96 | PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$ | |
97 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED, | |
98 | PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$ | |
99 | ||
100 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, | |
101 | PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$ | |
102 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER, | |
103 | PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$ | |
104 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED, | |
105 | PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$ | |
106 | ||
107 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL | |
108 | + "next_nav.gif", false); //$NON-NLS-1$ | |
109 | ||
110 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, | |
111 | PATH_ETOOL + "prev_nav.gif", false); //$NON-NLS-1$ | |
112 | ||
113 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, | |
114 | PATH_WIZBAN + "newprj_wiz.png", false); //$NON-NLS-1$ | |
115 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ, | |
116 | PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$ | |
117 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, | |
118 | PATH_WIZBAN + "newfile_wiz.png", false); //$NON-NLS-1$ | |
119 | ||
120 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ, | |
121 | PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$ | |
122 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ, | |
123 | PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$ | |
124 | ||
125 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ, | |
126 | PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$ | |
127 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ, | |
128 | PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$ | |
129 | ||
130 | declareWorkbenchImage(ideBundle, | |
131 | IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ, PATH_WIZBAN | |
132 | + "workset_wiz.png", false); //$NON-NLS-1$ | |
133 | ||
134 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, | |
135 | PATH_WIZBAN + "saveas_wiz.png", false); //$NON-NLS-1$ | |
136 | ||
137 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, | |
138 | PATH_WIZBAN + "quick_fix.png", false); //$NON-NLS-1$ | |
139 | ||
140 | declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT | |
141 | + "prj_obj.gif", true); //$NON-NLS-1$ | |
142 | declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT | |
143 | + "cprj_obj.gif", true); //$NON-NLS-1$ | |
144 | declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER, PATH_ELOCALTOOL | |
145 | + "gotoobj_tsk.gif", true); //$NON-NLS-1$ | |
146 | ||
147 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED, | |
148 | PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$ | |
149 | ||
150 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED, | |
151 | PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$ | |
152 | ||
153 | declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK, PATH_OBJECT | |
154 | + "taskmrk_tsk.gif", true); //$NON-NLS-1$ | |
155 | declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK, PATH_OBJECT | |
156 | + "bkmrk_tsk.gif", true); //$NON-NLS-1$ | |
157 | ||
158 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, | |
159 | PATH_OBJECT + "complete_tsk.gif", true); //$NON-NLS-1$ | |
160 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, | |
161 | PATH_OBJECT + "incomplete_tsk.gif", true); //$NON-NLS-1$ | |
162 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, | |
163 | PATH_OBJECT + "welcome_item.gif", true); //$NON-NLS-1$ | |
164 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, | |
165 | PATH_OBJECT + "welcome_banner.gif", true); //$NON-NLS-1$ | |
166 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, | |
167 | PATH_OBJECT + "error_tsk.gif", true); //$NON-NLS-1$ | |
168 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, | |
169 | PATH_OBJECT + "warn_tsk.gif", true); //$NON-NLS-1$ | |
170 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT | |
171 | + "info_tsk.gif", true); //$NON-NLS-1$ | |
172 | ||
173 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, | |
174 | PATH_ELOCALTOOL + "flatLayout.gif", true); //$NON-NLS-1$ | |
175 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT, | |
176 | PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$ | |
177 | declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY, | |
178 | PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$ | |
179 | } | |
180 | ||
181 | /** | |
182 | * Declares an IDE-specific workbench image. | |
183 | * | |
184 | * Declares all IDE-specific workbench images. This includes both "shared" | |
185 | * images (named in ( @link IDE.SharedImages} ) and internal images (named in | |
186 | * {@link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}). | |
187 | * | |
188 | * @param symbolicName | |
189 | * the symbolic name of the image | |
190 | * @param path | |
191 | * the path of the image file; this path is relative to the base | |
192 | * of the IDE plug-in | |
193 | * @param shared | |
194 | * <code>true</code> if this is a shared image, and | |
195 | * <code>false</code> if this is not a shared image | |
196 | */ | |
197 | private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String path, boolean shared) { | |
198 | URL url = FileLocator.find(ideBundle, new Path(path), null); | |
199 | ImageDescriptor desc = ImageDescriptor.createFromURL(url); | |
200 | getWorkbenchConfigurer().declareImage(symbolicName, desc, shared); | |
201 | } | |
202 | } |