diff options
author | Tobias Schwarz | 2012-07-18 06:56:05 +0000 |
---|---|---|
committer | Uwe Stieber | 2012-07-18 07:08:33 +0000 |
commit | b818bd7fa3801c8d25e7f5447567064b10b6756e (patch) | |
tree | 0a01ee1062effe30c5f2912d72f9509cb4e2294f /target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui | |
parent | d1d63a37e70906b8047a95b2225a40f27842b581 (diff) | |
download | org.eclipse.tcf-b818bd7fa3801c8d25e7f5447567064b10b6756e.tar.gz org.eclipse.tcf-b818bd7fa3801c8d25e7f5447567064b10b6756e.tar.xz org.eclipse.tcf-b818bd7fa3801c8d25e7f5447567064b10b6756e.zip |
Target Explorer: ADD launch tab handling in editor
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui')
7 files changed, 250 insertions, 11 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF index 3b580f6c4..6ab958265 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF @@ -29,7 +29,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0", org.eclipse.tcf.te.ui.swt;bundle-version="1.1.0", org.eclipse.tcf.te.ui.views;bundle-version="1.1.0", org.eclipse.tcf.debug.ui;bundle-version="1.1.0", - org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.1.0" + org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.1.0", + org.eclipse.tcf.te.runtime.persistence;bundle-version="1.1.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.properties index 96f35d4d3..fe817d801 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.properties @@ -15,6 +15,7 @@ providerName = Eclipse.org - TCF MemoryMapEditorPage.name=Symbol Files PathMapEditorPage.name=Path Map +SourceLookupEditorPage.name=Source # ***** Command contributions ***** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml index c9e55e800..7c8027bc7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml @@ -123,6 +123,12 @@ name="%PathMapEditorPage.name" id="org.eclipse.tcf.te.tcf.launch.ui.PathMapEditorPage"> </editorPage> + + <editorPage + class="org.eclipse.tcf.te.tcf.launch.ui.editor.SourceLookupEditorPage" + name="%SourceLookupEditorPage.name" + id="org.eclipse.tcf.te.launch.ui.SourceLookupEditorPage"> + </editorPage> </extension> <!-- Editor page binding contributions --> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java new file mode 100644 index 000000000..60a598741 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * 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.tcf.launch.ui.editor; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.tcf.core.AbstractPeer; +import org.eclipse.tcf.core.TransientPeer; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.launch.core.lm.LaunchManager; +import org.eclipse.tcf.te.launch.core.lm.LaunchSpecification; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification; +import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate; +import org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.runtime.persistence.PersistenceManager; +import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate; +import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService; +import org.eclipse.tcf.te.tcf.core.peers.Peer; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.model.Model; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; + +/** + * TCF launch configuration tab container page implementation. + */ +public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLaunchTabContainerEditorPage { + + protected static final String PROP_LAUNCH_CONFIG_WC = "launchConfigWorkingCopy.transient.silent"; //$NON-NLS-1$ + protected static final String PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES = "launchConfigAttributes.transient.silent"; //$NON-NLS-1$ + + /** + * Get the peer model from the editor input. + * @param input The editor input. + * @return The peer model. + */ + IPeerModel getPeerModel(Object input) { + return (IPeerModel)((IAdaptable)input).getAdapter(IPeerModel.class); + } + + /** + * Get the launch configuration from the peer model. + * @param peerModel The peer model. + * @return The launch configuration. + */ + ILaunchConfigurationWorkingCopy getLaunchConfig(final IPeerModel peerModel) { + ILaunchConfigurationWorkingCopy wc = null; + if (peerModel != null) { + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); + if (service != null && service.getProperty(peerModel, PROP_LAUNCH_CONFIG_WC) instanceof ILaunchConfigurationWorkingCopy) { + wc = (ILaunchConfigurationWorkingCopy)service.getProperty(peerModel, PROP_LAUNCH_CONFIG_WC); + } + else { + String launchConfigAttributes = peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_LAUNCH_CONFIG_ATTRIBUTES); + ILaunchSpecification spec = new LaunchSpecification(ILaunchTypes.ATTACH, ILaunchManager.DEBUG_MODE); + LaunchContextsPersistenceDelegate.setLaunchContexts(spec, new IModelNode[]{peerModel}); + try { + wc = LaunchManager.getInstance().getLaunchConfiguration(spec, true).getWorkingCopy(); + LaunchContextsPersistenceDelegate.setLaunchContexts(wc, null); + IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(wc, launchConfigAttributes, false); + if (launchConfigAttributes != null && launchConfigAttributes.trim().length() > 0) { + delegate.read(wc, launchConfigAttributes, null); + } + launchConfigAttributes = (String)delegate.write(wc, String.class, null); + service.setProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, launchConfigAttributes); + service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, wc); + } + catch (Exception e) { + } + } + } + return wc; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#setupData(java.lang.Object) + */ + @Override + public boolean setupData(Object input) { + ILaunchConfigurationWorkingCopy wc = getLaunchConfig(getPeerModel(input)); + if (wc != null) { + getLaunchConfigurationTab().initializeFrom(wc); + checkLaunchConfigDirty(); + return true; + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#extractData() + */ + @Override + public boolean extractData() { + ILaunchConfigurationWorkingCopy wc = getLaunchConfig(getPeerModel(getEditorInput())); + if (wc != null && checkLaunchConfigDirty()) { + getLaunchConfigurationTab().performApply(wc); + IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(wc, String.class, false); + try { + final String launchConfigAttributes = (String)delegate.write(wc, String.class, null); + final IPeerModel peerModel = getPeerModel(getEditorInput()); + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); + service.setProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, launchConfigAttributes); + if (peerModel != null) { + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + IPeer oldPeer = peerModel.getPeer(); + Map<String, String> attributes = new HashMap<String, String>(peerModel.getPeer().getAttributes()); + attributes.put(IPeerModelProperties.PROP_LAUNCH_CONFIG_ATTRIBUTES, launchConfigAttributes); + IPeer newPeer = new Peer(attributes); + if (oldPeer instanceof TransientPeer && !(oldPeer instanceof AbstractPeer || oldPeer instanceof PeerRedirector || oldPeer instanceof Peer)) { + peerModel.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties.PROP_INSTANCE, newPeer); + } else { + Model.getModel().getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerModel, newPeer, false); + } + checkLaunchConfigDirty(); + } + }); + return true; + } + } + catch (Exception e) { + } + } + return false; + } + + /** + * Check if the launch config has changed. + * If it has changed, the page is set dirty. + * @return <code>true</code> if the launch config has changed since last save. + */ + public boolean checkLaunchConfigDirty() { + boolean dirty = false; + IPeerModel peerModel = getPeerModel(getEditorInput()); + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); + String oldLaunchConfigAttributes = (String)service.getProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES); + IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(getLaunchConfig(peerModel), String.class, false); + String launchConfigAttributes = null; + try { + launchConfigAttributes = (String)delegate.write(getLaunchConfig(peerModel), String.class, null); + dirty = !launchConfigAttributes.equals(oldLaunchConfigAttributes); + } + catch (Exception e) { + } + + setDirty(dirty); + getManagedForm().dirtyStateChanged(); + return dirty; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#dispose() + */ + @Override + public void dispose() { + super.dispose(); + IPeerModel peerModel = getPeerModel(getEditorInput()); + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); + service.setProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, null); + service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, null); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/MemoryMapEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/MemoryMapEditorPage.java index 5ccb6e454..5d782681f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/MemoryMapEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/MemoryMapEditorPage.java @@ -11,19 +11,24 @@ package org.eclipse.tcf.te.tcf.launch.ui.editor; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.tcf.internal.debug.ui.launch.TCFMemoryMapTab; -import org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage; /** * TCF memory map launch configuration tab container page implementation. */ -public class MemoryMapEditorPage extends AbstractLaunchTabContainerEditorPage { +public class MemoryMapEditorPage extends AbstractTcfLaunchTabContainerEditorPage { /* (non-Javadoc) * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#createLaunchConfigurationTab() */ - @Override + @Override protected AbstractLaunchConfigurationTab createLaunchConfigurationTab() { - return new TCFMemoryMapTab(); + return new TCFMemoryMapTab() { + @Override + protected void updateLaunchConfigurationDialog() { + super.updateLaunchConfigurationDialog(); + performApply(getLaunchConfig(getPeerModel(getEditorInput()))); + checkLaunchConfigDirty(); + } + }; } - } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java index 79dcd9396..c277b9d5d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java @@ -11,19 +11,24 @@ package org.eclipse.tcf.te.tcf.launch.ui.editor; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.tcf.internal.debug.ui.launch.TCFPathMapTab; -import org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage; /** * TCF path map launch configuration tab container page implementation. */ -public class PathMapEditorPage extends AbstractLaunchTabContainerEditorPage { +public class PathMapEditorPage extends AbstractTcfLaunchTabContainerEditorPage { /* (non-Javadoc) * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#createLaunchConfigurationTab() */ - @Override + @Override protected AbstractLaunchConfigurationTab createLaunchConfigurationTab() { - return new TCFPathMapTab(); + return new TCFPathMapTab() { + @Override + protected void updateLaunchConfigurationDialog() { + super.updateLaunchConfigurationDialog(); + performApply(getLaunchConfig(getPeerModel(getEditorInput()))); + checkLaunchConfigDirty(); + } + }; } - } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/SourceLookupEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/SourceLookupEditorPage.java new file mode 100644 index 000000000..d16a12c8e --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/SourceLookupEditorPage.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.tcf.launch.ui.editor; + +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; + +/** + * Source lookup launch configuration tab container page implementation. + */ +public class SourceLookupEditorPage extends AbstractTcfLaunchTabContainerEditorPage { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#createLaunchConfigurationTab() + */ + @Override + protected AbstractLaunchConfigurationTab createLaunchConfigurationTab() { + return new SourceLookupTab() { + @Override + public void createControl(Composite parent) { + super.createControl(parent); + ((Composite)getControl()).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + } + @Override + protected void updateLaunchConfigurationDialog() { + super.updateLaunchConfigurationDialog(); + performApply(getLaunchConfig(getPeerModel(getEditorInput()))); + checkLaunchConfigDirty(); + } + }; + } +} |