Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-08-20 04:59:00 -0400
committerUwe Stieber2012-08-20 04:59:00 -0400
commit5805635f20351911621d573dbc9f65178398d678 (patch)
tree860e68834aa95fc19d63aa73619f59ded557af2e /target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet
parenta8145734a84329786a04ea82c172089a71a7f293 (diff)
downloadorg.eclipse.tcf-5805635f20351911621d573dbc9f65178398d678.tar.gz
org.eclipse.tcf-5805635f20351911621d573dbc9f65178398d678.tar.xz
org.eclipse.tcf-5805635f20351911621d573dbc9f65178398d678.zip
Target Explorer: Bug 379391 - [Terminal] Open Terminal sessions should be restored after quit / restart
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetMementoHandler.java53
2 files changed, 67 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java
index 392bf6a67..295bfb865 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java
@@ -22,6 +22,7 @@ import org.eclipse.tcf.te.runtime.services.interfaces.ITerminalService;
import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
+import org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler;
import org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate;
import org.eclipse.tcf.te.ui.terminals.telnet.controls.TelnetWizardConfigurationPanel;
import org.eclipse.tcf.te.ui.terminals.telnet.nls.Messages;
@@ -30,6 +31,8 @@ import org.eclipse.tcf.te.ui.terminals.telnet.nls.Messages;
* Telnet launcher delegate implementation.
*/
public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
+ // The Telnet terminal connection memento handler
+ private final IMementoHandler mementoHandler = new TelnetMementoHandler();
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#needsUserConfiguration()
@@ -91,4 +94,15 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
}
return Messages.TelnetLauncherDelegate_terminalTitle_default;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (IMementoHandler.class.equals(adapter)) {
+ return mementoHandler;
+ }
+ return super.getAdapter(adapter);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetMementoHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetMementoHandler.java
new file mode 100644
index 000000000..124fc8b7d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetMementoHandler.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.ui.terminals.telnet.launcher;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
+import org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler;
+import org.eclipse.ui.IMemento;
+
+/**
+ * Telnet terminal connection memento handler implementation.
+ */
+public class TelnetMementoHandler implements IMementoHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler#saveState(org.eclipse.ui.IMemento, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void saveState(IMemento memento, IPropertiesContainer properties) {
+ Assert.isNotNull(memento);
+ Assert.isNotNull(properties);
+
+ // Do not write the terminal title to the memento -> needs to
+ // be recreated at the time of restoration.
+ memento.putString(ITerminalsConnectorConstants.PROP_IP_HOST, properties.getStringProperty(ITerminalsConnectorConstants.PROP_IP_HOST));
+ memento.putString(ITerminalsConnectorConstants.PROP_IP_PORT, properties.getStringProperty(ITerminalsConnectorConstants.PROP_IP_PORT));
+ memento.putInteger(ITerminalsConnectorConstants.PROP_TIMEOUT, properties.getIntProperty(ITerminalsConnectorConstants.PROP_TIMEOUT));
+ memento.putString(ITerminalsConnectorConstants.PROP_ENCODING, properties.getStringProperty(ITerminalsConnectorConstants.PROP_ENCODING));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler#restoreState(org.eclipse.ui.IMemento, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void restoreState(IMemento memento, IPropertiesContainer properties) {
+ Assert.isNotNull(memento);
+ Assert.isNotNull(properties);
+
+ // Restore the terminal properties from the memento
+ properties.setProperty(ITerminalsConnectorConstants.PROP_IP_HOST, memento.getString(ITerminalsConnectorConstants.PROP_IP_HOST));
+ properties.setProperty(ITerminalsConnectorConstants.PROP_IP_PORT, memento.getString(ITerminalsConnectorConstants.PROP_IP_PORT));
+ properties.setProperty(ITerminalsConnectorConstants.PROP_TIMEOUT, memento.getInteger(ITerminalsConnectorConstants.PROP_TIMEOUT));
+ properties.setProperty(ITerminalsConnectorConstants.PROP_ENCODING, memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
+ }
+}

Back to the top