1 /**********************************************************************
2 * Copyright (c) 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.tracing
.rcp
.ui
;
14 import org
.eclipse
.core
.resources
.IProject
;
15 import org
.eclipse
.core
.resources
.IWorkspace
;
16 import org
.eclipse
.core
.resources
.IWorkspaceRoot
;
17 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
18 import org
.eclipse
.core
.runtime
.CoreException
;
19 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
20 import org
.eclipse
.linuxtools
.internal
.tracing
.rcp
.ui
.cli
.CliParser
;
21 import org
.eclipse
.linuxtools
.internal
.tracing
.rcp
.ui
.messages
.Messages
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfNavigatorContentProvider
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
25 import org
.eclipse
.ui
.IPerspectiveDescriptor
;
26 import org
.eclipse
.ui
.IPerspectiveListener
;
27 import org
.eclipse
.ui
.IWorkbenchPage
;
28 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
29 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
30 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
31 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
34 * The WorkbenchAdvisor implementation of the LTTng RCP.
36 * @author Bernd Hufmann
38 public class ApplicationWorkbenchWindowAdvisor
extends WorkbenchWindowAdvisor
{
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
43 @SuppressWarnings("nls")
44 private static final String
[] UNWANTED_ACTION_SET
= {
45 "org.eclipse.search.searchActionSet",
46 "org.eclipse.rse.core.search.searchActionSet",
47 "org.eclipse.debug.ui.launchActionSet",
48 "org.eclipse.debug.ui.debugActionSet",
49 "org.eclipse.debug.ui.breakpointActionSet",
50 "org.eclipse.team.ui",
51 "org.eclipse.ui.externaltools.ExternalToolsSet",
52 // "org.eclipse.update.ui.softwareUpdates",
53 // "org.eclipse.ui.edit.text.actionSet.navigation",
54 // "org.eclipse.ui.actionSet.keyBindings",
55 // "org.eclipse.ui.edit.text.actionSet.navigation",
56 "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
57 // "org.eclipse.ui.edit.text.actionSet.annotationNavigation",
58 // "org.eclipse.ui.NavigateActionSet",
59 // "org.eclipse.jdt.ui.JavaActionSet",
60 // "org.eclipse.jdt.ui.A_OpenActionSet",
61 // "org.eclipse.jdt.ui.text.java.actionSet.presentation",
62 // "org.eclipse.jdt.ui.JavaElementCreationActionSet",
63 // "org.eclipse.jdt.ui.CodingActionSet",
64 // "org.eclipse.jdt.ui.SearchActionSet",
65 // "org.eclipse.jdt.debug.ui.JDTDebugActionSet",
66 "org.eclipse.ui.edit.text.actionSet.openExternalFile",
67 // "org.eclipse.debug.ui.profileActionSet"
70 // ------------------------------------------------------------------------
72 // ------------------------------------------------------------------------
75 * Standard constructor
78 * - the workbench window configurer
80 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer
) {
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
88 public ActionBarAdvisor
createActionBarAdvisor(IActionBarConfigurer configurer
) {
89 return new ApplicationActionBarAdvisor(configurer
);
93 public void preWindowOpen() {
94 IWorkbenchWindowConfigurer configurer
= getWindowConfigurer();
95 configurer
.setShowCoolBar(false);
96 configurer
.setShowStatusLine(true);
97 configurer
.setShowProgressIndicator(true);
98 configurer
.setTitle(Messages
.ApplicationWorkbenchWindowAdvisor_WindowTitle
);
102 public void postWindowCreate() {
103 super.postWindowOpen();
104 TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveListener());
105 createDefaultProject();
107 openTraceIfNecessary();
112 private static void openTraceIfNecessary() {
113 String traceToOpen
= TracingRcpPlugin
.getDefault().getCli().getArgument(CliParser
.OPEN_FILE_LOCATION
);
114 if (traceToOpen
!= null) {
115 final IWorkspace workspace
= ResourcesPlugin
.getWorkspace();
116 final IWorkspaceRoot root
= workspace
.getRoot();
117 IProject project
= root
.getProject(Messages
.ApplicationWorkbenchWindowAdvisor_DefaultProjectName
);
118 final TmfNavigatorContentProvider ncp
= new TmfNavigatorContentProvider();
119 ncp
.getChildren( project
); // force the model to be populated
120 TmfOpenTraceHelper oth
= new TmfOpenTraceHelper();
122 oth
.openTraceFromPath(Messages
.ApplicationWorkbenchWindowAdvisor_DefaultProjectName
,traceToOpen
, TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
123 } catch (CoreException e
) {
124 TracingRcpPlugin
.getDefault().logError(e
.getMessage());
130 // ------------------------------------------------------------------------
132 // ------------------------------------------------------------------------
135 * Hides the unwanted action sets
137 private static void hideActionSets() {
139 IWorkbenchPage page
= TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
141 for (int i
= 0; i
< UNWANTED_ACTION_SET
.length
; i
++) {
142 page
.hideActionSet(UNWANTED_ACTION_SET
[i
]);
146 private static void createDefaultProject() {
147 TmfProjectRegistry
.createProject(Messages
.ApplicationWorkbenchWindowAdvisor_DefaultProjectName
, null, new NullProgressMonitor());
151 * A perspective listener implementation
153 * @author Bernd Hufmann
155 public class PerspectiveListener
implements IPerspectiveListener
{
158 * Default Constructor
160 public PerspectiveListener() {
164 public void perspectiveActivated(IWorkbenchPage page
, IPerspectiveDescriptor perspective
) {
165 createDefaultProject();
170 public void perspectiveChanged(IWorkbenchPage page
, IPerspectiveDescriptor perspective
, String changeId
) {