Search in sources :

Example 6 with IDiagramModelObject

use of com.archimatetool.model.IDiagramModelObject 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 7 with IDiagramModelObject

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

the class FillColorSection method update.

@Override
protected void update() {
    IDiagramModelObject lastSelected = (IDiagramModelObject) getFirstSelectedObject();
    String colorValue = lastSelected.getFillColor();
    RGB rgb = ColorFactory.convertStringToRGB(colorValue);
    if (rgb == null) {
        rgb = ColorFactory.getDefaultFillColor(lastSelected).getRGB();
    }
    fColorChooser.setColorValue(rgb);
    fColorChooser.setEnabled(!isLocked(lastSelected));
    // If user pref is to save the color 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.getDefaultFillColor(lastSelected).getRGB());
    }
    fColorChooser.setIsDefaultColor(isDefaultColor);
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) RGB(org.eclipse.swt.graphics.RGB)

Example 8 with IDiagramModelObject

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

the class CopySnapshot method createSnapshotObjects.

/*
     * Make snapshot copies of top level objects
     */
private List<IDiagramModelObject> createSnapshotObjects(List<IDiagramModelObject> objectsToCopy) {
    List<IDiagramModelObject> topLevelObjects = new ArrayList<IDiagramModelObject>();
    for (IDiagramModelObject dmo : objectsToCopy) {
        IDiagramModelObject snapshotObject = createSnapshotObject(dmo);
        topLevelObjects.add(snapshotObject);
    }
    return topLevelObjects;
}
Also used : ArrayList(java.util.ArrayList) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject)

Example 9 with IDiagramModelObject

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

the class CopySnapshot method createSnapshotObject.

/*
     * Make snapshot copy of object
     */
private IDiagramModelObject createSnapshotObject(IDiagramModelObject originalObject) {
    IDiagramModelObject snapshotObject = (IDiagramModelObject) originalObject.getCopy();
    // Add to mapping
    fOriginalToSnapshotComponentsMapping.put(originalObject, snapshotObject);
    // Object is Container, so recurse
    if (snapshotObject instanceof IDiagramModelContainer) {
        for (IDiagramModelObject child : ((IDiagramModelContainer) originalObject).getChildren()) {
            IDiagramModelObject dmo = createSnapshotObject(child);
            ((IDiagramModelContainer) snapshotObject).getChildren().add(dmo);
        }
    }
    return snapshotObject;
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Example 10 with IDiagramModelObject

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

the class CopySnapshot method translateToAbsolute.

/**
 * Translate an objects x,y position to absolute co-ordinates
 * @param object
 * @param pt
 */
private void translateToAbsolute(IDiagramModelObject object, Point pt) {
    if (object.eContainer() instanceof IDiagramModelContainer && !(object.eContainer() instanceof IDiagramModel)) {
        IDiagramModelObject parent = (IDiagramModelObject) object.eContainer();
        pt.performTranslate(parent.getBounds().getX(), parent.getBounds().getY());
        translateToAbsolute(parent, pt);
    }
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Aggregations

IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)51 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)12 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)12 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)10 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 Test (org.junit.Test)10 IArchimateElement (com.archimatetool.model.IArchimateElement)9 Dimension (org.eclipse.draw2d.geometry.Dimension)9 IDiagramModel (com.archimatetool.model.IDiagramModel)8 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)7 IBounds (com.archimatetool.model.IBounds)6 Command (org.eclipse.gef.commands.Command)6 ILockable (com.archimatetool.model.ILockable)5 ArrayList (java.util.ArrayList)5 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 EObject (org.eclipse.emf.ecore.EObject)4 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)4 IArchimateModel (com.archimatetool.model.IArchimateModel)3 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)3 ILineObject (com.archimatetool.model.ILineObject)3