Class WizardNewFileCreationPage

  • All Implemented Interfaces:
    IDialogPage, IMessageProvider, IWizardPage, Listener

    public class WizardNewFileCreationPage
    extends WizardPage
    implements Listener
    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

    Subclasses may extend

    • handleEvent
    • Constructor Detail

      • WizardNewFileCreationPage

        public WizardNewFileCreationPage​(String pageName,
                                         IStructuredSelection selection)
        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.
        pageName - the name of the page
        selection - the current resource selection
    • Method Detail

      • createAdvancedControls

        protected void createAdvancedControls​(Composite parent)
        Creates the widget for advanced options.
        parent - the parent composite
      • createControl

        public void createControl​(Composite parent)
        Description copied from interface: IDialogPage
        Creates the top level control for this dialog page under the given parent composite.

        Implementors are responsible for ensuring that the created control can be accessed via getControl

        Specified by:
        createControl in interface IDialogPage
        parent - the parent composite
      • createFile

        protected void createFile​(IFile fileHandle,
                                  InputStream contents,
                                  IProgressMonitor monitor)
                           throws CoreException
        As of 3.3, use or override createNewFile() which uses the undoable operation support. To supply customized file content for a subclass, use getInitialContents().
        Creates a file resource given the file handle and contents.
        fileHandle - the file handle to create a file resource with
        contents - the initial contents of the new file resource, or null if none (equivalent to an empty stream)
        monitor - the progress monitor to show visual progress with
        CoreException - if the operation fails
        OperationCanceledException - if the operation is canceled
      • createLinkTarget

        protected void createLinkTarget()
        Creates the link target path if a link target has been specified.
      • createNewFile

        public IFile 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.

        the created file resource, or null if the file was not created
      • createRule

        protected ISchedulingRule createRule​(IResource resource)
        As of 3.3, scheduling rules are provided by the undoable operation that this page creates and executes.
        Returns the scheduling rule to use when creating the resource at the given container path. The rule should be the creation rule for the top-most non-existing parent.
        resource - The resource being created
        The scheduling rule for creating the given resource
      • getContainerFullPath

        public IPath getContainerFullPath()
        Returns the current full path of the containing resource as entered or selected by the user, or its anticipated initial value.
        the container's full path, anticipated initial value, or null if no path is known
      • getFileName

        public String getFileName()
        Returns the current file name as entered by the user, or its anticipated initial value.

        The current file name will include the file extension if the preconditions are met.
        the file name, its anticipated initial value, or null if no file name is known
        See Also:
      • getFileExtension

        public String getFileExtension()
        Returns the file extension to use when creating the new file.
        the file extension or null.
        See Also:
      • getInitialContents

        protected InputStream 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.
        initial contents to be given to new file resource instances
      • getNewFileLabel

        protected String getNewFileLabel()
        Returns the label to display in the file name specification visual component group.

        Subclasses may reimplement.

        the label to display in the file name specification visual component group
      • handleAdvancedButtonSelect

        protected void handleAdvancedButtonSelect()
        Shows/hides the advanced option widgets.
      • handleEvent

        public void handleEvent​(Event event)
        The WizardNewFileCreationPage implementation of this Listener method handles all events and enablements for controls on this page. Subclasses may extend.
        Specified by:
        handleEvent in interface Listener
        event - the event which occurred
      • 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.
      • setAllowExistingResources

        public void setAllowExistingResources​(boolean value)
        Sets the flag indicating whether existing resources are permitted to be specified on this page.
        value - true if existing resources are permitted, and false otherwise
      • setContainerFullPath

        public 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.
        path - the full path to the container
      • setFileName

        public 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.
        value - new file name
      • setFileExtension

        public void setFileExtension​(String value)
        Set the only file extension allowed for this page's file name field. If this page's controls do not exist yet, store it for future use.

        If a file extension is specified, then it will always be appended with a '.' to the text from the file name field for validation when the following conditions are met:

        (1) File extension length is greater than 0
        (2) File name field text length is greater than 0
        (3) File name field text does not already end with a '.' and the file extension specified (case sensitive)

        The file extension will not be reflected in the actual file name field until the file name field loses focus.
        value - The file extension without the '.' prefix (e.g. 'java', 'xml')
      • validateLinkedResource

        protected IStatus validateLinkedResource()
        Checks whether the linked resource target is valid. Sets the error message accordingly and returns the status.
        IStatus validation result from the CreateLinkedResourceGroup
      • validatePage

        protected boolean validatePage()
        Returns whether this page's controls currently all contain valid values.
        true if all controls are valid, and false if at least one is invalid
      • setVisible

        public void setVisible​(boolean visible)
        Description copied from class: DialogPage
        The DialogPage implementation of this IDialogPage method sets the control to the given visibility state. Subclasses may extend.
        Specified by:
        setVisible in interface IDialogPage
        setVisible in class DialogPage
        visible - true to make this page visible, and false to hide it