mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
[188939] All terminal connections fail if RXTX is not available
This commit is contained in:
parent
47899ae3c2
commit
966d8da9e6
4 changed files with 22 additions and 18 deletions
|
@ -23,6 +23,7 @@ import java.net.SocketException;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.StyledText;
|
import org.eclipse.swt.custom.StyledText;
|
||||||
import org.eclipse.swt.custom.VerifyKeyListener;
|
import org.eclipse.swt.custom.VerifyKeyListener;
|
||||||
|
@ -239,7 +240,12 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
|
||||||
if(fConnector==null)
|
if(fConnector==null)
|
||||||
return;
|
return;
|
||||||
fTerminalText.resetState();
|
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
|
// clean the error message
|
||||||
setMsg(""); //$NON-NLS-1$
|
setMsg(""); //$NON-NLS-1$
|
||||||
waitForConnect();
|
waitForConnect();
|
||||||
|
@ -272,8 +278,7 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
|
||||||
}
|
}
|
||||||
if (!getMsg().equals("")) //$NON-NLS-1$
|
if (!getMsg().equals("")) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
String strTitle = TerminalMessages.TerminalError;
|
showErrorMessage(getMsg());
|
||||||
MessageDialog.openError( getShell(), strTitle, getMsg());
|
|
||||||
|
|
||||||
disconnectTerminal();
|
disconnectTerminal();
|
||||||
return;
|
return;
|
||||||
|
@ -282,6 +287,11 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
|
||||||
getCtlText().setFocus();
|
getCtlText().setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showErrorMessage(String message) {
|
||||||
|
String strTitle = TerminalMessages.TerminalError;
|
||||||
|
MessageDialog.openError( getShell(), strTitle, message);
|
||||||
|
}
|
||||||
|
|
||||||
protected void sendString(String string) {
|
protected void sendString(String string) {
|
||||||
try {
|
try {
|
||||||
// Send the string after converting it to an array of bytes using the
|
// 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) {
|
} catch (SocketException socketException) {
|
||||||
displayTextInTerminal(socketException.getMessage());
|
displayTextInTerminal(socketException.getMessage());
|
||||||
|
|
||||||
String strTitle = TerminalMessages.TerminalError;
|
|
||||||
String strMsg = TerminalMessages.SocketError
|
String strMsg = TerminalMessages.SocketError
|
||||||
+ "!\n" + socketException.getMessage(); //$NON-NLS-1$
|
+ "!\n" + socketException.getMessage(); //$NON-NLS-1$
|
||||||
|
showErrorMessage(strMsg);
|
||||||
|
|
||||||
MessageDialog.openError(getShell(), strTitle, strMsg);
|
|
||||||
Logger.logException(socketException);
|
Logger.logException(socketException);
|
||||||
|
|
||||||
disconnectTerminal();
|
disconnectTerminal();
|
||||||
} catch (IOException ioException) {
|
} 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);
|
Logger.logException(ioException);
|
||||||
|
|
||||||
disconnectTerminal();
|
disconnectTerminal();
|
||||||
|
@ -348,11 +353,10 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
|
||||||
|
|
||||||
displayTextInTerminal(socketException.getMessage());
|
displayTextInTerminal(socketException.getMessage());
|
||||||
|
|
||||||
String strTitle = TerminalMessages.TerminalError;
|
|
||||||
String strMsg = TerminalMessages.SocketError
|
String strMsg = TerminalMessages.SocketError
|
||||||
+ "!\n" + socketException.getMessage(); //$NON-NLS-1$
|
+ "!\n" + socketException.getMessage(); //$NON-NLS-1$
|
||||||
|
|
||||||
MessageDialog.openError(getShell(), strTitle, strMsg);
|
showErrorMessage(strMsg);
|
||||||
Logger.logException(socketException);
|
Logger.logException(socketException);
|
||||||
|
|
||||||
disconnectTerminal();
|
disconnectTerminal();
|
||||||
|
@ -361,10 +365,9 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
|
||||||
|
|
||||||
displayTextInTerminal(ioException.getMessage());
|
displayTextInTerminal(ioException.getMessage());
|
||||||
|
|
||||||
String strTitle = TerminalMessages.TerminalError;
|
|
||||||
String strMsg = TerminalMessages.IOError + "!\n" + ioException.getMessage(); //$NON-NLS-1$
|
String strMsg = TerminalMessages.IOError + "!\n" + ioException.getMessage(); //$NON-NLS-1$
|
||||||
|
|
||||||
MessageDialog.openError(getShell(), strTitle, strMsg);
|
showErrorMessage(strMsg);
|
||||||
Logger.logException(ioException);
|
Logger.logException(ioException);
|
||||||
|
|
||||||
disconnectTerminal();
|
disconnectTerminal();
|
||||||
|
|
|
@ -21,5 +21,5 @@ public class TerminalMessages extends NLS {
|
||||||
public static String TerminalError;
|
public static String TerminalError;
|
||||||
public static String SocketError;
|
public static String SocketError;
|
||||||
public static String IOError;
|
public static String IOError;
|
||||||
|
public static String CannotConnectTo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,3 +17,4 @@
|
||||||
TerminalError = Terminal Error
|
TerminalError = Terminal Error
|
||||||
SocketError = Socket Error
|
SocketError = Socket Error
|
||||||
IOError = IO Error
|
IOError = IO Error
|
||||||
|
CannotConnectTo = Cannot connect to {1}:\n{2}
|
|
@ -84,7 +84,8 @@ public class TerminalConnectorExtension {
|
||||||
if(!isInitialized()) {
|
if(!isInitialized()) {
|
||||||
try {
|
try {
|
||||||
fConnector=createConnector(fConfig);
|
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$
|
throw new RuntimeException(getName()+ " is not properly installed!"); //$NON-NLS-1$
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fException=e;
|
fException=e;
|
||||||
|
@ -92,9 +93,8 @@ public class TerminalConnectorExtension {
|
||||||
if(fConnector!=null && fStore!=null)
|
if(fConnector!=null && fStore!=null)
|
||||||
fConnector.load(fStore);
|
fConnector.load(fStore);
|
||||||
}
|
}
|
||||||
if(fConnector==null) {
|
if(fException!=null)
|
||||||
throw new RuntimeException(fException);
|
throw new RuntimeException(fException);
|
||||||
}
|
|
||||||
return fConnector;
|
return fConnector;
|
||||||
}
|
}
|
||||||
private boolean isInitialized() {
|
private boolean isInitialized() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue