1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

[188939] All terminal connections fail if RXTX is not available

This commit is contained in:
Michael Scharf 2007-05-25 00:07:16 +00:00
parent 47899ae3c2
commit 966d8da9e6
4 changed files with 22 additions and 18 deletions

View file

@ -23,6 +23,7 @@ import java.net.SocketException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
@ -239,7 +240,12 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
if(fConnector==null)
return;
fTerminalText.resetState();
fConnector.connect(this);
try {
fConnector.connect(this);
} catch(RuntimeException e) {
showErrorMessage(NLS.bind(TerminalMessages.CannotConnectTo,new Object[]{fConnector.getName(),e.getMessage()}));
return;
}
// clean the error message
setMsg(""); //$NON-NLS-1$
waitForConnect();
@ -272,8 +278,7 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
}
if (!getMsg().equals("")) //$NON-NLS-1$
{
String strTitle = TerminalMessages.TerminalError;
MessageDialog.openError( getShell(), strTitle, getMsg());
showErrorMessage(getMsg());
disconnectTerminal();
return;
@ -282,6 +287,11 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
getCtlText().setFocus();
}
private void showErrorMessage(String message) {
String strTitle = TerminalMessages.TerminalError;
MessageDialog.openError( getShell(), strTitle, message);
}
protected void sendString(String string) {
try {
// Send the string after converting it to an array of bytes using the
@ -294,21 +304,16 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
} catch (SocketException socketException) {
displayTextInTerminal(socketException.getMessage());
String strTitle = TerminalMessages.TerminalError;
String strMsg = TerminalMessages.SocketError
+ "!\n" + socketException.getMessage(); //$NON-NLS-1$
showErrorMessage(strMsg);
MessageDialog.openError(getShell(), strTitle, strMsg);
Logger.logException(socketException);
disconnectTerminal();
} catch (IOException ioException) {
displayTextInTerminal(ioException.getMessage());
showErrorMessage(TerminalMessages.IOError + "!\n" + ioException.getMessage());//$NON-NLS-1$
String strTitle = TerminalMessages.TerminalError;
String strMsg = TerminalMessages.IOError + "!\n" + ioException.getMessage(); //$NON-NLS-1$
MessageDialog.openError(getShell(), strTitle, strMsg);
Logger.logException(ioException);
disconnectTerminal();
@ -348,11 +353,10 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
displayTextInTerminal(socketException.getMessage());
String strTitle = TerminalMessages.TerminalError;
String strMsg = TerminalMessages.SocketError
+ "!\n" + socketException.getMessage(); //$NON-NLS-1$
MessageDialog.openError(getShell(), strTitle, strMsg);
showErrorMessage(strMsg);
Logger.logException(socketException);
disconnectTerminal();
@ -361,10 +365,9 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
displayTextInTerminal(ioException.getMessage());
String strTitle = TerminalMessages.TerminalError;
String strMsg = TerminalMessages.IOError + "!\n" + ioException.getMessage(); //$NON-NLS-1$
MessageDialog.openError(getShell(), strTitle, strMsg);
showErrorMessage(strMsg);
Logger.logException(ioException);
disconnectTerminal();

View file

@ -21,5 +21,5 @@ public class TerminalMessages extends NLS {
public static String TerminalError;
public static String SocketError;
public static String IOError;
public static String CannotConnectTo;
}

View file

@ -17,3 +17,4 @@
TerminalError = Terminal Error
SocketError = Socket Error
IOError = IO Error
CannotConnectTo = Cannot connect to {1}:\n{2}

View file

@ -84,7 +84,8 @@ public class TerminalConnectorExtension {
if(!isInitialized()) {
try {
fConnector=createConnector(fConfig);
if(!fConnector.isInstalled())
if(fConnector==null || !fConnector.isInstalled())
// TODO MSA externalize
throw new RuntimeException(getName()+ " is not properly installed!"); //$NON-NLS-1$
} catch (Exception e) {
fException=e;
@ -92,9 +93,8 @@ public class TerminalConnectorExtension {
if(fConnector!=null && fStore!=null)
fConnector.load(fStore);
}
if(fConnector==null) {
if(fException!=null)
throw new RuntimeException(fException);
}
return fConnector;
}
private boolean isInitialized() {