Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2007, 2008 Anyware Technologies 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: Anyware Technologies - initial API and implementation $Id: EPackage2EditPart.java,v 1.12 2009/02/02 08:39:06 jlescot Exp $ /
 
 
 package org.eclipse.emf.ecoretools.diagram.edit.parts;
 
 import java.util.List;
 
 import  org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
 import  org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
 import  org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
 import  org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
 import  org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
 import  org.eclipse.gmf.runtime.emf.type.core.IElementType;
 import  org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
 import  org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
 import  org.eclipse.gmf.runtime.notation.View;
 import  org.eclipse.swt.graphics.Color;

Generated:
 
 public class EPackage2EditPart extends ShapeNodeEditPart {

Generated:
 
 	public static final int VISUAL_ID = 1002;

Generated:
 
 	protected IFigure contentPane;

Generated:
 
 	protected IFigure primaryShape;

Generated:
 
 	public EPackage2EditPart(View view) {
 		super(view);
 	}

Generated:
NOT
 
 	protected void createDefaultEditPolicies() {
 
 		super.createDefaultEditPolicies();
 		// // To manage delete from diagram when there is an associated diagram
 		// with the package
 		// installEditPolicy(EditPolicy.COMPONENT_ROLE,
 		// new PackageComponentEditPolicy());
		installEditPolicy(EditPolicyRoles.SEMANTIC_ROLEnew EPackage2ItemSemanticEditPolicy());
		installEditPolicy(EditPolicyRoles.OPEN_ROLEnew OpenDiagramEditPolicy());
		// XXX need an SCR to runtime to have another abstract superclass that
		// would let children add reasonable editpolicies
		removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
	}

Generated:
				if (result == null) {
					result = new NonResizableEditPolicy();
				}
				return result;
			}
			protected Command getMoveChildrenCommand(Request request) {
				return null;
			}
			protected Command getCreateCommand(CreateRequest request) {
				return null;
			}
		};
		return lep;
	}

Generated:
NOT
	protected IFigure createNodeShape() {
		PackageFigure figure = new PackageFigure();
		return  = figure;
	}

Generated:
	}

Generated:
	protected boolean addFixedChild(EditPart childEditPart) {
		if (childEditPart instanceof EPackageNameEditPart) {
			return true;
		}
		if (childEditPart instanceof EPackageContentsEditPart) {
			setupContentPane(pane); // FIXME each comparment should handle his
			// content pane in his own way
			pane.add(((EPackageContentsEditPartchildEditPart).getFigure());
			return true;
		}
		return false;
	}

Generated:
	protected boolean removeFixedChild(EditPart childEditPart) {
		if (childEditPart instanceof EPackageNameEditPart) {
			return true;
		}
		if (childEditPart instanceof EPackageContentsEditPart) {
			setupContentPane(pane); // FIXME each comparment should handle his
			// content pane in his own way
			pane.remove(((EPackageContentsEditPartchildEditPart).getFigure());
			return true;
		}
		return false;
	}

Generated:
	protected void addChildVisual(EditPart childEditPartint index) {
		if (addFixedChild(childEditPart)) {
			return;
		}
		super.addChildVisual(childEditPart, -1);
	}

Generated:
	protected void removeChildVisual(EditPart childEditPart) {
		if (removeFixedChild(childEditPart)) {
			return;
		}
		super.removeChildVisual(childEditPart);
	}

Generated:
	protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
		if (editPart instanceof EPackageContentsEditPart) {
		}
		return getContentPane();
	}

Generated:
NOT
	protected NodeFigure createNodePlate() {
		DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(getMapMode().DPtoLP(40), getMapMode().DPtoLP(40)) {
				PointList points = new PointList(7);
				points.addPoint(nameRectangle.xnameRectangle.y);
				points.addPoint(nameRectangle.x + nameRectangle.widthnameRectangle.y);
				points.addPoint(nameRectangle.x + nameRectangle.widthnameRectangle.y + nameRectangle.height);
				points.addPoint(bodyRectangle.x + bodyRectangle.widthbodyRectangle.y);
				points.addPoint(bodyRectangle.x + bodyRectangle.widthbodyRectangle.y + bodyRectangle.height);
				points.addPoint(bodyRectangle.xbodyRectangle.y + bodyRectangle.height);
				points.addPoint(nameRectangle.xnameRectangle.y);
				return points;
			}
		};
		result.setBorder(shadowBorder);
		return result;
	}

Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may safely remove generated tag and modify it.

