Search in sources :

Example 1 with ILineObject

use of com.archimatetool.model.ILineObject in project archi by archimatetool.

the class LineColorSection method update.

@Override
protected void update() {
    ILineObject lineObject = (ILineObject) getFirstSelectedObject();
    String colorValue = lineObject.getLineColor();
    RGB rgb = ColorFactory.convertStringToRGB(colorValue);
    if (rgb == null) {
        rgb = ColorFactory.getDefaultLineColor(lineObject).getRGB();
    }
    fColorChooser.setColorValue(rgb);
    // Locked
    boolean enabled = !isLocked(lineObject);
    fColorChooser.setEnabled(enabled);
    if (!enabled) {
        return;
    }
    // If the user pref is to save the color in the file, then it's a different meaning of default
    boolean isDefaultColor = (colorValue == null);
    if (Preferences.STORE.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) {
        isDefaultColor = (colorValue != null) && rgb.equals(ColorFactory.getDefaultLineColor(lineObject).getRGB());
    }
    fColorChooser.setIsDefaultColor(isDefaultColor);
    // If this is an element line disable some things
    if (lineObject instanceof IDiagramModelObject) {
        boolean deriveElementLineColor = Preferences.STORE.getBoolean(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR);
        fColorChooser.setDoShowColorImage(!deriveElementLineColor);
        fColorChooser.getColorButton().setEnabled(!deriveElementLineColor);
        fColorChooser.setDoShowDefaultMenuItem(!deriveElementLineColor);
    } else {
        fColorChooser.setDoShowColorImage(true);
        fColorChooser.getColorButton().setEnabled(true);
        fColorChooser.setDoShowDefaultMenuItem(true);
    }
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) RGB(org.eclipse.swt.graphics.RGB) ILineObject(com.archimatetool.model.ILineObject)

Example 2 with ILineObject

use of com.archimatetool.model.ILineObject in project archi by archimatetool.

the class FormatPainterTool method createCommand.

