Skip to content
This repository has been archived by the owner on Oct 7, 2018. It is now read-only.

CAM-4803 #14

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,7 +20,7 @@
import org.eclipse.graphiti.datatypes.IRectangle;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.algorithms.MultiText;
import org.eclipse.graphiti.mm.algorithms.styles.Orientation;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
Expand All @@ -45,14 +45,13 @@ protected void postCreateHook(IAddContext context, IRectangle newShapeBounds, Co

T activity = getBusinessObject(context);

int width = newShapeBounds.getWidth();

Shape textShape = peService.createShape(newShape, false);
Text text = gaService.createDefaultText(getDiagram(), textShape, activity.getName());
gaService.setLocationAndSize(text, 5, 5, width - 10, 15);
MultiText text = gaService.createDefaultMultiText(getDiagram(), textShape, activity.getName());
gaService.setLocationAndSize(text, 5, 5, newShapeBounds.getWidth() - 10, newShapeBounds.getHeight() - 10);

StyleUtil.applyStyle(text, activity);
text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
link(textShape, activity);
}

Expand Down
Expand Up @@ -13,10 +13,9 @@
package org.camunda.bpm.modeler.ui.features.activity.subprocess;

import org.camunda.bpm.modeler.core.features.activity.LayoutActivityFeature;
import org.camunda.bpm.modeler.core.utils.GraphicsUtil;
import org.eclipse.graphiti.datatypes.IRectangle;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.algorithms.AbstractText;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
Expand All @@ -30,13 +29,8 @@ public LayoutExpandableActivityFeature(IFeatureProvider fp) {
@Override
protected void layoutLabel(ContainerShape container, Shape labelShape, IRectangle bounds) {

Text text = (Text) labelShape.getGraphicsAlgorithm();
AbstractText text = (AbstractText) labelShape.getGraphicsAlgorithm();

int padding = 5;

int width = bounds.getWidth() - padding;
int height = Math.min(GraphicsUtil.getLabelHeight(text), bounds.getHeight() - padding);

Graphiti.getGaService().setLocationAndSize(text, padding, padding, width, height);
Graphiti.getGaService().setLocationAndSize(text, 5, 5, bounds.getWidth() - 10, bounds.getHeight() - 10);
}
}
Expand Up @@ -17,7 +17,12 @@
import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IResizeShapeContext;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.MultiText;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;

/**
* Expandable activities resize feature.
Expand All @@ -42,4 +47,25 @@ public boolean canResizeShape(IResizeShapeContext context) {

return super.canResizeShape(context);
}


@Override
protected void postResize(IResizeShapeContext context) {
super.postResize(context);

IGaService gaService = Graphiti.getGaService();

ContainerShape containerShape = (ContainerShape) context.getShape();
BPMNShape bpmnShape = BusinessObjectUtil.getFirstElementOfType(containerShape, BPMNShape.class);

// resize the MultiText element (holding the name of the element) appropriately
for (PictogramElement pe : containerShape.getChildren()) {
GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
if (ga instanceof MultiText) {
gaService.setLocationAndSize(ga, 5, 5, (int) bpmnShape.getBounds().getWidth() - 10, (int) bpmnShape.getBounds().getHeight() - 10);
break;
}
}
}

}