Search in sources :

Example 16 with EObjectFeatureCommand

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

the class DiagramModelImageSection method clearImage.

protected void clearImage() {
    CompoundCommand result = new CompoundCommand();
    for (EObject dmo : getEObjects()) {
        if (isAlive(dmo)) {
            Command cmd = new EObjectFeatureCommand(Messages.DiagramModelImageSection_4, dmo, IArchimatePackage.Literals.DIAGRAM_MODEL_IMAGE_PROVIDER__IMAGE_PATH, null);
            if (cmd.canExecute()) {
                result.add(cmd);
            }
        }
    }
    executeCommand(result.unwrap());
}
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) EObject(org.eclipse.emf.ecore.EObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 17 with EObjectFeatureCommand

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

the class DiagramEditorFindReplaceProvider method doRenameCommand.

void doRenameCommand(EditPart editPart, String newName) {
    INameable object = (INameable) editPart.getModel();
    CommandStack stack = (CommandStack) ((IAdapter) object).getAdapter(CommandStack.class);
    if (stack != null) {
        stack.execute(new EObjectFeatureCommand(NLS.bind(Messages.DiagramEditorFindReplaceProvider_0, object.getName()), object, IArchimatePackage.Literals.NAMEABLE__NAME, newName));
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) INameable(com.archimatetool.model.INameable)

Example 18 with EObjectFeatureCommand

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

the class NoteSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.NoteSection_3, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    // Combo
    fComboBorderType = new Combo(parent, SWT.READ_ONLY);
    fComboBorderType.setItems(comboItems);
    fComboBorderType.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject note : getEObjects()) {
                if (isAlive(note)) {
                    Command cmd = new EObjectFeatureCommand(Messages.NoteSection_4, note, IArchimatePackage.Literals.DIAGRAM_MODEL_NOTE__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 19 with EObjectFeatureCommand

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

the class IconSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.IconSection_9, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
    final int canvasSize = IIconic.MAX_IMAGE_SIZE;
    fCanvas = new Canvas(parent, SWT.BORDER);
    getWidgetFactory().adapt(fCanvas);
    GridData gd = new GridData(SWT.NONE, SWT.NONE, false, false);
    gd.widthHint = canvasSize;
    gd.heightHint = canvasSize;
    fCanvas.setLayoutData(gd);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    fCanvas.setLayout(layout);
    fCanvas.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            disposeImage();
        }
    });
    fCanvas.addListener(SWT.MouseDoubleClick, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (!isLocked(getFirstSelectedObject())) {
                chooseImage();
            }
        }
    });
    fCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (fImage != null) {
                Rectangle bounds = fImage.getBounds();
                int x = (canvasSize - bounds.width) / 2;
                int y = (canvasSize - bounds.height) / 2;
                e.gc.drawImage(fImage, x, y);
            }
        }
    });
    String tooltip = Messages.IconSection_10;
    fCanvas.setToolTipText(tooltip);
    DropTarget target = new DropTarget(fCanvas, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT);
    target.setTransfer(new Transfer[] { FileTransfer.getInstance() });
    target.addDropListener(new DropTargetAdapter() {

        @Override
        public void drop(DropTargetEvent event) {
            if (event.data instanceof String[]) {
                if (!isLocked(getFirstSelectedObject())) {
                    File file = new File(((String[]) event.data)[0]);
                    setImage(file);
                }
            }
        }
    });
    // Image Button
    createImageButton(parent);
    // Position
    createLabel(parent, Messages.IconSection_11, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fComboPosition = new Combo(parent, SWT.READ_ONLY);
    fComboPosition.setItems(fComboPositionItems);
    gd = new GridData(SWT.NONE, SWT.NONE, false, false);
    fComboPosition.setLayoutData(gd);
    fComboPosition.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject iconic : getEObjects()) {
                if (isAlive(iconic)) {
                    Command cmd = new EObjectFeatureCommand(Messages.IconSection_12, iconic, ICanvasPackage.Literals.ICONIC__IMAGE_POSITION, fComboPosition.getSelectionIndex());
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    });
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) PaintListener(org.eclipse.swt.events.PaintListener) DisposeListener(org.eclipse.swt.events.DisposeListener) Listener(org.eclipse.swt.widgets.Listener) Rectangle(org.eclipse.swt.graphics.Rectangle) Combo(org.eclipse.swt.widgets.Combo) DisposeEvent(org.eclipse.swt.events.DisposeEvent) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) GridLayout(org.eclipse.swt.layout.GridLayout) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) EObject(org.eclipse.emf.ecore.EObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) Command(org.eclipse.gef.commands.Command) GridData(org.eclipse.swt.layout.GridData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Event(org.eclipse.swt.widgets.Event) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DropTarget(org.eclipse.swt.dnd.DropTarget) File(java.io.File)

Example 20 with EObjectFeatureCommand

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

the class InfluenceRelationshipSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.InfluenceRelationshipSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    Text text = createSingleTextControl(parent, SWT.NONE);
    text.setMessage(Messages.InfluenceRelationshipSection_2);
    fTextStrength = new PropertySectionTextControl(text, IArchimatePackage.Literals.INFLUENCE_RELATIONSHIP__STRENGTH) {

        @Override
        protected void textChanged(String oldText, String newText) {
            CompoundCommand result = new CompoundCommand();
            for (EObject relationship : getEObjects()) {
                if (isAlive(relationship)) {
                    Command cmd = new EObjectFeatureCommand(Messages.InfluenceRelationshipSection_1, relationship, IArchimatePackage.Literals.INFLUENCE_RELATIONSHIP__STRENGTH, newText);
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    };
    // Help ID
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : Command(org.eclipse.gef.commands.Command) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) EObject(org.eclipse.emf.ecore.EObject) Text(org.eclipse.swt.widgets.Text) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

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