tmf/lttng: Update 2014 copyrights
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tracing.rcp.ui / src / org / eclipse / linuxtools / internal / tracing / rcp / ui / ApplicationWorkbenchWindowAdvisor.java
1 /**********************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.internal.tracing.rcp.ui;
13
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;
27
28 /**
29 * The WorkbenchAdvisor implementation of the LTTng RCP.
30 *
31 * @author Bernd Hufmann
32 */
33 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
34
35 // ------------------------------------------------------------------------
36 // Constants
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"
63 };
64
65 // ------------------------------------------------------------------------
66 // Constructors
67 // ------------------------------------------------------------------------
68
69 /**
70 * Standard constructor
71 *
72 * @param configurer
73 * - the workbench window configurer
74 */
75 public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
76 super(configurer);
77 }
78
79 // ------------------------------------------------------------------------
80 // Operations
81 // ------------------------------------------------------------------------
82 @Override
83 public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
84 return new ApplicationActionBarAdvisor(configurer);
85 }
86
87 @Override
88 public void preWindowOpen() {
89 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
90 configurer.setShowCoolBar(false);
91 configurer.setShowStatusLine(true);
92 configurer.setShowProgressIndicator(true);
93 }
94
95 @Override
96 public void postWindowCreate() {
97 super.postWindowOpen();
98 TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new PerspectiveListener());
99 createDefaultProject();
100 hideActionSets();
101 openTraceIfNecessary();
102 }
103
104
105
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();
110 try {
111 oth.openTraceFromPath(TmfCommonConstants.DEFAULT_TRACE_PROJECT_NAME, traceToOpen, TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
112 } catch (CoreException e) {
113 TracingRcpPlugin.getDefault().logError(e.getMessage());
114 }
115
116 }
117 }
118
119 // ------------------------------------------------------------------------
120 // Helper methods
121 // ------------------------------------------------------------------------
122
123 /**
124 * Hides the unwanted action sets
125 */
126 private static void hideActionSets() {
127
128 IWorkbenchPage page = TracingRcpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
129
130 for (int i = 0; i < UNWANTED_ACTION_SET.length; i++) {
131 page.hideActionSet(UNWANTED_ACTION_SET[i]);
132 }
133 }
134
135 private static void createDefaultProject() {
136 TmfProjectRegistry.createProject(TmfCommonConstants.DEFAULT_TRACE_PROJECT_NAME, null, new NullProgressMonitor());
137 }
138
139 /**
140 * A perspective listener implementation
141 *
142 * @author Bernd Hufmann
143 */
144 public class PerspectiveListener implements IPerspectiveListener {
145
146 /**
147 * Default Constructor
148 */
149 public PerspectiveListener() {
150 }
151
152 @Override
153 public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
154 createDefaultProject();
155 hideActionSets();
156 }
157
158 @Override
159 public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
160 }
161 }
162
163 }
This page took 0.03572 seconds and 6 git commands to generate.