Search in sources :

Example 1 with AddCommand

use of org.eclipse.emf.edit.command.AddCommand in project statecharts by Yakindu.

the class StatechartDefinitionSection method addInlineStyle.

protected void addInlineStyle(BooleanValueStyle inlineStyle, TransactionalEditingDomain domain) {
    AddCommand command = new AddCommand(domain, (View) getDiagram(), NotationPackage.Literals.VIEW__STYLES, inlineStyle);
    domain.getCommandStack().execute(command);
}
Also used : AddCommand(org.eclipse.emf.edit.command.AddCommand)

Example 2 with AddCommand

use of org.eclipse.emf.edit.command.AddCommand in project InformationSystem by ObeoNetwork.

the class ClassDiagramGenerator method addPalette.

private void addPalette(Configuration configuration, Viewpoint viewpointFromTemplate) {
    if (configuration.getColors().isEmpty() == false) {
        // Get Group from template
        Group groupFromTemplate = null;
        if (viewpointFromTemplate.eContainer() instanceof Group) {
            groupFromTemplate = (Group) viewpointFromTemplate.eContainer();
        }
        // get group
        EObject eContainer = configuration.getViewpoint().eContainer();
        if (eContainer instanceof Group) {
            Group group = (Group) eContainer;
            UserColorsPalette palette = null;
            if (group.getUserColorsPalettes().isEmpty()) {
                // We have to create a user color palette
                palette = DescriptionFactory.eINSTANCE.createUserColorsPalette();
                palette.setName("Palette");
                AddCommand addCommand = new AddCommand(editingDomain, group, DescriptionPackage.Literals.GROUP__USER_COLORS_PALETTES, palette);
                editingDomain.getCommandStack().execute(addCommand);
            } else {
                // use the first palette
                palette = group.getUserColorsPalettes().get(0);
            }
            for (ColorInfo colorInfo : configuration.getColors()) {
                // Check if color exists
                UserFixedColor newColor = null;
                for (UserColor userColor : palette.getEntries()) {
                    if (userColor instanceof UserFixedColor && userColor.getName().equals(colorInfo.getName())) {
                        newColor = (UserFixedColor) userColor;
                        break;
                    }
                }
                if (newColor == null) {
                    newColor = DescriptionFactory.eINSTANCE.createUserFixedColor();
                    AddCommand addCommand = new AddCommand(editingDomain, palette, DescriptionPackage.Literals.USER_COLORS_PALETTE__ENTRIES, newColor);
                    editingDomain.getCommandStack().execute(addCommand);
                }
                newColor.setName(colorInfo.getName());
                newColor.setRed(colorInfo.getRed());
                newColor.setGreen(colorInfo.getGreen());
                newColor.setBlue(colorInfo.getBlue());
            }
            // representation descriptions must reference the new palette
            if (palette != null) {
                replaceColorReferences(groupFromTemplate, group, configuration.getColors(), palette);
            }
        }
    }
}
Also used : Group(org.eclipse.sirius.viewpoint.description.Group) UserColorsPalette(org.eclipse.sirius.viewpoint.description.UserColorsPalette) UserFixedColor(org.eclipse.sirius.viewpoint.description.UserFixedColor) EObject(org.eclipse.emf.ecore.EObject) UserColor(org.eclipse.sirius.viewpoint.description.UserColor) ColorInfo(org.obeonetwork.tools.classdiagramconfiguration.ColorInfo) AddCommand(org.eclipse.emf.edit.command.AddCommand)

Example 3 with AddCommand

use of org.eclipse.emf.edit.command.AddCommand in project InformationSystem by ObeoNetwork.

the class ClassDiagramGenerator method addJavaExtensions.

private void addJavaExtensions(Configuration configuration, Viewpoint viewpointFromTemplate) {
    Collection<String> javaExtensions = new LinkedHashSet<String>(configuration.getJavaExtensions());
    for (JavaExtension javaExtensionFromTemplate : viewpointFromTemplate.getOwnedJavaExtensions()) {
        javaExtensions.add(javaExtensionFromTemplate.getQualifiedClassName());
    }
    if (javaExtensions.isEmpty() == false) {
        for (String javaExtension : javaExtensions) {
            if (containsJavaExtension(configuration.getViewpoint().getOwnedJavaExtensions(), javaExtension) == false) {
                JavaExtension extension = DescriptionFactory.eINSTANCE.createJavaExtension();
                extension.setQualifiedClassName(javaExtension);
                AddCommand addCommand = new AddCommand(editingDomain, configuration.getViewpoint(), DescriptionPackage.Literals.VIEWPOINT__OWNED_JAVA_EXTENSIONS, extension);
                editingDomain.getCommandStack().execute(addCommand);
            }
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JavaExtension(org.eclipse.sirius.viewpoint.description.JavaExtension) AddCommand(org.eclipse.emf.edit.command.AddCommand)

Example 4 with AddCommand

use of org.eclipse.emf.edit.command.AddCommand in project InformationSystem by ObeoNetwork.

the class ClassDiagramGenerator method createDescriptionsInTargetVSM.

private Collection<RepresentationDescription> createDescriptionsInTargetVSM(Collection<GenerationInfo> generationInfos, Viewpoint viewpointFromTemplate, Viewpoint viewpointFromTargetVSM) {
    Collection<RepresentationDescription> descriptions = new ArrayList<RepresentationDescription>();
    if (viewpointFromTemplate != null) {
        for (GenerationInfo generationInfo : generationInfos) {
            RepresentationDescription desc = getDescriptionFromId(viewpointFromTemplate, generationInfo.getDescriptionId());
            if (desc != null) {
                descriptions.add(desc);
                // Add metamodels
                if (!generationInfo.getMetamodelsURIs().isEmpty()) {
                    for (String metamodelUri : generationInfo.getMetamodelsURIs()) {
                        Object ePackage = EPackage.Registry.INSTANCE.getEPackage(metamodelUri);
                        if (ePackage instanceof EPackage) {
                            desc.getMetamodel().add((EPackage) ePackage);
                        }
                    }
                }
            }
        }
        if (descriptions.isEmpty() == false) {
            AddCommand addCommand = new AddCommand(editingDomain, viewpointFromTargetVSM, DescriptionPackage.Literals.VIEWPOINT__OWNED_REPRESENTATIONS, descriptions);
            editingDomain.getCommandStack().execute(addCommand);
        }
    }
    return descriptions;
}
Also used : RepresentationDescription(org.eclipse.sirius.viewpoint.description.RepresentationDescription) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) EPackage(org.eclipse.emf.ecore.EPackage) AddCommand(org.eclipse.emf.edit.command.AddCommand)

Aggregations

AddCommand (org.eclipse.emf.edit.command.AddCommand)4 EObject (org.eclipse.emf.ecore.EObject)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 EPackage (org.eclipse.emf.ecore.EPackage)1 Group (org.eclipse.sirius.viewpoint.description.Group)1 JavaExtension (org.eclipse.sirius.viewpoint.description.JavaExtension)1 RepresentationDescription (org.eclipse.sirius.viewpoint.description.RepresentationDescription)1 UserColor (org.eclipse.sirius.viewpoint.description.UserColor)1 UserColorsPalette (org.eclipse.sirius.viewpoint.description.UserColorsPalette)1 UserFixedColor (org.eclipse.sirius.viewpoint.description.UserFixedColor)1 ColorInfo (org.obeonetwork.tools.classdiagramconfiguration.ColorInfo)1