Search in sources :

Example 6 with EObjectFeatureCommand

use of com.archimatetool.editor.model.commands.EObjectFeatureCommand 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);
    styledTextControl.setMessage(Messages.TextContentSection_2);
    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());
        }
    };
    // 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)

Example 7 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);
    fCanvas = new Canvas(parent, SWT.BORDER);
    getWidgetFactory().adapt(fCanvas);
    GridData gd = new GridData(SWT.NONE, SWT.NONE, false, false);
    gd.widthHint = IMAGE_SIZE;
    gd.heightHint = IMAGE_SIZE;
    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 (fImageButton.isEnabled()) {
                chooseImage();
            }
        }
    });
    fCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (fImage != null) {
                e.gc.setAntialias(SWT.ON);
                e.gc.setInterpolation(SWT.HIGH);
                Rectangle imageBounds = fImage.getBounds();
                Rectangle newSize = ImageFactory.getScaledImageSize(fImage, IMAGE_SIZE);
                // Centre the image
                int x = (IMAGE_SIZE - newSize.width) / 2;
                int y = (IMAGE_SIZE - newSize.height) / 2;
                e.gc.drawImage(fImage, 0, 0, imageBounds.width, imageBounds.height, x, y, newSize.width, newSize.height);
            }
        }
    });
    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[] && fImageButton.isEnabled()) {
                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);
    getWidgetFactory().adapt(fComboPosition, true, true);
    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, IArchimatePackage.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) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) Combo(org.eclipse.swt.widgets.Combo) DisposeEvent(org.eclipse.swt.events.DisposeEvent) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) 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) SelectionEvent(org.eclipse.swt.events.SelectionEvent) 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 8 with EObjectFeatureCommand

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

the class AbstractImporter method importImageBytes.

/**
 * Import the image bytes from the imported model's IDiagramModelImageProvider to the target model's IDiagramModelImageProvider
 */
protected void importImageBytes(IDiagramModelImageProvider importedObject, IDiagramModelImageProvider targetObject) throws IOException {
    String importedImagePath = importedObject.getImagePath();
    if (importedImagePath != null) {
        IArchiveManager importedArchiveManager = (IArchiveManager) getImportedModel().getAdapter(IArchiveManager.class);
        IArchiveManager targetArchiveManager = (IArchiveManager) getTargetModel().getAdapter(IArchiveManager.class);
        importedImagePath = targetArchiveManager.copyImageBytes(importedArchiveManager, importedImagePath);
        addCommand(new EObjectFeatureCommand(null, targetObject, IArchimatePackage.Literals.DIAGRAM_MODEL_IMAGE_PROVIDER__IMAGE_PATH, importedImagePath));
    }
}
Also used : EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) IArchiveManager(com.archimatetool.editor.model.IArchiveManager)

Example 9 with EObjectFeatureCommand

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

the class HintContentSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.HintContentSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    Text text = createSingleTextControl(parent, SWT.NONE);
    text.setMessage(Messages.HintContentSection_2);
    fTextTitleControl = new PropertySectionTextControl(text, ICanvasPackage.Literals.HINT_PROVIDER__HINT_TITLE) {

        @Override
        protected void textChanged(String oldText, String newText) {
            CompoundCommand result = new CompoundCommand();
            for (EObject provider : getEObjects()) {
                if (isAlive(provider)) {
                    Command cmd = new EObjectFeatureCommand(Messages.HintContentSection_1, provider, ICanvasPackage.Literals.HINT_PROVIDER__HINT_TITLE, newText);
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    };
    createLabel(parent, Messages.HintContentSection_3, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
    StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
    styledTextControl.setMessage(Messages.HintContentSection_5);
    fTextContentControl = new PropertySectionTextControl(styledTextControl.getControl(), ICanvasPackage.Literals.HINT_PROVIDER__HINT_CONTENT) {

        @Override
        protected void textChanged(String oldText, String newText) {
            CompoundCommand result = new CompoundCommand();
            for (EObject provider : getEObjects()) {
                if (isAlive(provider)) {
                    Command cmd = new EObjectFeatureCommand(Messages.HintContentSection_4, provider, ICanvasPackage.Literals.HINT_PROVIDER__HINT_CONTENT, newText);
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    };
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fTextContentControl.getTextControl(), 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) StyledTextControl(com.archimatetool.editor.ui.components.StyledTextControl) EObject(org.eclipse.emf.ecore.EObject) Text(org.eclipse.swt.widgets.Text) PropertySectionTextControl(com.archimatetool.editor.propertysections.PropertySectionTextControl) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 10 with EObjectFeatureCommand

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

the class NotesSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.NotesSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
    StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
    styledTextControl.setMessage(Messages.NotesSection_2);
    fTextNotesControl = new PropertySectionTextControl(styledTextControl.getControl(), ICanvasPackage.Literals.NOTES_CONTENT__NOTES) {

        @Override
        protected void textChanged(String oldText, String newText) {
            CompoundCommand result = new CompoundCommand();
            for (EObject notesContent : getEObjects()) {
                if (isAlive(notesContent)) {
                    Command cmd = new EObjectFeatureCommand(Messages.NotesSection_1, notesContent, ICanvasPackage.Literals.NOTES_CONTENT__NOTES, newText);
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    };
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fTextNotesControl.getTextControl(), HELP_ID);
}
Also used : StyledTextControl(com.archimatetool.editor.ui.components.StyledTextControl) 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) PropertySectionTextControl(com.archimatetool.editor.propertysections.PropertySectionTextControl) 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