Skip to content

Commit

Permalink
Merge pull request #12 from peransin-obeo/DiagramRefactor
Browse files Browse the repository at this point in the history
Fix the gateway and task refactoring
  • Loading branch information
sdrapeau authored Mar 14, 2024
2 parents 7d3ab12 + f50a23a commit 8ffedd8
Show file tree
Hide file tree
Showing 48 changed files with 9,013 additions and 548 deletions.
33 changes: 33 additions & 0 deletions BPMN-Designer.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#template = tycho;Eclipse2021-06;emf;emfTools
template = emfTools


# From Tycho
project.java = 11
project.copyright = Copyright (c) ${project.year} ${project.provider}. All rights reserved.

# From EclipseXX
eclipe.version = 2021-06

# From emf
project.ecoreuri = http://www.omg.org/spec/BPMN/20100524/MODEL-XMI
validation.category = ${project.name}/validation


project.name = BPMN2
project.label = BPMN 2

project.prefix = Bpmn
project.extension = bpmn2

project.fullname = org.obeonetwork.dsl.bpmn2
project.fullpath = org/obeonetwork/dsl/bpmn2

project.provider = OBEO
project.license = Eclipse EPL 2.0

# Name for configuration files. Example (Java Formatter, checkstyle, ...)
project.profile = ObeoDev

project.url = https://github.com/ObeoNetwork/BPMN-Designer

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.sirius.diagram,
org.eclipse.sirius.diagram.ui,
org.eclipse.sirius.ext.base,
org.eclipse.emf.edit.ui
org.eclipse.sirius.common.acceleo.aql,
org.eclipse.emf.edit.ui,
org.eclipse.gmf.runtime.diagram.ui,
org.eclipse.sirius.common.ui,
org.eclipse.gmf.runtime.diagram.ui.resources.editor,
org.eclipse.sirius.ecore.extender
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: org.obeonetwork.bpmn2.design
Expand Down
471 changes: 319 additions & 152 deletions plugins/org.obeonetwork.dsl.bpmn2.design/description/BPMN2.odesign

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions plugins/org.obeonetwork.dsl.bpmn2.design/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Other=Other
ToggleCollapse=Toggle collapse
LanesAutosize=Lanes autosize
ConvertTaskTo=Convert Task to...
ConvertGatewayTo=Convert Gateway to...
Paste=Paste

Start=Start
End=End
IntermediateCatch=Intermediate Catch
IntermediateThrow=Intermediate Throw
StartEvent=Start
EndEvent=End
IntermediateCatchEvent=Intermediate Catch
IntermediateThrowEvent=Intermediate Throw
Boundary=Boundary

Message=Message
Expand Down
9 changes: 5 additions & 4 deletions plugins/org.obeonetwork.dsl.bpmn2.design/plugin_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Other=Autres
ToggleCollapse=Plier/Déplier
LanesAutosize=Redimensionnement automatique des lanes
ConvertTaskTo=Convertir la tâche en...
ConvertGatewayTo=Convertir la porte logique en...
Paste=Coller

Start=Début
End=Fin
IntermediateCatch=Réception intermédiaire
IntermediateThrow=Envoi intermédiaire
StartEvent=Début
EndEvent=Fin
IntermediateCatchEvent=Réception intermédiaire
IntermediateThrowEvent=Envoi intermédiaire
Boundary=Borne

Message=Message
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2019 Obeo.
* Copyright (c) 2011-2024 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -11,57 +11,51 @@
*/
package org.obeonetwork.bpmn2.design;

import org.eclipse.sirius.business.api.componentization.ViewpointRegistry;
import org.eclipse.sirius.viewpoint.description.Viewpoint;

import java.util.HashSet;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.Set;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.sirius.business.api.componentization.ViewpointRegistry;
import org.eclipse.sirius.viewpoint.description.Viewpoint;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {

private static final String PATH_SEPARATOR = "/";

// The plug-in ID
public static final String PLUGIN_ID = "org.obeonetwork.dsl.bpmn2.design";

public static final String DESIGN_PATH = PLUGIN_ID + "/description/BPMN2.odesign";
// The shared instance
private static Activator plugin;

private static Set<Viewpoint> viewpoints;

/**
* The constructor
*/
public Activator() {
}

/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
private Set<Viewpoint> viewpoints;
private ResourceBundle i10n;

@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
viewpoints = new HashSet<Viewpoint>();
viewpoints.addAll(ViewpointRegistry.getInstance().registerFromPlugin(
PLUGIN_ID + "/description/BPMN2.odesign"));
viewpoints = ViewpointRegistry.getInstance().registerFromPlugin(DESIGN_PATH);
i10n = Platform.getResourceBundle(getBundle());
}

