KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 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.application;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14 import java.net.URL JavaDoc;
15 import java.text.Collator JavaDoc;
16 import java.util.ArrayList JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import java.util.Map JavaDoc;
19 import java.util.TreeMap JavaDoc;
20
21 import org.eclipse.core.net.proxy.IProxyService;
22 import org.eclipse.core.resources.IContainer;
23 import org.eclipse.core.resources.IResource;
24 import org.eclipse.core.resources.ResourcesPlugin;
25 import org.eclipse.core.resources.WorkspaceJob;
26 import org.eclipse.core.runtime.CoreException;
27 import org.eclipse.core.runtime.FileLocator;
28 import org.eclipse.core.runtime.IAdaptable;
29 import org.eclipse.core.runtime.IBundleGroup;
30 import org.eclipse.core.runtime.IBundleGroupProvider;
31 import org.eclipse.core.runtime.IProgressMonitor;
32 import org.eclipse.core.runtime.IStatus;
33 import org.eclipse.core.runtime.MultiStatus;
34 import org.eclipse.core.runtime.Path;
35 import org.eclipse.core.runtime.Platform;
36 import org.eclipse.core.runtime.Status;
37 import org.eclipse.core.runtime.jobs.Job;
38 import org.eclipse.jface.dialogs.ErrorDialog;
39 import org.eclipse.jface.dialogs.IDialogSettings;
40 import org.eclipse.jface.dialogs.MessageDialog;
41 import org.eclipse.jface.dialogs.TrayDialog;
42 import org.eclipse.jface.operation.IRunnableWithProgress;
43 import org.eclipse.jface.preference.IPreferenceStore;
44 import org.eclipse.jface.resource.ImageDescriptor;
45 import org.eclipse.jface.util.Policy;
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.PluginActionBuilder;
58 import org.eclipse.ui.internal.Workbench;
59 import org.eclipse.ui.internal.ide.AboutInfo;
60 import org.eclipse.ui.internal.ide.IDEInternalPreferences;
61 import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
62 import org.eclipse.ui.internal.ide.IDESelectionConversionService;
63 import org.eclipse.ui.internal.ide.IDEWorkbenchActivityHelper;
64 import org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler;
65 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
66 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
67 import org.eclipse.ui.internal.ide.model.WorkbenchAdapterBuilder;
68 import org.eclipse.ui.internal.ide.undo.WorkspaceUndoMonitor;
69 import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog;
70 import org.eclipse.ui.progress.IProgressService;
71 import org.eclipse.ui.statushandlers.AbstractStatusHandler;
72 import org.eclipse.update.core.SiteManager;
73 import org.osgi.framework.Bundle;
74 import org.osgi.framework.ServiceReference;
75 import org.osgi.framework.Version;
76
77 /**
78  * IDE-specified workbench advisor which configures the workbench for use as an
79  * IDE.
80  * <p>
81  * Note: This class replaces <code>org.eclipse.ui.internal.Workbench</code>.
82  * </p>
83  *
84  * @since 3.0
85  */

86 public class IDEWorkbenchAdvisor extends WorkbenchAdvisor {
87
88     private static final String JavaDoc WORKBENCH_PREFERENCE_CATEGORY_ID = "org.eclipse.ui.preferencePages.Workbench"; //$NON-NLS-1$
89

90     /**
91      * The dialog setting key to access the known installed features since the
92      * last time the workbench was run.
93      */

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

96     private static IDEWorkbenchAdvisor workbenchAdvisor = null;
97
98     /**
99      * Contains the workspace location if the -showlocation command line
100      * argument is specified, or <code>null</code> if not specified.
101      */

102     private String JavaDoc workspaceLocation = null;
103
104     /**
105      * Ordered map of versioned feature ids -> info that are new for this
106      * session; <code>null</code> if uninitialized. Key type:
107      * <code>String</code>, Value type: <code>AboutInfo</code>.
108      */

109     private Map JavaDoc newlyAddedBundleGroups;
110
111     /**
112      * Array of <code>AboutInfo</code> for all new installed features that
113      * specify a welcome perspective.
114      */

115     private AboutInfo[] welcomePerspectiveInfos = null;
116
117     /**
118      * Helper for managing activites in response to workspace changes.
119      */

120     private IDEWorkbenchActivityHelper activityHelper = null;
121
122     /**
123      * Helper for managing work that is performed when the system is otherwise
124      * idle.
125      */

126     private IDEIdleHelper idleHelper;
127
128     private Listener settingsChangeListener;
129     
130     /**
131      * Support class for monitoring workspace changes and periodically
132      * validating the undo history
133      */

134     private WorkspaceUndoMonitor workspaceUndoMonitor;
135
136     /**
137      * The IDE workbench error handler.
138      */

139     private AbstractStatusHandler ideWorkbenchErrorHandler;
140
141     /**
142      * Creates a new workbench advisor instance.
143      */

144     public IDEWorkbenchAdvisor() {
145         super();
146         if (workbenchAdvisor != null) {
147             throw new IllegalStateException JavaDoc();
148         }
149         workbenchAdvisor = this;
150     }
151
152     /*
153      * (non-Javadoc)
154      *
155      * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize
156      */

157     public void initialize(IWorkbenchConfigurer configurer) {
158
159         PluginActionBuilder.setAllowIdeLogging(true);
160         
161         // make sure we always save and restore workspace state
162
configurer.setSaveAndRestore(true);
163
164         // register workspace adapters
165
WorkbenchAdapterBuilder.registerAdapters();
166
167         // get the command line arguments
168
String JavaDoc[] cmdLineArgs = Platform.getCommandLineArgs();
169
170         // include the workspace location in the title
171
// if the command line option -showlocation is specified
172
for (int i = 0; i < cmdLineArgs.length; i++) {
173             if ("-showlocation".equalsIgnoreCase(cmdLineArgs[i])) { //$NON-NLS-1$
174
String JavaDoc name = null;
175                 if (cmdLineArgs.length > i + 1) {
176                     name = cmdLineArgs[i + 1];
177                 }
178                 if (name != null && name.indexOf("-") == -1) { //$NON-NLS-1$
179
workspaceLocation = name;
180                 } else {
181                     workspaceLocation = Platform.getLocation().toOSString();
182                 }
183                 break;
184             }
185         }
186
187         // register shared images
188
declareWorkbenchImages();
189
190         // initialize the activity helper
191
activityHelper = IDEWorkbenchActivityHelper.getInstance();
192
193         // initialize idle handler
194
idleHelper = new IDEIdleHelper(configurer);
195         
196         // initialize the workspace undo monitor
197
workspaceUndoMonitor = WorkspaceUndoMonitor.getInstance();
198
199         // show Help button in JFace dialogs
200
TrayDialog.setDialogHelpAvailable(true);
201
202         Policy.setComparator(Collator.getInstance());
203     }
204
205     /*
206      * (non-Javadoc)
207      *
208      * @see org.eclipse.ui.application.WorkbenchAdvisor#preStartup()
209      */

210     public void preStartup() {
211
212         // Suspend background jobs while we startup
213
Platform.getJobManager().suspend();
214
215         // Register the build actions
216
IProgressService service = PlatformUI.getWorkbench()
217                 .getProgressService();
218         ImageDescriptor newImage = IDEInternalWorkbenchImages
219                 .getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC);
220         service.registerIconForFamily(newImage,
221                 ResourcesPlugin.FAMILY_MANUAL_BUILD);
222         service.registerIconForFamily(newImage,
223                 ResourcesPlugin.FAMILY_AUTO_BUILD);
224     }
225
226     /*
227      * (non-Javadoc)
228      *
229      * @see org.eclipse.ui.application.WorkbenchAdvisor#postStartup()
230      */

231     public void postStartup() {
232         try {
233             refreshFromLocal();
234             activateProxyService();
235             checkUpdates();
236             ((Workbench) PlatformUI.getWorkbench()).registerService(
237                     ISelectionConversionService.class,
238                     new IDESelectionConversionService());
239
240             initializeSettingsChangeListener();
241             Display.getCurrent().addListener(SWT.Settings,
242                     settingsChangeListener);
243         } finally {// Resume background jobs after we startup
244
Platform.getJobManager().resume();
245         }
246     }
247
248     /**
249      * Activate the proxy service by obtaining it.
250      */

251     private void activateProxyService() {
252         Bundle bundle = Platform.getBundle("org.eclipse.ui.ide"); //$NON-NLS-1$
253
Object JavaDoc proxyService = null;
254         if (bundle != null) {
255             ServiceReference ref = bundle.getBundleContext().getServiceReference(IProxyService.class.getName());
256             if (ref != null)
257                 proxyService = bundle.getBundleContext().getService(ref);
258         }
259         if (proxyService == null) {
260             IDEWorkbenchPlugin.log("Proxy service could not be found."); //$NON-NLS-1$
261
}
262     }
263
264     /**
265      * Initialize the listener for settings changes.
266      */

267     private void initializeSettingsChangeListener() {
268         settingsChangeListener = new Listener() {
269
270             boolean currentHighContrast = Display.getCurrent()
271                     .getHighContrast();
272
273             public void handleEvent(org.eclipse.swt.widgets.Event event) {
274                 if (Display.getCurrent().getHighContrast() == currentHighContrast)
275                     return;
276
277                 currentHighContrast = !currentHighContrast;
278
279                 // make sure they really want to do this
280
if (new MessageDialog(null,
281                         IDEWorkbenchMessages.SystemSettingsChange_title, null,
282                         IDEWorkbenchMessages.SystemSettingsChange_message,
283                         MessageDialog.QUESTION, new String JavaDoc[] {
284                                 IDEWorkbenchMessages.SystemSettingsChange_yes,
285                                 IDEWorkbenchMessages.SystemSettingsChange_no },
286                         1).open() == Window.OK) {
287                     PlatformUI.getWorkbench().restart();
288                 }
289             }
290         };
291
292     }
293
294     /*
295      * (non-Javadoc)
296      *
297      * @see org.eclipse.ui.application.WorkbenchAdvisor#postShutdown
298      */

299     public void postShutdown() {
300         if (activityHelper != null) {
301             activityHelper.shutdown();
302             activityHelper = null;
303         }
304         if (idleHelper != null) {
305             idleHelper.shutdown();
306             idleHelper = null;
307         }
308         if (workspaceUndoMonitor != null) {
309             workspaceUndoMonitor.shutdown();
310             workspaceUndoMonitor = null;
311         }
312         if (IDEWorkbenchPlugin.getPluginWorkspace() != null) {
313             disconnectFromWorkspace();
314         }
315     }
316
317     /*
318      * (non-Javadoc)
319      *
320      * @see org.eclipse.ui.application.WorkbenchAdvisor#preShutdown()
321      */

322     public boolean preShutdown() {
323         Display.getCurrent().removeListener(SWT.Settings,
324                 settingsChangeListener);
325         return super.preShutdown();
326     }
327
328     /*
329      * (non-Javadoc)
330      *
331      * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
332      */

333     public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
334             IWorkbenchWindowConfigurer configurer) {
335         return new IDEWorkbenchWindowAdvisor(this, configurer);
336     }
337
338     /**
339      * Return true if the intro plugin is present and false otherwise.
340      *
341      * @return boolean
342      */

343     public boolean hasIntro() {
344         return getWorkbenchConfigurer().getWorkbench().getIntroManager()
345                 .hasIntro();
346     }
347
348     private void refreshFromLocal() {
349         String JavaDoc[] commandLineArgs = Platform.getCommandLineArgs();
350         IPreferenceStore store = IDEWorkbenchPlugin.getDefault()
351                 .getPreferenceStore();
352         boolean refresh = store
353                 .getBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP);
354         if (!refresh) {
355             return;
356         }
357
358         // Do not refresh if it was already done by core on startup.
359
for (int i = 0; i < commandLineArgs.length; i++) {
360             if (commandLineArgs[i].equalsIgnoreCase("-refresh")) { //$NON-NLS-1$
361
return;
362             }
363         }
364
365         final IContainer root = ResourcesPlugin.getWorkspace().getRoot();
366         Job job = new WorkspaceJob(IDEWorkbenchMessages.Workspace_refreshing) {
367             public IStatus runInWorkspace(IProgressMonitor monitor)
368                     throws CoreException {
369                 root.refreshLocal(IResource.DEPTH_INFINITE, monitor);
370                 return Status.OK_STATUS;
371             }
372         };
373         job.setRule(root);
374         job.schedule();
375     }
376
377     /**
378      * Disconnect from the core workspace.
379      */

