Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2007, 2009 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: EEnum2EditPart.java,v 1.12 2009/04/20 15:08:17 jlescot Exp $ /
 
 
 package org.eclipse.emf.ecoretools.diagram.edit.parts;
 
 import java.util.List;
 
 import  org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
 import  org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
 import  org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
 import  org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
 import  org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy;
 import  org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
 import  org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
 import  org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
 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 EEnum2EditPart extends ShapeNodeEditPart {

Generated:
 
 	public static final int VISUAL_ID = 2005;

Generated:
 
 	protected IFigure contentPane;

Generated:
 
 	protected IFigure primaryShape;

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

Generated:
NOT
 
 	protected void createDefaultEditPolicies() {
 		installEditPolicy(EditPolicyRoles.CREATION_ROLEnew CreationEditPolicy() {
 
 			public Command getCommand(Request request) {
 				if (understandsRequest(request)) {
 					if (request instanceof CreateViewAndElementRequest) {
 						CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
 						IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
							EditPart compartmentEditPart = getChildBySemanticHint(EcoreVisualIDRegistry.getType(.));
							return compartmentEditPart == null ? null : compartmentEditPart.getCommand(request);
						}
					}
					return super.getCommand(request);
				}
				return null;
			}
		});
		super.createDefaultEditPolicies();
		installEditPolicy(EditPolicyRoles.SEMANTIC_ROLEnew EEnum2ItemSemanticEditPolicy());
		// 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:
		ConstrainedToolbarLayoutEditPolicy lep = new ConstrainedToolbarLayoutEditPolicy() {
				if (child.getEditPolicy(.) == null) {
					if (child instanceof ITextAwareEditPart) {
					}
				}
				return super.createChildEditPolicy(child);
			}
		};
		return lep;
	}

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

Generated:
	}

Generated:
	protected boolean addFixedChild(EditPart childEditPart) {
		if (childEditPart instanceof EEnumName2EditPart) {
			return true;
		}
		return false;
	}

Generated:
	protected boolean removeFixedChild(EditPart childEditPart) {
		if (childEditPart instanceof EEnumName2EditPart) {
			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) {
		return getContentPane();
	}

Generated:
NOT
	protected NodeFigure createNodePlate() {
		DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(getMapMode().DPtoLP(40), getMapMode().DPtoLP(40));
		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 == .) {
		}
		if (relationshipType == .) {
		}
		if (relationshipType == .) {
		}
		return types;
	}

Generated:
	public EditPart getTargetEditPart(Request request) {
		if (request instanceof CreateViewAndElementRequest) {
			CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
			IElementType type = (IElementType) adapter.getAdapter(IElementType.class);
				return getChildBySemanticHint(EcoreVisualIDRegistry.getType(.));
			}
		}
		return super.getTargetEditPart(request);
	}
	protected void refreshVisuals() {
		EObject semanticElement = resolveSemanticElement();
		if (FigureFromLabelUtils.needFromLabel(semanticElement, getNotationView())) {
			getPrimaryShape().updateFromLabel(FigureFromLabelUtils.getQualifiedName(semanticElement));
else {
		}
		super.refreshVisuals();
	}

(non-Javadoc)

See also:
org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart.handleNotificationEvent(org.eclipse.emf.common.notify.Notification)
	protected void handleNotificationEvent(Notification event) {
		if (event.getNotifier() == getModel() && ..getEModelElement_EAnnotations().equals(event.getFeature())) {
			handleMajorSemanticChange();
else {
			super.handleNotificationEvent(event);
		}
	}
	}

Generated:
NOT
	public class EnumerationFigure extends GradientRectangleFigure {

Generated:
		private WrappingLabel fFigureEnumerationNameLabel;

Generated:
NOT
		public EnumerationFigure() {
			ToolbarLayoutExt layoutThis = new ToolbarLayoutExt();
			layoutThis.setStretchMinorAxis(true);
			layoutThis.setSpacing(0);
			layoutThis.setVertical(true);
			this.setLayoutManager(layoutThis);
			this.setMinimumSize(new Dimension(getMapMode().DPtoLP(100), getMapMode().DPtoLP(30)));
		}

Generated:
NOT
		private void createContents() {
			WrappingLabel enumerationFixedNameLabel0 = new WrappingLabel();
			enumerationFixedNameLabel0.setAlignment(.);
			enumerationFixedNameLabel0.setText("<<enumeration>>"); //$NON-NLS-1$
			this.add(enumerationFixedNameLabel0);
			 = new WrappingLabel();
			.setText("<..>"); //$NON-NLS-1$
			 = new WrappingLabel();
			.setText("<..>"); //$NON-NLS-1$
		}

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

Generated:
		protected boolean useLocalCoordinates() {
		}

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

Generated:
		public WrappingLabel getFigureEnumerationNameLabel() {
		}
		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