blob: cf60ee5c0a18c2e7a440567f1f1a83b2b3945b3e [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2007 IBM Corporation and others.
// 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:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
/*
* Copyright (c) 2005, 2006 IBM Corporation and others.
* 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:
* IBM Corporation - initial implementation
*
*/
package org.eclipse.epf.diagramming.edit.parts;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.LineBorder;
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.epf.diagramming.edit.policies.ActivityPartitionPartitionCampartment2CanonicalEditPolicy;
import org.eclipse.epf.diagramming.edit.policies.ActivityPartitionPartitionCampartment2ItemSemanticEditPolicy;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
import org.eclipse.gmf.runtime.notation.NotationPackage;
/**
* @generated
*/
public class ActivityPartitionPartitionCampartment2EditPart extends
ShapeCompartmentEditPart {
/**
* @generated
*/
public static final int VISUAL_ID = 5002;
/**
* @generated
*/
public ActivityPartitionPartitionCampartment2EditPart(View view) {
super(view);
}
/**
* @generated
*/
public String getCompartmentName() {
return "PartitionCampartment";
}
/**
* @generated
*/
public IFigure createFigure() {
ResizableCompartmentFigure result = (ResizableCompartmentFigure) super
.createFigure();
result.setTitleVisibility(false);
return result;
}
/**
* @generated
*/
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(
EditPolicyRoles.SEMANTIC_ROLE,
new ActivityPartitionPartitionCampartment2ItemSemanticEditPolicy());
installEditPolicy(EditPolicyRoles.CREATION_ROLE,
new CreationEditPolicy());
installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE,
new DragDropEditPolicy());
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE,
new ActivityPartitionPartitionCampartment2CanonicalEditPolicy());
}
/**
* @generated
*/
//public IFigure createFigure() {
// IFigure result = super.createFigure();
// result.setBorder(new LineBorder());
// return result;
//}
/**
* @generated
*/
protected void refreshVisuals() {
super.refreshVisuals();
refreshBounds();
}
/**
* @generated
*/
protected void handleNotificationEvent(Notification notification) {
super.handleNotificationEvent(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();
}
}
/**
* @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 setRatio(Double ratio) {
// nothing to do -- parent layout does not accept Double constraints as ratio
// super.setRatio(ratio);
}
}