use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class CreateSubdiagramCommand method isEnabled.
@Override
public boolean isEnabled() {
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow == null)
return false;
ISelection selection = activeWorkbenchWindow.getActivePage().getSelection();
if (selection == null)
return false;
Node unwrap = unwrap(selection);
if (unwrap == null) {
return false;
}
State state = (State) unwrap.getElement();
if (state == null || state.isComposite())
return false;
BooleanValueStyle inlineStyle = DiagramPartitioningUtil.getInlineStyle(unwrap);
if (inlineStyle != null && !inlineStyle.isBooleanValue())
return false;
return super.isEnabled();
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class StatechartTextFactory method decorateView.
@Override
protected void decorateView(View containerView, View view, IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
IAdaptable eObjectAdapter = null;
EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
if (eObject != null) {
eObjectAdapter = new EObjectAdapter(eObject);
}
// Create the statechart name label
FactoryUtils.createLabel(view, STATECHART_NAME);
// create the expressions compartment
Node textCompartment = getViewService().createNode(eObjectAdapter, view, STATECHART_TEXT_EXPRESSION, ViewUtil.APPEND, true, getPreferencesHint());
Assert.isNotNull(textCompartment);
ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
style.setFillColor(FigureUtilities.RGBToInteger(ColorConstants.white.getRGB()));
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class GroupStatesIntoCompositeRefactoring method doGraphicalRefactoring.
protected void doGraphicalRefactoring() {
Node compositeStateView = createNodeForCompositeState(compositeState);
Node innerRegionNode = ViewService.createNode(getStateFigureCompartmentView(compositeStateView), innerRegion, SemanticHints.REGION, preferencesHint);
View regionCompartment = ViewUtil.getChildBySemanticHint(innerRegionNode, SemanticHints.REGION_COMPARTMENT);
moveSelectedStateNodesTo(regionCompartment, (Bounds) compositeStateView.getLayoutConstraint());
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class GroupStatesIntoCompositeRefactoring method moveSelectedStateNodesTo.
protected void moveSelectedStateNodesTo(View containerView, Bounds compositeBounds) {
for (GraphicalEditPart editPart : getContextObjects()) {
Node stateNode = (Node) editPart.getNotationView();
ViewUtil.insertChildView(containerView, stateNode, ViewUtil.APPEND, true);
Bounds newBounds = NotationFactory.eINSTANCE.createBounds();
Bounds oldBounds = (Bounds) stateNode.getLayoutConstraint();
// FIXME use bounds of region view
newBounds.setX(oldBounds.getX() - compositeBounds.getX() - 7);
// FIXME use bounds of region view
newBounds.setY(oldBounds.getY() - compositeBounds.getY() - 34);
((Node) editPart.getNotationView()).setLayoutConstraint(newBounds);
}
}
use of org.eclipse.gmf.runtime.notation.Node in project tdi-studio-se by Talend.
the class BusinessItemShapeEditPart method refreshVisuals.
@Override
public void refreshVisuals() {
super.refreshVisuals();
NodeFigure nodeFigure = getNodeFigure();
for (Object obj : nodeFigure.getChildren()) {
if (obj instanceof BusinessItemShapeFigure) {
BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) obj;
for (Object figure : shapFigure.getChildren()) {
if (figure instanceof BusinessItemNameFigure) {
BusinessItemNameFigure nameFigure = (BusinessItemNameFigure) figure;
nameFigure.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseMoved(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseHover(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent me) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent me) {
elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, editPart);
}
@Override
public void mouseDragged(MouseEvent me) {
// TODO Auto-generated method stub
}
});
EObject object = ((Node) getModel()).getElement();
if (object instanceof BusinessItem) {
BusinessItem item = (BusinessItem) object;
String hAlignment = item.getHAlignment();
if (hAlignment == null) {
hAlignment = BusinessAlignment.LEFT.toString();
}
String vAlignment = item.getVAlignment();
if (vAlignment == null) {
vAlignment = BusinessAlignment.TOP.toString();
}
if (BusinessAlignment.HCENTRE.toString().equals(hAlignment)) {
if (BusinessAlignment.TOP.toString().equals(vAlignment)) {
nameFigure.setAlignment(PositionConstants.TOP);
} else if (BusinessAlignment.BOTTOM.toString().equals(vAlignment)) {
nameFigure.setAlignment(PositionConstants.BOTTOM);
} else {
nameFigure.setAlignment(PositionConstants.CENTER);
}
} else if (BusinessAlignment.VCENTRE.toString().equals(vAlignment)) {
if (BusinessAlignment.LEFT.toString().equals(hAlignment)) {
nameFigure.setAlignment(PositionConstants.LEFT);
} else if (BusinessAlignment.RIGHT.toString().equals(hAlignment)) {
nameFigure.setAlignment(PositionConstants.RIGHT);
} else {
nameFigure.setAlignment(PositionConstants.CENTER);
}
} else {
nameFigure.setAlignment(getPosition(hAlignment, BusinessAlignment.HORIZONTAL, item) | getPosition(vAlignment, BusinessAlignment.VERTICAL, item));
}
}
}
}
}
}
elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, this);
}
Aggregations