SAM

org.topcased.modeler.sam.dialogs
Class FilteredFilesResourceSelectionDialog

java.lang.Object
  extended by org.eclipse.jface.window.Window
      extended by org.eclipse.jface.dialogs.Dialog
          extended by org.eclipse.jface.dialogs.TrayDialog
              extended by org.eclipse.ui.dialogs.SelectionDialog
                  extended by org.topcased.modeler.sam.dialogs.FilteredFilesResourceSelectionDialog
All Implemented Interfaces:
org.eclipse.jface.window.IShellProvider

public class FilteredFilesResourceSelectionDialog
extends org.eclipse.ui.dialogs.SelectionDialog

Code copied from ResourceSelectionDialog in org.eclipse.ui.dialogs so as to change the getResourceProvider(int) in order to only list files having an extension specified with setFileExtensionFilter(String). Since this method is private and there is no simple way to override createDialogArea(Composite) to use our own (no access to private fields), this is the only workaround I found. The only dependency remaining toward internal eclipse classes is the constant IIDEHelpContextIds.RESOURCE_SELECTION_DIALOG. The internal to eclipse class CheckboxTreeAndListGroup was copied in this package to be independent of changes in the future. Original Javadoc : A standard resource selection dialog which solicits a list of resources from the user. The getResult method returns the selected resources.

This class may be instantiated; it is not intended to be subclassed.

Example:

 ResourceSelectionDialog dialog = new ResourceSelectionDialog(getShell(), rootResource, msg);
 dialog.setInitialSelections(selectedResources);
 dialog.open();
 return dialog.getResult();
 


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
FilteredFilesResourceSelectionDialog(org.eclipse.swt.widgets.Shell parentShell, org.eclipse.core.runtime.IAdaptable rootElement, java.lang.String message)
          Creates a resource selection dialog rooted at the given element.
 
Method Summary
 void checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent event)
           
protected  void configureShell(org.eclipse.swt.widgets.Shell shell)
           
 void create()
           
protected  org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
           
protected  void okPressed()
          The ResourceSelectionDialog implementation of this Dialog method builds a list of the selected resources for later retrieval by the client and closes this dialog.
 void setFileExtensionFilter(java.lang.String filter)
          To be called before opening the dialog so as to set the accepted file extensions.
 
Methods inherited from class org.eclipse.ui.dialogs.SelectionDialog
createButtonsForButtonBar, createMessageArea, getDialogBoundsSettings, getDialogBoundsStrategy, getInitialElementSelections, getInitialSelections, getMessage, getOkButton, getResult, setDialogBoundsSettings, setInitialElementSelections, setInitialSelections, setMessage, setResult, setSelectionResult, setTitle
 
Methods inherited from class org.eclipse.jface.dialogs.TrayDialog
close, closeTray, createButtonBar, createHelpControl, getLayout, getTray, isDialogHelpAvailable, isHelpAvailable, openTray, setDialogHelpAvailable, setHelpAvailable
 
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, buttonPressed, cancelPressed, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, createButton, createContents, dialogFontIsDefault, getBlockedHandler, getButton, getButtonBar, getCancelButton, getDialogArea, getImage, getInitialLocation, getInitialSize, getOKButton, initializeBounds, initializeDialogUnits, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
 
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, 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

FilteredFilesResourceSelectionDialog

public FilteredFilesResourceSelectionDialog(org.eclipse.swt.widgets.Shell parentShell,
                                            org.eclipse.core.runtime.IAdaptable rootElement,
                                            java.lang.String message)
Creates a resource selection dialog rooted at the given element.

Parameters:
parentShell - the parent shell
rootElement - the root element to populate this dialog with
message - the message to be displayed at the top of this dialog, or null to display a default message
Method Detail

checkStateChanged

public void checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent event)
Parameters:
event - the event

configureShell

protected void configureShell(org.eclipse.swt.widgets.Shell shell)
Overrides:
configureShell in class org.eclipse.ui.dialogs.SelectionDialog

create

public void create()
Overrides:
create in class org.eclipse.jface.dialogs.Dialog

createDialogArea

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

okPressed

protected void okPressed()
The ResourceSelectionDialog implementation of this Dialog method builds a list of the selected resources for later retrieval by the client and closes this dialog.

Overrides:
okPressed in class org.eclipse.jface.dialogs.Dialog

setFileExtensionFilter

public void setFileExtensionFilter(java.lang.String filter)
To be called before opening the dialog so as to set the accepted file extensions. By default all file resources will be displayed.

Parameters:
filter - The allowed file extension.

SAM

Copyright (c) 2005 TOPCASED Contributors 2005 - 2007. All rights reserved.