KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > IDEWorkbenchAdvisor


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.ide;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14 import java.net.URL JavaDoc;
15 import java.util.ArrayList JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.Map JavaDoc;
18 import java.util.TreeMap JavaDoc;
19
20 import org.eclipse.core.resources.IContainer;
21 import org.eclipse.core.resources.IResource;
22 import org.eclipse.core.resources.ResourcesPlugin;
23 import org.eclipse.core.resources.WorkspaceJob;
24 import org.eclipse.core.runtime.CoreException;
25 import org.eclipse.core.runtime.IAdaptable;
26 import org.eclipse.core.runtime.IBundleGroup;
27 import org.eclipse.core.runtime.IBundleGroupProvider;
28 import org.eclipse.core.runtime.IProgressMonitor;
29 import org.eclipse.core.runtime.IStatus;
30 import org.eclipse.core.runtime.MultiStatus;
31 import org.eclipse.core.runtime.Path;
32 import org.eclipse.core.runtime.Platform;
33 import org.eclipse.core.runtime.PluginVersionIdentifier;
34 import org.eclipse.core.runtime.Status;
35 import org.eclipse.core.runtime.jobs.Job;
36 import org.eclipse.jface.dialogs.Dialog;
37 import org.eclipse.jface.dialogs.ErrorDialog;
38 import org.eclipse.jface.dialogs.IDialogSettings;
39 import org.eclipse.jface.dialogs.MessageDialog;
40 import org.eclipse.jface.dialogs.TrayDialog;
41 import org.eclipse.jface.operation.IRunnableWithProgress;
42 import org.eclipse.jface.preference.IPreferenceStore;
43 import org.eclipse.jface.resource.ImageDescriptor;
44 import org.eclipse.jface.resource.ImageRegistry;
45 import org.eclipse.jface.resource.JFaceResources;
46 import org.eclipse.jface.window.Window;
47 import org.eclipse.swt.SWT;
48 import org.eclipse.swt.widgets.Display;
49 import org.eclipse.swt.widgets.Listener;
50 import org.eclipse.ui.PlatformUI;
51 import org.eclipse.ui.application.IWorkbenchConfigurer;
52 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
53 import org.eclipse.ui.application.WorkbenchAdvisor;
54 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
55 import org.eclipse.ui.ide.IDE;
56 import org.eclipse.ui.internal.ISelectionConversionService;
57 import org.eclipse.ui.internal.Workbench;
58 import org.eclipse.ui.internal.ide.model.WorkbenchAdapterBuilder;
59 import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog;
60 import org.eclipse.ui.progress.IProgressService;
61 import org.eclipse.update.core.SiteManager;
62 import org.osgi.framework.Bundle;
63
64 /**
65  * IDE-specified workbench advisor which configures the workbench for use as an
66  * IDE.
67  * <p>
68  * Note: This class replaces <code>org.eclipse.ui.internal.Workbench</code>.
69  * </p>
70  *
71  * @since 3.0
72  */

