Skip to content

Commit

Permalink
Add Resizable with 'resizeLocations' to shape elements
Browse files Browse the repository at this point in the history
- Use string for GResizeLocation
- Fix issue with issue severity not being of type string
- Fix minor issue with wrong EClass mapping for weighted edge
  • Loading branch information
martin-fleck-at committed May 27, 2024
1 parent fc5d3b8 commit e756973
Show file tree
Hide file tree
Showing 25 changed files with 897 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Map<String, EClass> getTypeMappings() {
mappings.put(LABEL_TEXT, GraphPackage.Literals.GLABEL);
mappings.put(COMP_HEADER, GraphPackage.Literals.GCOMPARTMENT);
mappings.put(LABEL_ICON, GraphPackage.Literals.GLABEL);
mappings.put(WEIGHTED_EDGE, GraphPackage.Literals.GEDGE);
mappings.put(WEIGHTED_EDGE, WfgraphPackage.Literals.WEIGHTED_EDGE);
mappings.put(ICON, WfgraphPackage.Literals.ICON);
mappings.put(ACTIVITY_NODE, WfgraphPackage.Literals.ACTIVITY_NODE);
mappings.put(TASK, WfgraphPackage.Literals.TASK_NODE);
Expand Down Expand Up @@ -105,7 +105,6 @@ public List<EdgeTypeHint> getEdgeTypeHints() {
return edgeHints;
}


@Override
public ServerLayoutKind getLayoutKind() { return ServerLayoutKind.MANUAL; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.glsp.example.workflow.utils.WorkflowBuilder.ActivityNodeBuilder;
import org.eclipse.glsp.graph.GNode;
import org.eclipse.glsp.graph.GPoint;
import org.eclipse.glsp.graph.GResizeLocation;
import org.eclipse.glsp.graph.builder.impl.GLayoutOptions;

public class CreateDecisionNodeHandler extends CreateActivityNodeHandler {
Expand All @@ -36,6 +37,7 @@ protected GNode createNode(final Optional<GPoint> point, final Map<String, Strin
return new ActivityNodeBuilder(getElementTypeId(), nodeType) //
.layoutOptions(new GLayoutOptions().minHeight(32d).minWidth(32d)) //
.position(point.orElse(null)) //
.resizeLocations(GResizeLocation.CROSS) //
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,27 @@
********************************************************************************/
package org.eclipse.glsp.example.workflow.handler;

import java.util.Map;
import java.util.Optional;

import org.eclipse.glsp.example.workflow.utils.ModelTypes;
import org.eclipse.glsp.example.workflow.utils.WorkflowBuilder.ActivityNodeBuilder;
import org.eclipse.glsp.graph.GNode;
import org.eclipse.glsp.graph.GPoint;
import org.eclipse.glsp.graph.GResizeLocation;

public class CreateMergeNodeHandler extends CreateActivityNodeHandler {

public CreateMergeNodeHandler() {
super(ModelTypes.MERGE_NODE, "Merge Node");
}

@Override
protected GNode createNode(final Optional<GPoint> point, final Map<String, String> args) {
String nodeType = ModelTypes.toNodeType(getElementTypeId());
return new ActivityNodeBuilder(getElementTypeId(), nodeType) //
.position(point.orElse(null)) //
.resizeLocations(GResizeLocation.CROSS) //
.build();
}
}
8 changes: 6 additions & 2 deletions plugins/org.eclipse.glsp.graph/model/glsp-graph.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="GShapeElement" abstract="true" interface="true"
eSuperTypes="#//GModelElement #//GBoundsAware #//GLayoutable"/>
eSuperTypes="#//GModelElement #//GBoundsAware #//GLayoutable #//GResizable"/>
<eClassifiers xsi:type="ecore:EClass" name="GGraph" eSuperTypes="#//GModelRoot #//GBoundsAware #//GLayoutable"/>
<eClassifiers xsi:type="ecore:EClass" name="GModelRoot" eSuperTypes="#//GModelElement">
<eStructuralFeatures xsi:type="ecore:EReference" name="canvasBounds" eType="#//GBounds"
Expand Down Expand Up @@ -108,7 +108,7 @@
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="GIssue">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="severity" lowerBound="1"
eType="#//GSeverity" defaultValueLiteral="info"/>
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" defaultValueLiteral="info"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="message" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="GSeverity">
Expand All @@ -132,4 +132,8 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="layoutOptions" upperBound="-1"
eType="#//StringToObjectMapEntry" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="GResizable">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="resizeLocations" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
3 changes: 3 additions & 0 deletions plugins/org.eclipse.glsp.graph/model/glsp-graph.genmodel
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,8 @@
<genClasses ecoreClass="glsp-graph.ecore#//GLayoutable">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference glsp-graph.ecore#//GLayoutable/layoutOptions"/>
</genClasses>
<genClasses ecoreClass="glsp-graph.ecore#//GResizable">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EAttribute glsp-graph.ecore#//GResizable/resizeLocations"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,25 @@ public interface GIssue extends EObject {
/**
* Returns the value of the '<em><b>Severity</b></em>' attribute.
* The default value is <code>"info"</code>.
* The literals are from the enumeration {@link org.eclipse.glsp.graph.GSeverity}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Severity</em>' attribute.
* @see org.eclipse.glsp.graph.GSeverity
* @see #setSeverity(GSeverity)
* @see #setSeverity(String)
* @see org.eclipse.glsp.graph.GraphPackage#getGIssue_Severity()
* @model default="info" required="true"
* @generated
*/
GSeverity getSeverity();
String getSeverity();

/**
* Sets the value of the '{@link org.eclipse.glsp.graph.GIssue#getSeverity <em>Severity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Severity</em>' attribute.
* @see org.eclipse.glsp.graph.GSeverity
* @see #getSeverity()
* @generated
*/
void setSeverity(GSeverity value);
void setSeverity(String value);

/**
* Returns the value of the '<em><b>Message</b></em>' attribute.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) 2019-2022 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
* ********************************************************************************
*/
package org.eclipse.glsp.graph;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EObject;

/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>GResizable</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link org.eclipse.glsp.graph.GResizable#getResizeLocations <em>Resize Locations</em>}</li>
* </ul>
*
* @see org.eclipse.glsp.graph.GraphPackage#getGResizable()
* @model
* @generated
*/
public interface GResizable extends EObject {
/**
* Returns the value of the '<em><b>Resize Locations</b></em>' attribute list.
* The list contents are of type {@link java.lang.String}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Resize Locations</em>' attribute list.
* @see org.eclipse.glsp.graph.GraphPackage#getGResizable_ResizeLocations()
* @model
* @generated
*/
EList<String> getResizeLocations();

} // GResizable
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
* @model interface="true" abstract="true"
* @generated
*/
public interface GShapeElement extends GModelElement, GBoundsAware, GLayoutable {} // GShapeElement
public interface GShapeElement extends GModelElement, GBoundsAware, GLayoutable, GResizable {} // GShapeElement
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ public interface GraphFactory extends EFactory {
*/
GLayoutable createGLayoutable();

/**
* Returns a new object of class '<em>GResizable</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return a new object of class '<em>GResizable</em>'.
* @generated
*/
GResizable createGResizable();

/**
* Returns the package supported by this factory.
* <!-- begin-user-doc -->
Expand Down
Loading

0 comments on commit e756973

Please sign in to comment.