List of usage examples for org.eclipse.jface.dialogs IMessageProvider NONE
int NONE
To view the source code for org.eclipse.jface.dialogs IMessageProvider NONE.
Click Source Link
From source file:org.eclipse.tm.te.ui.controls.BaseControl.java
License:Open Source License
/** * Validates the control and sets the message text and type so the parent * page or control is able to display validation result informations. * The validation should be done by implementations of WRValidator! * The default implementation of this method does nothing. * Use the isValid(WRBaseControl, boolean) method to validate child-controls. * * @return Result of validation.// ww w .java2s . co m */ public boolean isValid() { setMessage(null, IMessageProvider.NONE); return true; }
From source file:org.eclipse.tm.te.ui.controls.BaseEditBrowseTextControl.java
License:Open Source License
@Override public boolean isValid() { if (isInitializing) { return true; }//from w ww .j ava 2s.c o m boolean valid = super.isValid(); if (getEditFieldValidator() != null && getEditFieldControl() != null && !getEditFieldControl().isDisposed() && SWTControlUtil.isEnabled(getEditFieldControl()) && !isReadOnly() && isLabelControlSelected()) { valid = getEditFieldValidator().isValid(getEditFieldControlTextForValidation()); setMessage(getEditFieldValidator().getMessage(), getEditFieldValidator().getMessageType()); } if (getEditFieldControlDecoration() != null) { // Setup and show the control decoration if necessary if (isEnabled() && (!valid || (getMessage() != null && getMessageType() != IMessageProvider.NONE))) { // Update the control decorator ControlDecoration decoration = getEditFieldControlDecoration(); updateEditFieldControlDecorationForMessage(decoration, getMessage(), getMessageType()); // And show the decoration decoration.show(); } else { ControlDecoration decoration = getEditFieldControlDecoration(); // Control is valid and no message is set -> hide the decoration decoration.hide(); decoration.setDescriptionText(null); } } return valid; }
From source file:org.eclipse.tm.te.ui.controls.net.RemoteHostAddressControl.java
License:Open Source License
@Override protected void onButtonControlSelected() { onCheckAddress();//from w w w .j a v a 2 s . co m getButtonControl().setEnabled(false); // Reset the validation message. if (getMessage() != null && getMessage().equals(getUserInformationTextCheckNameAddress())) { setMessage(null, IMessageProvider.NONE); if (getEditFieldControlDecoration() != null) { getEditFieldControlDecoration().hide(); } } }
From source file:org.eclipse.tm.te.ui.dialogs.NameValuePairDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite top = (Composite) super.createDialogArea(parent); setDialogTitle(dialogTitle);/* www . j a va 2 s .co m*/ setTitle(title); setDefaultMessage(message, IMessageProvider.NONE); Composite panel = new Composite(top, SWT.NONE); panel.setLayout(new GridLayout(2, false)); panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Label label = new Label(panel, SWT.NONE); label.setText(fieldLabels[0]); nameText = new Text(panel, SWT.BORDER | SWT.SINGLE); nameText.setText(initialValues[0]); GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false); layoutData.widthHint = 300; nameText.setLayoutData(layoutData); nameText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { updateButtons(); } }); label = new Label(panel, SWT.NONE); label.setText(fieldLabels[1]); valueText = new Text(panel, SWT.BORDER | SWT.SINGLE); valueText.setText(initialValues[1]); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.widthHint = 300; valueText.setLayoutData(layoutData); valueText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { updateButtons(); } }); applyDialogFont(panel); return panel; }
From source file:org.eclipse.tm.terminal.connector.serial.controls.SerialPortAddressDialog.java
License:Open Source License
/** * Validates the tty device control./*from www .ja v a 2 s. c o m*/ * * @return <code>True</code> if the control is valid, <code>false</code> otherwise. */ protected boolean isTtyControlValid() { if (ttyControl == null || ttyControl.isDisposed()) return false; boolean valid = true; String m = null; int mt = IMessageProvider.NONE; String newText = ttyControl.getText(); Assert.isNotNull(newText); if (newText.trim().length() > 0) { Matcher matcher = validCharacters.matcher(newText); if (!matcher.matches()) { m = Messages.SerialLinePanel_error_invalidCharactes; mt = IMessageProvider.ERROR; } } else { m = Messages.SerialLinePanel_error_emptyHostTTYDevice; mt = IMessageProvider.INFORMATION; } valid = mt != IMessageProvider.ERROR; if (mt > getMessageType()) setMessage(m, mt); return valid; }
From source file:org.eclipse.tm.terminal.connector.serial.controls.SerialPortAddressDialog.java
License:Open Source License
/** * Validates the address control.// w w w . j a va 2s . c om * * @return <code>True</code> if the control is valid, <code>false</code> otherwise. */ protected boolean isAddressControlValid() { if (addressControl == null || addressControl.isDisposed()) return false; boolean valid = true; String m = null; int mt = IMessageProvider.NONE; String ipOrHostName = addressControl.getText(); // info message when value is empty if (ipOrHostName == null || ipOrHostName.trim().length() == 0) { m = Messages.SerialPortAddressDialog_Information_MissingTargetNameAddress; mt = IMessageProvider.INFORMATION; } else { ipOrHostName = ipOrHostName.trim(); // check IP address when only numeric values and '.' are entered if (ipOrHostName.matches(IP_CHARACTERS_REGEX)) { if (!ipOrHostName.matches(IP_REGEX)) { m = Messages.SerialPortAddressDialog_Error_InvalidTargetIpAddress; mt = IMessageProvider.ERROR; } } else if (ipOrHostName.matches(NAME_CHARACTERS_REGEX)) { if (!ipOrHostName.matches(NAME_REGEX)) { m = Messages.SerialPortAddressDialog_Error_InvalidTargetNameAddress; mt = IMessageProvider.ERROR; } } else { m = Messages.SerialPortAddressDialog_Error_InvalidTargetNameAddress; mt = IMessageProvider.ERROR; } } valid = mt != IMessageProvider.ERROR; if (mt > getMessageType()) setMessage(m, mt); return valid; }
From source file:org.eclipse.tm.terminal.connector.serial.controls.SerialPortAddressDialog.java
License:Open Source License
/** * Validates the port control.// w ww. j ava 2s .c om * * @return <code>True</code> if the control is valid, <code>false</code> otherwise. */ protected boolean isPortControlValid() { if (portControl == null || portControl.isDisposed()) return false; boolean valid = true; String m = null; int mt = IMessageProvider.NONE; String newText = portControl.getText(); Assert.isNotNull(newText); if (newText.trim().length() > 0) { if (!newText.matches("([0-9]{0,5})|(0((x|X)[0-9a-fA-F]{0,4})?)")) { //$NON-NLS-1$ m = Messages.SerialPortAddressDialog_Error_InvalidPort; mt = IMessageProvider.ERROR; } else { try { int value = Integer.decode(newText).intValue(); if (value < 0 || value > 65535) { m = Messages.SerialPortAddressDialog_Error_InvalidPortRange; mt = IMessageProvider.ERROR; } } catch (Exception ex) { /* ignored on purpose */ } } } else { m = Messages.SerialPortAddressDialog_Information_MissingPort; mt = IMessageProvider.INFORMATION; } valid = mt != IMessageProvider.ERROR; if (mt > getMessageType()) setMessage(m, mt); return valid; }
From source file:org.eclipse.tm.terminal.connector.serial.controls.SerialPortAddressDialog.java
License:Open Source License
/** * Cleanup when dialog is closed.//from w ww . ja va 2s. c o m */ protected void dispose() { message = null; messageType = IMessageProvider.NONE; errorMessage = null; title = null; defaultMessage = null; defaultMessageType = IMessageProvider.NONE; }
From source file:org.eclipse.tm.terminal.connector.ssh.connector.SshSettingsPage.java
License:Open Source License
@Override public boolean validateSettings() { String message = null;//ww w . ja v a 2 s .co m int messageType = IMessageProvider.NONE; boolean valid = true; if (fHostText.getText().trim().length() == 0) { String m = "Please enter a host IP or name."; //$NON-NLS-1$ int mt = IMessageProvider.INFORMATION; updateControlDecoration(fHostText, m, mt); if (mt > messageType) { message = m; messageType = mt; } valid = false; } else { updateControlDecoration(fHostText, null, IMessageProvider.NONE); } if (fUser.getText().trim().length() == 0) { String m = "Please enter a username."; //$NON-NLS-1$ int mt = IMessageProvider.INFORMATION; updateControlDecoration(fUser, m, mt); if (mt > messageType) { message = m; messageType = mt; } valid = false; } else { updateControlDecoration(fUser, null, IMessageProvider.NONE); } try { int p = Integer.parseInt(fPort.getText().trim()); if (p <= 0 || p > 65535) { String m = "Invalid network port. Must be between 0 and 65535."; //$NON-NLS-1$ int mt = IMessageProvider.ERROR; updateControlDecoration(fPort, m, mt); if (mt > messageType) { message = m; messageType = mt; } valid = false; } else { updateControlDecoration(fPort, null, IMessageProvider.NONE); } p = Integer.parseInt(fTimeout.getText().trim()); if (p < 0) { String m = "Invalid timeout. Must be greater than 0."; //$NON-NLS-1$ int mt = IMessageProvider.ERROR; updateControlDecoration(fTimeout, m, mt); if (mt > messageType) { message = m; messageType = mt; } valid = false; } else { updateControlDecoration(fTimeout, null, IMessageProvider.NONE); } p = Integer.parseInt(fKeepalive.getText().trim()); if (p < 0) { String m = "Invalid keep alive. Must be greater than 0."; //$NON-NLS-1$ int mt = IMessageProvider.ERROR; updateControlDecoration(fKeepalive, m, mt); if (mt > messageType) { message = m; messageType = mt; } valid = false; } else { updateControlDecoration(fKeepalive, null, IMessageProvider.NONE); } } catch (Exception e) { valid = false; } setMessage(message, messageType); return valid; }
From source file:org.eclipse.tm.terminal.connector.telnet.connector.TelnetSettingsPage.java
License:Open Source License
@Override public boolean validateSettings() { String message = null;/* w w w. j a v a 2 s . co m*/ int messageType = IMessageProvider.NONE; boolean valid = true; if (fHostText.getText().trim().length() == 0) { String m = "Please enter a host IP or name."; //$NON-NLS-1$ int mt = IMessageProvider.INFORMATION; updateControlDecoration(fHostText, m, mt); if (mt > messageType) { message = m; messageType = mt; } valid = false; } else { updateControlDecoration(fHostText, null, IMessageProvider.NONE); } try { int p = Integer.parseInt(getNetworkPort()); if (p <= 0 || p > 65535) { String m = "Invalid network port. Must be between 0 and 65535."; //$NON-NLS-1$ int mt = IMessageProvider.ERROR; updateControlDecoration(fNetworkPortCombo, m, mt); if (mt > messageType) { message = m; messageType = mt; } valid = false; } else { updateControlDecoration(fNetworkPortCombo, null, IMessageProvider.NONE); } p = Integer.parseInt(fTimeout.getText().trim()); if (p < 0) { String m = "Invalid timeout. Must be greater than 0."; //$NON-NLS-1$ int mt = IMessageProvider.ERROR; updateControlDecoration(fTimeout, m, mt); if (mt > messageType) { message = m; messageType = mt; } valid = false; } else { updateControlDecoration(fTimeout, null, IMessageProvider.NONE); } } catch (Exception e) { valid = false; } setMessage(message, messageType); return valid; }