Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AbstractAddFacetChildrenWizard.java175
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetAttributeWizardImpl.java76
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationParameterWizardImpl.java60
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationWizardImpl.java71
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetReferenceWizardImpl.java78
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetInFacetSetWizardImpl.java163
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetSetWizardImpl.java189
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/SelectETypeWizardImpl.java82
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AbstractFacetWizardPage.java786
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddAttributeInFacetWizardPage.java51
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationInFacetWizardPage.java51
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationParameterInFacetWizardPage.java69
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddReferenceInFacetWizardPage.java51
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetInFacetSetWizardPage.java139
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetSetWizardPage.java107
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateQueryWizardPage.java286
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/FacetSetPropertyWizardPage.java106
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEClassifierWizardPage.java114
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEPackageWizardPage.java114
19 files changed, 2768 insertions, 0 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AbstractAddFacetChildrenWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AbstractAddFacetChildrenWizard.java
new file mode 100644
index 00000000000..90434292d19
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AbstractAddFacetChildrenWizard.java
@@ -0,0 +1,175 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ * Grégoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.Facet;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.ui.internal.IQueryCreationPagePartRegistry;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+
+@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
+//@SuppressWarnings("PMD.ConstructorCallsOverridableMethod") This class is
+//deprecated, we won't then spend to many time to conforms to PMD rules.
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public abstract class AbstractAddFacetChildrenWizard extends Wizard implements IFacetChildrenWizard {
+
+ private final ISelection selection;
+ private final EditingDomain editingDomain;
+ private final WizardDialog dialog;
+ private FacetSet facetSet;
+ private Facet facet;
+ private final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage;
+
+ private AbstractFacetWizardPage facetCreationPage;
+ private CreateQueryWizardPage queryCreationPage;
+
+ public AbstractAddFacetChildrenWizard(final ISelection selection, final EditingDomain editingDomain) {
+ this.selection = selection;
+ this.editingDomain = editingDomain;
+ initializeSelection();
+ this.queryTypeNameToQueryCreationPage = IQueryCreationPagePartRegistry.INSTANCE.getRegisteredWizardPageParts();
+ this.dialog = new WizardDialog(getShell(), this);
+ addQueryCreationPage();
+ }
+
+ protected void addQueryCreationPage() {
+ this.queryCreationPage = new CreateQueryWizardPage(this.queryTypeNameToQueryCreationPage, getFacetSet(), this.facet);
+ }
+
+ private void initializeSelection() {
+ if (this.selection != null && !this.selection.isEmpty() && this.selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) this.selection;
+ if (ssel.size() > 1) {
+ return;
+ }
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof FacetSet) {
+ this.facetSet = (FacetSet) obj;
+ } else {
+ if (obj instanceof Facet) {
+ this.facetSet = ((Facet) obj).getFacetSet();
+ this.facet = (Facet) obj;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void addPages() {
+ if (this.facetCreationPage != null) {
+ addPage(this.facetCreationPage);
+ }
+ if (this.queryCreationPage != null) {
+ this.queryCreationPage.canChangeCanBeCached(false);
+ this.queryCreationPage.canChangeHasSideEffect(false);
+ this.queryCreationPage.canChangeLowerBound(false);
+ this.queryCreationPage.canChangeUpperBound(false);
+ this.queryCreationPage.canChangeQueryName(false);
+ this.queryCreationPage.setFacetSet(getFacetSet());
+ addPage(this.queryCreationPage);
+ }
+ }
+
+ @Override
+ public boolean canFinish() {
+ return getContainer().getCurrentPage() == this.queryCreationPage && this.queryCreationPage.isPageComplete();
+ }
+
+ public int open() {
+ if (this.dialog != null) {
+ return this.dialog.open();
+ }
+ return Window.CANCEL;
+ }
+
+ public void setFacet(final Facet facet) {
+ this.facetCreationPage.setFacet(facet);
+ }
+
+ public void setChildrenName(final String referenceName) {
+ this.facetCreationPage.setChildrenName(referenceName);
+ }
+
+ public void setUpperBound(final int upperBound) {
+ this.facetCreationPage.setUpperBound(upperBound);
+ }
+
+ public void setLowerBound(final int lowerBound) {
+ this.facetCreationPage.setLowerBound(lowerBound);
+ }
+
+ public void setType(final EClass type) {
+ this.facetCreationPage.setType(type);
+ }
+
+ public void canChangeFacet(final boolean canChange) {
+ this.facetCreationPage.canChangeParentName(canChange);
+ }
+
+ public void canChangeChildrenName(final boolean canChange) {
+ this.facetCreationPage.canChangeChildrenName(canChange);
+ }
+
+ public void canChangeUpperBound(final boolean canChange) {
+ this.facetCreationPage.canChangeUpperBound(canChange);
+ }
+
+ public void canChangeLowerBound(final boolean canChange) {
+ this.facetCreationPage.canChangeLowerBound(canChange);
+ }
+
+ public void canChangeType(final boolean canChange) {
+ this.facetCreationPage.canChangeType(canChange);
+ }
+
+ public EditingDomain getEditingDomain() {
+ return this.editingDomain;
+ }
+
+ protected final FacetSet getFacetSet() {
+ return this.facetSet;
+ }
+
+ protected final CreateQueryWizardPage getQueryCreationPage() {
+ return this.queryCreationPage;
+ }
+
+ protected void setFacetCreationPage(final AbstractFacetWizardPage facetCreationPage) {
+ this.facetCreationPage = facetCreationPage;
+ }
+
+ protected ISelection getSelection() {
+ return this.selection;
+ }
+
+ protected Map<String, IQueryCreationPagePart> getQueryTypeNameToQueryCreationPage() {
+ return this.queryTypeNameToQueryCreationPage;
+ }
+
+ protected AbstractFacetWizardPage getFacetCreationPage() {
+ return this.facetCreationPage;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetAttributeWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetAttributeWizardImpl.java
new file mode 100644
index 00000000000..053a76c311d
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetAttributeWizardImpl.java
@@ -0,0 +1,76 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.EFacetFactory;
+import org.eclipse.emf.facet.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.core.IFacetAction;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AddAttributeInFacetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
+import org.eclipse.jface.viewers.ISelection;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class AddFacetAttributeWizardImpl extends AbstractAddFacetChildrenWizard {
+
+ public AddFacetAttributeWizardImpl(final ISelection selection, final EditingDomain editingDomain) {
+ super(selection, editingDomain);
+ setWindowTitle(Messages.Add_an_Attribute);
+ setFacetCreationPage(new AddAttributeInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage()));
+ }
+
+ @Override
+ public boolean performFinish() {
+ Query query = null;
+ AbstractFacetWizardPage facetPage = getFacetCreationPage();
+
+ if (facetPage.isSubTypingFacet()) {
+ CreateQueryWizardPage queryPage = getQueryCreationPage();
+
+ IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage();
+ iQueryPage.setCanBeCached(queryPage.getCanBeCached());
+ iQueryPage.setHasSideEffect(queryPage.getHasSideEffect());
+ iQueryPage.setQueryName(queryPage.getQueryName());
+ iQueryPage.setLowerBound(queryPage.getLowerBound());
+ iQueryPage.setUpperBound(queryPage.getUpperBound());
+ iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass());
+ iQueryPage.setQueryType(facetPage.getType());
+
+ iQueryPage.setUnique(facetPage.isUnique());
+ iQueryPage.setOrdered(facetPage.isOrdered());
+
+ query = iQueryPage.performFinish();
+ }
+
+ FacetAttribute facetAttribute = EFacetFactory.eINSTANCE.createFacetAttribute();
+ facetAttribute.setName(facetPage.getChildrenName());
+ facetAttribute.setEType(facetPage.getType());
+ facetAttribute.setQuery(query);
+ facetAttribute.setLowerBound(facetPage.getLowerBound());
+ facetAttribute.setUpperBound(facetPage.getUpperBound());
+
+ facetAttribute.setUnique(facetPage.isUnique());
+ facetAttribute.setOrdered(facetPage.isOrdered());
+ facetAttribute.setTransient(facetPage.isTransient());
+ facetAttribute.setChangeable(facetPage.isChangeable());
+ facetAttribute.setDerived(facetPage.isDerived());
+ facetAttribute.setVolatile(facetPage.isVolatile());
+
+ IFacetAction.INSTANCE.addAttributeInFacet(facetPage.getFacet(), facetAttribute, getEditingDomain());
+ return true;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationParameterWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationParameterWizardImpl.java
new file mode 100644
index 00000000000..f18d19c7c13
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationParameterWizardImpl.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards;
+
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.core.IFacetAction;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AddOperationParameterInFacetWizardPage;
+import org.eclipse.jface.viewers.ISelection;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class AddFacetOperationParameterWizardImpl extends AbstractAddFacetChildrenWizard {
+
+ public AddFacetOperationParameterWizardImpl(final ISelection selection, final EditingDomain editingDomain) {
+ super(selection, editingDomain);
+ setFacetCreationPage(new AddOperationParameterInFacetWizardPage(getSelection(), getEditingDomain()));
+ setWindowTitle(Messages.Add_an_Operation_Parameter);
+ }
+
+ @Override
+ protected void addQueryCreationPage() {
+ // We do not want to create a query for the operation's parameter
+ }
+
+ @Override
+ public boolean canFinish() {
+ return getFacetCreationPage().isPageComplete();
+ }
+
+ @Override
+ public boolean performFinish() {
+ AbstractFacetWizardPage page = getFacetCreationPage();
+ FacetOperation facetOperation = (FacetOperation) page.getQueryFacetElement();
+
+ EParameter parameter = EcoreFactory.eINSTANCE.createEParameter();
+ parameter.setName(page.getChildrenName());
+ parameter.setEType(page.getType());
+ parameter.setLowerBound(page.getLowerBound());
+ parameter.setUpperBound(page.getUpperBound());
+ parameter.setUnique(page.isUnique());
+ parameter.setOrdered(page.isOrdered());
+
+ IFacetAction.INSTANCE.addParameterInOperation(facetOperation, parameter, getEditingDomain());
+ return true;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationWizardImpl.java
new file mode 100644
index 00000000000..4473439cad6
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationWizardImpl.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.EFacetFactory;
+import org.eclipse.emf.facet.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.core.IFacetAction;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AddOperationInFacetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
+import org.eclipse.jface.viewers.ISelection;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class AddFacetOperationWizardImpl extends AbstractAddFacetChildrenWizard {
+
+ public AddFacetOperationWizardImpl(final ISelection selection, final EditingDomain editingDomain) {
+ super(selection, editingDomain);
+ setWindowTitle(Messages.Add_an_Operation);
+ setFacetCreationPage(new AddOperationInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage()));
+ }
+
+ @Override
+ public boolean performFinish() {
+ Query conformanceQuery = null;
+ AbstractFacetWizardPage facetPage = getFacetCreationPage();
+
+ if (facetPage.isSubTypingFacet()) {
+ CreateQueryWizardPage queryPage = getQueryCreationPage();
+
+ IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage();
+ iQueryPage.setCanBeCached(queryPage.getCanBeCached());
+ iQueryPage.setHasSideEffect(queryPage.getHasSideEffect());
+ iQueryPage.setQueryName(queryPage.getQueryName());
+ iQueryPage.setLowerBound(queryPage.getLowerBound());
+ iQueryPage.setUpperBound(queryPage.getUpperBound());
+ iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass());
+ iQueryPage.setQueryType(facetPage.getType());
+
+ iQueryPage.setUnique(facetPage.isUnique());
+ iQueryPage.setOrdered(facetPage.isOrdered());
+
+ conformanceQuery = iQueryPage.performFinish();
+ }
+
+ FacetOperation facetOperation = EFacetFactory.eINSTANCE.createFacetOperation();
+ facetOperation.setName(facetPage.getChildrenName());
+ facetOperation.setEType(facetPage.getType());
+ facetOperation.setQuery(conformanceQuery);
+ facetOperation.setLowerBound(facetPage.getLowerBound());
+ facetOperation.setUpperBound(facetPage.getUpperBound());
+ facetOperation.setUnique(facetPage.isUnique());
+ facetOperation.setOrdered(facetPage.isOrdered());
+
+ IFacetAction.INSTANCE.addOperationInFacet(facetPage.getFacet(), facetOperation, getEditingDomain());
+ return true;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetReferenceWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetReferenceWizardImpl.java
new file mode 100644
index 00000000000..e217fce8f4e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetReferenceWizardImpl.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.EFacetFactory;
+import org.eclipse.emf.facet.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.core.IFacetAction;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.AddReferenceInFacetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
+import org.eclipse.jface.viewers.ISelection;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class AddFacetReferenceWizardImpl extends AbstractAddFacetChildrenWizard {
+
+ public AddFacetReferenceWizardImpl(final ISelection selection, final EditingDomain editingDomain) {
+ super(selection, editingDomain);
+ setWindowTitle(Messages.Add_a_Reference);
+
+ setFacetCreationPage(new AddReferenceInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage()));
+ }
+
+ @Override
+ public boolean performFinish() {
+ Query conformanceQuery = null;
+ AbstractFacetWizardPage facetPage = getFacetCreationPage();
+
+ if (facetPage.isSubTypingFacet()) {
+ CreateQueryWizardPage queryPage = getQueryCreationPage();
+
+ IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage();
+ iQueryPage.setCanBeCached(queryPage.getCanBeCached());
+ iQueryPage.setHasSideEffect(queryPage.getHasSideEffect());
+ iQueryPage.setQueryName(queryPage.getQueryName());
+ iQueryPage.setLowerBound(queryPage.getLowerBound());
+ iQueryPage.setUpperBound(queryPage.getUpperBound());
+ iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass());
+ iQueryPage.setQueryType(facetPage.getType());
+
+ iQueryPage.setUnique(facetPage.isUnique());
+ iQueryPage.setOrdered(facetPage.isOrdered());
+
+ conformanceQuery = iQueryPage.performFinish();
+ }
+
+ FacetReference facetReference = EFacetFactory.eINSTANCE.createFacetReference();
+ facetReference.setName(facetPage.getChildrenName());
+ facetReference.setEType(facetPage.getType());
+ facetReference.setQuery(conformanceQuery);
+ facetReference.setLowerBound(facetPage.getLowerBound());
+ facetReference.setUpperBound(facetPage.getUpperBound());
+
+ facetReference.setUnique(facetPage.isUnique());
+ facetReference.setOrdered(facetPage.isOrdered());
+ facetReference.setTransient(facetPage.isTransient());
+ facetReference.setChangeable(facetPage.isChangeable());
+ facetReference.setDerived(facetPage.isDerived());
+ facetReference.setVolatile(facetPage.isVolatile());
+
+ IFacetAction.INSTANCE.addReferenceInFacet(facetPage.getFacet(), facetReference, getEditingDomain());
+ return true;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetInFacetSetWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetInFacetSetWizardImpl.java
new file mode 100644
index 00000000000..329e470e659
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetInFacetSetWizardImpl.java
@@ -0,0 +1,163 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.EFacetFactory;
+import org.eclipse.emf.facet.efacet.Facet;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.Query;
+import org.eclipse.emf.facet.efacet.core.IFacetAction;
+import org.eclipse.emf.facet.efacet.ui.internal.IQueryCreationPagePartRegistry;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.CreateFacetInFacetSetWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class CreateFacetInFacetSetWizardImpl extends Wizard implements ICreateFacetInFacetSetWizard {
+
+ private WizardDialog dialog = null;
+ private final CreateFacetInFacetSetWizardPage facetCreationPage;
+ private final CreateQueryWizardPage queryCreationPage;
+
+ private final ISelection selection;
+ private final EditingDomain editingDomain;
+
+ private FacetSet facetSet;
+ private boolean canChangeFacetSet;
+
+ private final Facet facet;
+
+ private boolean canChangeExtendedMetaClass = true;
+
+ private final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage;
+
+ public CreateFacetInFacetSetWizardImpl(final ISelection selection2, final EditingDomain editingDomain2) {
+ super();
+ this.facet = EFacetFactory.eINSTANCE.createFacet();
+ setWindowTitle(Messages.Create_facet_in_facetSet);
+ this.selection = selection2;
+ initializeSelection();
+ this.editingDomain = editingDomain2;
+
+ this.queryTypeNameToQueryCreationPage = IQueryCreationPagePartRegistry.INSTANCE.getRegisteredWizardPageParts();
+
+ this.dialog = new WizardDialog(getShell(), this);
+
+ this.facetCreationPage = new CreateFacetInFacetSetWizardPage(this.facet, this.selection, this.editingDomain,
+ this.queryTypeNameToQueryCreationPage);
+
+ this.queryCreationPage = new CreateQueryWizardPage(this.queryTypeNameToQueryCreationPage, this.facetSet, this.facet);
+
+ }
+
+ private void initializeSelection() {
+ if (this.selection != null && !this.selection.isEmpty() && this.selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) this.selection;
+ if (ssel.size() > 1) {
+ return;
+ }
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof FacetSet) {
+ this.facetSet = (FacetSet) obj;
+ }
+ }
+ }
+
+ @Override
+ public void addPages() {
+ this.facetCreationPage.setFacetSet(this.facetSet);
+ this.facetCreationPage.canChangeParentName(this.canChangeFacetSet);
+ this.facetCreationPage.setExtendedMetaClass(this.facet.getExtendedMetaclass());
+ this.facetCreationPage.canChangeExtendedMetaClass(this.canChangeExtendedMetaClass);
+ addPage(this.facetCreationPage);
+
+ this.queryCreationPage.canChangeCanBeCached(false);
+ this.queryCreationPage.canChangeHasSideEffect(false);
+ this.queryCreationPage.canChangeLowerBound(false);
+ this.queryCreationPage.canChangeUpperBound(false);
+ this.queryCreationPage.canChangeQueryName(false);
+ this.queryCreationPage.setFacetSet(this.facetSet);
+ addPage(this.queryCreationPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ if (getContainer().getCurrentPage() == this.facetCreationPage && !this.facetCreationPage.isSubTypingFacet()
+ && this.facetCreationPage.isPageComplete()) {
+ return true;
+ }
+ return getContainer().getCurrentPage() == this.queryCreationPage && getContainer().getCurrentPage().isPageComplete();
+ }
+
+ public int open() {
+ if (this.dialog != null) {
+ return this.dialog.open();
+ }
+ return Window.CANCEL;
+ }
+
+ @Override
+ public boolean performFinish() {
+ final String facetName = this.facetCreationPage.getChildrenName();
+ Query conformanceQuery = null;
+ if (this.facetCreationPage.isSubTypingFacet()) {
+ IQueryCreationPagePart iQueryPage = this.queryCreationPage.getQueryCreationPage();
+ iQueryPage.setCanBeCached(this.queryCreationPage.getCanBeCached());
+ iQueryPage.setHasSideEffect(this.queryCreationPage.getHasSideEffect());
+ iQueryPage.setQueryName(this.queryCreationPage.getQueryName());
+ iQueryPage.setLowerBound(this.queryCreationPage.getLowerBound());
+ iQueryPage.setUpperBound(this.queryCreationPage.getUpperBound());
+ iQueryPage.setQueryScope(this.facetCreationPage.getExtendedMetaclass());
+ iQueryPage.setQueryType(EcorePackage.eINSTANCE.getEBoolean());
+ conformanceQuery = iQueryPage.performFinish();
+ }
+
+ this.facet.setName(facetName);
+ this.facet.setExtendedMetaclass(this.facetCreationPage.getExtendedMetaclass());
+ this.facet.setConformanceQuery(conformanceQuery);
+
+ IFacetAction.INSTANCE.createFacetInFacetSet(this.facetCreationPage.getFacetSet(), this.facet, this.editingDomain);
+ return true;
+ }
+
+ public void setFacetSet(final FacetSet facetSet2) {
+ this.facetSet = facetSet2;
+ this.queryCreationPage.setFacetSet(facetSet2);
+ }
+
+ public void canChangeFacetSet(final boolean canChange) {
+ this.canChangeFacetSet = canChange;
+
+ }
+
+ public void setExtendedMetaClass(final EClass extendedMetaClass) {
+ this.facet.setExtendedMetaclass(extendedMetaClass);
+
+ }
+
+ public void canChangeExtendedMetaClass(final boolean canChange) {
+ this.canChangeExtendedMetaClass = canChange;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetSetWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetSetWizardImpl.java
new file mode 100644
index 00000000000..9adcd0b763c
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetSetWizardImpl.java
@@ -0,0 +1,189 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.facet.efacet.EFacetPackage;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.core.IFacetAction;
+import org.eclipse.emf.facet.efacet.ui.internal.Activator;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard;
+import org.eclipse.emf.facet.efacet.ui.internal.utils.ImageProvider;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.FacetSetPropertyWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.CreateFacetSetWizardPage;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class CreateFacetSetWizardImpl extends Wizard implements INewWizard, ICreateFacetSetWizard {
+
+ public static final String FILE_EXTENSION = "efacet"; //$NON-NLS-1$
+
+ private final CreateFacetSetWizardPage newFileCreationPage;
+ private final FacetSetPropertyWizardPage facetSetPropertyWizardPage;
+
+ private IStructuredSelection selection;
+
+ private IWorkbench workbench;
+
+ private final WizardDialog dialog;
+
+ private boolean openCreatedFacet = true;
+
+ public CreateFacetSetWizardImpl() {
+ this(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection());
+ }
+
+ public CreateFacetSetWizardImpl(final ISelection selection2, final boolean openCreatedFacetSet) {
+ this(selection2);
+ this.openCreatedFacet = openCreatedFacetSet;
+ }
+
+ public CreateFacetSetWizardImpl(final ISelection selection2) {
+ super();
+ this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), this);
+ if (selection2 != null && selection2 instanceof IStructuredSelection) {
+ this.selection = (IStructuredSelection) selection2;
+ }
+ setWindowTitle(Messages.Create_FacetSet_Model);
+ ImageProvider.getInstance();
+ setDefaultPageImageDescriptor(ImageProvider.getFacetIconDescriptor());
+
+ this.newFileCreationPage = new CreateFacetSetWizardPage("Whatever", this.selection); //$NON-NLS-1$
+
+ this.facetSetPropertyWizardPage = new FacetSetPropertyWizardPage(null);
+ }
+
+ public void init(final IWorkbench workbench2, final IStructuredSelection selection2) {
+ this.workbench = workbench2;
+ this.selection = selection2;
+ }
+
+ protected FacetSet createInitialFacet() {
+ FacetSet facetSet = EFacetPackage.eINSTANCE.getEFacetFactory().createFacetSet();
+ String modelFacetSetName = getModelFile().getName().replaceAll(".facetSet$", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ facetSet.setName(modelFacetSetName);
+ facetSet.setNsURI(this.facetSetPropertyWizardPage.getNsUri());
+ facetSet.setNsPrefix(this.facetSetPropertyWizardPage.getPrefix());
+ facetSet.setExtendedEPackage(this.facetSetPropertyWizardPage.getFirstSelectedEPackage());
+ return facetSet;
+ }
+
+ @Override
+ public boolean performFinish() {
+ if (this.facetSetPropertyWizardPage.isPageComplete()) {
+ try {
+ // Remember the file.
+ //
+ final IFile modelFile = getModelFile();
+
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(final IProgressMonitor progressMonitor) {
+ try {
+ FacetSet facetSet = createInitialFacet();
+ IFacetAction.INSTANCE.createFacetSet(facetSet, modelFile);
+ } catch (Exception exception) {
+ Logger.logError(exception, Activator.getDefault());
+ } finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ if (this.openCreatedFacet) {
+ // Select the new file resource in the current view.
+ if (this.workbench == null) {
+ this.workbench = PlatformUI.getWorkbench();
+ }
+ IWorkbenchWindow workbenchWindow = this.workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ final IWorkbenchPart activePart = page.getActivePart();
+ if (activePart instanceof ISetSelectionTarget) {
+ final ISelection targetSelection = new StructuredSelection(modelFile);
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
+ }
+ });
+ }
+
+ // Open an editor on the new file.
+ //
+ try {
+ page.openEditor(new FileEditorInput(modelFile),
+ this.workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
+ } catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(), "Open Editor", exception.getMessage()); //$NON-NLS-1$
+ return false;
+ }
+ }
+
+ return true;
+ } catch (Exception exception) {
+ Logger.logError(exception, Activator.getDefault());
+ return false;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean canFinish() {
+ return getContainer().getCurrentPage() == this.facetSetPropertyWizardPage && this.facetSetPropertyWizardPage.isPageComplete();
+ }
+
+ @Override
+ public boolean isHelpAvailable() {
+ return false;
+ }
+
+ @Override
+ public void addPages() {
+ addPage(this.newFileCreationPage);
+ addPage(this.facetSetPropertyWizardPage);
+ }
+
+ public IFile getModelFile() {
+ return this.newFileCreationPage.getModelFile();
+ }
+
+ public int open() {
+ if (this.dialog != null) {
+ return this.dialog.open();
+ }
+ return Window.CANCEL;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/SelectETypeWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/SelectETypeWizardImpl.java
new file mode 100644
index 00000000000..6c1b4a3d57b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/SelectETypeWizardImpl.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.ISelectETypeWizard;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.SelectEClassifierWizardPage;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.pages.SelectEPackageWizardPage;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.PlatformUI;
+
+public class SelectETypeWizardImpl extends Wizard implements ISelectETypeWizard {
+
+ private final WizardDialog dialog;
+
+ private final SelectEPackageWizardPage selectEPackagePage;
+ private final SelectEClassifierWizardPage selectETypePage;
+
+ private final EditingDomain editingDomain;
+
+ private EClassifier selectedEType;
+
+ private boolean canChangeEPackage = true;
+
+ public SelectETypeWizardImpl(final EditingDomain editingDomain, final ETypeSelectionOptions eTypeSelectionOption,
+ final boolean canChangeEPackage, final EPackage ePackage) {
+ super();
+ this.editingDomain = editingDomain;
+ this.canChangeEPackage = canChangeEPackage;
+ this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), this);
+ this.selectEPackagePage = new SelectEPackageWizardPage(this.editingDomain);
+ this.selectETypePage = new SelectEClassifierWizardPage(eTypeSelectionOption, ePackage);
+ if (eTypeSelectionOption == ETypeSelectionOptions.ECLASS) {
+ setWindowTitle(Messages.Select_EClass);
+ } else if (eTypeSelectionOption == ETypeSelectionOptions.EDATATYPE) {
+ setWindowTitle(Messages.Select_EDataType);
+ } else {
+ setWindowTitle(Messages.Select_EClassifier);
+ }
+ }
+
+ @Override
+ public void addPages() {
+ if (this.canChangeEPackage) {
+ addPage(this.selectEPackagePage);
+ }
+ addPage(this.selectETypePage);
+ }
+
+ public int open() {
+ if (this.dialog != null) {
+ return this.dialog.open();
+ }
+ return Window.CANCEL;
+ }
+
+ @Override
+ public boolean performFinish() {
+ this.selectedEType = this.selectETypePage.getSelectedEclassifier();
+ return true;
+ }
+
+ public EClassifier getSelectedEType() {
+ return this.selectedEType;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AbstractFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AbstractFacetWizardPage.java
new file mode 100644
index 00000000000..ba575ff9db2
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AbstractFacetWizardPage.java
@@ -0,0 +1,786 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.Facet;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.QueryFacetElement;
+import org.eclipse.emf.facet.efacet.ui.internal.Activator;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectETypeComposite;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectQueryTypeComposite;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.widgets.celleditors.AbstractCellEditorComposite;
+import org.eclipse.emf.facet.widgets.celleditors.ICompositeEditorFactory;
+import org.eclipse.emf.facet.widgets.celleditors.core.composite.registries.ICompositeEditorFactoriesRegistry;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
+// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") This class is
+// deprecated, we won't then spend to many time to conforms to PMD rules.
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public abstract class AbstractFacetWizardPage extends WizardPage {
+
+ private static final int QUERY_SELECTION_GROUP_COLUMN_NUMBER = 4;
+ private static final int NUMBER_COLUMN_PROPERTY = 3;
+ protected static final int NUMBER_COLUMN = 3;
+ protected static final int VERTICAL_SPACING = 9;
+
+ private ISelection selection;
+ private EditingDomain editingDomain;
+
+ // USER PERMISSION
+ private boolean canChangeParentName = true;
+ private boolean canChangeChildrenName = true;
+ private boolean canChangeUpperBound = true;
+ private boolean canChangeLowerBound = true;
+ private boolean canChangeType = true;
+ private final boolean canChangeVolatile = false;
+ private final boolean canChangeChangeable = false;
+ private final boolean canChangeDerived = false;
+ private final boolean canChangeTransient = false;
+ private final boolean canChangeOrdered = true;
+ private final boolean canChangeUnique = true;
+ private boolean canChangeEPackage = true;
+
+ private boolean showUpperBound = true;
+ private boolean showLowerBound = true;
+ private boolean showParentName = true;
+ private boolean showChildrenName = true;
+ private boolean showQueryTypeSelection = true;
+ private boolean showEType = true;
+ private boolean showVolatile = true;
+ private boolean showChangeable = true;
+ private boolean showDerived = true;
+ private boolean showTransient = true;
+ private boolean showOrdered = true;
+ private boolean showUnique = true;
+
+ // DATA
+ private FacetSet facetSet;
+ private Facet facet;
+ private String facetName;
+ private QueryFacetElement queryFacetElement;
+ private EClass type;
+ private String parentName = ""; //$NON-NLS-1$
+ private String childrenName = ""; //$NON-NLS-1$
+ private int lowerBound;
+ private int upperBound;
+ private boolean fVolatile = true;
+ private boolean fChangeable = false;
+ private boolean fDerived = true;
+ private boolean fTransient = true;
+ private boolean fOrdered = false;
+ private boolean fUnique = false;
+
+ // COMPOSITE
+ private Label parentNameLabel;
+ private Label childrenNameLabel;
+ private Label lowerBoundLabel;
+ private Label upperBoundLabel;
+ private SelectETypeComposite selectETypeComposite;
+ private Text parentNameTextField;
+ private Text childrenNameTextField;
+ private AbstractCellEditorComposite<Integer> lowerBoundTextField;
+ private AbstractCellEditorComposite<Integer> upperBoundTextField;
+ private SelectQueryTypeComposite selectQueryTypeComposite;
+ private Button subClassingQueryButton;
+
+ private Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage;
+ private boolean wizardNeedsQuery = true;
+ private ETypeSelectionOptions eTypeSelectionOption;
+
+ public AbstractFacetWizardPage(final ISelection selection, final EditingDomain editingDomain,
+ final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage,
+ final ETypeSelectionOptions eTypeSelectionOption) {
+ this(selection, editingDomain);
+ this.queryTypeNameToWizardPage = queryTypeNameToWizardPage;
+ this.eTypeSelectionOption = eTypeSelectionOption;
+ }
+
+ public AbstractFacetWizardPage(final ISelection selection, final EditingDomain editingDomain) {
+ super("whatever"); //$NON-NLS-1$
+ this.selection = selection;
+ this.editingDomain = editingDomain;
+ initializeWithSelection();
+ }
+
+ @Override
+ public void setVisible(final boolean visible) {
+ updatePageButtons();
+ super.setVisible(visible);
+ }
+
+ protected Composite createControlParts(final Composite parent) {
+
+ final Composite threeColumnContainer = new Composite(parent, SWT.NONE);
+ GridLayout layout3Column = new GridLayout(AbstractFacetWizardPage.NUMBER_COLUMN, false);
+ threeColumnContainer.setLayout(layout3Column);
+ GridData fillGridData = new GridData(GridData.FILL_HORIZONTAL);
+
+ threeColumnContainer.setLayoutData(fillGridData);
+
+ if (this.showParentName) {
+ this.parentNameLabel = new Label(threeColumnContainer, SWT.NONE);
+ this.parentNameTextField = new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE);
+ this.parentNameTextField.setText(this.parentName);
+ this.parentNameTextField.setEnabled(this.canChangeParentName);
+ this.parentNameTextField.setLayoutData(fillGridData);
+ this.parentNameTextField.addModifyListener(new ModifyListener() {
+ public void modifyText(final ModifyEvent e) {
+ setParentName(((Text) e.getSource()).getText(), false);
+ updatePageButtons();
+ }
+ });
+ Label dummyLabel = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel.setText(""); //$NON-NLS-1$
+ }
+
+ if (this.showChildrenName) {
+ this.childrenNameLabel = new Label(threeColumnContainer, SWT.NONE);
+ this.childrenNameTextField = new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE);
+ this.childrenNameTextField.setText(this.childrenName);
+ this.childrenNameTextField.setEnabled(canChangeChildrenName());
+ this.childrenNameTextField.setLayoutData(fillGridData);
+ this.childrenNameTextField.addModifyListener(new ModifyListener() {
+ public void modifyText(final ModifyEvent e) {
+ setChildrenName(((Text) e.getSource()).getText());
+ updatePageButtons();
+ }
+ });
+ Label dummyLabel2 = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel2.setText(""); //$NON-NLS-1$
+ }
+ ICompositeEditorFactory<Integer> compositeFactory = ICompositeEditorFactoriesRegistry.INSTANCE
+ .getCompositeEditorFactory(Integer.class);
+ if (this.showLowerBound) {
+ this.lowerBoundLabel = new Label(threeColumnContainer, SWT.NONE);
+ this.lowerBoundTextField = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER
+ | SWT.SINGLE);
+ this.lowerBoundTextField.setLayoutData(fillGridData);
+ this.lowerBoundTextField.setEnabled(canChangeLowerBound());
+ setLowerBound(this.lowerBound);
+ Label dummyLabel5 = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel5.setText(""); //$NON-NLS-1$
+ }
+ if (this.showUpperBound) {
+ this.upperBoundLabel = new Label(threeColumnContainer, SWT.NONE);
+ this.upperBoundTextField = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER
+ | SWT.SINGLE);
+ this.upperBoundTextField.setLayoutData(fillGridData);
+ this.upperBoundTextField.setEnabled(this.canChangeUpperBound);
+ setUpperBound(this.upperBound);
+ Label dummyLabel6 = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel6.setText(""); //$NON-NLS-1$
+ }
+ if (this.showEType) {
+ this.selectETypeComposite = new SelectETypeComposite(parent, SWT.NONE, this.eTypeSelectionOption,
+ this.canChangeEPackage, this.facetSet) {
+ @Override
+ protected void createCompositeWidget() {
+ setETypeLabel(new Label(threeColumnContainer, SWT.NULL));
+ setETypedTextField(new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY));
+ setSelectButton(new Button(threeColumnContainer, SWT.PUSH));
+ }
+
+ @Override
+ protected void eTypeSelected() {
+ updatePageButtons();
+ }
+ };
+ if (this.type != null) {
+ this.selectETypeComposite.setEType(this.type);
+ }
+ this.selectETypeComposite.setEditingDomain(getEditingDomain());
+ this.selectETypeComposite.canChangeEType(this.canChangeType);
+ }
+
+ createPropertyControls(threeColumnContainer);
+
+ if (this.wizardNeedsQuery) {
+ createQueryComposite(parent, threeColumnContainer);
+ }
+ return threeColumnContainer;
+ }
+
+ /**
+ * @param parent
+ * @param threeColumnContainer
+ */
+ protected void createQueryComposite(final Composite parent, final Composite threeColumnContainer) {
+ if (this.showQueryTypeSelection) {
+ final Group group = new Group(threeColumnContainer, SWT.SHADOW_ETCHED_OUT);
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, AbstractFacetWizardPage.NUMBER_COLUMN, 1));
+ group.setLayout(new GridLayout(AbstractFacetWizardPage.QUERY_SELECTION_GROUP_COLUMN_NUMBER, false));
+ Label subClassingQueryButtonText = new Label(group, SWT.NONE);
+ subClassingQueryButtonText.setText(Messages.CreateFacetInFacetSetWizardPage_Sub_Typing_Facet);
+
+ this.subClassingQueryButton = new Button(group, SWT.CHECK);
+ this.subClassingQueryButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.subClassingQueryButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ setQueryTypeSelectionVisible(getSubClassingQueryButton().getSelection());
+ updatePageButtons();
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // nothing
+ }
+ });
+
+ // Query Type Composite
+ this.selectQueryTypeComposite = new SelectQueryTypeComposite(parent, SWT.NONE) {
+ @Override
+ protected void createCompositeWidget() {
+ setQueryTypeLabel(new Label(group, SWT.NONE));
+ setQueryTypeComboBox(new Combo(group, SWT.DROP_DOWN));
+ }
+
+ @Override
+ protected void queryTypeSelected() {
+ updatePageButtons();
+ }
+ };
+
+ setQueryTypeSelectionVisible(false);
+ } else {
+ // Query Type Composite
+ this.selectQueryTypeComposite = new SelectQueryTypeComposite(parent, SWT.NONE) {
+ @Override
+ protected void createCompositeWidget() {
+ setQueryTypeLabel(new Label(threeColumnContainer, SWT.NONE));
+ setQueryTypeComboBox(new Combo(threeColumnContainer, SWT.DROP_DOWN | SWT.READ_ONLY));
+ }
+
+ @Override
+ protected void queryTypeSelected() {
+ updatePageButtons();
+ }
+ };
+ }
+ }
+
+ /**
+ * @param threeColumnContainer
+ */
+ protected void createPropertyControls(final Composite threeColumnContainer) {
+ Label dummyLabel = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel.setText(""); //$NON-NLS-1$
+ Composite composite = new Composite(threeColumnContainer, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = AbstractFacetWizardPage.NUMBER_COLUMN_PROPERTY;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+ if (this.showVolatile) {
+ final Button button = new Button(composite, SWT.CHECK);
+ button.setText(Messages.Volatile);
+ button.setEnabled(this.canChangeVolatile);
+ button.setSelection(this.fVolatile);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ setVolatile(button.getSelection());
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // Nothing
+ }
+ });
+ }
+ if (this.showChangeable) {
+ final Button button = new Button(composite, SWT.CHECK);
+ button.setText(Messages.Changeable);
+ button.setSelection(this.fChangeable);
+ button.setEnabled(this.canChangeChangeable);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ setChangeable(button.getSelection());
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // Nothing
+ }
+ });
+ }
+ if (this.showDerived) {
+ final Button button = new Button(composite, SWT.CHECK);
+ button.setText(Messages.Derived);
+ button.setEnabled(this.canChangeDerived);
+ button.setSelection(this.fDerived);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ setDerived(button.getSelection());
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // Nothing
+ }
+ });
+ }
+ if (this.showTransient) {
+ final Button button = new Button(composite, SWT.CHECK);
+ button.setText(Messages.Transient);
+ button.setEnabled(this.canChangeTransient);
+ button.setSelection(this.fTransient);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ setTransient(button.getSelection());
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // Nothing
+ }
+ });
+ }
+ if (this.showOrdered) {
+ final Button button = new Button(composite, SWT.CHECK);
+ button.setText(Messages.Ordered);
+ button.setSelection(this.fOrdered);
+ button.setEnabled(this.canChangeOrdered);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ setOrdered(button.getSelection());
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // Nothing
+ }
+ });
+ }
+ if (this.showUnique) {
+ final Button button = new Button(composite, SWT.CHECK);
+ button.setText(Messages.Unique);
+ button.setSelection(this.fUnique);
+ button.setEnabled(this.canChangeUnique);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ setUnique(button.getSelection());
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ // Nothing
+ }
+ });
+ }
+ }
+
+ public boolean isSubTypingFacet() {
+ if (getSubClassingQueryButton() == null) {
+ return true;
+ }
+ return getSubClassingQueryButton().getSelection();
+ }
+
+ protected void initializeWithSelection() {
+ if (getSelection() != null && !getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) getSelection();
+ if (ssel.size() > 1) {
+ return;
+ }
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof Facet) {
+ setFacet((Facet) obj);
+ setFacetSet(((Facet) obj).getFacetSet());
+ if (((Facet) obj).getName() != null) {
+ setParentName(((Facet) obj).getName(), true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public IWizardPage getNextPage() {
+ if (this.showQueryTypeSelection) {
+ if (this.queryTypeNameToWizardPage != null && this.subClassingQueryButton != null) {
+ if (this.subClassingQueryButton.getSelection()) {
+ IQueryCreationPagePart wizard = this.queryTypeNameToWizardPage.get(getSelectedQueryType());
+ if (wizard != null) {
+ return super.getNextPage();
+ }
+ setErrorMessage(Messages.SelectQueryTypeWizardPage_No_wizard_found);
+ }
+ }
+ } else {
+ if (this.queryTypeNameToWizardPage != null) {
+ IQueryCreationPagePart wizard = this.queryTypeNameToWizardPage.get(getSelectedQueryType());
+ if (wizard != null) {
+ return super.getNextPage();
+ }
+ setErrorMessage(Messages.SelectQueryTypeWizardPage_No_wizard_found);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void setControl(final Control newControl) {
+ updatePageButtons();
+ super.setControl(newControl);
+ }
+
+ protected void setQueryTypeSelectionVisible(final boolean visible) {
+ this.selectQueryTypeComposite.setEnabled(visible);
+ }
+
+ public String getSelectedQueryType() {
+ return this.selectQueryTypeComposite.getSelectedQueryType();
+ }
+
+ protected void updatePageButtons() {
+ if (getContainer() != null && getContainer().getCurrentPage() != null) {
+ getContainer().updateButtons();
+ }
+ }
+
+ public void initializeTextContent(final String parentName2, final String childrenName2) {
+ if (parentName2 != null) {
+ this.parentNameLabel.setText(parentName2);
+ }
+ this.childrenNameLabel.setText(childrenName2);
+ if (this.showLowerBound) {
+ this.lowerBoundLabel.setText(Messages.Lower_bound);
+ }
+ if (this.showUpperBound) {
+ this.upperBoundLabel.setText(Messages.Upper_bound);
+ }
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ if (getChildrenName() == null) {
+ return false;
+ }
+ if (this.showChildrenName && getChildrenName().length() == 0) {
+ setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.childrenNameLabel.getText()));
+ return false;
+ }
+ if (this.showLowerBound && this.lowerBoundTextField.getValue() == null) {
+ setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.lowerBoundLabel.getText()));
+ return false;
+ }
+ if (this.showUpperBound && this.upperBoundTextField.getValue() == null) {
+ setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.upperBoundLabel.getText()));
+ return false;
+ }
+ if (this.showEType && getType() == null) {
+ setErrorMessage(NLS.bind(Messages.Please_enter_value_for, "Type")); //$NON-NLS-1$
+ return false;
+ }
+ if (this.wizardNeedsQuery) {
+ if (this.subClassingQueryButton != null && !this.subClassingQueryButton.getSelection()) {
+ setErrorMessage(null);
+ return true;
+ }
+ if (getNextPage() == null) {
+ setErrorMessage(Messages.CreateFacetInFacetSetWizardPage_could_not_find_wizard_page);
+ return false;
+ }
+ }
+ setErrorMessage(null);
+ return true;
+ }
+
+ // CanChange section
+ public void canChangeParentName(final boolean canChange) {
+ this.canChangeParentName = canChange;
+ }
+
+ public boolean canChangeParentName() {
+ return this.canChangeParentName;
+ }
+
+ public void canChangeChildrenName(final boolean canChange) {
+ this.canChangeChildrenName = canChange;
+ }
+
+ public boolean canChangeChildrenName() {
+ return this.canChangeChildrenName;
+ }
+
+ public void canChangeUpperBound(final boolean canChange) {
+ this.canChangeUpperBound = canChange;
+ }
+
+ public boolean canChangeUpperBound() {
+ return this.canChangeUpperBound;
+ }
+
+ public void canChangeLowerBound(final boolean canChange) {
+ this.canChangeLowerBound = canChange;
+ }
+
+ public boolean canChangeLowerBound() {
+ return this.canChangeLowerBound;
+ }
+
+ public void canChangeType(final boolean canChange) {
+ this.canChangeType = canChange;
+ }
+
+ public boolean canChangeType() {
+ return this.canChangeType;
+ }
+
+ public void canChangeEPackage(final boolean canChangeEPackage2) {
+ this.canChangeEPackage = canChangeEPackage2;
+ }
+
+ public EditingDomain getEditingDomain() {
+ return this.editingDomain;
+ }
+
+ public void setEditingDomain(final EditingDomain editingDomain) {
+ this.editingDomain = editingDomain;
+ }
+
+ public final ISelection getSelection() {
+ return this.selection;
+ }
+
+ public void setSelection(final ISelection selection) {
+ this.selection = selection;
+ }
+
+ public final FacetSet getFacetSet() {
+ return this.facetSet;
+ }
+
+ public final void setFacetSet(final FacetSet facetSet) {
+ this.facetSet = facetSet;
+ }
+
+ public Facet getFacet() {
+ return this.facet;
+ }
+
+ public final void setFacet(final Facet facet) {
+ this.facet = facet;
+ }
+
+ public String getFacetName() {
+ return this.facetName;
+ }
+
+ public void setFacetName(final String facetName) {
+ this.facetName = facetName;
+ }
+
+ public int getLowerBound() {
+ try {
+ return (this.lowerBoundTextField.getValue()).intValue();
+ } catch (Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ return 0;
+ }
+
+ public void setLowerBound(final int lowerBound) {
+ this.lowerBound = lowerBound;
+ if (this.lowerBoundTextField != null) {
+ (this.lowerBoundTextField).setValue(Integer.valueOf(lowerBound));
+ }
+ }
+
+ public int getUpperBound() {
+ try {
+ return (this.upperBoundTextField.getValue()).intValue();
+ } catch (Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ return 0;
+ }
+
+ public void setUpperBound(final int upperBound) {
+ this.upperBound = upperBound;
+ if (this.upperBoundTextField != null) {
+ this.upperBoundTextField.setValue(Integer.valueOf(upperBound));
+ }
+ }
+
+ public EClassifier getType() {
+ return this.selectETypeComposite.getEType();
+ }
+
+ public void setType(final EClass eType) {
+ this.type = eType;
+ if (this.selectETypeComposite != null) {
+ this.selectETypeComposite.setEType(eType);
+ }
+ }
+
+ public String getParentName() {
+ return this.parentName;
+ }
+
+ /**
+ * Set the parent(container) name
+ *
+ * @param parentName
+ * the new parent's name
+ * @param updateTextField
+ * whether to update the corresponding textField
+ */
+ public final void setParentName(final String parentName2, final boolean updateTextField) {
+ this.parentName = parentName2;
+ if (this.parentNameTextField != null) {
+ if (updateTextField) {
+ this.parentNameTextField.setText(parentName2);
+ }
+ }
+ }
+
+ public String getChildrenName() {
+ return this.childrenName;
+ }
+
+ public void setChildrenName(final String childrenName) {
+ this.childrenName = childrenName;
+ }
+
+ public Button getSubClassingQueryButton() {
+ return this.subClassingQueryButton;
+ }
+
+ public void showUpperBound(final boolean showUpperBound2) {
+ this.showUpperBound = showUpperBound2;
+ }
+
+ public void showLowerBound(final boolean showLOwerBound2) {
+ this.showLowerBound = showLOwerBound2;
+ }
+
+ public void showParentName(final boolean showParentName2) {
+ this.showParentName = showParentName2;
+ }
+
+ public void showChildrenName(final boolean showChildrenName2) {
+ this.showChildrenName = showChildrenName2;
+ }
+
+ public void showQueryTypeSelection(final boolean showQueryTypeSelection2) {
+ this.showQueryTypeSelection = showQueryTypeSelection2;
+ }
+
+ public void showEType(final boolean showEType2) {
+ this.showEType = showEType2;
+ }
+
+ public boolean isVolatile() {
+ return this.fVolatile;
+ }
+
+ public void showVolatile(final boolean fVolatile1) {
+ this.showVolatile = fVolatile1;
+ }
+
+ public boolean isChangeable() {
+ return this.fChangeable;
+ }
+
+ public void showChangeable(final boolean fChangeable1) {
+ this.showChangeable = fChangeable1;
+ }
+
+ public boolean isDerived() {
+ return this.fDerived;
+ }
+
+ public void showDerived(final boolean fDerived1) {
+ this.showDerived = fDerived1;
+ }
+
+ public boolean isTransient() {
+ return this.fTransient;
+ }
+
+ public void showTransient(final boolean fTransient1) {
+ this.showTransient = fTransient1;
+ }
+
+ public boolean isOrdered() {
+ return this.fOrdered;
+ }
+
+ public void showOrdered(final boolean fOrdered1) {
+ this.showOrdered = fOrdered1;
+ }
+
+ public boolean isUnique() {
+ return this.fUnique;
+ }
+
+ public void showUnique(final boolean fUnique1) {
+ this.showUnique = fUnique1;
+ }
+
+ public void setVolatile(final boolean fVolatile2) {
+ this.fVolatile = fVolatile2;
+ }
+
+ public void setChangeable(final boolean fChangeable2) {
+ this.fChangeable = fChangeable2;
+ }
+
+ public void setDerived(final boolean fDerived2) {
+ this.fDerived = fDerived2;
+ }
+
+ public void setTransient(final boolean fTransient2) {
+ this.fTransient = fTransient2;
+ }
+
+ public void setOrdered(final boolean ordered) {
+ this.fOrdered = ordered;
+ }
+
+ public void setUnique(final boolean fUnique2) {
+ this.fUnique = fUnique2;
+ }
+
+ public void setWizardNeedsQuery(final boolean wizardNeedsQuery) {
+ this.wizardNeedsQuery = wizardNeedsQuery;
+ }
+
+ public QueryFacetElement getQueryFacetElement() {
+ return this.queryFacetElement;
+ }
+
+ public void setQueryFacetElement(final QueryFacetElement queryFacetElement) {
+ this.queryFacetElement = queryFacetElement;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddAttributeInFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddAttributeInFacetWizardPage.java
new file mode 100644
index 00000000000..b509a4790ab
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddAttributeInFacetWizardPage.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import java.util.Map;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class AddAttributeInFacetWizardPage extends AbstractFacetWizardPage {
+
+ public AddAttributeInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain,
+ final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) {
+ super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.EDATATYPE);
+ setTitle(Messages.Add_an_Attribute);
+ setDescription(Messages.Add_an_Attribute_desc);
+ }
+
+ public void createControl(final Composite parent) {
+ final Composite container = new Composite(parent, SWT.NULL);
+
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 1;
+ layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
+
+ showQueryTypeSelection(false);
+
+ createControlParts(container);
+ initializeTextContent(Messages.Facet, Messages.Attribute_name);
+
+ setControl(container);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationInFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationInFacetWizardPage.java
new file mode 100644
index 00000000000..8506639d1e6
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationInFacetWizardPage.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import java.util.Map;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class AddOperationInFacetWizardPage extends AbstractFacetWizardPage {
+
+ public AddOperationInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain,
+ final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) {
+ super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.ECLASSIFIER);
+ setTitle(Messages.Add_an_Operation);
+ setDescription(Messages.Add_an_Operation_desc);
+ }
+
+ public void createControl(final Composite parent) {
+ final Composite container = new Composite(parent, SWT.NULL);
+
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 1;
+ layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
+
+ showQueryTypeSelection(false);
+
+ createControlParts(container);
+ initializeTextContent(Messages.Facet, Messages.Operation_name);
+
+ setControl(container);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationParameterInFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationParameterInFacetWizardPage.java
new file mode 100644
index 00000000000..fbc3a9215f5
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationParameterInFacetWizardPage.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class AddOperationParameterInFacetWizardPage extends AbstractFacetWizardPage {
+
+ public AddOperationParameterInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain) {
+ super(selection, editingDomain);
+ setTitle(Messages.Add_an_Operation_Parameter);
+ setDescription(Messages.Add_an_Operation_Parameter_desc);
+ }
+
+ @Override
+ protected void initializeWithSelection() {
+ if (getSelection() != null && !getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) getSelection();
+ if (ssel.size() > 1) {
+ return;
+ }
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof FacetOperation) {
+ FacetOperation facetOperation = (FacetOperation) obj;
+ setQueryFacetElement(facetOperation);
+ setFacet(facetOperation.getFacet());
+ setFacetSet(facetOperation.getFacet().getFacetSet());
+ if (facetOperation.getName() != null) {
+ setParentName(facetOperation.getName(), true);
+ }
+ }
+ }
+ }
+
+ public void createControl(final Composite parent) {
+ final Composite container = new Composite(parent, SWT.NULL);
+
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 1;
+ layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
+
+ setWizardNeedsQuery(false);
+
+ createControlParts(container);
+ initializeTextContent(Messages.Operation, Messages.Parameter_name);
+
+ setControl(container);
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddReferenceInFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddReferenceInFacetWizardPage.java
new file mode 100644
index 00000000000..27d2797f286
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddReferenceInFacetWizardPage.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import java.util.Map;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class AddReferenceInFacetWizardPage extends AbstractFacetWizardPage {
+
+ public AddReferenceInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain,
+ final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) {
+ super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.ECLASS);
+ setTitle(Messages.Add_a_Reference);
+ setDescription(Messages.Add_a_Reference_desc);
+ }
+
+ public void createControl(final Composite parent) {
+ final Composite container = new Composite(parent, SWT.NULL);
+
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 1;
+ layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
+
+ showQueryTypeSelection(false);
+
+ createControlParts(container);
+ initializeTextContent(Messages.Facet, Messages.Reference_name);
+
+ setControl(container);
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetInFacetSetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetInFacetSetWizardPage.java
new file mode 100644
index 00000000000..52777af4992
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetInFacetSetWizardPage.java
@@ -0,0 +1,139 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.Facet;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.BrowseComposite;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.SelectETypeWizardImpl;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class CreateFacetInFacetSetWizardPage extends AbstractFacetWizardPage {
+
+ private boolean canChangeExtendedMetaClass;
+ private final Facet facet;
+
+ public CreateFacetInFacetSetWizardPage(final Facet facet, final ISelection selection, final EditingDomain editingDomain2,
+ final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) {
+ super(selection, editingDomain2, queryTypeNameToWizardPage, ETypeSelectionOptions.ECLASS);
+ this.facet = facet;
+ setTitle(Messages.Create_facet_in_facetSet);
+ setDescription(Messages.CreateFacetInFacetSetWizardPage_wizard_description);
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return isPageComplete() && isSubTypingFacet();
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ if (super.isPageComplete()) {
+ if (getExtendedMetaclass() == null) {
+ setErrorMessage(Messages.CreateFacetInFacetSetWizardPage_Please_fill_extendedMetaClass);
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void initializeWithSelection() {
+ if (getSelection() != null && !getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) getSelection();
+ if (ssel.size() > 1) {
+ return;
+ }
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof FacetSet) {
+ FacetSet facetSet = (FacetSet) obj;
+ setFacetSet(facetSet);
+ if (facetSet.getName() != null) {
+ setParentName(facetSet.getName(), true);
+ }
+ }
+ }
+ }
+
+ public void createControl(final Composite parent) {
+ final Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 1;
+ layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
+ showLowerBound(false);
+ showUpperBound(false);
+ showEType(false);
+ showVolatile(false);
+ showOrdered(false);
+ showChangeable(false);
+ showUnique(false);
+ showTransient(false);
+ showDerived(false);
+
+ Composite container2 = createControlParts(container);
+
+ Label label = new Label(container2, SWT.NONE);
+ label.setText(Messages.ExtendedMetaClass);
+ @SuppressWarnings("unused")
+ // this composite is never read because it only takes care of the UI
+ BrowseComposite browseComposite = new BrowseComposite(container2, SWT.BORDER, null, this.canChangeExtendedMetaClass) {
+ @Override
+ protected void handleBrowse() {
+ SelectETypeWizardImpl dialog = new SelectETypeWizardImpl(getEditingDomain(), ETypeSelectionOptions.ECLASS, false, getFacetSet()
+ .getExtendedEPackage());
+ if (dialog.open() != Window.CANCEL) {
+ EClass eClass = (EClass) dialog.getSelectedEType();
+ setExtendedMetaClass(eClass);
+ if (eClass.getInstanceClassName() != null) {
+ updateTextFieldContent(eClass.getInstanceClassName());
+ } else {
+ updateTextFieldContent(eClass.getName());
+ }
+ updatePageButtons();
+ }
+ }
+ };
+
+ initializeTextContent(Messages.FacetSet, Messages.Facet);
+
+ setControl(container);
+ }
+
+ public void setExtendedMetaClass(final EClass extendedMetaClass) {
+ this.facet.setExtendedMetaclass(extendedMetaClass);
+ }
+
+ public void canChangeExtendedMetaClass(final boolean canChange2) {
+ this.canChangeExtendedMetaClass = canChange2;
+ }
+
+ public EClass getExtendedMetaclass() {
+ return this.facet.getExtendedMetaclass();
+ }
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetSetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetSetWizardPage.java
new file mode 100644
index 00000000000..177a4d71cc1
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetSetWizardPage.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.facet.efacet.ui.internal.Activator;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.wizards.CreateFacetSetWizardImpl;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.pde.core.internal.exported.PluginUtils;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class CreateFacetSetWizardPage extends WizardNewFileCreationPage {
+
+ public CreateFacetSetWizardPage(final String pageId, final IStructuredSelection selection) {
+ super(pageId, selection);
+
+ setTitle(Messages.CreateFacetSetWizardImpl_FacetModel);
+ setDescription(Messages.CreateFacetSetWizardImpl_Create_new_facet_Set);
+ setFileName("My" //$NON-NLS-1$
+ + "." + CreateFacetSetWizardImpl.FILE_EXTENSION); //$NON-NLS-1$
+
+ // Try and get the resource selection to determine a current directory
+ // for the file dialog.
+ if (selection != null && !selection.isEmpty()) {
+ // Get the resource...
+ //
+ Object selectedElement = selection.iterator().next();
+ if (selectedElement instanceof IResource) {
+ // Get the resource parent, if its a file.
+ IResource selectedResource = (IResource) selectedElement;
+ if (selectedResource.getType() == IResource.FILE) {
+ selectedResource = selectedResource.getParent();
+ }
+
+ // This gives us a directory...
+ if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
+ // Set this for the container.
+ setContainerFullPath(selectedResource.getFullPath());
+
+ // Make up a unique new name here.
+ //
+ String defaultModelBaseFilename = "My"; //$NON-NLS-1$
+ String defaultModelFilenameExtension = CreateFacetSetWizardImpl.FILE_EXTENSION;
+ String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; //$NON-NLS-1$
+ for (int i = 1; ((IContainer) selectedResource).findMember(modelFilename) != null; ++i) {
+ modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; //$NON-NLS-1$
+ }
+ setFileName(modelFilename);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected boolean validatePage() {
+ boolean valid = super.validatePage();
+
+ if (valid) {
+ String extension = new Path(getFileName()).getFileExtension();
+ if (extension == null || !CreateFacetSetWizardImpl.FILE_EXTENSION.equalsIgnoreCase((extension))) {
+ setErrorMessage(Messages.CreateFacetSetWizardImpl_File_extension_restriction);
+ valid = false;
+ }
+ }
+
+ if (valid) {
+
+ IPath containerFullPath = getContainerFullPath();
+ try {
+ if (!PluginUtils.isInPluginProject(containerFullPath)) {
+ setMessage(Messages.CreateFacetSetWizardPage_Not_a_Plugin_project, IMessageProvider.WARNING);
+ }
+ } catch (CoreException e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ }
+
+ return valid;
+ }
+
+ public IFile getModelFile() {
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName()));
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateQueryWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateQueryWizardPage.java
new file mode 100644
index 00000000000..9cd143bb5ee
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateQueryWizardPage.java
@@ -0,0 +1,286 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import java.util.Map;
+
+import org.eclipse.emf.facet.efacet.Facet;
+import org.eclipse.emf.facet.efacet.FacetSet;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
+import org.eclipse.emf.facet.widgets.celleditors.AbstractCellEditorComposite;
+import org.eclipse.emf.facet.widgets.celleditors.ICompositeEditorFactory;
+import org.eclipse.emf.facet.widgets.celleditors.core.composite.registries.ICompositeEditorFactoriesRegistry;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+@Deprecated
+//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
+public class CreateQueryWizardPage extends WizardPage {
+
+ private static final int NUMBER_COLUMN = 3;
+
+ private Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage;
+
+ private Text queryNameText;
+ private boolean canChangeQueryName = true;
+
+ private Button canBeCachedButton;
+ private boolean canChangeCanBeCached = true;
+
+ private Button hasSideEffectButton;
+ private boolean canChangeHasSideEffect = true;
+
+ private AbstractCellEditorComposite<Integer> lowerBoundText;
+ private boolean canChangeLowerBound = true;
+
+ private AbstractCellEditorComposite<Integer> upperBoundText;
+ private boolean canChangeUpperBound = true;
+
+ private String queryName;
+ private FacetSet facetSet;
+ private Facet facet;
+ private String queryType;
+
+ private Composite parentComposite;
+ private IQueryCreationPagePart queryCreationPage;
+
+ public CreateQueryWizardPage(final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage,
+ final FacetSet facetSet, final Facet facet) {
+ this("Whatever", facetSet); //$NON-NLS-1$
+ this.facet = facet;
+ this.queryTypeNameToQueryCreationPage = queryTypeNameToQueryCreationPage;
+ }
+
+ @Override
+ public void setVisible(final boolean visible) {
+ if (visible) {
+ setFocus();
+ IWizardPage previousPage = getPreviousPage();
+ if (previousPage instanceof AbstractFacetWizardPage) {
+ AbstractFacetWizardPage createFacetInFacetSetWizardPage = (AbstractFacetWizardPage) getPreviousPage();
+ this.queryType = createFacetInFacetSetWizardPage.getSelectedQueryType();
+ String childrenName = createFacetInFacetSetWizardPage.getChildrenName();
+ String childrenNameFirstLetterToUpperCase = childrenName.substring(0, 1).toUpperCase()
+ + childrenName.substring(1);
+ if (previousPage instanceof CreateFacetInFacetSetWizardPage) {
+ setQueryName("is" + childrenNameFirstLetterToUpperCase); //$NON-NLS-1$
+ } else if (previousPage instanceof AddReferenceInFacetWizardPage
+ || previousPage instanceof AddAttributeInFacetWizardPage) {
+ setQueryName("get" + childrenNameFirstLetterToUpperCase); //$NON-NLS-1$
+ } else {
+ setQueryName(childrenNameFirstLetterToUpperCase);
+ }
+ deleteAllControls(this.parentComposite);
+ createControl2(this.parentComposite);
+ this.parentComposite.layout();
+ }
+ }
+ super.setVisible(visible);
+ }
+
+ private void setFocus() {
+ this.queryNameText.setFocus();
+ }
+
+ public CreateQueryWizardPage(final String pageName, final FacetSet facetSet) {
+ super(pageName);
+ setTitle(Messages.Create_Query);
+ this.facetSet = facetSet;
+ }
+
+ private static void deleteAllControls(final Composite comp) {
+ for (Control c : comp.getChildren()) {
+ c.dispose();
+ }
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ if (this.queryCreationPage != null) {
+ if (!this.queryCreationPage.isCompositeComplete()) {
+ setErrorMessage(this.queryCreationPage.getErrorMessage());
+ return false;
+ }
+ setErrorMessage(null);
+ }
+ return super.isPageComplete();
+ }
+
+ private void createControl2(final Composite parent) {
+ Composite threeColumnContainer = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(CreateQueryWizardPage.NUMBER_COLUMN, false);
+ threeColumnContainer.setLayout(layout);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ threeColumnContainer.setLayoutData(gridData);
+ Label label = new Label(threeColumnContainer, SWT.NONE);
+ label.setText(Messages.JavaQueryWizardPage_Query_name);
+ this.queryNameText = new Text(threeColumnContainer, SWT.BORDER);
+ this.queryNameText.setEditable(this.canChangeQueryName);
+ this.queryNameText.setLayoutData(gridData);
+ if (this.queryName != null) {
+ this.queryNameText.setText(this.queryName);
+ }
+ this.queryNameText.addModifyListener(new ModifyListener() {
+ public void modifyText(final ModifyEvent e) {
+ updateQueryName();
+ }
+ });
+ Label dummyLabel = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel.setText(""); //$NON-NLS-1$
+ Label canBeCachedLabel = new Label(threeColumnContainer, SWT.NONE);
+ canBeCachedLabel.setText(Messages.JavaQueryWizardPage_Can_be_cached);
+ this.canBeCachedButton = new Button(threeColumnContainer, SWT.CHECK);
+ this.canBeCachedButton.setEnabled(this.canChangeCanBeCached);
+
+ Label dummyLabel1 = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel1.setText(""); //$NON-NLS-1$
+
+ Label hasSideEffectLabel = new Label(threeColumnContainer, SWT.NONE);
+ hasSideEffectLabel.setText(Messages.JavaQueryWizardPage_has_side_effect);
+ this.hasSideEffectButton = new Button(threeColumnContainer, SWT.CHECK);
+ this.hasSideEffectButton.setEnabled(this.canChangeHasSideEffect);
+
+ Label dummyLabel2 = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel2.setText(""); //$NON-NLS-1$
+ ICompositeEditorFactory<Integer> compositeFactory = ICompositeEditorFactoriesRegistry.INSTANCE
+ .getCompositeEditorFactory(Integer.class);
+
+ Label lowerBoundLabel = new Label(threeColumnContainer, SWT.NONE);
+ lowerBoundLabel.setText(Messages.Lower_bound);
+ this.lowerBoundText = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER | SWT.SINGLE);
+ this.lowerBoundText.setLayoutData(gridData);
+ this.lowerBoundText.setEnabled(this.canChangeLowerBound);
+ this.lowerBoundText.setValue(Integer.valueOf(1));
+ Label dummyLabel3 = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel3.setText(""); //$NON-NLS-1$
+
+ Label upperBoundLabel = new Label(threeColumnContainer, SWT.NONE);
+ upperBoundLabel.setText(Messages.Upper_bound);
+ this.upperBoundText = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER | SWT.SINGLE);
+ this.upperBoundText.setLayoutData(gridData);
+ this.upperBoundText.setEnabled(this.canChangeUpperBound);
+ this.upperBoundText.setValue(Integer.valueOf(1));
+ Label dummyLabel4 = new Label(threeColumnContainer, SWT.NONE);
+ dummyLabel4.setText(""); //$NON-NLS-1$
+
+ // Add the composite provided by extension point for the chosen Query type
+ if (this.queryTypeNameToQueryCreationPage != null) {
+ this.queryCreationPage = this.queryTypeNameToQueryCreationPage.get(this.queryType);
+ if (this.queryCreationPage != null) {
+ this.queryCreationPage.completeComposite(threeColumnContainer);
+ this.queryCreationPage.setFacetSet(getFacetSet());
+ this.queryCreationPage.setQueryType(this.facet.getExtendedMetaclass());
+ this.queryCreationPage.setQueryName(this.queryName);
+ this.queryCreationPage.addModifyListener(new ModifyListener() {
+
+ public void modifyText(final ModifyEvent e) {
+ updateButtons();
+ }
+ });
+ }
+ }
+
+ setControl(threeColumnContainer);
+ }
+
+ private FacetSet getFacetSet() {
+ return this.facetSet;
+ }
+
+ public void createControl(final Composite parent) {
+ this.parentComposite = new Composite(parent, SWT.NONE);
+ this.parentComposite.setLayout(new GridLayout(1, false));
+ createControl2(this.parentComposite);
+ }
+
+ protected void updateButtons() {
+ if (getContainer() != null && getContainer().getCurrentPage() != null) {
+ getContainer().updateButtons();
+ this.queryNameText.setFocus();
+ }
+ }
+
+ protected void updateQueryName() {
+ if (this.queryNameText != null) {
+ this.queryName = this.queryNameText.getText();
+ this.queryNameText.setFocus();
+ }
+ }
+
+ public void setQueryName(final String queryName) {
+ this.queryName = queryName;
+ if (this.queryNameText != null) {
+ this.queryNameText.setText(queryName);
+ this.queryNameText.redraw();
+ }
+ }
+
+ public String getQueryName() {
+ return this.queryName;
+ }
+
+ public void canChangeUpperBound(final boolean canChange) {
+ this.canChangeUpperBound = canChange;
+ }
+
+ public void canChangeQueryName(final boolean canChange) {
+ this.canChangeQueryName = canChange;
+ }
+
+ public void canChangeLowerBound(final boolean canChange) {
+ this.canChangeLowerBound = canChange;
+ }
+
+ public void canChangeHasSideEffect(final boolean canChange) {
+ this.canChangeHasSideEffect = canChange;
+ }
+
+ public void canChangeCanBeCached(final boolean canChange) {
+ this.canChangeCanBeCached = canChange;
+ }
+
+ public boolean getCanBeCached() {
+ return this.canBeCachedButton.getSelection();
+ }
+
+ public boolean getHasSideEffect() {
+ return this.hasSideEffectButton.getSelection();
+ }
+
+ public int getLowerBound() {
+ return this.lowerBoundText.getValue().intValue();
+ }
+
+ public int getUpperBound() {
+ return this.upperBoundText.getValue().intValue();
+ }
+
+ public IQueryCreationPagePart getQueryCreationPage() {
+ return this.queryCreationPage;
+ }
+
+ public void setFacetSet(final FacetSet facetSet) {
+ this.facetSet = facetSet;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/FacetSetPropertyWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/FacetSetPropertyWizardPage.java
new file mode 100644
index 00000000000..dbafcfcbf21
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/FacetSetPropertyWizardPage.java
@@ -0,0 +1,106 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
+ */
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Wizard page to enter a NsURI, a prefix and an extended EPackage to a facetSet
+ */
+public class FacetSetPropertyWizardPage extends SelectEPackageWizardPage {
+
+ private Text nsUriTextField;
+ private Text prefixTextField;
+
+ public FacetSetPropertyWizardPage(final EditingDomain editingDomain) {
+ super(editingDomain);
+ }
+
+ @Override
+ public void createControl(final Composite parent) {
+
+ // Extends the SelectEPackageWizardPage to add a NsURI and a Prefix textField
+ Composite container = new Composite(parent, SWT.NONE);
+ container.setLayout(new GridLayout(1, false));
+ container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true));
+
+ Composite nsURiContainer = new Composite(container, SWT.NONE);
+ nsURiContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ nsURiContainer.setLayout(new GridLayout(2, false));
+
+ // NsURI
+ Label nsUriLabel = new Label(nsURiContainer, SWT.NONE);
+ nsUriLabel.setText(Messages.Enter_a_nsUri);
+ this.nsUriTextField = new Text(nsURiContainer, SWT.BORDER | SWT.SINGLE);
+ this.nsUriTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.nsUriTextField.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(final Event event) {
+ updateButtons();
+ }
+ });
+
+ // PREFIX
+ Label prefixLabel = new Label(nsURiContainer, SWT.NONE);
+ prefixLabel.setText(Messages.Enter_a_prefix);
+ this.prefixTextField = new Text(nsURiContainer, SWT.BORDER | SWT.SINGLE);
+ this.prefixTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.prefixTextField.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(final Event event) {
+ updateButtons();
+ }
+ });
+
+ super.createControl(container);
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ if (this.nsUriTextField.getText().length() == 0) {
+ setErrorMessage(Messages.Please_enter_nsUri);
+ return false;
+ }
+
+ if (this.prefixTextField.getText().length() == 0) {
+ setErrorMessage(Messages.Please_enter_prefix);
+ return false;
+ }
+ if (super.isPageComplete()) {
+ setErrorMessage(null);
+ return true;
+ }
+ setErrorMessage(Messages.Please_select_EPackage);
+
+ return false;
+ }
+
+ public String getNsUri() {
+ return this.nsUriTextField.getText();
+ }
+
+ public String getPrefix() {
+ return this.prefixTextField.getText();
+ }
+
+ protected void updateButtons() {
+ getContainer().updateButtons();
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEClassifierWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEClassifierWizardPage.java
new file mode 100644
index 00000000000..7ab88aae214
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEClassifierWizardPage.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
+import org.eclipse.emf.facet.efacet.ui.internal.widget.EClassifierSelectionControl;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.FilteredList;
+
+public class SelectEClassifierWizardPage extends WizardPage {
+
+ private EClassifierSelectionControl eClassSelectionControl;
+ private final ETypeSelectionOptions eTypeSelectionOption;
+ private String metamodelNsUri;
+
+ public SelectEClassifierWizardPage(final ETypeSelectionOptions eTypeSelectionOption, final EPackage ePackage) {
+ super("Whatever"); //$NON-NLS-1$
+ if (eTypeSelectionOption == ETypeSelectionOptions.ECLASS) {
+ setTitle(Messages.Select_EClass);
+ } else if (eTypeSelectionOption == ETypeSelectionOptions.EDATATYPE) {
+ setTitle(Messages.Select_EDataType);
+ } else {
+ setTitle(Messages.Select_EClassifier);
+ }
+ if (ePackage != null) {
+ this.metamodelNsUri = ePackage.getNsURI();
+ }
+ this.eTypeSelectionOption = eTypeSelectionOption;
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return this.eClassSelectionControl.getSelectedEClassifier() != null;
+ }
+
+ @Override
+ public void setVisible(final boolean visible) {
+ super.setVisible(visible);
+ if (getPreviousPage() instanceof SelectEPackageWizardPage) {
+ SelectEPackageWizardPage selectEPackageWizardPage = (SelectEPackageWizardPage) getPreviousPage();
+ this.metamodelNsUri = selectEPackageWizardPage.getFirstSelectedEPackage().getNsURI();
+ if (this.metamodelNsUri != null) {
+ setDescription(selectEPackageWizardPage.getFirstSelectedEPackage().getNsURI());
+ }
+ }
+ this.eClassSelectionControl.updateList(this.metamodelNsUri);
+ }
+
+ public void createControl(final Composite parent) {
+ this.eClassSelectionControl = new EClassifierSelectionControl(parent, this.metamodelNsUri, this.eTypeSelectionOption);
+ final FilteredList filteredList = this.eClassSelectionControl.getFilteredList();
+
+ filteredList.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ if (e.item != null) {
+ updateButton();
+ // setPageComplete(filteredList.getSelection().length == 1);
+ }
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ if (getWizard().canFinish()) {
+ getWizard().performFinish();
+ }
+ if (getNextPage() != null) {
+ goToNextPage();
+ }
+ }
+ });
+
+ this.eClassSelectionControl.getFilterText().addModifyListener(new ModifyListener() {
+
+ public void modifyText(final ModifyEvent e) {
+ updateButton();
+ }
+ });
+
+ // avoid the page being "complete" when still on a previous page
+ filteredList.setSelection(new int[0]);
+ setPageComplete(false);
+
+ setControl(this.eClassSelectionControl);
+ }
+
+ protected void goToNextPage() {
+ getContainer().showPage(getNextPage());
+ }
+
+ protected void updateButton() {
+ if (getContainer() != null && getContainer().getCurrentPage() != null) {
+ getContainer().updateButtons();
+ }
+ }
+
+ public EClassifier getSelectedEclassifier() {
+ return this.eClassSelectionControl.getSelectedEClassifier();
+ }
+} \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEPackageWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEPackageWizardPage.java
new file mode 100644
index 00000000000..195ceceb23b
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEPackageWizardPage.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.facet.efacet.ui.internal.wizards.pages;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.efacet.ui.internal.Messages;
+import org.eclipse.emf.facet.efacet.ui.internal.widget.MetamodelSelectionControl;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.FilteredList;
+
+public class SelectEPackageWizardPage extends WizardPage {
+
+ private MetamodelSelectionControl metamodelSelectionControl;
+ private final EditingDomain editingDomain;
+
+ public SelectEPackageWizardPage(final EditingDomain editingDomain) {
+ super("Whatever"); //$NON-NLS-1$
+ setTitle(Messages.Select_EPackage);
+ this.editingDomain = editingDomain;
+ }
+
+ @Override
+ public void setVisible(final boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ this.metamodelSelectionControl.getFilterText().setFocus();
+ setPageComplete(true);
+ }
+ }
+
+ public void createControl(final Composite parent) {
+ this.metamodelSelectionControl = new MetamodelSelectionControl(parent);
+ this.metamodelSelectionControl.setLayoutData(new GridData(GridData.FILL_BOTH));
+ final FilteredList filteredList = this.metamodelSelectionControl.getFilteredList();
+
+ filteredList.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(final SelectionEvent e) {
+ if (e.item != null) {
+ setPageComplete(filteredList.getSelection().length == 1);
+ }
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ if (getWizard().canFinish()) {
+ getWizard().performFinish();
+ }
+ if (getNextPage() != null) {
+ goToNextPage();
+ }
+ }
+ });
+
+ // prevent the page from being "complete" when still on a previous page
+ filteredList.setSelection(new int[0]);
+ setPageComplete(false);
+
+ setControl(this.metamodelSelectionControl);
+ }
+
+ protected void goToNextPage() {
+ getContainer().showPage(getNextPage());
+ }
+
+ public EPackage getFirstSelectedEPackage() {
+ // Only one result
+ if (this.metamodelSelectionControl.getSelectedElements() != null) {
+ Object result = this.metamodelSelectionControl.getSelectedElements()[0];
+ if (EPackage.Registry.INSTANCE.containsKey(result.toString())) {
+ return EPackage.Registry.INSTANCE.getEPackage(result.toString());
+ }
+ }
+ return null;
+ }
+
+ public void loadSelectedMetamodel() {
+ Object[] results = this.metamodelSelectionControl.getSelectedElements();
+ // if user cancel the selection of meta models, results = null
+ if (results != null) {
+ ResourceSet resourceSet = this.editingDomain.getResourceSet();
+ for (Object result : results) {
+ URI uri = URI.createURI(result.toString());
+ Resource r = resourceSet.getResource(uri, true);
+ if (!resourceSet.getResources().contains(r)) {
+ Registry packageRegistry = resourceSet.getPackageRegistry();
+ for (EObject eObject : r.getContents()) {
+ if (eObject instanceof EPackage) {
+ EPackage ePackage = (EPackage) eObject;
+ packageRegistry.put(ePackage.getNsURI(), ePackage);
+ }
+ }
+ resourceSet.getResources().add(r);
+ }
+ }
+ }
+ }
+}

Back to the top