diff --git a/org.eclipse.tm.terminal.serial/src/org/eclipse/tm/internal/terminal/serial/SerialSettingsPage.java b/org.eclipse.tm.terminal.serial/src/org/eclipse/tm/internal/terminal/serial/SerialSettingsPage.java index 43b85997214..c896ed508ac 100644 --- a/org.eclipse.tm.terminal.serial/src/org/eclipse/tm/internal/terminal/serial/SerialSettingsPage.java +++ b/org.eclipse.tm.terminal.serial/src/org/eclipse/tm/internal/terminal/serial/SerialSettingsPage.java @@ -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 TerminalSettingsDlg + * Michael Scharf (Wind River) - extracted from TerminalSettingsDlg * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings *******************************************************************************/ package org.eclipse.tm.internal.terminal.serial; @@ -91,11 +92,11 @@ public class SerialSettingsPage implements ISettingsPage { nIndex = combo.indexOf(value); } else { return; - } + } } combo.select(nIndex); - + } private String getComboValue(Combo combo) { int nIndex = combo.getSelectionIndex(); @@ -106,9 +107,17 @@ public class SerialSettingsPage implements ISettingsPage { } return combo.getItem(nIndex); - + } public boolean validateSettings() { + try { + int p = Integer.parseInt(fTimeout.getText().trim()); + if (p < 0) { + return false; + } + } catch (Exception e) { + return false; + } return true; } public void createControl(Composite parent) { diff --git a/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshSettingsPage.java b/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshSettingsPage.java index 35d6b800bb5..bf21bc4674f 100644 --- a/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshSettingsPage.java +++ b/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshSettingsPage.java @@ -1,14 +1,15 @@ /******************************************************************************* * Copyright (c) 2006, 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives + * Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings *******************************************************************************/ package org.eclipse.tm.internal.terminal.ssh; @@ -57,6 +58,28 @@ public class SshSettingsPage implements ISettingsPage { return value; } public boolean validateSettings() { + if (fHostText.getText().trim().length() == 0) { + return false; + } + if (fUser.getText().trim().length() == 0) { + return false; + } + try { + int p = Integer.parseInt(fPort.getText().trim()); + if (p <= 0 || p > 65535) { + return false; + } + p = Integer.parseInt(fTimeout.getText().trim()); + if (p < 0) { + return false; + } + p = Integer.parseInt(fKeepalive.getText().trim()); + if (p < 0) { + return false; + } + } catch (Exception e) { + return false; + } return true; } public void createControl(Composite parent) { @@ -84,7 +107,7 @@ public class SshSettingsPage implements ISettingsPage { // Add control gridData = new GridData(GridData.FILL_HORIZONTAL); - Text text= new Text(composite, SWT.BORDER | textOptions); + Text text= new Text(composite, SWT.BORDER | textOptions); text.setLayoutData(gridData); return text; } diff --git a/org.eclipse.tm.terminal.telnet-feature/feature.xml b/org.eclipse.tm.terminal.telnet-feature/feature.xml index d91b26fece5..7dae7b8c509 100644 --- a/org.eclipse.tm.terminal.telnet-feature/feature.xml +++ b/org.eclipse.tm.terminal.telnet-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF b/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF index ec1ec440cf3..a1dbdaa9054 100644 --- a/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF +++ b/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.telnet;singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.1.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, diff --git a/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetSettingsPage.java b/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetSettingsPage.java index 732bdba8491..526b355a2b6 100644 --- a/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetSettingsPage.java +++ b/org.eclipse.tm.terminal.telnet/src/org/eclipse/tm/internal/terminal/telnet/TelnetSettingsPage.java @@ -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 TerminalSettingsDlg + * Michael Scharf (Wind River) - extracted from TerminalSettingsDlg * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings *******************************************************************************/ package org.eclipse.tm.internal.terminal.telnet; @@ -55,13 +56,13 @@ public class TelnetSettingsPage implements ISettingsPage { if(strHost==null) strHost=""; //$NON-NLS-1$ fHostText.setText(strHost); - + } private void setTimeout(String timeout) { if(timeout==null || timeout.length()==0) timeout="5"; //$NON-NLS-1$ fTimeout.setText(timeout); - + } private void setNetworkPort(String strNetworkPort) { if (strNetworkPort!=null) { @@ -88,8 +89,24 @@ public class TelnetSettingsPage implements ISettingsPage { } public boolean validateSettings() { + if (fHostText.getText().trim().length() == 0) { + return false; + } + try { + int p = Integer.parseInt(getNetworkPort().trim()); + if (p <= 0 || p > 65535) { + return false; + } + p = Integer.parseInt(fTimeout.getText().trim()); + if (p < 0) { + return false; + } + } catch (Exception e) { + return false; + } return true; } + public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(2, false); diff --git a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalSettingsDlg.java b/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalSettingsDlg.java index aa50f332f33..8ea599b7168 100644 --- a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalSettingsDlg.java +++ b/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalSettingsDlg.java @@ -17,6 +17,7 @@ * Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs * Michael Scharf (Wind River) - [196454] Initial connection settings dialog should not be blank * Michael Scharf (Wind River) - [240023] Get rid of the terminal's "Pin" button + * Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; @@ -148,8 +149,14 @@ class TerminalSettingsDlg extends Dialog { } protected void okPressed() { - if (!validateSettings()) + if (!validateSettings()) { + String strTitle = ViewMessages.TERMINALSETTINGS; + MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK); + mb.setText(strTitle); + mb.setMessage(ViewMessages.INVALID_SETTINGS); + mb.open(); return; + } if(fSelectedConnector>=0) { getPage(fSelectedConnector).saveSettings(); } diff --git a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.java b/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.java index d40e21cc774..989acc6091f 100644 --- a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.java +++ b/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.java @@ -14,6 +14,7 @@ * Michael Scharf (Wind River) - split into core, view and connector plugins * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Michael Scharf (Wind River) - [240023] Get rid of the terminal's "Pin" button + * Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; @@ -33,6 +34,7 @@ public class ViewMessages extends NLS { public static String CONNECTIONTYPE; public static String VIEW_TITLE; public static String VIEW_SETTINGS; + public static String INVALID_SETTINGS; public static String INVERT_COLORS; public static String BUFFERLINES; diff --git a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.properties b/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.properties index 7a1593a167d..4b9c6e0cdd7 100644 --- a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.properties +++ b/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.properties @@ -14,6 +14,7 @@ # Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified # Michael Scharf (Wind River) - [240023] Get rid of the terminal's "Pin" button +# Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings ############################################################################### NO_CONNECTION_SELECTED = No Connection Selected PROP_TITLE = Terminal @@ -25,6 +26,7 @@ NEW_TERMINAL_VIEW = New Terminal View CONNECTIONTYPE = Connection Type VIEW_TITLE = View Title: VIEW_SETTINGS = View Settings: +INVALID_SETTINGS = The specified settings are invalid, please review or cancel. INVERT_COLORS = Invert terminal colors BUFFERLINES = Terminal buffer lines: