⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shapeseditpartfactory.java

📁 mywork是rcp开发的很好的例子
💻 JAVA
字号:
/******************************************************************************* * Copyright (c) 2004, 2005 Elias Volanakis 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:�*����Elias Volanakis - initial API and implementation�*******************************************************************************/package net.sf.freenote.parts;import net.sf.freenote.mindmap.BranchEditPart;import net.sf.freenote.mindmap.model.BranchShape;import net.sf.freenote.model.Connection;import net.sf.freenote.model.Shape;import net.sf.freenote.model.ShapesDiagram;import net.sf.freenote.uml.SystemEditPart;import net.sf.freenote.uml.UmlShapeEditPart;import net.sf.freenote.uml.model.SystemShape;import net.sf.freenote.uml.model.UmlShape;import org.eclipse.gef.EditPart;import org.eclipse.gef.EditPartFactory;/** * Factory that maps model elements to edit parts. * @author Elias Volanakis */public class ShapesEditPartFactory implements EditPartFactory {/* * (non-Javadoc) * @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object) */public EditPart createEditPart(EditPart context, Object modelElement) {	// get EditPart for model element	EditPart part = getPartForElement(modelElement);	// store model element in EditPart	part.setModel(modelElement);	return part;}/** * Maps an object to an EditPart.  * @throws RuntimeException if no match was found (programming error) */private EditPart getPartForElement(Object modelElement) {	//注意:本方法中的if有前后顺序要求	if(modelElement instanceof BranchShape){		return new BranchEditPart(); 	}	if(modelElement instanceof SystemShape){		return new SystemEditPart();	}	if(modelElement instanceof UmlShape){		return new UmlShapeEditPart();	}	if (modelElement instanceof Shape) {		return new ShapeEditPart();	}	if (modelElement instanceof ShapesDiagram) {		return new DiagramEditPart();	}	if (modelElement instanceof Connection) {		return new ConnectionEditPart();	}	throw new RuntimeException(			"Can't create part for model element: "			+ ((modelElement != null) ? modelElement.getClass().getName() : "null"));}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -