1 /**********************************************************************
2 * Copyright (c) 2013, 2014 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
.runtime
.CoreException
;
15 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
16 import org
.eclipse
.linuxtools
.internal
.tracing
.rcp
.ui
.cli
.CliParser
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.TmfCommonConstants
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
20 import org
.eclipse
.ui
.IPerspectiveDescriptor
;
21 import org
.eclipse
.ui
.IPerspectiveListener
;
22 import org
.eclipse
.ui
.IWorkbenchPage
;
23 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
24 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
25 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
26 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
29 * The WorkbenchAdvisor implementation of the LTTng RCP.
31 * @author Bernd Hufmann
33 public class ApplicationWorkbenchWindowAdvisor
extends WorkbenchWindowAdvisor
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
38 @SuppressWarnings("nls")
39 private static final String
[] UNWANTED_ACTION_SET
= {
40 "org.eclipse.search.searchActionSet",
41 "org.eclipse.rse.core.search.searchActionSet",
42 "org.eclipse.debug.ui.launchActionSet",
43 "org.eclipse.debug.ui.debugActionSet",
44 "org.eclipse.debug.ui.breakpointActionSet",
45 "org.eclipse.team.ui",
46 "org.eclipse.ui.externaltools.ExternalToolsSet",
47 // "org.eclipse.update.ui.softwareUpdates",
48 // "org.eclipse.ui.edit.text.actionSet.navigation",
49 // "org.eclipse.ui.actionSet.keyBindings",
50 // "org.eclipse.ui.edit.text.actionSet.navigation",
51 "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
52 // "org.eclipse.ui.edit.text.actionSet.annotationNavigation",
53 // "org.eclipse.ui.NavigateActionSet",
54 // "org.eclipse.jdt.ui.JavaActionSet",
55 // "org.eclipse.jdt.ui.A_OpenActionSet",
56 // "org.eclipse.jdt.ui.text.java.actionSet.presentation",
57 // "org.eclipse.jdt.ui.JavaElementCreationActionSet",
58 // "org.eclipse.jdt.ui.CodingActionSet",
59 // "org.eclipse.jdt.ui.SearchActionSet",
60 // "org.eclipse.jdt.debug.ui.JDTDebugActionSet",
61 "org.eclipse.ui.edit.text.actionSet.openExternalFile",
62 // "org.eclipse.debug.ui.profileActionSet"
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
70 * Standard constructor
73 * - the workbench window configurer
75 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer
) {
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
83 public ActionBarAdvisor
createActionBarAdvisor(IActionBarConfigurer configurer
) {
84 return new ApplicationActionBarAdvisor(configurer
);
88 public void preWindowOpen() {
89 IWorkbenchWindowConfigurer configurer
= getWindowConfigurer();
90 configurer
.setShowCoolBar(false);
91 configurer
.setShowStatusLine(true);
92 configurer
.setShowProgressIndicator(true);
96 public void postWindowCreate() {
97 super.postWindowOpen();
98 TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveListener());
99 createDefaultProject();
101 openTraceIfNecessary();
106 private static void openTraceIfNecessary() {
107 String traceToOpen
= TracingRcpPlugin
.getDefault().getCli().getArgument(CliParser
.OPEN_FILE_LOCATION
);
108 if (traceToOpen
!= null) {
109 TmfOpenTraceHelper oth
= new TmfOpenTraceHelper();
111 oth
.openTraceFromPath(TmfCommonConstants
.DEFAULT_TRACE_PROJECT_NAME
, traceToOpen
, TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
112 } catch (CoreException e
) {
113 TracingRcpPlugin
.getDefault().logError(e
.getMessage());
119 // ------------------------------------------------------------------------
121 // ------------------------------------------------------------------------
124 * Hides the unwanted action sets
126 private static void hideActionSets() {
128 IWorkbenchPage page
= TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
130 for (int i
= 0; i
< UNWANTED_ACTION_SET
.length
; i
++) {
131 page
.hideActionSet(UNWANTED_ACTION_SET
[i
]);
135 private static void createDefaultProject() {
136 TmfProjectRegistry
.createProject(TmfCommonConstants
.DEFAULT_TRACE_PROJECT_NAME
, null, new NullProgressMonitor());
140 * A perspective listener implementation
142 * @author Bernd Hufmann
144 public class PerspectiveListener
implements IPerspectiveListener
{
147 * Default Constructor
149 public PerspectiveListener() {
153 public void perspectiveActivated(IWorkbenchPage page
, IPerspectiveDescriptor perspective
) {
154 createDefaultProject();
159 public void perspectiveChanged(IWorkbenchPage page
, IPerspectiveDescriptor perspective
, String changeId
) {