//Generated on Wed Aug 08 14:32:53 CEST 2012 with EGF 1.0.0.qualifier | |
package org.eclipse.egf.emf.pattern.model.cdo; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import org.eclipse.core.resources.IFile; | |
import org.eclipse.core.resources.IFolder; | |
import org.eclipse.core.resources.IResource; | |
import org.eclipse.core.resources.IWorkspaceRoot; | |
import org.eclipse.core.resources.ResourcesPlugin; | |
import org.eclipse.core.runtime.NullProgressMonitor; | |
import org.eclipse.core.runtime.Path; | |
import org.eclipse.egf.model.domain.EMFDomain; | |
import org.eclipse.egf.model.pattern.Node; | |
import org.eclipse.egf.model.pattern.PatternContext; | |
import org.eclipse.egf.pattern.execution.InternalPatternContext; | |
import org.eclipse.egf.pattern.execution.OutputManager; | |
import org.eclipse.egf.pattern.query.IQuery; | |
import org.eclipse.emf.codegen.ecore.genmodel.GenModel; | |
public class deletePackageImpl { | |
public deletePackageImpl() { | |
//Here is the constructor | |
// add initialisation of the pattern variables (declaration has been already done). | |
} | |
public void generate(Object argument) throws Exception { | |
InternalPatternContext ctx = (InternalPatternContext) argument; | |
IQuery.ParameterDescription paramDesc = null; | |
Map<String, String> queryCtx = null; | |
Node.Container currentNode = ctx.getNode(); | |
List<Object> genPackageList = null; | |
//this pattern can only be called by another (i.e. it's not an entry point in execution) | |
for (Object genPackageParameter : genPackageList) { | |
this.genPackage = (org.eclipse.emf.codegen.ecore.genmodel.GenPackage) genPackageParameter; | |
if (preCondition(ctx)) { | |
ctx.setNode(new Node.Container(currentNode, getClass())); | |
orchestration((PatternContext) argument); | |
} | |
} | |
if (ctx.useReporter()) { | |
ctx.getReporter().executionFinished(OutputManager.computeExecutionOutput(ctx), ctx); | |
} | |
} | |
public String orchestration(PatternContext ctx) throws Exception { | |
InternalPatternContext ictx = (InternalPatternContext) ctx; | |
Node.Container currentNode = ictx.getNode(); | |
method_delete(new StringBuffer(), ictx); | |
ictx.setNode(currentNode); | |
if (ictx.useReporter()) { | |
Map<String, Object> parameterValues = new HashMap<String, Object>(); | |
parameterValues.put("genPackage", this.genPackage); | |
String outputWithCallBack = OutputManager.computeLoopOutput(ictx); | |
String loop = OutputManager.computeLoopOutputWithoutCallback(ictx); | |
ictx.getReporter().loopFinished(loop, outputWithCallBack, ictx, parameterValues); | |
} | |
return null; | |
} | |
protected void method_delete(final StringBuffer out, final PatternContext ctx) throws Exception { | |
EMFDomain domainOut = (EMFDomain) ctx.getValue("domainOut"); | |
GenModel newGenModel = (GenModel) domainOut.getContent().get(0); | |
String newModelDirectory = newGenModel.getModelDirectory(); | |
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); | |
Path path = new Path(newModelDirectory + "/" + genPackage.getClassPackageName().replace('.', '/')); | |
IFolder folder = root.getFolder(path); | |
if (folder.exists()) | |
folder.delete(true, new NullProgressMonitor()); | |
InternalPatternContext ictx = (InternalPatternContext) ctx; | |
new Node.DataLeaf(ictx.getNode(), getClass(), "delete", out.toString()); | |
} | |
public boolean preCondition(PatternContext ctx) throws Exception { | |
return true; | |
} | |
protected org.eclipse.emf.codegen.ecore.genmodel.GenPackage genPackage; | |
public void set_genPackage(org.eclipse.emf.codegen.ecore.genmodel.GenPackage genPackage) { | |
this.genPackage = genPackage; | |
} | |
public Map<String, Object> getParameters() { | |
Map<String, Object> parameters = new HashMap<String, Object>(); | |
parameters.put("genPackage", this.genPackage); | |
return parameters; | |
} | |
} |