mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Reformat with Eclipse style
This commit is contained in:
parent
95eb3ec719
commit
e25a596063
1 changed files with 223 additions and 214 deletions
|
@ -48,21 +48,22 @@ import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
public class TelnetConnectorService extends StandardConnectorService implements ITelnetSessionProvider {
|
public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
|
ITelnetSessionProvider {
|
||||||
public static final String PROPERTY_SET_NAME="Telnet Settings"; //$NON-NLS-1$
|
|
||||||
public static final String PROPERTY_LOGIN_REQUIRED="Login.Required"; //$NON-NLS-1$
|
public static final String PROPERTY_SET_NAME = "Telnet Settings"; //$NON-NLS-1$
|
||||||
public static final String PROPERTY_LOGIN_PROMPT="Login.Prompt"; //$NON-NLS-1$
|
public static final String PROPERTY_LOGIN_REQUIRED = "Login.Required"; //$NON-NLS-1$
|
||||||
public static final String PROPERTY_PASSWORD_PROMPT="Password.Prompt"; //$NON-NLS-1$
|
public static final String PROPERTY_LOGIN_PROMPT = "Login.Prompt"; //$NON-NLS-1$
|
||||||
public static final String PROPERTY_COMMAND_PROMPT="Command.Prompt"; //$NON-NLS-1$
|
public static final String PROPERTY_PASSWORD_PROMPT = "Password.Prompt"; //$NON-NLS-1$
|
||||||
|
public static final String PROPERTY_COMMAND_PROMPT = "Command.Prompt"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final int TELNET_DEFAULT_PORT = 23;
|
private static final int TELNET_DEFAULT_PORT = 23;
|
||||||
private static TelnetClient fTelnetClient = new TelnetClient();
|
private static TelnetClient fTelnetClient = new TelnetClient();
|
||||||
private SessionLostHandler fSessionLostHandler;
|
private SessionLostHandler fSessionLostHandler;
|
||||||
private InputStream in;
|
private InputStream in;
|
||||||
private PrintStream out;
|
private PrintStream out;
|
||||||
private IPropertySet telnetPropertySet = null;
|
private IPropertySet telnetPropertySet = null;
|
||||||
|
|
||||||
public TelnetConnectorService(IHost host) {
|
public TelnetConnectorService(IHost host) {
|
||||||
super(TelnetConnectorResources.TelnetConnectorService_Name,
|
super(TelnetConnectorResources.TelnetConnectorService_Name,
|
||||||
TelnetConnectorResources.TelnetConnectorService_Description,
|
TelnetConnectorResources.TelnetConnectorService_Description,
|
||||||
|
@ -70,18 +71,20 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
fSessionLostHandler = null;
|
fSessionLostHandler = null;
|
||||||
telnetPropertySet = getTelnetPropertySet();
|
telnetPropertySet = getTelnetPropertySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the telnet property set, and fill it with default
|
* Return the telnet property set, and fill it with default values if it has
|
||||||
* values if it has not been created yet.
|
* not been created yet. Extenders may override in order to set different
|
||||||
* Extenders may override in order to set different default values.
|
* default values.
|
||||||
|
*
|
||||||
* @return a property set holding properties understood by the telnet
|
* @return a property set holding properties understood by the telnet
|
||||||
* connector service.
|
* connector service.
|
||||||
*/
|
*/
|
||||||
protected IPropertySet getTelnetPropertySet() {
|
protected IPropertySet getTelnetPropertySet() {
|
||||||
IPropertySet telnetSet = getPropertySet(PROPERTY_SET_NAME);
|
IPropertySet telnetSet = getPropertySet(PROPERTY_SET_NAME);
|
||||||
if (telnetSet == null) {
|
if (telnetSet == null) {
|
||||||
telnetSet = createPropertySet(PROPERTY_SET_NAME, TelnetConnectorResources.PropertySet_Description);
|
telnetSet = createPropertySet(PROPERTY_SET_NAME,
|
||||||
|
TelnetConnectorResources.PropertySet_Description);
|
||||||
telnetSet.addProperty(PROPERTY_LOGIN_REQUIRED,
|
telnetSet.addProperty(PROPERTY_LOGIN_REQUIRED,
|
||||||
"true", PropertyType.getEnumPropertyType(new String[] { "true", "false" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"true", PropertyType.getEnumPropertyType(new String[] { "true", "false" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
telnetSet.addProperty(PROPERTY_LOGIN_PROMPT,
|
telnetSet.addProperty(PROPERTY_LOGIN_PROMPT,
|
||||||
|
@ -98,75 +101,79 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void internalConnect(IProgressMonitor monitor) throws Exception {
|
protected void internalConnect(IProgressMonitor monitor) throws Exception {
|
||||||
String host = getHostName();
|
String host = getHostName();
|
||||||
String user = getUserId();
|
String user = getUserId();
|
||||||
String password = ""; //$NON-NLS-1$
|
String password = ""; //$NON-NLS-1$
|
||||||
telnetPropertySet = getTelnetPropertySet();
|
telnetPropertySet = getTelnetPropertySet();
|
||||||
String login_required = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_REQUIRED);
|
String login_required = telnetPropertySet
|
||||||
String login_prompt = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_PROMPT);
|
.getPropertyValue(PROPERTY_LOGIN_REQUIRED);
|
||||||
String password_prompt = telnetPropertySet.getPropertyValue(PROPERTY_PASSWORD_PROMPT);
|
String login_prompt = telnetPropertySet
|
||||||
String command_prompt = telnetPropertySet.getPropertyValue(PROPERTY_COMMAND_PROMPT);
|
.getPropertyValue(PROPERTY_LOGIN_PROMPT);
|
||||||
try {
|
String password_prompt = telnetPropertySet
|
||||||
Activator.trace("Telnet Service: Connecting....."); //$NON-NLS-1$
|
.getPropertyValue(PROPERTY_PASSWORD_PROMPT);
|
||||||
fTelnetClient.connect(host,TELNET_DEFAULT_PORT );
|
String command_prompt = telnetPropertySet
|
||||||
ICredentials cred = getCredentialsProvider().getCredentials();
|
.getPropertyValue(PROPERTY_COMMAND_PROMPT);
|
||||||
if (cred!=null) {
|
try {
|
||||||
password = cred.getPassword();
|
Activator.trace("Telnet Service: Connecting....."); //$NON-NLS-1$
|
||||||
}
|
fTelnetClient.connect(host, TELNET_DEFAULT_PORT);
|
||||||
|
ICredentials cred = getCredentialsProvider().getCredentials();
|
||||||
in = fTelnetClient.getInputStream();
|
if (cred != null) {
|
||||||
out = new PrintStream( fTelnetClient.getOutputStream() );
|
password = cred.getPassword();
|
||||||
//Send login and password if needed
|
}
|
||||||
if( Boolean.valueOf(login_required ).booleanValue() ) {
|
|
||||||
if (login_prompt!=null && login_prompt.length()>0) {
|
in = fTelnetClient.getInputStream();
|
||||||
readUntil(login_prompt);
|
out = new PrintStream(fTelnetClient.getOutputStream());
|
||||||
write(user);
|
// Send login and password if needed
|
||||||
}
|
if (Boolean.valueOf(login_required).booleanValue()) {
|
||||||
if (password_prompt!=null && password_prompt.length()>0) {
|
if (login_prompt != null && login_prompt.length() > 0) {
|
||||||
readUntil(password_prompt);
|
readUntil(login_prompt);
|
||||||
write(password);
|
write(user);
|
||||||
}
|
}
|
||||||
}
|
if (password_prompt != null && password_prompt.length() > 0) {
|
||||||
if (command_prompt!=null && command_prompt.length()>0) {
|
readUntil(password_prompt);
|
||||||
readUntil(command_prompt);
|
write(password);
|
||||||
}
|
}
|
||||||
Activator.trace("Telnet Service: Connected"); //$NON-NLS-1$
|
}
|
||||||
}catch( SocketException se) {
|
if (command_prompt != null && command_prompt.length() > 0) {
|
||||||
Activator.trace("Telnet Service failed: "+se.toString()); //$NON-NLS-1$
|
readUntil(command_prompt);
|
||||||
sessionDisconnect();
|
}
|
||||||
}catch( IOException ioe ) {
|
Activator.trace("Telnet Service: Connected"); //$NON-NLS-1$
|
||||||
Activator.trace("Telnet Service failed: "+ioe.toString()); //$NON-NLS-1$
|
} catch (SocketException se) {
|
||||||
sessionDisconnect();
|
Activator.trace("Telnet Service failed: " + se.toString()); //$NON-NLS-1$
|
||||||
}
|
sessionDisconnect();
|
||||||
|
} catch (IOException ioe) {
|
||||||
fSessionLostHandler = new SessionLostHandler( this );
|
Activator.trace("Telnet Service failed: " + ioe.toString()); //$NON-NLS-1$
|
||||||
|
sessionDisconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
fSessionLostHandler = new SessionLostHandler(this);
|
||||||
notifyConnection();
|
notifyConnection();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect the telnet session.
|
* Disconnect the telnet session. Synchronized in order to avoid NPE's from
|
||||||
* Synchronized in order to avoid NPE's from commons.net when called
|
* commons.net when called quickly in succession.
|
||||||
* quickly in succession.
|
|
||||||
*/
|
*/
|
||||||
private synchronized void sessionDisconnect() {
|
private synchronized void sessionDisconnect() {
|
||||||
Activator.trace("TelnetConnectorService.sessionDisconnect"); //$NON-NLS-1$
|
Activator.trace("TelnetConnectorService.sessionDisconnect"); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
if (fTelnetClient!=null) {
|
if (fTelnetClient != null) {
|
||||||
synchronized(fTelnetClient) {
|
synchronized (fTelnetClient) {
|
||||||
if (fTelnetClient.isConnected())
|
if (fTelnetClient.isConnected())
|
||||||
fTelnetClient.disconnect();
|
fTelnetClient.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
//Avoid NPE on disconnect shown in UI
|
// Avoid NPE on disconnect shown in UI
|
||||||
//This is a non-critical exception so print only in debug mode
|
// This is a non-critical exception so print only in debug mode
|
||||||
if (Activator.isTracingOn()) e.printStackTrace();
|
if (Activator.isTracingOn())
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readUntil(String pattern) {
|
public String readUntil(String pattern) {
|
||||||
try {
|
try {
|
||||||
char lastChar = pattern.charAt(pattern.length() - 1);
|
char lastChar = pattern.charAt(pattern.length() - 1);
|
||||||
|
@ -185,139 +192,136 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
ch = in.read();
|
ch = in.read();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SystemBasePlugin.logError(e.getMessage()==null ? e.getClass().getName() : e.getMessage(), e);
|
SystemBasePlugin.logError(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write( String value ) {
|
public void write(String value) {
|
||||||
try {
|
try {
|
||||||
out.println( value );
|
out.println(value);
|
||||||
out.flush();
|
out.flush();
|
||||||
if (Activator.isTracingOn()) {
|
if (Activator.isTracingOn()) {
|
||||||
//Avoid printing password to stdout
|
// Avoid printing password to stdout
|
||||||
//Activator.trace("write: "+value ); //$NON-NLS-1$
|
// Activator.trace("write: "+value ); //$NON-NLS-1$
|
||||||
int len = value.length()+6;
|
int len = value.length() + 6;
|
||||||
Activator.trace("write: ******************".substring(0, len<=24 ? len : 24)); //$NON-NLS-1$
|
Activator.trace("write: ******************".substring(0, len <= 24 ? len : 24)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch( Exception e ) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void internalDisconnect(IProgressMonitor monitor) throws Exception {
|
protected void internalDisconnect(IProgressMonitor monitor)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
Activator.trace("Telnet Service: Disconnecting ....."); //$NON-NLS-1$
|
Activator.trace("Telnet Service: Disconnecting ....."); //$NON-NLS-1$
|
||||||
boolean sessionLost = (fSessionLostHandler!=null && fSessionLostHandler.isSessionLost());
|
boolean sessionLost = (fSessionLostHandler != null && fSessionLostHandler.isSessionLost());
|
||||||
// no more interested in handling session-lost, since we are disconnecting anyway
|
// no more interested in handling session-lost, since we are
|
||||||
|
// disconnecting anyway
|
||||||
fSessionLostHandler = null;
|
fSessionLostHandler = null;
|
||||||
// handle events
|
// handle events
|
||||||
if (sessionLost) {
|
if (sessionLost) {
|
||||||
notifyError();
|
notifyError();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Fire comm event to signal state about to change
|
// Fire comm event to signal state about to change
|
||||||
fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT);
|
fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionDisconnect();
|
sessionDisconnect();
|
||||||
|
|
||||||
// Fire comm event to signal state changed
|
// Fire comm event to signal state changed
|
||||||
notifyDisconnection();
|
notifyDisconnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TelnetClient getTelnetClient() {
|
public TelnetClient getTelnetClient() {
|
||||||
return fTelnetClient;
|
return fTelnetClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle session-lost events.
|
* Handle session-lost events. This is generic for any sort of connector
|
||||||
* This is generic for any sort of connector service.
|
* service. Most of this is extracted from dstore's
|
||||||
* Most of this is extracted from dstore's ConnectionStatusListener.
|
* ConnectionStatusListener.
|
||||||
*
|
*
|
||||||
* TODO should be refactored to make it generally available, and allow
|
* TODO should be refactored to make it generally available, and allow
|
||||||
* dstore to derive from it.
|
* dstore to derive from it.
|
||||||
*/
|
*/
|
||||||
public static class SessionLostHandler implements Runnable, IRunnableWithProgress
|
public static class SessionLostHandler implements Runnable,
|
||||||
{
|
IRunnableWithProgress {
|
||||||
private IConnectorService _connection;
|
private IConnectorService _connection;
|
||||||
private boolean fSessionLost;
|
private boolean fSessionLost;
|
||||||
|
|
||||||
public SessionLostHandler(IConnectorService cs)
|
public SessionLostHandler(IConnectorService cs) {
|
||||||
{
|
|
||||||
_connection = cs;
|
_connection = cs;
|
||||||
fSessionLost = false;
|
fSessionLost = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify that the connection has been lost. This may be called
|
* Notify that the connection has been lost. This may be called multiple
|
||||||
* multiple times from multiple subsystems. The SessionLostHandler
|
* times from multiple subsystems. The SessionLostHandler ensures that
|
||||||
* ensures that actual user feedback and disconnect actions are
|
* actual user feedback and disconnect actions are done only once, on
|
||||||
* done only once, on the first invocation.
|
* the first invocation.
|
||||||
*/
|
*/
|
||||||
public void sessionLost()
|
public void sessionLost() {
|
||||||
{
|
// avoid duplicate execution of sessionLost
|
||||||
//avoid duplicate execution of sessionLost
|
boolean showSessionLostDlg = false;
|
||||||
boolean showSessionLostDlg=false;
|
synchronized (this) {
|
||||||
synchronized(this) {
|
|
||||||
if (!fSessionLost) {
|
if (!fSessionLost) {
|
||||||
fSessionLost = true;
|
fSessionLost = true;
|
||||||
showSessionLostDlg=true;
|
showSessionLostDlg = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (showSessionLostDlg) {
|
if (showSessionLostDlg) {
|
||||||
//invokes this.run() on dispatch thread
|
// invokes this.run() on dispatch thread
|
||||||
Display.getDefault().asyncExec(this);
|
Display.getDefault().asyncExec(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean isSessionLost() {
|
public synchronized boolean isSessionLost() {
|
||||||
return fSessionLost;
|
return fSessionLost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
Shell shell = getShell();
|
Shell shell = getShell();
|
||||||
//TODO need a more correct message for "session lost"
|
// TODO need a more correct message for "session lost"
|
||||||
//TODO allow users to reconnect from this dialog
|
// TODO allow users to reconnect from this dialog
|
||||||
//SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST);
|
// SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST);
|
||||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_CANCELLED);
|
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_CANCELLED);
|
||||||
msg.makeSubstitution(_connection.getPrimarySubSystem().getHost().getAliasName());
|
msg.makeSubstitution(_connection.getPrimarySubSystem().getHost().getAliasName());
|
||||||
SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg);
|
SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
try
|
try {
|
||||||
{
|
// TODO I think we should better use a Job for disconnecting?
|
||||||
//TODO I think we should better use a Job for disconnecting?
|
// But what about error messages?
|
||||||
//But what about error messages?
|
|
||||||
IRunnableContext runnableContext = getRunnableContext(getShell());
|
IRunnableContext runnableContext = getRunnableContext(getShell());
|
||||||
// will do this.run(IProgressMonitor mon)
|
// will do this.run(IProgressMonitor mon)
|
||||||
//runnableContext.run(false,true,this); // inthread, cancellable, IRunnableWithProgress
|
// runnableContext.run(false,true,this); // inthread,
|
||||||
runnableContext.run(true,true,this); // fork, cancellable, IRunnableWithProgress
|
// cancellable, IRunnableWithProgress
|
||||||
_connection.reset();
|
runnableContext.run(true, true, this); // fork, cancellable,
|
||||||
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
// IRunnableWithProgress
|
||||||
sr.connectedStatusChange(_connection.getPrimarySubSystem(), false, true, true);
|
_connection.reset();
|
||||||
}
|
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
||||||
catch (InterruptedException exc) // user cancelled
|
sr.connectedStatusChange(_connection.getPrimarySubSystem(),
|
||||||
{
|
false, true, true);
|
||||||
if (shell != null)
|
} catch (InterruptedException exc) // user cancelled
|
||||||
showDisconnectCancelledMessage(shell, _connection.getHostName(), _connection.getPort());
|
|
||||||
}
|
|
||||||
catch (java.lang.reflect.InvocationTargetException invokeExc) // unexpected error
|
|
||||||
{
|
|
||||||
Exception exc = (Exception)invokeExc.getTargetException();
|
|
||||||
if (shell != null)
|
|
||||||
showDisconnectErrorMessage(shell, _connection.getHostName(), _connection.getPort(), exc);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
|
if (shell != null)
|
||||||
|
showDisconnectCancelledMessage(shell, _connection
|
||||||
|
.getHostName(), _connection.getPort());
|
||||||
|
} catch (java.lang.reflect.InvocationTargetException invokeExc) // unexpected error
|
||||||
|
{
|
||||||
|
Exception exc = (Exception) invokeExc.getTargetException();
|
||||||
|
if (shell != null)
|
||||||
|
showDisconnectErrorMessage(shell,
|
||||||
|
_connection.getHostName(), _connection.getPort(),
|
||||||
|
exc);
|
||||||
|
} catch (Exception e) {
|
||||||
SystemBasePlugin.logError(TelnetConnectorResources.TelnetConnectorService_ErrorDisconnecting, e);
|
SystemBasePlugin.logError(TelnetConnectorResources.TelnetConnectorService_ErrorDisconnecting, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor)
|
public void run(IProgressMonitor monitor)
|
||||||
throws InvocationTargetException, InterruptedException
|
throws InvocationTargetException, InterruptedException {
|
||||||
{
|
|
||||||
String message = null;
|
String message = null;
|
||||||
message = SubSystemConfiguration.getDisconnectingMessage(
|
message = SubSystemConfiguration.getDisconnectingMessage(
|
||||||
_connection.getHostName(), _connection.getPort());
|
_connection.getHostName(), _connection.getPort());
|
||||||
|
@ -360,7 +364,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the progress monitor dialog for this operation. We try to use one
|
* Get the progress monitor dialog for this operation. We try to use one
|
||||||
* for all phases of a single operation, such as connecting and
|
* for all phases of a single operation, such as connecting and
|
||||||
* resolving.
|
* resolving.
|
||||||
|
@ -391,64 +395,68 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
return dlg;
|
return dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an error message when the disconnection fails. Shows a common
|
* Show an error message when the disconnection fails. Shows a common
|
||||||
* message by default. Overridable.
|
* message by default. Overridable.
|
||||||
*/
|
*/
|
||||||
protected void showDisconnectErrorMessage(Shell shell, String hostName, int port, Exception exc)
|
protected void showDisconnectErrorMessage(Shell shell, String hostName,
|
||||||
{
|
int port, Exception exc) {
|
||||||
//SystemMessage.displayMessage(SystemMessage.MSGTYPE_ERROR,shell,RSEUIPlugin.getResourceBundle(),
|
// SystemMessage.displayMessage(SystemMessage.MSGTYPE_ERROR,shell,RSEUIPlugin.getResourceBundle(),
|
||||||
// ISystemMessages.MSG_DISCONNECT_FAILED,
|
// ISystemMessages.MSG_DISCONNECT_FAILED,
|
||||||
// hostName, exc.getMessage());
|
// hostName, exc.getMessage());
|
||||||
//RSEUIPlugin.logError("Disconnect failed",exc); // temporary
|
// RSEUIPlugin.logError("Disconnect failed",exc); // temporary
|
||||||
SystemMessageDialog msgDlg = new SystemMessageDialog(shell,
|
SystemMessageDialog msgDlg = new SystemMessageDialog(shell,
|
||||||
RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_DISCONNECT_FAILED).makeSubstitution(hostName,exc));
|
RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_DISCONNECT_FAILED)
|
||||||
msgDlg.setException(exc);
|
.makeSubstitution(hostName, exc));
|
||||||
msgDlg.open();
|
msgDlg.setException(exc);
|
||||||
}
|
msgDlg.open();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an error message when the user cancels the disconnection.
|
* Show an error message when the user cancels the disconnection. Shows
|
||||||
* Shows a common message by default.
|
* a common message by default. Overridable.
|
||||||
* Overridable.
|
*/
|
||||||
*/
|
protected void showDisconnectCancelledMessage(Shell shell,
|
||||||
protected void showDisconnectCancelledMessage(Shell shell, String hostName, int port)
|
String hostName, int port) {
|
||||||
{
|
// SystemMessage.displayMessage(SystemMessage.MSGTYPE_ERROR, shell,
|
||||||
//SystemMessage.displayMessage(SystemMessage.MSGTYPE_ERROR, shell, RSEUIPlugin.getResourceBundle(),
|
// RSEUIPlugin.getResourceBundle(),
|
||||||
// ISystemMessages.MSG_DISCONNECT_CANCELLED, hostName);
|
// ISystemMessages.MSG_DISCONNECT_CANCELLED, hostName);
|
||||||
SystemMessageDialog msgDlg = new SystemMessageDialog(shell,
|
SystemMessageDialog msgDlg = new SystemMessageDialog(shell,
|
||||||
RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_DISCONNECT_CANCELLED).makeSubstitution(hostName));
|
RSEUIPlugin.getPluginMessage(
|
||||||
msgDlg.open();
|
ISystemMessages.MSG_DISCONNECT_CANCELLED)
|
||||||
}
|
.makeSubstitution(hostName));
|
||||||
|
msgDlg.open();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notification from sub-services that our session was lost.
|
/*
|
||||||
* Notify all subsystems properly.
|
* Notification from sub-services that our session was lost. Notify all
|
||||||
* TODO allow user to try and reconnect?
|
* subsystems properly.
|
||||||
*/
|
* TODO allow user to try and reconnect?
|
||||||
|
*/
|
||||||
public void handleSessionLost() {
|
public void handleSessionLost() {
|
||||||
Activator.trace("TelnetConnectorService: handleSessionLost"); //$NON-NLS-1$
|
Activator.trace("TelnetConnectorService: handleSessionLost"); //$NON-NLS-1$
|
||||||
if (fSessionLostHandler!=null) {
|
if (fSessionLostHandler != null) {
|
||||||
fSessionLostHandler.sessionLost();
|
fSessionLostHandler.sessionLost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Display getStandardDisplay() {
|
protected static Display getStandardDisplay() {
|
||||||
Display display = Display.getCurrent();
|
Display display = Display.getCurrent();
|
||||||
if( display==null ) {
|
if (display == null) {
|
||||||
display = Display.getDefault();
|
display = Display.getDefault();
|
||||||
}
|
}
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
boolean connected = false;
|
boolean connected = false;
|
||||||
if (fTelnetClient!=null) {
|
if (fTelnetClient != null) {
|
||||||
synchronized(fTelnetClient) {
|
synchronized (fTelnetClient) {
|
||||||
connected = fTelnetClient.isConnected();
|
connected = fTelnetClient.isConnected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!connected && fSessionLostHandler!=null) {
|
if (!connected && fSessionLostHandler != null) {
|
||||||
Activator.trace("TelnetConnectorService.isConnected: false -> sessionLost"); //$NON-NLS-1$
|
Activator.trace("TelnetConnectorService.isConnected: false -> sessionLost"); //$NON-NLS-1$
|
||||||
fSessionLostHandler.sessionLost();
|
fSessionLostHandler.sessionLost();
|
||||||
}
|
}
|
||||||
|
@ -456,10 +464,10 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if this connector service requires a password.
|
* Test if this connector service requires a password. Telnet connector
|
||||||
* Telnet connector service returns false since a password is
|
* service returns false since a password is not necessarily required, i.e.
|
||||||
* not necessarily required, i.e. the corresponding
|
* the corresponding password field may be empty.
|
||||||
* password field may be empty.
|
*
|
||||||
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
|
@ -468,10 +476,10 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if this connector service requires a user id.
|
* Test if this connector service requires a user id. Telnet connector
|
||||||
* Telnet connector service returns false since a user id
|
* service returns false since a user id is not necessarily required, i.e.
|
||||||
* is not necessarily required, i.e. the corresponding
|
* the corresponding user id field may be empty.
|
||||||
* user id field may be empty.
|
*
|
||||||
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
|
@ -481,14 +489,15 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if this connector service requires logging in.
|
* Test if this connector service requires logging in.
|
||||||
* @return false if the Property {@link #PROPERTY_LOGIN_REQUIRED}
|
*
|
||||||
* is set and false. Returns true otherwise.
|
* @return false if the Property {@link #PROPERTY_LOGIN_REQUIRED} is set and
|
||||||
|
* false. Returns true otherwise.
|
||||||
*/
|
*/
|
||||||
protected boolean supportsLogin() {
|
protected boolean supportsLogin() {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
if (telnetPropertySet!=null) {
|
if (telnetPropertySet != null) {
|
||||||
String login_required = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_REQUIRED);
|
String login_required = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_REQUIRED);
|
||||||
if (login_required!=null && login_required.equalsIgnoreCase("false")) { //$NON-NLS-1$
|
if (login_required != null && login_required.equalsIgnoreCase("false")) { //$NON-NLS-1$
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,5 +519,5 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
public boolean supportsUserId() {
|
public boolean supportsUserId() {
|
||||||
return supportsLogin();
|
return supportsLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue