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
.tmf
.core
.TmfCommonConstants
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfNavigatorContentProvider
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
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);
101 public void postWindowCreate() {
102 super.postWindowOpen();
103 TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveListener());
104 createDefaultProject();
106 openTraceIfNecessary();
111 private static void openTraceIfNecessary() {
112 String traceToOpen
= TracingRcpPlugin
.getDefault().getCli().getArgument(CliParser
.OPEN_FILE_LOCATION
);
113 if (traceToOpen
!= null) {
114 final IWorkspace workspace
= ResourcesPlugin
.getWorkspace();
115 final IWorkspaceRoot root
= workspace
.getRoot();
116 IProject project
= root
.getProject(TmfCommonConstants
.DEFAULT_TRACE_PROJECT_NAME
);
117 final TmfNavigatorContentProvider ncp
= new TmfNavigatorContentProvider();
118 ncp
.getChildren( project
); // force the model to be populated
119 TmfOpenTraceHelper oth
= new TmfOpenTraceHelper();
121 oth
.openTraceFromPath(TmfCommonConstants
.DEFAULT_TRACE_PROJECT_NAME
,traceToOpen
, TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
122 } catch (CoreException e
) {
123 TracingRcpPlugin
.getDefault().logError(e
.getMessage());
129 // ------------------------------------------------------------------------
131 // ------------------------------------------------------------------------
134 * Hides the unwanted action sets
136 private static void hideActionSets() {
138 IWorkbenchPage page
= TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
140 for (int i
= 0; i
< UNWANTED_ACTION_SET
.length
; i
++) {
141 page
.hideActionSet(UNWANTED_ACTION_SET
[i
]);
145 private static void createDefaultProject() {
146 TmfProjectRegistry
.createProject(TmfCommonConstants
.DEFAULT_TRACE_PROJECT_NAME
, null, new NullProgressMonitor());
150 * A perspective listener implementation
152 * @author Bernd Hufmann
154 public class PerspectiveListener
implements IPerspectiveListener
{
157 * Default Constructor
159 public PerspectiveListener() {
163 public void perspectiveActivated(IWorkbenchPage page
, IPerspectiveDescriptor perspective
) {
164 createDefaultProject();
169 public void perspectiveChanged(IWorkbenchPage page
, IPerspectiveDescriptor perspective
, String changeId
) {