Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'terminals/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java')
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java155
1 files changed, 0 insertions, 155 deletions
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java
deleted file mode 100644
index 1ad192c30..000000000
--- a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2015 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.serial.launcher;
-
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.core.terminals.TerminalServiceFactory;
-import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService;
-import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService.Done;
-import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants;
-import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
-import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanelContainer;
-import org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler;
-import org.eclipse.tcf.te.ui.terminals.internal.SettingsStore;
-import org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate;
-import org.eclipse.tcf.te.ui.terminals.serial.controls.SerialConfigurationPanel;
-import org.eclipse.tcf.te.ui.terminals.serial.nls.Messages;
-import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
-import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
-import org.eclipse.tm.internal.terminal.serial.SerialSettings;
-
-/**
- * Serial launcher delegate implementation.
- */
-@SuppressWarnings("restriction")
-public class SerialLauncherDelegate extends AbstractLauncherDelegate {
- // The serial terminal connection memento handler
- private final IMementoHandler mementoHandler = new SerialMementoHandler();
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#needsUserConfiguration()
- */
- @Override
- public boolean needsUserConfiguration() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#getPanel(org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanelContainer)
- */
- @Override
- public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
- return new SerialConfigurationPanel(container);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#execute(java.util.Map, org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService.Done)
- */
- @Override
- public void execute(Map<String, Object> properties, Done done) {
- Assert.isNotNull(properties);
-
- // Set the terminal tab title
- String terminalTitle = getTerminalTitle(properties);
- if (terminalTitle != null) {
- properties.put(ITerminalsConnectorConstants.PROP_TITLE, terminalTitle);
- }
-
- // Get the terminal service
- ITerminalService terminal = TerminalServiceFactory.getService();
- // If not available, we cannot fulfill this request
- if (terminal != null) {
- terminal.openConsole(properties, done);
- }
- }
-
- /**
- * Returns the terminal title string.
- * <p>
- * The default implementation constructs a title like &quot;Serial &lt;port&gt; (Start time) &quot;.
- *
- * @return The terminal title string or <code>null</code>.
- */
- private String getTerminalTitle(Map<String, Object> properties) {
- String device = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DEVICE);
-
- if (device != null) {
- DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
- String date = format.format(new Date(System.currentTimeMillis()));
- return NLS.bind(Messages.SerialLauncherDelegate_terminalTitle, new String[]{device, date});
- }
- return Messages.SerialLauncherDelegate_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);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
- */
- @Override
- public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
- Assert.isNotNull(properties);
-
- // Check for the terminal connector id
- String connectorId = (String)properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
- if (connectorId == null) connectorId = "org.eclipse.tm.internal.terminal.serial.SerialConnector"; //$NON-NLS-1$
-
- String port = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DEVICE);
- String baud = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_BAUD_RATE);
- Object value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
- String timeout = value instanceof Integer ? ((Integer)value).toString() : null;
- String databits = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DATA_BITS);
- String stopbits = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_STOP_BITS);
- String parity = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_PARITY);
- String flowcontrol = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_FLOW_CONTROL);
-
- // Construct the terminal settings store
- ISettingsStore store = new SettingsStore();
-
- // Construct the serial settings
- SerialSettings serialSettings = new SerialSettings();
- serialSettings.setSerialPort(port);
- serialSettings.setBaudRate(baud);
- serialSettings.setTimeout(timeout);
- serialSettings.setDataBits(databits);
- serialSettings.setStopBits(stopbits);
- serialSettings.setParity(parity);
- serialSettings.setFlowControl(flowcontrol);
-
- // And save the settings to the store
- serialSettings.save(store);
-
- // Construct the terminal connector instance
- ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
- if (connector != null) {
- // Apply default settings
- connector.makeSettingsPage();
- // And load the real settings
- connector.load(store);
- }
-
- return connector;
- }
-}

Back to the top