1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-07 00:05:53 +02:00

[206917][terminal] Add validation for Terminal Settings

This commit is contained in:
Martin Oberhuber 2008-07-15 22:40:47 +00:00
parent 07cd423176
commit ce78395c37
8 changed files with 79 additions and 19 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,6 +13,7 @@
* Contributors: * 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) - fixed copyright headers and beautified
* Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.serial; package org.eclipse.tm.internal.terminal.serial;
@ -109,6 +110,14 @@ public class SerialSettingsPage implements ISettingsPage {
} }
public boolean validateSettings() { public boolean validateSettings() {
try {
int p = Integer.parseInt(fTimeout.getText().trim());
if (p < 0) {
return false;
}
} catch (Exception e) {
return false;
}
return true; return true;
} }
public void createControl(Composite parent) { public void createControl(Composite parent) {

View file

@ -9,6 +9,7 @@
* Michael Scharf (Wind River) - initial API and implementation * Michael Scharf (Wind River) - initial API and implementation
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Martin Oberhuber (Wind River) - fixed copyright headers and beautified
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives * 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; package org.eclipse.tm.internal.terminal.ssh;
@ -57,6 +58,28 @@ public class SshSettingsPage implements ISettingsPage {
return value; return value;
} }
public boolean validateSettings() { 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; return true;
} }
public void createControl(Composite parent) { public void createControl(Composite parent) {

View file

@ -2,7 +2,7 @@
<feature <feature
id="org.eclipse.tm.terminal.telnet" id="org.eclipse.tm.terminal.telnet"
label="%featureName" label="%featureName"
version="2.0.0.qualifier" version="2.0.1.qualifier"
provider-name="%providerName"> provider-name="%providerName">
<description> <description>

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.terminal.telnet;singleton:=true 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-Vendor: %providerName
Bundle-Localization: plugin Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui, Require-Bundle: org.eclipse.ui,

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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,6 +13,7 @@
* Contributors: * 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) - fixed copyright headers and beautified
* Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.telnet; package org.eclipse.tm.internal.terminal.telnet;
@ -88,8 +89,24 @@ public class TelnetSettingsPage implements ISettingsPage {
} }
public boolean validateSettings() { 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; return true;
} }
public void createControl(Composite parent) { public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE); Composite composite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false); GridLayout gridLayout = new GridLayout(2, false);

View file

@ -17,6 +17,7 @@
* Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs * 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) - [196454] Initial connection settings dialog should not be blank
* Michael Scharf (Wind River) - [240023] Get rid of the terminal's "Pin" button * 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; package org.eclipse.tm.internal.terminal.view;
@ -148,8 +149,14 @@ class TerminalSettingsDlg extends Dialog {
} }
protected void okPressed() { 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; return;
}
if(fSelectedConnector>=0) { if(fSelectedConnector>=0) {
getPage(fSelectedConnector).saveSettings(); getPage(fSelectedConnector).saveSettings();
} }

View file

@ -14,6 +14,7 @@
* 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) - fixed copyright headers and beautified
* Michael Scharf (Wind River) - [240023] Get rid of the terminal's "Pin" button * 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; package org.eclipse.tm.internal.terminal.view;
@ -33,6 +34,7 @@ public class ViewMessages extends NLS {
public static String CONNECTIONTYPE; public static String CONNECTIONTYPE;
public static String VIEW_TITLE; public static String VIEW_TITLE;
public static String VIEW_SETTINGS; public static String VIEW_SETTINGS;
public static String INVALID_SETTINGS;
public static String INVERT_COLORS; public static String INVERT_COLORS;
public static String BUFFERLINES; public static String BUFFERLINES;

View file

@ -14,6 +14,7 @@
# 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) - fixed copyright headers and beautified
# Michael Scharf (Wind River) - [240023] Get rid of the terminal's "Pin" button # 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 NO_CONNECTION_SELECTED = No Connection Selected
PROP_TITLE = Terminal PROP_TITLE = Terminal
@ -25,6 +26,7 @@ NEW_TERMINAL_VIEW = New Terminal View
CONNECTIONTYPE = Connection Type CONNECTIONTYPE = Connection Type
VIEW_TITLE = View Title: VIEW_TITLE = View Title:
VIEW_SETTINGS = View Settings: VIEW_SETTINGS = View Settings:
INVALID_SETTINGS = The specified settings are invalid, please review or cancel.
INVERT_COLORS = Invert terminal colors INVERT_COLORS = Invert terminal colors
BUFFERLINES = Terminal buffer lines: BUFFERLINES = Terminal buffer lines: