Source Code Cross Referenced for IDEWorkbenchAdvisor.java in  » IDE-Eclipse » ui-ide » org » eclipse » ui » internal » ide » application » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui ide » org.eclipse.ui.internal.ide.application 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.ide.application;
011:
012:        import java.lang.reflect.InvocationTargetException;
013:        import java.net.URL;
014:        import java.text.Collator;
015:        import java.util.ArrayList;
016:        import java.util.Iterator;
017:        import java.util.Map;
018:        import java.util.TreeMap;
019:
020:        import org.eclipse.core.net.proxy.IProxyService;
021:        import org.eclipse.core.resources.IContainer;
022:        import org.eclipse.core.resources.IResource;
023:        import org.eclipse.core.resources.ResourcesPlugin;
024:        import org.eclipse.core.resources.WorkspaceJob;
025:        import org.eclipse.core.runtime.CoreException;
026:        import org.eclipse.core.runtime.FileLocator;
027:        import org.eclipse.core.runtime.IAdaptable;
028:        import org.eclipse.core.runtime.IBundleGroup;
029:        import org.eclipse.core.runtime.IBundleGroupProvider;
030:        import org.eclipse.core.runtime.IProgressMonitor;
031:        import org.eclipse.core.runtime.IStatus;
032:        import org.eclipse.core.runtime.MultiStatus;
033:        import org.eclipse.core.runtime.Path;
034:        import org.eclipse.core.runtime.Platform;
035:        import org.eclipse.core.runtime.Status;
036:        import org.eclipse.core.runtime.jobs.Job;
037:        import org.eclipse.jface.dialogs.ErrorDialog;
038:        import org.eclipse.jface.dialogs.IDialogSettings;
039:        import org.eclipse.jface.dialogs.MessageDialog;
040:        import org.eclipse.jface.dialogs.TrayDialog;
041:        import org.eclipse.jface.operation.IRunnableWithProgress;
042:        import org.eclipse.jface.preference.IPreferenceStore;
043:        import org.eclipse.jface.resource.ImageDescriptor;
044:        import org.eclipse.jface.util.Policy;
045:        import org.eclipse.jface.window.Window;
046:        import org.eclipse.swt.SWT;
047:        import org.eclipse.swt.widgets.Display;
048:        import org.eclipse.swt.widgets.Listener;
049:        import org.eclipse.ui.PlatformUI;
050:        import org.eclipse.ui.application.IWorkbenchConfigurer;
051:        import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
052:        import org.eclipse.ui.application.WorkbenchAdvisor;
053:        import org.eclipse.ui.application.WorkbenchWindowAdvisor;
054:        import org.eclipse.ui.ide.IDE;
055:        import org.eclipse.ui.internal.ISelectionConversionService;
056:        import org.eclipse.ui.internal.PluginActionBuilder;
057:        import org.eclipse.ui.internal.Workbench;
058:        import org.eclipse.ui.internal.ide.AboutInfo;
059:        import org.eclipse.ui.internal.ide.IDEInternalPreferences;
060:        import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
061:        import org.eclipse.ui.internal.ide.IDESelectionConversionService;
062:        import org.eclipse.ui.internal.ide.IDEWorkbenchActivityHelper;
063:        import org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler;
064:        import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
065:        import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
066:        import org.eclipse.ui.internal.ide.model.WorkbenchAdapterBuilder;
067:        import org.eclipse.ui.internal.ide.undo.WorkspaceUndoMonitor;
068:        import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog;
069:        import org.eclipse.ui.progress.IProgressService;
070:        import org.eclipse.ui.statushandlers.AbstractStatusHandler;
071:        import org.eclipse.update.core.SiteManager;
072:        import org.osgi.framework.Bundle;
073:        import org.osgi.framework.ServiceReference;
074:        import org.osgi.framework.Version;
075:
076:        /**
077:         * IDE-specified workbench advisor which configures the workbench for use as an
078:         * IDE.
079:         * <p>
080:         * Note: This class replaces <code>org.eclipse.ui.internal.Workbench</code>.
081:         * </p>
082:         * 
083:         * @since 3.0
084:         */
085:        public class IDEWorkbenchAdvisor extends WorkbenchAdvisor {
086:
087:            private static final String WORKBENCH_PREFERENCE_CATEGORY_ID = "org.eclipse.ui.preferencePages.Workbench"; //$NON-NLS-1$
088:
089:            /**
090:             * The dialog setting key to access the known installed features since the
091:             * last time the workbench was run.
092:             */
093:            private static final String INSTALLED_FEATURES = "installedFeatures"; //$NON-NLS-1$
094:
095:            private static IDEWorkbenchAdvisor workbenchAdvisor = null;
096:
097:            /**
098:             * Contains the workspace location if the -showlocation command line
099:             * argument is specified, or <code>null</code> if not specified.
100:             */
101:            private String workspaceLocation = null;
102:
103:            /**
104:             * Ordered map of versioned feature ids -> info that are new for this
105:             * session; <code>null</code> if uninitialized. Key type:
106:             * <code>String</code>, Value type: <code>AboutInfo</code>.
107:             */
108:            private Map newlyAddedBundleGroups;
109:
110:            /**
111:             * Array of <code>AboutInfo</code> for all new installed features that
112:             * specify a welcome perspective.
113:             */
114:            private AboutInfo[] welcomePerspectiveInfos = null;
115:
116:            /**
117:             * Helper for managing activites in response to workspace changes.
118:             */
119:            private IDEWorkbenchActivityHelper activityHelper = null;
120:
121:            /**
122:             * Helper for managing work that is performed when the system is otherwise
123:             * idle.
124:             */
125:            private IDEIdleHelper idleHelper;
126:
127:            private Listener settingsChangeListener;
128:
129:            /**
130:             * Support class for monitoring workspace changes and periodically
131:             * validating the undo history
132:             */
133:            private WorkspaceUndoMonitor workspaceUndoMonitor;
134:
135:            /**
136:             * The IDE workbench error handler.
137:             */
138:            private AbstractStatusHandler ideWorkbenchErrorHandler;
139:
140:            /**
141:             * Creates a new workbench advisor instance.
142:             */
143:            public IDEWorkbenchAdvisor() {
144:                super ();
145:                if (workbenchAdvisor != null) {
146:                    throw new IllegalStateException();
147:                }
148:                workbenchAdvisor = this ;
149:            }
150:
151:            /*
152:             * (non-Javadoc)
153:             * 
154:             * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize
155:             */
156:            public void initialize(IWorkbenchConfigurer configurer) {
157:
158:                PluginActionBuilder.setAllowIdeLogging(true);
159:
160:                // make sure we always save and restore workspace state
161:                configurer.setSaveAndRestore(true);
162:
163:                // register workspace adapters
164:                WorkbenchAdapterBuilder.registerAdapters();
165:
166:                // get the command line arguments
167:                String[] cmdLineArgs = Platform.getCommandLineArgs();
168:
169:                // include the workspace location in the title
170:                // if the command line option -showlocation is specified
171:                for (int i = 0; i < cmdLineArgs.length; i++) {
172:                    if ("-showlocation".equalsIgnoreCase(cmdLineArgs[i])) { //$NON-NLS-1$
173:                        String name = null;
174:                        if (cmdLineArgs.length > i + 1) {
175:                            name = cmdLineArgs[i + 1];
176:                        }
177:                        if (name != null && name.indexOf("-") == -1) { //$NON-NLS-1$
178:                            workspaceLocation = name;
179:                        } else {
180:                            workspaceLocation = Platform.getLocation()
181:                                    .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 proxyService = null;
254:                if (bundle != null) {
255:                    ServiceReference ref = bundle.getBundleContext()
256:                            .getServiceReference(IProxyService.class.getName());
257:                    if (ref != null)
258:                        proxyService = bundle.getBundleContext()
259:                                .getService(ref);
260:                }
261:                if (proxyService == null) {
262:                    IDEWorkbenchPlugin.log("Proxy service could not be found."); //$NON-NLS-1$
263:                }
264:            }
265:
266:            /**
267:             * Initialize the listener for settings changes.
268:             */
269:            private void initializeSettingsChangeListener() {
270:                settingsChangeListener = new Listener() {
271:
272:                    boolean currentHighContrast = Display.getCurrent()
273:                            .getHighContrast();
274:
275:                    public void handleEvent(org.eclipse.swt.widgets.Event event) {
276:                        if (Display.getCurrent().getHighContrast() == currentHighContrast)
277:                            return;
278:
279:                        currentHighContrast = !currentHighContrast;
280:
281:                        // make sure they really want to do this
282:                        if (new MessageDialog(
283:                                null,
284:                                IDEWorkbenchMessages.SystemSettingsChange_title,
285:                                null,
286:                                IDEWorkbenchMessages.SystemSettingsChange_message,
287:                                MessageDialog.QUESTION,
288:                                new String[] {
289:                                        IDEWorkbenchMessages.SystemSettingsChange_yes,
290:                                        IDEWorkbenchMessages.SystemSettingsChange_no },
291:                                1).open() == Window.OK) {
292:                            PlatformUI.getWorkbench().restart();
293:                        }
294:                    }
295:                };
296:
297:            }
298:
299:            /*
300:             * (non-Javadoc)
301:             * 
302:             * @see org.eclipse.ui.application.WorkbenchAdvisor#postShutdown
303:             */
304:            public void postShutdown() {
305:                if (activityHelper != null) {
306:                    activityHelper.shutdown();
307:                    activityHelper = null;
308:                }
309:                if (idleHelper != null) {
310:                    idleHelper.shutdown();
311:                    idleHelper = null;
312:                }
313:                if (workspaceUndoMonitor != null) {
314:                    workspaceUndoMonitor.shutdown();
315:                    workspaceUndoMonitor = null;
316:                }
317:                if (IDEWorkbenchPlugin.getPluginWorkspace() != null) {
318:                    disconnectFromWorkspace();
319:                }
320:            }
321:
322:            /*
323:             * (non-Javadoc)
324:             * 
325:             * @see org.eclipse.ui.application.WorkbenchAdvisor#preShutdown()
326:             */
327:            public boolean preShutdown() {
328:                Display.getCurrent().removeListener(SWT.Settings,
329:                        settingsChangeListener);
330:                return super .preShutdown();
331:            }
332:
333:            /*
334:             * (non-Javadoc)
335:             * 
336:             * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
337:             */
338:            public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
339:                    IWorkbenchWindowConfigurer configurer) {
340:                return new IDEWorkbenchWindowAdvisor(this , configurer);
341:            }
342:
343:            /**
344:             * Return true if the intro plugin is present and false otherwise.
345:             * 
346:             * @return boolean
347:             */
348:            public boolean hasIntro() {
349:                return getWorkbenchConfigurer().getWorkbench()
350:                        .getIntroManager().hasIntro();
351:            }
352:
353:            private void refreshFromLocal() {
354:                String[] commandLineArgs = Platform.getCommandLineArgs();
355:                IPreferenceStore store = IDEWorkbenchPlugin.getDefault()
356:                        .getPreferenceStore();
357:                boolean refresh = store
358:                        .getBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP);
359:                if (!refresh) {
360:                    return;
361:                }
362:
363:                // Do not refresh if it was already done by core on startup.
364:                for (int i = 0; i < commandLineArgs.length; i++) {
365:                    if (commandLineArgs[i].equalsIgnoreCase("-refresh")) { //$NON-NLS-1$
366:                        return;
367:                    }
368:                }
369:
370:                final IContainer root = ResourcesPlugin.getWorkspace()
371:                        .getRoot();
372:                Job job = new WorkspaceJob(
373:                        IDEWorkbenchMessages.Workspace_refreshing) {
374:                    public IStatus runInWorkspace(IProgressMonitor monitor)
375:                            throws CoreException {
376:                        root.refreshLocal(IResource.DEPTH_INFINITE, monitor);
377:                        return Status.OK_STATUS;
378:                    }
379:                };
380:                job.setRule(root);
381:                job.schedule();
382:            }
383:
384:            /**
385:             * Disconnect from the core workspace.
386:             */
387:            private void disconnectFromWorkspace() {
388:                // save the workspace
389:                final MultiStatus status = new MultiStatus(
390:                        IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
391:                        IDEWorkbenchMessages.ProblemSavingWorkbench, null);
392:                IRunnableWithProgress runnable = new IRunnableWithProgress() {
393:                    public void run(IProgressMonitor monitor) {
394:                        try {
395:                            status.merge(ResourcesPlugin.getWorkspace().save(
396:                                    true, monitor));
397:                        } catch (CoreException e) {
398:                            status.merge(e.getStatus());
399:                        }
400:                    }
401:                };
402:                try {
403:                    new ProgressMonitorJobsDialog(null).run(true, false,
404:                            runnable);
405:                } catch (InvocationTargetException e) {
406:                    status.merge(new Status(IStatus.ERROR,
407:                            IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
408:                            IDEWorkbenchMessages.InternalError, e
409:                                    .getTargetException()));
410:                } catch (InterruptedException e) {
411:                    status.merge(new Status(IStatus.ERROR,
412:                            IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
413:                            IDEWorkbenchMessages.InternalError, e));
414:                }
415:                ErrorDialog.openError(null,
416:                        IDEWorkbenchMessages.ProblemsSavingWorkspace, null,
417:                        status, IStatus.ERROR | IStatus.WARNING);
418:                if (!status.isOK()) {
419:                    IDEWorkbenchPlugin.log(
420:                            IDEWorkbenchMessages.ProblemsSavingWorkspace,
421:                            status);
422:                }
423:            }
424:
425:            /**
426:             * Checks if the -newUpdates command line argument is present and if so,
427:             * opens the update manager.
428:             */
429:            private void checkUpdates() {
430:                boolean newUpdates = false;
431:                String[] commandLineArgs = Platform.getCommandLineArgs();
432:                for (int i = 0; i < commandLineArgs.length; i++) {
433:                    if (commandLineArgs[i].equalsIgnoreCase("-newUpdates")) { //$NON-NLS-1$
434:                        newUpdates = true;
435:                        break;
436:                    }
437:                }
438:
439:                if (newUpdates) {
440:                    try {
441:                        SiteManager.handleNewChanges();
442:                    } catch (CoreException e) {
443:                        IDEWorkbenchPlugin
444:                                .log(
445:                                        "Problem opening update manager", e.getStatus()); //$NON-NLS-1$
446:                    }
447:                }
448:            }
449:
450:            /*
451:             * (non-Javadoc)
452:             * 
453:             * @see org.eclipse.ui.application.WorkbenchAdvisor#getDefaultPageInput
454:             */
455:            public IAdaptable getDefaultPageInput() {
456:                return ResourcesPlugin.getWorkspace().getRoot();
457:            }
458:
459:            /*
460:             * (non-Javadoc)
461:             * 
462:             * @see org.eclipse.ui.application.WorkbenchAdvisor
463:             */
464:            public String getInitialWindowPerspectiveId() {
465:                int index = PlatformUI.getWorkbench().getWorkbenchWindowCount() - 1;
466:
467:                String perspectiveId = null;
468:                AboutInfo[] welcomeInfos = getWelcomePerspectiveInfos();
469:                if (index >= 0 && welcomeInfos != null
470:                        && index < welcomeInfos.length) {
471:                    perspectiveId = welcomeInfos[index]
472:                            .getWelcomePerspectiveId();
473:                }
474:                if (perspectiveId == null) {
475:                    perspectiveId = IDE.RESOURCE_PERSPECTIVE_ID;
476:                }
477:                return perspectiveId;
478:            }
479:
480:            /**
481:             * Returns the map of versioned feature ids -> info object for all installed
482:             * features. The format of the versioned feature id (the key of the map) is
483:             * featureId + ":" + versionId.
484:             * 
485:             * @return map of versioned feature ids -> info object (key type:
486:             *         <code>String</code>, value type: <code>AboutInfo</code>)
487:             * @since 3.0
488:             */
489:            private Map computeBundleGroupMap() {
490:                // use tree map to get predicable order
491:                Map ids = new TreeMap();
492:
493:                IBundleGroupProvider[] providers = Platform
494:                        .getBundleGroupProviders();
495:                for (int i = 0; i < providers.length; ++i) {
496:                    IBundleGroup[] groups = providers[i].getBundleGroups();
497:                    for (int j = 0; j < groups.length; ++j) {
498:                        IBundleGroup group = groups[j];
499:                        AboutInfo info = new AboutInfo(group);
500:
501:                        String version = info.getVersionId();
502:                        version = version == null ? "0.0.0" //$NON-NLS-1$
503:                                : new Version(version).toString();
504:                        String versionedFeature = group.getIdentifier()
505:                                + ":" + version; //$NON-NLS-1$
506:
507:                        ids.put(versionedFeature, info);
508:                    }
509:                }
510:
511:                return ids;
512:            }
513:
514:            /**
515:             * Returns the ordered map of versioned feature ids -> AboutInfo that are
516:             * new for this session.
517:             * 
518:             * @return ordered map of versioned feature ids (key type:
519:             *         <code>String</code>) -> infos (value type:
520:             *         <code>AboutInfo</code>).
521:             */
522:            public Map getNewlyAddedBundleGroups() {
523:                if (newlyAddedBundleGroups == null) {
524:                    newlyAddedBundleGroups = createNewBundleGroupsMap();
525:                }
526:                return newlyAddedBundleGroups;
527:            }
528:
529:            /**
530:             * Updates the old features setting and returns a map of new features.
531:             */
532:            private Map createNewBundleGroupsMap() {
533:                // retrieve list of installed bundle groups from last session
534:                IDialogSettings settings = IDEWorkbenchPlugin.getDefault()
535:                        .getDialogSettings();
536:                String[] previousFeaturesArray = settings
537:                        .getArray(INSTALLED_FEATURES);
538:
539:                // get a map of currently installed bundle groups and store it for next
540:                // session
541:                Map bundleGroups = computeBundleGroupMap();
542:                String[] currentFeaturesArray = new String[bundleGroups.size()];
543:                bundleGroups.keySet().toArray(currentFeaturesArray);
544:                settings.put(INSTALLED_FEATURES, currentFeaturesArray);
545:
546:                // remove the previously known from the current set
547:                if (previousFeaturesArray != null) {
548:                    for (int i = 0; i < previousFeaturesArray.length; ++i) {
549:                        bundleGroups.remove(previousFeaturesArray[i]);
550:                    }
551:                }
552:
553:                return bundleGroups;
554:            }
555:
556:            /**
557:             * Declares all IDE-specific workbench images. This includes both "shared"
558:             * images (named in {@link IDE.SharedImages}) and internal images (named in
559:             * {@link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}).
560:             * 
561:             * @see IWorkbenchConfigurer#declareImage
562:             */
563:            private void declareWorkbenchImages() {
564:
565:                final String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
566:                final String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; // Enabled //$NON-NLS-1$
567:
568:                // toolbar
569:                // icons.
570:                final String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; // Disabled //$NON-NLS-1$
571:                // //$NON-NLS-1$
572:                // toolbar
573:                // icons.
574:                final String PATH_ETOOL = ICONS_PATH + "etool16/"; // Enabled toolbar //$NON-NLS-1$
575:                // //$NON-NLS-1$
576:                // icons.
577:                final String PATH_DTOOL = ICONS_PATH + "dtool16/"; // Disabled toolbar //$NON-NLS-1$
578:                // //$NON-NLS-1$
579:                // icons.
580:                final String PATH_OBJECT = ICONS_PATH + "obj16/"; // Model object //$NON-NLS-1$
581:                // //$NON-NLS-1$
582:                // icons
583:                final String PATH_WIZBAN = ICONS_PATH + "wizban/"; // Wizard //$NON-NLS-1$
584:                // //$NON-NLS-1$
585:                // icons
586:
587:                Bundle ideBundle = Platform
588:                        .getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
589:
590:                declareWorkbenchImage(ideBundle,
591:                        IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC,
592:                        PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
593:                declareWorkbenchImage(ideBundle,
594:                        IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER,
595:                        PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
596:                declareWorkbenchImage(
597:                        ideBundle,
598:                        IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED,
599:                        PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
600:
601:                declareWorkbenchImage(ideBundle,
602:                        IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC,
603:                        PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
604:                declareWorkbenchImage(ideBundle,
605:                        IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER,
606:                        PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
607:                declareWorkbenchImage(
608:                        ideBundle,
609:                        IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED,
610:                        PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
611:
612:                declareWorkbenchImage(ideBundle,
613:                        IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV,
614:                        PATH_ETOOL + "next_nav.gif", false); //$NON-NLS-1$
615:
616:                declareWorkbenchImage(ideBundle,
617:                        IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV,
618:                        PATH_ETOOL + "prev_nav.gif", false); //$NON-NLS-1$
619:
620:                declareWorkbenchImage(ideBundle,
621:                        IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ,
622:                        PATH_WIZBAN + "newprj_wiz.png", false); //$NON-NLS-1$
623:                declareWorkbenchImage(ideBundle,
624:                        IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ,
625:                        PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
626:                declareWorkbenchImage(ideBundle,
627:                        IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ,
628:                        PATH_WIZBAN + "newfile_wiz.png", false); //$NON-NLS-1$
629:
630:                declareWorkbenchImage(ideBundle,
631:                        IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ,
632:                        PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
633:                declareWorkbenchImage(ideBundle,
634:                        IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ,
635:                        PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
636:
637:                declareWorkbenchImage(ideBundle,
638:                        IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ,
639:                        PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
640:                declareWorkbenchImage(ideBundle,
641:                        IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ,
642:                        PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
643:
644:                declareWorkbenchImage(
645:                        ideBundle,
646:                        IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ,
647:                        PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
648:
649:                declareWorkbenchImage(ideBundle,
650:                        IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG,
651:                        PATH_WIZBAN + "saveas_wiz.png", false); //$NON-NLS-1$
652:
653:                declareWorkbenchImage(ideBundle,
654:                        IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG,
655:                        PATH_WIZBAN + "quick_fix.png", false); //$NON-NLS-1$
656:
657:                declareWorkbenchImage(ideBundle,
658:                        IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT
659:                                + "prj_obj.gif", true); //$NON-NLS-1$
660:                declareWorkbenchImage(ideBundle,
661:                        IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
662:                                + "cprj_obj.gif", true); //$NON-NLS-1$
663:                declareWorkbenchImage(ideBundle,
664:                        IDE.SharedImages.IMG_OPEN_MARKER, PATH_ELOCALTOOL
665:                                + "gotoobj_tsk.gif", true); //$NON-NLS-1$
666:
667:                declareWorkbenchImage(ideBundle,
668:                        IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED,
669:                        PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
670:
671:                declareWorkbenchImage(ideBundle,
672:                        IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED,
673:                        PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
674:
675:                // task objects
676:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_HPRIO_TSK,
677:                // PATH_OBJECT+"hprio_tsk.gif");
678:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_MPRIO_TSK,
679:                // PATH_OBJECT+"mprio_tsk.gif");
680:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
681:                // PATH_OBJECT+"lprio_tsk.gif");
682:
683:                declareWorkbenchImage(ideBundle,
684:                        IDE.SharedImages.IMG_OBJS_TASK_TSK, PATH_OBJECT
685:                                + "taskmrk_tsk.gif", true); //$NON-NLS-1$
686:                declareWorkbenchImage(ideBundle,
687:                        IDE.SharedImages.IMG_OBJS_BKMRK_TSK, PATH_OBJECT
688:                                + "bkmrk_tsk.gif", true); //$NON-NLS-1$
689:
690:                declareWorkbenchImage(ideBundle,
691:                        IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK,
692:                        PATH_OBJECT + "complete_tsk.gif", true); //$NON-NLS-1$
693:                declareWorkbenchImage(ideBundle,
694:                        IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK,
695:                        PATH_OBJECT + "incomplete_tsk.gif", true); //$NON-NLS-1$
696:                declareWorkbenchImage(ideBundle,
697:                        IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM,
698:                        PATH_OBJECT + "welcome_item.gif", true); //$NON-NLS-1$
699:                declareWorkbenchImage(ideBundle,
700:                        IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER,
701:                        PATH_OBJECT + "welcome_banner.gif", true); //$NON-NLS-1$
702:                declareWorkbenchImage(ideBundle,
703:                        IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH,
704:                        PATH_OBJECT + "error_tsk.gif", true); //$NON-NLS-1$
705:                declareWorkbenchImage(ideBundle,
706:                        IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH,
707:                        PATH_OBJECT + "warn_tsk.gif", true); //$NON-NLS-1$
708:                declareWorkbenchImage(ideBundle,
709:                        IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH,
710:                        PATH_OBJECT + "info_tsk.gif", true); //$NON-NLS-1$
711:
712:                declareWorkbenchImage(ideBundle,
713:                        IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT,
714:                        PATH_ELOCALTOOL + "flatLayout.gif", true); //$NON-NLS-1$
715:                declareWorkbenchImage(ideBundle,
716:                        IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT,
717:                        PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
718:                declareWorkbenchImage(ideBundle,
719:                        IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY,
720:                        PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
721:
722:                // synchronization indicator objects
723:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_WBET_STAT,
724:                // PATH_OVERLAY+"wbet_stat.gif");
725:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_SBET_STAT,
726:                // PATH_OVERLAY+"sbet_stat.gif");
727:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_CONFLICT_STAT,
728:                // PATH_OVERLAY+"conflict_stat.gif");
729:
730:                // content locality indicator objects
731:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_NOTLOCAL_STAT,
732:                // PATH_STAT+"notlocal_stat.gif");
733:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LOCAL_STAT,
734:                // PATH_STAT+"local_stat.gif");
735:                // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_FILLLOCAL_STAT,
736:                // PATH_STAT+"filllocal_stat.gif");
737:            }
738:
739:            /**
740:             * Declares an IDE-specific workbench image.
741:             * 
742:             * @param symbolicName
743:             *            the symbolic name of the image
744:             * @param path
745:             *            the path of the image file; this path is relative to the base
746:             *            of the IDE plug-in
747:             * @param shared
748:             *            <code>true</code> if this is a shared image, and
749:             *            <code>false</code> if this is not a shared image
750:             * @see IWorkbenchConfigurer#declareImage
751:             */
752:            private void declareWorkbenchImage(Bundle ideBundle,
753:                    String symbolicName, String path, boolean shared) {
754:                URL url = FileLocator.find(ideBundle, new Path(path), null);
755:                ImageDescriptor desc = ImageDescriptor.createFromURL(url);
756:                getWorkbenchConfigurer().declareImage(symbolicName, desc,
757:                        shared);
758:            }
759:
760:            /*
761:             * (non-Javadoc)
762:             * 
763:             * @see org.eclipse.ui.application.WorkbenchAdvisor#getMainPreferencePageId
764:             */
765:            public String getMainPreferencePageId() {
766:                // indicate that we want the Workench preference page to be prominent
767:                return WORKBENCH_PREFERENCE_CATEGORY_ID;
768:            }
769:
770:            /**
771:             * @return the workspace location string, or <code>null</code> if the
772:             *         location is not being shown
773:             */
774:            public String getWorkspaceLocation() {
775:                return workspaceLocation;
776:            }
777:
778:            /**
779:             * @return the welcome perspective infos, or <code>null</code> if none or
780:             *         if they should be ignored due to the new intro being present
781:             */
782:            public AboutInfo[] getWelcomePerspectiveInfos() {
783:                if (welcomePerspectiveInfos == null) {
784:                    // support old welcome perspectives if intro plugin is not present
785:                    if (!hasIntro()) {
786:                        Map m = getNewlyAddedBundleGroups();
787:                        ArrayList list = new ArrayList(m.size());
788:                        for (Iterator i = m.values().iterator(); i.hasNext();) {
789:                            AboutInfo info = (AboutInfo) i.next();
790:                            if (info != null
791:                                    && info.getWelcomePerspectiveId() != null
792:                                    && info.getWelcomePageURL() != null) {
793:                                list.add(info);
794:                            }
795:                        }
796:                        welcomePerspectiveInfos = new AboutInfo[list.size()];
797:                        list.toArray(welcomePerspectiveInfos);
798:                    }
799:                }
800:                return welcomePerspectiveInfos;
801:            }
802:
803:            /*
804:             * (non-Javadoc)
805:             * 
806:             * @see org.eclipse.ui.application.WorkbenchAdvisor#getWorkbenchErrorHandler()
807:             */
808:            public AbstractStatusHandler getWorkbenchErrorHandler() {
809:                if (ideWorkbenchErrorHandler == null) {
810:                    ideWorkbenchErrorHandler = new IDEWorkbenchErrorHandler(
811:                            getWorkbenchConfigurer());
812:                }
813:                return ideWorkbenchErrorHandler;
814:            }
815:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.