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
.tracecompass
.internal
.tracing
.rcp
.ui
;
14 import org
.eclipse
.core
.resources
.IProject
;
15 import org
.eclipse
.core
.runtime
.CoreException
;
16 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
17 import org
.eclipse
.tracecompass
.internal
.tracing
.rcp
.ui
.cli
.CliParser
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.TmfCommonConstants
;
19 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
20 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
21 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceFolder
;
22 import org
.eclipse
.ui
.IPerspectiveDescriptor
;
23 import org
.eclipse
.ui
.IPerspectiveListener
;
24 import org
.eclipse
.ui
.IWorkbenchPage
;
25 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
26 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
27 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
28 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
31 * The WorkbenchAdvisor implementation of the LTTng RCP.
33 * @author Bernd Hufmann
35 public class ApplicationWorkbenchWindowAdvisor
extends WorkbenchWindowAdvisor
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
40 @SuppressWarnings("nls")
41 private static final String
[] UNWANTED_ACTION_SET
= {
42 "org.eclipse.search.searchActionSet",
43 "org.eclipse.rse.core.search.searchActionSet",
44 "org.eclipse.debug.ui.launchActionSet",
45 "org.eclipse.debug.ui.debugActionSet",
46 "org.eclipse.debug.ui.breakpointActionSet",
47 "org.eclipse.team.ui",
48 "org.eclipse.ui.externaltools.ExternalToolsSet",
49 // "org.eclipse.update.ui.softwareUpdates",
50 // "org.eclipse.ui.edit.text.actionSet.navigation",
51 // "org.eclipse.ui.actionSet.keyBindings",
52 // "org.eclipse.ui.edit.text.actionSet.navigation",
53 "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
54 // "org.eclipse.ui.edit.text.actionSet.annotationNavigation",
55 // "org.eclipse.ui.NavigateActionSet",
56 // "org.eclipse.jdt.ui.JavaActionSet",
57 // "org.eclipse.jdt.ui.A_OpenActionSet",
58 // "org.eclipse.jdt.ui.text.java.actionSet.presentation",
59 // "org.eclipse.jdt.ui.JavaElementCreationActionSet",
60 // "org.eclipse.jdt.ui.CodingActionSet",
61 // "org.eclipse.jdt.ui.SearchActionSet",
62 // "org.eclipse.jdt.debug.ui.JDTDebugActionSet",
63 "org.eclipse.ui.edit.text.actionSet.openExternalFile",
64 // "org.eclipse.debug.ui.profileActionSet"
67 // ------------------------------------------------------------------------
69 // ------------------------------------------------------------------------
72 * Standard constructor
75 * - the workbench window configurer
77 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer
) {
81 // ------------------------------------------------------------------------
83 // ------------------------------------------------------------------------
85 public ActionBarAdvisor
createActionBarAdvisor(IActionBarConfigurer configurer
) {
86 return new ApplicationActionBarAdvisor(configurer
);
90 public void preWindowOpen() {
91 IWorkbenchWindowConfigurer configurer
= getWindowConfigurer();
92 configurer
.setShowCoolBar(false);
93 configurer
.setShowStatusLine(true);
94 configurer
.setShowProgressIndicator(true);
98 public void postWindowCreate() {
99 super.postWindowOpen();
100 TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveListener());
101 IProject defaultProject
= createDefaultProject();
103 openTraceIfNecessary(defaultProject
);
108 private static void openTraceIfNecessary(IProject project
) {
109 String traceToOpen
= TracingRcpPlugin
.getDefault().getCli().getArgument(CliParser
.OPEN_FILE_LOCATION
);
110 if (traceToOpen
!= null) {
112 TmfTraceFolder destinationFolder
= TmfProjectRegistry
.getProject(project
, true).getTracesFolder();
113 TmfOpenTraceHelper
.openTraceFromPath(destinationFolder
, traceToOpen
, TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
114 } catch (CoreException e
) {
115 TracingRcpPlugin
.getDefault().logError(e
.getMessage());
121 // ------------------------------------------------------------------------
123 // ------------------------------------------------------------------------
126 * Hides the unwanted action sets
128 private static void hideActionSets() {
130 IWorkbenchPage page
= TracingRcpPlugin
.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
132 for (int i
= 0; i
< UNWANTED_ACTION_SET
.length
; i
++) {
133 page
.hideActionSet(UNWANTED_ACTION_SET
[i
]);
137 private static IProject
createDefaultProject() {
138 return TmfProjectRegistry
.createProject(TmfCommonConstants
.DEFAULT_TRACE_PROJECT_NAME
, null, new NullProgressMonitor());
142 * A perspective listener implementation
144 * @author Bernd Hufmann
146 public class PerspectiveListener
implements IPerspectiveListener
{
149 * Default Constructor
151 public PerspectiveListener() {
155 public void perspectiveActivated(IWorkbenchPage page
, IPerspectiveDescriptor perspective
) {
156 createDefaultProject();
161 public void perspectiveChanged(IWorkbenchPage page
, IPerspectiveDescriptor perspective
, String changeId
) {