1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

[168197][terminal] Replace JFace MessagDialog by SWT MessageBox

This commit is contained in:
Martin Oberhuber 2008-04-11 20:38:06 +00:00
parent 6aae228d73
commit 01f2b8e0da
5 changed files with 60 additions and 31 deletions

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2003, 2007 Wind River Systems, Inc. and others.
# Copyright (c) 2003, 2008 Wind River Systems, Inc. and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@ -13,6 +13,7 @@
# Contributors:
# Michael Scharf (Wind River) - split into core, view and connector plugins
# Martin Oberhuber (Wind River) - fixed copyright headers and beautified
# Martin Oberhuber (Wind River) - [168197] Replace JFace MessagDialog by SWT MessageBox
###############################################################################
PORT_IN_USE = Serial port \''{0}\'' is currently in use\!\nDo you want to close the port?
PROP_TITLE = Terminal
@ -29,7 +30,8 @@ Installation:\n\
* Get RXTX binaries from\n\
ftp://ftp.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip\n\
* Copy RXTXcomm.jar into $JRE/lib/ext\n\
* Copy the native libs for your Platform (*.so, *.jnilib, *.dll) into the respective native lib folder of your RSE \n\
* Copy the native libs for your Platform (*.so, *.jnilib, *.dll)\n\
into the respective native lib folder of your RSE \n\
* More installation instructions are at\n\
http://rxtx.qbang.org/wiki/index.php/Main_Page\n\
* More downloads for other platforms (currently about 30)\n\

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2007 Wind River Systems, Inc. and others.
* Copyright (c) 2003, 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -11,8 +11,9 @@
* Helmut Haigermoser and Ted Williams.
*
* Contributors:
* Michael Scharf (Wind River) - extracted from TerminalControl
* Michael Scharf (Wind River) - extracted from TerminalControl
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
* Martin Oberhuber (Wind River) - [168197] Replace JFace MessagDialog by SWT MessageBox
*******************************************************************************/
package org.eclipse.tm.internal.terminal.serial;
@ -23,8 +24,9 @@ import gnu.io.SerialPortEventListener;
import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
@ -71,12 +73,16 @@ public class SerialPortHandler implements
public void run() {
String[] args = new String[] { fConn.getSerialSettings().getSerialPort() };
String strMsg = MessageFormat.format(SerialMessages.PORT_IN_USE, args);
if (!MessageDialog.openQuestion(fControl.getShell(), SerialMessages.PROP_TITLE, strMsg))
// [168197] Replace JFace MessagDialog by SWT MessageBox
//if (!MessageDialog.openQuestion(fControl.getShell(), SerialMessages.PROP_TITLE, strMsg))
MessageBox mb = new MessageBox(fControl.getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
mb.setText(SerialMessages.PROP_TITLE);
mb.setMessage(strMsg);
if (mb.open() != SWT.YES)
return;
fConn.disconnect();
}
});
}

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [155026] Add keepalives for SSH connection
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
* Martin Oberhuber (Wind River) - [225792] Rename SshConnector.getTelnetSettings() to getSshSettings()
* Martin Oberhuber (Wind River) - [168197] Replace JFace MessagDialog by SWT MessageBox
*******************************************************************************/
package org.eclipse.tm.internal.terminal.ssh;
@ -25,10 +26,11 @@ import java.io.InterruptedIOException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.jsch.core.IJSchService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
@ -179,7 +181,7 @@ class SshConnection extends Thread {
return display;
}
private static class MyUserInfo implements UserInfo, UIKeyboardInteractive {
private class MyUserInfo implements UserInfo, UIKeyboardInteractive {
private final String fConnectionId;
private final String fUser;
private String fPassword;
@ -199,7 +201,12 @@ class SshConnection extends Thread {
final boolean[] retval = new boolean[1];
Display.getDefault().syncExec(new Runnable() {
public void run() {
retval[0] = MessageDialog.openQuestion(null, SshMessages.WARNING, str);
// [168197] Replace JFace MessagDialog by SWT MessageBox
//retval[0] = MessageDialog.openQuestion(null, SshMessages.WARNING, str);
MessageBox mb = new MessageBox(fControl.getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
mb.setText(SshMessages.WARNING);
mb.setMessage(str);
retval[0] = (mb.open() == SWT.YES);
}
});
return retval[0];
@ -237,7 +244,12 @@ class SshConnection extends Thread {
public void showMessage(final String message) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(null, SshMessages.INFO, message);
// [168197] Replace JFace MessagDialog by SWT MessageBox
// MessageDialog.openInformation(null, SshMessages.INFO, message);
MessageBox mb = new MessageBox(null, SWT.ICON_INFORMATION | SWT.OK);
mb.setText(SshMessages.INFO);
mb.setMessage(message);
mb.open();
}
});
}

View file

@ -11,8 +11,9 @@
* Helmut Haigermoser and Ted Williams.
*
* Contributors:
* Michael Scharf (Wind River) - split into core, view and connector plugins
* Michael Scharf (Wind River) - split into core, view and connector plugins
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
* Martin Oberhuber (Wind River) - [168197] Replace JFace MessagDialog by SWT MessageBox
*******************************************************************************/
package org.eclipse.tm.internal.terminal.view;
@ -24,7 +25,6 @@ import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@ -38,6 +38,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
@ -92,13 +93,15 @@ class TerminalSettingsDlg extends Dialog {
public void createControl(Composite parent) {
Label l=new Label(parent,SWT.WRAP);
String error=NLS.bind(ViewMessages.CONNECTOR_NOT_AVAILABLE,conn.getName());
l.setText(error);
l.setText(error);
l.setForeground(l.getDisplay().getSystemColor(SWT.COLOR_RED));
MessageDialog.openError(getShell(),
error,
NLS.bind(ViewMessages.CANNOT_INITIALIZE,
conn.getName(),
conn.getInitializationErrorMessage()));
String msg = NLS.bind(ViewMessages.CANNOT_INITIALIZE, conn.getName(), conn.getInitializationErrorMessage());
// [168197] Replace JFace MessagDialog by SWT MessageBox
//MessageDialog.openError(getShell(), error, msg);
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
mb.setText(error);
mb.setMessage(msg);
mb.open();
}
public void loadSettings() {}
public void saveSettings() {}
@ -114,7 +117,7 @@ class TerminalSettingsDlg extends Dialog {
resize();
}
return fPages[i];
}
void resize() {
Point size=getShell().getSize();
@ -201,12 +204,12 @@ class TerminalSettingsDlg extends Dialog {
wndGroup.setLayout(gridLayout);
wndGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
wndGroup.setText(ViewMessages.VIEW_SETTINGS);
Label label=new Label(wndGroup,SWT.NONE);
label.setText(ViewMessages.VIEW_TITLE);
label.setLayoutData(new GridData(GridData.BEGINNING));
fTerminalTitleText = new Text(wndGroup, SWT.BORDER);
fTerminalTitleText.setText(fTerminalTitle);
fTerminalTitleText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -229,7 +232,7 @@ class TerminalSettingsDlg extends Dialog {
gridData.widthHint = 200;
fCtlConnTypeCombo.setLayoutData(gridData);
}
private void setupSettingsGroup(Composite parent) {
Group group = new Group(parent, SWT.NONE);
group.setText(ViewMessages.SETTINGS + ":"); //$NON-NLS-1$
@ -273,15 +276,15 @@ class TerminalSettingsDlg extends Dialog {
}
protected IDialogSettings getDialogBoundsSettings() {
IDialogSettings ds=TerminalViewPlugin.getDefault().getDialogSettings();
fDialogSettings = ds.getSection(getClass().getName());
fDialogSettings = ds.getSection(getClass().getName());
if (fDialogSettings == null) {
fDialogSettings = ds.addNewSection(getClass().getName());
fDialogSettings = ds.addNewSection(getClass().getName());
}
return fDialogSettings;
}
public void setTerminalTitle(String partName) {
fTerminalTitle=partName;
}
public String getTerminalTitle() {
return fTerminalTitle;

View file

@ -20,6 +20,7 @@
* Michael Scharf (Wind River) - [209665] Add ability to log byte streams from terminal
* Ruslan Sychev (Xored Software) - [217675] NPE or SWTException when closing Terminal View while connection establishing
* Michael Scharf (Wing River) - [196447] The optional terminal input line should be resizeable
* Martin Oberhuber (Wind River) - [168197] Replace JFace MessagDialog by SWT MessageBox
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -32,7 +33,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@ -50,6 +50,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tm.internal.terminal.control.ICommandInputField;
import org.eclipse.tm.internal.terminal.control.ITerminalListener;
@ -368,7 +369,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
}
} finally {
// clean the job: start a new one when the connection gets restarted
// Bug 208145: make sure we do not clean an other job that's already started (since it would become a Zombie)
// Bug 208145: make sure we do not clean an other job that's already started (since it would become a Zombie)
synchronized (VT100TerminalControl.this) {
if (fJob==this) {
fJob=null;
@ -386,7 +387,12 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
private void showErrorMessage(String message) {
String strTitle = TerminalMessages.TerminalError;
MessageDialog.openError( getShell(), strTitle, message);
// [168197] Replace JFace MessagDialog by SWT MessageBox
//MessageDialog.openError( getShell(), strTitle, message);
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
mb.setText(strTitle);
mb.setMessage(message);
mb.open();
}
protected void sendString(String string) {