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);
}
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);
}
}
}
}
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);
}
}
}
}
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;
}
Aggregations