380     private void disconnectFromWorkspace() {
381         // save the workspace
382
final MultiStatus status = new MultiStatus(
383                 IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
384                 IDEWorkbenchMessages.ProblemSavingWorkbench, null);
385         IRunnableWithProgress runnable = new IRunnableWithProgress() {
386             public void run(IProgressMonitor monitor) {
387                 try {
388                     status.merge(ResourcesPlugin.getWorkspace().save(true,
389                             monitor));
390                 } catch (CoreException e) {
391                     status.merge(e.getStatus());
392                 }
393             }
394         };
395         try {
396             new ProgressMonitorJobsDialog(null).run(true, false, runnable);
397         } catch (InvocationTargetException JavaDoc e) {
398             status
399                     .merge(new Status(IStatus.ERROR,
400                             IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
401                             IDEWorkbenchMessages.InternalError, e
402                                     .getTargetException()));
403         } catch (InterruptedException JavaDoc e) {
404             status.merge(new Status(IStatus.ERROR,
405                     IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
406                     IDEWorkbenchMessages.InternalError, e));
407         }
408         ErrorDialog.openError(null,
409                 IDEWorkbenchMessages.ProblemsSavingWorkspace, null, status,
410                 IStatus.ERROR | IStatus.WARNING);
411         if (!status.isOK()) {
412             IDEWorkbenchPlugin.log(
413                     IDEWorkbenchMessages.ProblemsSavingWorkspace, status);
414         }
415     }
416
417     /**
418      * Checks if the -newUpdates command line argument is present and if so,
419      * opens the update manager.
420      */

421     private void checkUpdates() {
422         boolean newUpdates = false;
423         String JavaDoc[] commandLineArgs = Platform.getCommandLineArgs();
424         for (int i = 0; i < commandLineArgs.length; i++) {
425             if (commandLineArgs[i].equalsIgnoreCase("-newUpdates")) { //$NON-NLS-1$
426
newUpdates = true;
427                 break;
428             }
429         }
430
431         if (newUpdates) {
432             try {
433                 SiteManager.handleNewChanges();
434             } catch (CoreException e) {
435                 IDEWorkbenchPlugin.log(
436                         "Problem opening update manager", e.getStatus()); //$NON-NLS-1$
437
}
438         }
439     }
440
441     /*
442      * (non-Javadoc)
443      *
444      * @see org.eclipse.ui.application.WorkbenchAdvisor#getDefaultPageInput
445      */

446     public IAdaptable getDefaultPageInput() {
447         return ResourcesPlugin.getWorkspace().getRoot();
448     }
449
450     /*
451      * (non-Javadoc)
452      *
453      * @see org.eclipse.ui.application.WorkbenchAdvisor
454      */

455     public String JavaDoc getInitialWindowPerspectiveId() {
456         int index = PlatformUI.getWorkbench().getWorkbenchWindowCount() - 1;
457
458         String JavaDoc perspectiveId = null;
459         AboutInfo[] welcomeInfos = getWelcomePerspectiveInfos();
460         if (index >= 0 && welcomeInfos != null && index < welcomeInfos.length) {
461             perspectiveId = welcomeInfos[index].getWelcomePerspectiveId();
462         }
463         if (perspectiveId == null) {
464             perspectiveId = IDE.RESOURCE_PERSPECTIVE_ID;
465         }
466         return perspectiveId;
467     }
468
469     /**
470      * Returns the map of versioned feature ids -> info object for all installed
471      * features. The format of the versioned feature id (the key of the map) is
472      * featureId + ":" + versionId.
473      *
474      * @return map of versioned feature ids -> info object (key type:
475      * <code>String</code>, value type: <code>AboutInfo</code>)
476      * @since 3.0
477      */