Generated:
	protected NodeFigure createNodeFigure() {
		NodeFigure figure = createNodePlate();
		figure.add(shape);
		return figure;
	}

Default implementation treats passed figure as content pane. Respects layout one may have set for generated figure.

Parameters:
nodeShape instance of generated figure class
Generated:
	protected IFigure setupContentPane(IFigure nodeShape) {
		if (nodeShape.getLayoutManager() == null) {
			ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
			layout.setSpacing(getMapMode().DPtoLP(5));
			nodeShape.setLayoutManager(layout);
		}
		return nodeShape// use nodeShape itself as contentPane
	}

Generated:
	public IFigure getContentPane() {
		if ( != null) {
			return ;
		}
		return super.getContentPane();
	}

Generated:
	protected void setForegroundColor(Color color) {
		if ( != null) {
		}
	}

Generated:
	protected void setBackgroundColor(Color color) {
		if ( != null) {
		}
	}

Generated:
	protected void setLineWidth(int width) {
		if ( instanceof Shape) {
			((Shape).setLineWidth(getMapMode().DPtoLP(width));
		}
	}

Generated:
	protected void setLineType(int style) {
		if ( instanceof Shape) {
		}
	}

Generated:
		return getChildBySemanticHint(EcoreVisualIDRegistry.getType(.));
	}

Generated:
	public List<org.eclipse.gmf.runtime.emf.type.core.IElementType> getMARelTypesOnTarget() {
		List<org.eclipse.gmf.runtime.emf.type.core.IElementType> types = new ArrayList<org.eclipse.gmf.runtime.emf.type.core.IElementType>();
		return types;
	}

Generated:
	public List<org.eclipse.gmf.runtime.emf.type.core.IElementType> getMATypesForSource(IElementType relationshipType) {
		List<org.eclipse.gmf.runtime.emf.type.core.IElementType> types = new ArrayList<org.eclipse.gmf.runtime.emf.type.core.IElementType>();
		if (relationshipType == .) {
		}
		return types;
	}

