Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 22efd005eeab384863873ea4106de67063ba8fa3 (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
77
/*******************************************************************************
 * Copyright (c) 2011, 2016 THALES GLOBAL SERVICES.
 * 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:
 *    Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.sirius.editor.properties.sections.description.representationextensiondescription;

import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.AddFromFilesystemButtonListener;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.AddFromRegistryButtonListener;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.AddFromWorkspaceButtonListener;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.DescriptionMetamodelsUpdater;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.RemoveMetamodelsSelectionButtonListener;
import org.eclipse.sirius.editor.properties.sections.description.representationdescription.RepresentationDescriptionMetamodelPropertySectionSpec;
import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
import org.eclipse.sirius.viewpoint.description.RepresentationExtensionDescription;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;

/**
 * A {@link AbstractSiriusPropertySection} for the metamodels tab.
 * 
 * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
 */
public class RepresentationExtensionDescriptionMetamodelPropertySectionSpec extends RepresentationDescriptionMetamodelPropertySectionSpec {

    @Override
    protected void addButtons() {
        RepresentationExtensionDescription representationExtensionDescription = (RepresentationExtensionDescription) eObject;
        this.descriptionMetamodelsUpdater = new DescriptionMetamodelsUpdater(representationExtensionDescription, DescriptionPackage.eINSTANCE.getRepresentationExtensionDescription_Metamodel());
        addFromRegistryButton = getWidgetFactory().createButton(composite, "Add from registry", SWT.PUSH);
        addFromRegistryButton.addSelectionListener(new AddFromRegistryButtonListener(this, descriptionMetamodelsUpdater));
        FormData data = new FormData();
        data.top = new FormAttachment(listHeader, 0, SWT.RIGHT);
        data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
        data.right = new FormAttachment(100);
        addFromRegistryButton.setLayoutData(data);

        addFromWorkspaceButton = getWidgetFactory().createButton(composite, "Add from workspace", SWT.PUSH);
        addFromWorkspaceButton.addSelectionListener(new AddFromWorkspaceButtonListener(this, descriptionMetamodelsUpdater));
        data = new FormData();
        data.top = new FormAttachment(addFromRegistryButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
        data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
        data.right = new FormAttachment(100);
        addFromWorkspaceButton.setLayoutData(data);

        addFromFilesystemButton = getWidgetFactory().createButton(composite, "Add from filesystem", SWT.PUSH);
        addFromFilesystemButton.addSelectionListener(new AddFromFilesystemButtonListener(this, descriptionMetamodelsUpdater));
        data = new FormData();
        data.top = new FormAttachment(addFromWorkspaceButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
        data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
        data.right = new FormAttachment(100);
        addFromFilesystemButton.setLayoutData(data);

        removeMetamodelsSelectionButton = getWidgetFactory().createButton(composite, "Remove", SWT.PUSH);
        removeMetamodelsSelectionButton.addSelectionListener(new RemoveMetamodelsSelectionButtonListener(this, removeMetamodelsSelectionButton, metamodelsTable, descriptionMetamodelsUpdater));
        removeMetamodelsSelectionButton.setEnabled(false);
        data = new FormData();
        data.top = new FormAttachment(addFromFilesystemButton, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
        data.left = new FormAttachment(metamodelsTable, ITabbedPropertyConstants.HMARGIN, SWT.RIGHT);
        data.right = new FormAttachment(100);
        removeMetamodelsSelectionButton.setLayoutData(data);
    }

    @Override
    protected EStructuralFeature getFeature() {
        return DescriptionPackage.eINSTANCE.getRepresentationExtensionDescription_Metamodel();
    }

}

Back to the top