Bug 453499: Allow for programmatically adding a connection to the
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / Workaround_Bug449362.java
CommitLineData
b732adaa
MS
1/*******************************************************************************
2 * Copyright (c) 2014 Wind River Systems, Inc. and others
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 * Markus Schorn - Initial API and implementation
11 *******************************************************************************/
12package org.eclipse.tracecompass.internal.lttng2.control.ui.views;
13
14import org.eclipse.core.runtime.CoreException;
15import org.eclipse.core.runtime.IConfigurationElement;
16import org.eclipse.core.runtime.IExtensionPoint;
17import org.eclipse.core.runtime.Platform;
65e28a02 18import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
b732adaa
MS
19import org.eclipse.ui.IStartup;
20
21/**
22 * Collection of workarounds needed for dealing with the RSE adapter.
23 */
cf9fcae0 24public class Workaround_Bug449362 {
b732adaa
MS
25
26 private static final String RSE_ADAPTER_ID = "org.eclipse.ptp.remote.RSERemoteServices"; //$NON-NLS-1$
27
28 private static boolean fTriggeredRSEStartup = false;
29
65e28a02
MK
30 private Workaround_Bug449362() {
31 // utility class
32 }
33
b732adaa
MS
34 /**
35 * Trigger the startup of RSE, if necessary.
65e28a02
MK
36 *
37 * @param adapterID
38 * the id of the adapter that will be initialized
39 * @return <code>false</code> if the startup cannot be triggered, although
40 * it should be.
b732adaa
MS
41 */
42 public static boolean triggerRSEStartup(String adapterID) {
43 if (fTriggeredRSEStartup || !RSE_ADAPTER_ID.equals(adapterID)) {
44 return true;
45 }
46
47 IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.ui.startup"); //$NON-NLS-1$
48 if (ep == null) {
49 return false;
50 }
51 for (IConfigurationElement elem : ep.getConfigurationElements()) {
52 String clazz = elem.getAttribute("class"); //$NON-NLS-1$
53 if (clazz != null && clazz.endsWith("RSEUIStartup")) { //$NON-NLS-1$
54 try {
55 Object ext = elem.createExecutableExtension("class"); //$NON-NLS-1$
56 if (ext instanceof IStartup) {
57 ((IStartup) ext).earlyStartup();
58 fTriggeredRSEStartup = true;
59 return true;
60 }
61 } catch (CoreException e) {
65e28a02 62 Activator.getDefault().logError(e.getMessage(), e);
b732adaa
MS
63 }
64 }
65 }
66 return false;
67 }
68
69}
This page took 0.030735 seconds and 5 git commands to generate.