org.mailster.gui.prefs.widgets
Class HostFieldEditor

java.lang.Object
  extended by org.eclipse.jface.preference.FieldEditor
      extended by org.eclipse.jface.preference.StringFieldEditor
          extended by org.mailster.gui.prefs.widgets.HostFieldEditor

public class HostFieldEditor
extends org.eclipse.jface.preference.StringFieldEditor

---
Mailster (C) 2007-2009 De Oliveira Edouard

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

See  Mailster Web Site
---

HostFieldEditor.java - A FieldEditor to edit host/ip addresses.

Version:
$Author: kods $ / $Date: 2008/12/06 13:57:18 $
Author:
Edouard De Oliveira

Field Summary
private static java.lang.String _255
          The pattern to identify an IPv4 address.
private static java.util.regex.Pattern hostPattern
           
private static java.util.regex.Pattern ipv4Pattern
           
private static java.util.regex.Pattern ipv6Pattern
          The pattern to identify an IPv6 address.
private  boolean isValid
          Cached valid state.
private static java.lang.String labelDNS
          The pattern to identify a valid FQDN hostname.
private  boolean onlyLocalAddressAllowed
          true if only local addresses are valid.
 
Fields inherited from class org.eclipse.jface.preference.StringFieldEditor
oldValue, UNLIMITED, VALIDATE_ON_FOCUS_LOST, VALIDATE_ON_KEY_STROKE
 
Fields inherited from class org.eclipse.jface.preference.FieldEditor
HORIZONTAL_GAP, IS_VALID, VALUE
 
Constructor Summary
HostFieldEditor(java.lang.String name, java.lang.String labelText, org.eclipse.swt.widgets.Composite parent)
           
 
Method Summary
protected  boolean checkState()
          Checks whether the text input field contains a valid value or not.
protected  void clearErrorMessage()
          Clears the error message from the message line.
protected  void clearErrorMessage(boolean force)
          Clears the error message from the message line.
 org.eclipse.swt.widgets.Text getTextControl(org.eclipse.swt.widgets.Composite parent)
          Returns this field editor's text control.
 boolean isOnlyLocalAddressAllowed()
           
 boolean isValid()
           
protected  void refreshValidState()
           
 void setOnlyLocalAddressAllowed(boolean onlyLocalAddressAllowed)
           
protected  void valueChanged()
          Informs this field editor's listener, if it has one, about a change to the value (VALUE property) provided that the old and new values are different.
 
Methods inherited from class org.eclipse.jface.preference.StringFieldEditor
adjustForNumColumns, doCheckState, doFillIntoGrid, doLoad, doLoadDefault, doStore, getErrorMessage, getNumberOfControls, getStringValue, getTextControl, isEmptyStringAllowed, setEmptyStringAllowed, setEnabled, setErrorMessage, setFocus, setStringValue, setTextLimit, setValidateStrategy, showErrorMessage
 
Methods inherited from class org.eclipse.jface.preference.FieldEditor
applyFont, checkParent, clearMessage, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, createControl, dispose, fillIntoGrid, fireStateChanged, fireValueChanged, getFieldEditorFontName, getLabelControl, getLabelControl, getLabelText, getPage, getPreferenceName, getPreferencePage, getPreferenceStore, init, load, loadDefault, presentsDefaultValue, setButtonLayoutData, setLabelText, setPage, setPreferenceName, setPreferencePage, setPreferenceStore, setPresentsDefaultValue, setPropertyChangeListener, showErrorMessage, showMessage, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_255

private static final java.lang.String _255
The pattern to identify an IPv4 address.

See Also:
Constant Field Values

ipv4Pattern

private static final java.util.regex.Pattern ipv4Pattern

ipv6Pattern

private static final java.util.regex.Pattern ipv6Pattern
The pattern to identify an IPv6 address.


labelDNS

private static final java.lang.String labelDNS
The pattern to identify a valid FQDN hostname. See RFC 1035 # 2.3.1

See Also:
Constant Field Values

hostPattern

private static final java.util.regex.Pattern hostPattern

onlyLocalAddressAllowed

private boolean onlyLocalAddressAllowed
true if only local addresses are valid.


isValid

private boolean isValid
Cached valid state.

Constructor Detail

HostFieldEditor

public HostFieldEditor(java.lang.String name,
                       java.lang.String labelText,
                       org.eclipse.swt.widgets.Composite parent)
Method Detail

refreshValidState

protected void refreshValidState()
Overrides:
refreshValidState in class org.eclipse.jface.preference.StringFieldEditor

isValid

public boolean isValid()
Overrides:
isValid in class org.eclipse.jface.preference.StringFieldEditor

checkState

protected boolean checkState()
Checks whether the text input field contains a valid value or not.

Overrides:
checkState in class org.eclipse.jface.preference.StringFieldEditor
Returns:
true if the field value is valid, and false if invalid

getTextControl

public org.eclipse.swt.widgets.Text getTextControl(org.eclipse.swt.widgets.Composite parent)
Returns this field editor's text control.

The control is created if it does not yet exist

Overrides:
getTextControl in class org.eclipse.jface.preference.StringFieldEditor
Parameters:
parent - the parent
Returns:
the text control

valueChanged

protected void valueChanged()
Informs this field editor's listener, if it has one, about a change to the value (VALUE property) provided that the old and new values are different.

This hook is not called when the text is initialized (or reset to the default value) from the preference store.

Overrides:
valueChanged in class org.eclipse.jface.preference.StringFieldEditor

clearErrorMessage

protected void clearErrorMessage()
Clears the error message from the message line.

Overrides:
clearErrorMessage in class org.eclipse.jface.preference.FieldEditor

clearErrorMessage

protected void clearErrorMessage(boolean force)
Clears the error message from the message line.


isOnlyLocalAddressAllowed

public boolean isOnlyLocalAddressAllowed()

setOnlyLocalAddressAllowed

public void setOnlyLocalAddressAllowed(boolean onlyLocalAddressAllowed)