org.topbraidcomposer.ui.util
Class WSFileDialog

java.lang.Object
  extended by org.eclipse.jface.window.Window
      extended by org.eclipse.jface.dialogs.Dialog
          extended by org.topbraidcomposer.ui.util.WSFileDialog
All Implemented Interfaces:
org.eclipse.jface.window.IShellProvider

public class WSFileDialog
extends org.eclipse.jface.dialogs.Dialog

FileDialog that is workspace relative and can start at a given root element Basically embeds the relevant parts of the resource navigator in a dialog. The workhorse here is the WorkbenchContentProvider I'm sure...

Author:
Frank Sauer, Holger Knublauch

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
org.eclipse.jface.window.Window.IExceptionHandler
 
Field Summary
 
Fields inherited from class org.eclipse.jface.dialogs.Dialog
blockedHandler, buttonBar, DIALOG_DEFAULT_BOUNDS, DIALOG_PERSISTLOCATION, DIALOG_PERSISTSIZE, dialogArea, DLG_IMG_ERROR, DLG_IMG_HELP, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
WSFileDialog(org.eclipse.swt.widgets.Shell parentShell, int selectionStyle, java.lang.String title)
          Open on the workspace root without filters or workingset
WSFileDialog(org.eclipse.swt.widgets.Shell parentShell, int selectionStyle, java.lang.String title, org.eclipse.core.resources.IResource rootElement, boolean expand, java.lang.String[] extensions, org.eclipse.ui.IWorkingSet workingSet)
           
 
Method Summary
protected  org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
           
protected  org.eclipse.jface.viewers.TreeViewer createViewer(org.eclipse.swt.widgets.Composite parent)
           
 java.lang.String getFileName()
           
 org.eclipse.core.resources.IResource[] getMultiResult()
          Get an array of selected resources or null if canceled
 org.eclipse.core.resources.IResource getSingleResult()
          Get the single selection result if any or the first selected element if SWT.MULTI was used as the selectionType
protected  void initContentProvider(org.eclipse.jface.viewers.TreeViewer viewer)
          This is the key, the WorkBenchContentProvider provides us with all the resource information
protected  void initFilters(org.eclipse.jface.viewers.TreeViewer viewer)
          Attach the filters to the tree viewer
protected  void initLabelProvider(org.eclipse.jface.viewers.TreeViewer viewer)
           
protected  void okPressed()
          process the tree selection and keep as the resultIResource[] until needed by our client
 void setExtensions(java.lang.String[] extensions)
          Only files with the given file extensions will be shown
 void setNewFileName(java.lang.String fileName)
           
 void setSelectedContainer(org.eclipse.core.resources.IContainer container)
           
 
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, buttonPressed, cancelPressed, close, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButton, createButtonBar, createButtonsForButtonBar, createContents, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getDialogBoundsSettings, getDialogBoundsStrategy, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
 
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, configureShell, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSFileDialog

public WSFileDialog(org.eclipse.swt.widgets.Shell parentShell,
                    int selectionStyle,
                    java.lang.String title,
                    org.eclipse.core.resources.IResource rootElement,
                    boolean expand,
                    java.lang.String[] extensions,
                    org.eclipse.ui.IWorkingSet workingSet)
Parameters:
parentShell - this shell will be blocked by the modal WSFileDialog
selectionStyle - must be SWT.SINGLE or SWT.MULTI or SWT.SAVE
title - the dialog's title
rootElement - resource to be the rootElement for the tree
expand - if true, the root element will be expanded
extensions - if specified only files with these extensions are shown
workingSet - if specified only files in this workingSet are shown

WSFileDialog

public WSFileDialog(org.eclipse.swt.widgets.Shell parentShell,
                    int selectionStyle,
                    java.lang.String title)
Open on the workspace root without filters or workingset

Parameters:
parentShell - this shell will be blocked by the modal WSFileDialog
selectionStyle - must be SWT.SINGLE or SWT.MULTI or SWT.SAVE
title - the dialog title
Method Detail

setExtensions

public void setExtensions(java.lang.String[] extensions)
Only files with the given file extensions will be shown

Parameters:
extensions -

createDialogArea

protected org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
Overrides:
createDialogArea in class org.eclipse.jface.dialogs.Dialog

createViewer

protected org.eclipse.jface.viewers.TreeViewer createViewer(org.eclipse.swt.widgets.Composite parent)

getFileName

public java.lang.String getFileName()

initFilters

protected void initFilters(org.eclipse.jface.viewers.TreeViewer viewer)
Attach the filters to the tree viewer

Parameters:
viewer -

initContentProvider

protected void initContentProvider(org.eclipse.jface.viewers.TreeViewer viewer)
This is the key, the WorkBenchContentProvider provides us with all the resource information

Parameters:
viewer -

initLabelProvider

protected void initLabelProvider(org.eclipse.jface.viewers.TreeViewer viewer)

okPressed

protected void okPressed()
process the tree selection and keep as the resultIResource[] until needed by our client

Overrides:
okPressed in class org.eclipse.jface.dialogs.Dialog
See Also:
Dialog.okPressed()

getSingleResult

public org.eclipse.core.resources.IResource getSingleResult()
Get the single selection result if any or the first selected element if SWT.MULTI was used as the selectionType

Returns:
one selected resource or null if none or canceled

getMultiResult

public org.eclipse.core.resources.IResource[] getMultiResult()
Get an array of selected resources or null if canceled

Returns:
selected resources or null if none or canceled

setNewFileName

public void setNewFileName(java.lang.String fileName)

setSelectedContainer

public void setSelectedContainer(org.eclipse.core.resources.IContainer container)