1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 07:35:24 +02:00

[226764] Contribute RSE Terminal Subsystem (MontaVista contribution)

This commit is contained in:
Martin Oberhuber 2008-04-16 20:56:41 +00:00
parent 2a01598b6f
commit 1ad1441f00
58 changed files with 3030 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1 @@
bin

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.rse.subsystems.terminals.core</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
#Fri Apr 04 23:25:44 CEST 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3

View file

@ -0,0 +1,23 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.subsystems.terminals.core;singleton:=true
Bundle-Version: 0.1.0.qualifier
Bundle-Activator: org.eclipse.rse.internal.subsystems.terminals.core.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.rse.services;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.subsystems.shells.core;bundle-version="[3.0.0,4.0.0)"
Eclipse-LazyStart: true
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Export-Package: org.eclipse.rse.internal.subsystems.terminals.core;x-internal:=true,
org.eclipse.rse.subsystems.terminals.core;
uses:="org.eclipse.rse.services,
org.eclipse.rse.core.subsystems,
org.eclipse.rse.core.model,
org.eclipse.rse.internal.services.terminals",
org.eclipse.rse.subsystems.terminals.core.elements
Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>June 5, 2007</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
</body>
</html>

View file

@ -0,0 +1,17 @@
###############################################################################
# Copyright (c) 2008 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:
#
###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.properties,\
about.html
src.includes = about.html

View file

@ -0,0 +1,16 @@
################################################################################
# Copyright (c) 2008 MontaVista Software, Inc.
# 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:
# Yu-Fen Kuo - initial API and implementation
################################################################################
# NLS_MESSAGEFORMAT_NONE
# NLS_ENCODING=UTF-8
pluginName = RSE Terminals Core (Incubation)
providerName = Eclipse.org

View file

@ -0,0 +1,87 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.internal.subsystems.terminals.core;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends SystemBasePlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.rse.subsystems.terminals.core";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// make sure that org.eclipse.rse.terminals.ui plugin is loaded
// Decouple from the current Thread
new Thread("terminals.ui adapter loader") { //$NON-NLS-1$
public void run() {
try {
Bundle bundle = Platform
.getBundle("org.eclipse.rse.terminals.ui");
if (bundle != null) {
bundle
.loadClass("org.eclipse.rse.terminals.ui.TerminalServiceHelper");
}
} catch (ClassNotFoundException e) {
logError(e.getLocalizedMessage(), e);
}
}
}.start();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
protected void initializeImageRegistry() {
}
}

View file

@ -0,0 +1,19 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.subsystems.terminals.core;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
public interface ITerminalServiceSubSystem extends ISubSystem {
public void addChild(TerminalElement element);
public void removeChild(TerminalElement element);
}

View file

@ -0,0 +1,23 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.subsystems.terminals.core;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.services.terminals.ITerminalService;
public interface ITerminalServiceSubSystemConfiguration extends
ISubSystemConfiguration {
public ITerminalService getTerminalService(IHost host);
public ITerminalService createTerminalService(IHost host);
}

View file

@ -0,0 +1,136 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.subsystems.terminals.core;
import java.util.ArrayList;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
import org.eclipse.rse.core.events.SystemResourceChangeEvent;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.CommunicationsEvent;
import org.eclipse.rse.core.subsystems.ICommunicationsListener;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.SubSystem;
import org.eclipse.rse.internal.services.terminals.ITerminalService;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
import org.eclipse.swt.widgets.Display;
public final class TerminalServiceSubSystem extends SubSystem implements
ITerminalServiceSubSystem, ICommunicationsListener {
protected ITerminalService _hostService;
private ArrayList children;
public class Refresh implements Runnable {
private TerminalServiceSubSystem _ss;
public Refresh(TerminalServiceSubSystem ss) {
_ss = ss;
}
public void run() {
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
registry.fireEvent(new SystemResourceChangeEvent(_ss,
ISystemResourceChangeEvents.EVENT_REFRESH, _ss));
}
}
protected TerminalServiceSubSystem(IHost host,
IConnectorService connectorService) {
super(host, connectorService);
}
public TerminalServiceSubSystem(IHost host,
IConnectorService connectorService, ITerminalService hostService) {
super(host, connectorService);
_hostService = hostService;
}
public ITerminalService getTerminalService() {
return _hostService;
}
public Class getServiceType() {
return ITerminalService.class;
}
public void addChild(TerminalElement element) {
if (children == null) {
children = new ArrayList();
// if this is first shell, start listening so that on disconnect, we
// persist
getConnectorService().addCommunicationsListener(this);
}
children.add(element);
Display.getDefault().asyncExec(new Refresh(this));
}
public void removeChild(TerminalElement element) {
if (children != null) {
children.remove(element);
}
if (children == null) {
getConnectorService().removeCommunicationsListener(this);
}
Display.getDefault().asyncExec(new Refresh(this));
}
public Object[] getChildren() {
if (children != null)
return children.toArray();
return null;
}
public boolean hasChildren() {
if (children != null && children.size() > 0)
return true;
return false;
}
public void setTerminalService(ITerminalService service) {
_hostService = service;
}
public void communicationsStateChange(CommunicationsEvent e) {
switch (e.getState()) {
case CommunicationsEvent.AFTER_DISCONNECT:
// no longer listen
getConnectorService().removeCommunicationsListener(this);
// if (_cmdShells != null) _cmdShells.clear();
// if (_envVars != null) _envVars.clear();
// _defaultShell = null;
break;
case CommunicationsEvent.BEFORE_DISCONNECT:
case CommunicationsEvent.CONNECTION_ERROR:
// remove all shells
// saveShellState(_cmdShells);
// if (getShells().length > 0)
// {
// Display.getDefault().asyncExec(new CancelAllShells());
// // cancelAllShells();
// }
break;
default:
break;
}
}
public boolean isPassiveCommunicationsListener() {
return true;
}
}

View file

@ -0,0 +1,54 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.subsystems.terminals.core;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.SubSystemConfiguration;
import org.eclipse.rse.internal.services.terminals.ITerminalService;
import org.eclipse.rse.services.IService;
public abstract class TerminalServiceSubSystemConfiguration extends
SubSystemConfiguration implements
ITerminalServiceSubSystemConfiguration {
private Map _services;
protected TerminalServiceSubSystemConfiguration() {
super();
_services = new HashMap();
}
public boolean supportsFilters() {
return false;
}
public final ITerminalService getTerminalService(IHost host) {
ITerminalService service = (ITerminalService) _services.get(host);
if (service == null) {
service = createTerminalService(host);
_services.put(host, service);
}
return service;
}
public final IService getService(IHost host) {
return getTerminalService(host);
}
public Class getServiceType() {
return ITerminalService.class;
}
}

View file

