Skip to content

Commit

Permalink
Customized ComponentPort images now rotate properly
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Dorner <felix.dorner@gmail.com>
  • Loading branch information
felixdo committed Mar 10, 2021
1 parent 3e844d6 commit fbf26f9
Show file tree
Hide file tree
Showing 50 changed files with 284 additions and 57 deletions.
5 changes: 4 additions & 1 deletion plugins/ms.design/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ Require-Bundle: org.eclipse.ui,
org.polarsys.capella.vp.ms.expression,
org.polarsys.capella.vp.ms.ui.css,
org.eclipse.e4.ui.css.core;bundle-version="0.12.700",
org.w3c.css.sac;bundle-version="1.3.1"
org.w3c.css.sac;bundle-version="1.3.1",
org.eclipse.gmf.runtime.diagram.ui,
org.polarsys.capella.core.sirius.analysis,
org.eclipse.sirius.diagram.ui;bundle-version="6.3.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: ms.configuration.services.cs,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Custom images for Contextual Component Detailed Interfaces diagrams
*/
ComponentPort[kind=STANDARD][providedInterfaces].vpms-all-undefined {
image: '/ms.design/images/vpms-rotating/StandardPort_provided.png';
}

ComponentPort[kind=STANDARD][requiredInterfaces].vpms-all-undefined {
image: '/ms.design/images/vpms-rotating/StandardPort_required.png';
}

ComponentPort[kind=STANDARD][providedInterfaces][requiredInterfaces].vpms-all-undefined {
image: '/ms.design/images/vpms-rotating/StandardPort_providedrequired.png';
}

ComponentPort[kind=STANDARD][providedInterfaces].vpms-excluded {
image: '/ms.design/images/vpms-rotating/StandardPort_provided-red.png';
}

ComponentPort[kind=STANDARD][requiredInterfaces].vpms-excluded {
image: '/ms.design/images/vpms-rotating/StandardPort_required-red.png';
}

ComponentPort[kind=STANDARD][providedInterfaces][requiredInterfaces].vpms-excluded {
image: '/ms.design/images/vpms-rotating/StandardPort_providedrequired-red.png';
}

ComponentPort[kind=STANDARD][providedInterfaces].vpms-excluded.vpms-included {
image: '/ms.design/images/vpms-rotating/StandardPort_provided-purple.png';
}

ComponentPort[kind=STANDARD][requiredInterfaces].vpms-excluded.vpms-included {
image: '/ms.design/images/vpms-rotating/StandardPort_required-purple.png';
}

ComponentPort[kind=STANDARD][providedInterfaces][requiredInterfaces].vpms-excluded.vpms-included {
image: '/ms.design/images/vpms-rotating/StandardPort_providedrequired-purple.png';
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Custom images for Contextual Component External Interfaces Diagrams
*/

ComponentPort[kind=STANDARD][providedInterfaces].vpms-all-undefined {
image: '/ms.design/images/vpms-rotating/StandardPort_provided.png';
}

ComponentPort[kind=STANDARD][requiredInterfaces].vpms-all-undefined {
image: '/ms.design/images/vpms-rotating/StandardPort_required.png';
}

ComponentPort[kind=STANDARD][providedInterfaces][requiredInterfaces].vpms-all-undefined {
image: '/ms.design/images/vpms-rotating/StandardPort_providedrequired.png';
}

ComponentPort[kind=STANDARD][providedInterfaces].vpms-excluded {
image: '/ms.design/images/vpms-rotating/StandardPort_provided-red.png';
}

ComponentPort[kind=STANDARD][requiredInterfaces].vpms-excluded {
image: '/ms.design/images/vpms-rotating/StandardPort_required-red.png';
}

ComponentPort[kind=STANDARD][providedInterfaces][requiredInterfaces].vpms-excluded {
image: '/ms.design/images/vpms-rotating/StandardPort_providedrequired-red.png';
}

ComponentPort[kind=STANDARD][providedInterfaces].vpms-excluded.vpms-included {
image: '/ms.design/images/vpms-rotating/StandardPort_provided-purple.png';
}

ComponentPort[kind=STANDARD][requiredInterfaces].vpms-excluded.vpms-included {
image: '/ms.design/images/vpms-rotating/StandardPort_required-purple.png';
}

ComponentPort[kind=STANDARD][providedInterfaces][requiredInterfaces].vpms-excluded.vpms-included {
image: '/ms.design/images/vpms-rotating/StandardPort_providedrequired-purple.png';
}

65 changes: 43 additions & 22 deletions plugins/ms.design/description/ms.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,53 +43,74 @@ For each element, only configurations that have the element in its scope are con
edge-color: DarkViolet;
}