73 public class IDEWorkbenchAdvisor extends WorkbenchAdvisor {
74
75     private static final String JavaDoc WORKBENCH_PREFERENCE_CATEGORY_ID = "org.eclipse.ui.preferencePages.Workbench"; //$NON-NLS-1$
76

77     /**
78      * The dialog setting key to access the known installed features since the
79      * last time the workbench was run.
80      */

81     private static final String JavaDoc INSTALLED_FEATURES = "installedFeatures"; //$NON-NLS-1$
82

83     private static IDEWorkbenchAdvisor workbenchAdvisor = null;
84
85     /**
86      * Event loop exception handler for the advisor.
87      */

88     private IDEExceptionHandler exceptionHandler = null;
89
90     /**
91      * Contains the workspace location if the -showlocation command line
92      * argument is specified, or <code>null</code> if not specified.
93      */

94     private String JavaDoc workspaceLocation = null;
95
96     /**
97      * Ordered map of versioned feature ids -> info that are new for this
98      * session; <code>null</code> if uninitialized. Key type:
99      * <code>String</code>, Value type: <code>AboutInfo</code>.
100      */

101     private Map JavaDoc newlyAddedBundleGroups;
102
103     /**
104      * Array of <code>AboutInfo</code> for all new installed features that
105      * specify a welcome perspective.
106      */

107     private AboutInfo[] welcomePerspectiveInfos = null;
108
109     /**
110      * Helper for managing activites in response to workspace changes.
111      */

112     private IDEWorkbenchActivityHelper activityHelper = null;
113
114     /**
115      * Helper for managing work that is performed when the system is otherwise
116      * idle.
117      */

118     private IDEIdleHelper idleHelper;
119
120     private Listener settingsChangeListener;
121
122     /**
123      * Creates a new workbench advisor instance.
124      */

125     public IDEWorkbenchAdvisor() {
126         super();
127         if (workbenchAdvisor != null) {
128             throw new IllegalStateException JavaDoc();
129         }
130         workbenchAdvisor = this;
131     }
132
133     /*
134      * (non-Javadoc)
135      *
136      * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize
137      */

138     public void initialize(IWorkbenchConfigurer configurer) {
139
140         // make sure we always save and restore workspace state
141
configurer.setSaveAndRestore(true);
142
143         // setup the event loop exception handler
144
exceptionHandler = new IDEExceptionHandler(configurer);
145
146         // register workspace adapters
147
WorkbenchAdapterBuilder.registerAdapters();
148
149         // get the command line arguments
150
String JavaDoc[] cmdLineArgs = Platform.getCommandLineArgs();
151
152         // include the workspace location in the title
153
// if the command line option -showlocation is specified
154
for (int i = 0; i < cmdLineArgs.length; i++) {
155             if ("-showlocation".equalsIgnoreCase(cmdLineArgs[i])) { //$NON-NLS-1$
156
String JavaDoc name = null;
157                 if (cmdLineArgs.length > i + 1) {
158                     name = cmdLineArgs[i + 1];
159                 }
160                 if (name != null && name.indexOf("-") == -1) { //$NON-NLS-1$
161
workspaceLocation = name;
162                 } else {
163                     workspaceLocation = Platform.getLocation().toOSString();
164                 }
165                 break;
166             }
167         }
168
169         // register shared images
170
declareWorkbenchImages();
171
172         // initialize the activity helper
173
activityHelper = IDEWorkbenchActivityHelper.getInstance();
174
175         // initialize idle handler
176
idleHelper = new IDEIdleHelper(configurer);
177
178         // show Help button in JFace dialogs
179
TrayDialog.setDialogHelpAvailable(true);
180
181         // use this image for the help button in dialogs
182
ImageRegistry reg = JFaceResources.getImageRegistry();
183         reg
184                 .put(
185                         Dialog.DLG_IMG_HELP,
186                         IDEInternalWorkbenchImages
187                                 .getImageDescriptor(IDEInternalWorkbenchImages.IMG_LCL_LINKTO_HELP));
188     }
189
190     /*
191      * (non-Javadoc)
192      *
193      * @see org.eclipse.ui.application.WorkbenchAdvisor#preStartup()
194      */

195     public void preStartup() {
196
197         // Suspend background jobs while we startup
198
Platform.getJobManager().suspend();
199
200         // Register the build actions
201
IProgressService service = PlatformUI.getWorkbench()
202                 .getProgressService();
203         ImageDescriptor newImage = IDEInternalWorkbenchImages
204                 .getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC);
205         service.registerIconForFamily(newImage,
206                 ResourcesPlugin.FAMILY_MANUAL_BUILD);
207         service.registerIconForFamily(newImage,
208                 ResourcesPlugin.FAMILY_AUTO_BUILD);
209     }
210
211     /*
212      * (non-Javadoc)
213      *
214      * @see org.eclipse.ui.application.WorkbenchAdvisor#postStartup()
215      */