478     private Map JavaDoc computeBundleGroupMap() {
479         // use tree map to get predicable order
480
Map JavaDoc ids = new TreeMap JavaDoc();
481
482         IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
483         for (int i = 0; i < providers.length; ++i) {
484             IBundleGroup[] groups = providers[i].getBundleGroups();
485             for (int j = 0; j < groups.length; ++j) {
486                 IBundleGroup group = groups[j];
487                 AboutInfo info = new AboutInfo(group);
488
489                 String JavaDoc version = info.getVersionId();
490                 version = version == null ? "0.0.0" //$NON-NLS-1$
491
: new Version(version).toString();
492                 String JavaDoc versionedFeature = group.getIdentifier() + ":" + version; //$NON-NLS-1$
493

494                 ids.put(versionedFeature, info);
495             }
496         }
497
498         return ids;
499     }
500
501     /**
502      * Returns the ordered map of versioned feature ids -> AboutInfo that are
503      * new for this session.
504      *
505      * @return ordered map of versioned feature ids (key type:
506      * <code>String</code>) -> infos (value type:
507      * <code>AboutInfo</code>).
508      */

509     public Map JavaDoc getNewlyAddedBundleGroups() {
510         if (newlyAddedBundleGroups == null) {
511             newlyAddedBundleGroups = createNewBundleGroupsMap();
512         }
513         return newlyAddedBundleGroups;
514     }
515
516     /**
517      * Updates the old features setting and returns a map of new features.
518      */

519     private Map JavaDoc createNewBundleGroupsMap() {
520         // retrieve list of installed bundle groups from last session
521
IDialogSettings settings = IDEWorkbenchPlugin.getDefault()
522                 .getDialogSettings();
523         String JavaDoc[] previousFeaturesArray = settings.getArray(INSTALLED_FEATURES);
524
525         // get a map of currently installed bundle groups and store it for next
526
// session
527
Map JavaDoc bundleGroups = computeBundleGroupMap();
528         String JavaDoc[] currentFeaturesArray = new String JavaDoc[bundleGroups.size()];
529         bundleGroups.keySet().toArray(currentFeaturesArray);
530         settings.put(INSTALLED_FEATURES, currentFeaturesArray);
531
532         // remove the previously known from the current set
533
if (previousFeaturesArray != null) {
534             for (int i = 0; i < previousFeaturesArray.length; ++i) {
535                 bundleGroups.remove(previousFeaturesArray[i]);
536             }
537         }
538
539         return bundleGroups;
540     }
541
542     /**
543      * Declares all IDE-specific workbench images. This includes both "shared"
544      * images (named in {@link IDE.SharedImages}) and internal images (named in
545      * {@link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}).
546      *
547      * @see IWorkbenchConfigurer#declareImage
548      */

