Ejemplo n.º 1
0
  protected void enhanceProject(final IProject project, final IProgressMonitor monitor)
      throws CoreException {
    OutputImpl output = new OutputImpl();
    output.addOutlet(
        new Outlet(
            false, getEncoding(), null, true, project.getLocation().makeAbsolute().toOSString()));

    XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl(output, null);
    execCtx.getResourceManager().setFileEncoding("UTF-8");
    execCtx.registerMetaModel(new JavaBeansMetaModel());

    XpandFacade facade = XpandFacade.create(execCtx);
    facade.evaluate("org::deltaj::ui::wizard::DeltaJNewProject::main", getProjectInfo());

    project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
  }
Ejemplo n.º 2
0
  /** Invokes the Template engine to generate resources */
  public static void generate(
      ExecutionFlow flow, String templatePath, IProject project, String targetFolder)
      throws CoreException {

    String absoluteTargetFolder =
        ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()
            + File.separator
            + project.getFullPath().toOSString()
            + File.separator
            + targetFolder;

    OutputImpl output = new OutputImpl();
    Outlet outlet = new Outlet(absoluteTargetFolder);
    outlet.setOverwrite(true);
    output.addOutlet(outlet);

    XpandExecutionContextImpl execCtx =
        new XpandExecutionContextImpl(
            output, null, Collections.<String, Variable>emptyMap(), null, null);
    EmfRegistryMetaModel metamodel =
        new EmfRegistryMetaModel() {
          @Override
          protected EPackage[] allPackages() {
            return new EPackage[] {
              SGraphPackage.eINSTANCE,
              StextPackage.eINSTANCE,
              EcorePackage.eINSTANCE,
              SexecPackage.eINSTANCE
            };
          }
        };
    execCtx.registerMetaModel(metamodel);
    // generate
    XpandFacade facade = XpandFacade.create(execCtx);
    facade.evaluate(templatePath, flow);
    // refresh the project to get external updates:
    project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
  }