Package org.csstudio.ui.util.wizards
Class WizardNewFileCreationPage
java.lang.Object
org.eclipse.jface.dialogs.DialogPage
org.eclipse.jface.wizard.WizardPage
org.csstudio.ui.util.wizards.WizardNewFileCreationPage
- All Implemented Interfaces:
IDialogPage
,IMessageProvider
,IWizardPage
,Listener
- Direct Known Subclasses:
NewJavaScriptWizardPage
,NewOPIFileWizardPage
,NewParFileWizardPage
,NewPythonScriptWizardPage
Standard main page for a wizard that creates a file resource.
This page may be used by clients as-is; it may be also be subclassed to suit.
Subclasses may override
getInitialContents
getNewFileLabel
handleEvent
Code is based upon org.eclipse.ui.dialogs.WizardNewFileCreationPage
in plugin
org.eclipse.ui.ide
.
-
Field Summary
Fields inherited from interface org.eclipse.jface.dialogs.IMessageProvider
ERROR, INFORMATION, NONE, WARNING
-
Constructor Summary
ConstructorDescriptionWizardNewFileCreationPage
(String pageName, IStructuredSelection selection) Creates a new file creation wizard page.WizardNewFileCreationPage
(String pageName, IStructuredSelection selection, boolean canChooseProject) Creates a new file creation wizard page. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createControl
(Composite parent) protected void
createFile
(IFile fileHandle, InputStream contents) Creates a file resource given the file handle and contents.protected final IFile
createFileHandle
(IPath filePath) Creates a file resource handle for the file with the given workspace path.final IFile
Creates a new file resource in the selected container and with the selected name.final IPath
Returns the current full path of the containing resource as entered or selected by the user, or its anticipated initial value.Returns the current file name as entered by the user, or its anticipated initial value.protected InputStream
Returns a stream containing the initial contents to be given to new file resource instances.protected String
Returns the label to display in the file name specification visual component group.void
handleEvent
(Event event) TheWizardNewFileCreationPage
implementation of thisListener
method handles all events and enablements for controls on this page.protected void
Sets the initial contents of the container name entry field, based upon either a previously-specified initial value or the ability to determine such a value.void
setContainerFullPath
(IPath path) Sets the value of this page's container name field, or stores it for future use if this page's controls do not exist yet.void
setFileName
(String value) Sets the value of this page's file name field, or stores it for future use if this page's controls do not exist yet.void
setVisible
(boolean visible) protected final boolean
Returns whether this page's controls currently all contain valid values.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
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
Methods inherited from interface org.eclipse.jface.wizard.IWizardPage
getMinimumPageSize
-
Constructor Details
-
WizardNewFileCreationPage
Creates a new file creation wizard page. If the initial resource selection contains exactly one container resource then it will be used as the default container resource.- Parameters:
pageName
- the name of the pageselection
- the current resource selection
-
WizardNewFileCreationPage
public WizardNewFileCreationPage(String pageName, IStructuredSelection selection, boolean canChooseProject) Creates a new file creation wizard page. If the initial resource selection contains exactly one container resource then it will be used as the default container resource.- Parameters:
pageName
- the name of the pageselection
- the current resource selectioncanChooseProject
- flag to allow the selection of the target project
-
-
Method Details
-
createControl
- Specified by:
createControl
in interfaceIDialogPage
-
createFile
Creates a file resource given the file handle and contents.- Parameters:
fileHandle
- the file handle to create a file resource withcontents
- the initial contents of the new file resource, ornull
if none (equivalent to an empty stream)- Throws:
CoreException
- if the operation fails
-
createFileHandle
Creates a file resource handle for the file with the given workspace path. This method does not create the file resource; this is the responsibility ofcreateFile
.- Parameters:
filePath
- the path of the file resource to create a handle for- Returns:
- the new file resource handle
-
createNewFile
Creates a new file resource in the selected container and with the selected name. Creates any missing resource containers along the path; does nothing if the container resources already exist.In normal usage, this method is invoked after the user has pressed Finish on the wizard; the enablement of the Finish button implies that all controls on on this page currently contain valid values.
Note that this page caches the new file once it has been successfully created; subsequent invocations of this method will answer the same file resource without attempting to create it again.
This method should be called within a workspace modify operation since it creates resources.
- Returns:
- the created file resource, or
null
if the file was not created
-
getContainerFullPath
Returns the current full path of the containing resource as entered or selected by the user, or its anticipated initial value.- Returns:
- the container's full path, anticipated initial value, or
null
if no path is known
-
getFileName
Returns the current file name as entered by the user, or its anticipated initial value.- Returns:
- the file name, its anticipated initial value, or
null
if no file name is known
-
getInitialContents
Returns a stream containing the initial contents to be given to new file resource instances. Subclasses may wish to override. This default implementation provides no initial contents.- Returns:
- initial contents to be given to new file resource instances
-
getNewFileLabel
Returns the label to display in the file name specification visual component group.Subclasses may reimplement.
- Returns:
- the label to display in the file name specification visual component group
-
handleEvent
TheWizardNewFileCreationPage
implementation of thisListener
method handles all events and enablements for controls on this page. Subclasses may extend.- Specified by:
handleEvent
in interfaceListener
-
initialPopulateContainerNameField
protected void initialPopulateContainerNameField()Sets the initial contents of the container name entry field, based upon either a previously-specified initial value or the ability to determine such a value. -
setContainerFullPath
Sets the value of this page's container name field, or stores it for future use if this page's controls do not exist yet.- Parameters:
path
- the full path to the container
-
setFileName
Sets the value of this page's file name field, or stores it for future use if this page's controls do not exist yet.- Parameters:
value
- new file name
-
validatePage
protected final boolean validatePage()Returns whether this page's controls currently all contain valid values.- Returns:
true
if all controls are valid, andfalse
if at least one is invalid
-
setVisible
public void setVisible(boolean visible) - Specified by:
setVisible
in interfaceIDialogPage
- Overrides:
setVisible
in classDialogPage
-
getFileExtension
-