//------------------------------------------------------------------------------ // 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 //------------------------------------------------------------------------------ package org.eclipse.epf.diagram.wpdd.edit.parts; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.notation.Node; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; import org.eclipse.epf.diagram.core.part.util.DiagramEditorUtil; import org.eclipse.epf.diagram.wpdd.edit.policies.WorkProductDependencyDiagramCanonicalEditPolicy; import org.eclipse.epf.diagram.wpdd.edit.policies.WorkProductDependencyDiagramItemSemanticEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; /** * @generated */ public class WorkProductDependencyDiagramEditPart extends DiagramEditPart { /** * @generated */ public static final String MODEL_ID = "WPDD"; //$NON-NLS-1$ /** * @generated */ public static final int VISUAL_ID = 79; /** * @generated */ public WorkProductDependencyDiagramEditPart(View view) { super(view); } /** * @generated */ protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new WorkProductDependencyDiagramItemSemanticEditPolicy()); installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new WorkProductDependencyDiagramCanonicalEditPolicy()); } @Override protected void handleNotificationEvent(Notification event) { if (NotationPackage.Literals.VIEW__VISIBLE.equals(event.getFeature())) { Object notifier = event.getNotifier(); if (notifier == getModel()) refreshVisibility(); else if (event.getNotifier() instanceof Node) { refreshChildren(); DiagramEditorUtil.refreshConnectionEditParts(this); } } else super.handleNotificationEvent(event); } @Override public void activate() { super.activate(); Object model = getModel(); if (model instanceof View) { EObject e = ((View) model).getElement(); if (e instanceof org.eclipse.epf.diagram.model.Node) { ((org.eclipse.epf.diagram.model.Node) e).addConsumer(this); } } } @Override public void deactivate() { super.deactivate(); Object model = getModel(); if (model instanceof View) { EObject e = ((View) model).getElement(); if (e instanceof org.eclipse.epf.diagram.model.Node) { ((org.eclipse.epf.diagram.model.Node) e).removeConsumer(this); } } } }