Class NewContainerWizardPage

java.lang.Object
org.eclipse.jface.dialogs.DialogPage
org.eclipse.jface.wizard.WizardPage
org.eclipse.jdt.ui.wizards.NewElementWizardPage
org.eclipse.jdt.ui.wizards.NewContainerWizardPage
All Implemented Interfaces:
org.eclipse.jface.dialogs.IDialogPage, org.eclipse.jface.dialogs.IMessageProvider, org.eclipse.jface.wizard.IWizardPage
Direct Known Subclasses:
NewTypeWizardPage

public abstract class NewContainerWizardPage extends NewElementWizardPage
Wizard page that acts as a base class for wizard pages that create new Java elements. The class provides a input field for source folders (called container in this class) and API to validate the enter source folder name.

Clients may subclass.

Since:
2.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    Id of the container field
    protected org.eclipse.core.runtime.IStatus
    The status of the last validation.

    Fields inherited from interface org.eclipse.jface.dialogs.IMessageProvider

    ERROR, INFORMATION, NONE, WARNING
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new NewContainerWizardPage
  • Method Summary

    Modifier and Type
    Method
    Description
    Opens a selection dialog that allows to select a source container.
    protected org.eclipse.core.runtime.IStatus
    This method is a hook which gets called after the source folder's text input field has changed.
    protected void
    createContainerControls(org.eclipse.swt.widgets.Composite parent, int nColumns)
    Creates the necessary controls (label, text field and browse button) to edit the source folder location.
    protected String
    Returns the label that is used for the container input field.
    protected org.eclipse.jface.text.ITextSelection
    Returns the text selection of the current editor.
    protected IJavaElement
    getInitialJavaElement(org.eclipse.jface.viewers.IStructuredSelection selection)
    Utility method to inspect a selection to find a Java element.
    Returns the Java project of the currently selected package fragment root or null if no package fragment root is configured.
    protected int
    Returns the recommended maximum width for text fields (in pixels).
    Returns the IPackageFragmentRoot that corresponds to the current value of the source folder field.
    Returns the current text of source folder text field.
    protected org.eclipse.core.resources.IWorkspaceRoot
    Returns the workspace root.
    protected void
    Hook method that gets called when a field on this page has changed.
    protected void
    Initializes the source folder field with a valid package fragment root.
    protected void
    initContainerPage(IJavaElement elem, boolean preferTestSourceFolder)
    Initializes the source folder field with a valid package fragment root.
    protected void
    Sets the focus to the source folder's text field.
    void
    setPackageFragmentRoot(IPackageFragmentRoot root, boolean canBeModified)
    Sets the current source folder (model and text field) to the given package fragment root.

    Methods inherited from class org.eclipse.jdt.ui.wizards.NewElementWizardPage

    setVisible, updateStatus, updateStatus

    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

    createControl, dispose, getControl, getDescription, getErrorMessage, getMessage, getTitle, performHelp

    Methods inherited from interface org.eclipse.jface.wizard.IWizardPage

    getMinimumPageSize
  • Field Details

    • CONTAINER

      protected static final String CONTAINER
      Id of the container field
      See Also:
    • fContainerStatus

      protected org.eclipse.core.runtime.IStatus fContainerStatus
      The status of the last validation.
  • Constructor Details

    • NewContainerWizardPage

      public NewContainerWizardPage(String name)
      Create a new NewContainerWizardPage
      Parameters:
      name - the wizard page's name
  • Method Details

    • getContainerLabel

      protected String getContainerLabel()
      Returns the label that is used for the container input field.
      Returns:
      the label that is used for the container input field.
      Since:
      3.2
    • initContainerPage

      protected void initContainerPage(IJavaElement elem)
      Initializes the source folder field with a valid package fragment root. The package fragment root is computed from the given Java element.
      Parameters:
      elem - the Java element used to compute the initial package fragment root used as the source folder
    • initContainerPage

      protected void initContainerPage(IJavaElement elem, boolean preferTestSourceFolder)
      Initializes the source folder field with a valid package fragment root. The package fragment root is computed from the given Java element.
      Parameters:
      elem - the Java element used to compute the initial package fragment root used as the source folder
      preferTestSourceFolder - where a source folder which has the IClasspathAttribute.TEST with a value of true should be preferred.
      Since:
      3.14
    • getInitialJavaElement

      protected IJavaElement getInitialJavaElement(org.eclipse.jface.viewers.IStructuredSelection selection)
      Utility method to inspect a selection to find a Java element.
      Parameters:
      selection - the selection to be inspected
      Returns:
      a Java element to be used as the initial selection, or null, if no Java element exists in the given selection
    • getCurrentTextSelection

      protected org.eclipse.jface.text.ITextSelection getCurrentTextSelection()
      Returns the text selection of the current editor. null is returned when the current editor does not have focus or does not return a text selection.
      Returns:
      Returns the text selection of the current editor or null.
      Since:
      3.0
    • getMaxFieldWidth

      protected int getMaxFieldWidth()
      Returns the recommended maximum width for text fields (in pixels). This method requires that createContent has been called before this method is call. Subclasses may override to change the maximum width for text fields.
      Returns:
      the recommended maximum width for text fields.
    • createContainerControls

      protected void createContainerControls(org.eclipse.swt.widgets.Composite parent, int nColumns)
      Creates the necessary controls (label, text field and browse button) to edit the source folder location. The method expects that the parent composite uses a GridLayout as its layout manager and that the grid layout has at least 3 columns.
      Parameters:
      parent - the parent composite
      nColumns - the number of columns to span. This number must be greater or equal three
    • setFocusOnContainer

      protected void setFocusOnContainer()
      Sets the focus to the source folder's text field.
    • containerChanged

      protected org.eclipse.core.runtime.IStatus containerChanged()
      This method is a hook which gets called after the source folder's text input field has changed. This default implementation updates the model and returns an error status. The underlying model is only valid if the returned status is OK.
      Returns:
      the model's error status
    • handleFieldChanged

      protected void handleFieldChanged(String fieldName)
      Hook method that gets called when a field on this page has changed. For this page the method gets called when the source folder field changes.

      Every sub type is responsible to call this method when a field on its page has changed. Subtypes override (extend) the method to add verification when a own field has a dependency to an other field. For example the class name input must be verified again when the package field changes (check for duplicated class names).

      Parameters:
      fieldName - The name of the field that has changed (field id). For the source folder the field id is CONTAINER
    • getWorkspaceRoot

      protected org.eclipse.core.resources.IWorkspaceRoot getWorkspaceRoot()
      Returns the workspace root.
      Returns:
      the workspace root
    • getJavaProject

      public IJavaProject getJavaProject()
      Returns the Java project of the currently selected package fragment root or null if no package fragment root is configured.
      Returns:
      The current Java project or null.
      Since:
      3.3
    • getPackageFragmentRoot

      public IPackageFragmentRoot getPackageFragmentRoot()
      Returns the IPackageFragmentRoot that corresponds to the current value of the source folder field.
      Returns:
      the IPackageFragmentRoot or null if the current source folder value is not a valid package fragment root
    • getPackageFragmentRootText

      public String getPackageFragmentRootText()
      Returns the current text of source folder text field.
      Returns:
      the text of the source folder text field
    • setPackageFragmentRoot

      public void setPackageFragmentRoot(IPackageFragmentRoot root, boolean canBeModified)
      Sets the current source folder (model and text field) to the given package fragment root.
      Parameters:
      root - The new root.
      canBeModified - if false the source folder field can not be changed by the user. If true the field is editable
    • chooseContainer

      protected IPackageFragmentRoot chooseContainer()
      Opens a selection dialog that allows to select a source container.
      Returns:
      returns the selected package fragment root or null if the dialog has been canceled. The caller typically sets the result to the container input field.

      Clients can override this method if they want to offer a different dialog.

      Since:
      3.2