protected CompoundCommand createCommand(PaintFormat pf, IDiagramModelComponent targetComponent) {
    CompoundCommand result = new CompoundCommand(Messages.FormatPainterTool_0);
    // IFontAttribute
    if (pf.getSourceComponent() instanceof IFontAttribute && targetComponent instanceof IFontAttribute) {
        IFontAttribute source = (IFontAttribute) pf.getSourceComponent();
        IFontAttribute target = (IFontAttribute) targetComponent;
        Command cmd = new FontStyleCommand(target, source.getFont());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
        cmd = new FontColorCommand(target, source.getFontColor());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // ILineObject
    if (pf.getSourceComponent() instanceof ILineObject && targetComponent instanceof ILineObject) {
        ILineObject source = (ILineObject) pf.getSourceComponent();
        ILineObject target = (ILineObject) targetComponent;
        Command cmd = new LineColorCommand(target, source.getLineColor());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
        cmd = new LineWidthCommand(target, source.getLineWidth());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // IBorderObject
    if (pf.getSourceComponent() instanceof IBorderObject && targetComponent instanceof IBorderObject) {
        IBorderObject source = (IBorderObject) pf.getSourceComponent();
        IBorderObject target = (IBorderObject) targetComponent;
        Command cmd = new BorderColorCommand(target, source.getBorderColor());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // ITextPosition
    if (pf.getSourceComponent() instanceof ITextPosition && targetComponent instanceof ITextPosition) {
        ITextPosition source = (ITextPosition) pf.getSourceComponent();
        ITextPosition target = (ITextPosition) targetComponent;
        Command cmd = new TextPositionCommand(target, source.getTextPosition());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // ITextAlignment
    if (pf.getSourceComponent() instanceof ITextAlignment && targetComponent instanceof ITextAlignment) {
        ITextAlignment source = (ITextAlignment) pf.getSourceComponent();
        ITextAlignment target = (ITextAlignment) targetComponent;
        Command cmd = new TextAlignmentCommand(target, source.getTextAlignment());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // IDiagramModelObject
    if (pf.getSourceComponent() instanceof IDiagramModelObject && targetComponent instanceof IDiagramModelObject) {
        IDiagramModelObject source = (IDiagramModelObject) pf.getSourceComponent();
        IDiagramModelObject target = (IDiagramModelObject) targetComponent;
        // Source fill colour is null which is "default"
        String fillColorString = source.getFillColor();
        if (fillColorString == null) {
            fillColorString = ColorFactory.convertColorToString(ColorFactory.getDefaultFillColor(source));
        }
        Command cmd = new FillColorCommand(target, fillColorString);
        if (cmd.canExecute()) {
            result.add(cmd);
        }
        // Alpha opacity
        cmd = new DiagramModelObjectAlphaCommand(target, source.getAlpha());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // IDiagramModelConnection
    if (pf.getSourceComponent() instanceof IDiagramModelConnection && targetComponent instanceof IDiagramModelConnection) {
        IDiagramModelConnection source = (IDiagramModelConnection) pf.getSourceComponent();
        IDiagramModelConnection target = (IDiagramModelConnection) targetComponent;
        // Connection text position
        Command cmd = new ConnectionTextPositionCommand(target, source.getTextPosition());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    return result;
}
Also used : TextAlignmentCommand(com.archimatetool.editor.diagram.commands.TextAlignmentCommand) LineColorCommand(com.archimatetool.editor.diagram.commands.LineColorCommand) ITextPosition(com.archimatetool.model.ITextPosition) FillColorCommand(com.archimatetool.editor.diagram.commands.FillColorCommand) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) DiagramModelObjectAlphaCommand(com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand) ILineObject(com.archimatetool.model.ILineObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) BorderColorCommand(com.archimatetool.editor.diagram.commands.BorderColorCommand) IBorderObject(com.archimatetool.model.IBorderObject) FontColorCommand(com.archimatetool.editor.diagram.commands.FontColorCommand) ITextAlignment(com.archimatetool.model.ITextAlignment) FontStyleCommand(com.archimatetool.editor.diagram.commands.FontStyleCommand) DiagramModelObjectAlphaCommand(com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand) BorderColorCommand(com.archimatetool.editor.diagram.commands.BorderColorCommand) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) LineWidthCommand(com.archimatetool.editor.diagram.commands.LineWidthCommand) FontColorCommand(com.archimatetool.editor.diagram.commands.FontColorCommand) TextAlignmentCommand(com.archimatetool.editor.diagram.commands.TextAlignmentCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) FillColorCommand(com.archimatetool.editor.diagram.commands.FillColorCommand) LineColorCommand(com.archimatetool.editor.diagram.commands.LineColorCommand) Command(org.eclipse.gef.commands.Command) IFontAttribute(com.archimatetool.model.IFontAttribute) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) LineWidthCommand(com.archimatetool.editor.diagram.commands.LineWidthCommand) FontStyleCommand(com.archimatetool.editor.diagram.commands.FontStyleCommand) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand)

Example 3 with ILineObject

use of com.archimatetool.model.ILineObject in project archi by archimatetool.

the class ColorFactory method setDefaultColors.

/**
 * @param component
 * Set user default colors as set in prefs for a model object
 */
public static void setDefaultColors(IDiagramModelComponent component) {
    // If user Prefs is to *not* save default colours in file
    if (!Preferences.STORE.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) {
        return;
    }
    // Fill color
    if (component instanceof IDiagramModelObject) {
        IDiagramModelObject dmo = (IDiagramModelObject) component;
        Color fillColor = getDefaultFillColor(dmo);
        if (fillColor != null) {
            dmo.setFillColor(convertColorToString(fillColor));
        }
    }
    // Line color
    if (component instanceof ILineObject) {
        ILineObject lo = (ILineObject) component;
        Color lineColor = getDefaultLineColor(lo);
        if (lineColor != null) {
            lo.setLineColor(convertColorToString(lineColor));
        }
    }
}
Also used : Color(org.eclipse.swt.graphics.Color) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) ILineObject(com.archimatetool.model.ILineObject)

Example 4 with ILineObject

use of com.archimatetool.model.ILineObject in project archi by archimatetool.

the class DiagramConnectionSection method createLineWidthComboControl.

private void createLineWidthComboControl(Composite parent) {
    createLabel(parent, Messages.DiagramConnectionSection_7, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fComboLineWidth = new Combo(parent, SWT.READ_ONLY);
    fComboLineWidth.setItems(comboLineWidthItems);
    GridData gd = new GridData(SWT.NONE, SWT.NONE, true, false);
    gd.minimumWidth = ITabbedLayoutConstants.COMBO_WIDTH;
    fComboLineWidth.setLayoutData(gd);
    fComboLineWidth.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject connection : getEObjects()) {
                if (isAlive(connection)) {
                    Command cmd = new LineWidthCommand((ILineObject) connection, fComboLineWidth.getSelectionIndex() + 1);
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    });
}
Also used : LineWidthCommand(com.archimatetool.editor.diagram.commands.LineWidthCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand) Command(org.eclipse.gef.commands.Command) 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) LineWidthCommand(com.archimatetool.editor.diagram.commands.LineWidthCommand) ILineObject(com.archimatetool.model.ILineObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 5 with ILineObject

use of com.archimatetool.model.ILineObject in project archi by archimatetool.

the class ConnectionLineWidthAction method run.

@Override
public void run() {
    List<?> selection = getSelectedObjects();
    ILineObject model = (ILineObject) getFirstValidSelectedModelObject(selection);
    if (model == null) {
        return;
    }
    // Set default line width on first selected connection
    int lineWidth = model.getLineWidth();
    LineWidthDialog dialog = new LineWidthDialog(getWorkbenchPart().getSite().getShell(), lineWidth);
    if (dialog.open() == Window.OK) {
        execute(createCommand(selection, dialog.getLineWidth()));
    }
}
Also used : ILineObject(com.archimatetool.model.ILineObject)

Aggregations

ILineObject (com.archimatetool.model.ILineObject)6 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)3 ConnectionTextPositionCommand (com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand)2 LineWidthCommand (com.archimatetool.editor.diagram.commands.LineWidthCommand)2 Command (org.eclipse.gef.commands.Command)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 RGB (org.eclipse.swt.graphics.RGB)2 BorderColorCommand (com.archimatetool.editor.diagram.commands.BorderColorCommand)1 DiagramModelObjectAlphaCommand (com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand)1 FillColorCommand (com.archimatetool.editor.diagram.commands.FillColorCommand)1 FontColorCommand (com.archimatetool.editor.diagram.commands.FontColorCommand)1 FontStyleCommand (com.archimatetool.editor.diagram.commands.FontStyleCommand)1 LineColorCommand (com.archimatetool.editor.diagram.commands.LineColorCommand)1 TextAlignmentCommand (com.archimatetool.editor.diagram.commands.TextAlignmentCommand)1 TextPositionCommand (com.archimatetool.editor.diagram.commands.TextPositionCommand)1 IBorderObject (com.archimatetool.model.IBorderObject)1 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)1 IFontAttribute (com.archimatetool.model.IFontAttribute)1 ITextAlignment (com.archimatetool.model.ITextAlignment)1 ITextPosition (com.archimatetool.model.ITextPosition)1