216     public void postStartup() {
217         try {
218             refreshFromLocal();
219             checkUpdates();
220             ((Workbench) PlatformUI.getWorkbench()).registerService(
221                     ISelectionConversionService.class,
222                     new IDESelectionConversionService());
223
224             initializeSettingsChangeListener();
225             Display.getCurrent().addListener(SWT.Settings,
226                     settingsChangeListener);
227         } finally {// Resume background jobs after we startup
228
Platform.getJobManager().resume();
229         }
230     }
231
232     /**
233      * Initialize the listener for settings changes.
234      */

235     private void initializeSettingsChangeListener() {
236         settingsChangeListener = new Listener() {
237             
238             boolean currentHighContrast = Display.getCurrent().getHighContrast();
239             public void handleEvent(org.eclipse.swt.widgets.Event event) {
240                 if(Display.getCurrent().getHighContrast() == currentHighContrast)
241                     return;
242                 
243                 currentHighContrast = !currentHighContrast;
244                 
245                 // make sure they really want to do this
246
if (new MessageDialog(null,
247                         IDEWorkbenchMessages.SystemSettingsChange_title, null,
248                         IDEWorkbenchMessages.SystemSettingsChange_message,
249                         MessageDialog.QUESTION, new String JavaDoc[] {
250                                 IDEWorkbenchMessages.SystemSettingsChange_yes,
251                                 IDEWorkbenchMessages.SystemSettingsChange_no },
252                         1).open() == Window.OK) {
253                     PlatformUI.getWorkbench().restart();
254                 }
255             }
256         };
257
258     }
259
260     /*
261      * (non-Javadoc)
262      *
263      * @see org.eclipse.ui.application.WorkbenchAdvisor#postShutdown
264      */

265     public void postShutdown() {
266         if (activityHelper != null) {
267             activityHelper.shutdown();
268             activityHelper = null;
269         }
270         if (idleHelper != null) {
271             idleHelper.shutdown();
272             idleHelper = null;
273         }
274         if (IDEWorkbenchPlugin.getPluginWorkspace() != null) {
275             disconnectFromWorkspace();
276         }
277     }
278
279     /*
280      * (non-Javadoc)
281      *
282      * @see org.eclipse.ui.application.WorkbenchAdvisor#preShutdown()
283      */

284     public boolean preShutdown() {
285         Display.getCurrent().removeListener(SWT.Settings,
286                 settingsChangeListener);
287         return super.preShutdown();
288     }
289
290     /*
291      * (non-Javadoc)
292      *
293      * @see org.eclipse.ui.application.WorkbenchAdvisor#eventLoopException
294      */

295     public void eventLoopException(Throwable JavaDoc exception) {
296         super.eventLoopException(exception);
297         if (exceptionHandler != null) {
298             exceptionHandler.handleException(exception);
299         } else {
300             if (getWorkbenchConfigurer() != null) {
301                 getWorkbenchConfigurer().emergencyClose();
302             }
303         }
304     }
305
306     /*
307      * (non-Javadoc)
308      *
309      * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
310      */

311     public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
312             IWorkbenchWindowConfigurer configurer) {
313         return new IDEWorkbenchWindowAdvisor(this, configurer);
314     }
315
316     /**
317      * Return true if the intro plugin is present and false otherwise.
318      *
319      * @return boolean
320      */

321     public boolean hasIntro() {
322         return getWorkbenchConfigurer().getWorkbench().getIntroManager()
323                 .hasIntro();
324     }
325
326     private void refreshFromLocal() {
327         String JavaDoc[] commandLineArgs = Platform.getCommandLineArgs();
328         IPreferenceStore store = IDEWorkbenchPlugin.getDefault()
329                 .getPreferenceStore();
330         boolean refresh = store
331                 .getBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP);
332         if (!refresh) {
333             return;
334         }
335
336         // Do not refresh if it was already done by core on startup.
337
for (int i = 0; i < commandLineArgs.length; i++) {
338             if (commandLineArgs[i].equalsIgnoreCase("-refresh")) { //$NON-NLS-1$
339
return;
340             }
341         }
342
343         final IContainer root = ResourcesPlugin.getWorkspace().getRoot();
344         Job job = new WorkspaceJob(IDEWorkbenchMessages.Workspace_refreshing) {
345             public IStatus runInWorkspace(IProgressMonitor monitor)
346                     throws CoreException {
347                 root.refreshLocal(IResource.DEPTH_INFINITE, monitor);
348                 return Status.OK_STATUS;
349             }
350         };
351         job.setRule(root);
352         job.schedule();
353     }
354
355     /**
356      * Disconnect from the core workspace.
357      */