@ -0,0 +1,44 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
* Anna Dushistova (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.subsystems.terminals.core.elements;
import org.eclipse.rse.core.subsystems.AbstractResource;
import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
public class TerminalElement extends AbstractResource {
private String name;
public String getName() {
return name;
}
public TerminalElement(String name,
ITerminalServiceSubSystem terminalServiceSubSystem) {
super(terminalServiceSubSystem);
this.name = name;
}
public String toString() {
return getName();
}
public boolean equals(Object obj) {
if (obj instanceof TerminalElement) {
return name.equals(((TerminalElement) obj).getName());
}
return super.equals(obj);
}
public int hashCode() {
return name.hashCode();
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1 @@
bin

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.rse.subsystems.terminals.ssh</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
#Fri Apr 04 23:26:40 CEST 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3

View file

@ -0,0 +1,19 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.subsystems.terminals.ssh;singleton:=true
Bundle-Version: 0.1.0.qualifier
Bundle-Activator: org.eclipse.rse.subsystems.terminals.ssh.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.rse.services;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.connectorservice.ssh;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.services.ssh;bundle-version="[2.0.0,3.0.0)",
org.eclipse.rse.subsystems.terminals.core;bundle-version="[0.1.0,0.2.0)",
org.eclipse.rse.subsystems.shells.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)"
Eclipse-LazyStart: true
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>June 5, 2007</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
</body>
</html>

View file

@ -0,0 +1,9 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.properties,\
about.html,\
plugin.xml,\
icons/
src.includes = about.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 B

View file

@ -0,0 +1,19 @@
################################################################################
# Copyright (c) 2008 MontaVista Software Inc.
# 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:
# Yu-Fen Kuo - initial API and implementation
################################################################################
# NLS_MESSAGEFORMAT_NONE
# NLS_ENCODING=UTF-8
pluginName = RSE SSH Terminals (Incubation)
providerName = Eclipse.org
SshTerminalSubsystemName=Ssh Terminals
SshTerminalSubsystemDescription=Work with terminals and commands on remote systems using the Secure Shell (ssh) protocol.

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2008 MontaVista Software, Inc.
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:
Yu-Fen Kuo (MontaVista)- initial API and implementation
-->
<?eclipse version="3.1"?>
<plugin>
<extension
point="org.eclipse.rse.core.subsystemConfigurations">
<configuration
category="terminals"
class="org.eclipse.rse.subsystems.terminals.ssh.SshTerminalSubSystemConfiguration"
description="%SshTerminalSubsystemDescription"
icon="icons/full/obj16/terminalcommands_obj.gif"
iconlive="icons/full/obj16/terminalcommandslive_obj.gif"
id="ssh.terminals"
name="%SshTerminalSubsystemName"
priority="300"
serviceType="_ssh._tcp;_sftp-ssh._tcp"
systemTypeIds="org.eclipse.rse.systemtype.linux;org.eclipse.rse.systemtype.unix;org.eclipse.rse.systemtype.aix;org.eclipse.rse.systemtype.ssh"
vendor="%providerName">
</configuration>
</extension>
</plugin>

View file

@ -0,0 +1,62 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.subsystems.terminals.ssh;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.rse.subsystems.terminals.ssh";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista)- initial API and implementation
*******************************************************************************/
package org.eclipse.rse.subsystems.terminals.ssh;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.connectorservice.ssh.SshConnectorService;
import org.eclipse.rse.internal.connectorservice.ssh.SshConnectorServiceManager;
import org.eclipse.rse.internal.services.ssh.ISshService;
import org.eclipse.rse.internal.services.ssh.terminal.SshTerminalService;
import org.eclipse.rse.internal.services.terminals.ITerminalService;
import org.eclipse.rse.subsystems.terminals.core.TerminalServiceSubSystem;
import org.eclipse.rse.subsystems.terminals.core.TerminalServiceSubSystemConfiguration;
public class SshTerminalSubSystemConfiguration extends
TerminalServiceSubSystemConfiguration {
/*
* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#isFactoryFor(java.lang.Class)
*/
public boolean isFactoryFor(Class subSystemType) {
boolean isFor = TerminalServiceSubSystem.class.equals(subSystemType);
return isFor;
}
/**
* Instantiate and return an instance of OUR subsystem. Do not populate it
* yet though!
*
* @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#createSubSystemInternal(IHost)
*/
public ISubSystem createSubSystemInternal(IHost host) {
SshConnectorService connectorService = (SshConnectorService) getConnectorService(host);
ISubSystem subsys = new TerminalServiceSubSystem(host,
connectorService, createTerminalService(host));
return subsys;
}
public ITerminalService createTerminalService(IHost host) {
SshConnectorService cserv = (SshConnectorService) getConnectorService(host);
return new SshTerminalService(cserv);
}
public IConnectorService getConnectorService(IHost host) {
return SshConnectorServiceManager.getInstance().getConnectorService(
host, ISshService.class);
}
public void setConnectorService(IHost host,
IConnectorService connectorService) {
SshConnectorServiceManager.getInstance().setConnectorService(host,
ISshService.class, connectorService);
}
public Class getServiceImplType() {
return ISshService.class;
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1 @@
bin

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.rse.terminals.ui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
#Fri Apr 04 23:28:00 CEST 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3

View file

@ -0,0 +1,25 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.terminals.ui;singleton:=true
Bundle-Version: 0.1.0.qualifier
Bundle-Activator: org.eclipse.rse.internal.terminals.ui.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.rse.services;bundle-version="[3.0.0,4.0.0)",
org.eclipse.ui.views,
org.eclipse.rse.subsystems.files.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.subsystems.shells.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.subsystems.terminals.core;bundle-version="[0.1.0,0.2.0)",
org.eclipse.tm.terminal,
org.eclipse.tm.terminal.view
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Export-Package: org.eclipse.rse.internal.terminals.ui;x-internal:=true,
org.eclipse.rse.internal.terminals.ui.actions;x-internal:=true,
org.eclipse.rse.internal.terminals.ui.configuration.adapter;x-internal:=true,
org.eclipse.rse.internal.terminals.ui.views;x-internal:=true

View file

@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>June 5, 2007</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
</body>
</html>

View file

@ -0,0 +1,9 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
plugin.properties,\
plugin.xml,\
icons/
src.includes = about.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 B

View file

@ -0,0 +1,25 @@
###############################################################################
# Copyright (c) 2008 MontaVista Software, Inc.
# 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:
# Yu-Fen Kuo (MontaVista) - initial API and implementation
###############################################################################
# NLS_MESSAGEFORMAT_NONE
# NLS_ENCODING=UTF-8
pluginName = RSE Terminals UI (Incubation)
providerName = Eclipse.org
view.remoteTerminal=Remote Terminal
PropertyPage.ServerLauncherSettings = Server Launcher Settings
PropertyPage.Service = Service
PropertyPage.EnvVariables = Environment Variables
Launch_Terminal=Launch Terminal
Launch_Terminal_Tooltip=Launch a terminal from the selected directory

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2006, 2008 IBM Corporation 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
Initial Contributors:
The following IBM employees contributed to the Remote System Explorer
component that contains this file: David McKnight, Kushal Munir,
Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
Contributors:
Martin Oberhuber (Wind River) - [180519] declaratively register adapter factories
Yu-Fen Kuo (MontaVista) - [170910] Integrate Terminal with RSE
-->
<?eclipse version="3.2"?>
<plugin>
<extension point="org.eclipse.core.runtime.adapters">
<!-- ITerminalServiceSubSystemConfiguration -->
<factory
class="org.eclipse.rse.internal.terminals.ui.configuration.adapter.TerminalServiceSubSystemConfigurationAdapterFactory"
adaptableType="org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystemConfiguration">
<adapter type="org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter"/>
</factory>
<factory
class="org.eclipse.rse.internal.terminals.ui.views.TerminalViewElementsAdapterFactory"
adaptableType="org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement">
<adapter type="org.eclipse.rse.ui.view.ISystemViewElementAdapter"/>
<adapter type="org.eclipse.rse.core.subsystems.ISystemDragDropAdapter"/>
<adapter type="org.eclipse.rse.ui.view.ISystemRemoteElementAdapter"/>
<adapter type="org.eclipse.ui.views.properties.IPropertySource"/>
<adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
<adapter type="org.eclipse.ui.IActionFilter"/>
</factory>
</extension>
<extension
point="org.eclipse.ui.views">
<view
name="Terminals"
icon="icons/terminal_view.gif"
category="org.eclipse.rse.ui.view"
class="org.eclipse.rse.internal.terminals.ui.views.TerminalViewer"
id="org.eclipse.rse.terminals.ui.view.TerminalView">
</view>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"
id="org.eclipse.rse.terminals.ui.launch">
<visibility>
<and>
<objectState name="isdirectory" value="true"/>
<objectState name="isTerminalSubSystemExists" value="true"/>
</and>
</visibility>
<action
label="Launch Terminal"
icon="icons/terminal_view.gif"
tooltip="%Launch_Terminal_Tooltip"
class="org.eclipse.rse.internal.terminals.ui.actions.LaunchTerminalActionDelegate"
enablesFor="1"
id="org.eclipse.rse.terminalss.ui.actions.LaunchTerminalActionDelegate">
</action>
</objectContribution>
</extension>
</plugin>

View file

@ -0,0 +1,122 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends SystemBasePlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.rse.internal.terminals.ui"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
private ResourceBundle resourceBundle;
public static String ICON_ID_LAUNCH_TERMINAL = "icon_id_launch_terminal"; //$NON-NLS-1$
public static String ICON_ID_TERMINAL_SUBSYSTEM = "icon_id_terminal_subsystem"; //$NON-NLS-1$
public static String ICON_ID_TERMINAL_SUBSYSTEM_LIVE = "icon_id_terminal_subsystem_live"; //$NON-NLS-1$
public static String ICON_ID_REMOVE_TERMINAL = "icon_id_remove_terminal"; //$NON-NLS-1$
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
resourceBundle = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns the string from the plugin's resource bundle, or 'key' if not
* found.
*
* @see java.util.ResourceBundle#getString(String)
*
* @param key
* the key for the desired string
* @return the string for the given key
*/
public static String getResourceString(String key) {
ResourceBundle bundle = Activator.getDefault().getResourceBundle();
try {
return (bundle != null) ? bundle.getString(key) : key;
} catch (MissingResourceException e) {
return key;
}
}
/**
* Return the plugin's Resource bundle.
*
* @return the Resource bundle
*/
public ResourceBundle getResourceBundle() {
try {
if (resourceBundle == null)
resourceBundle = ResourceBundle
.getBundle("org.eclipse.rse.internal.terminals.ui.TerminalUIResources"); //$NON-NLS-1$
} catch (MissingResourceException x) {
resourceBundle = null;
}
return resourceBundle;
}
/**
* Initialize the image registry by declaring all of the required graphics.
*/
protected void initializeImageRegistry() {
String path = getIconPath();
putImageInRegistry(ICON_ID_LAUNCH_TERMINAL, path + "terminal_view.gif"); //$NON-NLS-1$
putImageInRegistry(ICON_ID_TERMINAL_SUBSYSTEM, path
+ "terminalcommands_obj.gif"); //$NON-NLS-1$
putImageInRegistry(ICON_ID_TERMINAL_SUBSYSTEM_LIVE, path
+ "terminalcommandslive_obj.gif"); //$NON-NLS-1$
putImageInRegistry(ICON_ID_REMOVE_TERMINAL, path + "removeterminal.gif"); //$NON-NLS-1$
}
}

View file

@ -0,0 +1,91 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
import org.eclipse.swt.custom.CTabItem;
public class TerminalServiceHelper {
/**
* Constructor for TerminalServiceHelper.
*/
public TerminalServiceHelper() {
super();
}
/**
* Helper method to return the path to change-directory to, given a selected
* remote file object
*/
public static String getWorkingDirectory(IRemoteFile selectedFile) {
String path = null;
if (selectedFile.isDirectory())
path = selectedFile.getAbsolutePath();
else
path = selectedFile.getParentPath();
return path;
}
public static ITerminalServiceSubSystem getTerminalSubSystem(
IHost connection) {
ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
ISubSystem[] subsystems = systemRegistry.getSubSystems(connection);
for (int i = 0; i < subsystems.length; i++) {
if ("ssh.terminals".equals(subsystems[i].getSubSystemConfiguration().getId())) {
ITerminalServiceSubSystem subSystem = (ITerminalServiceSubSystem) subsystems[i];
return subSystem;
}
}
return null;
}
public static ITerminalServiceSubSystem[] getTerminalSubSystems(
IHost connection) {
List results = new ArrayList();
ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
ISubSystem[] subsystems = systemRegistry.getSubSystems(connection);
for (int i = 0; i < subsystems.length; i++) {
if (subsystems[i] instanceof ITerminalServiceSubSystem) {
ITerminalServiceSubSystem subSystem = (ITerminalServiceSubSystem) subsystems[i];
results.add(subSystem);
}
}
return (ITerminalServiceSubSystem[]) results
.toArray(new ITerminalServiceSubSystem[results.size()]);
}
public static TerminalElement createTerminalElement(CTabItem item,
ITerminalServiceSubSystem terminalServiceSubSystem) {
TerminalElement element = new TerminalElement(item.getText(),
terminalServiceSubSystem);
return element;
}
public static void removeTerminalElementFromHost(CTabItem item, IHost host) {
ITerminalServiceSubSystem terminalServiceSubSystem = getTerminalSubSystem(host);
if (terminalServiceSubSystem != null) {
TerminalElement element = new TerminalElement(item.getText(),
terminalServiceSubSystem);
terminalServiceSubSystem.removeChild(element);
}
}
}

View file

@ -0,0 +1,22 @@
################################################################################
# Copyright (c) 2008 MontaVista Software, Inc..
# 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:
# Yu-Fen Kuo (MontaVista) - initial API and implementation
################################################################################
# NLS_MESSAGEFORMAT_VAR
# NLS_ENCODING=UTF-8
LaunchTerminalAction.title=Launch Terminal
LaunchTerminalAction.tooltip=Launch Terminal view
TerminalsUI.cannotOpenView.error=Can not open remote terminals view
RemoveTerminalAction.label=Remove Terminal
RemoveTerminalAction.tooltip=Remove current terminal from terminals view
ShowInTerminalViewAction.label=Show In Terminals View
ShowInTerminalViewAction.tooltip=Show current terminal in Terminals view

View file

@ -0,0 +1,268 @@
/********************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - Fix 154874 - handle files with space or $ in the name
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [174945] Remove obsolete icons from rse.shells.ui
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect()
* Kevin Doyle (IBM) - [187083] Launch Shell action available on folders inside virtual files
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
* Yu-Fen Kuo (MontaVista) - Adapted from SystemCommandAction
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.actions;
import java.util.Iterator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.filters.ISystemFilterReference;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.terminals.ui.Activator;
import org.eclipse.rse.internal.terminals.ui.TerminalServiceHelper;
import org.eclipse.rse.internal.terminals.ui.views.TerminalViewer;
import org.eclipse.rse.internal.terminals.ui.views.TerminalsUI;
import org.eclipse.rse.services.clientserver.PathUtility;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Shell;
/**
* action to launch a terminal from either the terminal subsystem or selected
* directory
*
*/
public class LaunchTerminalAction extends SystemBaseAction {
private ITerminalServiceSubSystem subSystem;
private IRemoteFile selected;
private ISystemFilterReference selectedFilterRef;
public LaunchTerminalAction(String text, ImageDescriptor image, Shell shell) {
super(text, image, shell);
}
/**
* Constructor for LaunchTerminalAction
*
* @param parent
* @param subSystem
* the terminal subsystem to use if launching a terminal
*/
public LaunchTerminalAction(Shell parent,
ITerminalServiceSubSystem subSystem) {
this(Activator.getResourceString("LaunchTerminalAction.title"), //$NON-NLS-1$
Activator.getResourceString("LaunchTerminalAction.tooltip"), //$NON-NLS-1$
parent, subSystem);
}
/**
* Constructor for LaunchTerminalAction
*
* @param title
* title of the action
* @param tooltip
* tooltip of the action
* @param parent
* @param subSystem
* the terminal subsystem to use if launching a terminal
*/
public LaunchTerminalAction(String title, String tooltip, Shell parent,
ITerminalServiceSubSystem subSystem) {
this(title, tooltip, Activator.getDefault().getImageDescriptor(
Activator.ICON_ID_LAUNCH_TERMINAL), parent,
subSystem);
}
/**
* Constructor for LaunchTerminalAction
*
* @param title
* title of the action
* @param tooltip
* tooltip of the action
* @param descriptor
* image descriptor to be displayed for this action
* @param parent
* @param subSystem
* the terminal subsystem to use if launching a terminal
*/
public LaunchTerminalAction(String title, String tooltip,
ImageDescriptor descriptor, Shell parent,
ITerminalServiceSubSystem subSystem) {
super(title, tooltip, descriptor, parent);
this.subSystem = subSystem;
}
/**
* @return the terminal subsystem
*/
public ITerminalServiceSubSystem getSubSystem() {
return subSystem;
}
/**
* settor for the terminal subsystem
*
* @param subSystem
* terminal subsystem
*/
public void setSubSystem(ITerminalServiceSubSystem subSystem) {
this.subSystem = subSystem;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.rse.ui.actions.SystemBaseAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
*/
public boolean updateSelection(IStructuredSelection selection) {
boolean enable = false;
Iterator e = selection.iterator();
Object selectedObject = e.next();
if (selectedObject != null) {
if (selectedObject instanceof ISystemFilterReference) {
selectedFilterRef = (ISystemFilterReference) selectedObject;
selected = null;
enable = true;
}
if (selectedObject instanceof IRemoteFile) {
selected = (IRemoteFile) selectedObject;
selectedFilterRef = null;
IHost host = selected.getParentRemoteFileSubSystem().getHost();
subSystem = TerminalServiceHelper.getTerminalSubSystem(host);
// If the selected object is a virtual folder then we need to
// select the parent
// of the archive
if (ArchiveHandlerManager.isVirtual(selected.getAbsolutePath())) {
IRemoteFileSubSystem rfss = selected
.getParentRemoteFileSubSystem();
String file = selected.getAbsolutePath();
// Get the archive's path
file = file.substring(0, file
.indexOf(ArchiveHandlerManager.VIRTUAL_SEPARATOR));
// Get the parent of the archive's path
file = file.substring(0, file.lastIndexOf(selected
.getSeparator()));
try {
selected = rfss.getRemoteFileObject(file, null);
} catch (SystemMessageException exc) {
}
}
if (!selected.isFile()) {
enable = checkObjectType(selected);
}
} else if (selectedObject instanceof ITerminalServiceSubSystem) {
subSystem = (ITerminalServiceSubSystem) selectedObject;
enable = true;
}
}
return enable;
}
private ITerminalServiceSubSystem getTerminalSubSystem() {
IHost currentHost = null;
if (selectedFilterRef != null) {
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) selectedFilterRef)
.getAdapter(ISystemViewElementAdapter.class);
if (adapter != null) {
ISubSystem ss = adapter.getSubSystem(selectedFilterRef);
if (ss != null) {
currentHost = ss.getHost();
}
}
} else if (selected != null) {
currentHost = selected.getSystemConnection();
}
if (currentHost != null) {
return TerminalServiceHelper.getTerminalSubSystem(currentHost);
}
return getSubSystem();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.rse.ui.actions.SystemBaseAction#run()
*/
public void run() {
if (selectedFilterRef != null) {
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) selectedFilterRef)
.getAdapter(ISystemViewElementAdapter.class);
if (adapter != null) {
ISubSystem ss = adapter.getSubSystem(selectedFilterRef);
if (ss != null) {
Object target = ss.getTargetForFilter(selectedFilterRef);
if (target != null && target instanceof IRemoteFile) {
selected = (IRemoteFile) target;
}
}
}
}
ITerminalServiceSubSystem terminalSubSystem = getTerminalSubSystem();
if (terminalSubSystem != null) {
TerminalsUI terminalsUI = TerminalsUI.getInstance();
TerminalViewer viewer = terminalsUI.activateTerminalsView();
if (!terminalSubSystem.isConnected()) {
try {
terminalSubSystem.connect(new NullProgressMonitor(), false);
} catch (Exception e) {
Activator.logError(e.getLocalizedMessage(), e);
}
}
if (terminalSubSystem.isConnected()) {
CTabItem tab = viewer.getTabFolder().createTabItem(
terminalSubSystem.getHost(), getInitialDirectoryCmd());
TerminalElement element = TerminalServiceHelper
.createTerminalElement(tab, terminalSubSystem);
terminalSubSystem.addChild(element);
}
}
}
private String getInitialDirectoryCmd() {
if (selected == null)
return null;
String path = TerminalServiceHelper.getWorkingDirectory(selected);
String cdCmd = "cd " + PathUtility.enQuoteUnix(path); //$NON-NLS-1$
if (getTerminalSubSystem().getHost().getSystemType().isWindows()) {
cdCmd = "cd /d \"" + path + '\"'; //$NON-NLS-1$
}
return cdCmd + "\r"; //$NON-NLS-1$
}
}

View file

@ -0,0 +1,55 @@
/********************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
* Yu-Fen Kuo (MontaVista) - Adapted from LaunchShellActionDelegate
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.actions.ActionDelegate;
public class LaunchTerminalActionDelegate extends ActionDelegate implements
IActionDelegate {
private LaunchTerminalAction launchTerminalAction;
private ISelection selection;
public void run(IAction action) {
if (launchTerminalAction == null) {
launchTerminalAction = new LaunchTerminalAction(SystemBasePlugin
.getActiveWorkbenchShell(), null);
}
launchTerminalAction.updateSelection((IStructuredSelection) selection);
launchTerminalAction.run();
}
public void runWithEvent(IAction action, Event event) {
super.runWithEvent(action, event);
}
public void selectionChanged(IAction action, ISelection selection) {
super.selectionChanged(action, selection);
this.selection = selection;
}
public LaunchTerminalActionDelegate() {
}
}

View file

@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2004, 2007 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* David McKnight (IBM) - [165680] "Show in Remote Shell View" does not work
* Anna Dushistova (MontaVista) - Adapted from SystemShowInShellViewAction
* Anna Dushistova (MontaVista) - Adapted from ShowInTerminalViewAction
*******************************************************************************/
package org.eclipse.rse.internal.terminals.ui.actions;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.rse.internal.terminals.ui.Activator;
import org.eclipse.rse.internal.terminals.ui.views.TerminalViewer;
import org.eclipse.rse.internal.terminals.ui.views.TerminalsUI;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
import org.eclipse.swt.widgets.Shell;
public class RemoveTerminalAction extends TerminalElementBaseAction {
public RemoveTerminalAction(Shell parent) {
this(Activator.getResourceString("RemoveTerminalAction.label"), //$NON-NLS-1$
Activator.getResourceString("RemoveTerminalAction.tooltip"), //$NON-NLS-1$
Activator.getDefault().getImageDescriptor(
Activator.ICON_ID_REMOVE_TERMINAL), parent);
}
public RemoveTerminalAction(String label, String tooltip,
ImageDescriptor image, Shell parent) {
super(label, tooltip, image, parent);
}
public void run() {
TerminalsUI terminalsUI = TerminalsUI.getInstance();
TerminalViewer viewPart = terminalsUI.activateTerminalsView();
for (int i = 0; i < selected.size(); i++) {
TerminalElement element = (TerminalElement) selected.get(i);
viewPart.getTabFolder().disposePageFor(element.getName());
}
}
}

View file

@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2004, 2007 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* David McKnight (IBM) - [165680] "Show in Remote Shell View" does not work
* Anna Dushistova (MontaVista) - Adapted from SystemShowInShellViewAction
*******************************************************************************/
package org.eclipse.rse.internal.terminals.ui.actions;
import org.eclipse.rse.internal.terminals.ui.Activator;
import org.eclipse.rse.internal.terminals.ui.views.TerminalViewer;
import org.eclipse.rse.internal.terminals.ui.views.TerminalsUI;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
import org.eclipse.swt.widgets.Shell;
public class ShowInTerminalViewAction extends TerminalElementBaseAction {
public ShowInTerminalViewAction(Shell parent) {
super(
Activator.getResourceString("ShowInTerminalViewAction.label"), //$NON-NLS-1$
Activator.getResourceString("ShowInTerminalViewAction.tooltip"), //$NON-NLS-1$
Activator.getDefault().getImageDescriptor(
Activator.ICON_ID_LAUNCH_TERMINAL), parent);
allowOnMultipleSelection(false);
}
/**
* Called when this action is selected from the popup menu.
*/
public void run() {
TerminalsUI terminalsUI = TerminalsUI.getInstance();
TerminalViewer viewPart = terminalsUI.activateTerminalsView();
for (int i = 0; i < selected.size(); i++) {
TerminalElement element = (TerminalElement) selected.get(i);
viewPart.getTabFolder().showPageFor(element.getName());
}
}
}

View file

@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Anna Dushistova (MontaVista) - Adapted from SystemBaseShellAction
* Yu-Fen Kuo (MontaVista) - Adapted from SystemBaseShellAction
*******************************************************************************/
package org.eclipse.rse.internal.terminals.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell;
public abstract class TerminalElementBaseAction extends SystemBaseAction {
protected List selected;
public TerminalElementBaseAction(String name, String tooltip,
ImageDescriptor image, Shell parent) {
super(name, tooltip, image, parent);
setAvailableOffline(true);
allowOnMultipleSelection(true);
selected = new ArrayList();
}
/**
* Called when the selection changes. The selection is checked to make sure
* this action can be performed on the selected object.
*/
public boolean updateSelection(IStructuredSelection selection) {
boolean enable = false;
Iterator e = selection.iterator();
selected.clear();
while (e.hasNext()) {
Object object = e.next();
if (object instanceof TerminalElement) {
if (isApplicable((TerminalElement) object)) {
selected.add(object);
enable = true;
} else {
return false;
}
} else {
return false;
}
}
return enable;
}
protected boolean isApplicable(TerminalElement element) {
return true;
}
}

View file

@ -0,0 +1,94 @@
/********************************************************************************
* Copyright (c) 2006, 2008 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Yu-Fen Kuo (MontaVista) - Adapted from ShellServiceSubSystemConfigurationAdapter
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.configuration.adapter;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.terminals.ui.Activator;
import org.eclipse.rse.internal.terminals.ui.TerminalServiceHelper;
import org.eclipse.rse.internal.terminals.ui.actions.LaunchTerminalAction;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
import org.eclipse.rse.ui.SystemMenuManager;
import org.eclipse.rse.ui.view.SubSystemConfigurationAdapter;
import org.eclipse.swt.widgets.Shell;
public class TerminalServiceSubSystemConfigurationAdapter extends
SubSystemConfigurationAdapter {
protected LaunchTerminalAction terminalAction;
protected ImageDescriptor activeImageDescriptor;
protected ImageDescriptor inactiveImageDescriptor;
public IAction[] getSubSystemActions(SystemMenuManager menu,
IStructuredSelection selection, Shell shell, String menuGroup,
ISubSystemConfiguration factory, ISubSystem selectedSubSystem) {
List allActions = new ArrayList();
IAction[] baseActions = super.getSubSystemActions(menu, selection,
shell, menuGroup, factory, selectedSubSystem);
for (int i = 0; i < baseActions.length; i++) {
allActions.add(baseActions[i]);
}
// launching terminals and finding files
if (selectedSubSystem instanceof IRemoteFileSubSystem) {
IRemoteFileSubSystem fs = (IRemoteFileSubSystem) selectedSubSystem;
ITerminalServiceSubSystem cmdSubSystem = TerminalServiceHelper
.getTerminalSubSystem(fs.getHost());
if (cmdSubSystem != null) {
allActions.add(getTerminalAction(cmdSubSystem, shell));
}
} else if (selectedSubSystem instanceof ITerminalServiceSubSystem) {
allActions.add(getTerminalAction(
(ITerminalServiceSubSystem) selectedSubSystem, shell));
}
return (IAction[]) allActions.toArray(new IAction[allActions.size()]);
}
public IAction getTerminalAction(
ITerminalServiceSubSystem selectedSubSystem, Shell shell) {
if (terminalAction == null) {
terminalAction = new LaunchTerminalAction(shell, selectedSubSystem);
} else {
terminalAction.setSubSystem(selectedSubSystem);
}
return terminalAction;
}
public ImageDescriptor getImage(ISubSystemConfiguration config) {
if (inactiveImageDescriptor == null) {
inactiveImageDescriptor = Activator.getDefault()
.getImageDescriptor(Activator.ICON_ID_TERMINAL_SUBSYSTEM);
}
return inactiveImageDescriptor;
}
public ImageDescriptor getLiveImage(ISubSystemConfiguration config) {
if (activeImageDescriptor == null) {
activeImageDescriptor = Activator.getDefault().getImageDescriptor(
Activator.ICON_ID_TERMINAL_SUBSYSTEM_LIVE);
}
return activeImageDescriptor;
}
}

View file

@ -0,0 +1,47 @@
/********************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - [180519][api] declaratively register adapter factories
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Yu-Fen Kuo (MontaVista) - Adapted from ShellServiceSubSystemConfigurationAdapterFactory
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.configuration.adapter;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.rse.subsystems.terminals.core.TerminalServiceSubSystemConfiguration;
import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
public class TerminalServiceSubSystemConfigurationAdapterFactory implements
IAdapterFactory {
private ISubSystemConfigurationAdapter factoryAdapter;
public TerminalServiceSubSystemConfigurationAdapterFactory() {
super();
factoryAdapter = new TerminalServiceSubSystemConfigurationAdapter();
}
public Object getAdapter(Object adaptableObject, Class adapterType) {
Object adapter = null;
if (adaptableObject instanceof TerminalServiceSubSystemConfiguration)
adapter = factoryAdapter;
return adapter;
}
public Class[] getAdapterList() {
return new Class[] { ISubSystemConfigurationAdapter.class };
}
}

View file

@ -0,0 +1,119 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Anna Dushistova (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.views;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.rse.internal.services.terminals.ITerminalShell;
import org.eclipse.rse.internal.services.terminals.ITerminalService;
import org.eclipse.rse.internal.terminals.ui.TerminalServiceHelper;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
import org.eclipse.rse.subsystems.terminals.core.TerminalServiceSubSystem;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
public class RSETerminalConnectionThread extends Thread {
private final ITerminalControl fControl;
private final RSETerminalConnectorImpl fConn;
private ITerminalShell shell;
public RSETerminalConnectionThread(RSETerminalConnectorImpl conn,
ITerminalControl control) {
super();
fControl = control;
fConn = conn;
fControl.setState(TerminalState.CONNECTING);
}
public void run() {
ITerminalServiceSubSystem subsystem = TerminalServiceHelper
.getTerminalSubSystem(fConn.host);
try {
subsystem.connect(new NullProgressMonitor(), false);
} catch (Exception e1) {
connectFailed(e1.getMessage(), e1.getMessage());
}
try {
if (subsystem instanceof TerminalServiceSubSystem) {
ITerminalService ts = ((TerminalServiceSubSystem) subsystem).getTerminalService();
shell = ts.launchTerminal("ansi", null, null, "/", null, new NullProgressMonitor());
}
fConn.setInputStream(shell.getInputStream());
fConn.setOutputStream(shell.getOutputStream());
} catch (SystemMessageException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
fConn.setTerminalHostShell(shell);
fControl.setState(TerminalState.CONNECTED);
try {
// this is the workaround to delay read data
// otherwise we might end of with race condition to processText
// before dimension is set.
Thread.sleep(500);
// read data until the connection gets terminated
readDataForever(fConn.getInputStream());
} catch (InterruptedIOException e) {
// we got interrupted: we are done...
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
}
// when reading is done, we set the state to closed
fControl.setState(TerminalState.CLOSED);
}
/**
* disconnect the ssh session
*/
void disconnect() {
interrupt();
synchronized (this) {
try {
// do not close the connection
// TerminalServiceHelper.getTerminalSubSystem(fConn.host)
// .disconnect();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* Read the data from the connection and display it in the terminal.
*
* @param in
* @throws IOException
*/
private void readDataForever(InputStream in) throws IOException {
// read the data
byte bytes[] = new byte[32 * 1024];
int n;
// read until the thread gets interrupted....
while ((n = in.read(bytes)) != -1) {
fControl.getRemoteToTerminalOutputStream().write(bytes, 0, n);
}
}
private void connectFailed(String terminalText, String msg) {
Logger.log(terminalText);
fControl.displayTextInTerminal(terminalText);
fControl.setState(TerminalState.CLOSED);
fControl.setMsg(msg);
}
}

View file

@ -0,0 +1,44 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Anna Dushistova (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.views;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
public class RSETerminalConnector extends RSETerminalConnectorImpl implements ITerminalConnector {
public RSETerminalConnector(IHost host) {
super(host);
}
public String getId() {
return "rse_internal_connector"; //$NON-NLS-1$
}
public String getInitializationErrorMessage() {
return null;
}
public String getName() {
return "rse_internal_connector";
}
public boolean isInitialized() {
return true;
}
public Object getAdapter(Class adapterType) {
if (adapterType.isInstance(this))
return this;
return Platform.getAdapterManager().getAdapter(this, adapterType);
}
}

View file

@ -0,0 +1,89 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Anna Dushistova (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.views;
import java.io.InputStream;
import java.io.OutputStream;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.internal.services.terminals.ITerminalShell;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnectorImpl;
public class RSETerminalConnectorImpl extends TerminalConnectorImpl {
private OutputStream fOutputStream;
private InputStream fInputStream;
IHost host;
private RSETerminalConnectionThread fConnection;
private ITerminalShell shell;
public RSETerminalConnectorImpl(IHost host) {
super();
this.host = host;
}
public void connect(ITerminalControl control) {
super.connect(control);
fConnection = new RSETerminalConnectionThread(this, control);
fConnection.start();
}
public void doDisconnect() {
fConnection.disconnect();
if (getInputStream() != null) {
try {
getInputStream().close();
} catch (Exception exception) {
exception.printStackTrace();
}
}
if (getTerminalToRemoteStream() != null) {
try {
getTerminalToRemoteStream().close();
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
public OutputStream getTerminalToRemoteStream() {
return fOutputStream;
}
public String getSettingsSummary() {
return "RSE: " + host.getName();
}
public boolean isLocalEcho() {
return shell.isLocalEcho();
}
public void setTerminalSize(int newWidth, int newHeight) {
shell.setTerminalSize(newWidth, newHeight);
}
public InputStream getInputStream() {
return fInputStream;
}
public void setOutputStream(OutputStream outputStream) {
fOutputStream = outputStream;
}
public void setInputStream(InputStream inputStream) {
fInputStream = inputStream;
}
public void setTerminalHostShell(ITerminalShell shell) {
this.shell = shell;
}
}

View file

@ -0,0 +1,172 @@
/*******************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - [180562] dont implement ISystemOutputRemoteTypes
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [174945] Remove obsolete icons from rse.shells.ui
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [189130] Move SystemIFileProperties from UI to Core
* David McKnight (IBM) - [196842] Don't have open menu for folders
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* David McKnight (IBM) - [189873] Improve remote shell editor open action with background jobs
* David McKnight (IBM) - [216252] [nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
* Xuan Chen (IBM) - [223126] [api][breaking] Remove API related to User Actions in RSE Core/UI
* Yu-Fen Kuo (MontaVista) - Adopted from SystemViewRemoteOutputAdapter
* Anna Dushistova (MontaVista) - Adopted from SystemViewRemoteOutputAdapter
*******************************************************************************/
package org.eclipse.rse.internal.terminals.ui.views;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.internal.terminals.ui.Activator;
import org.eclipse.rse.internal.terminals.ui.actions.RemoveTerminalAction;
import org.eclipse.rse.internal.terminals.ui.actions.ShowInTerminalViewAction;
import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystemConfiguration;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.SystemMenuManager;
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
public class TerminalViewElementAdapter extends AbstractSystemViewAdapter
implements ISystemRemoteElementAdapter {
private List actions = null;
private ShowInTerminalViewAction showInTerminalViewAction;
private RemoveTerminalAction closeTerminalAction;
public TerminalViewElementAdapter() {
actions = new ArrayList();
}
public void addActions(SystemMenuManager menu,
IStructuredSelection selection, Shell parent, String menuGroup) {
Object firstSelection = selection.getFirstElement();
if (firstSelection != null) {
if (firstSelection instanceof TerminalElement) {
TerminalElement cmdShell = (TerminalElement) firstSelection;
if (showInTerminalViewAction == null) {
showInTerminalViewAction = new ShowInTerminalViewAction(
shell);
}
menu.add(ISystemContextMenuConstants.GROUP_OPEN,
showInTerminalViewAction);
getTerminalActions((ITerminalServiceSubSystemConfiguration) cmdShell
.getSubSystem().getSubSystemConfiguration());
menu.add(ISystemContextMenuConstants.GROUP_CHANGE,
closeTerminalAction);
}
} else {
return;
}
}
public List getTerminalActions(ITerminalServiceSubSystemConfiguration factory) {
actions.clear();
if (actions.size() == 0) {
if (closeTerminalAction == null) {
closeTerminalAction = new RemoveTerminalAction(shell);
}
actions.add(closeTerminalAction);
}
return actions;
}
public Object[] getChildren(IAdaptable element, IProgressMonitor monitor) {
return null;
}
public ImageDescriptor getImageDescriptor(Object element) {
// TODO different image for different state?
return Activator.getDefault().getImageDescriptor(
Activator.ICON_ID_TERMINAL_SUBSYSTEM_LIVE);
}
public Object getParent(Object element) {
return null;
}
public String getType(Object element) {
// TODO Auto-generated method stub
return null;
}
public boolean hasChildren(IAdaptable element) {
return false;
}
protected IPropertyDescriptor[] internalGetPropertyDescriptors() {
return null;
}
protected Object internalGetPropertyValue(Object key) {
return null;
}
public String getAbsoluteParentName(Object element) {
return null;
}
public Object getRemoteParent(Object element, IProgressMonitor monitor)
throws Exception {
return null;
}
public String[] getRemoteParentNamesInUse(Object element,
IProgressMonitor monitor) throws Exception {
return null;
}
public boolean refreshRemoteObject(Object oldElement, Object newElement) {
return false;
}
public String getRemoteSubType(Object element) {
return null;
}
public String getRemoteType(Object element) {
return null;
}
public String getRemoteTypeCategory(Object element) {
return null;
}
public String getSubSystemConfigurationId(Object element) {
return null;
}
public String getText(Object element) {
return element.toString();
}
public String getAbsoluteName(Object object) {
return object.toString();
}
}

View file

@ -0,0 +1,49 @@
/********************************************************************************
* Copyright (c) 2008 MontaVista Software, Inc.
* 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:
* Yu-Fen Kuo (MontaVista) - initial API and implementation
* Anna Dushistova (MontaVista) - initial API and implementation
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.views;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.views.properties.IPropertySource;
public class TerminalViewElementsAdapterFactory implements IAdapterFactory {
private TerminalViewElementAdapter elementAdapter = new TerminalViewElementAdapter();
public Object getAdapter(Object adaptableObject, Class adapterType) {
Object adapter = null;
if (adaptableObject instanceof TerminalElement)
adapter = elementAdapter;
if ((adapter != null) && (adapterType == IPropertySource.class)) {
((ISystemViewElementAdapter) adapter)
.setPropertySourceInput(adaptableObject);
} else if (adapter == null) {
SystemBasePlugin
.logWarning("No adapter found for object of type: " + adaptableObject.getClass().getName()); //$NON-NLS-1$
}
return adapter;
}
public Class[] getAdapterList() {
return new Class[] { ISystemViewElementAdapter.class,
ISystemDragDropAdapter.class,
ISystemRemoteElementAdapter.class, IPropertySource.class,
IWorkbenchAdapter.class, IActionFilter.class };
}
}

View file

@ -0,0 +1,451 @@
/*******************************************************************************
* Copyright (c) 2002, 2007 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* David McKnight (IBM) - [165680] "Show in Remote Shell View" does not work
* Yu-Fen Kuo (MontaVista) - Adapted from CommandsViewWorkbook
* Anna Dushistova (MontaVista) - Adapted from CommandsViewWorkbook
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.views;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.internal.terminals.ui.TerminalServiceHelper;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.tm.internal.terminal.actions.TerminalAction;
import org.eclipse.tm.internal.terminal.actions.TerminalActionClearAll;
import org.eclipse.tm.internal.terminal.actions.TerminalActionCopy;
import org.eclipse.tm.internal.terminal.actions.TerminalActionCut;
import org.eclipse.tm.internal.terminal.actions.TerminalActionPaste;
import org.eclipse.tm.internal.terminal.actions.TerminalActionSelectAll;
import org.eclipse.tm.internal.terminal.control.ITerminalListener;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
import org.eclipse.tm.internal.terminal.view.ITerminalView;
/**
* This is the desktop view wrapper of the System View viewer.
*/
public class TerminalViewTab extends Composite implements ITerminalListener,
ITerminalView {
public static String DATA_KEY_CONTROL = "$_control_$"; //$NON-NLS-1$
private CTabFolder tabFolder;
private Menu menu;
private TerminalViewer viewer;
private boolean fMenuAboutToShow;
private TerminalAction fActionEditCopy;
private TerminalAction fActionEditCut;
private TerminalAction fActionEditPaste;
private TerminalAction fActionEditClearAll;
private TerminalAction fActionEditSelectAll;
protected class TerminalContextMenuHandler implements MenuListener,
IMenuListener {
public void menuHidden(MenuEvent event) {
fMenuAboutToShow = false;
updateEditCopy();
}
public void menuShown(MenuEvent e) {
//
}
public void menuAboutToShow(IMenuManager menuMgr) {
fMenuAboutToShow = true;
updateEditCopy();
updateEditCut();
updateEditSelectAll();
updateEditPaste();
updateEditClearAll();
}
}
public TerminalViewTab(final Composite parent, TerminalViewer viewer) {
super(parent, SWT.NONE);
tabFolder = new CTabFolder(this, SWT.NONE);
tabFolder.setLayout(new FillLayout());
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
setLayout(new FillLayout());
this.viewer = viewer;
tabFolder.setBackground(parent.getBackground());
tabFolder.setSimple(false);
tabFolder.setUnselectedImageVisible(false);
tabFolder.setUnselectedCloseVisible(false);
tabFolder.setMinimizeVisible(false);
tabFolder.setMaximizeVisible(false);
setupActions();
}
public void dispose() {
if (!tabFolder.isDisposed()) {
tabFolder.dispose();
}
super.dispose();
}
public CTabFolder getFolder() {
return tabFolder;
}
public void remove(Object root) {
}
public CTabItem getSelectedTab() {
if (tabFolder.getItemCount() > 0) {
int index = tabFolder.getSelectionIndex();
CTabItem item = tabFolder.getItem(index);
return item;
}
return null;
}
public void showCurrentPage() {
tabFolder.setFocus();
}
public void showPageFor(Object root) {
for (int i = 0; i < tabFolder.getItemCount(); i++) {
CTabItem item = tabFolder.getItem(i);
if (item.getData() == root) {
tabFolder.setSelection(item);
}
}
}
public void showPageFor(String tabName) {
for (int i = 0; i < tabFolder.getItemCount(); i++) {
CTabItem item = tabFolder.getItem(i);
if (item.getText().equals(tabName)) {
tabFolder.setSelection(item);
return;
}
}
}
public void disposePageFor(String tabName) {
for (int i = 0; i < tabFolder.getItemCount(); i++) {
CTabItem item = tabFolder.getItem(i);
if (item.getText().equals(tabName)) {
item.dispose();
return;
}
}
}
public CTabItem createTabItem(IAdaptable root, String initialWorkingDirCmd) {
CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
setTabTitle(root, item);
item.setData(root);
Composite c = new Composite(tabFolder, SWT.NONE);
c.setLayout(new FillLayout());
tabFolder.getParent().layout(true);
if (root instanceof IHost) {
IHost host = (IHost) root;
ITerminalConnector connector = new RSETerminalConnector(host);
ITerminalViewControl terminalControl = TerminalViewControlFactory
.makeControl(this, c,
new ITerminalConnector[] { connector });
// TODO https://bugs.eclipse.org/bugs/show_bug.cgi?id=204796
// Specify Encoding for Terminal
// try {
// terminalControl.setEncoding(host.getDefaultEncoding(true));
// } catch (UnsupportedEncodingException e) {
// /* ignore and allow fallback to default encoding */
// }
terminalControl.setConnector(connector);
terminalControl.connectTerminal();
if (initialWorkingDirCmd != null) {
while (!terminalControl.pasteString(initialWorkingDirCmd))
;
}
item.setData(DATA_KEY_CONTROL, terminalControl);
}
item.setControl(c);
tabFolder.setSelection(item);
item.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
Object source = e.getSource();
if (source instanceof CTabItem) {
CTabItem currentItem = (CTabItem) source;
Object data = currentItem.getData(DATA_KEY_CONTROL);
if (data instanceof ITerminalViewControl) {
((ITerminalViewControl) data).disposeTerminal();
}
data = currentItem.getData();
if (data instanceof IHost) {
TerminalServiceHelper.removeTerminalElementFromHost(
currentItem, (IHost) data);
}
}
}
});
setupContextMenus();
return item;
}
protected void setupActions() {
fActionEditCopy = new TerminalActionCopy(this);
fActionEditCut = new TerminalActionCut(this);
fActionEditPaste = new TerminalActionPaste(this);
fActionEditClearAll = new TerminalActionClearAll(this);
fActionEditSelectAll = new TerminalActionSelectAll(this);
}
protected void setupContextMenus() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
if (menu == null) {
MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
menu = menuMgr.createContextMenu(tabFolder);
loadContextMenus(menuMgr);
TerminalContextMenuHandler contextMenuHandler = new TerminalContextMenuHandler();
menuMgr.addMenuListener(contextMenuHandler);
menu.addMenuListener(contextMenuHandler);
}
Control ctlText = terminalViewControl.getControl();
ctlText.setMenu(menu);
}
protected void loadContextMenus(IMenuManager menuMgr) {
menuMgr.add(fActionEditCopy);
menuMgr.add(fActionEditPaste);
menuMgr.add(new Separator());
menuMgr.add(fActionEditClearAll);
menuMgr.add(fActionEditSelectAll);
menuMgr.add(new Separator());
// Other plug-ins can contribute there actions here
menuMgr.add(new Separator("Additions")); //$NON-NLS-1$
}
public void onEditCopy() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
String selection = terminalViewControl.getSelection();
if (!selection.equals("")) {//$NON-NLS-1$
terminalViewControl.copy();
} else {
terminalViewControl.sendKey('\u0003');
}
}
public void updateEditCopy() {
boolean bEnabled = true;
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
if (fMenuAboutToShow) {
bEnabled = terminalViewControl.getSelection().length() > 0;
}
fActionEditCopy.setEnabled(bEnabled);
}
public void onEditCut() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
terminalViewControl.sendKey('\u0018');
}
public void updateEditCut() {
boolean bEnabled;
bEnabled = !fMenuAboutToShow;
fActionEditCut.setEnabled(bEnabled);
}
public void onEditPaste() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
terminalViewControl.paste();
}
public void updateEditPaste() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
String strText = (String) terminalViewControl.getClipboard()
.getContents(TextTransfer.getInstance());
boolean bEnabled = ((strText != null) && (!strText.equals("")));//$NON-NLS-1$
fActionEditPaste.setEnabled(bEnabled);
}
public void onEditClearAll() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
terminalViewControl.clearTerminal();
}
public void updateEditClearAll() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
fActionEditClearAll.setEnabled(!terminalViewControl.isEmpty());
}
public void onEditSelectAll() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
terminalViewControl.selectAll();
}
public void updateEditSelectAll() {
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
if (terminalViewControl == null)
return;
fActionEditSelectAll.setEnabled(!terminalViewControl.isEmpty());
}
private void setTabTitle(IAdaptable root, CTabItem titem) {
ISystemViewElementAdapter va = (ISystemViewElementAdapter) root
.getAdapter(ISystemViewElementAdapter.class);
if (va != null) {
updateWithUniqueTitle(va.getName(root), titem);
titem.setImage(va.getImageDescriptor(root).createImage());
}
}
public void setState(TerminalState state) {
// terminalControl.setState(state);
}
public void setTerminalTitle(String title) {
// TODO Auto-generated method stub
}
public boolean hasCommandInputField() {
// TODO Auto-generated method stub
return false;
}
public boolean isScrollLock() {
// TODO Auto-generated method stub
return false;
}
public void onTerminalConnect() {
// TODO Auto-generated method stub
}
public void onTerminalDisconnect() {
// TODO Auto-generated method stub
}
public void onTerminalFontChanged() {
// TODO Auto-generated method stub
}
public void onTerminalNewTerminal() {
// TODO Auto-generated method stub
}
public void onTerminalSettings() {
// TODO Auto-generated method stub
}
public void setCommandInputField(boolean on) {
// TODO Auto-generated method stub
}
public void setScrollLock(boolean b) {
// TODO Auto-generated method stub
}
private void updateWithUniqueTitle(String title, CTabItem currentItem) {
CTabItem[] items = tabFolder.getItems();
int increment = 1;
String temp = title;
for (int i = 0; i < items.length; i++) {
if (items[i] != currentItem) {
String name = items[i].getText();
if (name != null) {
if (name.equals(temp)) {
temp = title + " " + increment++; //$NON-NLS-1$
}
}
}
}
currentItem.setText(temp);
}
private ITerminalViewControl getCurrentTerminalViewControl() {
if (tabFolder != null && !tabFolder.isDisposed()) {
CTabItem item = tabFolder.getSelection();
if (item != null && !item.isDisposed()) {
Object data = item.getData(DATA_KEY_CONTROL);
if (data instanceof ITerminalViewControl)
return ((ITerminalViewControl) data);
}
}
return null;
}
}

