Class SelectSubclassAndTemplateWizard

  • All Implemented Interfaces:
    org.eclipse.jface.window.IShellProvider, org.eclipse.jface.wizard.IWizard

    public class SelectSubclassAndTemplateWizard
    extends org.eclipse.jface.wizard.Wizard
    Wizard that allows to select an EClass on the first page and a model element on the second page. Thereby, the second page only shows model elements that are an instance of the selected EClass.

    If there is only one possible EClass, the class selection page is skipped and the template selection is shown directly.
    If there is only one template left after selecting the EClass, the template selection page is skipped and the remaining Template counts as selected.

    Author:
    Lucas Koehler
    • Field Summary

      • Fields inherited from class org.eclipse.jface.wizard.Wizard

        DEFAULT_IMAGE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPages()  
      boolean canFinish()  
      protected java.util.Set<Template> getAvailableTemplates​(org.eclipse.emf.ecore.EClass eClass)
      Get all available templates for the given EClass.
      org.eclipse.jface.wizard.IWizardPage getNextPage​(org.eclipse.jface.wizard.IWizardPage page)  
      Optional<Template> getSelectedTemplate()
      Returns the template selected by the user.
      boolean performFinish()  
      protected void setSubClass​(org.eclipse.emf.ecore.EClass subClass)
      Update the selected sub class.
      • Methods inherited from class org.eclipse.jface.wizard.Wizard

        addPage, createPageControls, dispose, getContainer, getDefaultPageImage, getDialogSettings, getPage, getPageCount, getPages, getPreviousPage, getShell, getStartingPage, getTitleBarColor, getWindowTitle, isHelpAvailable, needsPreviousAndNextButtons, needsProgressMonitor, performCancel, setContainer, setDefaultPageImageDescriptor, setDialogSettings, setForcePreviousAndNextButtons, setHelpAvailable, setNeedsProgressMonitor, setTitleBarColor, setWindowTitle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SelectSubclassAndTemplateWizard

        public SelectSubclassAndTemplateWizard​(java.lang.String windowTitle,
                                               java.util.Set<org.eclipse.emf.ecore.EClass> subClasses,
                                               java.util.Set<Template> templates,
                                               EMFFormsLocalizationService localizationService)
        Creates a new instance.
        Parameters:
        windowTitle - The title of the wizard
        subClasses - The EClasses to choose from
        templates - The available templates for all given EClasses
        localizationService - The EMFFormsLocalizationService
    • Method Detail

      • performFinish

        public boolean performFinish()
        Specified by:
        performFinish in interface org.eclipse.jface.wizard.IWizard
        Specified by:
        performFinish in class org.eclipse.jface.wizard.Wizard
      • canFinish

        public boolean canFinish()
        Specified by:
        canFinish in interface org.eclipse.jface.wizard.IWizard
        Overrides:
        canFinish in class org.eclipse.jface.wizard.Wizard
      • getSelectedTemplate

        public Optional<Template> getSelectedTemplate()
        Returns the template selected by the user. If there is only one valid template left after selecting a sub class, this template is selected automatically without showing the second wizard page.
        Returns:
        The selected Template, or the empty Optional if none was selected
      • addPages

        public void addPages()
        Specified by:
        addPages in interface org.eclipse.jface.wizard.IWizard
        Overrides:
        addPages in class org.eclipse.jface.wizard.Wizard
      • getNextPage

        public org.eclipse.jface.wizard.IWizardPage getNextPage​(org.eclipse.jface.wizard.IWizardPage page)
        Specified by:
        getNextPage in interface org.eclipse.jface.wizard.IWizard
        Overrides:
        getNextPage in class org.eclipse.jface.wizard.Wizard
      • setSubClass

        protected void setSubClass​(org.eclipse.emf.ecore.EClass subClass)
        Update the selected sub class. This is typically called by the SelectSubclassAndTemplateWizard.SubClassSelectionPage.
        Parameters:
        subClass - The selected sub class
      • getAvailableTemplates

        protected java.util.Set<Template> getAvailableTemplates​(org.eclipse.emf.ecore.EClass eClass)
        Get all available templates for the given EClass. Thereby, only templates whose instance exactly match the given EClass are returned. This does not include templates for sub classes of the given EClass.
        Parameters:
        eClass - The EClass
        Returns:
        The available templates