Package org.objectstyle.wolips.eogenerator.core.model

Examples of org.objectstyle.wolips.eogenerator.core.model.EOGeneratorModel


      EOModelGroup modelGroup = new EOModelGroup();
      final Set<EOModelVerificationFailure> failures = new HashSet<EOModelVerificationFailure>();
      IEOModelGroupFactory.Utility.loadModelGroup(_modelFile, modelGroup, failures, true, _modelFile.getLocationURI().toURL(), new NullProgressMonitor());
      EOModel model = modelGroup.getEditingModel();
      if (model != null) {
        EOGeneratorModel eogenModel = EOGeneratorWizard.createEOGeneratorModel(_modelFile.getParent(), model, false);
        String eogenBasePath = URLUtils.cheatAndTurnIntoFile(model.getModelURL()).getAbsolutePath();
        int dotIndex = eogenBasePath.lastIndexOf('.');
        eogenBasePath = eogenBasePath.substring(0, dotIndex);
        String eogenPath = eogenBasePath + extension;
        IFile eogenFile = _modelFile.getWorkspace().getRoot().getFileForLocation(new Path(eogenPath));
        for (int dupeNum = 0; eogenFile.exists(); dupeNum++) {
          eogenPath = eogenBasePath + dupeNum + extension;
          eogenFile = _modelFile.getWorkspace().getRoot().getFileForLocation(new Path(eogenPath));
        }
        eogenModel.writeToFile(eogenFile, null);
      }
      if (!failures.isEmpty()) {
        Display.getDefault().asyncExec(new Runnable() {
          public void run() {
            new EOModelErrorDialog(new Shell(), failures).open();
View Full Code Here


      throwCoreException("Container \"" + containerName + "\" does not exist.");
    }
    IContainer container = (IContainer) resource;
    final IFile file = container.getFile(new Path(fileName));
    try {
      EOGeneratorModel model = EOGeneratorCreator.createDefaultModel(container.getProject());
      model.writeToFile(file, monitor);
    } catch (IOException e) {
      e.printStackTrace();
    }
    monitor.worked(1);
    monitor.setTaskName("Opening file for editing...");
View Full Code Here

  public void init(IWorkbench workbench, IStructuredSelection selection) {
    _selection = selection;
  }

  public static EOGeneratorModel createEOGeneratorModel(IContainer parentResource, EOModel targetModel, boolean includeRefModels) {
    EOGeneratorModel eogenModel = EOGeneratorCreator.createDefaultModel(parentResource.getProject());
    EOModelGroup modelGroup = targetModel.getModelGroup();
    List<EOModel> exceptModels = new LinkedList<EOModel>();
    exceptModels.add(targetModel);
    List<EOModelReference> modelReferences = EOGeneratorModel.createModelReferencesForModelGroup(modelGroup, exceptModels);
    File modelFolder = URLUtils.cheatAndTurnIntoFile(targetModel.getModelURL());
    if (modelFolder != null) {
      eogenModel.addModel(new EOModelReference(new Path(modelFolder.getAbsolutePath())));
    }
    if (includeRefModels) {
      eogenModel.setLoadModelGroup(Boolean.FALSE);
      for (EOModelReference modelReference : modelReferences) {
        eogenModel.addRefModel(modelReference);
      }
    }
   
    // MS: If you link to ERExtensions and you didn't set your default template names, guess that you want the Wonder versions
    try {
      if (eogenModel.getDefaultJavaTemplate() == null && ((ProjectFrameworkAdapter)parentResource.getProject().getAdapter(ProjectFrameworkAdapter.class)).isLinkedToFrameworkNamed("ERExtensions")) {
        eogenModel.setJavaTemplate("_WonderEntity.java");
        eogenModel.setSubclassJavaTemplate("WonderEntity.java");
      }
    }
    catch (Throwable t) {
      t.printStackTrace();
    }
View Full Code Here

      throwCoreException("Container \"" + containerName + "\" does not exist.");
    }
    IContainer container = (IContainer) resource;
    final IFile file = container.getFile(new Path(fileName));
    try {
      EOGeneratorModel model = EOGeneratorCreator.createDefaultModel(container.getProject());
      model.writeToFile(file, monitor);
    } catch (IOException e) {
      e.printStackTrace();
    }
    monitor.worked(1);
    monitor.setTaskName("Opening file for editing...");
View Full Code Here

    File modelFolderFile = model.saveToFolder(parentContainer.getLocation().toFile());
    IFolder modelFolder = parentContainer.getFolder(new Path(modelFolderFile.getName()));
    String baseName = model.getName();

    if (_createEOGeneratorFile) {
      EOGeneratorModel eogenModel = EOGeneratorWizard.createEOGeneratorModel(parentContainer, model, false);
      IFile eogenFile = parentContainer.getFile(new Path(baseName + ".eogen"));
      if (eogenFile.exists()) {
        for (int dupeNum = 1; !eogenFile.exists(); dupeNum++) {
          eogenFile = parentContainer.getFile(new Path(baseName + dupeNum + ".eogen"));
        }
      }
      eogenModel.writeToFile(eogenFile, monitor);
    }
    parentContainer.refreshLocal(IResource.DEPTH_INFINITE, monitor);

    if (createModelGroup) {
      EOGeneratorModel modelGroupModel = EOGeneratorCreator.createDefaultModel(_parentResource.getProject());
      if (modelFolder != null) {
        Path modelPath = new Path(modelFolderFile.getAbsolutePath());
        EOModelReference modelReference = new EOModelReference(modelPath);
        modelGroupModel.addModel(modelReference);
      }
      IFile modelGroupFile = parentContainer.getFile(new Path(baseName + ".eomodelgroup"));
      modelGroupModel.writeToFile(modelGroupFile, monitor);
      _page.setResourceToReveal(modelGroupFile);
    } else {
      _page.setResourceToReveal(modelFolder.findMember("index.eomodeld"));
    }
  }
View Full Code Here

    }
    return workingDir;
  }
 
  public static void main(String[] args2) throws Exception {
    EOGeneratorModel eogeneratorModel = new EOGeneratorModel();
    eogeneratorModel.setPackageDirs(Boolean.TRUE);
    eogeneratorModel.setExtension("java");
   
    List<String> argsList = new LinkedList<String>();
    for (String arg : args2) {
      argsList.add(arg);
    }

    File workingDir = workingDir(argsList);
    if (argsList.size() >= 2 && "-config".equals(argsList.get(0))) {
      BufferedReader br = new BufferedReader(new FileReader(PathUtils.getAbsolutePath(argsList.get(1), workingDir)));
      try {
        StringBuilder sb = new StringBuilder();
        String configLine;
        while ((configLine = br.readLine()) != null) {
          sb.append(configLine.replaceFirst("\\\\$", ""));
        }
        eogeneratorModel.readFromString(sb.toString(), workingDir);
      }
      finally {
        br.close();
      }
    }

    if (workingDir == null) {
      workingDir = workingDir(argsList);
    }
   
    boolean loadModelGroup = false;
    File modelGroupFolder = workingDir == null ? new File(".") : workingDir;
    List<String> modelPaths = new LinkedList<String>();
    List<String> entityList = new LinkedList<String>();
    boolean force = false;
    boolean useStdout = false;
   
    for (int argNum = 0; argNum < argsList.size(); argNum++) {
      String arg = argsList.get(argNum);
      if ("-model".equalsIgnoreCase(arg)) {
        modelPaths.add(Veogen.path(workingDir, argsList.get(++argNum)));
      }
      else if ("-modelgroup".equalsIgnoreCase(arg)) {
        modelGroupFolder = new File(Veogen.path(workingDir, argsList.get(++argNum)));
        loadModelGroup = true;
      }
      else if ("-templateDir".equalsIgnoreCase(arg)) {
        eogeneratorModel.setTemplateDir(Veogen.path(workingDir, argsList.get(++argNum)));
      }
      else if ("-superclassTemplate".equalsIgnoreCase(arg)) {
        eogeneratorModel.setJavaTemplate(argsList.get(++argNum));
      }
      else if ("-subclassTemplate".equalsIgnoreCase(arg)) {
        eogeneratorModel.setSubclassJavaTemplate(argsList.get(++argNum));
      }
      else if ("-javaTemplate".equalsIgnoreCase(arg)) {
        eogeneratorModel.setJavaTemplate(argsList.get(++argNum));
      }
      else if ("-subclassJavaTemplate".equalsIgnoreCase(arg)) {
        eogeneratorModel.setSubclassJavaTemplate(argsList.get(++argNum));
      }
      else if ("-extension".equalsIgnoreCase(arg)) {
        eogeneratorModel.setExtension(argsList.get(++argNum));
      }
      else if ("-java".equalsIgnoreCase(arg)) {
        eogeneratorModel.setJava(Boolean.TRUE);
      }
      else if ("-javaClient".equalsIgnoreCase(arg)) {
        eogeneratorModel.setJavaClient(Boolean.TRUE);
      }
      else if ("-destination".equalsIgnoreCase(arg)) {
        eogeneratorModel.setDestination(Veogen.path(workingDir, argsList.get(++argNum)));
      }
      else if ("-subclassDestination".equalsIgnoreCase(arg)) {
        eogeneratorModel.setSubclassDestination(Veogen.path(workingDir, argsList.get(++argNum)));
      }
      else if ("-prefix".equalsIgnoreCase(arg)) {
        eogeneratorModel.setPrefix(argsList.get(++argNum));
      }
      else if ("-superclassPackage".equalsIgnoreCase(arg)) {
        eogeneratorModel.setSuperclassPackage(argsList.get(++argNum));
      }
      else if ("-verbose".equalsIgnoreCase(arg)) {
        eogeneratorModel.setVerbose(Boolean.TRUE);
      }
      else if ("-java14".equalsIgnoreCase(arg)) {
        eogeneratorModel.setJava14(true);
      }
      else if ("-generate".equalsIgnoreCase(arg)) {
        String modelName = argsList.get(++argNum);
        eogeneratorModel.addModel(new EOModelReference(new Path(modelName)));
      }
      else if ("-loadModelGroup".equalsIgnoreCase(arg)) {
        loadModelGroup = true;
      }
      else if ("-force".equalsIgnoreCase(arg)) {
        force = true;
      }
      else if ("-workingDir".equalsIgnoreCase(arg)) {
        argNum ++;
      }
      else if ("-config".equalsIgnoreCase(arg)) {
        argNum ++;
      }
      else if ("-stdout".equalsIgnoreCase(arg))
        useStdout = true;
      else {
        entityList.add(arg);
      }
    }

    if (eogeneratorModel.getModels() == null || eogeneratorModel.getModels().isEmpty()) {
      for (String modelPath : modelPaths) {
        eogeneratorModel.addModel(new EOModelReference(new Path(modelPath)));
      }
    }

    if (eogeneratorModel.getDestination() == null || eogeneratorModel.getModels().size() == 0) {
      System.out.println("veogen");
      System.out.println("  -config /path/to/eogen");
      System.out.println("    the path to an eogen file to use as the config");
      System.out.println("  -model /path/to/model.eomodeld");
      System.out.println("    the path to a model to add to this model group (multiples allowed)");
      System.out.println("  -modelgroup /path/to/modelgroup/folder");
      System.out.println("    the path that can be traversed to find models (finds dependencies), implies -loadModelGroup");
      System.out.println("  -templateDir /path/containing/templates");
      System.out.println("    the path to the folder that contains templates");
      System.out.println("  -superclassTemplate nameOfTemplate.java");
      System.out.println("    the name of the superclass template file (_File.java)");
      System.out.println("  -subclassTemplate nameOfTemplate.java");
      System.out.println("    the name of the subclass template file (File.java)");
      System.out.println("  -extension");
      System.out.println("    the file extension for generated files (default \".java + \")");
      System.out.println("  -java");
      System.out.println("    generate regular java output (default)");
      System.out.println("  -javaClient");
      System.out.println("    generate java client output");
      System.out.println("  -destination /path/for/output");
      System.out.println("    the path to the folder to write generated superclass output input");
      System.out.println("  -subclassDestination /path/for/subclass/output");
      System.out.println("    the path to the folder to write generated subclass output input");
      System.out.println("  -prefix thePrefix");
      System.out.println("    the prefix to prepend to superclass names (default: _)");
      System.out.println("  -superclassPackage packageName");
      System.out.println("    the package name to append to superclass package name (default: none)");
      System.out.println("  -verbose");
      System.out.println("    generate verbose output");
      System.out.println("  -java14");
      System.out.println("    switch to Java 1.4 templates");
      System.out.println("  -generate modelName");
      System.out.println("    generate source files for the model with the given name (multiples allowed).");
      System.out.println("    if no explicit generate flags are specified, the items from -model will be used.");
      System.out.println("  -loadModelGroup");
      System.out.println("    if specified and -modelgroup is not, an implicit modelgroup folder of '.' will be used.");
      System.out.println("  -workingDir");
      System.out.println("    the working directory to prepend to all the provided paths");
      System.out.println("  -force");
      System.out.println("    force generation even if there are errors");
      System.out.println("  -stdout");
      System.out.println("    send output to the console instead of the filesystem");
      System.out.println();
      System.out.println("You must specify at least -destination and a -generate or -model.");
      System.exit(0);
    }

    if (eogeneratorModel.getSubclassDestination() == null) {
      eogeneratorModel.setSubclassDestination(eogeneratorModel.getDestination());
    }

    EOModelGroup modelGroup = new EOModelGroup();
    Set<EOModelVerificationFailure> failures = new HashSet<EOModelVerificationFailure>();
    if (loadModelGroup || modelPaths.size() == 0) {
View Full Code Here

        locate.locate();

        IResource[] eogenFiles = result.getResources();
        for (IResource eogenResource : eogenFiles) {
          IFile eogenFile = (IFile) eogenResource;
          EOGeneratorModel eogenModel = EOGeneratorModel.createModelFromFile(eogenFile);
          if (eogenModel.isModelReferenced(modifiedModelReference)) {
            EOGenerateWorkspaceJob eogenerateJob = new EOGenerateWorkspaceJob(eogenFile);
            eogenerateJob.addListener(new MarkerEOGeneratorListener());
            eogenerateJob.schedule();
          }
        }
View Full Code Here

  }

  protected void addModelsFromEOModelGroupFile(IFile eoModelGroupFile, EOModelGroup modelGroup, Set<EOModelVerificationFailure> failures, boolean skipOnDuplicates, IProgressMonitor progressMonitor) throws ParseException, CoreException, IOException, EOModelException {
    EOModel model = null;
    IProject project = eoModelGroupFile.getProject();
    EOGeneratorModel eogeneratorModel = EOGeneratorModel.createModelFromFile(eoModelGroupFile);
    List<EOModelReference> modelRefList = new LinkedList<EOModelReference>();
    modelRefList.addAll(eogeneratorModel.getModels());
    modelRefList.addAll(eogeneratorModel.getRefModels());
    for (EOModelReference modelRef : modelRefList) {
      String modelPath = modelRef.getPath(project);
      File modelFolder = new File(modelPath);
      if (!modelFolder.isAbsolute()) {
        modelFolder = new File(project.getLocation().toFile(), modelPath);
View Full Code Here

import org.objectstyle.wolips.eogenerator.core.model.EOGeneratorModel;
import org.objectstyle.wolips.jdt.ProjectFrameworkAdapter;

public class EOGeneratorCreator {
  public static EOGeneratorModel createDefaultModel(IProject project) {
    EOGeneratorModel model = new EOGeneratorModel(project);
    model.setJava(Boolean.TRUE);
    model.setPackageDirs(Boolean.TRUE);
    model.setVerbose(Boolean.TRUE);
    model.setLoadModelGroup(Boolean.TRUE);
    // model.setEOGeneratorPath(Preferences.getEOGeneratorPath());
    // model.setJavaTemplate(Preferences.getEOGeneratorJavaTemplate());
    // model.setTemplateDir(Preferences.getEOGeneratorTemplateDir());
    // model.setSubclassJavaTemplate(Preferences.getEOGeneratorSubclassJavaTemplate());
    try {
      IJavaProject javaProject = JavaCore.create(project);
      if (javaProject != null) {
        IClasspathEntry[] classpathEntry = javaProject.getRawClasspath();
        for (int classpathEntryNum = 0; classpathEntryNum < classpathEntry.length; classpathEntryNum++) {
          IClasspathEntry entry = classpathEntry[classpathEntryNum];
          if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
            IPath path = entry.getPath();
            if (path != null) {
              IFolder sourceFolder = project.getWorkspace().getRoot().getFolder(path);
              IPath projectRelativePath = sourceFolder.getProjectRelativePath();
              String projectRelativePathStr = projectRelativePath.toPortableString();
              model.setDestination(projectRelativePathStr);
              model.setSubclassDestination(projectRelativePathStr);
            }
          }
        }
      }
    } catch (JavaModelException e) {
      e.printStackTrace();
    }
   
   
    // MS: If you link to ERExtensions and you didn't set your default template names, guess that you want the Wonder versions
    try {
      if (ComparisonUtils.equals(model.getDefaultJavaTemplate(), null, true) && ((ProjectFrameworkAdapter)project.getAdapter(ProjectFrameworkAdapter.class)).isLinkedToFrameworkNamed("ERExtensions")) {
        model.setJavaTemplate("_WonderEntity.java");
        model.setSubclassJavaTemplate("WonderEntity.java");
      }
    }
    catch (Throwable t) {
      t.printStackTrace();
    }
View Full Code Here

TOP

Related Classes of org.objectstyle.wolips.eogenerator.core.model.EOGeneratorModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.