Skip to content
Snippets Groups Projects
Commit 71b79760 authored by Dongyue Mou's avatar Dongyue Mou
Browse files

added new editpart to show a diagram as a sub frame in another diagram

parent 91f4f294
No related branches found
No related tags found
No related merge requests found
/*--------------------------------------------------------------------------+
$Id: ElementEditPartBase.java 8344 2013-08-05 08:11:09Z hoelzl $
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editpart;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Rectangle;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* The base class for graphical edit parts which encapsulate nodes (i.e. the
* main modeling elements). All of them have a name label and an activation
* mode.
*
* @param <T>
* the type of the model element wrapped.
*
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 8344 $
* @ConQAT.Rating GREEN Hash: 7E81A6A123F7421DD0D73BE0F9C7D72A
*/
public abstract class SubDiagramEditPartBase<T extends ILayoutedModelElement & INamedCommentedElement>
extends ElementEditPartBase<T> {
/** Constructor. */
protected SubDiagramEditPartBase(T modelObject) {
super(modelObject);
}
/**
* {@inheritDoc}
* <p>
* Returns the connectors as children.
*/
@Override
protected List<?> getModelChildren() {
List<Object> result = new ArrayList<Object>();
result.addAll(modelElementHandler.getSubnodes(getModel()));
result.addAll(modelElementHandler.getConnectors(getModel()));
return result;
}
/** {@inheritDoc} */
@Override
protected Rectangle determineBaseFigureBounds() {
Rectangle result = null;
for(Object o : getModelChildren()) {
if(o instanceof ILayoutedModelElement) {
Rectangle p = LayoutDataUtils.getNodeBounds((ILayoutedModelElement)o);
result = p.getUnion(result);
}
}
if(result == null) {
result = new Rectangle();
}
result.expand(DefaultLayoutConstants.DEFAULT_GRID_SIZE,
DefaultLayoutConstants.DEFAULT_GRID_SIZE);
return result;
}
/** {@inheritDoc} */
@Override
public Label createLabelFigure() {
Label label = super.createLabelFigure();
label.setIconAlignment(PositionConstants.TOP | PositionConstants.LEFT);
return label;
}
/** {@inheritDoc} */
@Override
protected Rectangle determineLabelFigureBounds() {
Rectangle textBounds = labelFigure.getTextBounds();
Rectangle labelBounds = determineBaseFigureBounds();
labelBounds.y += 2 * DefaultLayoutConstants.DEFAULT_SHAPE_INSETS;
labelBounds.x += 2 * DefaultLayoutConstants.DEFAULT_SHAPE_INSETS;
labelBounds.width -= 4 * DefaultLayoutConstants.DEFAULT_SHAPE_INSETS;
labelBounds.height = textBounds.height * 2;
return labelBounds;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment