/***************************************************************************** * Copyright (c) 2010 Atos Origin. * * * 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Atos Origin - Initial API and implementation * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.activity.edit.parts; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.ScrollPane; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.common.notify.Notification; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure; import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.uml.diagram.activity.edit.policies.ActivityGroupCustomDragAndDropEditPolicy; import org.eclipse.papyrus.uml.diagram.activity.edit.policies.CustomInterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentItemSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.activity.edit.policies.InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentItemSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.activity.edit.policies.RemoveOrphanViewPolicy; import org.eclipse.papyrus.uml.diagram.activity.part.Messages; import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy; /** * @generated */ public class InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentEditPart extends ShapeCompartmentEditPart { /** * @generated */ public static final int VISUAL_ID = 7007; /** * @generated */ public InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentEditPart(View view) { super(view); } /** * @generated */ public String getCompartmentName() { return Messages.InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentEditPart_title; } /** * @generated NOT (remove the top border,hide scrollbar) */ public IFigure createFigure() { ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure(); result.setTitleVisibility(false); // remove the top border result.setBorder(null); // Hide scrollBar result.getScrollPane().setEnabled(false); result.getScrollPane().setHorizontalScrollBar(null); result.getScrollPane().setVerticalScrollBar(null); result.getScrollPane().setScrollBarVisibility(ScrollPane.NEVER); return result; } /** * @generated */ protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentItemSemanticEditPolicy()); installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.activity.edit.policies.InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentCanonicalEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ActivityGroupCustomDragAndDropEditPolicy()); installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomInterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentItemSemanticEditPolicy()); } /** * @generated */ protected void setRatio(Double ratio) { if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } /** * @generated */ protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); } /** * @generated */ protected void refreshBounds() { int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** * @generated */ protected void refreshVisuals() { super.refreshVisuals(); refreshBounds(); } }