Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2007 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: EcoreEditPartFactory.java,v 1.5 2009/02/02 08:39:06 jlescot Exp $ /
 
 
 package org.eclipse.emf.ecoretools.diagram.edit.parts;
 
 import  org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
 import  org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
 import  org.eclipse.gmf.runtime.notation.View;
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.widgets.Text;

Generated:
 
 public class EcoreEditPartFactory implements EditPartFactory {

Generated:
 
 	public EditPart createEditPart(EditPart contextObject model) {
 		if (model instanceof View) {
 			View view = (View) model;
 			switch (EcoreVisualIDRegistry.getVisualID(view)) {
 
 				return new EPackageEditPart(view);
 
 				return new EClassEditPart(view);
 
 				return new EClassNameEditPart(view);
 
 				return new EPackage2EditPart(view);
 
 				return new EPackageNameEditPart(view);
 
 				return new EAnnotationEditPart(view);
 
 				return new EAnnotationSourceEditPart(view);
 
 				return new EDataTypeEditPart(view);
 
 				return new EDataTypeNameEditPart(view);
 
 				return new EDataTypeInstanceClassEditPart(view);
 
 				return new EEnumEditPart(view);
 
 				return new EEnumNameEditPart(view);
 
 				return new EAttributeEditPart(view);
 
 				return new EOperationEditPart(view);
 
 				return new EClass2EditPart(view);
 
 				return new EClassName2EditPart(view);
 
 				return new EDataType2EditPart(view);
 
 				return new EDataTypeName2EditPart(view);
 
				return new EEnum2EditPart(view);
				return new EEnumName2EditPart(view);
				return new EEnumLiteralEditPart(view);
				return new EClassAttributesEditPart(view);
				return new EClassOperationsEditPart(view);
				return new EPackageContentsEditPart(view);
				return new EClassAttributes2EditPart(view);
				return new EClassOperations2EditPart(view);
				return new EEnumLiteralsEditPart(view);
				return new EAnnotationDetailsEditPart(view);
				return new EEnumLiterals2EditPart(view);
				return new EReferenceEditPart(view);
				return new EReferenceNameEditPart(view);
				return new EClassESuperTypesEditPart(view);
			}
		}
		return createUnrecognizedEditPart(contextmodel);
	}

Generated:
	private EditPart createUnrecognizedEditPart(EditPart contextObject model) {
		// Handle creation of unrecognized child node EditParts here
		return null;
	}

Generated:
	public static CellEditorLocator getTextCellEditorLocator(ITextAwareEditPart source) {
		if (source.getFigure() instanceof WrappingLabel)
			return new TextCellEditorLocator((WrappingLabel) source.getFigure());
		else {
			return new LabelCellEditorLocator((Labelsource.getFigure());
		}
	}

Generated:
	static private class TextCellEditorLocator implements CellEditorLocator {

Generated:
		private WrappingLabel wrapLabel;

Generated:
		public TextCellEditorLocator(WrappingLabel wrapLabel) {
			this. = wrapLabel;
		}

Generated:
		public WrappingLabel getWrapLabel() {
			return ;
		}

Generated:
		public void relocate(CellEditor celleditor) {
			Text text = (Text) celleditor.getControl();
			Rectangle rect = getWrapLabel().getTextBounds().getCopy();
			if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) {
				rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT)));
else {
				int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
				rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
			}
			if (!rect.equals(new Rectangle(text.getBounds()))) {
				text.setBounds(rect.xrect.yrect.widthrect.height);
			}
		}
	}

Generated:
	private static class LabelCellEditorLocator implements CellEditorLocator {

Generated:
		private Label label;

Generated:
		public LabelCellEditorLocator(Label label) {
			this. = label;
		}

Generated:
		public Label getLabel() {
			return ;
		}

Generated:
		public void relocate(CellEditor celleditor) {
			Text text = (Text) celleditor.getControl();
			int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
			rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
			if (!rect.equals(new Rectangle(text.getBounds()))) {
				text.setBounds(rect.xrect.yrect.widthrect.height);
			}
		}
	}
New to GrepCode? Check out our FAQ X