358     private void disconnectFromWorkspace() {
359         // save the workspace
360
final MultiStatus status = new MultiStatus(
361                 IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
362                 IDEWorkbenchMessages.ProblemSavingWorkbench, null);
363         IRunnableWithProgress runnable = new IRunnableWithProgress() {
364             public void run(IProgressMonitor monitor) {
365                 try {
366                     status.merge(ResourcesPlugin.getWorkspace().save(true,
367                             monitor));
368                 } catch (CoreException e) {
369                     status.merge(e.getStatus());
370                 }
371             }
372         };
373         try {
374             new ProgressMonitorJobsDialog(null).run(true, false, runnable);
375         } catch (InvocationTargetException JavaDoc e) {
376             status
377                     .merge(new Status(IStatus.ERROR,
378                             IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
379                             IDEWorkbenchMessages.InternalError, e
380                                     .getTargetException()));
381         } catch (InterruptedException JavaDoc e) {
382             status.merge(new Status(IStatus.ERROR,
383                     IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
384                     IDEWorkbenchMessages.InternalError, e));
385         }
386         ErrorDialog.openError(null,
387                 IDEWorkbenchMessages.ProblemsSavingWorkspace, null, status,
388                 IStatus.ERROR | IStatus.WARNING);
389         if (!status.isOK()) {
390             IDEWorkbenchPlugin.log(
391                     IDEWorkbenchMessages.ProblemsSavingWorkspace, status);
392         }
393     }
394
395     /**
396      * Checks if the -newUpdates command line argument is present and if so,
397      * opens the update manager.
398      */

399     private void checkUpdates() {
400         boolean newUpdates = false;
401         String JavaDoc[] commandLineArgs = Platform.getCommandLineArgs();
402         for (int i = 0; i < commandLineArgs.length; i++) {
403             if (commandLineArgs[i].equalsIgnoreCase("-newUpdates")) { //$NON-NLS-1$
404
newUpdates = true;
405                 break;
406             }
407         }
408
409         if (newUpdates) {
410             try {
411                 SiteManager.handleNewChanges();
412             } catch (CoreException e) {
413                 IDEWorkbenchPlugin.log(
414                         "Problem opening update manager", e.getStatus()); //$NON-NLS-1$
415
}
416         }
417     }
418
419     /*
420      * (non-Javadoc)
421      *
422      * @see org.eclipse.ui.application.WorkbenchAdvisor#getDefaultPageInput
423      */

424     public IAdaptable getDefaultPageInput() {
425         return ResourcesPlugin.getWorkspace().getRoot();
426     }
427
428     /*
429      * (non-Javadoc)
430      *
431      * @see org.eclipse.ui.application.WorkbenchAdvisor
432      */

433     public String JavaDoc getInitialWindowPerspectiveId() {
434         int index = PlatformUI.getWorkbench().getWorkbenchWindowCount() - 1;
435
436         String JavaDoc perspectiveId = null;
437         AboutInfo[] welcomeInfos = getWelcomePerspectiveInfos();
438         if (index >= 0 && welcomeInfos != null && index < welcomeInfos.length) {
439             perspectiveId = welcomeInfos[index].getWelcomePerspectiveId();
440         }
441         if (perspectiveId == null) {
442             perspectiveId = IDE.RESOURCE_PERSPECTIVE_ID;
443         }
444         return perspectiveId;
445     }
446
447     /**
448      * Returns the map of versioned feature ids -> info object for all installed
449      * features. The format of the versioned feature id (the key of the map) is
450      * featureId + ":" + versionId.
451      *
452      * @return map of versioned feature ids -> info object (key type:
453      * <code>String</code>, value type: <code>AboutInfo</code>)
454      * @since 3.0
455      */

