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

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.WorkspaceResourcesPage
All Implemented Interfaces:
IDialogPage, IMessageProvider, IWizardPage
Direct Known Subclasses:
ImportDiagramsWorkspaceSourcesPage, ImportGraphWorkspaceSourcesPage

public class WorkspaceResourcesPage
extends ResourceTreeAndListPage

A wizard page that allows the user to choose files to import from the workspace. Optionally, a target group may allow the user to choose a target folder in the workspace to import to.

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
WorkspaceResourcesPage(String pageName, boolean showTargetGroup, String[] fileExtensions, IStructuredSelection selection)
          Constructs a new instance with the given name.
 
Method Summary
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 doBrowseTarget()
          Called when the target group browse button is clicked.
protected  boolean doValidate()
          Validates the page.
protected  ViewerFilter[] getResourceListFilters()
          Returns the viewer filters to be used for the resource list.
 List<IResource> getResources(IProgressMonitor monitor)
          Returns the selected files.
protected  ViewerFilter[] getResourceTreeFilters()
          Returns the viewer filters to be used for the resource tree.
 IPath getTargetContainerPath()
          Returns the target container path entered by the user.
protected  IStructuredSelection getWorkspaceSelection()
          Returns the selection the wizard was invoked on.
protected  void initializeControls()
          Called after the controls were created and the settings restored.
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
applyNewSource, createButtonBar, createControl, createDefaultSourceGroup, createDefaultTargetGroup, deselectAllListItems, doBrowseSource, getResourceListContentProvider, getResourceListLabelProvider, getResourceListViewerComparator, getResourceTreeContentProvider, getResourceTreeLabelProvider, getResourceTreeViewerComparator, getSelectedElements, getSourceGroupBrowseButton, getSourceGroupCombo, getTargetGroupBrowseButton, getTargetGroupCombo, 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

WorkspaceResourcesPage

public WorkspaceResourcesPage(String pageName,
                              boolean showTargetGroup,
                              String[] fileExtensions,
                              IStructuredSelection selection)
Constructs a new instance with the given name.

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 - array of allowed file name extensions without preceding dot. May be null.
selection - the selection on which the wizard was invoked.
Method Detail

getResources

public List<IResource> getResources(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.

getWorkspaceSelection

protected IStructuredSelection getWorkspaceSelection()
Returns the selection the wizard was invoked on.

Returns:
selection the wizard was invoked on.

initializeControls

protected void initializeControls()
Called after the controls were created and the settings restored. Subclasses may override and can use this method to do any initialization tasks that might be left, like preselecting resources. The default implementation does nothing.

Overrides:
initializeControls in class ResourceTreeAndListPage

getResourceTreeFilters

protected ViewerFilter[] getResourceTreeFilters()
Returns the viewer filters 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 an empty array.

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

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

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.

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.

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