diff options
author | Tobias Schwarz | 2012-07-19 07:45:32 +0000 |
---|---|---|
committer | Uwe Stieber | 2012-07-19 09:15:54 +0000 |
commit | 9d7bcf759ff6cdce47259c4547bcd82ae4d13c46 (patch) | |
tree | c6ddd89f9a4b21c6e5089dd0b3f0c5fe3b563a4c /target_explorer/plugins/org.eclipse.tcf.te.launch.core/src | |
parent | 1588da08dfedec83e025f8a893cc974d03dd0432 (diff) | |
download | org.eclipse.tcf-9d7bcf759ff6cdce47259c4547bcd82ae4d13c46.tar.gz org.eclipse.tcf-9d7bcf759ff6cdce47259c4547bcd82ae4d13c46.tar.xz org.eclipse.tcf-9d7bcf759ff6cdce47259c4547bcd82ae4d13c46.zip |
Target Explorer: ADD update peer when attach launch config changes
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.launch.core/src')
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/activator/CoreBundleActivator.java | 190 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/LaunchConfigurationListenerDelegate.java | 83 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/internal/LaunchConfigurationDelegate.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java) | 3 |
3 files changed, 186 insertions, 90 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/activator/CoreBundleActivator.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/activator/CoreBundleActivator.java index 824fe6ffd..f4606ecb4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/activator/CoreBundleActivator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/activator/CoreBundleActivator.java @@ -1,89 +1,101 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.launch.core.activator;
-
-import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
-import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class CoreBundleActivator implements BundleActivator {
- // The bundle context
- private static BundleContext context;
- // The scoped preferences instance
- private static volatile ScopedEclipsePreferences scopedPreferences;
- // The trace handler instance
- private static volatile TraceHandler traceHandler;
-
- /**
- * Returns the bundle context
- *
- * @return the bundle context
- */
- public static BundleContext getContext() {
- return context;
- }
-
- /**
- * Convenience method which returns the unique identifier of this plugin.
- */
- public static String getUniqueIdentifier() {
- if (getContext() != null && getContext().getBundle() != null) {
- return getContext().getBundle().getSymbolicName();
- }
- return "org.eclipse.tcf.te.launch.core"; //$NON-NLS-1$
- }
-
- /**
- * Return the scoped preferences for this plugin.
- */
- public static ScopedEclipsePreferences getScopedPreferences() {
- if (scopedPreferences == null) {
- scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier());
- }
- return scopedPreferences;
- }
-
- /**
- * Returns the bundles trace handler.
- *
- * @return The bundles trace handler.
- */
- public static TraceHandler getTraceHandler() {
- if (traceHandler == null) {
- traceHandler = new TraceHandler(getUniqueIdentifier());
- }
- return traceHandler;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext bundleContext) throws Exception {
- CoreBundleActivator.context = bundleContext;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext bundleContext) throws Exception {
- CoreBundleActivator.context = null;
- scopedPreferences = null;
- traceHandler = null;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.core.activator; + +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfigurationListener; +import org.eclipse.tcf.te.launch.core.internal.LaunchConfigurationListenerDelegate; +import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences; +import org.eclipse.tcf.te.runtime.tracing.TraceHandler; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class CoreBundleActivator implements BundleActivator { + // The bundle context + private static BundleContext context; + // The scoped preferences instance + private static volatile ScopedEclipsePreferences scopedPreferences; + // The trace handler instance + private static volatile TraceHandler traceHandler; + // The launch config listener to delegate launch config changes to the launch manager delegate + private ILaunchConfigurationListener launchConfigListener; + + + /** + * Returns the bundle context + * + * @return the bundle context + */ + public static BundleContext getContext() { + return context; + } + + /** + * Convenience method which returns the unique identifier of this plugin. + */ + public static String getUniqueIdentifier() { + if (getContext() != null && getContext().getBundle() != null) { + return getContext().getBundle().getSymbolicName(); + } + return "org.eclipse.tcf.te.launch.core"; //$NON-NLS-1$ + } + + /** + * Return the scoped preferences for this plugin. + */ + public static ScopedEclipsePreferences getScopedPreferences() { + if (scopedPreferences == null) { + scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier()); + } + return scopedPreferences; + } + + /** + * Returns the bundles trace handler. + * + * @return The bundles trace handler. + */ + public static TraceHandler getTraceHandler() { + if (traceHandler == null) { + traceHandler = new TraceHandler(getUniqueIdentifier()); + } + return traceHandler; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext bundleContext) throws Exception { + CoreBundleActivator.context = bundleContext; + + launchConfigListener = new LaunchConfigurationListenerDelegate(); + DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(launchConfigListener); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext bundleContext) throws Exception { + CoreBundleActivator.context = null; + scopedPreferences = null; + traceHandler = null; + + DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(launchConfigListener); + launchConfigListener = null; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/LaunchConfigurationListenerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/LaunchConfigurationListenerDelegate.java new file mode 100644 index 000000000..338294ef9 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/LaunchConfigurationListenerDelegate.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.core.internal; + +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationListener; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.tcf.te.launch.core.lm.LaunchManager; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate; + +/** + * LaunchConfigurationListenerDelegate + */ +public class LaunchConfigurationListenerDelegate implements ILaunchConfigurationListener { + + /** + * Constructor. + */ + public LaunchConfigurationListenerDelegate() { + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public void launchConfigurationAdded(ILaunchConfiguration configuration) { + if (configuration instanceof ILaunchConfigurationWorkingCopy) { + return; + } + ILaunchConfigurationListener listener = getListeningDelegate(configuration); + if (listener != null) { + listener.launchConfigurationAdded(configuration); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public void launchConfigurationChanged(ILaunchConfiguration configuration) { + if (configuration instanceof ILaunchConfigurationWorkingCopy) { + return; + } + ILaunchConfigurationListener listener = getListeningDelegate(configuration); + if (listener != null) { + listener.launchConfigurationChanged(configuration); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public void launchConfigurationRemoved(ILaunchConfiguration configuration) { + if (configuration instanceof ILaunchConfigurationWorkingCopy) { + return; + } + ILaunchConfigurationListener listener = getListeningDelegate(configuration); + if (listener != null) { + listener.launchConfigurationRemoved(configuration); + } + } + + private ILaunchConfigurationListener getListeningDelegate(ILaunchConfiguration configuration) { + try { + ILaunchManagerDelegate delegate = LaunchManager.getInstance().getLaunchManagerDelegate(configuration.getType(), ""); //$NON-NLS-1$ + if (delegate instanceof ILaunchConfigurationListener) { + return (ILaunchConfigurationListener)delegate; + } + } + catch (Exception e) { + } + return null; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/internal/LaunchConfigurationDelegate.java index 5612da668..5b3fd9dac 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/delegates/LaunchConfigurationDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/internal/LaunchConfigurationDelegate.java @@ -7,7 +7,7 @@ * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.launch.core.delegates; +package org.eclipse.tcf.te.launch.core.lm.internal; import java.util.ArrayList; import java.util.Date; @@ -36,6 +36,7 @@ import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.osgi.util.NLS; import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator; import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager; +import org.eclipse.tcf.te.launch.core.delegates.Launch; import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem; import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes; import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate; |