Search in sources :

Example 11 with EObjectFeatureCommand

use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.

the class JunctionTypeSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.JunctionTypeSection_2, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fComboType = new Combo(parent, SWT.READ_ONLY);
    fComboType.setItems(fComboTypeItems);
    fComboType.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    getWidgetFactory().adapt(fComboType, true, true);
    fComboType.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject junction : getEObjects()) {
                if (isAlive(junction)) {
                    Command cmd = new EObjectFeatureCommand(Messages.JunctionTypeSection_3, junction, IArchimatePackage.Literals.JUNCTION__TYPE, fTypeValues[fComboType.getSelectionIndex()]);
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    });
    // Help ID
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) Command(org.eclipse.gef.commands.Command) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EObject(org.eclipse.emf.ecore.EObject) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 12 with EObjectFeatureCommand

use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.

the class AssociationRelationshipSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.AssociationRelationshipSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fButtonDirected = getWidgetFactory().createButton(parent, null, SWT.CHECK);
    fButtonDirected.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject relationship : getEObjects()) {
                if (isAlive(relationship)) {
                    Command cmd = new EObjectFeatureCommand(Messages.AssociationRelationshipSection_1, relationship, IArchimatePackage.Literals.ASSOCIATION_RELATIONSHIP__DIRECTED, fButtonDirected.getSelection());
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    });
    // Help ID
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) Command(org.eclipse.gef.commands.Command) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EObject(org.eclipse.emf.ecore.EObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 13 with EObjectFeatureCommand

use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.

the class BorderTypeSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.BorderTypeSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    // Combo
    fComboBorderType = new Combo(parent, SWT.READ_ONLY);
    getWidgetFactory().adapt(fComboBorderType, true, true);
    fComboBorderType.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject eObject : getEObjects()) {
                if (isAlive(eObject)) {
                    Command cmd = new EObjectFeatureCommand(Messages.BorderTypeSection_1, eObject, IArchimatePackage.Literals.BORDER_TYPE__BORDER_TYPE, fComboBorderType.getSelectionIndex());
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    });
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) Command(org.eclipse.gef.commands.Command) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EObject(org.eclipse.emf.ecore.EObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 14 with EObjectFeatureCommand

use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.

the class ViewpointAction method run.

@Override
public void run() {
    if (isChecked()) {
        CommandStack stack = part.getAdapter(CommandStack.class);
        stack.execute(new EObjectFeatureCommand(Messages.ViewpointAction_0, diagramModel, IArchimatePackage.Literals.ARCHIMATE_DIAGRAM_MODEL__VIEWPOINT, viewPoint.getID()));
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand)

Example 15 with EObjectFeatureCommand

use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.

the class EditorModelManagerTests method isModelDirty_Model.

@Test
public void isModelDirty_Model() {
    IArchimateModel model = editorModelManager.createNewModel();
    assertFalse(editorModelManager.isModelDirty(model));
    // Execute simple command on Command Stack
    Command cmd = new EObjectFeatureCommand("", model, IArchimatePackage.Literals.NAMEABLE__NAME, "Hello");
    CommandStack stack = (CommandStack) model.getAdapter(CommandStack.class);
    stack.execute(cmd);
    assertTrue(editorModelManager.isModelDirty(model));
    // Flush the Command Stack so we can close the model without a dialog asking us to save
    stack.flush();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) Command(org.eclipse.gef.commands.Command) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Aggregations

EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)27 Command (org.eclipse.gef.commands.Command)22 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)21 EObject (org.eclipse.emf.ecore.EObject)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 Combo (org.eclipse.swt.widgets.Combo)8 GridData (org.eclipse.swt.layout.GridData)6 StyledTextControl (com.archimatetool.editor.ui.components.StyledTextControl)5 CommandStack (org.eclipse.gef.commands.CommandStack)5 NonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)4 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)3 INameable (com.archimatetool.model.INameable)3 File (java.io.File)3 PropertySectionTextControl (com.archimatetool.editor.propertysections.PropertySectionTextControl)2 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)2 IOException (java.io.IOException)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 BorderColorCommand (com.archimatetool.editor.diagram.commands.BorderColorCommand)1