Search in sources :

Example 21 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand 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));
    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 22 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.

the class DiagramModelConnectionSection method createRouterTypeControl.

private void createRouterTypeControl(Composite parent) {
    // Label
    createLabel(parent, Messages.DiagramModelConnectionSection_0, ITabbedLayoutConstants.BIG_LABEL_WIDTH, SWT.CENTER);
    // Combo
    fComboRouterType = new Combo(parent, SWT.READ_ONLY);
    fComboRouterType.setItems(comboItems);
    fComboRouterType.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject dm : getEObjects()) {
                if (isAlive(dm)) {
                    Command cmd = new ConnectionRouterTypeCommand((IDiagramModel) dm, ConnectionRouterAction.CONNECTION_ROUTER_TYPES.get(fComboRouterType.getSelectionIndex()));
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    });
    GridData gd = new GridData(SWT.NONE, SWT.NONE, true, false);
    gd.minimumWidth = ITabbedLayoutConstants.COMBO_WIDTH;
    fComboRouterType.setLayoutData(gd);
}
Also used : ConnectionRouterTypeCommand(com.archimatetool.editor.diagram.commands.ConnectionRouterTypeCommand) ConnectionRouterTypeCommand(com.archimatetool.editor.diagram.commands.ConnectionRouterTypeCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) IDiagramModel(com.archimatetool.model.IDiagramModel) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EObject(org.eclipse.emf.ecore.EObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) Combo(org.eclipse.swt.widgets.Combo) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 23 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.

the class DiagramModelImageSection method setImage.

protected void setImage(Object selected) {
    String path = null;
    try {
        // User selected a file
        if (selected instanceof File) {
            File file = (File) selected;
            if (!file.exists() || !file.canRead()) {
                return;
            }
            IArchiveManager archiveManager = (IArchiveManager) ((IAdapter) getFirstSelectedObject()).getAdapter(IArchiveManager.class);
            path = archiveManager.addImageFromFile(file);
        } else // User selected a Gallery image path
        if (selected instanceof String) {
            path = (String) selected;
        } else // User selected nothing
        {
            return;
        }
    } catch (IOException ex) {
        ex.printStackTrace();
        MessageDialog.openError(getPart().getSite().getShell(), Messages.DiagramModelImageSection_5, Messages.DiagramModelImageSection_6);
        return;
    }
    CompoundCommand result = new CompoundCommand();
    for (EObject dmo : getEObjects()) {
        if (isAlive(dmo)) {
            Command cmd = new EObjectFeatureCommand(Messages.DiagramModelImageSection_7, dmo, IArchimatePackage.Literals.DIAGRAM_MODEL_IMAGE_PROVIDER__IMAGE_PATH, path);
            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) IOException(java.io.IOException) IArchiveManager(com.archimatetool.editor.model.IArchiveManager) File(java.io.File) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 24 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.

the class TextAlignmentSection method createControls.

@Override
protected void createControls(final Composite parent) {
    SelectionAdapter adapter = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            for (int i = 0; i < fAlignmentButtons.length; i++) {
                // Select/deselects
                fAlignmentButtons[i].setSelection(e.widget == fAlignmentButtons[i]);
                // Command
                if (fAlignmentButtons[i] == e.widget) {
                    int alignment = (Integer) fAlignmentButtons[i].getData();
                    CompoundCommand result = new CompoundCommand();
                    for (EObject textAlignment : getEObjects()) {
                        if (((ITextAlignment) textAlignment).getTextAlignment() != alignment && isAlive(textAlignment)) {
                            Command cmd = new TextAlignmentCommand((ITextAlignment) textAlignment, alignment);
                            if (cmd.canExecute()) {
                                result.add(cmd);
                            }
                        }
                    }
                    executeCommand(result.unwrap());
                }
            }
        }
    };
    createLabel(parent, Messages.TextAlignmentSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    Composite client = createComposite(parent, 3);
    for (int i = 0; i < fAlignmentButtons.length; i++) {
        fAlignmentButtons[i] = new Button(client, SWT.TOGGLE | SWT.FLAT);
        // Need to do it this way for Mac
        getWidgetFactory().adapt(fAlignmentButtons[i], true, true);
        fAlignmentButtons[i].addSelectionListener(adapter);
    }
    // Left Button
    fAlignmentButtons[0].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_LEFT));
    fAlignmentButtons[0].setData(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    // Center Button
    fAlignmentButtons[1].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_CENTER));
    fAlignmentButtons[1].setData(ITextAlignment.TEXT_ALIGNMENT_CENTER);
    // Right Button
    fAlignmentButtons[2].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_RIGHT));
    fAlignmentButtons[2].setData(ITextAlignment.TEXT_ALIGNMENT_RIGHT);
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : TextAlignmentCommand(com.archimatetool.editor.diagram.commands.TextAlignmentCommand) ITextAlignment(com.archimatetool.model.ITextAlignment) Composite(org.eclipse.swt.widgets.Composite) TextAlignmentCommand(com.archimatetool.editor.diagram.commands.TextAlignmentCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) Button(org.eclipse.swt.widgets.Button) 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 25 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.

the class TextContentSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.TextContentSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
    StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
    fTextContentControl = new PropertySectionTextControl(styledTextControl.getControl(), IArchimatePackage.Literals.TEXT_CONTENT__CONTENT) {

        @Override
        protected void textChanged(String oldText, String newText) {
            CompoundCommand result = new CompoundCommand();
            for (EObject textContent : getEObjects()) {
                if (isAlive(textContent)) {
                    Command cmd = new EObjectFeatureCommand(Messages.TextContentSection_1, textContent, IArchimatePackage.Literals.TEXT_CONTENT__CONTENT, newText);
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    };
    fTextContentControl.setHint(Messages.TextContentSection_2);
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fTextContentControl.getTextControl(), HELP_ID);
}
Also used : StyledTextControl(com.archimatetool.editor.ui.components.StyledTextControl) 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) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

CompoundCommand (org.eclipse.gef.commands.CompoundCommand)148 Command (org.eclipse.gef.commands.Command)63 EObject (org.eclipse.emf.ecore.EObject)28 ArrayList (java.util.ArrayList)23 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)22 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)17 List (java.util.List)16 EditPart (org.eclipse.gef.EditPart)16 IElementParameter (org.talend.core.model.process.IElementParameter)16 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)15 Node (org.talend.designer.core.ui.editor.nodes.Node)15 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)14 Point (org.eclipse.draw2d.geometry.Point)14 Rectangle (org.eclipse.draw2d.geometry.Rectangle)14 INode (org.talend.core.model.process.INode)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 RepositoryNode (org.talend.repository.model.RepositoryNode)13 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 ConnectionItem (org.talend.core.model.properties.ConnectionItem)12 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11