Class ResourceDialog
- java.lang.Object
-
- org.eclipse.jface.window.Window
-
- org.eclipse.jface.dialogs.Dialog
-
- net.enilink.komma.common.ui.rcp.dialogs.ResourceDialog
-
- All Implemented Interfaces:
org.eclipse.jface.window.IShellProvider
public class ResourceDialog extends org.eclipse.jface.dialogs.DialogInstances 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
-
-
Field Summary
Fields Modifier and Type Field Description protected static intCONTROL_OFFSETprotected intstyleprotected Stringtitleprotected org.eclipse.swt.widgets.TexturiFieldprotected StringuriText-
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
-
-
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 voidconfigureShell(org.eclipse.swt.widgets.Shell shell)protected org.eclipse.swt.widgets.ControlcreateDialogArea(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.StringgetURIText()Returns the value of the URI text field.protected booleanisMulti()protected booleanisSave()protected voidnormalizeStyle()protected voidokPressed()Called when the OK button has been pressed, this method callsgetURIText()to cache and return the URI text field's value (so that it may be retrieved even after the field has been disposed).protected voidprepareBrowseFileSystemButton(org.eclipse.swt.widgets.Button browseFileSystemButton)Called to prepare the Browse File System button, this implementation adds a selection listener that creates an appropriateFileDialog.protected voidprepareBrowseWorkspaceButton(org.eclipse.swt.widgets.Button browseWorkspaceButton)Called to prepare the Browse Workspace button, this implementation adds a selection listener that creates an appropriateWorkspaceResourceDialog.protected booleanprocessResources()Called byokPressed()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
-
CONTROL_OFFSET
protected static final int CONTROL_OFFSET
- See Also:
- Constant Field Values
-
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 instancetitle- an optional title for the dialog, to be used in place of the defaultstyle-SWT style bits, indicating whetherexisting (orSWT.OPEN)newresources are to be specified and, in the former case, whether(SWT.SAVE)single (orSWT.SINGLE)multiple (. Open existing and single resource are the defaults.SWT.MULTI)
-
-
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:
configureShellin classorg.eclipse.jface.window.Window
-
createDialogArea
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. This implementation creates a labeled text field for the URI(s) and buttons for browsing the file system and workspace. These buttons are configured (selection listeners are added) by callingprepareBrowseFileSystemButton(org.eclipse.swt.widgets.Button)andprepareBrowseWorkspaceButton(org.eclipse.swt.widgets.Button), respectively.- Overrides:
createDialogAreain classorg.eclipse.jface.dialogs.Dialog
-
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 appropriateFileDialog.
-
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 appropriateWorkspaceResourceDialog.
-
okPressed
protected void okPressed()
Called when the OK button has been pressed, this method callsgetURIText()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 callsprocessResources()to handle the specified URIs and optionally closes the dialog, based on its return value.- Overrides:
okPressedin classorg.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 byokPressed()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:
trueif the dialog can be closed,falseif URI(s) must be re-entered
-
-