View file

@ -0,0 +1,199 @@
/********************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [174945] Remove obsolete icons from rse.shells.ui
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* David McKnight (IBM) - [165680] "Show in Remote Shell View" does not work
* Kevin Doyle (IBM) - [198534] Shell Menu Enablement Issue's
* Radoslav Gerganov(ProSyst) - [181563] Fix hardcoded Ctrl+Space for remote shell content assist
* Yu-Fen Kuo (MontaVista) - Adapted from SystemCommandsViewPart
* Anna Dushistova (MontaVista) - Adapted from SystemCommandsViewPart
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.views;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
import org.eclipse.rse.core.events.ISystemResourceChangeListener;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.rse.ui.model.ISystemShellProvider;
import org.eclipse.rse.ui.view.IRSEViewPart;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.ViewPart;
public class TerminalViewer extends ViewPart implements ISelectionListener,
SelectionListener, ISelectionChangedListener,
ISystemResourceChangeListener, ISystemShellProvider, IRSEViewPart,
IMenuListener, ISystemMessageLine {
private TerminalViewTab tabFolder;
public static String VIEW_ID = "org.eclipse.rse.terminals.ui.view.TerminalView"; //$NON-NLS-1$
public void createPartControl(Composite parent) {
tabFolder = new TerminalViewTab(parent, this);
tabFolder.getFolder().addSelectionListener(this);
ISelectionService selectionService = getSite().getWorkbenchWindow()
.getSelectionService();
selectionService.addSelectionListener(this);
SystemWidgetHelpers.setHelp(tabFolder, RSEUIPlugin.HELPPREFIX
+ "ucmd0000"); //$NON-NLS-1$
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
registry.addSystemResourceChangeListener(this);
fillLocalToolBar();
}
public void setFocus() {
// TODO Auto-generated method stub
}
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// TODO Auto-generated method stub
}
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
public void widgetSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
public void selectionChanged(SelectionChangedEvent event) {
// TODO Auto-generated method stub
}
public void systemResourceChanged(ISystemResourceChangeEvent event) {
// TODO Auto-generated method stub
}
public Shell getShell() {
// TODO Auto-generated method stub
return null;
}
public Viewer getRSEViewer() {
// TODO Auto-generated method stub
return null;
}
public void menuAboutToShow(IMenuManager manager) {
// TODO Auto-generated method stub
}
public void clearErrorMessage() {
// TODO Auto-generated method stub
}
public void clearMessage() {
// TODO Auto-generated method stub
}
public String getErrorMessage() {
// TODO Auto-generated method stub
return null;
}
public String getMessage() {
// TODO Auto-generated method stub
return null;
}
public SystemMessage getSystemErrorMessage() {
// TODO Auto-generated method stub
return null;
}
public void setErrorMessage(String message) {
// TODO Auto-generated method stub
}
public void setErrorMessage(SystemMessage message) {
// TODO Auto-generated method stub
}
public void setErrorMessage(Throwable exc) {
// TODO Auto-generated method stub
}
public void setMessage(String message) {
// TODO Auto-generated method stub
}
public void setMessage(SystemMessage message) {
// TODO Auto-generated method stub
}
public void fillLocalToolBar() {
if (tabFolder != null) {
// IActionBars actionBars = getViewSite().getActionBars();
//
// if (_shellActions == null || _shellActions.size() == 0)
// {
// updateShellActions();
// _clearAction = new ClearAction();
// _printTableAction = new SystemTablePrintAction(getTitle(), null);
// IMenuManager menuManager = actionBars.getMenuManager();
// addMenuItems(menuManager);
// _statusLine = actionBars.getStatusLineManager();
// }
// IToolBarManager toolBarManager = actionBars.getToolBarManager();
// addToolBarItems(toolBarManager);
//
// updateActionStates();
}
}
public TerminalViewTab getTabFolder() {
return tabFolder;
}
}

View file

@ -0,0 +1,69 @@
/********************************************************************************
* Copyright (c) 2003, 2007 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
* Yu-Fen Kuo (MontaVista) - Adapted from SystemCommandsUI
********************************************************************************/
package org.eclipse.rse.internal.terminals.ui.views;
import org.eclipse.rse.internal.terminals.ui.Activator;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* A singleton class which has handle to the terminals view
*/
public class TerminalsUI {
// singleton instance
private static TerminalsUI instance;
private static TerminalViewer viewer;
private TerminalsUI() {
super();
}
/**
* Get the singleton instance.
*
* @return the singleton object of this type
*/
public static TerminalsUI getInstance() {
if (instance == null) {
instance = new TerminalsUI();
}
return instance;
}
public TerminalViewer activateTerminalsView() {
try {
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
viewer = (TerminalViewer) page.showView(TerminalViewer.VIEW_ID);
page.bringToTop(viewer);
} catch (PartInitException e) {
e.printStackTrace();
Activator.logError(Activator
.getResourceString("TerminalsUI.cannotOpenView.error"), e); //$NON-NLS-1$
}
return viewer;
}
public static TerminalViewer getTerminalsView() {
return viewer;
}
}