diff options
author | Christian W. Damus | 2018-10-29 20:16:55 +0000 |
---|---|---|
committer | Christian W. Damus | 2018-11-05 20:18:35 +0000 |
commit | 6c7e3a6580ef6922d10651e8f8e26a16890546bb (patch) | |
tree | f76985e5aff944a9d67299c14ab2ddce5e68c72f /plugins | |
parent | e7303e65d7fb28a2e4e3593d867bb204efce96ca (diff) | |
download | org.eclipse.papyrus-6c7e3a6580ef6922d10651e8f8e26a16890546bb.tar.gz org.eclipse.papyrus-6c7e3a6580ef6922d10651e8f8e26a16890546bb.tar.xz org.eclipse.papyrus-6c7e3a6580ef6922d10651e8f8e26a16890546bb.zip |
Bug 540584: [New Wizard] Private details block wizard extensibility
Add protected APIs for access to the wizard's selected storage
provider and for customization of the construction of the
representation kinds page.
Change-Id: I94e85b57c5fe68bfec724c145b3c15cf25c5c289
Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
Diffstat (limited to 'plugins')
4 files changed, 232 insertions, 112 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF index 276d9bfe151..7d731493a9c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/META-INF/MANIFEST.MF @@ -25,7 +25,7 @@ Require-Bundle: org.eclipse.m2m.qvt.oml;bundle-version="[3.6.0,4.0.0)";visibilit org.eclipse.papyrus.infra.architecture.representation;bundle-version="[1.0.0,3.0.0)" Bundle-Vendor: %pluginProvider Bundle-ActivationPolicy: lazy -Bundle-Version: 3.1.0.qualifier +Bundle-Version: 3.2.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-Activator: org.eclipse.papyrus.uml.diagram.wizards.Activator diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/pom.xml index d2cac58c7e4..a03d3d890ad 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/pom.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.diagram.wizards</artifactId> - <version>3.1.0-SNAPSHOT</version> + <version>3.2.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRepresentationKindPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRepresentationKindPage.java index 67a0f633ad4..51893f6f441 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRepresentationKindPage.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRepresentationKindPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2017, 2018 Obeo, Christian W. Damus, and others. + * Copyright (c) 2008, 2018 Obeo, Christian W. Damus, and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -11,15 +11,17 @@ * Obeo - initial API and implementation * Tatiana Fesenko(CEA) - improved look&feel * Saadia Dhouib (CEA LIST) - Implementation of loading diagrams from template files (.uml, .di , .notation) - * Christian W. Damus - bug 471453 - * Pauline DEVILLE (CEA LIST) - Bug 493312 - [Wizard] Apply multiple profiles in new model wizard + * Christian W. Damus - bugs 471453, 540584 + * Pauline DEVILLE (CEA LIST) - Bug 493312 - [Wizard] Apply multiple profiles in new model wizard *******************************************************************************/ package org.eclipse.papyrus.uml.diagram.wizards.pages; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; import org.eclipse.core.databinding.observable.value.IObservableValue; @@ -27,6 +29,7 @@ import org.eclipse.core.databinding.observable.value.IValueChangeListener; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; @@ -78,12 +81,18 @@ public class SelectRepresentationKindPage extends WizardPage { private boolean nameTextModified; /** The select template composite. */ - private SelectModelTemplateComposite selectTemplateComposite; + private Optional<SelectModelTemplateComposite> selectTemplateComposite; + /** Whether to show a template composite. */ + private boolean showTemplateChooser = true; /** the select diagram Kind composite */ - private RepresentationKindComposite representationKindComposite; + private Optional<RepresentationKindComposite> representationKindComposite; + /** Whether to show a representation kinds composite. */ + private boolean showRepresentationKinds = true; - private ProfileChooserComposite profileChooserComposite; + private Optional<ProfileChooserComposite> profileChooserComposite; + /** Whether to show a profile chooser composite. */ + private boolean showProfileChooser = true; /** The my context provider. */ private final ContextProvider myContextProvider; @@ -143,40 +152,54 @@ public class SelectRepresentationKindPage extends WizardPage { pageComposite.setLayout(new GridLayout()); pageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - Composite nameFormComposite = new Composite(pageComposite, SWT.NONE); - nameFormComposite.setLayout(new GridLayout()); - nameFormComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - createNameForm(nameFormComposite); + Composite nameFormParent = new Composite(pageComposite, SWT.NONE); + nameFormParent.setLayout(new GridLayout()); + nameFormParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + nameText = createNameForm(nameFormParent); - Composite representationKindComposite = new Composite(pageComposite, SWT.NONE); - representationKindComposite.setLayout(new GridLayout()); - representationKindComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - createPresentationKindForm(representationKindComposite); - - Composite modelTemplateComposite = new Composite(pageComposite, SWT.NONE); - modelTemplateComposite.setLayout(new GridLayout()); - modelTemplateComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - createModelTemplateComposite(modelTemplateComposite); + if (isShowRepresentationKinds()) { + Composite representationKindParent = new Composite(pageComposite, SWT.NONE); + representationKindParent.setLayout(new GridLayout()); + representationKindParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + representationKindComposite = Optional.of(createPresentationKindForm(representationKindParent)); + } else { + representationKindComposite = Optional.empty(); + } - fillInTables(getContexts(), getViewpoints()); + if (isShowTemplateChooser()) { + Composite modelTemplateParent = new Composite(pageComposite, SWT.NONE); + modelTemplateParent.setLayout(new GridLayout()); + modelTemplateParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + selectTemplateComposite = Optional.of(createModelTemplateComposite(modelTemplateParent)); + } else { + selectTemplateComposite = Optional.empty(); + } - Composite profileChooserComposite = new Composite(pageComposite, SWT.NONE); - profileChooserComposite.setLayout(new GridLayout()); - profileChooserComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - createProfileFileChooser(profileChooserComposite); + if (isShowProfileChooser()) { + Composite profileChooserParent = new Composite(pageComposite, SWT.NONE); + profileChooserParent.setLayout(new GridLayout()); + profileChooserParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + profileChooserComposite = Optional.of(createProfileFileChooser(profileChooserParent)); + } else { + profileChooserComposite = Optional.empty(); + } setControl(pageComposite); + + fillInTables(getContexts(), getViewpoints()); } /** - * Create the filechooser composite + * Create the profile chooser composite. * * @param parent + * the parent composite in which to create the profile chooser + * @return the profile chooser, or {@code null} if it is not needed in the host wizard */ - private void createProfileFileChooser(Composite parent) { + private ProfileChooserComposite createProfileFileChooser(Composite parent) { Group group = createGroup(parent, Messages.SelectRepresentationKindPage_0); - profileChooserComposite = new ProfileChooserComposite(group); - profileChooserComposite.getTextField().addModifyListener(new ModifyListener() { + ProfileChooserComposite result = new ProfileChooserComposite(group); + result.getTextField().addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent ev) { @@ -184,34 +207,59 @@ public class SelectRepresentationKindPage extends WizardPage { } }); + return result; + } + + /** + * Queries whether I present the profile chooser controls. By default, I do. + * + * @return whether I show the profile chooser controls + * + * @since 3.2 + */ + public boolean isShowProfileChooser() { + return showProfileChooser; + } + + /** + * Sets whether I present the profile chooser controls. + * + * @param showProfileChooser + * whether I show the profile chooser + * + * @since 3.2 + */ + public void setShowProfileChooser(boolean showProfileChooser) { + this.showProfileChooser = showProfileChooser; } /** - * @deprecated Since 3.1 - * Use getProfilesURI() instead + * @deprecated Since 3.1, use {@link #getProfilesURI()} instead */ + @Deprecated public String getProfileURI() { - return profileChooserComposite.getProfileURI(); + return profileChooserComposite.map(ProfileChooserComposite::getProfileURI).orElse(null); } /** - * Get choose profiles + * Get the chosen profiles. + * * @return the list of selected profiles - * + * * @since 3.1 */ public List<String> getProfilesURI() { - return profileChooserComposite.getProfilesURI(); + return profileChooserComposite.map(ProfileChooserComposite::getProfilesURI).orElse(Collections.emptyList()); } /** - * Check that the provided path matches against a known Profile and that it is defined - * + * Check that the provided path matches against a known Profile and that it is defined. + * * @return * true if the retrieved profile is correctly defined, false otherwise */ public IStatus getProfileDefinitionStatus() { - return profileChooserComposite.getProfileDefinitionStatus(); + return profileChooserComposite.map(ProfileChooserComposite::getProfileDefinitionStatus).orElse(Status.OK_STATUS); } /** @@ -227,17 +275,20 @@ public class SelectRepresentationKindPage extends WizardPage { if (visible) { fillInTables(getContexts(), getViewpoints()); validatePage(); - // Deactivates the viewer if its contained list is empty - Combo templateCombo = selectTemplateComposite.getTemplateCombo(); - if (templateCombo.getItemCount() == 0) { - templateCombo.setEnabled(false); - } else { - templateCombo.setEnabled(true); - } - if (!allowTemplates) { - selectTemplateComposite.disable(); - } + selectTemplateComposite.ifPresent(stc -> { + // Deactivates the viewer if its contained list is empty + Combo templateCombo = stc.getTemplateCombo(); + if (templateCombo.getItemCount() == 0) { + templateCombo.setEnabled(false); + } else { + templateCombo.setEnabled(true); + } + + if (!allowTemplates) { + stc.disable(); + } + }); } } @@ -251,8 +302,8 @@ public class SelectRepresentationKindPage extends WizardPage { if (viewpoints == null || contexts == null) { return; } - representationKindComposite.setInput(viewpoints); - selectTemplateComposite.setInput(contexts); + representationKindComposite.ifPresent(rkc -> rkc.setInput(viewpoints)); + selectTemplateComposite.ifPresent(stc -> stc.setInput(contexts)); } @@ -262,7 +313,7 @@ public class SelectRepresentationKindPage extends WizardPage { * @return the template path */ public String getTemplatePath() { - return selectTemplateComposite.getTemplatePath(); + return selectTemplateComposite.map(SelectModelTemplateComposite::getTemplatePath).orElse(null); } /** @@ -271,7 +322,7 @@ public class SelectRepresentationKindPage extends WizardPage { * @return the notation template path */ public String getNotationTemplatePath() { - return selectTemplateComposite.getNotationTemplatePath(); + return selectTemplateComposite.map(SelectModelTemplateComposite::getNotationTemplatePath).orElse(null); } /** @@ -280,7 +331,7 @@ public class SelectRepresentationKindPage extends WizardPage { * @return the di template path */ public String getDiTemplatePath() { - return selectTemplateComposite.getDiTemplatePath(); + return selectTemplateComposite.map(SelectModelTemplateComposite::getDiTemplatePath).orElse(null); } /** @@ -289,7 +340,7 @@ public class SelectRepresentationKindPage extends WizardPage { * @return the template plugin id */ public String getTemplatePluginId() { - return selectTemplateComposite.getTemplatePluginId(); + return selectTemplateComposite.map(SelectModelTemplateComposite::getTemplatePluginId).orElse(null); } /** @@ -317,7 +368,7 @@ public class SelectRepresentationKindPage extends WizardPage { * @return the new diagram name */ public List<String> getDiagramName() { - return representationKindComposite.getDiagramName(); + return representationKindComposite.map(RepresentationKindComposite::getDiagramName).orElse(Collections.emptyList()); } public String getRootElementName() { @@ -325,12 +376,15 @@ public class SelectRepresentationKindPage extends WizardPage { } /** - * Templates enabled. + * Query whether template selection is enabled. This implies that I + * {@linkplain #isShowTemplateChooser() show the template composite} in the first + * place. Sometimes it is useful to show the template selection but disable it + * for workflows where template selection is conditional. * - * @return true, if successful + * @return whether the application of templates is enabled */ public boolean templatesEnabled() { - return allowTemplates; + return allowTemplates && selectTemplateComposite.isPresent(); } /** @@ -342,13 +396,15 @@ public class SelectRepresentationKindPage extends WizardPage { */ public List<RepresentationKind> getSelectedRepresentationKinds(String contextId) { MergedArchitectureContext context = ArchitectureDomainManager.getInstance().getArchitectureContextById(contextId); - Set<RepresentationKind> allowedKinds = new HashSet<RepresentationKind>(); - for (MergedArchitectureViewpoint viewpoint : context.getViewpoints()) + Set<RepresentationKind> allowedKinds = new HashSet<>(); + for (MergedArchitectureViewpoint viewpoint : context.getViewpoints()) { allowedKinds.addAll(viewpoint.getRepresentationKinds()); - List<RepresentationKind> selectedKinds = new ArrayList<RepresentationKind>(); + } + List<RepresentationKind> selectedKinds = new ArrayList<>(); for (RepresentationKind kind : getSelectedRepresentationKinds()) { - if (allowedKinds.contains(kind)) + if (allowedKinds.contains(kind)) { selectedKinds.add(kind); + } } return selectedKinds; } @@ -356,23 +412,72 @@ public class SelectRepresentationKindPage extends WizardPage { /** * Creates the model template composite. * - * @param composite - * the composite + * @param parent + * the parent composite in which to create the model template composite + * @return the model templates composite, or {@code null} if it is not needed in the host wizard + */ + private SelectModelTemplateComposite createModelTemplateComposite(Composite parent) { + Group group = createGroup(parent, Messages.SelectRepresentationKindPage_load_template_group); + return new SelectModelTemplateComposite(group); + } + + /** + * Queries whether I present the template selection controls. By default, I do. + * + * @return whether I show the template selection controls + * + * @see #templatesEnabled() + * @since 3.2 + */ + public boolean isShowTemplateChooser() { + return showTemplateChooser; + } + + /** + * Sets whether I present the template chooser controls. + * + * @param showTemplateChooser + * whether to show the template chooser controls + * + * @since 3.2 */ - private void createModelTemplateComposite(Composite composite) { - Group group = createGroup(composite, Messages.SelectRepresentationKindPage_load_template_group); - selectTemplateComposite = new SelectModelTemplateComposite(group); + public void setShowTemplateChooser(boolean showTemplateChooser) { + this.showTemplateChooser = showTemplateChooser; } /** * Creates the diagram kind form. * - * @param composite - * the composite + * @param parent + * the parent composite in which to create the diagram kind form + * @return the representation kinds form, or {@code null} if it is not needed in the host wizard */ - private void createPresentationKindForm(Composite composite) { - Group group = createGroup(composite, Messages.SelectRepresentationKindPage_select_kind_group); - representationKindComposite = new RepresentationKindComposite(group); + private RepresentationKindComposite createPresentationKindForm(Composite parent) { + Group group = createGroup(parent, Messages.SelectRepresentationKindPage_select_kind_group); + return new RepresentationKindComposite(group); + } + + /** + * Queries whether I present the representation kinds. By default, I do. + * + * @return whether I show the representation kinds controls + * + * @since 3.2 + */ + public boolean isShowRepresentationKinds() { + return showRepresentationKinds; + } + + /** + * Sets whether I present the representation kinds. + * + * @param showRepresentationKinds + * whether I show the representation kinds controls + * + * @since 3.2 + */ + public void setShowRepresentationKinds(boolean showRepresentationKinds) { + this.showRepresentationKinds = showRepresentationKinds; } /** @@ -409,14 +514,15 @@ public class SelectRepresentationKindPage extends WizardPage { /** * Creates the name form. * - * @param composite - * the composite + * @param parent + * the parent composite in which to create the name form + * @return the name form. It is required, must never be {@code null} */ - private void createNameForm(Composite composite) { - Group group = createGroup(composite, Messages.SelectRepresentationKindPage_diagram_name_group); - nameText = new Text(group, SWT.BORDER); - nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - nameText.setText(getDefaultModelName().getValue()); + private Text createNameForm(Composite parent) { + Group group = createGroup(parent, Messages.SelectRepresentationKindPage_diagram_name_group); + Text result = new Text(group, SWT.BORDER); + result.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + result.setText(getDefaultModelName().getValue()); ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() > 0) { @@ -435,7 +541,9 @@ public class SelectRepresentationKindPage extends WizardPage { modelRoot = resource.getContents().get(0); if (modelRoot instanceof NamedElement) { NamedElement element = (NamedElement) modelRoot; - nameText.setText(element.getName()); + if (element.getName() != null) { + result.setText(element.getName()); + } } else { modelRoot = null; } @@ -448,13 +556,15 @@ public class SelectRepresentationKindPage extends WizardPage { } } - nameText.addModifyListener(new ModifyListener() { + result.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { validatePage(); } }); + + return result; } public static EObject getModelRoot() { @@ -471,7 +581,7 @@ public class SelectRepresentationKindPage extends WizardPage { nameTextModified = true; } - IStatus profileStatus = profileChooserComposite.getProfileDefinitionStatus(); + IStatus profileStatus = getProfileDefinitionStatus(); if (!profileStatus.isOK()) { this.setErrorMessage(profileStatus.getMessage()); return false; @@ -500,7 +610,8 @@ public class SelectRepresentationKindPage extends WizardPage { * @return the selected diagram kind descriptors */ protected RepresentationKind[] getSelectedRepresentationKinds() { - List<RepresentationKind> checked = representationKindComposite.getCheckElement(); + List<RepresentationKind> checked = representationKindComposite.map(RepresentationKindComposite::getCheckElement) + .orElseGet(ArrayList::new); RepresentationKind[] result = checked.toArray(new RepresentationKind[checked.size()]); return result; } @@ -536,7 +647,7 @@ public class SelectRepresentationKindPage extends WizardPage { } public List<ModelTemplateDescription> getTemplateTransfo() { - return selectTemplateComposite.getTemplateTransfoPath(); + return selectTemplateComposite.map(SelectModelTemplateComposite::getTemplateTransfoPath).orElse(Collections.emptyList()); } @Override diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java index 0e4fc215c11..36dd294d013 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/wizards/CreateModelWizard.java @@ -13,9 +13,9 @@ * Saadia Dhouib (CEA LIST) - Implementation of loading diagrams from template files (.uml, .di , .notation) * Christian W. Damus (CEA) - create models by URI, not IFile (CDO) * Christian W. Damus (CEA) - Support creating models in repositories (CDO) - * Christian W. Damus - bugs 490936, 471453 - * Pauline DEVILLE (CEA LIST) - Bug 493312 - [Wizard] Apply multiple profiles in new model wizard - * + * Christian W. Damus - bugs 490936, 471453, 540584 + * Pauline DEVILLE (CEA LIST) - Bug 493312 - [Wizard] Apply multiple profiles in new model wizard + * *******************************************************************************/ package org.eclipse.papyrus.uml.diagram.wizards.wizards; @@ -122,7 +122,7 @@ public class CreateModelWizard extends Wizard implements INewWizard { /** * The select architecture context page. - * + * * @since 3.0 */ protected SelectArchitectureContextPage selectArchitectureContextPage; @@ -134,9 +134,9 @@ public class CreateModelWizard extends Wizard implements INewWizard { private INewModelStorageProvider selectedStorageProvider; - private Map<INewModelStorageProvider, List<IWizardPage>> providerPages = new java.util.HashMap<INewModelStorageProvider, List<IWizardPage>>(); + private Map<INewModelStorageProvider, List<IWizardPage>> providerPages = new java.util.HashMap<>(); - private Map<IWizardPage, INewModelStorageProvider> providersByPage = new java.util.HashMap<IWizardPage, INewModelStorageProvider>(); + private Map<IWizardPage, INewModelStorageProvider> providersByPage = new java.util.HashMap<>(); private int startProviderPageIndex; // index of last page before provider pages @@ -167,8 +167,8 @@ public class CreateModelWizard extends Wizard implements INewWizard { @Override public void addPages() { // ModelCreation: the selectDiagramCategoryPage exists - if (selectedStorageProvider.getArchitectureContextPage() != null) { - addPageIfNotNull(selectedStorageProvider.getArchitectureContextPage()); + if (getSelectedStorageProvider().getArchitectureContextPage() != null) { + addPageIfNotNull(getSelectedStorageProvider().getArchitectureContextPage()); } else { addPageIfNotNull(selectArchitectureContextPage); } @@ -180,12 +180,12 @@ public class CreateModelWizard extends Wizard implements INewWizard { startProviderPageIndex = getPageCount() - 1; for (INewModelStorageProvider next : getStorageProviders()) { - List<IWizardPage> pageList = new java.util.ArrayList<IWizardPage>(3); + List<IWizardPage> pageList = new java.util.ArrayList<>(3); for (IWizardPage page : next.createPages()) { if (page != null) { pageList.add(page); providersByPage.put(page, next); - if (!page.equals(selectedStorageProvider.getArchitectureContextPage())) { + if (!page.equals(getSelectedStorageProvider().getArchitectureContextPage())) { addPage(page); } } @@ -439,7 +439,7 @@ public class CreateModelWizard extends Wizard implements INewWizard { protected String[] getSelectedViewpoints(String contextId) { ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance(); MergedArchitectureContext context = manager.getArchitectureContextById(contextId); - List<String> availableViewpoints = new ArrayList<String>(); + List<String> availableViewpoints = new ArrayList<>(); for (MergedArchitectureViewpoint viewpoint : context.getViewpoints()) { availableViewpoints.add(viewpoint.getId()); } @@ -451,8 +451,8 @@ public class CreateModelWizard extends Wizard implements INewWizard { private SelectArchitectureContextPage getSelectArchitectureContextPage() { return (selectArchitectureContextPage != null) ? selectArchitectureContextPage - : (selectedStorageProvider != null) - ? selectedStorageProvider.getArchitectureContextPage() + : (getSelectedStorageProvider() != null) + ? getSelectedStorageProvider().getArchitectureContextPage() : null; } @@ -620,10 +620,10 @@ public class CreateModelWizard extends Wizard implements INewWizard { CompoundCommand cc = new CompoundCommand(); // Add the main command to create the model from a template cc.append(new InitFromTemplateCommand( - modelSet.getTransactionalEditingDomain(), - modelSet, - selectRepresentationKindPage.getTemplatePluginId(), - selectRepresentationKindPage.getTemplatePath(), + modelSet.getTransactionalEditingDomain(), + modelSet, + selectRepresentationKindPage.getTemplatePluginId(), + selectRepresentationKindPage.getTemplatePath(), selectRepresentationKindPage.getNotationTemplatePath(), selectRepresentationKindPage.getDiTemplatePath())); // Add a command to switch the model to the new context id @@ -855,7 +855,7 @@ public class CreateModelWizard extends Wizard implements INewWizard { // if we are creating a project, then it is in the workspace if (isCreateProjectWizard()) { - this.selectedStorageProvider = new WorkspaceNewModelStorageProvider(); + setSelectedStorageProvider(new WorkspaceNewModelStorageProvider()); } else { // look for a pre-determined selection INewModelStorageProvider firstProvider = null; @@ -867,14 +867,14 @@ public class CreateModelWizard extends Wizard implements INewWizard { // don't match on empty selections because there is // then no context to match against if (!selection.isEmpty() && next.canHandle(selection)) { - this.selectedStorageProvider = next; + setSelectedStorageProvider(next); break; } } // if the choice is pre-determined, don't show the selection page - if (this.selectedStorageProvider == null) { - this.selectedStorageProvider = firstProvider; + if (getSelectedStorageProvider() == null) { + setSelectedStorageProvider(firstProvider); // don't need the selection page if only one choice if (registry.size() > 1) { @@ -906,8 +906,8 @@ public class CreateModelWizard extends Wizard implements INewWizard { if (storageProviderRegistry != null) { result = storageProviderRegistry; - } else if (selectedStorageProvider != null) { - result = Collections.singletonList(selectedStorageProvider); + } else if (getSelectedStorageProvider() != null) { + result = Collections.singletonList(getSelectedStorageProvider()); } else { result = Collections.emptyList(); } @@ -919,11 +919,20 @@ public class CreateModelWizard extends Wizard implements INewWizard { return selectedStorageProvider; } - private void setSelectedStorageProvider(INewModelStorageProvider provider) { + /** + * Set what is the storage {@code provider} selected implicitly or explicitly by the user. + * + * @param provider + * the selected storage provider + * @since 3.2 + */ + protected void setSelectedStorageProvider(INewModelStorageProvider provider) { this.selectedStorageProvider = provider; - // recompute next/previous buttons - getContainer().updateButtons(); + if (getContainer() != null) { + // recompute next/previous buttons + getContainer().updateButtons(); + } } @Override @@ -1013,7 +1022,7 @@ public class CreateModelWizard extends Wizard implements INewWizard { } if (result) { - for (IWizardPage next : providerPages.get(selectedStorageProvider)) { + for (IWizardPage next : providerPages.get(getSelectedStorageProvider())) { if (!next.isPageComplete()) { result = false; break; |