Search in sources :

Example 21 with EObjectFeatureCommand

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

the class AbstractECorePropertySection method createDocumentationControl.

/**
 * Create a Documentation control
 */
protected PropertySectionTextControl createDocumentationControl(Composite parent, String hint) {
    // Label
    Label label = createLabel(parent, Messages.AbstractECorePropertySection_2, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
    // CSS
    // $NON-NLS-1$ //$NON-NLS-2$
    label.setData("org.eclipse.e4.ui.css.CssClassName", "PropertiesDocumentationLabel");
    // Text
    StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
    styledTextControl.setMessage(hint);
    // CSS
    // $NON-NLS-1$ //$NON-NLS-2$
    styledTextControl.getControl().setData("org.eclipse.e4.ui.css.CssClassName", "PropertiesDocumentationText");
    PropertySectionTextControl textDoc = new PropertySectionTextControl(styledTextControl.getControl(), IArchimatePackage.Literals.DOCUMENTABLE__DOCUMENTATION) {

        @Override
        protected void textChanged(String oldText, String newText) {
            if (fObjects != null) {
                CompoundCommand result = new CompoundCommand(Messages.AbstractECorePropertySection_3);
                for (EObject eObject : fObjects) {
                    if (isAlive(eObject)) {
                        Command cmd = new EObjectFeatureCommand(Messages.AbstractECorePropertySection_3, eObject, IArchimatePackage.Literals.DOCUMENTABLE__DOCUMENTATION, newText);
                        if (cmd.canExecute()) {
                            result.add(cmd);
                        }
                    }
                }
                executeCommand(result.unwrap());
            }
        }
    };
    return textDoc;
}
Also used : StyledTextControl(com.archimatetool.editor.ui.components.StyledTextControl) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) 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) Label(org.eclipse.swt.widgets.Label) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)

Example 22 with EObjectFeatureCommand

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

the class AbstractECorePropertySection method createNameControl.

// ===========================================================================================================================
// WIDGET FACTORY METHODS
// ===========================================================================================================================
/**
 * Create a Name control
 */
protected PropertySectionTextControl createNameControl(Composite parent, String hint) {
    // Label
    Label label = createLabel(parent, Messages.AbstractECorePropertySection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    // CSS
    // $NON-NLS-1$ //$NON-NLS-2$
    label.setData("org.eclipse.e4.ui.css.CssClassName", "PropertiesNameLabel");
    // Text
    Text textControl = createSingleTextControl(parent, SWT.NONE);
    textControl.setMessage(hint);
    // CSS
    // $NON-NLS-1$ //$NON-NLS-2$
    textControl.setData("org.eclipse.e4.ui.css.CssClassName", "PropertiesNameText");
    PropertySectionTextControl textName = new PropertySectionTextControl(textControl, IArchimatePackage.Literals.NAMEABLE__NAME) {

        @Override
        protected void textChanged(String oldText, String newText) {
            if (fObjects != null) {
                CompoundCommand result = new NonNotifyingCompoundCommand(Messages.AbstractECorePropertySection_1);
                for (EObject eObject : fObjects) {
                    if (isAlive(eObject)) {
                        Command cmd = new // $NON-NLS-1$
                        EObjectFeatureCommand(// $NON-NLS-1$
                        Messages.AbstractECorePropertySection_1 + " " + oldText, // $NON-NLS-1$
                        eObject, IArchimatePackage.Literals.NAMEABLE__NAME, newText);
                        if (cmd.canExecute()) {
                            result.add(cmd);
                        }
                    }
                }
                executeCommand(result.unwrap());
            }
        }
    };
    return textName;
}
Also used : NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) 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) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)

Example 23 with EObjectFeatureCommand

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

the class AccessRelationshipSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.AccessRelationshipSection_4, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fComboType = new Combo(parent, SWT.READ_ONLY);
    getWidgetFactory().adapt(fComboType, true, true);
    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 relationship : getEObjects()) {
                if (isAlive(relationship)) {
                    Command cmd = new EObjectFeatureCommand(Messages.AccessRelationshipSection_5, relationship, IArchimatePackage.Literals.ACCESS_RELATIONSHIP__ACCESS_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 24 with EObjectFeatureCommand

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

the class ArchimateModelSection method createPurposeControl.

private void createPurposeControl(Composite parent) {
    // Label
    createLabel(parent, Messages.ArchimateModelSection_2, STANDARD_LABEL_WIDTH, SWT.NONE);
    // Text
    StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
    styledTextControl.setMessage(Messages.ArchimateModelSection_4);
    fTextPurpose = new PropertySectionTextControl(styledTextControl.getControl(), IArchimatePackage.Literals.ARCHIMATE_MODEL__PURPOSE) {

        @Override
        protected void textChanged(String oldText, String newText) {
            EObject model = getFirstSelectedObject();
            if (isAlive(model)) {
                Command cmd = new EObjectFeatureCommand(Messages.ArchimateModelSection_3, getFirstSelectedObject(), IArchimatePackage.Literals.ARCHIMATE_MODEL__PURPOSE, newText);
                if (cmd.canExecute()) {
                    executeCommand(cmd);
                }
            }
        }
    };
}
Also used : StyledTextControl(com.archimatetool.editor.ui.components.StyledTextControl) Command(org.eclipse.gef.commands.Command) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) EObject(org.eclipse.emf.ecore.EObject)

Example 25 with EObjectFeatureCommand

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

the class ViewpointSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.ViewpointSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fComboViewer = new ComboViewer(new Combo(parent, SWT.READ_ONLY | SWT.BORDER));
    fComboViewer.getCombo().setVisibleItemCount(12);
    fComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    getWidgetFactory().adapt(fComboViewer.getControl(), true, true);
    fComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (fIsRefreshing) {
                // A Viewer will get a selectionChanged event when setting it
                return;
            }
            IViewpoint viewPoint = (IViewpoint) ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (viewPoint != null) {
                CompoundCommand result = new CompoundCommand();
                for (EObject diagramModel : getEObjects()) {
                    if (isAlive(diagramModel)) {
                        Command cmd = new EObjectFeatureCommand(Messages.ViewpointSection_1, diagramModel, IArchimatePackage.Literals.ARCHIMATE_DIAGRAM_MODEL__VIEWPOINT, viewPoint.getID());
                        if (cmd.canExecute()) {
                            result.add(cmd);
                        }
                    }
                }
                executeCommand(result.unwrap());
            }
        }
    });
    fComboViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return ViewpointManager.INSTANCE.getAllViewpoints().toArray();
        }
    });
    fComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((IViewpoint) element).getName();
        }
    });
    // $NON-NLS-1$
    fComboViewer.setInput("");
    // Help ID
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Viewer(org.eclipse.jface.viewers.Viewer) ComboViewer(org.eclipse.jface.viewers.ComboViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ComboViewer(org.eclipse.jface.viewers.ComboViewer) 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) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) EObject(org.eclipse.emf.ecore.EObject) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

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