Skip to main content
summaryrefslogtreecommitdiffstats
blob: d7c97cb8d1b5f76492b5ee55fec9a53614158cb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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.papyrus.emf.facet.efacet.ui.internal.wizards;

import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory;
import org.eclipse.papyrus.emf.facet.efacet.FacetAttribute;
import org.eclipse.papyrus.emf.facet.efacet.Query;
import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction;
import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddAttributeInFacetWizardPage;
import org.eclipse.papyrus.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;
	}
}

Back to the top