Package org.springframework.roo.shell.eclipse

Examples of org.springframework.roo.shell.eclipse.Bootstrap


    return this.isReady;
  }

  public void removeTab() {
    if (bootstrap != null) {
      final Bootstrap shutdownBootstrap = bootstrap;
      Job shutdownJob = new Job("Shutdown Roo") {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
          shutdownBootstrap.shutdown();
          return Status.OK_STATUS;
        }
      };
      shutdownJob.schedule();
    }
View Full Code Here


          projectLocation = project.getRawLocation().toOSString();
        }

        try {
          ProjectRefresher refresher = new ProjectRefresher(project);
          bootstrap = new Bootstrap(projectLocation, install.getHome(), install.getVersion(), refresher);
          bootstrap.start(appender, project.getName());

          setEnabled(true);

          // refresh the project to make sure we are in sync with Roo
View Full Code Here

  }

  private void performInstall(RooAddOnManagerDialog dialog, final RooShellTab tab) {
    final Collection<PluginVersion> toInstall = dialog.getSelectedToInstall();
    final Collection<PluginVersion> toUninstall = dialog.getSelectedtoUninstall();
    final Bootstrap bootstrap = tab.getBootstrap();
    Job installJob = new Job("Installing Roo Add-ons") {
      public IStatus run(IProgressMonitor monitor) {
        try {
          monitor.beginTask("Performing operations", toInstall.size() + toUninstall.size());
          return doInstall(tab, bootstrap, toInstall, toUninstall, monitor);
View Full Code Here

        IRooInstall install = (useDefault ? RooCoreActivator.getDefault().getInstallManager()
            .getDefaultRooInstall() : RooCoreActivator.getDefault().getInstallManager().getRooInstall(
            rooInstall));
        monitor.worked(1);

        Bootstrap bootstrap = null;
        try {
          // Create project location
          monitor.subTask("creating project location");
          File projectFile = new File(new File(location), projectPage.getProjectName());
          if (!projectFile.exists()) {
            projectFile.mkdirs();
          }
          monitor.worked(2);
          monitor.subTask("starting Spring Roo shell");

          String javaVersion = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance");
          String rooJavaVersion = (ROO_JAVA_VERSION_MAPPING.containsKey(javaVersion) ? ROO_JAVA_VERSION_MAPPING
              .get(javaVersion)
              : "6");

          // Create Roo project by launching Roo and invoking the
          // create project command
          String projectLocation = projectFile.getCanonicalPath();

          bootstrap = new Bootstrap(projectLocation, install.getHome(), install.getVersion(), new ProjectRefresher(null));

          // Init Roo shell
          bootstrap.start(new StyledTextAppender(shellPage.getRooShell()), projectPage.getProjectName());
          monitor.worked(3);

          ProjectType type = projectPage.getProjectType();

          // Create project
          monitor.subTask(String.format("execute Spring Roo '%s' command", type.getCommand()));
          StringBuilder builder = new StringBuilder();
          builder.append(type.getCommand());
          builder.append(" --topLevelPackage ").append(projectPage.getPackageName());
          if (type == ProjectType.PROJECT) {
            builder.append(" --projectName ").append(projectPage.getProjectName());
            builder.append(" --java ").append(rooJavaVersion);
            if (RooUiUtil.isRoo120OrGreater(install)) {
              builder.append(" --packaging ").append(packagingProvider);
            }
          }
          else {
            builder.append(" --description \"").append(projectPage.getDescription()).append("\"");
          }

          final String commandString = builder.toString();

          Display.getDefault().asyncExec(new Runnable() {

            public void run() {
              shellPage.getRooShell().append(commandString + StyledTextAppender.NL);
            }
          });

          bootstrap.execute(commandString);

          // Shutdown Roo
          bootstrap.shutdown();
          bootstrap = null;
          monitor.worked(4);

          // Write our own .classpath file if M2E can't provide one for us
          if (!DependencyManagementUtils.IS_M2ECLIPSE_PRESENT) {
            monitor.subTask("configuring Eclipse project meta data");
            // Setup Eclipse metadata
            File classpathDescriptor = new File(projectFile, ".classpath");
            FileWriter writer = new FileWriter(classpathDescriptor);
            if (type == ProjectType.PROJECT) {
              // For now, only Java projects & web projects
              if (!RooUiUtil.isRoo120OrGreater(install) || "jar".equalsIgnoreCase(packagingProvider)
                  || "war".equalsIgnoreCase(packagingProvider)) {
                writer.write(CLASSPATH_FILE);
              }
            }
            else {
              // Add-on projects
              writer.write(CLASSPATH_FILE);
            }
            writer.flush();
            writer.close();
          }

          monitor.subTask("importing project into workspace");
          IWorkspace workspace = ResourcesPlugin.getWorkspace();
          IProject project = workspace.getRoot().getProject(projectPage.getProjectName());
          IProjectDescription desc = workspace.newProjectDescription(projectPage.getProjectName());
          if (projectPage.isExternalProject()) {
            desc.setLocation(new Path(projectLocation));
          }

          project.create(desc, new NullProgressMonitor());
          project.open(0, new NullProgressMonitor());
          project.setDescription(desc, new NullProgressMonitor());

          if (type == ProjectType.PROJECT) {
            if (!RooUiUtil.isRoo120OrGreater(install) || "jar".equalsIgnoreCase(packagingProvider)
                || "war".equalsIgnoreCase(packagingProvider)) {
              // For now, only Java projects & web projects
              SpringCoreUtils.addProjectBuilder(project, "org.eclipse.ajdt.core.ajbuilder", new NullProgressMonitor());
              SpringCoreUtils.addProjectBuilder(project, SpringCore.BUILDER_ID, new NullProgressMonitor());
              SpringCoreUtils.addProjectNature(project, JavaCore.NATURE_ID, new NullProgressMonitor());
              SpringCoreUtils.addProjectNature(project, "org.eclipse.ajdt.ui.ajnature", new NullProgressMonitor());
            }
            SpringCoreUtils.addProjectNature(project, SpringCore.NATURE_ID, new NullProgressMonitor());
            SpringCoreUtils.addProjectNature(project, RooCoreActivator.NATURE_ID, new NullProgressMonitor());
          } else {
            // Add-ons
            SpringCoreUtils.addProjectBuilder(project, JavaCore.BUILDER_ID, new NullProgressMonitor());
            SpringCoreUtils.addProjectNature(project, JavaCore.NATURE_ID, new NullProgressMonitor());
            SpringCoreUtils.addProjectBuilder(project, SpringCore.BUILDER_ID, new NullProgressMonitor());
            SpringCoreUtils.addProjectNature(project, SpringCore.NATURE_ID, new NullProgressMonitor());
          }
         
          SpringCorePreferences.getProjectPreferences(project, RooCoreActivator.PLUGIN_ID).putBoolean(
              RooCoreActivator.PROJECT_PROPERTY_ID, useDefault);
          SpringCorePreferences.getProjectPreferences(project, RooCoreActivator.PLUGIN_ID).putString(
              RooCoreActivator.ROO_INSTALL_PROPERTY, rooInstall);
         
          configureProjectUi(project);
         
          if (DependencyManagementUtils.IS_M2ECLIPSE_PRESENT) {
            DependencyManagementUtils.installDependencyManagement(project, dependencyManagement);
          }
         
          new OpenShellJob(project).schedule();

          monitor.worked(6);
          monitor.done();
        }
        catch (Throwable e) {
          SpringCore.log(e);
        }
        finally {
          if (bootstrap != null) {
            // Shutdown Roo
            try {
              bootstrap.shutdown();
            }
            catch (Throwable e) {
            }
          }
        }
View Full Code Here

TOP

Related Classes of org.springframework.roo.shell.eclipse.Bootstrap

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.