Search in sources :

Example 1 with NodeImageExtension

use of org.palladiosimulator.editors.sirius.custom.style.rotatable.NodeImageExtension in project Palladio-Editors-Sirius by PalladioSimulator.

the class RotatableSVGWorkspaceImageFigure method refreshFigure.

/**
 * Refresh the figure.
 *
 * @param imageStyle
 *            the image associated to the figure
 */
public void refreshFigure(final CustomStyle imageStyle) {
    boolean found = false;
    Iterator<NodeImageExtension> iterator = ExtensionActivator.getDefault().getImageExtensions().iterator();
    while (iterator.hasNext() && !found) {
        NodeImageExtension desc = (NodeImageExtension) iterator.next();
        if (imageStyle.getId() != null && imageStyle.getId().equals(desc.getId())) {
            if (currentImgPath != null) {
                if (currentImgPath.equals(bottomImgPath)) {
                    currentImgPath = desc.getBottomImage();
                } else if (currentImgPath.equals(leftImgPath)) {
                    currentImgPath = desc.getLeftImage();
                } else if (currentImgPath.equals(rightImgPath)) {
                    currentImgPath = desc.getRightImage();
                } else {
                    currentImgPath = desc.getTopImage();
                }
            } else {
                currentImgPath = desc.getTopImage();
            }
            topImgPath = desc.getTopImage();
            bottomImgPath = desc.getBottomImage();
            leftImgPath = desc.getLeftImage();
            rightImgPath = desc.getRightImage();
            found = true;
        }
    }
    refreshFigure();
    this.repaint();
}
Also used : NodeImageExtension(org.palladiosimulator.editors.sirius.custom.style.rotatable.NodeImageExtension)

Example 2 with NodeImageExtension

use of org.palladiosimulator.editors.sirius.custom.style.rotatable.NodeImageExtension in project Palladio-Editors-Sirius by PalladioSimulator.

the class ExtensionActivator method addImageExtensions.

/**
 * add image extensions.
 */
private void addImageExtensions() {
    imageExtensions = new ArrayList<NodeImageExtension>();
    IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(NodeImageExtension.IMAGE_EXTENSION_ID);
    for (IConfigurationElement configElement : configurationElements) {
        String id = configElement.getAttribute(NodeImageExtension.ID);
        String topImage = configElement.getAttribute(NodeImageExtension.TOP_IMAGE);
        String bottomImage = configElement.getAttribute(NodeImageExtension.BOTTOM_IMAGE);
        String leftImage = configElement.getAttribute(NodeImageExtension.LEFT_IMAGE);
        String rightImage = configElement.getAttribute(NodeImageExtension.RIGHT_IMAGE);
        imageExtensions.add(new NodeImageExtension(id, topImage, bottomImage, leftImage, rightImage));
    }
}
Also used : NodeImageExtension(org.palladiosimulator.editors.sirius.custom.style.rotatable.NodeImageExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 3 with NodeImageExtension

use of org.palladiosimulator.editors.sirius.custom.style.rotatable.NodeImageExtension in project Palladio-Editors-Sirius by PalladioSimulator.

the class AbstractRotatableImageEditPart method createNodeShape.

/**
 * @generated
 */
protected IFigure createNodeShape() {
    CustomStyle imageStyle = (CustomStyle) resolveSemanticElement();
    NodeImageExtension imageExtension = ExtensionActivator.getDefault().getBestImageExtension(imageStyle.getId());
    primaryShape = new RotatableSVGWorkspaceImageFigure(imageExtension.getMode(), imageExtension.getTopImage(), imageExtension.getLeftImage(), imageExtension.getBottomImage(), imageExtension.getRightImage());
    listener = new RotatableEditPartListener(this);
    primaryShape.addFigureListener(listener);
    EditPart parentEditPart = getParent();
    if (parentEditPart instanceof GraphicalEditPart) {
        GraphicalEditPart parentGraphicalEditPart = (GraphicalEditPart) parentEditPart;
        NodeListener dEdgeEditPartListener = new PropagateFigureListenerAtConnectionFigure(listener);
        parentGraphicalEditPart.addNodeListener(dEdgeEditPartListener);
    }
    return primaryShape;
}
Also used : PropagateFigureListenerAtConnectionFigure(org.palladiosimulator.editors.sirius.custom.style.rotatable.editPart.listener.PropagateFigureListenerAtConnectionFigure) RotatableSVGWorkspaceImageFigure(org.palladiosimulator.editors.sirius.custom.style.rotatable.figure.RotatableSVGWorkspaceImageFigure) NodeListener(org.eclipse.gef.NodeListener) AbstractNotSelectableShapeNodeEditPart(org.eclipse.sirius.diagram.ui.edit.api.part.AbstractNotSelectableShapeNodeEditPart) IStyleEditPart(org.eclipse.sirius.diagram.ui.edit.api.part.IStyleEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeImageExtension(org.palladiosimulator.editors.sirius.custom.style.rotatable.NodeImageExtension) CustomStyle(org.eclipse.sirius.diagram.CustomStyle) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) RotatableEditPartListener(org.palladiosimulator.editors.sirius.custom.style.rotatable.figure.listener.RotatableEditPartListener)

Aggregations

NodeImageExtension (org.palladiosimulator.editors.sirius.custom.style.rotatable.NodeImageExtension)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 EditPart (org.eclipse.gef.EditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 NodeListener (org.eclipse.gef.NodeListener)1 CustomStyle (org.eclipse.sirius.diagram.CustomStyle)1 AbstractNotSelectableShapeNodeEditPart (org.eclipse.sirius.diagram.ui.edit.api.part.AbstractNotSelectableShapeNodeEditPart)1 IStyleEditPart (org.eclipse.sirius.diagram.ui.edit.api.part.IStyleEditPart)1 PropagateFigureListenerAtConnectionFigure (org.palladiosimulator.editors.sirius.custom.style.rotatable.editPart.listener.PropagateFigureListenerAtConnectionFigure)1 RotatableSVGWorkspaceImageFigure (org.palladiosimulator.editors.sirius.custom.style.rotatable.figure.RotatableSVGWorkspaceImageFigure)1 RotatableEditPartListener (org.palladiosimulator.editors.sirius.custom.style.rotatable.figure.listener.RotatableEditPartListener)1