1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Bug 577097: Format all o.e.remote code to CDT standard

This is applying the per-project code formatting rules that would
be applied on save in the JDT editor

See also Bug 540373

Change-Id: Ie93f9b640d0f0cfce8711e72fabc87f6a89634fa
This commit is contained in:
Jonah Graham 2021-12-14 13:49:04 -05:00
parent 8980b1f104
commit 3e9dadd642
178 changed files with 2219 additions and 2134 deletions

View file

@ -55,8 +55,7 @@ public abstract class ConsoleAction extends Action {
* @param enabled
* the enabled state for this action
*/
protected void setupAction(String text, String tooltip,
String image, String enabledImage, String disabledImage,
protected void setupAction(String text, String tooltip, String image, String enabledImage, String disabledImage,
boolean enabled) {
ImageRegistry imageRegistry = Activator.getDefault().getImageRegistry();
setupAction(text, tooltip, image, enabledImage, disabledImage, enabled, imageRegistry);
@ -78,15 +77,10 @@ public abstract class ConsoleAction extends Action {
* @param imageRegistry
* the ImageRegistry to retrieve ImageDescriptor for the keys provided
*/
protected void setupAction(String text, String tooltip,
String hoverImage, String enabledImage, String disabledImage,
boolean enabled, ImageRegistry imageRegistry) {
setupAction(text,
tooltip,
imageRegistry.getDescriptor(hoverImage),
imageRegistry.getDescriptor(enabledImage),
imageRegistry.getDescriptor(disabledImage),
enabled);
protected void setupAction(String text, String tooltip, String hoverImage, String enabledImage,
String disabledImage, boolean enabled, ImageRegistry imageRegistry) {
setupAction(text, tooltip, imageRegistry.getDescriptor(hoverImage), imageRegistry.getDescriptor(enabledImage),
imageRegistry.getDescriptor(disabledImage), enabled);
}
/**
@ -103,9 +97,8 @@ public abstract class ConsoleAction extends Action {
* @param enabled
* the enabled state for this action
*/
protected void setupAction(String text, String tooltip,
ImageDescriptor hoverImage, ImageDescriptor enabledImage, ImageDescriptor disabledImage,
boolean enabled) {
protected void setupAction(String text, String tooltip, ImageDescriptor hoverImage, ImageDescriptor enabledImage,
ImageDescriptor disabledImage, boolean enabled) {
setText(text);
setToolTipText(tooltip);
setEnabled(enabled);

View file

@ -19,8 +19,7 @@
*******************************************************************************/
package org.eclipse.remote.internal.console;
public interface ImageConsts
{
public interface ImageConsts {
public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$
public final static String IMAGE_DIR_LOCALTOOL = "clcl16/"; // basic colors - size 16x16 //$NON-NLS-1$
public final static String IMAGE_DIR_DLCL = "dlcl16/"; // disabled - size 16x16 //$NON-NLS-1$
@ -49,4 +48,4 @@ public interface ImageConsts
public static final String IMAGE_CLCL_COMMAND_INPUT_FIELD = "ImageClclCommandInputField";//$NON-NLS-1$
public static final String IMAGE_ELCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$
public static final String IMAGE_DLCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$
}
}

View file

@ -27,7 +27,8 @@ public class TerminalConsole extends AbstractConsole implements ITerminalConsole
private final int index;
public TerminalConsole(IRemoteConnection connection, int index, String encoding) {
super(connection.getName(), Activator.getDefault().getImageRegistry().getDescriptor(ImageConsts.IMAGE_TERMINAL_VIEW));
super(connection.getName(),
Activator.getDefault().getImageRegistry().getDescriptor(ImageConsts.IMAGE_TERMINAL_VIEW));
this.encoding = encoding;
this.terminalConnector = new TerminalConsoleConnector(connection);
this.index = index;

View file

@ -143,11 +143,13 @@ public class TerminalConsoleConnector {
if (remoteProcess == null) {
disconnect();
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, ConsoleMessages.TerminalConsoleConnector_0);
return new Status(IStatus.ERROR, Activator.PLUGIN_ID,
ConsoleMessages.TerminalConsoleConnector_0);
}
if (width > 0 || height > 0) {
IRemoteProcessTerminalService termService = remoteProcess.getService(IRemoteProcessTerminalService.class);
IRemoteProcessTerminalService termService = remoteProcess
.getService(IRemoteProcessTerminalService.class);
if (termService != null) {
termService.setTerminalSize(width, height, 8 * width, 8 * height);
}
@ -202,7 +204,8 @@ public class TerminalConsoleConnector {
height = minHeight;
synchronized (this) {
if (remoteProcess != null) {
IRemoteProcessTerminalService termService = remoteProcess.getService(IRemoteProcessTerminalService.class);
IRemoteProcessTerminalService termService = remoteProcess
.getService(IRemoteProcessTerminalService.class);
if (termService != null) {
termService.setTerminalSize(width, height, 8 * width, 8 * height);
}

View file

@ -125,9 +125,7 @@ public class TerminalConsolePage extends Page implements IAdaptable {
mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
mainComposite.setLayout(new FillLayout());
tViewCtrl = TerminalViewControlFactory.makeControl(listener,
mainComposite,
new ITerminalConnector[] {});
tViewCtrl = TerminalViewControlFactory.makeControl(listener, mainComposite, new ITerminalConnector[] {});
tViewCtrl.setConnector(terminalConsole.getTerminalConnector().newPageConnector());
try {
@ -137,9 +135,7 @@ public class TerminalConsolePage extends Page implements IAdaptable {
NLS.bind(ConsoleMessages.ENCODING_UNAVAILABLE_1, encoding));
Activator.log(status);
ErrorDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
ConsoleMessages.OPEN_CONSOLE_ERROR,
ConsoleMessages.ENCODING_UNAVAILABLE_0,
status);
ConsoleMessages.OPEN_CONSOLE_ERROR, ConsoleMessages.ENCODING_UNAVAILABLE_0, status);
}
connectTerminalJob.schedule();
}

View file

@ -60,8 +60,9 @@ public class TerminalConsoleSettingsDialog extends Dialog {
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
// TODO remove the remote process service once we get command shell available with ssh and local
@SuppressWarnings("unchecked") List<IRemoteConnectionType> connTypes = manager.getConnectionTypesSupporting(
IRemoteCommandShellService.class, IRemoteProcessService.class);
@SuppressWarnings("unchecked")
List<IRemoteConnectionType> connTypes = manager.getConnectionTypesSupporting(IRemoteCommandShellService.class,
IRemoteProcessService.class);
remoteConnWidget = new RemoteConnectionWidget(composite, SWT.NONE, null, 0, connTypes);
@ -100,7 +101,7 @@ public class TerminalConsoleSettingsDialog extends Dialog {
return composite;
}
private List<String> getEncodings(){
private List<String> getEncodings() {
List<String> encodings = new ArrayList<>(2);
encodings.add("ISO-8859-1"); //$NON-NLS-1$
encodings.add("UTF-8"); //$NON-NLS-1$
@ -161,10 +162,12 @@ public class TerminalConsoleSettingsDialog extends Dialog {
}
private IDialogSettings getDialogSettings() {
IDialogSettings result = Activator.getDefault().getDialogSettings().getSection(TerminalConsoleSettingsDialog.class.getName());
IDialogSettings result = Activator.getDefault().getDialogSettings()
.getSection(TerminalConsoleSettingsDialog.class.getName());
if (result == null) {
result = Activator.getDefault().getDialogSettings().addNewSection(TerminalConsoleSettingsDialog.class.getName());
result = Activator.getDefault().getDialogSettings()
.addNewSection(TerminalConsoleSettingsDialog.class.getName());
}
return result;

View file

@ -22,12 +22,8 @@ public class ConsoleActionConnect extends ConsoleAction {
this.console = console;
setupAction(ActionMessages.CONNECT,
ActionMessages.CONNECT,
ImageConsts.IMAGE_CLCL_CONNECT,
ImageConsts.IMAGE_ELCL_CONNECT,
ImageConsts.IMAGE_DLCL_CONNECT,
true);
setupAction(ActionMessages.CONNECT, ActionMessages.CONNECT, ImageConsts.IMAGE_CLCL_CONNECT,
ImageConsts.IMAGE_ELCL_CONNECT, ImageConsts.IMAGE_DLCL_CONNECT, true);
}
@Override

View file

@ -17,18 +17,13 @@ import org.eclipse.remote.internal.console.TerminalConsole;
public class ConsoleActionDisconnect extends ConsoleAction {
private final TerminalConsole console;
public ConsoleActionDisconnect(TerminalConsole console)
{
public ConsoleActionDisconnect(TerminalConsole console) {
super(ConsoleActionDisconnect.class.getName());
this.console = console;
setupAction(ActionMessages.DISCONNECT,
ActionMessages.DISCONNECT,
ImageConsts.IMAGE_CLCL_DISCONNECT,
ImageConsts.IMAGE_ELCL_DISCONNECT,
ImageConsts.IMAGE_DLCL_DISCONNECT,
false);
setupAction(ActionMessages.DISCONNECT, ActionMessages.DISCONNECT, ImageConsts.IMAGE_CLCL_DISCONNECT,
ImageConsts.IMAGE_ELCL_DISCONNECT, ImageConsts.IMAGE_DLCL_DISCONNECT, false);
}
@Override

View file

@ -18,18 +18,13 @@ import org.eclipse.remote.internal.console.TerminalConsolePage;
public class ConsoleActionScrollLock extends ConsoleAction {
private final TerminalConsolePage page;
public ConsoleActionScrollLock(TerminalConsolePage page)
{
public ConsoleActionScrollLock(TerminalConsolePage page) {
super(ConsoleActionScrollLock.class.getName(), IAction.AS_RADIO_BUTTON);
this.page = page;
setupAction(ActionMessages.SCROLL_LOCK,
ActionMessages.SCROLL_LOCK,
ImageConsts.IMAGE_CLCL_SCROLL_LOCK,
ImageConsts.IMAGE_ELCL_SCROLL_LOCK,
ImageConsts.IMAGE_DLCL_SCROLL_LOCK,
true);
setupAction(ActionMessages.SCROLL_LOCK, ActionMessages.SCROLL_LOCK, ImageConsts.IMAGE_CLCL_SCROLL_LOCK,
ImageConsts.IMAGE_ELCL_SCROLL_LOCK, ImageConsts.IMAGE_DLCL_SCROLL_LOCK, true);
}
@Override

View file

@ -46,7 +46,8 @@ public interface IRemotePortForwardingService extends IRemoteConnection.Service
* @return local port number
* @throws RemoteConnectionException
*/
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor)
throws RemoteConnectionException;
/**
* Forward remote port remotePort to port fwdPort on machine fwdAddress. When a connection is made to remotePort on the remote
@ -76,7 +77,8 @@ public interface IRemotePortForwardingService extends IRemoteConnection.Service
* @return remote port number
* @throws RemoteConnectionException
*/
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor)
throws RemoteConnectionException;
/**
* Remove the local port forwarding associated with the given port.

View file

@ -169,7 +169,8 @@ public class RemoteConnectionType implements IRemoteConnectionType {
* @return the service object
* @throws CoreException
*/
public <T extends IRemoteConnection.Service> T getConnectionService(IRemoteConnection connection, Class<T> service) {
public <T extends IRemoteConnection.Service> T getConnectionService(IRemoteConnection connection,
Class<T> service) {
synchronized (connectionServiceDefinitionMap) {
IConfigurationElement ce = connectionServiceDefinitionMap.get(service.getName());
if (ce != null) {
@ -216,7 +217,8 @@ public class RemoteConnectionType implements IRemoteConnectionType {
IConfigurationElement ce = processServiceDefinitionMap.get(service.getName());
if (ce != null) {
try {
IRemoteProcess.Service.Factory factory = (IRemoteProcess.Service.Factory) ce.createExecutableExtension("factory"); //$NON-NLS-1$
IRemoteProcess.Service.Factory factory = (IRemoteProcess.Service.Factory) ce
.createExecutableExtension("factory"); //$NON-NLS-1$
if (factory != null) {
return factory.getService(process, service);
}
@ -356,7 +358,8 @@ public class RemoteConnectionType implements IRemoteConnectionType {
connections.remove(conn.getName());
connection.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_REMOVED);
} else {
RemoteCorePlugin.log("Wrong class for " + connection.getName() + ", was " + connection.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
RemoteCorePlugin
.log("Wrong class for " + connection.getName() + ", was " + connection.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}

View file

@ -298,7 +298,8 @@ public class RemotePath implements IPath, Cloneable {
newSegments[myLen + i] = tail.segment(i);
}
//use my leading separators and the tail's trailing separator
RemotePath result = new RemotePath(device, newSegments, (flags & (HAS_LEADING | IS_UNC | IS_FOR_WINDOWS)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0));
RemotePath result = new RemotePath(device, newSegments,
(flags & (HAS_LEADING | IS_UNC | IS_FOR_WINDOWS)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0));
String tailFirstSegment = newSegments[myLen];
if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
result.canonicalize();
@ -1070,7 +1071,8 @@ public class RemotePath implements IPath, Cloneable {
@Override
public IPath setDevice(String value) {
if (value != null) {
Assert.isTrue(value.indexOf(IPath.DEVICE_SEPARATOR) == (value.length() - 1), "Last character should be the device separator"); //$NON-NLS-1$
Assert.isTrue(value.indexOf(IPath.DEVICE_SEPARATOR) == (value.length() - 1),
"Last character should be the device separator"); //$NON-NLS-1$
}
//return the receiver if the device is the same
if (value == device || (value != null && value.equals(device)))

View file

@ -83,7 +83,8 @@ public class RemoteServicesManager implements IRemoteServicesManager {
for (IExtension ext : point.getExtensions()) {
for (IConfigurationElement ce : ext.getConfigurationElements()) {
String name = ce.getName();
if (name.equals("connectionTypeService") || name.equals("connectionService") || name.equals("processService")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (name.equals("connectionTypeService") || name.equals("connectionService") //$NON-NLS-1$//$NON-NLS-2$
|| name.equals("processService")) { //$NON-NLS-1$
String id = ce.getAttribute("connectionTypeId"); //$NON-NLS-1$
RemoteConnectionType services = connectionTypeMap.get(id);
if (services != null) {
@ -95,7 +96,8 @@ public class RemoteServicesManager implements IRemoteServicesManager {
// Init connection providers
for (IRemoteConnectionType connectionType : connectionTypeMap.values()) {
IRemoteConnectionProviderService providerService = connectionType.getService(IRemoteConnectionProviderService.class);
IRemoteConnectionProviderService providerService = connectionType
.getService(IRemoteConnectionProviderService.class);
if (providerService != null) {
providerService.init();
}
@ -135,7 +137,8 @@ public class RemoteServicesManager implements IRemoteServicesManager {
@Override
@SafeVarargs
public final List<IRemoteConnectionType> getConnectionTypesSupporting(Class<? extends IRemoteConnection.Service>... services) {
public final List<IRemoteConnectionType> getConnectionTypesSupporting(
Class<? extends IRemoteConnection.Service>... services) {
List<IRemoteConnectionType> connTypes = new ArrayList<IRemoteConnectionType>();
for (IRemoteConnectionType connType : getAllConnectionTypes()) {
for (Class<? extends IRemoteConnection.Service> service : services) {
@ -150,7 +153,8 @@ public class RemoteServicesManager implements IRemoteServicesManager {
@Override
@SafeVarargs
public final List<IRemoteConnectionType> getConnectionTypesByService(Class<? extends IRemoteConnectionType.Service>... services) {
public final List<IRemoteConnectionType> getConnectionTypesByService(
Class<? extends IRemoteConnectionType.Service>... services) {
List<IRemoteConnectionType> connTypes = new ArrayList<IRemoteConnectionType>();
for (IRemoteConnectionType connType : getAllConnectionTypes()) {
for (Class<? extends IRemoteConnectionType.Service> service : services) {

View file

@ -28,7 +28,8 @@ import org.osgi.service.prefs.BackingStoreException;
*/
public final class Preferences {
private static final IScopeContext[] contexts = new IScopeContext[] { DefaultScope.INSTANCE, InstanceScope.INSTANCE };
private static final IScopeContext[] contexts = new IScopeContext[] { DefaultScope.INSTANCE,
InstanceScope.INSTANCE };
private static final int DEFAULT_CONTEXT = 0;
private static final int INSTANCE_CONTEXT = 1;
@ -52,8 +53,8 @@ public final class Preferences {
* @return
*/
public static boolean contains(String name) {
return (contexts[INSTANCE_CONTEXT].getNode(fQualifier).get(name, null) != null || contexts[DEFAULT_CONTEXT].getNode(
fQualifier).get(name, null) != null);
return (contexts[INSTANCE_CONTEXT].getNode(fQualifier).get(name, null) != null
|| contexts[DEFAULT_CONTEXT].getNode(fQualifier).get(name, null) != null);
}
/**

View file

@ -124,7 +124,8 @@ public class LocalProcessBuilder extends AbstractRemoteProcessBuilder {
private IProcessFactory getProcessFactory() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = registry.getExtensionPoint(RemoteCorePlugin.getUniqueIdentifier(), EXTENSION_POINT_ID);
IExtensionPoint extensionPoint = registry.getExtensionPoint(RemoteCorePlugin.getUniqueIdentifier(),
EXTENSION_POINT_ID);
IProcessFactory processFactory = null;

View file

@ -51,7 +51,8 @@ public class ArgumentParser {
* string. Allows escaping.
*/
iterator.next(); // Skip quote
quoted_reader: while ((iterator.current() != CharacterIterator.DONE) && (iterator.current() != '"')) {
quoted_reader: while ((iterator.current() != CharacterIterator.DONE)
&& (iterator.current() != '"')) {
char innerChar = iterator.current();
switch (innerChar) {
case '\\':

View file

@ -51,8 +51,9 @@ import com.jcraft.jsch.Session;
/**
* @since 5.0
*/
public class JSchConnection implements IRemoteConnectionControlService, IRemoteConnectionPropertyService,
IRemotePortForwardingService, IRemoteProcessService, IRemoteConnectionHostService, IRemoteConnectionChangeListener {
public class JSchConnection
implements IRemoteConnectionControlService, IRemoteConnectionPropertyService, IRemotePortForwardingService,
IRemoteProcessService, IRemoteConnectionHostService, IRemoteConnectionChangeListener {
// Connection Type ID
public static final String JSCH_ID = "org.eclipse.remote.JSch"; //$NON-NLS-1$
@ -130,8 +131,9 @@ public class JSchConnection implements IRemoteConnectionControlService, IRemoteC
return (T) jschConnection;
}
} else if (IRemoteConnectionControlService.class.equals(service)
|| IRemoteConnectionPropertyService.class.equals(service) || IRemotePortForwardingService.class.equals(service)
|| IRemoteProcessService.class.equals(service) || IRemoteConnectionHostService.class.equals(service)) {
|| IRemoteConnectionPropertyService.class.equals(service)
|| IRemotePortForwardingService.class.equals(service) || IRemoteProcessService.class.equals(service)
|| IRemoteConnectionHostService.class.equals(service)) {
return (T) connection.getService(JSchConnection.class);
} else {
return null;
@ -230,7 +232,8 @@ public class JSchConnection implements IRemoteConnectionControlService, IRemoteC
}
@Override
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor)
throws RemoteConnectionException {
if (!isOpen()) {
throw new RemoteConnectionException(Messages.JSchConnection_connectionNotOpen);
}
@ -272,7 +275,8 @@ public class JSchConnection implements IRemoteConnectionControlService, IRemoteC
}
@Override
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor)
throws RemoteConnectionException {
if (!isOpen()) {
throw new RemoteConnectionException(Messages.JSchConnection_connectionNotOpen);
}
@ -426,7 +430,8 @@ public class JSchConnection implements IRemoteConnectionControlService, IRemoteC
if (proxyConnectionName.isEmpty()) {
return null;
}
return fRemoteConnection.getConnectionType().getConnection(proxyConnectionName).getService(JSchConnection.class);
return fRemoteConnection.getConnectionType().getConnection(proxyConnectionName)
.getService(JSchConnection.class);
}
/**
@ -680,12 +685,15 @@ public class JSchConnection implements IRemoteConnectionControlService, IRemoteC
IRemoteConnectionWorkingCopy wc = getRemoteConnection().getWorkingCopy();
IRemoteConnectionHostService hostService = wc.getService(IRemoteConnectionHostService.class);
IUserAuthenticatorService authService = wc.getService(IUserAuthenticatorService.class);
Session session = fJSchService.createSession(hostService.getHostname(), hostService.getPort(), hostService.getUsername());
Session session = fJSchService.createSession(hostService.getHostname(), hostService.getPort(),
hostService.getUsername());
session.setUserInfo(new JSchUserInfo(hostService, authService));
if (hostService.usePassword()) {
session.setConfig("PreferredAuthentications", "password,keyboard-interactive,gssapi-with-mic,publickey"); //$NON-NLS-1$ //$NON-NLS-2$
session.setConfig("PreferredAuthentications", //$NON-NLS-1$
"password,keyboard-interactive,gssapi-with-mic,publickey"); //$NON-NLS-1$
} else {
session.setConfig("PreferredAuthentications", "publickey,gssapi-with-mic,password,keyboard-interactive"); //$NON-NLS-1$ //$NON-NLS-2$
session.setConfig("PreferredAuthentications", //$NON-NLS-1$
"publickey,gssapi-with-mic,password,keyboard-interactive"); //$NON-NLS-1$
}
String password = hostService.getPassword();
if (!password.isEmpty()) {
@ -695,11 +703,12 @@ public class JSchConnection implements IRemoteConnectionControlService, IRemoteC
fJSchService.connect(session, getTimeout() * 1000, progress.newChild(10)); // connect without proxy
} else {
if (getProxyCommand().isEmpty()) {
session.setProxy(JSchConnectionProxyFactory.createForwardProxy(getProxyConnection(), progress.newChild(10)));
session.setProxy(
JSchConnectionProxyFactory.createForwardProxy(getProxyConnection(), progress.newChild(10)));
fJSchService.connect(session, getTimeout() * 1000, progress.newChild(10));
} else {
session.setProxy(JSchConnectionProxyFactory.createCommandProxy(getProxyConnection(), getProxyCommand(),
progress.newChild(10)));
session.setProxy(JSchConnectionProxyFactory.createCommandProxy(getProxyConnection(),
getProxyCommand(), progress.newChild(10)));
session.connect(getTimeout() * 1000); // the fJSchService doesn't pass the timeout correctly
}
}

View file

@ -97,8 +97,8 @@ public class JSchConnectionProxyFactory {
processBuilder.setPreamble(false);
process = processBuilder.start();
} else {
process = Activator.getService(IRemoteServicesManager.class).getLocalConnectionType().getConnections().get(0).
getService(IRemoteProcessService.class).getProcessBuilder(cmd).start();
process = Activator.getService(IRemoteServicesManager.class).getLocalConnectionType().getConnections()
.get(0).getService(IRemoteProcessService.class).getProcessBuilder(cmd).start();
}
// Wait on command to produce stdout output
@ -136,8 +136,8 @@ public class JSchConnectionProxyFactory {
} else if (bCanceled) {
cause = Messages.JSchConnectionProxyFactory_wasCanceled;
}
throw new IOException(MessageFormat.format(Messages.JSchConnectionProxyFactory_ProxyCommandFailed, command,
cause, msg));
throw new IOException(MessageFormat.format(Messages.JSchConnectionProxyFactory_ProxyCommandFailed,
command, cause, msg));
}
// Dump the stderr to log

View file

@ -27,10 +27,12 @@ import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.ChannelShell;
public class JSchProcess implements IRemoteProcessControlService, IRemoteProcessSignalService, IRemoteProcessTerminalService {
public class JSchProcess
implements IRemoteProcessControlService, IRemoteProcessSignalService, IRemoteProcessTerminalService {
@SuppressWarnings("nls")
private final String signals[] = new String[] { "", "HUP", "INT", "QUIT", "ILL", "", "ABRT", "", "FPE", "KILL", "", "SEGV", "",
"PIPE", "ALRM", "TERM", "", "STOP", "TSTP", "CONT", "", "", "", "", "", "", "", "", "", "", "USR1", "USR2" };
private final String signals[] = new String[] { "", "HUP", "INT", "QUIT", "ILL", "", "ABRT", "", "FPE", "KILL", "",
"SEGV", "", "PIPE", "ALRM", "TERM", "", "STOP", "TSTP", "CONT", "", "", "", "", "", "", "", "", "", "",
"USR1", "USR2" };
private static int WAIT_TIMEOUT = 1000;
private static int refCount = 0;
@ -147,7 +149,7 @@ public class JSchProcess implements IRemoteProcessControlService, IRemoteProcess
@Override
public int exitValue() {
if(!isCompleted()) {
if (!isCompleted()) {
throw new IllegalThreadStateException(Messages.JSchProcess_exitValue_exception_msg);
}
return fChannel.getExitStatus();

View file

@ -122,8 +122,9 @@ public class JSchUserInfo implements UserInfo, UIKeyboardInteractive {
System.out.println("promptYesNo:" + message); //$NON-NLS-1$
}
if (userAuthenticatorService != null) {
int prompt = userAuthenticatorService.prompt(IUserAuthenticatorService.QUESTION, Messages.AuthInfo_Authentication_message,
message, new int[] { IUserAuthenticatorService.YES, IUserAuthenticatorService.NO },
int prompt = userAuthenticatorService.prompt(IUserAuthenticatorService.QUESTION,
Messages.AuthInfo_Authentication_message, message,
new int[] { IUserAuthenticatorService.YES, IUserAuthenticatorService.NO },
IUserAuthenticatorService.YES);
return prompt == IUserAuthenticatorService.YES;
}
@ -136,8 +137,9 @@ public class JSchUserInfo implements UserInfo, UIKeyboardInteractive {
System.out.println("showMessage:" + message); //$NON-NLS-1$
}
if (userAuthenticatorService != null) {
userAuthenticatorService.prompt(IUserAuthenticatorService.INFORMATION, Messages.AuthInfo_Authentication_message, message,
new int[] { IUserAuthenticatorService.OK }, IUserAuthenticatorService.OK);
userAuthenticatorService.prompt(IUserAuthenticatorService.INFORMATION,
Messages.AuthInfo_Authentication_message, message, new int[] { IUserAuthenticatorService.OK },
IUserAuthenticatorService.OK);
}
}
}

View file

@ -76,7 +76,8 @@ public class JschFileStore extends FileStore {
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
IRemoteConnectionType connectionType = manager.getConnectionType(fURI);
if (connectionType == null) {
throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_No_remote_services_found_for_URI, fURI));
throw new RemoteConnectionException(
NLS.bind(Messages.JschFileStore_No_remote_services_found_for_URI, fURI));
}
try {
@ -136,7 +137,8 @@ public class JschFileStore extends FileStore {
@Override
public IFileStore getChild(String name) {
URI uri = JSchFileSystem.getURIFor(JSchFileSystem.getConnectionNameFor(fURI), fRemotePath.append(name).toString());
URI uri = JSchFileSystem.getURIFor(JSchFileSystem.getConnectionNameFor(fURI),
fRemotePath.append(name).toString());
return JschFileStore.getInstance(uri);
}
@ -168,7 +170,8 @@ public class JschFileStore extends FileStore {
if (fRemotePath.segmentCount() > 0) {
parentPath = fRemotePath.removeLastSegments(1).toString();
}
return JschFileStore.getInstance(JSchFileSystem.getURIFor(JSchFileSystem.getConnectionNameFor(fURI), parentPath));
return JschFileStore
.getInstance(JSchFileSystem.getURIFor(JSchFileSystem.getConnectionNameFor(fURI), parentPath));
}
@Override
@ -180,7 +183,8 @@ public class JschFileStore extends FileStore {
IFileStore parent = getParent();
if (parent != null && !parent.fetchInfo(EFS.NONE, subMon.newChild(9)).exists()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE,
NLS.bind(Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()), null));
NLS.bind(Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()),
null));
}
if (subMon.isCanceled()) {
return this;
@ -201,11 +205,14 @@ public class JschFileStore extends FileStore {
if (!subMon.isCanceled()) {
if (!info.exists()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE,
NLS.bind(Messages.JschFileStore_The_directory_could_not_be_created, fRemotePath.toString()), null));
NLS.bind(Messages.JschFileStore_The_directory_could_not_be_created, fRemotePath.toString()),
null));
}
if (!info.isDirectory()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
NLS.bind(Messages.JschFileStore_A_file_of_name_already_exists, fRemotePath.toString()), null));
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
EFS.ERROR_WRONG_TYPE,
NLS.bind(Messages.JschFileStore_A_file_of_name_already_exists, fRemotePath.toString()),
null));
}
}
}

View file

@ -80,7 +80,8 @@ public abstract class AbstractRemoteCommand<T> {
taskName.append(fPrefix);
}
if (fWorkPercentFactor < 0) {
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format1, new Object[] { workToDate, size }));
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format1,
new Object[] { workToDate, size }));
} else {
Double workPercent = Double.valueOf(fWorkPercentFactor * fWorkToDate);
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format2,
@ -300,8 +301,8 @@ public abstract class AbstractRemoteCommand<T> {
return convertToFileInfo(path.lastSegment(), path.removeLastSegments(1), attrs, monitor);
}
protected IFileInfo convertToFileInfo(final String name, final IPath parentPath, SftpATTRS attrs, IProgressMonitor monitor)
throws RemoteConnectionException {
protected IFileInfo convertToFileInfo(final String name, final IPath parentPath, SftpATTRS attrs,
IProgressMonitor monitor) throws RemoteConnectionException {
SubMonitor progress = SubMonitor.convert(monitor, 10);
FileInfo fileInfo = new FileInfo(name);
fileInfo.setExists(true);

View file

@ -48,7 +48,7 @@ public class ExecCommand extends AbstractRemoteCommand<String> {
if (getProgressMonitor().isCanceled()) {
return ""; //$NON-NLS-1$
}
if (getChannel().getExitStatus()!=0) {
if (getChannel().getExitStatus() != 0) {
throw new RemoteConnectionException(err.toString());
}
return stream.toString();

View file

@ -56,8 +56,10 @@ public class GetInputStreamCommand extends AbstractRemoteCommand<InputStream> {
@Override
public InputStream call() throws JSchException, SftpException, IOException {
return newChannel().get(fRemotePath.toString(), new CommandProgressMonitor(
NLS.bind(Messages.GetInputStreamCommand_Receiving, fRemotePath.toString()), getProgressMonitor()));
return newChannel().get(fRemotePath.toString(),
new CommandProgressMonitor(
NLS.bind(Messages.GetInputStreamCommand_Receiving, fRemotePath.toString()),
getProgressMonitor()));
}
};
try {

View file

@ -50,10 +50,8 @@ public class GetOutputStreamCommand extends AbstractRemoteCommand<OutputStream>
if ((fOptions & EFS.APPEND) != 0) {
mode = ChannelSftp.APPEND;
}
getChannel().put(
input,
fRemotePath.toString(),
new CommandProgressMonitor(NLS.bind(Messages.GetOutputStreamCommand_Sending, fRemotePath.toString()),
getChannel().put(input, fRemotePath.toString(), new CommandProgressMonitor(
NLS.bind(Messages.GetOutputStreamCommand_Sending, fRemotePath.toString()),
getProgressMonitor()), mode);
input.close();
} finally {

View file

@ -53,7 +53,8 @@ public class PutInfoCommand extends AbstractRemoteCommand<Void> {
return null;
}
private void chmod(final int permissions, final String path, IProgressMonitor monitor) throws RemoteConnectionException {
private void chmod(final int permissions, final String path, IProgressMonitor monitor)
throws RemoteConnectionException {
final SubMonitor subMon = SubMonitor.convert(monitor, 10);
SftpCallable<Void> c = new SftpCallable<Void>() {
@Override
@ -69,7 +70,8 @@ public class PutInfoCommand extends AbstractRemoteCommand<Void> {
}
}
private void setMTime(final int mtime, final String path, IProgressMonitor monitor) throws RemoteConnectionException {
private void setMTime(final int mtime, final String path, IProgressMonitor monitor)
throws RemoteConnectionException {
final SubMonitor subMon = SubMonitor.convert(monitor, 10);
SftpCallable<Void> c = new SftpCallable<Void>() {
@Override

View file

@ -175,7 +175,7 @@ public class ProcessTests extends TestCase {
public void testExitValue() {
IRemoteProcessService processService = fRemoteConnection.getService(IRemoteProcessService.class);
assertNotNull(processService);
IRemoteProcessBuilder builder = processService.getProcessBuilder(new String[]{"sleep","60"}); //$NON-NLS-1$
IRemoteProcessBuilder builder = processService.getProcessBuilder(new String[] { "sleep", "60" }); //$NON-NLS-1$
assertNotNull(builder);
IRemoteProcess rp = null;
try {
@ -189,7 +189,7 @@ public class ProcessTests extends TestCase {
try {
p.exitValue();
fail("Process has not exited. Should throws an IllegalThreadStateException exception");
} catch(IllegalThreadStateException e) {
} catch (IllegalThreadStateException e) {
e.printStackTrace();
}
}

View file

@ -90,8 +90,8 @@ public class JSchUserAuthenticator implements IUserAuthenticatorService {
display.syncExec(new Runnable() {
@Override
public void run() {
final MessageDialog dialog = new MessageDialog(display.getActiveShell(), title, null /* title image */, message,
promptType, buttons, defaultResponseIndex);
final MessageDialog dialog = new MessageDialog(display.getActiveShell(), title, null /* title image */,
message, promptType, buttons, defaultResponseIndex);
retval[0] = dialog.open();
}
});

View file

@ -246,8 +246,8 @@ public class JSchConnectionPage extends WizardPage {
fPasswordButton.setSelection(JSchConnection.DEFAULT_IS_PASSWORD);
fPublicKeyButton.setSelection(!JSchConnection.DEFAULT_IS_PASSWORD);
controls.setTabList(
new Control[] { fHostText, fUserText, fPublicKeyButton, fPassphraseText, fPasswordButton, fPasswordText });
controls.setTabList(new Control[] { fHostText, fUserText, fPublicKeyButton, fPassphraseText, fPasswordButton,
fPasswordText });
}
@Override
@ -312,7 +312,8 @@ public class JSchConnectionPage extends WizardPage {
lblConnection.setText(Messages.JSchConnectionPage_SelectConnection);
fProxyConnectionWidget = new RemoteConnectionWidget(proxyComp, SWT.NONE, null, 0);
fProxyConnectionWidget.filterConnections(IRemoteConnectionHostService.class, IRemotePortForwardingService.class);
fProxyConnectionWidget.filterConnections(IRemoteConnectionHostService.class,
IRemotePortForwardingService.class);
Label lblCommand = new Label(proxyComp, SWT.WRAP);
lblCommand.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -384,7 +385,8 @@ public class JSchConnectionPage extends WizardPage {
: Boolean.parseBoolean(useLoginShellStr);
fUseLoginShellButton.setSelection(useLoginShell);
String loginShellStr = fConnection.getAttribute(JSchConnection.LOGIN_SHELL_COMMAND_ATTR);
fLoginShellText.setText(loginShellStr.isEmpty() ? JSchConnection.DEFAULT_LOGIN_SHELL_COMMAND : loginShellStr);
fLoginShellText
.setText(loginShellStr.isEmpty() ? JSchConnection.DEFAULT_LOGIN_SHELL_COMMAND : loginShellStr);
fProxyCommandText.setText(fConnection.getAttribute(JSchConnection.PROXYCOMMAND_ATTR));
JSchConnection proxyConn = fConnection.getService(JSchConnection.class).getProxyConnection();
if (proxyConn == null) {
@ -520,7 +522,8 @@ public class JSchConnectionPage extends WizardPage {
fConnection.setAttribute(JSchConnection.TIMEOUT_ATTR, fTimeoutText.getText().trim());
fConnection.setAttribute(JSchConnection.PORT_ATTR, fPortText.getText().trim());
fConnection.setAttribute(JSchConnection.PROXYCOMMAND_ATTR, fProxyCommandText.getText().trim());
fConnection.setAttribute(JSchConnection.USE_LOGIN_SHELL_ATTR, Boolean.toString(fUseLoginShellButton.getSelection()));
fConnection.setAttribute(JSchConnection.USE_LOGIN_SHELL_ATTR,
Boolean.toString(fUseLoginShellButton.getSelection()));
fConnection.setAttribute(JSchConnection.LOGIN_SHELL_COMMAND_ATTR, fLoginShellText.getText().trim());
IRemoteConnection proxyConnection = fProxyConnectionWidget.getConnection();
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);

View file

@ -11,8 +11,7 @@ Export-Package: org.eclipse.remote.internal.proxy.core;x-friends:="org.eclipse.r
org.eclipse.remote.internal.proxy.core.messages;x-friends:="org.eclipse.remote.proxy.ui"
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package:
com.jcraft.jsch,
Import-Package: com.jcraft.jsch,
org.eclipse.core.filesystem,
org.eclipse.core.filesystem.provider,
org.eclipse.core.runtime,

View file

@ -69,7 +69,6 @@ public class Activator extends Plugin {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e));
}
/**
* The constructor
*/

View file

@ -46,10 +46,9 @@ import com.jcraft.jsch.ChannelShell;
/**
* @since 5.0
*/
public class ProxyConnection implements IRemoteConnectionControlService,
IRemoteConnectionChangeListener, IRemoteProcessService,
IRemoteCommandShellService, IRemoteConnectionHostService,
IRemoteConnectionPropertyService {
public class ProxyConnection
implements IRemoteConnectionControlService, IRemoteConnectionChangeListener, IRemoteProcessService,
IRemoteCommandShellService, IRemoteConnectionHostService, IRemoteConnectionPropertyService {
// Connection Type ID
public static final String JSCH_ID = "org.eclipse.remote.Proxy"; //$NON-NLS-1$
@ -120,8 +119,7 @@ public class ProxyConnection implements IRemoteConnectionControlService,
}
} else if (IRemoteConnectionControlService.class.equals(service)
|| IRemoteConnectionPropertyService.class.equals(service)
|| IRemoteConnectionHostService.class.equals(service)
|| IRemoteProcessService.class.equals(service)
|| IRemoteConnectionHostService.class.equals(service) || IRemoteProcessService.class.equals(service)
|| IRemoteCommandShellService.class.equals(service)
|| IRemoteConnectionPropertyService.class.equals(service)) {
return (T) connection.getService(ProxyConnection.class);
@ -281,7 +279,8 @@ public class ProxyConnection implements IRemoteConnectionControlService,
}
}
}.start();
ExecCommand cmd = new ExecCommand(this, command, getEnv(), getWorkingDirectory(), false, false, chanA.getId(), chanB.getId(), chanC.getId());
ExecCommand cmd = new ExecCommand(this, command, getEnv(), getWorkingDirectory(), false, false,
chanA.getId(), chanB.getId(), chanC.getId());
cmd.getResult(monitor);
DataInputStream status = new DataInputStream(chanC.getInputStream());
int stat = status.readInt();

View file

@ -145,7 +145,7 @@ public class ProxyConnectionBootstrap {
return true;
case "fail": //$NON-NLS-1$
context.setErrorMessage(parts[1]);
System.out.println("fail:"+parts[1]); //$NON-NLS-1$
System.out.println("fail:" + parts[1]); //$NON-NLS-1$
return false;
case "debug": //$NON-NLS-1$
System.err.println(line);
@ -163,7 +163,8 @@ public class ProxyConnectionBootstrap {
@Override
public boolean process(Context context) throws IOException {
context.getMonitor().subTask(Messages.ProxyConnectionBootstrap_3);
String bundleName = "org.eclipse.remote.proxy.server." + context.getOSName() + "." + context.getOSArch(); //$NON-NLS-1$ //$NON-NLS-2$
String bundleName = "org.eclipse.remote.proxy.server." + context.getOSName() + "." //$NON-NLS-1$//$NON-NLS-2$
+ context.getOSArch();
Bundle serverBundle = Platform.getBundle(bundleName);
if (serverBundle == null) {
throw new IOException(NLS.bind(Messages.ProxyConnectionBootstrap_2, bundleName));
@ -187,7 +188,7 @@ public class ProxyConnectionBootstrap {
return true;
case "fail": //$NON-NLS-1$
context.setErrorMessage(parts[1]);
System.out.println("fail:"+parts[1]); //$NON-NLS-1$
System.out.println("fail:" + parts[1]); //$NON-NLS-1$
return false;
case "debug": //$NON-NLS-1$
System.err.println(line);
@ -240,7 +241,8 @@ public class ProxyConnectionBootstrap {
jSchService = Activator.getService(IJSchService.class);
}
public StreamChannelManager run(IRemoteConnection connection, IProgressMonitor monitor) throws RemoteConnectionException {
public StreamChannelManager run(IRemoteConnection connection, IProgressMonitor monitor)
throws RemoteConnectionException {
SubMonitor subMon = SubMonitor.convert(monitor, 20);
try {
final Channel chan = openChannel(connection, subMon.newChild(10));
@ -268,7 +270,8 @@ public class ProxyConnectionBootstrap {
if (context.getState() != States.START) {
context.writer.write("exit\n"); //$NON-NLS-1$
context.writer.flush();
throw new RemoteConnectionException(NLS.bind(Messages.ProxyConnectionBootstrap_7, context.getErrorMessage()));
throw new RemoteConnectionException(
NLS.bind(Messages.ProxyConnectionBootstrap_7, context.getErrorMessage()));
}
new Thread("server error stream") { //$NON-NLS-1$
@Override
@ -277,7 +280,7 @@ public class ProxyConnectionBootstrap {
BufferedReader reader = new BufferedReader(new InputStreamReader(chan.getExtInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.err.println("server: "+ line); //$NON-NLS-1$
System.err.println("server: " + line); //$NON-NLS-1$
}
} catch (IOException e) {
// Ignore and terminate thread
@ -290,17 +293,21 @@ public class ProxyConnectionBootstrap {
}
}
private Channel openChannel(IRemoteConnection connection, IProgressMonitor monitor) throws RemoteConnectionException {
private Channel openChannel(IRemoteConnection connection, IProgressMonitor monitor)
throws RemoteConnectionException {
IRemoteConnectionWorkingCopy wc = connection.getWorkingCopy();
IRemoteConnectionHostService hostService = wc.getService(IRemoteConnectionHostService.class);
IUserAuthenticatorService authService = wc.getService(IUserAuthenticatorService.class);
try {
session = jSchService.createSession(hostService.getHostname(), hostService.getPort(), hostService.getUsername());
session = jSchService.createSession(hostService.getHostname(), hostService.getPort(),
hostService.getUsername());
session.setUserInfo(new JSchUserInfo(hostService, authService));
if (hostService.usePassword()) {
session.setConfig("PreferredAuthentications", "password,keyboard-interactive,gssapi-with-mic,publickey"); //$NON-NLS-1$ //$NON-NLS-2$
session.setConfig("PreferredAuthentications", //$NON-NLS-1$
"password,keyboard-interactive,gssapi-with-mic,publickey"); //$NON-NLS-1$
} else {
session.setConfig("PreferredAuthentications", "publickey,gssapi-with-mic,password,keyboard-interactive"); //$NON-NLS-1$ //$NON-NLS-2$
session.setConfig("PreferredAuthentications", //$NON-NLS-1$
"publickey,gssapi-with-mic,password,keyboard-interactive"); //$NON-NLS-1$
}
String password = hostService.getPassword();
if (!password.isEmpty()) {

View file

@ -145,7 +145,8 @@ public class ProxyFileStore extends FileStore {
@Override
public IFileStore getChild(String name) {
URI uri = ProxyFileSystem.getURIFor(ProxyFileSystem.getConnectionNameFor(fURI), fRemotePath.append(name).toString());
URI uri = ProxyFileSystem.getURIFor(ProxyFileSystem.getConnectionNameFor(fURI),
fRemotePath.append(name).toString());
return getInstance(uri);
}
@ -214,8 +215,8 @@ public class ProxyFileStore extends FileStore {
NLS.bind(Messages.ProxyFileStore_4, fRemotePath.toString()), null));
}
if (!info.isDirectory()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
NLS.bind(Messages.ProxyFileStore_5, fRemotePath.toString()), null));
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
EFS.ERROR_WRONG_TYPE, NLS.bind(Messages.ProxyFileStore_5, fRemotePath.toString()), null));
}
}
}

View file

@ -51,7 +51,7 @@ public class ProxyProcess implements IRemoteProcessControlService, IRemoteProces
protected ProxyProcess(IRemoteProcess process) {
remoteProcess = process;
ProxyProcessBuilder builder = (ProxyProcessBuilder)process.getProcessBuilder();
ProxyProcessBuilder builder = (ProxyProcessBuilder) process.getProcessBuilder();
List<StreamChannel> streams = builder.getStreams();
controlChan = streams.get(0);
stdIOChan = streams.get(1);

View file

@ -51,7 +51,7 @@ public class ProxyProcessBuilder extends AbstractRemoteProcessBuilder {
* @param connection
*/
public ProxyProcessBuilder(ProxyConnection connection) {
super(connection.getRemoteConnection(), (List<String>)null);
super(connection.getRemoteConnection(), (List<String>) null);
proxyConnection = connection;
redirectErrorStream(true);
}
@ -100,8 +100,9 @@ public class ProxyProcessBuilder extends AbstractRemoteProcessBuilder {
job = new Job("process executor") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
ExecCommand cmd = new ExecCommand(conn, cmdArgs, env, directory().toURI().getPath(), redirectErrorStream(), append,
streams.get(0).getId(), streams.get(1).getId(), streams.get(2).getId());
ExecCommand cmd = new ExecCommand(conn, cmdArgs, env, directory().toURI().getPath(),
redirectErrorStream(), append, streams.get(0).getId(), streams.get(1).getId(),
streams.get(2).getId());
try {
cmd.getResult(monitor);
} catch (ProxyException e) {

View file

@ -81,4 +81,3 @@ public abstract class AbstractCommand<T> implements Callable<T> {
this.connection = conn;
}
}

View file

@ -30,8 +30,8 @@ public class ExecCommand extends AbstractCommand<Void> {
private final int ioChan;
private final int errChan;
public ExecCommand(ProxyConnection conn, List<String> command, Map<String, String> env, String directory, boolean redirect, boolean appendEnv,
int cmdChan, int ioChan, int errChan) {
public ExecCommand(ProxyConnection conn, List<String> command, Map<String, String> env, String directory,
boolean redirect, boolean appendEnv, int cmdChan, int ioChan, int errChan) {
super(conn);
this.out = new DataOutputStream(conn.getCommandChannel().getOutputStream());
this.in = new DataInputStream(conn.getCommandChannel().getInputStream());

View file

@ -69,7 +69,6 @@ public class Activator extends Plugin {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e));
}
/**
* The constructor
*/

View file

@ -61,7 +61,7 @@ public class StreamChannel {
try {
if (currentPos >= currentSize) {
currentPos = currentSize = 0;
} else if (currentPos >= CAPACITY/2) {
} else if (currentPos >= CAPACITY / 2) {
System.arraycopy(buffer, currentPos, buffer, 0, currentSize - currentPos);
currentSize -= currentPos;
currentPos = 0;
@ -167,7 +167,7 @@ public class StreamChannel {
while (currentPos >= CAPACITY) {
send();
}
buffer[currentPos++] = (byte)b;
buffer[currentPos++] = (byte) b;
}
@Override

View file

@ -30,6 +30,7 @@ import java.util.concurrent.LinkedBlockingQueue;
public class StreamChannelManager implements Runnable {
public interface IChannelListener {
public void newChannel(StreamChannel chan);
public void closeChannel(StreamChannel chan);
}
@ -190,7 +191,7 @@ public class StreamChannelManager implements Runnable {
switch (cmd) {
case CMD_OPEN:
debugPrint("received cmd=OPEN id="+id);
debugPrint("received cmd=OPEN id=" + id);
chan = channels.get(id);
if (chan != null) {
throw new IOException("Channel already exists");
@ -211,7 +212,7 @@ public class StreamChannelManager implements Runnable {
* Received a command to close the channel.
* Clean up channel and free channel ID if we allocated it.
*/
debugPrint("received cmd=CLOSE id="+id);
debugPrint("received cmd=CLOSE id=" + id);
chan = channels.get(id);
if (chan == null) {
throw new IOException("CLOSE: Invalid channel id: " + id);
@ -232,7 +233,7 @@ public class StreamChannelManager implements Runnable {
* Received acknowledgement for our close command.
* Clean up channel and free channel ID if we allocated it.
*/
debugPrint("received cmd=CLOSEACK id="+id);
debugPrint("received cmd=CLOSEACK id=" + id);
chan = channels.get(id);
if (chan == null) {
throw new IOException("CLOSEACK: Invalid channel id");
@ -248,7 +249,7 @@ public class StreamChannelManager implements Runnable {
break;
case CMD_TRANSMIT:
debugPrint("received cmd=TRANSMIT id="+id);
debugPrint("received cmd=TRANSMIT id=" + id);
chan = channels.get(id);
if (chan == null) {
throw new IOException("TRANSMIT: Invalid channel id: " + id);
@ -265,7 +266,7 @@ public class StreamChannelManager implements Runnable {
throw new IOException("REQUEST: Invalid channel id: " + id);
}
int req = dataIn.readInt();
debugPrint("received cmd=REQUEST id="+id+ " len="+req);
debugPrint("received cmd=REQUEST id=" + id + " len=" + req);
chan.request(req);
break;
@ -273,7 +274,7 @@ public class StreamChannelManager implements Runnable {
/*
* Received a command to close the input side of the channel.
*/
debugPrint("received cmd=CLOSE_INPUT id="+id);
debugPrint("received cmd=CLOSE_INPUT id=" + id);
chan = channels.get(id);
if (chan == null) {
throw new IOException("CLOSE: Invalid channel id: " + id);
@ -281,12 +282,11 @@ public class StreamChannelManager implements Runnable {
chan.disconnectInput();
break;
case CMD_CLOSE_OUTPUT:
/*
* Received a command to close the output side of the channel.
*/
debugPrint("received cmd=CLOSE_OUTPUT id="+id);
debugPrint("received cmd=CLOSE_OUTPUT id=" + id);
chan = channels.get(id);
if (chan == null) {
throw new IOException("CLOSE: Invalid channel id: " + id);
@ -296,7 +296,7 @@ public class StreamChannelManager implements Runnable {
default:
synchronized (System.err) {
System.err.print("invalid command: "+ dump_byte((byte)cmd) + dump_byte((byte)id));
System.err.print("invalid command: " + dump_byte((byte) cmd) + dump_byte((byte) id));
}
try {
while (true) {
@ -341,8 +341,10 @@ public class StreamChannelManager implements Runnable {
private final static int SERVER_ID_MASK = 1 << 15;
private final static int MAX_CHANNELS = SERVER_ID_MASK >> 1;
private final Map<Integer, StreamChannel> channels = (Map<Integer, StreamChannel>) Collections.synchronizedMap(new HashMap<Integer,StreamChannel>());
private final List<IChannelListener> listeners = (List<IChannelListener>)Collections.synchronizedList(new ArrayList<IChannelListener>());
private final Map<Integer, StreamChannel> channels = (Map<Integer, StreamChannel>) Collections
.synchronizedMap(new HashMap<Integer, StreamChannel>());
private final List<IChannelListener> listeners = (List<IChannelListener>) Collections
.synchronizedList(new ArrayList<IChannelListener>());
private Set<Short> usedIds = new HashSet<>();
private int nextUnusedChannelId;
@ -372,7 +374,7 @@ public class StreamChannelManager implements Runnable {
if (!usedIds.isEmpty()) {
Short id = usedIds.iterator().next();
usedIds.remove(id);
debugPrint("recover id="+id);
debugPrint("recover id=" + id);
return id;
}
int nextId = nextUnusedChannelId;
@ -383,17 +385,17 @@ public class StreamChannelManager implements Runnable {
}
synchronized void freeId(int id) {
debugPrint("free id="+id);
usedIds.add((short)id);
debugPrint("free id=" + id);
usedIds.add((short) id);
}
void dump_buf(String pref, byte[] b, int off, int len) {
System.err.print(pref + ": ");
for (int i = off; i < len+off; i++) {
for (int i = off; i < len + off; i++) {
if (b[i] <= 32 || b[i] > 126) {
System.err.print(String.format(" 0x%02x ", b[i]));
} else {
System.err.print((char)b[i]);
System.err.print((char) b[i]);
}
}
System.err.println();
@ -436,7 +438,7 @@ public class StreamChannelManager implements Runnable {
return String.format(" 0x%02x ", b);
}
return String.valueOf((char)b);
return String.valueOf((char) b);
}
public StreamChannel openChannel() throws IOException {
@ -447,7 +449,7 @@ public class StreamChannelManager implements Runnable {
StreamChannel chan = new StreamChannel(this, newId());
channels.put(chan.getId(), chan);
debugPrint("send cmd=OPEN id="+chan.getId());
debugPrint("send cmd=OPEN id=" + chan.getId());
sender.sendOpenCmd(chan.getId());
return chan;
@ -455,14 +457,15 @@ public class StreamChannelManager implements Runnable {
synchronized void sendTransmitCmd(StreamChannel chan, byte buf[], int off, int len) throws IOException {
if (running && chan.isOpen()) {
debugPrint("send cmd=TRANSMIT id="+chan.getId()+" len="+len + " off=" + off + " buflen="+buf.length);
debugPrint(
"send cmd=TRANSMIT id=" + chan.getId() + " len=" + len + " off=" + off + " buflen=" + buf.length);
sender.sendTransmitCmd(chan.getId(), buf, off, len);
}
}
synchronized void sendCloseCmd(StreamChannel chan) throws IOException {
if (running && chan.isOpen()) {
debugPrint("send cmd=CLOSE id="+chan.getId());
debugPrint("send cmd=CLOSE id=" + chan.getId());
chan.disconnect();
sender.sendCloseCmd(chan.getId());
chan.setClosed();
@ -471,7 +474,7 @@ public class StreamChannelManager implements Runnable {
synchronized void sendCloseAckCmd(StreamChannel chan) throws IOException {
if (running && chan.isOpen()) {
debugPrint("send cmd=CLOSEACK id="+chan.getId());
debugPrint("send cmd=CLOSEACK id=" + chan.getId());
sender.sendCloseAckCmd(chan.getId());
chan.setClosed();
}
@ -479,7 +482,7 @@ public class StreamChannelManager implements Runnable {
synchronized void sendRequestCmd(StreamChannel chan, int len) throws IOException {
if (running && chan.isOpen()) {
debugPrint("send cmd=REQUEST id="+chan.getId()+" len="+len);
debugPrint("send cmd=REQUEST id=" + chan.getId() + " len=" + len);
sender.sendRequestCmd(chan.getId(), len);
}
}
@ -489,7 +492,7 @@ public class StreamChannelManager implements Runnable {
if (!chan.isOutputConnected()) {
sendCloseCmd(chan);
} else {
debugPrint("send cmd=CLOSE_INPUT id="+chan.getId());
debugPrint("send cmd=CLOSE_INPUT id=" + chan.getId());
sender.sendCloseInputCmd(chan.getId());
}
}
@ -500,7 +503,7 @@ public class StreamChannelManager implements Runnable {
if (!chan.isInputConnected()) {
sendCloseCmd(chan);
} else {
debugPrint("send cmd=CLOSE_OUTPUT id="+chan.getId());
debugPrint("send cmd=CLOSE_OUTPUT id=" + chan.getId());
sender.sendCloseOutputCmd(chan.getId());
}
}

View file

@ -20,13 +20,14 @@ public class Application implements IApplication {
private Server server = new Server();
public Object start(IApplicationContext context) throws Exception {
String[] args = (String[])context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
for (String arg : args) {
if (arg.equals("-magic")) { //$NON-NLS-1$
ByteBuffer b = ByteBuffer.allocate(4);
b.putInt(Protocol.MAGIC);
System.out.write(b.array());
};
}
;
}
server.start();
server.waitFor();

View file

@ -97,7 +97,6 @@ public class CommandServer implements Runnable {
cmdOut.flush();
}
/**
* TODO replace with dynamic dispatcher
*/
@ -183,7 +182,7 @@ public class CommandServer implements Runnable {
boolean appendEnv = in.readBoolean();
StreamChannel cmdChan = server.getChannel(cmdChanId);
StreamChannel ioChan = server.getChannel(ioChanId);
StreamChannel errChan= server.getChannel(errChanId);
StreamChannel errChan = server.getChannel(errChanId);
if (cmdChan == null || ioChan == null || errChan == null) {
throw new ProxyException("Unable to locate channels for command"); //$NON-NLS-1$
}
@ -200,6 +199,7 @@ public class CommandServer implements Runnable {
}
return new ServerShellCommand(cmdChan, ioChan);
}
private AbstractServerCommand cmdGetCwd(DataInputStream in) throws ProxyException, IOException {
int chanId = in.readByte();
StreamChannel chan = server.getChannel(chanId);

View file

@ -21,7 +21,6 @@ public class Server {
private StreamChannel cmdChannel;
private Map<Integer, StreamChannel> auxChannel = Collections.synchronizedMap(new HashMap<Integer, StreamChannel>());
public void start() {
final StreamChannelManager mux = new StreamChannelManager(System.in, System.out);
mux.setServer(true);
@ -60,7 +59,7 @@ public class Server {
}
public StreamChannel getChannel(int id) {
System.err.println("getChannel: "+id);
System.err.println("getChannel: " + id);
return auxChannel.get(id);
}

View file

@ -122,7 +122,8 @@ public abstract class AbstractServerExecCommand extends AbstractServerCommand {
out.write(buf, 0, n);
out.flush();
}
if (n < 0) break;
if (n < 0)
break;
}
} catch (IOException e) {
// Finish
@ -177,7 +178,8 @@ public abstract class AbstractServerExecCommand extends AbstractServerCommand {
private Process proc;
public AbstractServerExecCommand(List<String> command, Map<String, String> env, String directory, boolean redirect, boolean appendEnv, StreamChannel cmdChan, StreamChannel ioChan, StreamChannel errChan) {
public AbstractServerExecCommand(List<String> command, Map<String, String> env, String directory, boolean redirect,
boolean appendEnv, StreamChannel cmdChan, StreamChannel ioChan, StreamChannel errChan) {
this.command = command;
this.env = env;
this.directory = directory;
@ -203,7 +205,7 @@ public abstract class AbstractServerExecCommand extends AbstractServerCommand {
return command;
}
protected Map<String,String> getEnv() {
protected Map<String, String> getEnv() {
return env;
}

View file

@ -21,7 +21,7 @@ import org.eclipse.remote.proxy.protocol.core.StreamChannel;
public class ServerExecCommand extends AbstractServerExecCommand {
public Process doRun() throws IOException {
System.err.print("exec: ");
for (String arg:getCommand()) {
for (String arg : getCommand()) {
System.err.print(arg + " ");
}
System.err.println();
@ -59,7 +59,8 @@ public class ServerExecCommand extends AbstractServerExecCommand {
// Not supported
}
public ServerExecCommand(List<String> command, Map<String, String> env, String directory, boolean redirect, boolean appendEnv, StreamChannel cmdChan, StreamChannel ioChan, StreamChannel errChan) {
public ServerExecCommand(List<String> command, Map<String, String> env, String directory, boolean redirect,
boolean appendEnv, StreamChannel cmdChan, StreamChannel ioChan, StreamChannel errChan) {
super(command, env, directory, redirect, appendEnv, cmdChan, ioChan, errChan);
}
}

View file

@ -22,7 +22,7 @@ public class ServerGetEnvCommand extends AbstractServerCommand {
@Override
public void run() {
try {
Map<String,String> env = System.getenv();
Map<String, String> env = System.getenv();
result.writeInt(env.size());
for (Map.Entry<String, String> entry : env.entrySet()) {
result.writeUTF(entry.getKey());

View file

@ -72,7 +72,8 @@ public class ServerGetInputStreamCommand extends AbstractServerCommand {
public void exec() throws ProxyException {
try {
InputStream in = new BufferedInputStream(EFS.getStore(uri).openInputStream(options, new NullProgressMonitor()));
InputStream in = new BufferedInputStream(
EFS.getStore(uri).openInputStream(options, new NullProgressMonitor()));
startForwarder(in, out);
} catch (Exception e) {
throw new ProxyException(e.getMessage());

View file

@ -73,7 +73,8 @@ public class ServerGetOutputStreamCommand extends AbstractServerCommand {
public void exec() throws ProxyException {
try {
OutputStream out = new BufferedOutputStream(EFS.getStore(uri).openOutputStream(options, new NullProgressMonitor()));
OutputStream out = new BufferedOutputStream(
EFS.getStore(uri).openOutputStream(options, new NullProgressMonitor()));
startForwarder(in, out);
} catch (CoreException e) {
throw new ProxyException(e.getMessage());

View file

@ -24,13 +24,18 @@ public class ServerGetPropertiesCommand extends AbstractServerCommand {
@Override
public void run() {
try {
Map<String,String> props = new HashMap<String, String>();
props.put(IRemoteConnection.FILE_SEPARATOR_PROPERTY, System.getProperty(IRemoteConnection.FILE_SEPARATOR_PROPERTY));
props.put(IRemoteConnection.PATH_SEPARATOR_PROPERTY, System.getProperty(IRemoteConnection.PATH_SEPARATOR_PROPERTY));
props.put(IRemoteConnection.LINE_SEPARATOR_PROPERTY, System.getProperty(IRemoteConnection.LINE_SEPARATOR_PROPERTY));
props.put(IRemoteConnection.USER_HOME_PROPERTY, System.getProperty(IRemoteConnection.USER_HOME_PROPERTY));
Map<String, String> props = new HashMap<String, String>();
props.put(IRemoteConnection.FILE_SEPARATOR_PROPERTY,
System.getProperty(IRemoteConnection.FILE_SEPARATOR_PROPERTY));
props.put(IRemoteConnection.PATH_SEPARATOR_PROPERTY,
System.getProperty(IRemoteConnection.PATH_SEPARATOR_PROPERTY));
props.put(IRemoteConnection.LINE_SEPARATOR_PROPERTY,
System.getProperty(IRemoteConnection.LINE_SEPARATOR_PROPERTY));
props.put(IRemoteConnection.USER_HOME_PROPERTY,
System.getProperty(IRemoteConnection.USER_HOME_PROPERTY));
props.put(IRemoteConnection.OS_NAME_PROPERTY, System.getProperty(IRemoteConnection.OS_NAME_PROPERTY));
props.put(IRemoteConnection.OS_VERSION_PROPERTY, System.getProperty(IRemoteConnection.OS_VERSION_PROPERTY));
props.put(IRemoteConnection.OS_VERSION_PROPERTY,
System.getProperty(IRemoteConnection.OS_VERSION_PROPERTY));
props.put(IRemoteConnection.OS_ARCH_PROPERTY, System.getProperty(IRemoteConnection.OS_ARCH_PROPERTY));
props.put(IRemoteConnection.LOCALE_CHARMAP_PROPERTY, System.getProperty("file.encoding")); //$NON-NLS-1$

View file

@ -28,7 +28,8 @@ public class ServerPutInfoCommand extends AbstractServerCommand {
public void exec() throws ProxyException {
try {
EFS.getStore(uri).putInfo(info, options, new NullProgressMonitor());;
EFS.getStore(uri).putInfo(info, options, new NullProgressMonitor());
;
} catch (CoreException e) {
throw new ProxyException(e.getMessage());
}

View file

@ -87,11 +87,11 @@ public class ServerShellCommand extends AbstractServerExecCommand {
if (PTY.isSupported(Mode.TERMINAL)) {
PTY pty = new PTY(Mode.TERMINAL);
Process p = ProcessFactory.getFactory().exec(new String[] {shell, "-l"}, null, null, pty); //$NON-NLS-1$
Process p = ProcessFactory.getFactory().exec(new String[] { shell, "-l" }, null, null, pty); //$NON-NLS-1$
return new ShellProcess(p, pty);
}
return ProcessFactory.getFactory().exec(new String[] {shell, "-l"}, null, null); //$NON-NLS-1$
return ProcessFactory.getFactory().exec(new String[] { shell, "-l" }, null, null); //$NON-NLS-1$
}
protected void doKill(Process proc) {
@ -102,7 +102,7 @@ public class ServerShellCommand extends AbstractServerExecCommand {
protected void doSetTerminalSize(Process proc, int cols, int rows) {
if (proc.isAlive() && proc instanceof ShellProcess) {
ShellProcess shell = (ShellProcess)proc;
ShellProcess shell = (ShellProcess) proc;
shell.setTerminalSize(cols, rows);
}
}

View file

@ -2,4 +2,3 @@ bin.includes = META-INF/,\
proxy.server.tar.gz,\
plugin.properties,\
about.html

View file

@ -69,9 +69,9 @@ public class ConnectionTests extends TestCase {
INIT {
@Override
public boolean process(Context context) throws IOException {
System.out.println("state="+INIT);
System.out.println("state=" + INIT);
String line = context.reader.readLine();
System.out.println("got "+ line);
System.out.println("got " + line);
if (line.equals("running")) {
context.setState(States.CHECK);
return true;
@ -82,7 +82,7 @@ public class ConnectionTests extends TestCase {
CHECK {
@Override
public boolean process(Context context) throws IOException {
System.out.println("state="+CHECK);
System.out.println("state=" + CHECK);
context.writer.write("check\n");
context.writer.flush();
String line = context.reader.readLine();
@ -95,14 +95,14 @@ public class ConnectionTests extends TestCase {
context.setState(States.DOWNLOAD);
return true;
}
System.out.println("fail:"+parts[1]);
System.out.println("fail:" + parts[1]);
return false;
}
},
DOWNLOAD {
@Override
public boolean process(Context context) throws IOException {
System.out.println("state="+DOWNLOAD);
System.out.println("state=" + DOWNLOAD);
File file = new File("proxy.server-linux.gtk.x86_64.tar.gz");
long count = file.length() / 510;
System.out.println("download " + count);
@ -116,7 +116,7 @@ public class ConnectionTests extends TestCase {
context.setState(States.START);
return true;
case "fail":
System.out.println("fail:"+parts[1]);
System.out.println("fail:" + parts[1]);
return false;
}
}
@ -147,7 +147,7 @@ public class ConnectionTests extends TestCase {
START {
@Override
public boolean process(Context context) throws IOException {
System.out.println("state="+START);
System.out.println("state=" + START);
context.writer.write("start\n");
context.writer.flush();
return false;
@ -162,7 +162,7 @@ public class ConnectionTests extends TestCase {
session.setConfig("PreferredAuthentications", "password,keyboard-interactive,gssapi-with-mic,publickey"); //$NON-NLS-1$ //$NON-NLS-2$
new UserInfoPrompter(session);
jService.connect(session, 0, new NullProgressMonitor());
ChannelExec server = (ChannelExec)session.openChannel("exec");
ChannelExec server = (ChannelExec) session.openChannel("exec");
server.setCommand("/bin/sh");
server.connect();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(server.getOutputStream()));
@ -183,48 +183,48 @@ public class ConnectionTests extends TestCase {
fail(e.getMessage());
}
// try {
// final Process proc = Runtime.getRuntime().exec("java"
// + " -cp /Users/gw6/Work/git/org.eclipse.remote/releng/org.eclipse.remote.proxy.server.product/target/products/proxy.server/macosx/cocoa/x86_64/Proxy.app/Contents/Eclipse/plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar"
// + " org.eclipse.equinox.launcher.Main"
// + " -application org.eclipse.remote.proxy.server.core.application"
// + " -noExit");
// assertTrue(proc.isAlive());
//
// new Thread("stderr") {
// private byte[] buf = new byte[1024];
// @Override
// public void run() {
// int n;
// BufferedInputStream err = new BufferedInputStream(proc.getErrorStream());
// try {
// while ((n = err.read(buf)) >= 0) {
// if (n > 0) {
// System.err.println("server: " + new String(buf, 0, n));
// }
// }
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// }.start();
//
// IRemoteConnection conn = connType.newConnection("test");
// assertNotNull(conn);
// IRemoteProxyService proxy = conn.getService(IRemoteProxyService.class);
// assertNotNull(proxy);
// proxy.setStreams(proc.getInputStream(), proc.getOutputStream());
// conn.open(new NullProgressMonitor());
// conn.close();
//
// proc.destroy();
// proc.waitFor();
// assertEquals(false, proc.isAlive());
// } catch (IOException | RemoteConnectionException | InterruptedException e) {
// fail(e.getMessage());
// }
// try {
// final Process proc = Runtime.getRuntime().exec("java"
// + " -cp /Users/gw6/Work/git/org.eclipse.remote/releng/org.eclipse.remote.proxy.server.product/target/products/proxy.server/macosx/cocoa/x86_64/Proxy.app/Contents/Eclipse/plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar"
// + " org.eclipse.equinox.launcher.Main"
// + " -application org.eclipse.remote.proxy.server.core.application"
// + " -noExit");
// assertTrue(proc.isAlive());
//
// new Thread("stderr") {
// private byte[] buf = new byte[1024];
// @Override
// public void run() {
// int n;
// BufferedInputStream err = new BufferedInputStream(proc.getErrorStream());
// try {
// while ((n = err.read(buf)) >= 0) {
// if (n > 0) {
// System.err.println("server: " + new String(buf, 0, n));
// }
// }
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// }.start();
//
// IRemoteConnection conn = connType.newConnection("test");
// assertNotNull(conn);
// IRemoteProxyService proxy = conn.getService(IRemoteProxyService.class);
// assertNotNull(proxy);
// proxy.setStreams(proc.getInputStream(), proc.getOutputStream());
// conn.open(new NullProgressMonitor());
// conn.close();
//
// proc.destroy();
// proc.waitFor();
// assertEquals(false, proc.isAlive());
// } catch (IOException | RemoteConnectionException | InterruptedException e) {
// fail(e.getMessage());
// }
}
private String executeSshCommand(ChannelShell shell, String command) throws RemoteConnectionException {
@ -247,9 +247,9 @@ public class ConnectionTests extends TestCase {
@Override
protected void setUp() throws Exception {
// IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
// connType = manager.getConnectionType("org.eclipse.remote.Proxy"); //$NON-NLS-1$
// assertNotNull(connType);
// IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
// connType = manager.getConnectionType("org.eclipse.remote.Proxy"); //$NON-NLS-1$
// assertNotNull(connType);
}
@Override

View file

@ -246,7 +246,7 @@ public class FileStoreTests extends TestCase {
IRemoteConnectionWorkingCopy wc = connType.newConnection(CONNECTION_NAME);
IRemoteConnectionHostService host = wc.getService(IRemoteConnectionHostService.class);
host.setHostname("titan-ext1.ccs.ornl.gov");
// host.setHostname("localhost");
// host.setHostname("localhost");
host.setUsername("gw6");
connection = wc.save();
assertNotNull(connection);

View file

@ -72,7 +72,7 @@ public class MultiplexServerTests extends TestCase {
@Override
public void run() {
try{
try {
synchronized (MultiplexServerTests.this) {
System.out.println(getName() + " started");
}
@ -115,6 +115,7 @@ public class MultiplexServerTests extends TestCase {
new Thread("stderr") {
private byte[] buf = new byte[1024];
@Override
public void run() {
int n;
@ -135,7 +136,8 @@ public class MultiplexServerTests extends TestCase {
StreamChannelManager mpxClnt = startMpxClient(proc.getInputStream(), proc.getOutputStream());
List<StreamChannel> channels = runChannelTest(mpxClnt, clntReaders, clntWriters, clntSentBufs, clntRecvBufs);
List<StreamChannel> channels = runChannelTest(mpxClnt, clntReaders, clntWriters, clntSentBufs,
clntRecvBufs);
for (int i = 0; i < NUM_CHANS; i++) {
clntWriters[i].join();
@ -159,15 +161,16 @@ public class MultiplexServerTests extends TestCase {
}
}
private List<StreamChannel> runChannelTest(StreamChannelManager mpx, Thread[] readers, Thread[] writers, final StringBuffer[] sentBufs, final StringBuffer[] recvBufs) throws IOException {
private List<StreamChannel> runChannelTest(StreamChannelManager mpx, Thread[] readers, Thread[] writers,
final StringBuffer[] sentBufs, final StringBuffer[] recvBufs) throws IOException {
List<StreamChannel> channels = new ArrayList<StreamChannel>();
for (int i = 0 ; i < NUM_CHANS; i++) {
for (int i = 0; i < NUM_CHANS; i++) {
StreamChannel chan = mpx.openChannel(); // needs to be in same thread as reader
// ChanReader reader = new ChanReader(chan, recvBufs, "clnt reader thread " + chan.getId());
// readers[chan.getId()] = new Thread(reader, reader.getName());
// ChanReader reader = new ChanReader(chan, recvBufs, "clnt reader thread " + chan.getId());
// readers[chan.getId()] = new Thread(reader, reader.getName());
ChanWriter writer = new ChanWriter(chan, sentBufs, "clnt writer thread " + chan.getId());
writers[chan.getId()] = new Thread(writer, writer.getName());
// readers[chan.getId()].start();
// readers[chan.getId()].start();
writers[chan.getId()].start();
channels.add(chan);
}

View file

@ -82,7 +82,7 @@ public class MultiplexTests extends TestCase {
@Override
public void run() {
try{
try {
synchronized (MultiplexTests.this) {
System.out.println(getName() + " started");
}
@ -125,7 +125,7 @@ public class MultiplexTests extends TestCase {
@Override
public void run() {
try{
try {
synchronized (MultiplexTests.this) {
System.out.println(getName() + " started");
}
@ -147,7 +147,6 @@ public class MultiplexTests extends TestCase {
}
}
public void testChannels() {
try {
final PipedInputStream inClnt = new PipedInputStream();
@ -173,7 +172,8 @@ public class MultiplexTests extends TestCase {
StreamChannelManager mpxClnt = startMpxClient(inClnt, outClnt);
List<StreamChannel> channels = runChannelTest(mpxClnt, testers, clntReaders, clntWriters, clntSentBufs, clntRecvBufs);
List<StreamChannel> channels = runChannelTest(mpxClnt, testers, clntReaders, clntWriters, clntSentBufs,
clntRecvBufs);
// Make sure all the testers have finished
for (int i = 0; i < NUM_THREADS; i++) {
@ -204,19 +204,23 @@ public class MultiplexTests extends TestCase {
}
}
private List<StreamChannel> runChannelTest(final StreamChannelManager mpx, final Thread[] testers, final Thread[][] readers, final Thread[][] writers, final List<List<Integer>> sentBufs, final List<List<Integer>> recvBufs) throws IOException {
private List<StreamChannel> runChannelTest(final StreamChannelManager mpx, final Thread[] testers,
final Thread[][] readers, final Thread[][] writers, final List<List<Integer>> sentBufs,
final List<List<Integer>> recvBufs) throws IOException {
final List<StreamChannel> channels = new ArrayList<StreamChannel>();
for (int i = 0 ; i < NUM_THREADS; i++) {
for (int i = 0; i < NUM_THREADS; i++) {
final int thread = i;
testers[i] = new Thread("client test thread " + thread) {
@Override
public void run() {
try {
for (int j = 0 ; j < NUM_CHANS_PER_THREAD; j++) {
for (int j = 0; j < NUM_CHANS_PER_THREAD; j++) {
StreamChannel chan = mpx.openChannel();
ChanReader reader = new ChanReader(chan, recvBufs.get(thread * NUM_CHANS_PER_THREAD + j), "clnt reader thread=" + thread + " chan=" + chan.getId());
ChanReader reader = new ChanReader(chan, recvBufs.get(thread * NUM_CHANS_PER_THREAD + j),
"clnt reader thread=" + thread + " chan=" + chan.getId());
readers[thread][j] = new Thread(reader, reader.getName());
ChanWriter writer = new ChanWriter(chan, sentBufs.get(thread * NUM_CHANS_PER_THREAD + j), "clnt writer thread=" + thread + " chan=" + chan.getId());
ChanWriter writer = new ChanWriter(chan, sentBufs.get(thread * NUM_CHANS_PER_THREAD + j),
"clnt writer thread=" + thread + " chan=" + chan.getId());
writers[thread][j] = new Thread(writer, writer.getName());
readers[thread][j].start();
writers[thread][j].start();
@ -238,7 +242,8 @@ public class MultiplexTests extends TestCase {
return mpx;
}
private StreamChannelManager startMpxServer(InputStream in, OutputStream out, final Thread[] rws) throws IOException {
private StreamChannelManager startMpxServer(InputStream in, OutputStream out, final Thread[] rws)
throws IOException {
final StreamChannelManager mpx = new StreamChannelManager(in, out);
mpx.setServer(true);
mpx.addListener(new IChannelListener() {
@ -247,7 +252,7 @@ public class MultiplexTests extends TestCase {
@Override
public void newChannel(final StreamChannel chan) {
synchronized (MultiplexTests.this) {
System.out.println("newChannel "+chan.getId());
System.out.println("newChannel " + chan.getId());
}
ChanReaderWriter rw = new ChanReaderWriter(chan, "svr rw thread " + numThreadChans);
@ -257,10 +262,10 @@ public class MultiplexTests extends TestCase {
@Override
public void closeChannel(StreamChannel chan) {
// readers[idx].interrupt();
// writers[idx].interrupt();
// readers[idx].interrupt();
// writers[idx].interrupt();
synchronized (MultiplexTests.this) {
System.out.println("closeChannel "+ chan.getId());
System.out.println("closeChannel " + chan.getId());
}
}
});

View file

@ -66,14 +66,14 @@ public class ProcessTests extends TestCase {
final Set<String> results = Collections.synchronizedSet(new HashSet<String>());
IRemoteProcessBuilder builder = processService.getProcessBuilder("perl", "-v"); //$NON-NLS-1$
assertNotNull(builder);
// builder.redirectErrorStream(true);
// builder.redirectErrorStream(true);
for (int i = 0; i < 1; i++) {
try {
IRemoteProcess proc = builder.start();
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
while ((line = stdout.readLine()) != null) {
System.out.println("read "+line);
System.out.println("read " + line);
results.add(line);
results.add("\n");
}
@ -143,7 +143,7 @@ public class ProcessTests extends TestCase {
BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = stdout.readLine();
int count = Integer.parseInt(line);
for (int i = 0 ; i < count; i++) {
for (int i = 0; i < count; i++) {
line = stdout.readLine();
if (line == null) {
break;
@ -206,7 +206,7 @@ public class ProcessTests extends TestCase {
}
public void testExitValue() {
IRemoteProcessBuilder builder = processService.getProcessBuilder(new String[]{"sleep","50"}); //$NON-NLS-1$
IRemoteProcessBuilder builder = processService.getProcessBuilder(new String[] { "sleep", "50" }); //$NON-NLS-1$
assertNotNull(builder);
IRemoteProcess rp = null;
try {
@ -220,7 +220,7 @@ public class ProcessTests extends TestCase {
try {
p.exitValue();
fail("Process has not exited. Should throws an IllegalThreadStateException exception");
} catch(IllegalThreadStateException e) {
} catch (IllegalThreadStateException e) {
// Ok
}
try {
@ -241,7 +241,7 @@ public class ProcessTests extends TestCase {
IRemoteConnectionWorkingCopy wc = connType.newConnection(CONNECTION_NAME);
IRemoteConnectionHostService host = wc.getService(IRemoteConnectionHostService.class);
host.setHostname("localhost");
// host.setHostname("titan-ext1.ccs.ornl.gov");
// host.setHostname("titan-ext1.ccs.ornl.gov");
host.setUsername("gw6");
connection = wc.save();
assertNotNull(connection);

View file

@ -30,7 +30,8 @@ public class ProxyUserAuthenticator implements IUserAuthenticatorService {
IRemoteConnectionHostService hostService = conn.getService(IRemoteConnectionHostService.class);
if (hostService != null) {
try {
prompter = new UserInfoPrompter(new JSch().getSession(hostService.getUsername(), hostService.getHostname()));
prompter = new UserInfoPrompter(
new JSch().getSession(hostService.getUsername(), hostService.getHostname()));
} catch (JSchException e) {
// Not allowed
}
@ -85,8 +86,8 @@ public class ProxyUserAuthenticator implements IUserAuthenticatorService {
}
display.syncExec(() -> {
final MessageDialog dialog = new MessageDialog(display.getActiveShell(), title, null /* title image */, message,
promptType, buttons, defaultResponseIndex);
final MessageDialog dialog = new MessageDialog(display.getActiveShell(), title, null /* title image */,
message, promptType, buttons, defaultResponseIndex);
retval[0] = dialog.open();
});
return promptResponses[retval[0]];

View file

@ -226,8 +226,8 @@ public class ProxyConnectionPage extends WizardPage {
fPasswordButton.setSelection(ProxyConnection.DEFAULT_USE_PASSWORD);
fPublicKeyButton.setSelection(!ProxyConnection.DEFAULT_USE_PASSWORD);
controls.setTabList(
new Control[] { fHostText, fUserText, fPublicKeyButton, fPassphraseText, fPasswordButton, fPasswordText });
controls.setTabList(new Control[] { fHostText, fUserText, fPublicKeyButton, fPassphraseText, fPasswordButton,
fPasswordText });
}
@Override
@ -322,7 +322,8 @@ public class ProxyConnectionPage extends WizardPage {
: Boolean.parseBoolean(useDefaultServerStr);
fDefaultServerButton.setSelection(useDefaultServer);
String serverCommandStr = fConnection.getAttribute(ProxyConnection.SERVER_COMMAND_ATTR);
fServerCommandText.setText(serverCommandStr.isEmpty() ? ProxyConnection.DEFAULT_SERVER_COMMAND : serverCommandStr);
fServerCommandText
.setText(serverCommandStr.isEmpty() ? ProxyConnection.DEFAULT_SERVER_COMMAND : serverCommandStr);
} else {
fConnectionName.setText(fInitialName);
@ -438,10 +439,12 @@ public class ProxyConnectionPage extends WizardPage {
fConnection.setAttribute(ProxyConnection.USERNAME_ATTR, fUserText.getText().trim());
fConnection.setSecureAttribute(ProxyConnection.PASSWORD_ATTR, fPasswordText.getText().trim());
fConnection.setSecureAttribute(ProxyConnection.PASSPHRASE_ATTR, fPassphraseText.getText().trim());
fConnection.setAttribute(ProxyConnection.USE_PASSWORD_ATTR, Boolean.toString(fPasswordButton.getSelection()));
fConnection.setAttribute(ProxyConnection.USE_PASSWORD_ATTR,
Boolean.toString(fPasswordButton.getSelection()));
fConnection.setAttribute(ProxyConnection.TIMEOUT_ATTR, fTimeoutText.getText().trim());
fConnection.setAttribute(ProxyConnection.PORT_ATTR, fPortText.getText().trim());
fConnection.setAttribute(ProxyConnection.USE_DEFAULT_SERVER_ATTR, Boolean.toString(fDefaultServerButton.getSelection()));
fConnection.setAttribute(ProxyConnection.USE_DEFAULT_SERVER_ATTR,
Boolean.toString(fDefaultServerButton.getSelection()));
fConnection.setAttribute(ProxyConnection.SERVER_COMMAND_ATTR, fServerCommandText.getText().trim());
}
}

View file

@ -31,7 +31,6 @@ public class SerialPortCommandShell implements IRemoteProcess {
serialPort.open();
}
@Override
public synchronized void destroy() {
if (serialPort.isOpen()) {

View file

@ -69,10 +69,14 @@ public class SerialPortConnection implements ISerialPortService, IRemoteCommandS
if (portName != null) {
serialPort = new SerialPort(portName);
try {
serialPort.setBaudRate(BaudRate.fromStringIndex(Integer.parseInt(remoteConnection.getAttribute(BAUD_RATE_ATTR))));
serialPort.setByteSize(ByteSize.fromStringIndex(Integer.parseInt(remoteConnection.getAttribute(BYTE_SIZE_ATTR))));
serialPort.setParity(Parity.fromStringIndex(Integer.parseInt(remoteConnection.getAttribute(PARITY_ATTR))));
serialPort.setStopBits(StopBits.fromStringIndex(Integer.parseInt(remoteConnection.getAttribute(STOP_BITS_ATTR))));
serialPort.setBaudRate(
BaudRate.fromStringIndex(Integer.parseInt(remoteConnection.getAttribute(BAUD_RATE_ATTR))));
serialPort.setByteSize(
ByteSize.fromStringIndex(Integer.parseInt(remoteConnection.getAttribute(BYTE_SIZE_ATTR))));
serialPort.setParity(
Parity.fromStringIndex(Integer.parseInt(remoteConnection.getAttribute(PARITY_ATTR))));
serialPort.setStopBits(
StopBits.fromStringIndex(Integer.parseInt(remoteConnection.getAttribute(STOP_BITS_ATTR))));
} catch (IOException e) {
Activator.log(e);
}

View file

@ -36,7 +36,8 @@ public class Activator extends Plugin {
if (exception instanceof CoreException) {
log(((CoreException) exception).getStatus());
} else {
log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), exception.getLocalizedMessage(), exception));
log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), exception.getLocalizedMessage(),
exception));
}
}

View file

@ -55,7 +55,6 @@ public class SerialPortConnectionBlock {
private boolean isComplete;
private List<SerialBlockUpdateListener> listeners = new ArrayList<>();
/**
* Creates the UI elements for the SerialPortConnectionBlock
*
@ -188,7 +187,6 @@ public class SerialPortConnectionBlock {
}
});
updateStatus();
}
@ -205,7 +203,7 @@ public class SerialPortConnectionBlock {
isComplete = (!name.isEmpty() && portName != null);
for(SerialBlockUpdateListener listener : listeners) {
for (SerialBlockUpdateListener listener : listeners) {
listener.update();
}
}

View file

@ -22,7 +22,6 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.dialogs.PropertyPage;
public class SerialPortConnectionPropertyPage extends PropertyPage implements IWorkbenchPropertyPage {
protected SerialPortConnectionBlock block;
@ -53,7 +52,6 @@ public class SerialPortConnectionPropertyPage extends PropertyPage implements IW
else
workingCopy = null;
block.createBlock(comp, workingCopy);
return comp;
}

View file

@ -53,15 +53,15 @@ public class TelnetConnectionTests {
@BeforeClass
public static void setup() {
String host = System.getenv("TEST_HOSTNAME");
if(host != null) {
if (host != null) {
hostname = host;
}
String user = System.getenv("TEST_USERNAME");
if(user != null) {
if (user != null) {
username = user;
}
String passwd = System.getenv("TEST_PASSWORD");
if(user != null) {
if (user != null) {
password = passwd;
}
IRemoteServicesManager services = Activator.getService(IRemoteServicesManager.class);
@ -120,7 +120,7 @@ public class TelnetConnectionTests {
assertNotNull("Command shel output stream", os);
InputStream is = commandShell.getInputStream();
assertNotNull("Command shel input stream");
if(!username.isEmpty() && !password.isEmpty()) {
if (!username.isEmpty() && !password.isEmpty()) {
try {
// Assume that a login prompt appears
readPrompt(is);
@ -157,7 +157,7 @@ public class TelnetConnectionTests {
int v;
try {
v = is.read();
while((v != -1) && (v != ':')) {
while ((v != -1) && (v != ':')) {
v = is.read();
}
} catch (IOException e) {

View file

@ -21,55 +21,54 @@ package org.eclipse.remote.telnet.core;
* interface. The meanings of these constants are defined in the various TELNET RFCs
* (RFC 854 to RFC 861, and others).
*/
interface TelnetCodes
{
interface TelnetCodes {
/** Command code: Subnegotiation End. */
static final byte TELNET_SE = (byte)240;
static final byte TELNET_SE = (byte) 240;
/** Command code: No-op. */
static final byte TELNET_NOP = (byte)241;
static final byte TELNET_NOP = (byte) 241;
/** Command code: Data Mark. */
static final byte TELNET_DM = (byte)242;
static final byte TELNET_DM = (byte) 242;
/** Command code: Break. */
static final byte TELNET_BREAK = (byte)243;
static final byte TELNET_BREAK = (byte) 243;
/** Command code: Interrupt Process. */
static final byte TELNET_IP = (byte)244;
static final byte TELNET_IP = (byte) 244;
/** Command code: Abort Output. */
static final byte TELNET_AO = (byte)245;
static final byte TELNET_AO = (byte) 245;
/** Command code: Are You There. */
static final byte TELNET_AYT = (byte)246;
static final byte TELNET_AYT = (byte) 246;
/** Command code: Erase Character. */
static final byte TELNET_EC = (byte)247;
static final byte TELNET_EC = (byte) 247;
/** Command code: Erase Line. */
static final byte TELNET_EL = (byte)248;
static final byte TELNET_EL = (byte) 248;
/** Command code: Go Ahead. */
static final byte TELNET_GA = (byte)249;
static final byte TELNET_GA = (byte) 249;
/** Command code: Subnegotiation Begin. */
static final byte TELNET_SB = (byte)250;
static final byte TELNET_SB = (byte) 250;
/** Command code: Will. */
static final byte TELNET_WILL = (byte)251;
static final byte TELNET_WILL = (byte) 251;
/** Command code: Won't. */
static final byte TELNET_WONT = (byte)252;
static final byte TELNET_WONT = (byte) 252;
/** Command code: Do. */
static final byte TELNET_DO = (byte)253;
static final byte TELNET_DO = (byte) 253;
/** Command code: Don't. */
static final byte TELNET_DONT = (byte)254;
static final byte TELNET_DONT = (byte) 254;
/** Command code: Interpret As Command. */
static final byte TELNET_IAC = (byte)255;
static final byte TELNET_IAC = (byte) 255;
/** Command code: IS. */
static final byte TELNET_IS = 0;
@ -77,7 +76,6 @@ interface TelnetCodes
/** Command code: SEND. */
static final byte TELNET_SEND = 1;
/** Option code: Transmit Binary option. */
static final byte TELNET_OPTION_TRANSMIT_BINARY = 0;

View file

@ -35,7 +35,7 @@ public class TelnetCommandShell implements IRemoteProcess {
public TelnetCommandShell(IRemoteConnection remoteConnection, TelnetConnection telnetConnection) {
this.telnetConnection = telnetConnection;
assert(remoteConnection.getService(IRemoteConnectionHostService.class) != null);
assert (remoteConnection.getService(IRemoteConnectionHostService.class) != null);
}
@Override

View file

@ -27,8 +27,8 @@ import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
import org.eclipse.remote.core.exception.RemoteConnectionException;
public class TelnetConnection implements IRemoteConnectionControlService, IRemoteCommandShellService, IRemoteConnectionHostService,
IRemoteConnectionChangeListener {
public class TelnetConnection implements IRemoteConnectionControlService, IRemoteCommandShellService,
IRemoteConnectionHostService, IRemoteConnectionChangeListener {
public static int DEFAULT_PORT = 23;
public static int DEFAULT_TIMEOUT = 0; // Infinite
@ -53,7 +53,8 @@ public class TelnetConnection implements IRemoteConnectionControlService, IRemot
public <T extends Service> T getService(IRemoteConnection remoteConnection, Class<T> service) {
if (TelnetConnection.class.equals(service)) {
return (T) new TelnetConnection(remoteConnection);
} else if (IRemoteConnectionControlService.class.equals(service) || IRemoteConnectionHostService.class.equals(service)
} else if (IRemoteConnectionControlService.class.equals(service)
|| IRemoteConnectionHostService.class.equals(service)
|| IRemoteCommandShellService.class.equals(service)) {
return (T) remoteConnection.getService(TelnetConnection.class);
}

View file

@ -550,8 +550,8 @@ class TelnetOption implements TelnetCodes {
//
// IAC SB TERMINAL-TYPE IS x t e r m IAC SE
byte[] terminalTypeData = { TELNET_IAC, TELNET_SB, TELNET_OPTION_TERMINAL_TYPE, TELNET_IS, (byte) 'x', (byte) 't',
(byte) 'e', (byte) 'r', (byte) 'm', TELNET_IAC, TELNET_SE };
byte[] terminalTypeData = { TELNET_IAC, TELNET_SB, TELNET_OPTION_TERMINAL_TYPE, TELNET_IS, (byte) 'x',
(byte) 't', (byte) 'e', (byte) 'r', (byte) 'm', TELNET_IAC, TELNET_SE };
try {
outputStream.write(terminalTypeData);

View file

@ -349,7 +349,8 @@ public class TelnetProtocol extends Thread implements TelnetCodes {
// A "socket closed" exception is normal here. It's caused by the
// user clicking the disconnect button on the Terminal view toolbar.
if (message != null && !message.equalsIgnoreCase("Socket closed") && !message.equalsIgnoreCase("Connection reset")) { //$NON-NLS-1$ //$NON-NLS-2$
if (message != null && !message.equalsIgnoreCase("Socket closed") //$NON-NLS-1$
&& !message.equalsIgnoreCase("Connection reset")) { //$NON-NLS-1$
Logger.logException(ex);
}
@ -359,21 +360,21 @@ public class TelnetProtocol extends Thread implements TelnetCodes {
// Tell the command shell that we have terminated
shell.terminated();
try {
if(inputChannel != null) {
if (inputChannel != null) {
inputChannel.close();
}
} catch (IOException ioe) {
/* ignore */
}
try {
if(serverOutputStream != null) {
if (serverOutputStream != null) {
serverOutputStream.close();
}
} catch (IOException ioe) {
/* ignore */
}
try {
if(clientOutputStream != null) {
if (clientOutputStream != null) {
clientOutputStream.close();
}
} catch (IOException ioe) {
@ -592,7 +593,8 @@ public class TelnetProtocol extends Thread implements TelnetCodes {
// of 255, it is necessary to double this byte in accordance
// the general TELNET rules."
if (nextSubnegotiationByteIndex > 0 && receivedSubnegotiation[nextSubnegotiationByteIndex - 1] == TELNET_IAC) {
if (nextSubnegotiationByteIndex > 0
&& receivedSubnegotiation[nextSubnegotiationByteIndex - 1] == TELNET_IAC) {
// The last input byte we received in this
// subnegotiation was IAC, so this is a double IAC. Leave the previous IAC
// in the receivedSubnegotiation[] array and drop the current
@ -645,7 +647,8 @@ public class TelnetProtocol extends Thread implements TelnetCodes {
int subnegotiatedOption = receivedSubnegotiation[0] & 0xFF;
localOptions[subnegotiatedOption].handleSubnegotiation(receivedSubnegotiation, nextSubnegotiationByteIndex);
localOptions[subnegotiatedOption].handleSubnegotiation(receivedSubnegotiation,
nextSubnegotiationByteIndex);
} else {
Logger.log("NOT CALLING handleSubnegotiation() BECAUSE OF ERRORS!"); //$NON-NLS-1$
}

View file

@ -44,7 +44,8 @@ public class Activator extends Plugin {
if (e instanceof CoreException) {
log(((CoreException) e).getStatus());
} else {
log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), IStatus.ERROR, e.getLocalizedMessage(), e));
log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), IStatus.ERROR, e.getLocalizedMessage(),
e));
}
}

View file

@ -178,7 +178,8 @@ public final class Logger implements DebugOptionsListener {
public static final void logException(Exception ex) {
// log in eclipse error log
if (Activator.getDefault() != null) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex));
Activator.getDefault().getLog()
.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex));
} else {
ex.printStackTrace();
}

View file

@ -35,6 +35,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* Provides tests to several scenarios but they should be
* executed manually (i.e. browse and click OK)
@ -105,6 +106,7 @@ public class RemoteResourceBrowserTest {
public static void tearDown() throws RemoteConnectionException {
fConnectionType.removeConnection(fRemoteConnection);
}
/*
* Select any file.
*/
@ -119,6 +121,7 @@ public class RemoteResourceBrowserTest {
assertNotNull(expectedResource);
assertTrue(!expectedResource.fetchInfo().isDirectory());
}
/*
* Select any directory.
*/
@ -133,6 +136,7 @@ public class RemoteResourceBrowserTest {
assertNotNull(expectedResource);
assertTrue(expectedResource.fetchInfo().isDirectory());
}
/*
* Select either file or directory.
*/
@ -145,6 +149,7 @@ public class RemoteResourceBrowserTest {
expectedResource = browser.getResource();
assertNotNull(expectedResource);
}
/*
* Select more than one resource.
*/
@ -158,6 +163,7 @@ public class RemoteResourceBrowserTest {
assertNotNull(expectedResources);
assertTrue(expectedResources.size() > 0);
}
/*
* Select to local connection and select a directory.
*/
@ -174,6 +180,7 @@ public class RemoteResourceBrowserTest {
assertNotNull(expectedResource);
assertEquals(expectedResource.getFileSystem().getScheme(), "file");
}
/*
* Initial path set.
*/
@ -187,6 +194,7 @@ public class RemoteResourceBrowserTest {
browser.setInitialPath(initialPath);
browser.open();
}
/*
* Show connections.
* Don't show hidden check box and new folder button.

View file

@ -67,7 +67,8 @@ public class DeferredFileStore implements IDeferredWorkbenchAdapter, IAdaptable
IFileInfo[] childInfos = fFileStore.childInfos(EFS.NONE, monitor);
for (IFileInfo info : childInfos) {
if (!(fExcludeHidden && info.getName().startsWith("."))) { //$NON-NLS-1$
children.add(new DeferredFileStore(fFileStore.getChild(info.getName()), info, fExcludeHidden, this));
children.add(
new DeferredFileStore(fFileStore.getChild(info.getName()), info, fExcludeHidden, this));
}
}
} catch (CoreException e) {

View file

@ -192,7 +192,8 @@ public class RemoteTreeContentManager {
* @param monitor
* progress monitor
*/
protected void replaceChildren(final Object parent, final Object[] children, final int offset, IProgressMonitor monitor) {
protected void replaceChildren(final Object parent, final Object[] children, final int offset,
IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return;
}

View file

@ -49,9 +49,12 @@ public class RemoteUIImages {
public static final ImageDescriptor DESC_ELCL_UP_NAV = createManaged(T_ELCL, "up_nav.gif", IMG_ELCL_UP_NAV); //$NON-NLS-1$
public static final ImageDescriptor DESC_DLCL_UP_NAV = createManaged(T_DLCL, "up_nav.gif", IMG_ELCL_UP_NAV); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_SYMLINK = createManaged(T_OVR, "symlink_ovr.gif", IMG_OVR_SYMLINK); //$NON-NLS-1$
public static final ImageDescriptor DESC_ELCL_NEW_FOLDER = createManaged(T_ELCL, "new_folder.gif", IMG_ELCL_NEW_FOLDER); //$NON-NLS-1$
public static final ImageDescriptor DESC_DLCL_NEW_FOLDER = createManaged(T_DLCL, "new_folder.gif", IMG_DLCL_NEW_FOLDER); //$NON-NLS-1$
public static final ImageDescriptor DESC_DEFAULT_TYPE = createManaged(ICONS_PATH.append("console.png"), IMG_DEFAULT_TYPE); //$NON-NLS-1$
public static final ImageDescriptor DESC_ELCL_NEW_FOLDER = createManaged(T_ELCL, "new_folder.gif", //$NON-NLS-1$
IMG_ELCL_NEW_FOLDER);
public static final ImageDescriptor DESC_DLCL_NEW_FOLDER = createManaged(T_DLCL, "new_folder.gif", //$NON-NLS-1$
IMG_DLCL_NEW_FOLDER);
public static final ImageDescriptor DESC_DEFAULT_TYPE = createManaged(ICONS_PATH.append("console.png"), //$NON-NLS-1$
IMG_DEFAULT_TYPE);
/**
* Returns the image managed under the given key in this registry.

View file

@ -68,7 +68,8 @@ public class RemoteUIPlugin extends AbstractUIPlugin {
* @since 5.0
*/
public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, Messages.PTPRemoteUIPlugin_3, e));
log(new Status(IStatus.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR,
Messages.PTPRemoteUIPlugin_3, e));
}
/**

View file

@ -17,7 +17,8 @@ public class ServicePropertyTester extends PropertyTester {
String serviceName = (String) args[0];
try {
Class<?> service = Class.forName(serviceName);
return connection.getConnectionType().hasService((Class<IRemoteConnectionType.Service>) service);
return connection.getConnectionType()
.hasService((Class<IRemoteConnectionType.Service>) service);
} catch (ClassNotFoundException e) {
return false;
}
@ -35,14 +36,16 @@ public class ServicePropertyTester extends PropertyTester {
} else if (property.equals("canDelete")) { //$NON-NLS-1$
return connection.getConnectionType().canRemove();
} else if (property.equals("canOpen")) { //$NON-NLS-1$
IRemoteConnectionControlService controlService = connection.getService(IRemoteConnectionControlService.class);
IRemoteConnectionControlService controlService = connection
.getService(IRemoteConnectionControlService.class);
if (controlService != null) {
return !connection.isOpen();
} else {
return false;
}
} else if (property.equals("canClose")) { //$NON-NLS-1$
IRemoteConnectionControlService controlService = connection.getService(IRemoteConnectionControlService.class);
IRemoteConnectionControlService controlService = connection
.getService(IRemoteConnectionControlService.class);
if (controlService != null) {
return connection.isOpen();
} else {

View file

@ -112,7 +112,8 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
IRemoteConnection connection = getOriginalIfClean((IRemoteConnection) element);
switch (columnIndex) {
case 0:
return connection.isOpen() ? Messages.ConnectionsPreferencePage_open : Messages.ConnectionsPreferencePage_closed;
return connection.isOpen() ? Messages.ConnectionsPreferencePage_open
: Messages.ConnectionsPreferencePage_closed;
case 1:
return connection.getName();
case 2:
@ -229,8 +230,8 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
*/
private void addConnection() {
if (fIsDirty) {
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions, null,
Messages.ConnectionsPreferencePage_There_are_unsaved_changes, MessageDialog.QUESTION,
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions,
null, Messages.ConnectionsPreferencePage_There_are_unsaved_changes, MessageDialog.QUESTION,
new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
if (dialog.open() == 1) {
return;
@ -524,9 +525,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
if (conn instanceof IRemoteConnectionWorkingCopy) {
IRemoteConnectionWorkingCopy wc = (IRemoteConnectionWorkingCopy) conn;
if (wc.isDirty()) {
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions,
null, Messages.ConnectionsPreferencePage_This_connection_contains_unsaved_changes,
MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
MessageDialog dialog = new MessageDialog(getShell(),
Messages.ConnectionsPreferencePage_Confirm_Actions, null,
Messages.ConnectionsPreferencePage_This_connection_contains_unsaved_changes,
MessageDialog.QUESTION,
new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
if (dialog.open() == 1) {
return;
}

View file

@ -56,7 +56,7 @@ public class RemoteDevelopmentPreferencePage extends FieldEditorPreferencePage i
namesAndValues.add(nameAndValue);
}
addField(new ComboFieldEditor(IRemotePreferenceConstants.PREF_CONNECTION_TYPE_ID,
Messages.RemoteDevelopmentPreferencePage_Default_connection_type, namesAndValues.toArray(new String[namesAndValues
.size()][2]), getFieldEditorParent()));
Messages.RemoteDevelopmentPreferencePage_Default_connection_type,
namesAndValues.toArray(new String[namesAndValues.size()][2]), getFieldEditorParent()));
}
}

View file

@ -37,7 +37,8 @@ import org.eclipse.swt.widgets.Shell;
public abstract class AbstractRemoteUIConnectionService implements IRemoteUIConnectionService {
@Override
public void openConnectionWithProgress(final Shell shell, IRunnableContext context, final IRemoteConnection connection) {
public void openConnectionWithProgress(final Shell shell, IRunnableContext context,
final IRemoteConnection connection) {
if (!connection.isOpen()) {
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
@ -60,12 +61,12 @@ public abstract class AbstractRemoteUIConnectionService implements IRemoteUIConn
}
} catch (InvocationTargetException e) {
ErrorDialog.openError(shell, Messages.AbstractRemoteUIConnectionManager_Connection_Error,
Messages.AbstractRemoteUIConnectionManager_Could_not_open_connection, new Status(IStatus.ERROR,
RemoteUIPlugin.PLUGIN_ID, e.getCause().getMessage()));
Messages.AbstractRemoteUIConnectionManager_Could_not_open_connection,
new Status(IStatus.ERROR, RemoteUIPlugin.PLUGIN_ID, e.getCause().getMessage()));
} catch (InterruptedException e) {
ErrorDialog.openError(shell, Messages.AbstractRemoteUIConnectionManager_Connection_Error,
Messages.AbstractRemoteUIConnectionManager_Could_not_open_connection, new Status(IStatus.ERROR,
RemoteUIPlugin.PLUGIN_ID, e.getMessage()));
Messages.AbstractRemoteUIConnectionManager_Could_not_open_connection,
new Status(IStatus.ERROR, RemoteUIPlugin.PLUGIN_ID, e.getMessage()));
}
}
}

View file

@ -60,7 +60,8 @@ public class RemoteConnectionsLabelProvider extends LabelProvider {
String closedId = "closed." + type.getId(); //$NON-NLS-1$
Image closedImage = RemoteUIPlugin.getDefault().getImageRegistry().get(closedId);
if (closedImage == null) {
final Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEC_FIELD_ERROR);
final Image errorImage = PlatformUI.getWorkbench().getSharedImages()
.getImage(ISharedImages.IMG_DEC_FIELD_ERROR);
ImageDescriptor desc = new CompositeImageDescriptor() {
@Override
protected Point getSize() {

View file

@ -218,8 +218,8 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
}
@Override
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException,
InterruptedException {
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
throws InvocationTargetException, InterruptedException {
fProgressMonitor.attachToCancelComponent(null);
fProgressMonitor.getParent().setVisible(true);
try {

View file

@ -186,7 +186,8 @@ public class RemoteDirectoryWidget extends Composite {
throw new NullPointerException();
}
if (conn.hasService(IRemoteFileService.class) && conn.getConnectionType().hasService(IRemoteUIConnectionService.class)
if (conn.hasService(IRemoteFileService.class)
&& conn.getConnectionType().hasService(IRemoteUIConnectionService.class)
&& conn.getConnectionType().hasService(IRemoteUIFileService.class) && !conn.equals(fRemoteConnection)) {
fRemoteConnection = conn;
String path = getSavedPath();
@ -225,7 +226,8 @@ public class RemoteDirectoryWidget extends Composite {
private String getSavedPath() {
if (fRemoteConnection != null) {
return previousSelections.get(fRemoteConnection.getConnectionType().getId() + "." + fRemoteConnection.getName()); //$NON-NLS-1$
return previousSelections
.get(fRemoteConnection.getConnectionType().getId() + "." + fRemoteConnection.getName()); //$NON-NLS-1$
}
return null;
}
@ -265,7 +267,8 @@ public class RemoteDirectoryWidget extends Composite {
private void setSavedPath(String path) {
if (fRemoteConnection != null) {
previousSelections.put(fRemoteConnection.getConnectionType().getId() + "." + fRemoteConnection.getName(), path); //$NON-NLS-1$
previousSelections.put(fRemoteConnection.getConnectionType().getId() + "." + fRemoteConnection.getName(), //$NON-NLS-1$
path);
}
}

View file

@ -166,7 +166,8 @@ public class RemoteFileWidget extends Composite {
private String getSavedPath() {
if (fRemoteConnection != null) {
return fPreviousSelections.get(fRemoteConnection.getConnectionType().getId() + "." + fRemoteConnection.getName()); //$NON-NLS-1$
return fPreviousSelections
.get(fRemoteConnection.getConnectionType().getId() + "." + fRemoteConnection.getName()); //$NON-NLS-1$
}
return null;
}
@ -241,7 +242,8 @@ public class RemoteFileWidget extends Composite {
throw new NullPointerException();
}
if (conn.hasService(IRemoteFileService.class) && conn.getConnectionType().hasService(IRemoteUIConnectionService.class)
if (conn.hasService(IRemoteFileService.class)
&& conn.getConnectionType().hasService(IRemoteUIConnectionService.class)
&& conn.getConnectionType().hasService(IRemoteUIFileService.class) && !conn.equals(fRemoteConnection)) {
fRemoteConnection = conn;
String path = getSavedPath();
@ -284,7 +286,8 @@ public class RemoteFileWidget extends Composite {
private void setSavedPath(String path) {
if (fRemoteConnection != null) {
fPreviousSelections.put(fRemoteConnection.getConnectionType().getId() + "." + fRemoteConnection.getName(), path); //$NON-NLS-1$
fPreviousSelections.put(fRemoteConnection.getConnectionType().getId() + "." + fRemoteConnection.getName(), //$NON-NLS-1$
path);
}
}

View file

@ -322,8 +322,8 @@ public class RemoteResourceBrowserWidget extends Composite {
fTreeViewer.refresh(element);
Object[] children = element.getChildren(null);
for (Object child : children) {
if (child instanceof DeferredFileStore
&& newPath.equals(((DeferredFileStore) child).getFileStore().getName())) {
if (child instanceof DeferredFileStore && newPath
.equals(((DeferredFileStore) child).getFileStore().getName())) {
fTreeViewer.deferSelection(new StructuredSelection(child));
}
}
@ -404,7 +404,7 @@ public class RemoteResourceBrowserWidget extends Composite {
/*
* Only add filter if we are a directory browser. File and resource browsers show everything.
*/
int mask = FILE_BROWSER|DIRECTORY_BROWSER;
int mask = FILE_BROWSER | DIRECTORY_BROWSER;
if ((fOptionFlags & mask) != mask // Avoid filter on resource browsers.
&& (fOptionFlags & DIRECTORY_BROWSER) != 0) {
fTreeViewer.addFilter(new ViewerFilter() {
@ -535,7 +535,8 @@ public class RemoteResourceBrowserWidget extends Composite {
@Override
public void run() {
ErrorDialog.openError(getShell(), Messages.RemoteResourceBrowserWidget_New_Folder,
Messages.RemoteResourceBrowserWidget_Unable_to_create_new_folder, e.getStatus());
Messages.RemoteResourceBrowserWidget_Unable_to_create_new_folder,
e.getStatus());
}
});
}
@ -544,8 +545,9 @@ public class RemoteResourceBrowserWidget extends Composite {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
DelayedInputDialog dialog = new DelayedInputDialog(getShell(), Messages.RemoteResourceBrowserWidget_1,
Messages.RemoteResourceBrowserWidget_2, basePath.getName(), new IInputValidator() {
DelayedInputDialog dialog = new DelayedInputDialog(getShell(),
Messages.RemoteResourceBrowserWidget_1, Messages.RemoteResourceBrowserWidget_2,
basePath.getName(), new IInputValidator() {
@Override
public String isValid(String newText) {
if (!newText.equals("")) { //$NON-NLS-1$
@ -577,7 +579,8 @@ public class RemoteResourceBrowserWidget extends Composite {
@Override
public void run() {
ErrorDialog.openError(getShell(), Messages.RemoteResourceBrowserWidget_New_Folder,
Messages.RemoteResourceBrowserWidget_Unable_to_create_new_folder, e.getStatus());
Messages.RemoteResourceBrowserWidget_Unable_to_create_new_folder,
e.getStatus());
}
});
}