aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Weninger2011-12-14 12:03:36 (EST)
committerUwe Stieber2011-12-14 12:03:36 (EST)
commitad0fbf0356ebcf5915f21e06f0000c59a7ade181 (patch)
tree964fd07ec7903df4be0390c1a2f6904756f29425
parent98a7fd8ad615bd82dde9a634a840879b1fd3f117 (diff)
downloadorg.eclipse.tcf-ad0fbf0356ebcf5915f21e06f0000c59a7ade181.zip
org.eclipse.tcf-ad0fbf0356ebcf5915f21e06f0000c59a7ade181.tar.gz
org.eclipse.tcf-ad0fbf0356ebcf5915f21e06f0000c59a7ade181.tar.bz2
Target Explorer: Improve SSH and Telnet dialog settings storage
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java111
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java86
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java37
6 files changed, 109 insertions, 133 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF
index f55c86f..c562d51 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF
@@ -17,8 +17,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.tm.terminal.ssh;bundle-version="2.1.0",
org.eclipse.tm.terminal;bundle-version="3.1.1",
org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0",
- org.eclipse.tcf.te.tcf.locator;bundle-version="1.0.0",
- org.eclipse.tcf.core;bundle-version="1.0.0",
org.eclipse.equinox.security;bundle-version="1.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
index b18f268..28b6d14 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
@@ -10,25 +10,18 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.terminals.ssh.controls;
-import java.util.concurrent.atomic.AtomicReference;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.security.storage.ISecurePreferences;
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
import org.eclipse.equinox.security.storage.StorageException;
import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
import org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel;
import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
@@ -67,7 +60,7 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
SshConnector conn = new SshConnector();
sshSettings = (SshSettings) conn.getSshSettings();
- sshSettings.setHost(getHost());
+ sshSettings.setHost(getSelectionHost());
sshSettings.setUser(getDefaultUser());
sshSettingsPage = conn.makeSettingsPage();
sshSettingsPage.createControl(panel);
@@ -99,35 +92,6 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
return System.getProperty("user.name"); //$NON-NLS-1$
}
- /**
- * Returns the host name or IP from the current selection.
- *
- * @return The host name or IP.
- */
- private String getHost() {
- ISelection selection = getSelection();
- final AtomicReference<String> result = new AtomicReference<String>();
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Object element = ((IStructuredSelection) selection).getFirstElement();
- if (element instanceof IPeerModel) {
- final IPeerModel peerModel = (IPeerModel) element;
- if (Protocol.isDispatchThread()) {
- result.set(peerModel.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST));
- }
- else {
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- result.set(peerModel.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST));
- }
- });
- }
- }
- }
-
- return result.get();
- }
-
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#extractData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
*/
@@ -167,28 +131,37 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
*/
@Override
public void doRestoreWidgetValues(IDialogSettings settings, String idPrefix) {
- String host = getHost();
- if (settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_HOST)) != null) {
- sshSettings.setHost(settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_HOST)));
- }
- if (settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_PORT)) != null) {
- sshSettings.setPort(settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_PORT)));
- }
- if (settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_TIMEOUT)) != null) {
- sshSettings.setTimeout(settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_TIMEOUT)));
- }
- if (settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE)) != null) {
- sshSettings.setKeepalive(settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE)));
- }
- if (settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_SSH_USER)) != null) {
- sshSettings.setUser(settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_SSH_USER)));
+ String host = getSelectionHost();
+ if (host != null) {
+ // is there a section for this host
+ IDialogSettings hostSettings = settings.getSection(host);
+ if (hostSettings != null) {
+ if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
+ sshSettings.setHost(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST));
+ }
+ if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_PORT) != null) {
+ sshSettings.setPort(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_PORT));
+ }
+ if (hostSettings.get(ITerminalsConnectorConstants.PROP_TIMEOUT) != null) {
+ sshSettings.setTimeout(hostSettings.get(ITerminalsConnectorConstants.PROP_TIMEOUT));
+ }
+ if (hostSettings.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE) != null) {
+ sshSettings.setKeepalive(hostSettings.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE));
+ }
+ if (hostSettings.get(ITerminalsConnectorConstants.PROP_SSH_USER) != null) {
+ sshSettings.setUser(hostSettings.get(ITerminalsConnectorConstants.PROP_SSH_USER));
+ }
+ String password = accessSecurePassword(sshSettings.getHost());
+ if (password != null) {
+ sshSettings.setPassword(password);
+ }
+ // set settings in page
+ sshSettingsPage.loadSettings();
+ }
}
- String password = accessSecurePassword(sshSettings.getHost());
- if (password != null) {
- sshSettings.setPassword(password);
+ else {
+ // MWE TODO combo for all hosts
}
- // set settings in page
- sshSettingsPage.loadSettings();
}
/* (non-Javadoc)
@@ -199,12 +172,17 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
// make sure the values are saved
// actually not needed since this is done before in extractData
sshSettingsPage.saveSettings();
- String host = getHost();
- settings.put(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_HOST), sshSettings.getHost());
- settings.put(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_PORT), sshSettings.getPort());
- settings.put(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_TIMEOUT), sshSettings.getTimeout());
- settings.put(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE), sshSettings.getKeepalive());
- settings.put(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_SSH_USER), sshSettings.getUser());
+ String host = sshSettings.getHost();
+ IDialogSettings hostSection=settings.getSection(host);
+ if(hostSection==null){
+ hostSection=settings.addNewSection(host);
+ }
+
+ hostSection.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
+ hostSection.put(ITerminalsConnectorConstants.PROP_IP_PORT, sshSettings.getPort());
+ hostSection.put(ITerminalsConnectorConstants.PROP_TIMEOUT, sshSettings.getTimeout());
+ hostSection.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, sshSettings.getKeepalive());
+ hostSection.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
if(sshSettings.getPassword()!=null && sshSettings.getPassword().length()!=0){
saveSecurePassword(host, sshSettings.getPassword());
@@ -212,13 +190,6 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
}
/**
- * Constructs the full settings key.
- */
- private String getSettingsKeyWithPrefix(String host, String value) {
- return host + "." + value; //$NON-NLS-1$
- }
-
- /**
* Save the password to the secure storage.
*
* @param host The host. Must not be <code>null</code>.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF
index 8386a26..ff25a7b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF
@@ -16,8 +16,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.tcf.te.ui.swt;bundle-version="1.0.0",
org.eclipse.tm.terminal;bundle-version="3.1.1",
org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0",
- org.eclipse.tcf.te.tcf.locator;bundle-version="1.0.0",
- org.eclipse.tcf.core;bundle-version="1.0.0",
org.eclipse.equinox.security;bundle-version="1.1.0",
org.eclipse.tm.terminal.telnet;bundle-version="2.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java
index 96ef14d..69efa90 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java
@@ -10,21 +10,14 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.terminals.telnet.controls;
-import java.util.concurrent.atomic.AtomicReference;
-
import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
import org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel;
import org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage;
@@ -64,7 +57,7 @@ public class TelnetWizardConfigurationPanel extends AbstractConfigurationPanel i
TelnetConnector conn = new TelnetConnector();
telnetSettings = (TelnetSettings) conn.getTelnetSettings();
- telnetSettings.setHost(getHost());
+ telnetSettings.setHost(getSelectionHost());
// MWE otherwise we don't get a valid default selection of the combo
telnetSettings.setNetworkPort(NetworkPortMap.PROP_VALUETELNET);
telnetSettingsPage = conn.makeSettingsPage();
@@ -88,35 +81,6 @@ public class TelnetWizardConfigurationPanel extends AbstractConfigurationPanel i
public void setupData(IPropertiesContainer data) {
}
- /**
- * Returns the host name or IP from the current selection.
- *
- * @return The host name or IP.
- */
- private String getHost() {
- ISelection selection = getSelection();
- final AtomicReference<String> result = new AtomicReference<String>();
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Object element = ((IStructuredSelection) selection).getFirstElement();
- if (element instanceof IPeerModel) {
- final IPeerModel peerModel = (IPeerModel) element;
- if (Protocol.isDispatchThread()) {
- result.set(peerModel.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST));
- }
- else {
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- result.set(peerModel.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST));
- }
- });
- }
- }
- }
-
- return result.get();
- }
-
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.wizards.interfaces.ISharedDataWizardPage#extractData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
*/
@@ -153,18 +117,28 @@ public class TelnetWizardConfigurationPanel extends AbstractConfigurationPanel i
*/
@Override
public void doRestoreWidgetValues(IDialogSettings settings, String idPrefix) {
- String host = getHost();
- if (settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_HOST)) != null) {
- telnetSettings.setHost(settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_HOST)));
- }
- if (settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_PORT)) != null) {
- telnetSettings.setNetworkPort(settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_PORT)));
+ String host = getSelectionHost();
+ if (host != null) {
+ // is there a section for this host
+ IDialogSettings hostSettings = settings.getSection(host);
+ if (hostSettings != null) {
+ if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) {
+ telnetSettings.setHost(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST));
+ }
+ if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_PORT) != null) {
+ telnetSettings.setNetworkPort(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_PORT));
+ }
+ if (hostSettings.get(ITerminalsConnectorConstants.PROP_TIMEOUT) != null) {
+ telnetSettings.setTimeout(hostSettings.get(ITerminalsConnectorConstants.PROP_TIMEOUT));
+ }
+
+ // set settings in page
+ telnetSettingsPage.loadSettings();
+ }
}
- if (settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_TIMEOUT)) != null) {
- telnetSettings.setTimeout(settings.get(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_TIMEOUT)));
+ else {
+ // MWE TODO combo for all hosts
}
- // set settings in page
- telnetSettingsPage.loadSettings();
}
/* (non-Javadoc)
@@ -175,17 +149,15 @@ public class TelnetWizardConfigurationPanel extends AbstractConfigurationPanel i
// make sure the values are saved
// actually not needed since this is done before in extractData
telnetSettingsPage.saveSettings();
- String host = getHost();
- settings.put(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_HOST), telnetSettings.getHost());
- settings.put(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_IP_PORT), telnetSettings.getNetworkPort());
- settings.put(getSettingsKeyWithPrefix(host, ITerminalsConnectorConstants.PROP_TIMEOUT), telnetSettings.getTimeout());
- }
- /**
- * Constructs the full settings key.
- */
- private String getSettingsKeyWithPrefix(String host, String value) {
- return host + "." + value; //$NON-NLS-1$
+ String host = telnetSettings.getHost();
+ IDialogSettings hostSection = settings.getSection(host);
+ if (hostSection == null) {
+ hostSection = settings.addNewSection(host);
+ }
+ hostSection.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost());
+ hostSection.put(ITerminalsConnectorConstants.PROP_IP_PORT, telnetSettings.getNetworkPort());
+ hostSection.put(ITerminalsConnectorConstants.PROP_TIMEOUT, telnetSettings.getTimeout());
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF
index 52741df..8d8d81c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF
@@ -18,7 +18,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0",
org.eclipse.tcf.te.ui;bundle-version="1.0.0",
org.eclipse.tcf.te.ui.controls;bundle-version="1.0.0",
- org.eclipse.tcf.te.ui.swt;bundle-version="1.0.0"
+ org.eclipse.tcf.te.ui.swt;bundle-version="1.0.0",
+ org.eclipse.tcf.te.tcf.locator;bundle-version="1.0.0",
+ org.eclipse.tcf.core;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java
index 9160992..90c2d11 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/panels/AbstractConfigurationPanel.java
@@ -9,10 +9,16 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.terminals.panels;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
import org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
/**
* Abstract terminal configuration panel implementation.
@@ -47,4 +53,33 @@ public abstract class AbstractConfigurationPanel extends AbstractWizardConfigura
return selection;
}
+ /**
+ * Returns the host name or IP from the current selection.
+ *
+ * @return The host name or IP.
+ */
+ public String getSelectionHost() {
+ ISelection selection = getSelection();
+ final AtomicReference<String> result = new AtomicReference<String>();
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ Object element = ((IStructuredSelection) selection).getFirstElement();
+ if (element instanceof IPeerModel) {
+ final IPeerModel peerModel = (IPeerModel) element;
+ if (Protocol.isDispatchThread()) {
+ result.set(peerModel.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST));
+ }
+ else {
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result.set(peerModel.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST));
+ }
+ });
+ }
+ }
+ }
+
+ return result.get();
+ }
+
}