sk.uniba.euromath.editor.widgets
Class FileSelector

java.lang.Object
  extended by sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
      extended by sk.uniba.euromath.editor.widgets.FileSelector
All Implemented Interfaces:
IUserInputWidget

public class FileSelector
extends AbstractUserInputWidget

Allows user to select a file.

Author:
Martin Vysny

Field Summary
protected  String _fileName
          Valid after the component is disposed.
protected  Button browseButton
          Button that allows user to browse for files.
protected  FileBrowserEnum browser
          A kind of browser that is displayed when the 'browse' button is clicked.
protected  Composite composite
          Panel where all components are placed.
protected  MessageLevelEnum extLevel
          What level of validity to signalise when preferredExtension condition is broken.
protected  Text fileNameText
          Textbox where the file name may be entered.
protected  Map<FileRequirementsEnum,MessageLevelEnum> flags
          maps flags to their message level.
protected  ValidityMessages lastMessages
          Validity messages.
protected  String preferredExtension
          Ignored if null.
 
Fields inherited from class sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
listeners, msgListeners
 
Constructor Summary
FileSelector(Composite parent, String preferredExtension, MessageLevelEnum extLevel, Map<FileRequirementsEnum,MessageLevelEnum> flags, FileBrowserEnum browser)
          Constructs instance of the widget.
 
Method Summary
 boolean existsDir()
          Checks whether the directory exists.
 boolean existsFile()
          Checks whether the file exists.
protected  void fillData()
          Fills the text value and the validity message object.
 Composite getComposite()
          Returns composite that is encapsulated in this object.
 String getFileName()
          Returns file name that user entered.
 ValidityMessages getMessages()
          Checks if data contained in the widget are correct.
 String getState()
          Returns the state of this widget.
 Class<?> getStateClass()
          Returns the class of the state that the widget accepts.
 void setFileName(String fileName)
          Sets the file name.
 void setState(Object state)
          Sets new state for the widget.
 
Methods inherited from class sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
addMessageListener, addModifyListener, allowModifyEvent, fireDataModified, removeMessageListener, removeModifyListener, suppressModifyEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

preferredExtension

protected final String preferredExtension
Ignored if null. Otherwise, warning is signalised when file name does not end with this string. The string should start with a dot.


extLevel

protected final MessageLevelEnum extLevel
What level of validity to signalise when preferredExtension condition is broken.


flags

protected Map<FileRequirementsEnum,MessageLevelEnum> flags
maps flags to their message level.


browser

protected final FileBrowserEnum browser
A kind of browser that is displayed when the 'browse' button is clicked.


composite

protected final Composite composite
Panel where all components are placed.


fileNameText

protected final Text fileNameText
Textbox where the file name may be entered.


browseButton

protected final Button browseButton
Button that allows user to browse for files.


_fileName

protected String _fileName
Valid after the component is disposed.


lastMessages

protected ValidityMessages lastMessages
Validity messages.

Constructor Detail

FileSelector

public FileSelector(Composite parent,
                    String preferredExtension,
                    MessageLevelEnum extLevel,
                    Map<FileRequirementsEnum,MessageLevelEnum> flags,
                    FileBrowserEnum browser)
Constructs instance of the widget.

Parameters:
parent - parent composite.
preferredExtension - ignored if null. Otherwise, warning is signalised when file name does not end with this string. The string should start with a dot.
extLevel - what kind of validity to signalise when preferredExtension condition is broken. If null then no extension check is performed.
browser - a kind of browser that is displayed when the 'browse' button is clicked.
flags - maps flags to their message level.
Method Detail

getComposite

public final Composite getComposite()
Description copied from interface: IUserInputWidget
Returns composite that is encapsulated in this object.

Returns:
composite where all controls are placed.

getFileName

public String getFileName()
Returns file name that user entered.

Returns:
the file name.

setFileName

public void setFileName(String fileName)
Sets the file name.

Parameters:
fileName - file name to set.

existsFile

public boolean existsFile()
Checks whether the file exists.

Returns:
true if the file returned by getFileName() exists.

existsDir

public boolean existsDir()
Checks whether the directory exists.

Returns:
true if the

fillData

protected void fillData()
Fills the text value and the validity message object.


getMessages

public ValidityMessages getMessages()
Description copied from interface: IUserInputWidget
Checks if data contained in the widget are correct. Contains error/info/warning messages that occured during last data change.

Returns:
null if data is correct, or instance of ValidityMessages if there is error, warning or info message.

getState

public String getState()
Description copied from interface: IUserInputWidget
Returns the state of this widget. The state must be in sync with the controls placed on the widget.

Returns:
the model.

getStateClass

public Class<?> getStateClass()
Description copied from interface: IUserInputWidget
Returns the class of the state that the widget accepts.

Returns:
model class, never null.

setState

public void setState(Object state)
Description copied from interface: IUserInputWidget
Sets new state for the widget. The widget must re-read all relevant properties from the state and set its controls with new values.

Parameters:
state - the model to set. You may use the construct setModel(getModel()) to reflect changes made in the model. Please note that nearly all widgets rejects null value.


Copyright © 2003-2006 null. All Rights Reserved.