/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
if (viewpoints != null) {
for (final Viewpoint viewpoint : viewpoints) {
ViewpointRegistry.getInstance().disposeFromPlugin(viewpoint);
}
viewpoints.clear();
viewpoints = null;
}
super.stop(context);
Expand Down Expand Up @@ -89,4 +83,67 @@ public static Activator getDefault() {
public static void log(int severity, String message, Throwable exception) {
getDefault().getLog().log(new Status(severity, PLUGIN_ID, message, exception));
}

/**
* Returns a icon from this plugin.
*
* @param path
* (local) of image
* @return image or null
*/
public Image getImage(String path) {
return getImage(PLUGIN_ID, path);
}

/**
* Returns a icon from a plugin.
*
* @param bundleId
* plugin containing the image
* @param path
* of image
* @return image or null
*/
public Image getImage(String bundleId, String path) {
String key = bundleId + PATH_SEPARATOR + path;
if (getImageRegistry().getDescriptor(key) == null) {
// put must unique.
Bundle bundle = Platform.getBundle(bundleId == null
? PLUGIN_ID
: bundleId);
URL url = bundle != null
? bundle.getResource(path)
: null;
getImageRegistry().put(key, ImageDescriptor.createFromURL(url));
}
return getImageRegistry().get(key);
}

/**
* Returns a icon from a plugin where 1rst segment is a plugin.
*
* @param bundleId
* plugin containing the image
* @param path
* of image
* @return image or null
*/
public Image getImageFromPath(String path) {
if (path == null || path.isEmpty()) {
return null;
}
if (path.startsWith(PATH_SEPARATOR)) {
return getImageFromPath(path.substring(PATH_SEPARATOR.length()));
}
int token = path.indexOf(PATH_SEPARATOR);
if (token == -1) { // Invalid path (not critical)
return null;
}
return getImage(path.substring(0, token), path.substring(token + PATH_SEPARATOR.length()));
}


public static ResourceBundle getI10n() {
return getDefault().i10n;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,39 @@

/**
* This triggers move "external labels" near the forms without label.
*
* @author sdrapeau
*/
public class ExternalLabelTrigger implements ModelChangeTrigger {

protected static final NotificationFilter EXTERNAL_LABEL_FILTER = new Custom() {
@Override
public boolean matches(Notification notification) {
return notification.getEventType() == Notification.SET && notification.getNotifier() instanceof Bounds
return notification.getEventType() == Notification.SET
&& notification.getNotifier() instanceof Bounds
&& notification.getFeature() == NotationPackage.Literals.LOCATION__X
&& ((Integer) notification.getNewValue()) != 0 && ((Integer) notification.getOldValue()) == 0
&& ((Bounds) notification.getNotifier()).eContainer() instanceof Node
&& ((Node) ((Bounds) notification.getNotifier()).eContainer()).getElement() instanceof DNode //
&& (//
"ExternalLabel"
.equals(((DNode) ((Node) ((Bounds) notification.getNotifier()).eContainer()).getElement())
.getActualMapping().getName())//
|| //
"SPExternalLabel".equals(((DNode) ((Node) ((Bounds) notification.getNotifier()).eContainer()).getElement())
.getActualMapping().getName())//
&& ((Integer) notification.getNewValue()) != 0
&& ((Integer) notification.getOldValue()) == 0
&& isExternalLabelBound((Bounds) notification.getNotifier()
);
}
};

private static boolean isExternalLabelBound(Bounds bounds) {
if (bounds.eContainer() instanceof Node
&& ((Node) bounds.eContainer()).getElement() instanceof DNode) {
return isExternalLabelNode((DNode) ((Node) bounds.eContainer()).getElement());
}
return false;
}

private static boolean isExternalLabelNode(DNode node) {
String mapping = node.getActualMapping().getName();
return "ExternalLabel".equals(mapping) || "SPExternalLabel".equals(mapping);
}



/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -116,9 +127,11 @@ protected void doExecute() {

private DNode getDNodeWithoutLabel(DNode dNode) {
for (DDiagramElement d : ((DNodeContainer) dNode.eContainer()).getElements()) {
if (d.getTarget().equals(dNode.getTarget()) && (d instanceof DNode) && (//
if (d.getTarget().equals(dNode.getTarget())
&& (d instanceof DNode)
&& (//
!"ExternalLabel".equals(d.getMapping().getName()) //
|| //
|| // Highly suspicious : Always True !!!
!"SPExternalLabel".equals(d.getMapping().getName()))//
) {
return (DNode) d;
Expand Down
Loading

0 comments on commit 8ffedd8

Please sign in to comment.