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: EClassCreateCommand.java,v 1.3 2009/02/02 08:39:07 jlescot Exp $ /
package org.eclipse.emf.ecoretools.diagram.edit.commands;
import  org.eclipse.core.runtime.IAdaptable;
import  org.eclipse.core.runtime.IProgressMonitor;
import  org.eclipse.gmf.runtime.common.core.command.CommandResult;
import  org.eclipse.gmf.runtime.common.core.command.ICommand;
import  org.eclipse.gmf.runtime.emf.type.core.IElementType;
import  org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
import  org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
import  org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import  org.eclipse.gmf.runtime.notation.View;

Generated:
public class EClassCreateCommand extends EditElementCommand {

Generated:
	public EClassCreateCommand(CreateElementRequest req) {
		super(req.getLabel(), nullreq);
	}

Generated:
	protected EObject getElementToEdit() {
		EObject container = ((CreateElementRequest) getRequest()).getContainer();
		if (container instanceof View) {
			container = ((View) container).getElement();
		}
		return container;
	}

Generated:
	public boolean canExecute() {
		return true;
	}

Generated:
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable infothrows ExecutionException {
		owner.getEClassifiers().add(newElement);
		doConfigure(newElementmonitorinfo);
		((CreateElementRequest) getRequest()).setNewElement(newElement);
		return CommandResult.newOKCommandResult(newElement);
	}

Generated:
	protected void doConfigure(EClass newElement, IProgressMonitor monitor, IAdaptable infothrows ExecutionException {
		IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
		ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElementelementType);
		configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
		configureRequest.addParameters(getRequest().getParameters());
		ICommand configureCommand = elementType.getEditCommand(configureRequest);
		if (configureCommand != null && configureCommand.canExecute()) {
			configureCommand.execute(monitorinfo);
		}
	}
New to GrepCode? Check out our FAQ X