Source Code Cross Referenced for DependenciesView.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » views » dependencies » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.views.dependencies 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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.pde.internal.ui.views.dependencies;
011:
012:        import java.util.ArrayList;
013:        import java.util.HashMap;
014:        import java.util.Map;
015:
016:        import org.eclipse.core.runtime.Preferences;
017:        import org.eclipse.jface.action.Action;
018:        import org.eclipse.jface.action.IAction;
019:        import org.eclipse.jface.action.IContributionItem;
020:        import org.eclipse.jface.action.IToolBarManager;
021:        import org.eclipse.jface.action.Separator;
022:        import org.eclipse.jface.action.SubContributionItem;
023:        import org.eclipse.jface.viewers.IStructuredSelection;
024:        import org.eclipse.osgi.util.NLS;
025:        import org.eclipse.pde.core.plugin.IPlugin;
026:        import org.eclipse.pde.core.plugin.IPluginModel;
027:        import org.eclipse.pde.core.plugin.IPluginModelBase;
028:        import org.eclipse.pde.core.plugin.PluginRegistry;
029:        import org.eclipse.pde.internal.core.PDECore;
030:        import org.eclipse.pde.internal.core.builders.DependencyLoop;
031:        import org.eclipse.pde.internal.core.builders.DependencyLoopFinder;
032:        import org.eclipse.pde.internal.ui.IHelpContextIds;
033:        import org.eclipse.pde.internal.ui.IPreferenceConstants;
034:        import org.eclipse.pde.internal.ui.PDEPlugin;
035:        import org.eclipse.pde.internal.ui.PDEPluginImages;
036:        import org.eclipse.pde.internal.ui.PDEUIMessages;
037:        import org.eclipse.pde.internal.ui.editor.plugin.LoopDialog;
038:        import org.eclipse.swt.custom.BusyIndicator;
039:        import org.eclipse.swt.graphics.Image;
040:        import org.eclipse.swt.widgets.Composite;
041:        import org.eclipse.ui.IActionBars;
042:        import org.eclipse.ui.IMemento;
043:        import org.eclipse.ui.IPropertyListener;
044:        import org.eclipse.ui.IViewSite;
045:        import org.eclipse.ui.IWorkbenchPart;
046:        import org.eclipse.ui.IWorkbenchPartSite;
047:        import org.eclipse.ui.PartInitException;
048:        import org.eclipse.ui.PlatformUI;
049:        import org.eclipse.ui.part.IPage;
050:        import org.eclipse.ui.part.IPageBookViewPage;
051:        import org.eclipse.ui.part.PageBook;
052:        import org.eclipse.ui.part.PageBookView;
053:
054:        public class DependenciesView extends PageBookView implements 
055:                IPreferenceConstants, IHelpContextIds {
056:
057:            static class DummyPart implements  IWorkbenchPart {
058:                public void addPropertyListener(IPropertyListener listener) {/* dummy */
059:                }
060:
061:                public void createPartControl(Composite parent) {/* dummy */
062:                }
063:
064:                public void dispose() {/* dummy */
065:                }
066:
067:                public Object getAdapter(Class adapter) {
068:                    return null;
069:                }
070:
071:                public IWorkbenchPartSite getSite() {
072:                    return null;
073:                }
074:
075:                public String getTitle() {
076:                    return null;
077:                }
078:
079:                public Image getTitleImage() {
080:                    return null;
081:                }
082:
083:                public String getTitleToolTip() {
084:                    return null;
085:                }
086:
087:                public void removePropertyListener(IPropertyListener listener) {/* dummy */
088:                }
089:
090:                public void setFocus() {/* dummy */
091:                }
092:            }
093:
094:            class ShowLoopsAction extends Action {
095:
096:                public ShowLoopsAction() {
097:                    super ("", AS_PUSH_BUTTON); //$NON-NLS-1$
098:                    setText(PDEUIMessages.DependenciesView_ShowLoopsAction_label);
099:                    setDescription(PDEUIMessages.DependenciesView_ShowLoopsAction_description);
100:                    setToolTipText(PDEUIMessages.DependenciesView_ShowLoopsAction_tooltip);
101:                    setImageDescriptor(PDEPluginImages.DESC_DEP_LOOP);
102:                    setDisabledImageDescriptor(PDEPluginImages.DESC_DEP_LOOP_DISABLED);
103:                    setEnabled(false);
104:                }
105:
106:                /*
107:                 * @see Action#actionPerformed
108:                 */
109:                public void run() {
110:                    LoopDialog dialog = new LoopDialog(PDEPlugin
111:                            .getActiveWorkbenchShell(), fLoops);
112:                    dialog.open();
113:                }
114:            }
115:
116:            class ShowCalleesAction extends Action {
117:
118:                public ShowCalleesAction() {
119:                    super ("", AS_RADIO_BUTTON); //$NON-NLS-1$
120:                    setText(PDEUIMessages.DependenciesView_ShowCalleesAction_label);
121:                    setDescription(PDEUIMessages.DependenciesView_ShowCalleesAction_description);
122:                    setToolTipText(PDEUIMessages.DependenciesView_ShowCalleesAction_tooltip);
123:                    setImageDescriptor(PDEPluginImages.DESC_CALLEES);
124:                    setDisabledImageDescriptor(PDEPluginImages.DESC_CALLEES_DISABLED);
125:                }
126:
127:                /*
128:                 * @see Action#actionPerformed
129:                 */
130:                public void run() {
131:                    if (isChecked()) {
132:                        fPreferences.setValue(DEPS_VIEW_SHOW_CALLERS, false);
133:                        setViewType(false);
134:                    }
135:                }
136:            }
137:
138:            class ShowCallersAction extends Action {
139:                public ShowCallersAction() {
140:                    super ("", AS_RADIO_BUTTON); //$NON-NLS-1$
141:                    setText(PDEUIMessages.DependenciesView_ShowCallersAction_label);
142:                    setDescription(PDEUIMessages.DependenciesView_ShowCallersAction_description);
143:                    setToolTipText(PDEUIMessages.DependenciesView_ShowCallersAction_tooltip);
144:                    setImageDescriptor(PDEPluginImages.DESC_CALLERS);
145:                    setDisabledImageDescriptor(PDEPluginImages.DESC_CALLERS_DISABLED);
146:                }
147:
148:                /*
149:                 * @see Action#actionPerformed
150:                 */
151:                public void run() {
152:                    if (isChecked()) {
153:                        fPreferences.setValue(DEPS_VIEW_SHOW_CALLERS, true);
154:                        setViewType(true);
155:                    }
156:                }
157:            }
158:
159:            class ShowListAction extends Action {
160:                public ShowListAction() {
161:                    super ("", AS_RADIO_BUTTON); //$NON-NLS-1$
162:                    setText(PDEUIMessages.DependenciesView_ShowListAction_label);
163:                    setDescription(PDEUIMessages.DependenciesView_ShowListAction_description);
164:                    setToolTipText(PDEUIMessages.DependenciesView_ShowListAction_tooltip);
165:                    setImageDescriptor(PDEPluginImages.DESC_FLAT_LAYOUT);
166:                    setDisabledImageDescriptor(PDEPluginImages.DESC_FLAT_LAYOUT_DISABLED);
167:                }
168:
169:                /*
170:                 * @see Action#actionPerformed
171:                 */
172:                public void run() {
173:                    if (isChecked()) {
174:                        fPreferences.setValue(DEPS_VIEW_SHOW_LIST, true);
175:                        setPresentation(true);
176:                    }
177:                }
178:            }
179:
180:            class ShowTreeAction extends Action {
181:
182:                public ShowTreeAction() {
183:                    super ("", AS_RADIO_BUTTON); //$NON-NLS-1$
184:                    setText(PDEUIMessages.DependenciesView_ShowTreeAction_label);
185:                    setDescription(PDEUIMessages.DependenciesView_ShowTreeAction_description);
186:                    setToolTipText(PDEUIMessages.DependenciesView_ShowTreeAction_tooltip);
187:                    setImageDescriptor(PDEPluginImages.DESC_HIERARCHICAL_LAYOUT);
188:                    setDisabledImageDescriptor(PDEPluginImages.DESC_HIERARCHICAL_LAYOUT_DISABLED);
189:                }
190:
191:                /*
192:                 * @see Action#actionPerformed
193:                 */
194:                public void run() {
195:                    if (isChecked()) {
196:                        fPreferences.setValue(DEPS_VIEW_SHOW_LIST, false);
197:                        setPresentation(false);
198:                    }
199:                }
200:            }
201:
202:            class ShowStateAction extends Action {
203:
204:                public ShowStateAction() {
205:                    super (PDEUIMessages.DependenciesView_showStateAction_label,
206:                            IAction.AS_CHECK_BOX);
207:                    setDescription(PDEUIMessages.DependenciesView_showStateAction_description);
208:                    setToolTipText(PDEUIMessages.DependenciesView_showStateAction_toolTip);
209:                    setImageDescriptor(PDEPluginImages.DESC_REQ_PLUGINS_OBJ);
210:                    setId(SHOW_STATE_ACTION_ID);
211:                }
212:
213:                /*
214:                 * @see Action#actionPerformed
215:                 */
216:                public void run() {
217:                    fPreferences.setValue(DEPS_VIEW_SHOW_STATE, isChecked());
218:                    enableStateView(isChecked());
219:                }
220:            }
221:
222:            protected static final IWorkbenchPart PART_CALLEES_LIST = new DummyPart();
223:
224:            protected static final IWorkbenchPart PART_CALLEES_TREE = new DummyPart();
225:
226:            protected static final IWorkbenchPart PART_CALLERS_LIST = new DummyPart();
227:
228:            protected static final IWorkbenchPart PART_CALLERS_TREE = new DummyPart();
229:
230:            protected static final IWorkbenchPart PART_STATE_TREE = new DummyPart();
231:
232:            public static final String TREE_ACTION_GROUP = "tree"; //$NON-NLS-1$
233:
234:            protected static final String MEMENTO_KEY_INPUT = "inputPluginId"; //$NON-NLS-1$
235:
236:            protected static final String SHOW_STATE_ACTION_ID = "show.state.action"; //$NON-NLS-1$
237:
238:            private static final DependencyLoop[] NO_LOOPS = new DependencyLoop[0];
239:
240:            private Map fPagesToParts;
241:
242:            private Map fPartsToPages;
243:
244:            private Object fInput;
245:
246:            private Preferences fPreferences = PDEPlugin.getDefault()
247:                    .getPluginPreferences();
248:
249:            private ShowCalleesAction fShowCallees;
250:
251:            private ShowCallersAction fShowCallers;
252:
253:            private ShowListAction fShowList;
254:
255:            private ShowTreeAction fShowTree;
256:
257:            private ShowLoopsAction fShowLoops;
258:
259:            // history of input elements (as Strings). No duplicates
260:            private ArrayList fInputHistory;
261:
262:            private DependencyLoop[] fLoops;
263:
264:            private HistoryDropDownAction fHistoryDropDownAction;
265:
266:            private Action fShowState;
267:
268:            private IWorkbenchPart fLastDependenciesPart = null;
269:
270:            /**
271:             * 
272:             */
273:            public DependenciesView() {
274:                super ();
275:                fPartsToPages = new HashMap(4);
276:                fPagesToParts = new HashMap(4);
277:                fInputHistory = new ArrayList();
278:                fLoops = NO_LOOPS;
279:            }
280:
281:            private void contributeToActionBars(IActionBars actionBars) {
282:                contributeToLocalToolBar(actionBars.getToolBarManager());
283:                actionBars.updateActionBars();
284:            }
285:
286:            private void contributeToLocalToolBar(IToolBarManager manager) {
287:                manager.add(new Separator(TREE_ACTION_GROUP));
288:                manager.add(new Separator("type")); //$NON-NLS-1$
289:                manager.appendToGroup("type", fShowCallees); //$NON-NLS-1$
290:                manager.appendToGroup("type", fShowCallers); //$NON-NLS-1$
291:                manager.add(new Separator("presentation")); //$NON-NLS-1$
292:                manager.appendToGroup("presentation", fShowTree); //$NON-NLS-1$
293:                manager.appendToGroup("presentation", fShowList); //$NON-NLS-1$
294:                manager.add(new Separator("history")); //$NON-NLS-1$
295:                manager.add(fShowLoops);
296:                manager.add(fHistoryDropDownAction);
297:                manager.add(new Separator("state")); //$NON-NLS-1$
298:                manager.add(fShowState);
299:                if (PART_STATE_TREE.equals(getCurrentContributingPart()))
300:                    enableDependenciesActions(false);
301:            }
302:
303:            /*
304:             * (non-Javadoc)
305:             * 
306:             * @see org.eclipse.ui.part.PageBookView#createDefaultPage(org.eclipse.ui.part.PageBook)
307:             */
308:            protected IPage createDefaultPage(PageBook book) {
309:                if (fInput == null
310:                        || fPreferences.getBoolean(DEPS_VIEW_SHOW_STATE))
311:                    return createPage(PART_STATE_TREE);
312:                return createPage(getDefaultPart());
313:            }
314:
315:            private IWorkbenchPart getDefaultPart() {
316:                if (fPreferences.getBoolean(DEPS_VIEW_SHOW_CALLERS)) {
317:                    if (fPreferences.getBoolean(DEPS_VIEW_SHOW_LIST)) {
318:                        return PART_CALLERS_LIST;
319:                    }
320:                    return PART_CALLERS_TREE;
321:                }
322:                if (fPreferences.getBoolean(DEPS_VIEW_SHOW_LIST)) {
323:                    return PART_CALLEES_LIST;
324:                }
325:                return PART_CALLEES_TREE;
326:            }
327:
328:            /**
329:             * part of the part constants
330:             */
331:            private IPageBookViewPage createPage(IWorkbenchPart part) {
332:                IPageBookViewPage page;
333:                if (part == PART_CALLEES_TREE) {
334:                    page = new DependenciesViewTreePage(this ,
335:                            new CalleesTreeContentProvider(this ));
336:                } else if (part == PART_CALLEES_LIST) {
337:                    page = new DependenciesViewListPage(this ,
338:                            new CalleesListContentProvider(this ));
339:                } else if (part == PART_CALLERS_TREE) {
340:                    page = new DependenciesViewTreePage(this ,
341:                            new CallersTreeContentProvider(this ));
342:                } else if (part == PART_CALLERS_LIST) {
343:                    page = new DependenciesViewListPage(this ,
344:                            new CallersListContentProvider(this ));
345:                } else {
346:                    page = new StateViewPage(this );
347:                }
348:
349:                initPage(page);
350:                page.createControl(getPageBook());
351:                fPartsToPages.put(part, page);
352:                fPagesToParts.put(page, part);
353:                return page;
354:            }
355:
356:            /*
357:             * (non-Javadoc)
358:             * 
359:             * @see org.eclipse.ui.part.PageBookView#createPartControl(org.eclipse.swt.widgets.Composite)
360:             */
361:            public void createPartControl(Composite parent) {
362:                super .createPartControl(parent);
363:                fShowCallees = new ShowCalleesAction();
364:                fShowCallees.setChecked(!fPreferences
365:                        .getBoolean(DEPS_VIEW_SHOW_CALLERS));
366:                fShowCallers = new ShowCallersAction();
367:                fShowCallers.setChecked(fPreferences
368:                        .getBoolean(DEPS_VIEW_SHOW_CALLERS));
369:
370:                fShowTree = new ShowTreeAction();
371:                fShowTree.setChecked(!fPreferences
372:                        .getBoolean(DEPS_VIEW_SHOW_LIST));
373:                fShowList = new ShowListAction();
374:                fShowList.setChecked(fPreferences
375:                        .getBoolean(DEPS_VIEW_SHOW_LIST));
376:
377:                fShowLoops = new ShowLoopsAction();
378:                fShowLoops.setEnabled(fLoops != NO_LOOPS);
379:
380:                fHistoryDropDownAction = new HistoryDropDownAction(this );
381:                fHistoryDropDownAction.setEnabled(!fInputHistory.isEmpty());
382:
383:                fShowState = new ShowStateAction();
384:                fShowState.setChecked(fInput == null
385:                        || fPreferences.getBoolean(DEPS_VIEW_SHOW_STATE));
386:
387:                IActionBars actionBars = getViewSite().getActionBars();
388:                contributeToActionBars(actionBars);
389:
390:                PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
391:                        IHelpContextIds.DEPENDENCIES_VIEW);
392:            }
393:
394:            /*
395:             * (non-Javadoc)
396:             * 
397:             * @see org.eclipse.ui.part.PageBookView#doCreatePage(org.eclipse.ui.IWorkbenchPart)
398:             */
399:            protected PageRec doCreatePage(IWorkbenchPart part) {
400:                IPageBookViewPage page = (IPageBookViewPage) fPartsToPages
401:                        .get(part);
402:                if (page == null && !fPartsToPages.containsKey(part)) {
403:                    page = createPage(part);
404:                }
405:                if (page != null) {
406:                    return new PageRec(part, page);
407:                }
408:                return null;
409:            }
410:
411:            /*
412:             * (non-Javadoc)
413:             * 
414:             * @see org.eclipse.ui.part.PageBookView#doDestroyPage(org.eclipse.ui.IWorkbenchPart,
415:             *      org.eclipse.ui.part.PageBookView.PageRec)
416:             */
417:            protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
418:                IPage page = pageRecord.page;
419:                page.dispose();
420:                pageRecord.dispose();
421:
422:                // empty cross-reference cache
423:                fPartsToPages.remove(part);
424:            }
425:
426:            /*
427:             * (non-Javadoc)
428:             * 
429:             * @see org.eclipse.ui.part.PageBookView#getBootstrapPart()
430:             */
431:            protected IWorkbenchPart getBootstrapPart() {
432:                if (fInput == null
433:                        || fPreferences.getBoolean(DEPS_VIEW_SHOW_STATE))
434:                    return PART_STATE_TREE;
435:                return getDefaultPart();
436:            }
437:
438:            /*
439:             * (non-Javadoc)
440:             * 
441:             * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite,
442:             *      org.eclipse.ui.IMemento)
443:             */
444:            public void init(IViewSite site, IMemento memento)
445:                    throws PartInitException {
446:                super .init(site, memento);
447:                if (memento == null)
448:                    return;
449:                String id = memento.getString(MEMENTO_KEY_INPUT);
450:                if (id != null) {
451:                    IPluginModelBase plugin = PluginRegistry.findModel(id);
452:                    if (plugin != null) {
453:                        fInput = plugin;
454:                        addHistoryEntry(id);
455:                        findLoops();
456:                    }
457:                }
458:            }
459:
460:            /*
461:             * (non-Javadoc)
462:             * 
463:             * @see org.eclipse.ui.part.PageBookView#isImportant(org.eclipse.ui.IWorkbenchPart)
464:             */
465:            protected boolean isImportant(IWorkbenchPart part) {
466:                return part instanceof  DummyPart;
467:            }
468:
469:            public void openTo(Object object) {
470:                // if we are suppose to open to a element and we are in state mode, disable state mode and set focus
471:                if (getCurrentContributingPart() == PART_STATE_TREE) {
472:                    fShowState.setChecked(false);
473:                    fShowState.run();
474:                }
475:                if (object != null && !object.equals(fInput)) {
476:                    if (object instanceof  IPluginModelBase) {
477:                        String id = ((IPluginModelBase) object).getPluginBase()
478:                                .getId();
479:                        addHistoryEntry(id);
480:                    }
481:                }
482:                updateInput(object);
483:            }
484:
485:            public void openCallersFor(Object object) {
486:                if (getCurrentContributingPart() == PART_STATE_TREE)
487:                    fLastDependenciesPart = (fPreferences
488:                            .getBoolean(DEPS_VIEW_SHOW_LIST)) ? PART_CALLERS_LIST
489:                            : PART_CALLERS_TREE;
490:                else if (!fShowCallers.isChecked() && fShowCallees.isChecked()) {
491:                    fShowCallers.setChecked(true);
492:                    fShowCallees.setChecked(false);
493:                    fShowCallers.run();
494:                }
495:                openTo(object);
496:            }
497:
498:            public void openCalleesFor(Object object) {
499:                if (getCurrentContributingPart() == PART_STATE_TREE)
500:                    fLastDependenciesPart = (fPreferences
501:                            .getBoolean(DEPS_VIEW_SHOW_LIST)) ? PART_CALLEES_LIST
502:                            : PART_CALLEES_TREE;
503:                else if (!fShowCallees.isChecked() && fShowCallers.isChecked()) {
504:                    fShowCallees.setChecked(true);
505:                    fShowCallers.setChecked(false);
506:                    fShowCallees.run();
507:                }
508:                openTo(object);
509:            }
510:
511:            private void updateInput(Object object) {
512:                fInput = object;
513:                findLoops();
514:                ((DependenciesViewPage) getCurrentPage()).setInput(object);
515:            }
516:
517:            /**
518:             * 
519:             */
520:            private void findLoops() {
521:                fLoops = NO_LOOPS;
522:                if (fInput != null && fInput instanceof  IPluginModel) {
523:                    BusyIndicator.showWhile(PDEPlugin.getActiveWorkbenchShell()
524:                            .getDisplay(), new Runnable() {
525:                        /*
526:                         * (non-Javadoc)
527:                         * 
528:                         * @see java.lang.Runnable#run()
529:                         */
530:                        public void run() {
531:                            IPlugin plugin = ((IPluginModel) fInput)
532:                                    .getPlugin();
533:                            DependencyLoop[] loops = DependencyLoopFinder
534:                                    .findLoops(plugin);
535:                            if (loops.length > 0) {
536:                                fLoops = loops;
537:                            }
538:                        }
539:                    });
540:                }
541:                if (fShowLoops != null)
542:                    fShowLoops.setEnabled(fLoops != NO_LOOPS);
543:            }
544:
545:            /*
546:             * (non-Javadoc)
547:             * 
548:             * @see org.eclipse.ui.part.ViewPart#saveState(org.eclipse.ui.IMemento)
549:             */
550:            public void saveState(IMemento memento) {
551:                super .saveState(memento);
552:                if (fInput != null && fInput instanceof  IPluginModelBase) {
553:                    String inputPluginId = ((IPluginModelBase) fInput)
554:                            .getPluginBase().getId();
555:                    memento.putString(MEMENTO_KEY_INPUT, inputPluginId);
556:                }
557:            }
558:
559:            void setPresentation(boolean listNotTree) {
560:                IWorkbenchPart currentPart = getCurrentContributingPart();
561:                if (listNotTree) {
562:                    if (currentPart == PART_CALLEES_TREE) {
563:                        partActivated(PART_CALLEES_LIST);
564:                    } else if (currentPart == PART_CALLERS_TREE) {
565:                        partActivated(PART_CALLERS_LIST);
566:                    }
567:
568:                } else {
569:                    if (currentPart == PART_CALLEES_LIST) {
570:                        partActivated(PART_CALLEES_TREE);
571:                    } else if (currentPart == PART_CALLERS_LIST) {
572:                        partActivated(PART_CALLERS_TREE);
573:                    }
574:
575:                }
576:            }
577:
578:            void setViewType(boolean callers) {
579:                IWorkbenchPart currentPart = getCurrentContributingPart();
580:                if (callers) {
581:                    if (currentPart == PART_CALLEES_TREE) {
582:                        partActivated(PART_CALLERS_TREE);
583:                    } else if (currentPart == PART_CALLEES_LIST) {
584:                        partActivated(PART_CALLERS_LIST);
585:                    }
586:
587:                } else {
588:                    if (currentPart == PART_CALLERS_TREE) {
589:                        partActivated(PART_CALLEES_TREE);
590:                    } else if (currentPart == PART_CALLERS_LIST) {
591:                        partActivated(PART_CALLEES_LIST);
592:                    }
593:
594:                }
595:            }
596:
597:            /*
598:             * (non-Javadoc)
599:             * 
600:             * @see org.eclipse.ui.part.PageBookView#showPageRec(org.eclipse.ui.part.PageBookView.PageRec)
601:             */
602:            protected void showPageRec(PageRec pageRec) {
603:                IPage currPage = getCurrentPage();
604:                // if we try to show the same page, just call super and return, no use calling any custom functions
605:                if (pageRec.page.equals(currPage)) {
606:                    super .showPageRec(pageRec);
607:                    return;
608:                }
609:                IStructuredSelection selection = null;
610:                if (currPage instanceof  DependenciesViewPage) {
611:                    selection = ((DependenciesViewPage) currPage)
612:                            .getSelection();
613:                    ((DependenciesViewPage) currPage).setActive(false);
614:                } else if (currPage instanceof  StateViewPage) {
615:                    ((StateViewPage) currPage).setActive(false);
616:                }
617:                IPage p = pageRec.page;
618:                if (p instanceof  DependenciesViewPage) {
619:                    ((DependenciesViewPage) p).setInput(fInput);
620:                    // configure view before actually showing it
621:                    ((DependenciesViewPage) p).setActive(true);
622:                }
623:                super .showPageRec(pageRec);
624:                if (p instanceof  DependenciesViewPage) {
625:                    updateTitle(fInput);
626:                    ((DependenciesViewPage) p).setSelection(selection);
627:                } else if (p instanceof  StateViewPage) {
628:                    ((StateViewPage) p).setActive(true);
629:                }
630:            }
631:
632:            void updateTitle(Object newInput) {
633:                if (newInput == null) {
634:                    updateTitle(""); //$NON-NLS-1$
635:                } else if (!newInput.equals(PDECore.getDefault()
636:                        .getModelManager())) {
637:                    String name = PDEPlugin.getDefault().getLabelProvider()
638:                            .getText(newInput);
639:                    String title;
640:                    if (getCurrentContributingPart() == PART_CALLEES_TREE) {
641:                        title = NLS
642:                                .bind(
643:                                        PDEUIMessages.DependenciesView_callees_tree_title,
644:                                        name);
645:                    } else if (getCurrentContributingPart() == PART_CALLEES_LIST) {
646:                        title = NLS
647:                                .bind(
648:                                        PDEUIMessages.DependenciesView_callees_list_title,
649:                                        name);
650:                    } else if (getCurrentContributingPart() == PART_CALLERS_TREE) {
651:                        title = NLS
652:                                .bind(
653:                                        PDEUIMessages.DependenciesView_callers_tree_title,
654:                                        name);
655:                    } else {
656:                        title = NLS
657:                                .bind(
658:                                        PDEUIMessages.DependenciesView_callers_list_title,
659:                                        name);
660:                    }
661:                    if (fLoops != NO_LOOPS) {
662:                        title = title
663:                                + " " + PDEUIMessages.DependenciesView_cycles_title; //$NON-NLS-1$
664:                    }
665:                    updateTitle(title);
666:                }
667:            }
668:
669:            void updateTitle(String description) {
670:                setContentDescription(description);
671:                setTitleToolTip(getTitle());
672:            }
673:
674:            /**
675:             * Adds the entry if new. Inserted at the beginning of the history entries list.
676:             * @param entry The new entry
677:             */
678:            private void addHistoryEntry(String entry) {
679:                if (fInputHistory.contains(entry)) {
680:                    fInputHistory.remove(entry);
681:                }
682:                fInputHistory.add(0, entry);
683:                if (fHistoryDropDownAction != null)
684:                    fHistoryDropDownAction.setEnabled(true);
685:            }
686:
687:            private void updateHistoryEntries() {
688:                for (int i = fInputHistory.size() - 1; i >= 0; i--) {
689:                    String type = (String) fInputHistory.get(i);
690:                    if (PluginRegistry.findModel(type) == null) {
691:                        fInputHistory.remove(i);
692:                    }
693:                }
694:                if (fHistoryDropDownAction != null)
695:                    fHistoryDropDownAction.setEnabled(!fInputHistory.isEmpty());
696:            }
697:
698:            /**
699:             * Goes to the selected entry, without updating the order of history entries.
700:             * @param entry The entry to open
701:             */
702:            public void gotoHistoryEntry(String entry) {
703:                if (fInputHistory.contains(entry)) {
704:                    updateInput(PluginRegistry.findModel(entry));
705:                }
706:            }
707:
708:            /**
709:             * Gets all history entries.
710:             * @return All history entries
711:             */
712:            public String[] getHistoryEntries() {
713:                if (fInputHistory.size() > 0) {
714:                    updateHistoryEntries();
715:                }
716:                return (String[]) fInputHistory
717:                        .toArray(new String[fInputHistory.size()]);
718:            }
719:
720:            /**
721:             * Sets the history entries
722:             * @param elems The history elements to set
723:             */
724:            public void setHistoryEntries(String[] elems) {
725:                fInputHistory.clear();
726:                for (int i = 0; i < elems.length; i++) {
727:                    fInputHistory.add(elems[i]);
728:                }
729:                updateHistoryEntries();
730:            }
731:
732:            /**
733:             * @return Returns the fInput.
734:             */
735:            public String getInput() {
736:                if (fInput != null) {
737:                    return ((IPluginModelBase) fInput).getPluginBase().getId();
738:                }
739:                return null;
740:            }
741:
742:            public boolean isShowingCallers() {
743:                return fPreferences.getBoolean(DEPS_VIEW_SHOW_CALLERS);
744:            }
745:
746:            protected void enableStateView(boolean enabled) {
747:                if (enabled) {
748:                    fLastDependenciesPart = getCurrentContributingPart();
749:                    partActivated(DependenciesView.PART_STATE_TREE);
750:                } else {
751:                    if (fLastDependenciesPart != null)
752:                        partActivated(fLastDependenciesPart);
753:                    else
754:                        partActivated(getDefaultPart());
755:                    fLastDependenciesPart = null;
756:                }
757:                enableDependenciesActions(!enabled);
758:                getViewSite().getActionBars().getToolBarManager().update(true);
759:            }
760:
761:            // hide the table/tree, caller/callee, history and other action not applicable when showing the State view page
762:            private void enableDependenciesActions(boolean enabled) {
763:                IContributionItem[] items = getViewSite().getActionBars()
764:                        .getToolBarManager().getItems();
765:                for (int i = 0; i < items.length; i++) {
766:                    if (!(SHOW_STATE_ACTION_ID.equals(items[i].getId()) || "state".equals(items[i].getId())) //$NON-NLS-1$
767:                            && !(items[i] instanceof  SubContributionItem)) //$NON-NLS-1$
768:                        items[i].setVisible(enabled);
769:                }
770:            }
771:        }
w___w__w___.__ja___va___2__s___._c_om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.