Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-04-24 07:26:06 +0000
committerTobias Schwarz2013-04-24 07:26:06 +0000
commitc800f84412f0d875cda9ff1b8af034eea9393012 (patch)
tree99432d2a0c97c545349d07f1d7ebce3aa05133ed
parent10ad2ed78fd59a676b4b1a644ce81b02fa30275c (diff)
downloadorg.eclipse.tcf-c800f84412f0d875cda9ff1b8af034eea9393012.tar.gz
org.eclipse.tcf-c800f84412f0d875cda9ff1b8af034eea9393012.tar.xz
org.eclipse.tcf-c800f84412f0d875cda9ff1b8af034eea9393012.zip
Target Explorer: add auto save for launch editor tabs
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java144
1 files changed, 107 insertions, 37 deletions
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
index a499f16e1..c0a9310ea 100644
--- 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
@@ -22,6 +22,7 @@ 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.launch.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
/**
@@ -36,37 +37,61 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa
/**
* Get the peer model from the editor input.
+ *
* @param input The editor input.
* @return The peer model.
*/
public IPeerModel getPeerModel(Object input) {
- return (IPeerModel)((IAdaptable)input).getAdapter(IPeerModel.class);
+ return (IPeerModel) ((IAdaptable) input).getAdapter(IPeerModel.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#hasApplyAction()
+ */
+ @Override
+ protected boolean hasApplyAction() {
+ return !isAutoSave();
+ }
+
+ private boolean isAutoSave() {
+ boolean autoSave = !UIPlugin.getDefault().getPreferenceStore().getBoolean("NoLaunchEditorTabAutoSave"); //$NON-NLS-1$
+ return autoSave;
}
/**
* Get the launch configuration from the peer model.
+ *
* @param peerModel The peer model.
* @return The launch configuration.
*/
public static ILaunchConfigurationWorkingCopy getLaunchConfig(final IPeerModel peerModel) {
ILaunchConfigurationWorkingCopy wc = null;
if (peerModel != null) {
- IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class);
+ IPropertiesAccessService service = ServiceManager.getInstance()
+ .getService(peerModel, IPropertiesAccessService.class);
Assert.isNotNull(service);
if (service.getProperty(peerModel, PROP_LAUNCH_CONFIG_WC) instanceof ILaunchConfigurationWorkingCopy) {
- wc = (ILaunchConfigurationWorkingCopy)service.getProperty(peerModel, PROP_LAUNCH_CONFIG_WC);
+ wc = (ILaunchConfigurationWorkingCopy) service
+ .getProperty(peerModel, PROP_LAUNCH_CONFIG_WC);
}
else {
- wc = (ILaunchConfigurationWorkingCopy)Platform.getAdapterManager().getAdapter(peerModel, ILaunchConfigurationWorkingCopy.class);
+ wc = (ILaunchConfigurationWorkingCopy) Platform.getAdapterManager()
+ .getAdapter(peerModel, ILaunchConfigurationWorkingCopy.class);
if (wc == null) {
- wc = (ILaunchConfigurationWorkingCopy)Platform.getAdapterManager().loadAdapter(peerModel, "org.eclipse.debug.core.ILaunchConfigurationWorkingCopy"); //$NON-NLS-1$
+ wc = (ILaunchConfigurationWorkingCopy) Platform
+ .getAdapterManager()
+ .loadAdapter(peerModel, "org.eclipse.debug.core.ILaunchConfigurationWorkingCopy"); //$NON-NLS-1$
}
Assert.isNotNull(wc);
service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, wc);
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(wc, String.class);
+ IPersistenceDelegate delegate = PersistenceManager.getInstance()
+ .getDelegate(wc, String.class);
String launchConfigAttributes = null;
try {
- launchConfigAttributes = delegate != null ? (String)delegate.write(wc, String.class) : null;
+ launchConfigAttributes = delegate != null ? (String) delegate
+ .write(wc, String.class) : null;
}
catch (Exception e) {
/* ignored on purpose */
@@ -77,8 +102,11 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa
return wc;
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#setupData(java.lang.Object)
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#setupData(java.lang
+ * .Object)
*/
@Override
public boolean setupData(Object input) {
@@ -91,18 +119,23 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa
return false;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#extractData()
*/
@Override
public boolean extractData() {
+ if (isAutoSave()) {
+ return false;
+ }
ILaunchConfigurationWorkingCopy wc = getLaunchConfig(getPeerModel(getEditorInput()));
if (wc != null && checkLaunchConfigDirty()) {
getLaunchConfigurationTab().performApply(wc);
try {
wc.doSave();
IPeerModel peerModel = getPeerModel(getEditorInput());
- IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class);
+ IPropertiesAccessService service = ServiceManager.getInstance()
+ .getService(peerModel, IPropertiesAccessService.class);
Assert.isNotNull(service);
service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, null);
checkLaunchConfigDirty();
@@ -115,19 +148,23 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa
}
/**
- * Check if the launch configuration has changed.
- * If it has changed, the page is set dirty.
+ * Check if the launch configuration has changed. If it has changed, the page is set dirty.
+ *
* @return <code>true</code> if the launch configuration 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);
+ 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);
String launchConfigAttributes = null;
try {
- launchConfigAttributes = (String)delegate.write(getLaunchConfig(peerModel), String.class);
+ launchConfigAttributes = (String) delegate
+ .write(getLaunchConfig(peerModel), String.class);
dirty = !launchConfigAttributes.equals(oldLaunchConfigAttributes);
}
catch (Exception e) {
@@ -136,22 +173,42 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa
return dirty;
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#setDirty(boolean)
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#setDirty(boolean)
*/
@Override
public void setDirty(boolean dirty) {
- super.setDirty(dirty);
- ExecutorsUtil.executeInUI(new Runnable() {
- @Override
- public void run() {
- getManagedForm().dirtyStateChanged();
+ if (isAutoSave()) {
+ ILaunchConfigurationWorkingCopy wc = getLaunchConfig(getPeerModel(getEditorInput()));
+ if (wc != null && dirty) {
+ try {
+ wc.doSave();
+ IPeerModel peerModel = getPeerModel(getEditorInput());
+ IPropertiesAccessService service = ServiceManager.getInstance()
+ .getService(peerModel, IPropertiesAccessService.class);
+ service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, null);
+ }
+ catch (Exception e) {
+ }
}
- });
+ }
+ else {
+ super.setDirty(dirty);
+ ExecutorsUtil.executeInUI(new Runnable() {
+ @Override
+ public void run() {
+ getManagedForm().dirtyStateChanged();
+ }
+ });
+ }
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#setActive(boolean)
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.tcf.te.launch.ui.editor.AbstractLaunchTabContainerEditorPage#setActive(boolean)
*/
@Override
public void setActive(boolean active) {
@@ -162,43 +219,56 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa
}
}
- /* (non-Javadoc)
+ /*
+ * (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);
+ 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);
DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(this);
launchConfigListener = null;
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration)
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.
+ * debug.core.ILaunchConfiguration)
*/
@Override
public void launchConfigurationAdded(ILaunchConfiguration configuration) {
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse
+ * .debug.core.ILaunchConfiguration)
*/
@Override
public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration)
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse
+ * .debug.core.ILaunchConfiguration)
*/
@Override
public void launchConfigurationChanged(ILaunchConfiguration configuration) {
if (!(configuration instanceof ILaunchConfigurationWorkingCopy)) {
IPeerModel peerModel = getPeerModel(getEditorInput());
- IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class);
- ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy)service.getProperty(peerModel, PROP_LAUNCH_CONFIG_WC);
+ IPropertiesAccessService service = ServiceManager.getInstance()
+ .getService(peerModel, IPropertiesAccessService.class);
+ ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) service
+ .getProperty(peerModel, PROP_LAUNCH_CONFIG_WC);
if (wc != null && configuration.getName().equals(wc.getName())) {
service.setProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, null);
service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, null);

Back to the top