456     private Map JavaDoc computeBundleGroupMap() {
457         // use tree map to get predicable order
458
Map JavaDoc ids = new TreeMap JavaDoc();
459
460         IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
461         for (int i = 0; i < providers.length; ++i) {
462             IBundleGroup[] groups = providers[i].getBundleGroups();
463             for (int j = 0; j < groups.length; ++j) {
464                 IBundleGroup group = groups[j];
465                 AboutInfo info = new AboutInfo(group);
466
467                 String JavaDoc version = info.getVersionId();
468                 version = version == null ? "0.0.0" //$NON-NLS-1$
469
: new PluginVersionIdentifier(version).toString();
470                 String JavaDoc versionedFeature = group.getIdentifier() + ":" + version; //$NON-NLS-1$
471

472                 ids.put(versionedFeature, info);
473             }
474         }
475
476         return ids;
477     }
478
479     /**
480      * Returns the ordered map of versioned feature ids -> AboutInfo that are
481      * new for this session.
482      *
483      * @return ordered map of versioned feature ids (key type:
484      * <code>String</code>) -> infos (value type:
485      * <code>AboutInfo</code>).
486      */

487     public Map JavaDoc getNewlyAddedBundleGroups() {
488         if (newlyAddedBundleGroups == null) {
489             newlyAddedBundleGroups = createNewBundleGroupsMap();
490         }
491         return newlyAddedBundleGroups;
492     }
493
494     /**
495      * Updates the old features setting and returns a map of new features.
496      */

497     private Map JavaDoc createNewBundleGroupsMap() {
498         // retrieve list of installed bundle groups from last session
499
IDialogSettings settings = IDEWorkbenchPlugin.getDefault()
500                 .getDialogSettings();
501         String JavaDoc[] previousFeaturesArray = settings.getArray(INSTALLED_FEATURES);
502
503         // get a map of currently installed bundle groups and store it for next
504
// session
505
Map JavaDoc bundleGroups = computeBundleGroupMap();
506         String JavaDoc[] currentFeaturesArray = new String JavaDoc[bundleGroups.size()];
507         bundleGroups.keySet().toArray(currentFeaturesArray);
508         settings.put(INSTALLED_FEATURES, currentFeaturesArray);
509
510         // remove the previously known from the current set
511
if (previousFeaturesArray != null) {
512             for (int i = 0; i < previousFeaturesArray.length; ++i) {
513                 bundleGroups.remove(previousFeaturesArray[i]);
514             }
515         }
516
517         return bundleGroups;
518     }
519
520     /**
521      * Declares all IDE-specific workbench images. This includes both "shared"
522      * images (named in {@link IDE.SharedImages}) and internal images (named in
523      * {@link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}).
524      *
525      * @see IWorkbenchConfigurer#declareImage
526      */