Generated:
	protected void handleNotificationEvent(Notification event) {
		if (event.getNotifier() == getModel() && ..getEModelElement_EAnnotations().equals(event.getFeature())) {
			handleMajorSemanticChange();
else {
			super.handleNotificationEvent(event);
		}
	}
	protected void refreshVisuals() {
		EObject semanticElement = resolveSemanticElement();
		if (FigureFromLabelUtils.needFromLabel(semanticElement, getNotationView())) {
			getPrimaryShape().updateFromLabel(FigureFromLabelUtils.getQualifiedName(semanticElement));
else {
		}
		super.refreshVisuals();
	}
	}

Generated:
NOT
	public class PackageFigure extends GradientRectangleFigure {

Generated:
NOT

Generated:
		private WrappingLabel fFigurePackageNameLabel;

Generated:

Generated:
		public PackageFigure() {
			GridLayout layoutThis = new GridLayout();
			layoutThis.numColumns = 2;
			layoutThis.makeColumnsEqualWidth = false;
			layoutThis.horizontalSpacing = 0;
			layoutThis.verticalSpacing = 0;
			layoutThis.marginWidth = 0;
			layoutThis.marginHeight = 0;
			this.setLayoutManager(layoutThis);
			this.setFill(false);
			this.setOutline(false);
			this.setLineWidth(2);
			this.setMinimumSize(new Dimension(getMapMode().DPtoLP(110), getMapMode().DPtoLP(100)));
		}

Generated:
NOT
		private void createContents() {
			.setBorder(new MarginBorder(getMapMode().DPtoLP(5), getMapMode().DPtoLP(5), getMapMode().DPtoLP(5), getMapMode().DPtoLP(5)));
			GridData constraintPackageLabelRectangle0 = new GridData();
			constraintPackageLabelRectangle0.verticalAlignment = .;
			constraintPackageLabelRectangle0.horizontalAlignment = .;
			constraintPackageLabelRectangle0.horizontalIndent = 0;
			constraintPackageLabelRectangle0.horizontalSpan = 1;
			constraintPackageLabelRectangle0.verticalSpan = 1;
			constraintPackageLabelRectangle0.grabExcessHorizontalSpace = false;
			constraintPackageLabelRectangle0.grabExcessVerticalSpace = false;
			this.add(constraintPackageLabelRectangle0);
			ToolbarLayout layoutPackageLabelRectangle0 = new ToolbarLayout();
			layoutPackageLabelRectangle0.setStretchMinorAxis(false);
			layoutPackageLabelRectangle0.setMinorAlignment(.);
			layoutPackageLabelRectangle0.setSpacing(5);
			layoutPackageLabelRectangle0.setVertical(true);
			.setLayoutManager(layoutPackageLabelRectangle0);
			 = new WrappingLabel();
			.setText("<..>"); //$NON-NLS-1$
			 = new WrappingLabel();
			.setText("<..>"); //$NON-NLS-1$
			RectangleFigure fillerFigure0 = new RectangleFigure();
			GridData constraintFillerFigure0 = new GridData();
			constraintFillerFigure0.verticalAlignment = .;
			constraintFillerFigure0.horizontalAlignment = .;
			constraintFillerFigure0.horizontalIndent = 0;
			constraintFillerFigure0.horizontalSpan = 1;
			constraintFillerFigure0.verticalSpan = 1;
			constraintFillerFigure0.grabExcessHorizontalSpace = false;
			constraintFillerFigure0.grabExcessVerticalSpace = false;
			this.add(fillerFigure0constraintFillerFigure0);
			GridData constraintFFigurePackageBodyRectangle = new GridData();
			constraintFFigurePackageBodyRectangle.verticalAlignment = .;
			constraintFFigurePackageBodyRectangle.horizontalAlignment = .;
			constraintFFigurePackageBodyRectangle.horizontalIndent = 0;
			constraintFFigurePackageBodyRectangle.horizontalSpan = 1;
			constraintFFigurePackageBodyRectangle.verticalSpan = 1;
			constraintFFigurePackageBodyRectangle.grabExcessHorizontalSpace = true;
			constraintFFigurePackageBodyRectangle.grabExcessVerticalSpace = true;
			this.add(constraintFFigurePackageBodyRectangle);
		}

Generated:
		private boolean myUseLocalCoordinates = false;
		private boolean canRemovedFromLabel;
		private WrappingLabel fFigureFromLabel;

Generated:
		protected boolean useLocalCoordinates() {
		}

Generated:
		protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
			 = useLocalCoordinates;
		}

Generated:
		}

Generated:
		public WrappingLabel getFigurePackageNameLabel() {
		}

Generated:
		}
		// @Override
		// public void setBounds(Rectangle rect) {
		// int preferenceHeight = rect.height -
		// packageLabelRectangle0.getBounds().height - lineWidth / 2;
		// if (preferenceHeight < 0) {
		// preferenceHeight = 0;
		// }
		// getFigurePackageBodyRectangle().setPreferredSize(rect.width,
		// preferenceHeight);
		// super.setBounds(rect);
		// }
		public void addFromLabel() {
		}
		public WrappingLabel getFigureFromLabel() {
		}
		public void removeFromLabel() {
			}
		}
		public void updateFromLabel(String text) {
			getFigureFromLabel().setText(text);
		}
	}
New to GrepCode? Check out our FAQ X