549     private void declareWorkbenchImages() {
550
551         final String JavaDoc ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
552
final String JavaDoc PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; // Enabled //$NON-NLS-1$
553

554         // toolbar
555
// icons.
556
final String JavaDoc PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; // Disabled //$NON-NLS-1$
557
// //$NON-NLS-1$
558
// toolbar
559
// icons.
560
final String JavaDoc PATH_ETOOL = ICONS_PATH + "etool16/"; // Enabled toolbar //$NON-NLS-1$
561
// //$NON-NLS-1$
562
// icons.
563
final String JavaDoc PATH_DTOOL = ICONS_PATH + "dtool16/"; // Disabled toolbar //$NON-NLS-1$
564
// //$NON-NLS-1$
565
// icons.
566
final String JavaDoc PATH_OBJECT = ICONS_PATH + "obj16/"; // Model object //$NON-NLS-1$
567
// //$NON-NLS-1$
568
// icons
569
final String JavaDoc PATH_WIZBAN = ICONS_PATH + "wizban/"; // Wizard //$NON-NLS-1$
570
// //$NON-NLS-1$
571
// icons
572

573         Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
574
575         declareWorkbenchImage(ideBundle,
576                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, PATH_ETOOL
577                         + "build_exec.gif", false); //$NON-NLS-1$
578
declareWorkbenchImage(ideBundle,
579                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER,
580                 PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
581
declareWorkbenchImage(ideBundle,
582                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED,
583                 PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
584

585         declareWorkbenchImage(ideBundle,
586                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, PATH_ETOOL
587                         + "search_src.gif", false); //$NON-NLS-1$
588
declareWorkbenchImage(ideBundle,
589                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER,
590                 PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
591
declareWorkbenchImage(ideBundle,
592                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED,
593                 PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
594

595         declareWorkbenchImage(ideBundle,
596                 IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL
597                         + "next_nav.gif", false); //$NON-NLS-1$
598

599         declareWorkbenchImage(ideBundle,
600                 IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, PATH_ETOOL
601                         + "prev_nav.gif", false); //$NON-NLS-1$
602

603         declareWorkbenchImage(ideBundle,
604                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, PATH_WIZBAN
605                         + "newprj_wiz.png", false); //$NON-NLS-1$
606
declareWorkbenchImage(ideBundle,
607                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ,
608                 PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
609
declareWorkbenchImage(ideBundle,
610                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, PATH_WIZBAN
611                         + "newfile_wiz.png", false); //$NON-NLS-1$
612

613         declareWorkbenchImage(ideBundle,
614                 IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ,
615                 PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
616
declareWorkbenchImage(ideBundle,
617                 IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ,
618                 PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
619

620         declareWorkbenchImage(ideBundle,
621                 IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ,
622                 PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
623
declareWorkbenchImage(ideBundle,
624                 IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ,
625                 PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
626

627         declareWorkbenchImage(ideBundle,
628                 IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ,
629                 PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
630

631         declareWorkbenchImage(ideBundle,
632                 IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, PATH_WIZBAN
633                         + "saveas_wiz.png", false); //$NON-NLS-1$
634

635         declareWorkbenchImage(ideBundle,
636                 IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, PATH_WIZBAN
637                         + "quick_fix.png", false); //$NON-NLS-1$
638

639         declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT,
640                 PATH_OBJECT + "prj_obj.gif", true); //$NON-NLS-1$
641
declareWorkbenchImage(ideBundle,
642                 IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
643                         + "cprj_obj.gif", true); //$NON-NLS-1$
644
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER,
645                 PATH_ELOCALTOOL + "gotoobj_tsk.gif", true); //$NON-NLS-1$
646

647         declareWorkbenchImage(ideBundle,
648                 IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED,
649                 PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
650

651         declareWorkbenchImage(ideBundle,
652                 IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED,
653                 PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
654

655         // task objects
656
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_HPRIO_TSK,
657
// PATH_OBJECT+"hprio_tsk.gif");
658
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_MPRIO_TSK,
659
// PATH_OBJECT+"mprio_tsk.gif");
660
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
661
// PATH_OBJECT+"lprio_tsk.gif");
662

663         declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK,
664                 PATH_OBJECT + "taskmrk_tsk.gif", true); //$NON-NLS-1$
665
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK,
666                 PATH_OBJECT + "bkmrk_tsk.gif", true); //$NON-NLS-1$
667

668         declareWorkbenchImage(ideBundle,
669                 IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, PATH_OBJECT
670                         + "complete_tsk.gif", true); //$NON-NLS-1$
671
declareWorkbenchImage(ideBundle,
672                 IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, PATH_OBJECT
673                         + "incomplete_tsk.gif", true); //$NON-NLS-1$
674
declareWorkbenchImage(ideBundle,
675                 IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, PATH_OBJECT
676                         + "welcome_item.gif", true); //$NON-NLS-1$
677
declareWorkbenchImage(ideBundle,
678                 IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, PATH_OBJECT
679                         + "welcome_banner.gif", true); //$NON-NLS-1$
680
declareWorkbenchImage(ideBundle,
681                 IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, PATH_OBJECT
682                         + "error_tsk.gif", true); //$NON-NLS-1$
683
declareWorkbenchImage(ideBundle,
684                 IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, PATH_OBJECT
685                         + "warn_tsk.gif", true); //$NON-NLS-1$
686
declareWorkbenchImage(ideBundle,
687                 IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT
688                         + "info_tsk.gif", true); //$NON-NLS-1$
689

690         declareWorkbenchImage(ideBundle,
691                 IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, PATH_ELOCALTOOL
692                         + "flatLayout.gif", true); //$NON-NLS-1$
693
declareWorkbenchImage(ideBundle,
694                 IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT,
695                 PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
696
declareWorkbenchImage(ideBundle,
697                 IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY,
698                 PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
699

700         // synchronization indicator objects
701
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_WBET_STAT,
702
// PATH_OVERLAY+"wbet_stat.gif");
703
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_SBET_STAT,
704
// PATH_OVERLAY+"sbet_stat.gif");
705
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_CONFLICT_STAT,
706
// PATH_OVERLAY+"conflict_stat.gif");
707

708         // content locality indicator objects
709
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_NOTLOCAL_STAT,
710
// PATH_STAT+"notlocal_stat.gif");
711
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LOCAL_STAT,
712
// PATH_STAT+"local_stat.gif");
713
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_FILLLOCAL_STAT,
714
// PATH_STAT+"filllocal_stat.gif");
715
}
716
717     /**
718      * Declares an IDE-specific workbench image.
719      *
720      * @param symbolicName
721      * the symbolic name of the image
722      * @param path
723      * the path of the image file; this path is relative to the base
724      * of the IDE plug-in
725      * @param shared
726      * <code>true</code> if this is a shared image, and
727      * <code>false</code> if this is not a shared image
728      * @see IWorkbenchConfigurer#declareImage
729      */

730     private void declareWorkbenchImage(Bundle ideBundle, String JavaDoc symbolicName,
731             String JavaDoc path, boolean shared) {
732         URL JavaDoc url = FileLocator.find(ideBundle, new Path(path), null);
733         ImageDescriptor desc = ImageDescriptor.createFromURL(url);
734         getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
735     }
736
737     /*
738      * (non-Javadoc)
739      *
740      * @see org.eclipse.ui.application.WorkbenchAdvisor#getMainPreferencePageId
741      */

742     public String JavaDoc getMainPreferencePageId() {
743         // indicate that we want the Workench preference page to be prominent
744
return WORKBENCH_PREFERENCE_CATEGORY_ID;
745     }
746
747     /**
748      * @return the workspace location string, or <code>null</code> if the
749      * location is not being shown
750      */

751     public String JavaDoc getWorkspaceLocation() {
752         return workspaceLocation;
753     }
754
755     /**
756      * @return the welcome perspective infos, or <code>null</code> if none or
757      * if they should be ignored due to the new intro being present
758      */

759     public AboutInfo[] getWelcomePerspectiveInfos() {
760         if (welcomePerspectiveInfos == null) {
761             // support old welcome perspectives if intro plugin is not present
762
if (!hasIntro()) {
763                 Map JavaDoc m = getNewlyAddedBundleGroups();
764                 ArrayList JavaDoc list = new ArrayList JavaDoc(m.size());
765                 for (Iterator JavaDoc i = m.values().iterator(); i.hasNext();) {
766                     AboutInfo info = (AboutInfo) i.next();
767                     if (info != null && info.getWelcomePerspectiveId() != null
768                             && info.getWelcomePageURL() != null) {
769                         list.add(info);
770                     }
771                 }
772                 welcomePerspectiveInfos = new AboutInfo[list.size()];
773                 list.toArray(welcomePerspectiveInfos);
774             }
775         }
776         return welcomePerspectiveInfos;
777     }
778
779     /*
780      * (non-Javadoc)
781      *
782      * @see org.eclipse.ui.application.WorkbenchAdvisor#getWorkbenchErrorHandler()
783      */

784     public AbstractStatusHandler getWorkbenchErrorHandler() {
785         if (ideWorkbenchErrorHandler == null) {
786             ideWorkbenchErrorHandler = new IDEWorkbenchErrorHandler(
787                     getWorkbenchConfigurer());
788         }
789         return ideWorkbenchErrorHandler;
790     }
791 }
792
Popular Tags