FunctionInputPort.vpms-all-undefined {
image: 'ms.design/images/FlowPort.gif';
image: '/ms.design/images/vpms-rotating/FunctionInputPort.png';
}

FunctionInputPort.vpms-excluded {
image: '/ms.design/images/vpms-rotating/FunctionInputPort-red.png';
}

FunctionInputPort.vpms-included.vpms-excluded {
image: '/ms.design/images/vpms-rotating/FunctionInputPort-purple.png';
}

FunctionOutputPort.vpms-all-undefined {
image: 'ms.design/images/FlowPort.gif';
image: '/ms.design/images/vpms-rotating/FunctionOutputPort.png';
}

ComponentPort.vpms-all-undefined {
image: 'ms.design/images/FlowPort.gif';
FunctionOutputPort.vpms-excluded {
image: '/ms.design/images/vpms-rotating/FunctionOutputPort-red.png';
}

PhysicalPort.vpms-all-undefined {
image: 'ms.design/images/FlowPort.gif';
FunctionOutputPort.vpms-included.vpms-excluded {
image: '/ms.design/images/vpms-rotating/FunctionOutputPort-purple.png';
}

FunctionInputPort.vpms-excluded {
image: 'ms.design/images/FlowPort-red.gif';
ComponentPort[orientation='IN'].vpms-all-undefined {
image: '/ms.design/images/vpms-rotating/InFlowPort.png';
}

FunctionOutputPort.vpms-excluded {
image: 'ms.design/images/FlowPort-red.gif';
ComponentPort[orientation='IN'].vpms-excluded {
image: '/ms.design/images/vpms-rotating/InFlowPort-red.png';
}

ComponentPort.vpms-excluded {
image: 'ms.design/images/FlowPort-red.gif';
ComponentPort[orientation='IN'].vpms-excluded.vpms-included {
image: '/ms.design/images/vpms-rotating/InFlowPort-purple.png';
}

PhysicalPort.vpms-excluded {
image: 'ms.design/images/FlowPort-red.gif';
ComponentPort[orientation='OUT'].vpms-all-undefined {
image: '/ms.design/images/vpms-rotating/OutFlowPort.png';
}

FunctionInputPort.vpms-included.vpms-excluded {
image: 'ms.design/images/FlowPort-conflict.gif';
ComponentPort[orientation='OUT'].vpms-excluded {
image: '/ms.design/images/vpms-rotating/OutFlowPort-red.png';
}

FunctionOutputPort.vpms-included.vpms-excluded {
image: 'ms.design/images/FlowPort-conflict.gif';
ComponentPort[orientation='OUT'].vpms-excluded.vpms-included {
image: '/ms.design/images/vpms-rotating/OutFlowPort-purple.png';
}

ComponentPort.vpms-all-undefined {
image: '/ms.design/images/FlowPort.png';
}

ComponentPort.vpms-excluded {
image: '/ms.design/images/FlowPort-red.png';
}

ComponentPort.vpms-included.vpms-excluded {
image: 'ms.design/images/FlowPort-conflict.gif';
image: '/ms.design/images/FlowPort-purple.png';
}

PhysicalPort.vpms-included.vpms-excluded {
image: 'ms.design/images/FlowPort-conflict.gif';
PhysicalPort.vpms-all-undefined {
image: '/ms.design/images/FlowPort.png';
}

PhysicalPort.vpms-excluded {
image: '/ms.design/images/FlowPort-red.png';
}

PhysicalPort.vpms-included.vpms-excluded {
image: '/ms.design/images/FlowPort-purple.png';
}
Binary file removed plugins/ms.design/images/FlowPort-conflict.gif
Binary file not shown.
Binary file added plugins/ms.design/images/FlowPort-purple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed plugins/ms.design/images/FlowPort-red.gif
Binary file not shown.
Binary file added plugins/ms.design/images/FlowPort-red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed plugins/ms.design/images/FlowPort.gif
Binary file not shown.
Binary file added plugins/ms.design/images/FlowPort.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
52 changes: 27 additions & 25 deletions plugins/ms.design/images/license.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@ These followings icons are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0

<icon file path> - <original eclipse plug-in> - <original file path>

/images/Configuration.gif - org.polarsys.capella.vp.ms.edit - org.polarsys.capella.vp.ms.edit/icons/full/obj16/CSConfiguration.gif
/images/FlowPort.gif - ms.design - ms.design/images/FlowPort.gif
/images/FunctionInputPort.png - ms.design - ms.design/images/FunctionInputPort.png
/images/FunctionOutputPort.png - ms.design - ms.design/images/FunctionOutputPortPort.png
/images/InFlowPort.png - ms.design - ms.design/images/InFlowPort.png
/images/StandardPortSmall.png - ms.design - ms.design/images/StandardPortSmall.png
/images/TransparentPort.png - ms.design - ms.design/images/TransparentPort.png
/images/StandardPort_provided_east.png - ms.design - ms.design/images/StandardPort_provided_east.png
/images/StandardPort_provided_north.png - ms.design - ms.design/images/StandardPort_provided_north.png
/images/StandardPort_provided_south.png - ms.design - ms.design/images/StandardPort_provided_south.png
/images/StandardPort_provided_west.png - ms.design - ms.design/images/StandardPort_provided_west.png
/images/StandardPort_provided.png - ms.design - ms.design/images/StandardPort_provided.png
/images/StandardPort_providedrequired_east.png - ms.design - ms.design/images/StandardPort_providedrequired_east.png
/images/StandardPort_providedrequired_north.png - ms.design - ms.design/images/StandardPort_providedrequired_north.png
/images/StandardPort_providedrequired_south.png - ms.design - ms.design/images/StandardPort_providedrequired_south.png
/images/StandardPort_providedrequired_west.png - ms.design - ms.design/images/StandardPort_providedrequired_west.png
/images/StandardPort_providedrequired.png - ms.design - ms.design/images/StandardPort_providedrequired.png
/images/StandardPort_required_east.png - ms.design - ms.design/images/StandardPort_required_east.png
/images/StandardPort_required_north.png - ms.design - ms.design/images/StandardPort_required_north.png
/images/StandardPort_required_south.png - ms.design - ms.design/images/StandardPort_required_south.png
/images/StandardPort_required_west.png - ms.design - ms.design/images/StandardPort_required_west.png
/images/StandardPort_required.png - ms.design - ms.design/images/StandardPort_required.png
/images/FlowPort-red.gif - ms.design - ms.design/images/FlowPort-red.gif
images/Configuration.gif
images/FlowPort-purple.png
images/FlowPort-red.png
images/FlowPort.png
images/StandardPortSmall.png
images/TransparentPort.png
images/vpms-rotating/FunctionInputPort-purple.png
images/vpms-rotating/FunctionInputPort-red.png
images/vpms-rotating/FunctionInputPort.png
images/vpms-rotating/FunctionOutputPort-purple.png
images/vpms-rotating/FunctionOutputPort-red.png
images/vpms-rotating/FunctionOutputPort.png
images/vpms-rotating/InFlowPort-purple.png
images/vpms-rotating/InFlowPort-red.png
images/vpms-rotating/InFlowPort.png
images/vpms-rotating/OutFlowPort-purple.png
images/vpms-rotating/OutFlowPort-red.png
images/vpms-rotating/OutFlowPort.png
images/vpms-rotating/StandardPort_provided-purple.png
images/vpms-rotating/StandardPort_provided-red.png
images/vpms-rotating/StandardPort_provided.png
images/vpms-rotating/StandardPort_providedrequired-purple.png
images/vpms-rotating/StandardPort_providedrequired-red.png
images/vpms-rotating/StandardPort_providedrequired.png
images/vpms-rotating/StandardPort_required-purple.png
images/vpms-rotating/StandardPort_required-red.png
images/vpms-rotating/StandardPort_required.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
9 changes: 9 additions & 0 deletions plugins/ms.design/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@
providerClass="ms.design.MsRefreshExtensionProvider">
</refreshExtensionProvider>
</extension>
<extension
point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders">
<editpartProvider
class="ms.design.RotativeImageEditPartProvider">
<Priority
name="Highest">
</Priority>
</editpartProvider>
</extension>
</plugin>
74 changes: 74 additions & 0 deletions plugins/ms.design/src/ms/design/RotativeImageEditPartProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*******************************************************************************
* Copyright (c) 2006, 2019 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package ms.design;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.diagram.DNode;
import org.eclipse.sirius.diagram.WorkspaceImage;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNode4EditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.WorkspaceImageEditPart;
import org.polarsys.capella.core.sirius.analysis.editpart.RotativeDNode4EditPart;
import org.polarsys.capella.core.sirius.analysis.editpart.RotativeImageEditPart;

/**
* Specific Edit Part Provider for rotative image
*/
public class RotativeImageEditPartProvider extends AbstractEditPartProvider {

@Override
protected Class<?> getNodeEditPartClass(final View view) {
String type = view.getType();

if (type != null) {
EObject resolvedSemanticElement = ViewUtil.resolveSemanticElement(view);
if (resolvedSemanticElement != null) {

if (String.valueOf(WorkspaceImageEditPart.VISUAL_ID).equals(type)) {
if (resolvedSemanticElement instanceof WorkspaceImage) {
final WorkspaceImage customStyle = (WorkspaceImage) resolvedSemanticElement;
if (isRotative(customStyle)) {
return RotativeImageEditPart.class;
}
}
} else if (String.valueOf(DNode4EditPart.VISUAL_ID).equals(type)) {
if (resolvedSemanticElement instanceof DNode) {

DNode spec = (DNode) resolvedSemanticElement;
if (spec.getOwnedStyle() != null && spec.getOwnedStyle() instanceof WorkspaceImage) {
if (isRotative((WorkspaceImage) spec.getOwnedStyle())) {
return RotativeDNode4EditPart.class;
}
}
}
}
}
}

return super.getNodeEditPartClass(view);
}

private boolean isRotative(WorkspaceImage ownedStyle_p) {
IPath path = new Path(ownedStyle_p.getWorkspacePath());
if (path.segmentCount() >= 2) {
String folder = path.segment(path.segmentCount() - 2);
return "vpms-rotating".equals(folder);
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Require-Bundle: org.eclipse.e4.ui.css.core;bundle-version="0.12.700",
org.w3c.css.sac;bundle-version="1.3.1",
org.eclipse.e4.ui.css.swt;bundle-version="0.13.500",
org.eclipse.swt,
org.eclipse.core.resources;bundle-version="3.13.400"
org.eclipse.core.resources;bundle-version="3.13.400",
org.polarsys.capella.common.helpers,
org.polarsys.capella.core.data.gen
Import-Package: org.eclipse.core.runtime
Export-Package: org.polarsys.capella.vp.ms.ui.css,
org.polarsys.capella.vp.ms.ui.css.dom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ public void error(Exception e) {
for (Layer layer : dDiagram.getActivatedLayers()) {
URI resource = layer.eResource().getURI();
if (seen.add(resource)) {
URI cssURI = resource.trimFileExtension().appendFileExtension("css");

URI baseCssURI = resource.trimFileExtension();
String filename = baseCssURI.lastSegment() + ".css";
URI cssURI = baseCssURI.appendFileExtension("css");

URI diagramCssURI = baseCssURI.trimSegments(1).appendSegment(dDiagram.getDescription().getName()).appendSegment(filename);

try {
URL cssURL = FileLocator.find(new URL(cssURI.toString()));
Expand All @@ -92,7 +97,13 @@ public void error(Exception e) {
StyleSheet ss = engine.parseStyleSheet(is);
}
}

URL diagramCssURL = FileLocator.find(new URL(diagramCssURI.toString()));
if (diagramCssURL != null) {
try (InputStream is = diagramCssURL.openStream()){
StyleSheet ss = engine.parseStyleSheet(is);
}
}

if (workspaceBaseURI != null) {
URI customCSSURI = workspaceBaseURI.appendSegment(cssURI.segment(cssURI.segmentCount() - 1));
String customCSSPlatformString = customCSSURI.toPlatformString(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.polarsys.capella.core.data.capellacore.TypedElement;
import org.polarsys.capella.core.data.cs.Part;
import org.w3c.dom.Element;

public class DSemanticDecoratorElement extends EObjectElement {
Expand All @@ -27,7 +29,11 @@ public DSemanticDecoratorElement(DSemanticDecorator nativeWidget, CSSEngine engi
}

protected EObject getTarget() {
return ((DSemanticDecorator)getNativeWidget()).getTarget();
EObject target = ((DSemanticDecorator)getNativeWidget()).getTarget();
if (target instanceof Part) {
target = ((TypedElement) target).getType();
}
return target;
}

@Override
Expand Down
Loading

0 comments on commit fbf26f9

Please sign in to comment.