de.cau.cs.kieler.core.ui.wizards
Class FileSystemResourcesPage

java.lang.Object
  extended by org.eclipse.jface.dialogs.DialogPage
      extended by org.eclipse.jface.wizard.WizardPage
          extended by de.cau.cs.kieler.core.ui.wizards.ResourceTreeAndListPage
              extended by de.cau.cs.kieler.core.ui.wizards.FileSystemResourcesPage
All Implemented Interfaces:
IDialogPage, IMessageProvider, IWizardPage
Direct Known Subclasses:
ImportDiagramsFileSystemSourcesPage, ImportGraphFileSystemSourcesPage

public class FileSystemResourcesPage
extends ResourceTreeAndListPage

A wizard page that allows the user to choose files to import from the file system. Optionally, a target group may allow the user to choose a target folder in the workspace to import to. Files can be filtered using regular expressions.

The settings made on this page can be saved if the wizard has an instance of IDialogSettings set on it. If it has not, settings are neither saved nor loaded.

Rating yellow
2010-03-14 reviewed by haf, msp, pkl

Field Summary
 
Fields inherited from interface org.eclipse.jface.dialogs.IMessageProvider
ERROR, INFORMATION, NONE, WARNING
 
Constructor Summary
FileSystemResourcesPage(String pageName, boolean showTargetGroup)
          Constructs a new instance with the given name that doesn't filter out any files.
FileSystemResourcesPage(String pageName, boolean showTargetGroup, String fileNamePattern)
          Constructs a new instance with the given name, using a regular expression as its file name filter.
FileSystemResourcesPage(String pageName, boolean showTargetGroup, String[] fileExtensions)
          Constructs a new instance with the given name, using a regular expression as its file name filter.
 
Method Summary
protected  void applyNewSource(String text)
          Called when the source group combo loses focus.
protected  void applyNewTarget(String text)
          Called when the target group combo loses focus.
protected  Composite createOptionsGroup(Composite parent)
          Creates the options group.
protected  Composite createSourceGroup(Composite parent)
          Creates the source group.
protected  Composite createTargetGroup(Composite parent)
          Creates the target group.
protected  void doBrowseSource()
          Called when the source group browse button is clicked.
protected  void doBrowseTarget()
          Called when the target group browse button is clicked.
protected  boolean doValidate()
          Validates the page.
 List<File> getFiles(IProgressMonitor monitor)
          Returns the selected files.
protected  ITreeContentProvider getResourceListContentProvider()
          Returns the content provider to be used for the resource list.
protected  ViewerFilter[] getResourceListFilters()
          Returns the viewer filters to be used for the resource list.
protected  ITreeContentProvider getResourceTreeContentProvider()
          Returns the content provider to be used for the resource tree.
 IPath getTargetContainerPath()
          Returns the target container path entered by the user.
protected  void restoreDialogSettings()
          Restores the user's saved input.
 void saveDialogSettings()
          Saves the user's input.
 
Methods inherited from class de.cau.cs.kieler.core.ui.wizards.ResourceTreeAndListPage
createButtonBar, createControl, createDefaultSourceGroup, createDefaultTargetGroup, deselectAllListItems, getResourceListLabelProvider, getResourceListViewerComparator, getResourceTreeFilters, getResourceTreeLabelProvider, getResourceTreeViewerComparator, getSelectedElements, getSourceGroupBrowseButton, getSourceGroupCombo, getTargetGroupBrowseButton, getTargetGroupCombo, initializeControls, isAnythingSelected, selectAllListItems, selectAndRevealElement, setResourceTreeInput, validate
 
Methods inherited from class org.eclipse.jface.wizard.WizardPage
canFlipToNextPage, getContainer, getDialogSettings, getImage, getName, getNextPage, getPreviousPage, getShell, getWizard, isCurrentPage, isPageComplete, setDescription, setErrorMessage, setImageDescriptor, setMessage, setPageComplete, setPreviousPage, setTitle, setWizard, toString
 
Methods inherited from class org.eclipse.jface.dialogs.DialogPage
convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, dispose, getControl, getDescription, getDialogFontName, getErrorMessage, getFont, getMessage, getMessageType, getTitle, getToolTipText, initializeDialogUnits, isControlCreated, performHelp, setButtonLayoutData, setControl, setMessage, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.dialogs.IDialogPage
dispose, getControl, getDescription, getErrorMessage, getMessage, getTitle, performHelp, setVisible
 

Constructor Detail

FileSystemResourcesPage

public FileSystemResourcesPage(String pageName,
                               boolean showTargetGroup)
Constructs a new instance with the given name that doesn't filter out any files.

Parameters:
pageName - name of the page. Used as part of the IDs the dialog settings are saved as.
showTargetGroup - if true, a target group is created where the user can select a folder in the workspace to import to.

FileSystemResourcesPage

public FileSystemResourcesPage(String pageName,
                               boolean showTargetGroup,
                               String fileNamePattern)
Constructs a new instance with the given name, using a regular expression as its file name filter.

Parameters:
pageName - name of the page. Used as part of the IDs the dialog settings are saved as.
showTargetGroup - if true, a target group is created where the user can select a folder in the workspace to import to.
fileNamePattern - file name pattern, specified as a regular expression.

FileSystemResourcesPage

public FileSystemResourcesPage(String pageName,
                               boolean showTargetGroup,
                               String[] fileExtensions)
Constructs a new instance with the given name, using a regular expression as its file name filter.

Parameters:
pageName - name of the page. Used as part of the IDs the dialog settings are saved as.
showTargetGroup - if true, a target group is created where the user can select a folder in the workspace to import to.
fileExtensions - a list of file extensions, either with or without preceding dot, that determines the files that will be shown to the user.
Method Detail

getFiles

public List<File> getFiles(IProgressMonitor monitor)
Returns the selected files. This is a potentially long-running operation.

Parameters:
monitor - progress monitor. May be null.
Returns:
the list of selected files.

getTargetContainerPath

public IPath getTargetContainerPath()
Returns the target container path entered by the user. The container might not exist yet.

Returns:
the container to import to.

getResourceTreeContentProvider

protected ITreeContentProvider getResourceTreeContentProvider()
Returns the content provider to be used for the resource tree. This method is only called once, upon the resource tree's creation. Subclasses may override. The default implementation returns the BaseWorkbenchContentProvider.

Overrides:
getResourceTreeContentProvider in class ResourceTreeAndListPage
Returns:
content provider for the resource tree.

getResourceListFilters

protected ViewerFilter[] getResourceListFilters()
Returns the viewer filters to be used for the resource list. This method is only called once, upon the resource list's creation. Subclasses may override. The default implementation returns an empty array.

Note: This could be made more flexible to allow changeing the list of active filters after creation.

Overrides:
getResourceListFilters in class ResourceTreeAndListPage
Returns:
array of filters.

getResourceListContentProvider

protected ITreeContentProvider getResourceListContentProvider()
Returns the content provider to be used for the resource list. This method is only called once, upon the resource list's creation. Subclasses may override. The default implementation returns the BaseWorkbenchContentProvider.

Overrides:
getResourceListContentProvider in class ResourceTreeAndListPage
Returns:
content provider for the resource list.

createSourceGroup

protected Composite createSourceGroup(Composite parent)
Creates the source group. This method is intended to be implemented by subclasses.

Subclasses may call ResourceTreeAndListPage.createDefaultSourceGroup(Composite, String, String) to have a default source group with a label, a combo box and a browse button created. In this case, it should also implement ResourceTreeAndListPage.applyNewSource(String) and ResourceTreeAndListPage.doBrowseSource(). While access to the combo box and the browse button shouldn't normally be necessary, they can be retrieved using ResourceTreeAndListPage.getSourceGroupCombo() and ResourceTreeAndListPage.getSourceGroupBrowseButton().

Specified by:
createSourceGroup in class ResourceTreeAndListPage
Parameters:
parent - the new source group's parent.
Returns:
the new source group, or null if none should be shown.

applyNewSource

protected void applyNewSource(String text)
Called when the source group combo loses focus. If a subclass created the default source group, it should implement this method to react to the user entering a new source. The default implementation does nothing.

After this method was called, ResourceTreeAndListPage.validate() is called automatically.

Overrides:
applyNewSource in class ResourceTreeAndListPage
Parameters:
text - the combo's current text.

doBrowseSource

protected void doBrowseSource()
Called when the source group browse button is clicked. If a subclass created the default source group, it should implement this method to pop up some kind of browse dialog. The default implementation does nothing.

After this method was called, ResourceTreeAndListPage.validate() is called automatically.

Overrides:
doBrowseSource in class ResourceTreeAndListPage

createTargetGroup

protected Composite createTargetGroup(Composite parent)
Creates the target group. This method is intended to be implemented by subclasses.

Subclasses may call ResourceTreeAndListPage.createDefaultTargetGroup(Composite, String, String) to have a default target group with a label, a combo box and a browse button created. In this case, it should also implement ResourceTreeAndListPage.applyNewTarget(String) and ResourceTreeAndListPage.doBrowseTarget(). While access to the combo box and the browse button shouldn't normally be necessary, they can be retrieved using ResourceTreeAndListPage.getTargetGroupCombo() and ResourceTreeAndListPage.getTargetGroupBrowseButton().

Specified by:
createTargetGroup in class ResourceTreeAndListPage
Parameters:
parent - the new target group's parent.
Returns:
the new target group, or null if none should be shown.

applyNewTarget

protected void applyNewTarget(String text)
Called when the target group combo loses focus. If a subclass created the default target group, it should implement this method to react to the user entering a new target. The default implementation does nothing.

After this method was called, ResourceTreeAndListPage.validate() is called automatically.

Overrides:
applyNewTarget in class ResourceTreeAndListPage
Parameters:
text - the combo's current text.

doBrowseTarget

protected void doBrowseTarget()
Called when the target group browse button is clicked. If a subclass created the default target group, it should implement this method to pop up some kind of browse dialog. The default implementation does nothing.

After this method was called, ResourceTreeAndListPage.validate() is called automatically.

Overrides:
doBrowseTarget in class ResourceTreeAndListPage

createOptionsGroup

protected Composite createOptionsGroup(Composite parent)
Creates the options group. This method is intended to be implemented by subclasses.

Specified by:
createOptionsGroup in class ResourceTreeAndListPage
Parameters:
parent - the new options group's parent.
Returns:
the new options group, or null if none should be shown.

doValidate

protected boolean doValidate()
Validates the page. This is the right place to set error messages on this page when some user input is missing or wrong. If the page validates fine, any error message is automatically cleared by the calling method. Subclasses may override, but must call this implementation. This implementation always returns true.

Overrides:
doValidate in class ResourceTreeAndListPage
Returns:
true if the page validates fine and the page is complete, false otherwise.

saveDialogSettings

public void saveDialogSettings()
Saves the user's input. The default implementation does nothing. Subclasses may override.

Overrides:
saveDialogSettings in class ResourceTreeAndListPage

restoreDialogSettings

protected void restoreDialogSettings()
Restores the user's saved input. Called after all controls have been created. The default implementation does nothing. Subclasses may override.

Overrides:
restoreDialogSettings in class ResourceTreeAndListPage