527     private void declareWorkbenchImages() {
528
529         final String JavaDoc ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
530
final String JavaDoc PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; // Enabled toolbar icons.//$NON-NLS-1$
531
final String JavaDoc PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; // Disabled toolbar icons.//$NON-NLS-1$
532
final String JavaDoc PATH_ETOOL = ICONS_PATH + "etool16/"; // Enabled toolbar icons.//$NON-NLS-1$
533
final String JavaDoc PATH_DTOOL = ICONS_PATH + "dtool16/"; // Disabled toolbar icons.//$NON-NLS-1$
534
final String JavaDoc PATH_OBJECT = ICONS_PATH + "obj16/"; // Model object icons//$NON-NLS-1$
535
final String JavaDoc PATH_WIZBAN = ICONS_PATH + "wizban/"; // Wizard icons//$NON-NLS-1$
536

537         Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
538
539         declareWorkbenchImage(ideBundle,
540                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, PATH_ETOOL
541                         + "build_exec.gif", false); //$NON-NLS-1$
542
declareWorkbenchImage(ideBundle,
543                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER,
544                 PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
545
declareWorkbenchImage(ideBundle,
546                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED,
547                 PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
548

549         declareWorkbenchImage(ideBundle,
550                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, PATH_ETOOL
551                         + "search_src.gif", false); //$NON-NLS-1$
552
declareWorkbenchImage(ideBundle,
553                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER,
554                 PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
555
declareWorkbenchImage(ideBundle,
556                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED,
557                 PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
558

559         declareWorkbenchImage(ideBundle,
560                 IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL
561                         + "next_nav.gif", false); //$NON-NLS-1$
562

563         declareWorkbenchImage(ideBundle,
564                 IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, PATH_ETOOL
565                         + "prev_nav.gif", false); //$NON-NLS-1$
566

567         declareWorkbenchImage(ideBundle,
568                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, PATH_WIZBAN
569                         + "newprj_wiz.png", false); //$NON-NLS-1$
570
declareWorkbenchImage(ideBundle,
571                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ,
572                 PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
573
declareWorkbenchImage(ideBundle,
574                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, PATH_WIZBAN
575                         + "newfile_wiz.png", false); //$NON-NLS-1$
576

577         declareWorkbenchImage(ideBundle,
578                 IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ,
579                 PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
580
declareWorkbenchImage(ideBundle,
581                 IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ,
582                 PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
583

584         declareWorkbenchImage(ideBundle,
585                 IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ,
586                 PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
587
declareWorkbenchImage(ideBundle,
588                 IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ,
589                 PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
590

591         declareWorkbenchImage(ideBundle,
592                 IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ,
593                 PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
594

595         declareWorkbenchImage(ideBundle,
596                 IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, PATH_WIZBAN
597                         + "saveas_wiz.png", false); //$NON-NLS-1$
598

599         declareWorkbenchImage(ideBundle,
600                 IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, PATH_WIZBAN
601                         + "quick_fix.png", false); //$NON-NLS-1$
602

603         declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT,
604                 PATH_OBJECT + "prj_obj.gif", true); //$NON-NLS-1$
605
declareWorkbenchImage(ideBundle,
606                 IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
607                         + "cprj_obj.gif", true); //$NON-NLS-1$
608
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER,
609                 PATH_ELOCALTOOL + "gotoobj_tsk.gif", true); //$NON-NLS-1$
610

611         declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED,
612                 PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
613

614         declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED,
615                 PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
616

617         // task objects
618
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_HPRIO_TSK,
619
// PATH_OBJECT+"hprio_tsk.gif");
620
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_MPRIO_TSK,
621
// PATH_OBJECT+"mprio_tsk.gif");
622
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
623
// PATH_OBJECT+"lprio_tsk.gif");
624

625         declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK,
626                 PATH_OBJECT + "taskmrk_tsk.gif", true); //$NON-NLS-1$
627
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK,
628                 PATH_OBJECT + "bkmrk_tsk.gif", true); //$NON-NLS-1$
629

630         declareWorkbenchImage(ideBundle,
631                 IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, PATH_OBJECT
632                         + "complete_tsk.gif", true); //$NON-NLS-1$
633
declareWorkbenchImage(ideBundle,
634                 IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, PATH_OBJECT
635                         + "incomplete_tsk.gif", true); //$NON-NLS-1$
636
declareWorkbenchImage(ideBundle,
637                 IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, PATH_OBJECT
638                         + "welcome_item.gif", true); //$NON-NLS-1$
639
declareWorkbenchImage(ideBundle,
640                 IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, PATH_OBJECT
641                         + "welcome_banner.gif", true); //$NON-NLS-1$
642
declareWorkbenchImage(ideBundle,
643                 IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, PATH_OBJECT
644                         + "error_tsk.gif", true); //$NON-NLS-1$
645
declareWorkbenchImage(ideBundle,
646                 IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, PATH_OBJECT
647                         + "warn_tsk.gif", true); //$NON-NLS-1$
648
declareWorkbenchImage(ideBundle,
649                 IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT
650                         + "info_tsk.gif", true); //$NON-NLS-1$
651

652         declareWorkbenchImage(ideBundle,
653                 IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, PATH_ELOCALTOOL
654                         + "flatLayout.gif", true); //$NON-NLS-1$
655
declareWorkbenchImage(ideBundle,
656                 IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT,
657                 PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
658
declareWorkbenchImage(ideBundle,
659                 IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY,
660                 PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
661
declareWorkbenchImage(ideBundle,
662                 IDEInternalWorkbenchImages.IMG_LCL_LINKTO_HELP, PATH_ELOCALTOOL
663                         + "linkto_help.gif", false); //$NON-NLS-1$
664

665         // synchronization indicator objects
666
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_WBET_STAT,
667
// PATH_OVERLAY+"wbet_stat.gif");
668
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_SBET_STAT,
669
// PATH_OVERLAY+"sbet_stat.gif");
670
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_CONFLICT_STAT,
671
// PATH_OVERLAY+"conflict_stat.gif");
672

673         // content locality indicator objects
674
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_NOTLOCAL_STAT,
675
// PATH_STAT+"notlocal_stat.gif");
676
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LOCAL_STAT,
677
// PATH_STAT+"local_stat.gif");
678
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_FILLLOCAL_STAT,
679
// PATH_STAT+"filllocal_stat.gif");
680
}
681
682     /**
683      * Declares an IDE-specific workbench image.
684      *
685      * @param symbolicName
686      * the symbolic name of the image
687      * @param path
688      * the path of the image file; this path is relative to the base
689      * of the IDE plug-in
690      * @param shared
691      * <code>true</code> if this is a shared image, and
692      * <code>false</code> if this is not a shared image
693      * @see IWorkbenchConfigurer#declareImage
694      */

695     private void declareWorkbenchImage(Bundle ideBundle, String JavaDoc symbolicName,
696             String JavaDoc path, boolean shared) {
697         URL JavaDoc url = Platform.find(ideBundle, new Path(path));
698         ImageDescriptor desc = ImageDescriptor.createFromURL(url);
699         getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
700     }
701
702     /*
703      * (non-Javadoc)
704      *
705      * @see org.eclipse.ui.application.WorkbenchAdvisor#getMainPreferencePageId
706      */

707     public String JavaDoc getMainPreferencePageId() {
708         // indicate that we want the Workench preference page to be prominent
709
return WORKBENCH_PREFERENCE_CATEGORY_ID;
710     }
711
712     /**
713      * @return the workspace location string, or <code>null</code> if the
714      * location is not being shown
715      */

716     public String JavaDoc getWorkspaceLocation() {
717         return workspaceLocation;
718     }
719
720     /**
721      * @return the welcome perspective infos, or <code>null</code> if none or
722      * if they should be ignored due to the new intro being present
723      */

724     public AboutInfo[] getWelcomePerspectiveInfos() {
725         if (welcomePerspectiveInfos == null) {
726             // support old welcome perspectives if intro plugin is not present
727
if (!hasIntro()) {
728                 Map JavaDoc m = getNewlyAddedBundleGroups();
729                 ArrayList JavaDoc list = new ArrayList JavaDoc(m.size());
730                 for (Iterator JavaDoc i = m.values().iterator(); i.hasNext();) {
731                     AboutInfo info = (AboutInfo) i.next();
732                     if (info != null && info.getWelcomePerspectiveId() != null
733                             && info.getWelcomePageURL() != null) {
734                         list.add(info);
735                     }
736                 }
737                 welcomePerspectiveInfos = new AboutInfo[list.size()];
738                 list.toArray(welcomePerspectiveInfos);
739             }
740         }
741         return welcomePerspectiveInfos;
742     }
743 }
744
Popular Tags