Class ResourceDialog

  • All Implemented Interfaces:
    org.eclipse.jface.window.IShellProvider

    public class ResourceDialog
    extends org.eclipse.jface.dialogs.Dialog
    Instances of this class allow a user to specify one or more URIs identifying resources. The dialog includes buttons that allow the file system or workspace to be browsed, so that the URI can be automatically filled based on the selected file.

    Subclasses are encouraged to override processResources(), where they can process the specified URIs.

    Since:
    2.2.0
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.jface.window.Window

        org.eclipse.jface.window.Window.IExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int CONTROL_OFFSET  
      protected int style  
      protected String title  
      protected org.eclipse.swt.widgets.Text uriField  
      protected String uriText  
      • 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, resizeHasOccurred
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceDialog​(org.eclipse.swt.widgets.Shell parent, String title, int style)
      Creates a new instance of this class, given a parent shell, an optional title, and a style value describing its behaviour.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void configureShell​(org.eclipse.swt.widgets.Shell shell)  
      protected org.eclipse.swt.widgets.Control createDialogArea​(org.eclipse.swt.widgets.Composite parent)
      Creates and returns the contents of the upper part of this dialog.
      List<net.enilink.komma.core.URI> getURIs()
      Returns the list of space-separated URIs from the URI text field.
      String getURIText()
      Returns the value of the URI text field.
      protected boolean isMulti()  
      protected boolean isSave()  
      protected void normalizeStyle()  
      protected void okPressed()
      Called when the OK button has been pressed, this method calls getURIText() to cache and return the URI text field's value (so that it may be retrieved even after the field has been disposed).
      protected void prepareBrowseFileSystemButton​(org.eclipse.swt.widgets.Button browseFileSystemButton)
      Called to prepare the Browse File System button, this implementation adds a selection listener that creates an appropriate FileDialog.
      protected void prepareBrowseWorkspaceButton​(org.eclipse.swt.widgets.Button browseWorkspaceButton)
      Called to prepare the Browse Workspace button, this implementation adds a selection listener that creates an appropriate WorkspaceResourceDialog.
      protected boolean processResources()
      Called by okPressed() to handle the specified URIs, this implementation simply returns true, allowing the dialog to close.
      • 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, isResizable, setBlockedHandler, setButtonLayoutData, setButtonLayoutFormData, shortenText
      • Methods inherited from class org.eclipse.jface.window.Window

        canHandleShellCloseEvent, 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
    • Field Detail

      • title

        protected String title
      • style

        protected int style
      • uriField

        protected org.eclipse.swt.widgets.Text uriField
      • uriText

        protected String uriText
    • Constructor Detail

      • ResourceDialog

        public ResourceDialog​(org.eclipse.swt.widgets.Shell parent,
                              String title,
                              int style)
        Creates a new instance of this class, given a parent shell, an optional title, and a style value describing its behaviour.
        Parameters:
        parent - a shell which will be the parent of the new instance
        title - an optional title for the dialog, to be used in place of the default
        style - SWT style bits, indicating whether existing (SWT.OPEN) or new (SWT.SAVE) resources are to be specified and, in the former case, whether single (SWT.SINGLE) or multiple (SWT.MULTI). Open existing and single resource are the defaults.
    • Method Detail

      • normalizeStyle

        protected void normalizeStyle()
      • isSave

        protected boolean isSave()
      • isMulti

        protected boolean isMulti()
      • configureShell

        protected void configureShell​(org.eclipse.swt.widgets.Shell shell)
        Overrides:
        configureShell in class org.eclipse.jface.window.Window
      • prepareBrowseFileSystemButton

        protected void prepareBrowseFileSystemButton​(org.eclipse.swt.widgets.Button browseFileSystemButton)
        Called to prepare the Browse File System button, this implementation adds a selection listener that creates an appropriate FileDialog.
      • prepareBrowseWorkspaceButton

        protected void prepareBrowseWorkspaceButton​(org.eclipse.swt.widgets.Button browseWorkspaceButton)
        Called to prepare the Browse Workspace button, this implementation adds a selection listener that creates an appropriate WorkspaceResourceDialog.
      • okPressed

        protected void okPressed()
        Called when the OK button has been pressed, this method calls getURIText() to cache and return the URI text field's value (so that it may be retrieved even after the field has been disposed). It then calls processResources() to handle the specified URIs and optionally closes the dialog, based on its return value.
        Overrides:
        okPressed in class org.eclipse.jface.dialogs.Dialog
      • getURIText

        public String getURIText()
        Returns the value of the URI text field.
      • getURIs

        public List<net.enilink.komma.core.URI> getURIs()
        Returns the list of space-separated URIs from the URI text field.
      • processResources

        protected boolean processResources()
        Called by okPressed() to handle the specified URIs, this implementation simply returns true, allowing the dialog to close. Subclasses can override this method to load, save, or otherwise process resources, and based on this processing, to optionally prevent the dialog from being closed if the URIs are invalid.
        Returns:
        true if the dialog can be closed, false if URI(s) must be re-entered