1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 01:05:38 +02:00

[225510][api] Fix OutputRefreshJob API leakage

This commit is contained in:
Martin Oberhuber 2008-04-03 09:45:01 +00:00
parent a7c5de4b79
commit c2d0336a1b
6 changed files with 171 additions and 196 deletions

View file

@ -1,18 +1,18 @@
/********************************************************************************
* Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
* 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
* 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,
* 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) - [186640] Add IRSESystemType.testProperty()
* Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
********************************************************************************/
@ -46,7 +46,7 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
protected IRemoteCmdSubSystem _cmdSubSystem;
protected ArrayList _cmdHistory;
protected IProject _project;
public RemoteCommandShell(IRemoteCmdSubSystem cmdSubSystem)
{
_output = new ArrayList();
@ -61,13 +61,13 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
public String getName()
{
return _name;
return _name;
}
public String getId()
{
{
if (_id == null)
{
IRemoteCmdSubSystem subSystem = getCommandSubSystem();
@ -75,12 +75,12 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
String name = connection.getAliasName();
IRemoteCommandShell[] shells = subSystem.getShells();
List currentNames = new ArrayList();
for (int i = 0; i < shells.length; i++)
{
IRemoteCommandShell shell = shells[i];
if (shell != this)
if (shell != this)
{
// DKM - noticed that this caused a stack overflow in one scenario
if (shell instanceof RemoteCommandShell)
@ -89,7 +89,7 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
}
}
}
if (currentNames.size() > 0)
if (currentNames.size() > 0)
{
int number = 2;
String newName = name + " " + number; //$NON-NLS-1$
@ -180,7 +180,7 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
public IRemoteCmdSubSystem getCommandSubSystem()
{
if (_cmdSubSystem == null)
{
{
if (_fileSubSystem != null)
{
try
@ -190,7 +190,7 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
ISubSystem[] sses = sr.getSubSystems(host);
for (int i = 0; i < sses.length; i++)
{
if (sses[i] instanceof IRemoteCmdSubSystem)
if (sses[i] instanceof IRemoteCmdSubSystem)
{
IRemoteCmdSubSystem cmdSubSystem = (RemoteCmdSubSystem)sses[i];
_cmdSubSystem = cmdSubSystem;
@ -221,7 +221,7 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
public abstract boolean isActive();
public void updateHistory(String cmd)
{
{
/*
String text = cmd;
int tagIndex = text.indexOf("BEGIN-END-TAG");
@ -249,7 +249,7 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
}
return cmds;
}
/**
* Get the current working directory for this command
@ -259,7 +259,7 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
{
return _cwd;
}
/**
* Returns the context of this Shell as a String for persistence.
* The context is typically the current working directory.
@ -275,7 +275,7 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
}
return ""; //$NON-NLS-1$
}
/**
* Get the current working directory for this command
* @return the current working directory
@ -284,38 +284,39 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh
{
return _cwd;
}
/**
* Set the current working directory for this command
* @param file
*
* @param file the working directory.
*/
public void setWorkingDirectory(IRemoteFile file)
{
_cwd = file;
}
protected boolean isWindows()
{
return getCommandSubSystem().getHost().getSystemType().isWindows();
}
/**
* Override to provide a list of possible commands
*/
public abstract ICandidateCommand[] getCandidateCommands();
public void associateProject(IProject project)
{
_project = project;
}
public IProject getAssociatedProject()
{
return _project;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others.
* 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
@ -7,12 +7,12 @@
*
* 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,
* 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:
* {Name} (company) - description of contribution.
* Martin Oberhuber (Wind River) - [225510][api] Fix OutputRefreshJob API leakage
*******************************************************************************/
package org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem;
@ -34,14 +34,14 @@ import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput;
public class ServiceCommandShell extends RemoteCommandShell implements IServiceCommandShell
{
protected IHostShell _hostShell;
protected OutputRefreshJob _lastRefreshJob;
private OutputRefreshJob _lastRefreshJob;
public ServiceCommandShell(IRemoteCmdSubSystem cmdSS, IHostShell hostShell)
{
super(cmdSS);
_hostShell = hostShell;
setType(ShellStrings.RESID_SHELLS_COMMAND_SHELL_LABEL);
}
public String getTitle()
{
return getId();
@ -57,7 +57,7 @@ public class ServiceCommandShell extends RemoteCommandShell implements IServiceC
{
return _hostShell;
}
public void shellOutputChanged(IHostShellChangeEvent event)
@ -75,7 +75,7 @@ public class ServiceCommandShell extends RemoteCommandShell implements IServiceC
String type = event.isError() ? "stderr" : "stdout"; //$NON-NLS-1$ //$NON-NLS-2$
if (event.isError())
{
output = new RemoteError(this, type);
output = new RemoteError(this, type);
}
else
{
@ -83,11 +83,12 @@ public class ServiceCommandShell extends RemoteCommandShell implements IServiceC
}
String str = line.getString();
output.setText(str);
addOutput(output);
outputs[i] = output;
outputs[i] = output;
}
}
// FIXME unify with notifyListeners() below?
if (_lastRefreshJob == null || _lastRefreshJob.isComplete())
{
_lastRefreshJob = new OutputRefreshJob(this, outputs, false);
@ -98,7 +99,26 @@ public class ServiceCommandShell extends RemoteCommandShell implements IServiceC
_lastRefreshJob.addOutputs(outputs);
}
}
/**
* Notify listeners about new outputs. This will update any shell views with
* the new data.
*
* @param outputs the output objects to notify
* @param cwdChanged <code>true</code> if the current directory changed
* @since org.eclipse.rse.subsystems.shells.core 3.0
*/
protected void notifyOutputChanged(IRemoteOutput[] outputs, boolean cwdChanged) {
// if (_lastRefreshJob == null || _lastRefreshJob.isComplete())
{
_lastRefreshJob = new OutputRefreshJob(this, outputs, cwdChanged);
_lastRefreshJob.schedule();
}
/*
* else { _lastRefreshJob.addOutputs(outputs);
* _lastRefreshJob.schedule(); }
*/
}
public ICandidateCommand[] getCandidateCommands()
{

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others.
* 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
@ -7,13 +7,13 @@
*
* 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,
* 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:
* {Name} (company) - description of contribution.
* David McKnight (IBM) - [202822] cleanup output datalements after use
* David McKnight (IBM) - [202822] cleanup output datalements after use
* Martin Oberhuber (Wind River) - [225510][api] Fix OutputRefreshJob API leakage
*******************************************************************************/
package org.eclipse.rse.internal.subsystems.shells.dstore;
@ -26,7 +26,6 @@ import org.eclipse.dstore.extra.IDomainListener;
import org.eclipse.rse.internal.services.dstore.shells.DStoreHostOutput;
import org.eclipse.rse.internal.services.dstore.shells.DStoreHostShell;
import org.eclipse.rse.internal.services.dstore.shells.DStoreShellOutputReader;
import org.eclipse.rse.internal.subsystems.shells.servicesubsystem.OutputRefreshJob;
import org.eclipse.rse.services.shells.IHostOutput;
import org.eclipse.rse.services.shells.IHostShell;
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
@ -45,21 +44,21 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
private DataElement _status;
private DataStore _ds;
private boolean _done = false;
public CleanUpSpirited(DataElement status, String name)
{
_status = status;
_ds = status.getDataStore();
_ds.getDomainNotifier().addDomainListener(this);
}
public void domainChanged(DomainEvent e)
public void domainChanged(DomainEvent e)
{
deleteElements();
}
public void run()
{
{
while (!_done)
{
try
@ -67,12 +66,12 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
Thread.sleep(10000);
}
catch (Exception e)
{
{
}
deleteElements();
}
}
private void deleteElements()
{
if (_status.getNestedSize() > 0)
@ -84,13 +83,13 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
{
// delete
_ds.deleteObjects(_status);
_ds.refresh(_status);
_ds.refresh(_status);
_ds.getDomainNotifier().removeDomainListener(this);
_done = true;
}
}
}
}
}
public Shell getShell() {
@ -103,9 +102,9 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
return true;
return false;
}
}
public DStoreServiceCommandShell(IRemoteCmdSubSystem cmdSS, IHostShell hostShell)
{
super(cmdSS, hostShell);
@ -127,12 +126,12 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
}
}
catch (Exception e)
{
{
}
}
return null;
}
public String getContextString()
{
DStoreHostShell shell = (DStoreHostShell)getHostShell();
@ -155,20 +154,20 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
String src = line.getSource();
if (event.isError())
{
output = new RemoteError(this, type);
output = new RemoteError(this, type);
}
else
{
output = new RemoteOutput(this, type);
}
output.setText(line.getName());
output.setText(line.getName());
int colonSep = src.indexOf(':');
// line numbers
if (colonSep > 0)
{
String lineNo = src.substring(colonSep + 1);
String file = src.substring(0, colonSep);
int linen = 0;
@ -178,7 +177,7 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
}
catch (Exception e)
{
}
if (linen != 0)
{
@ -188,33 +187,22 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
else
{
output.setAbsolutePath(src);
}
}
}
else
{
output.setAbsolutePath(src);
output.setAbsolutePath(src);
}
addOutput(output);
outputs[i] = output;
}
}
//if (_lastRefreshJob == null || _lastRefreshJob.isComplete())
{
_lastRefreshJob = new OutputRefreshJob(this, outputs, false);
_lastRefreshJob.schedule();
}
/*
else
{
_lastRefreshJob.addOutputs(outputs);
_lastRefreshJob.schedule();
}
*/
notifyOutputChanged(outputs, false);
}
public boolean isActive()
public boolean isActive()
{
boolean activeShell = _hostShell.isActive();
if (!activeShell)
@ -223,13 +211,13 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
if (_output.size() < status.getNestedSize())
{
return true;
}
}
}
return activeShell;
}
public void removeOutput()
{
{
DStoreHostShell shell = (DStoreHostShell)getHostShell();
DataElement status = shell.getStatus();
DataStore ds = status.getDataStore();
@ -240,8 +228,8 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
if (!ds.isConnected())
{
status.removeNestedData();
}
else if (status.get(ssize - 1).isSpirit() || !ds.isDoSpirit())
}
else if (status.get(ssize - 1).isSpirit() || !ds.isDoSpirit())
{
// objects can be deleted directly at this point since there will be no more updates from the server
ds.deleteObjects(status);
@ -252,19 +240,19 @@ public class DStoreServiceCommandShell extends ServiceCommandShell
// cleanup later
// objects need to be deleted later since the server will still be sending spirited update
// if we don't defer this, then the deleted elements would get recreated when the spirits are updated
CleanUpSpirited cleanUp = new CleanUpSpirited(status, getId());
CleanUpSpirited cleanUp = new CleanUpSpirited(status, getId());
cleanUp.start();
}
}
synchronized(_output)
{
_output.clear();
_output.clear();
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others.
* 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
@ -7,12 +7,12 @@
*
* 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,
* 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:
* {Name} (company) - description of contribution.
* Martin Oberhuber (Wind River) - [225510][api] Fix OutputRefreshJob API leakage
*******************************************************************************/
package org.eclipse.rse.internal.subsystems.shells.local.model;
@ -22,7 +22,6 @@ import java.io.File;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.subsystems.shells.servicesubsystem.OutputRefreshJob;
import org.eclipse.rse.services.shells.IHostOutput;
import org.eclipse.rse.services.shells.IHostShell;
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
@ -41,7 +40,7 @@ public class LocalServiceCommandShell extends ServiceCommandShell
private Patterns _patterns;
private String _workingDir;
private IRemoteFileSubSystem _fs;
public LocalServiceCommandShell(IRemoteCmdSubSystem cmdSS, IHostShell hostShell)
{
super(cmdSS, hostShell);
@ -67,19 +66,19 @@ public class LocalServiceCommandShell extends ServiceCommandShell
return _fs.getRemoteFileObject(workingDir, new NullProgressMonitor());
}
catch (Exception e)
{
{
}
}
return null;
}
public String getContextString()
{
return _workingDir;
}
public void shellOutputChanged(IHostShellChangeEvent event)
{
IHostOutput[] lines = event.getLines();
@ -88,16 +87,16 @@ public class LocalServiceCommandShell extends ServiceCommandShell
{
String line = lines[i].getString();
ParsedOutput parsedMsg = null;
try
{
parsedMsg = _patterns.matchLine(line);
}
catch (Throwable e)
catch (Throwable e)
{
e.printStackTrace();
}
RemoteOutput output = null;
String type = "stdout"; //$NON-NLS-1$
if (parsedMsg != null)
@ -111,7 +110,7 @@ public class LocalServiceCommandShell extends ServiceCommandShell
if (event.isError())
{
output = new RemoteError(this, type);
}
}
else
{
output = new RemoteOutput(this, type);
@ -119,7 +118,7 @@ public class LocalServiceCommandShell extends ServiceCommandShell
output.setText(line);
if (parsedMsg != null)
{
{
String file = parsedMsg.file;
if (type.equals(ISystemOutputRemoteTypes.TYPE_PROMPT))
{
@ -137,29 +136,18 @@ public class LocalServiceCommandShell extends ServiceCommandShell
output.setAbsolutePath(_workingDir + File.separatorChar + file);
}
}
addOutput(output);
outputs[i] = output;
}
//if (_lastRefreshJob == null || _lastRefreshJob.isComplete())
{
_lastRefreshJob = new OutputRefreshJob(this, outputs, false);
_lastRefreshJob.schedule();
}
/*
else
{
_lastRefreshJob.addOutputs(outputs);
_lastRefreshJob.schedule();
}
*/
notifyOutputChanged(outputs, false);
}
public void writeToShell(String cmd)
{
_patterns.update(cmd);
super.writeToShell(cmd);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others.
* 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
@ -7,12 +7,13 @@
*
* 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,
* 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) - Adapted from LocalServiceCommandShell
* Martin Oberhuber (Wind River) - [225510][api] Fix OutputRefreshJob API leakage
*******************************************************************************/
package org.eclipse.rse.internal.subsystems.shells.ssh;
@ -26,7 +27,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.services.ssh.shell.SshHostShell;
import org.eclipse.rse.internal.subsystems.shells.servicesubsystem.OutputRefreshJob;
import org.eclipse.rse.services.shells.IHostOutput;
import org.eclipse.rse.services.shells.IHostShell;
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
@ -46,7 +46,7 @@ public class SshServiceCommandShell extends ServiceCommandShell
private String _curCommand;
private String _workingDir;
private IRemoteFileSubSystem _fs;
public SshServiceCommandShell(IRemoteCmdSubSystem cmdSS, IHostShell hostShell)
{
super(cmdSS, hostShell);
@ -72,13 +72,13 @@ public class SshServiceCommandShell extends ServiceCommandShell
return _fs.getRemoteFileObject(workingDir, new NullProgressMonitor());
}
catch (Exception e)
{
{
}
}
return null;
}
public String getContextString()
{
return _workingDir;
@ -95,27 +95,27 @@ public class SshServiceCommandShell extends ServiceCommandShell
if (line.endsWith(getPromptCommand())) {
continue; //ignore our synthetic prompt command
}
ParsedOutput parsedMsg = null;
if (!gotCommand && line.equals(_curCommand)) {
gotCommand = true;
continue; //ignore remote command echo
} else {
try {
// Bug 160202: Remote shell dies.
if ((_curCommand == null) || (!_curCommand.trim().equals("ls"))) { //$NON-NLS-1$
parsedMsg = _patterns.matchLine(line);
// Bug 160202: Remote shell dies.
if (_curCommand != null) {
String temp = _curCommand.trim();
StringTokenizer tokenizer = new StringTokenizer(temp);
if (tokenizer.countTokens() == 2) {
String token1 = tokenizer.nextToken();
String token2 = tokenizer.nextToken();
if ((token1.equals("ls")) && (token2.indexOf('-') == 0) && (token2.indexOf('l') > 0)) { //$NON-NLS-1$
if (line.startsWith("total")) { //$NON-NLS-1$
parsedMsg = null;
@ -129,25 +129,25 @@ public class SshServiceCommandShell extends ServiceCommandShell
e.printStackTrace();
}
}
RemoteOutput output = null;
String type = "stdout"; //$NON-NLS-1$
if (parsedMsg != null) {
type = parsedMsg.type;
}
if (event.isError()) {
output = new RemoteError(this, type);
}
}
else {
output = new RemoteOutput(this, type);
}
output.setText(line);
if (parsedMsg != null)
{
{
String file = parsedMsg.file;
if (type.equals(ISystemOutputRemoteTypes.TYPE_PROMPT))
{
@ -164,29 +164,18 @@ public class SshServiceCommandShell extends ServiceCommandShell
output.setAbsolutePath(file);
}
}
addOutput(output);
outputs.add(output);
}
IRemoteOutput[] remoteOutputs = (IRemoteOutput[])outputs.toArray(new IRemoteOutput[outputs.size()]);
//if (_lastRefreshJob == null || _lastRefreshJob.isComplete())
{
_lastRefreshJob = new OutputRefreshJob(this, remoteOutputs, false);
_lastRefreshJob.schedule();
}
/*
else
{
_lastRefreshJob.addOutputs(remoteOutputs);
_lastRefreshJob.schedule();
}
*/
notifyOutputChanged(remoteOutputs, false);
}
/**
* Return the prompt command, such that lines ending with the
* prompt command can be removed from output.
* Should be overridden in case the IHostShell used for this
* Should be overridden in case the IHostShell used for this
* service is not an SshHostShell.
* @return String promptCommand
*/
@ -207,5 +196,5 @@ public class SshServiceCommandShell extends ServiceCommandShell
super.writeToShell(cmd);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others.
* 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
@ -7,13 +7,14 @@
*
* 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,
* 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) - Adapted from LocalServiceCommandShell
* Sheldon D'souza (Celunite) - Adapted from SshServiceCommandShell
* Martin Oberhuber (Wind River) - [225510][api] Fix OutputRefreshJob API leakage
*******************************************************************************/
package org.eclipse.rse.internal.subsystems.shells.telnet;
@ -25,7 +26,6 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.services.telnet.shell.TelnetHostShell;
import org.eclipse.rse.internal.subsystems.shells.servicesubsystem.OutputRefreshJob;
import org.eclipse.rse.services.shells.IHostOutput;
import org.eclipse.rse.services.shells.IHostShell;
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
@ -45,7 +45,7 @@ public class TelnetServiceCommandShell extends ServiceCommandShell {
private String _curCommand;
private String _workingDir;
private IRemoteFileSubSystem _fs;
public TelnetServiceCommandShell(IRemoteCmdSubSystem cmdSS, IHostShell hostShell) {
super(cmdSS, hostShell);
_patterns = new Patterns();
@ -70,7 +70,7 @@ public class TelnetServiceCommandShell extends ServiceCommandShell {
return _fs.getRemoteFileObject(workingDir, new NullProgressMonitor());
}
catch (Exception e)
{
{
}
}
return null;
@ -88,27 +88,27 @@ public class TelnetServiceCommandShell extends ServiceCommandShell {
if (line.endsWith(getPromptCommand())) {
continue; //ignore our synthetic prompt command
}
ParsedOutput parsedMsg = null;
if (!gotCommand && line.equals(_curCommand)) {
gotCommand = true;
continue; //ignore remote command echo
} else {
try {
// Bug 160202: Remote shell dies.
if ((_curCommand == null) || (!_curCommand.trim().equals("ls"))) { //$NON-NLS-1$
parsedMsg = _patterns.matchLine(line);
// Bug 160202: Remote shell dies.
if (_curCommand != null) {
String temp = _curCommand.trim();
StringTokenizer tokenizer = new StringTokenizer(temp);
if (tokenizer.countTokens() == 2) {
String token1 = tokenizer.nextToken();
String token2 = tokenizer.nextToken();
if ((token1.equals("ls")) && (token2.indexOf('-') == 0) && (token2.indexOf('l') > 0)) { //$NON-NLS-1$
if (line.startsWith("total")) { //$NON-NLS-1$
parsedMsg = null;
@ -122,25 +122,25 @@ public class TelnetServiceCommandShell extends ServiceCommandShell {
e.printStackTrace();
}
}
RemoteOutput output = null;
String type = "stdout"; //$NON-NLS-1$
if (parsedMsg != null) {
type = parsedMsg.type;
}
if (event.isError()) {
output = new RemoteError(this, type);
}
}
else {
output = new RemoteOutput(this, type);
}
output.setText(line);
if (parsedMsg != null)
{
{
String file = parsedMsg.file;
if (type.equals(ISystemOutputRemoteTypes.TYPE_PROMPT))
{
@ -157,29 +157,18 @@ public class TelnetServiceCommandShell extends ServiceCommandShell {
output.setAbsolutePath(file);
}
}
addOutput(output);
outputs.add(output);
}
IRemoteOutput[] remoteOutputs = (IRemoteOutput[])outputs.toArray(new IRemoteOutput[outputs.size()]);
//if (_lastRefreshJob == null || _lastRefreshJob.isComplete())
{
_lastRefreshJob = new OutputRefreshJob(this, remoteOutputs, false);
_lastRefreshJob.schedule();
}
/*
else
{
_lastRefreshJob.addOutputs(remoteOutputs);
_lastRefreshJob.schedule();
}
*/
notifyOutputChanged(remoteOutputs, false);
}
/**
* Return the prompt command, such that lines ending with the
* prompt command can be removed from output.
* Should be overridden in case the IHostShell used for this
* Should be overridden in case the IHostShell used for this
* service is not an TelnetHostShell.
* @return String promptCommand
*/