Package org.springframework.ide.eclipse.wizard.template.infrastructure

Examples of org.springframework.ide.eclipse.wizard.template.infrastructure.Template


  }

  @Override
  public void configureProject(IProgressMonitor monitor) throws CoreException {

    Template template = configurationDescriptor.getTemplate();
    IProject project = getProject();

    if (template == null) {
      handleError("No project template selected to configure the project: " + getProject().getName());
      return;
    }

    if (project == null) {
      handleError("Failed to create a project. No project available to configure.");
      return;
    }

    // Now collect all the template variable inputs
    IStatus status = collectInput();

    if (status == null || status.getSeverity() != IStatus.ERROR) {

      if (status != null && status.getSeverity() == IStatus.WARNING) {
        WizardPlugin.getDefault().getLog().log(status);
      }
      URI newPath = configurationDescriptor.getProjectLocationPath();

      String[] topLevelPackageTokens = configurationDescriptor.getTopLevelPackageTokens();
      String projectName = project.getName();

      try {
        ProcessingInfo processingInfo = new NewProjectProcessingInfo(template.getZippedLocation(), getProject()
            .getName(), configurationDescriptor.getSpringVersion());

        Processor processor = new Processor(processingInfo);
        IProject processedProject = processor.process(project, newPath, topLevelPackageTokens,
            configurationDescriptor.getProjectNameToken(), collectedInput, inputKinds, shell, monitor);
View Full Code Here


        collectedInput.putAll(desCollectedInput);
      }
    }

    // Also handle the Spring version replacement
    Template template = configurationDescriptor.getTemplate();
    String templateSpringVersion = template != null && template.getTemplateData() != null
        && template.getTemplateData().getDescriptor() != null ? template.getTemplateData().getDescriptor()
        .getSpringVersion() : null;
    SpringVersion userDefinedSpringVersion = configurationDescriptor.getSpringVersion();
    // Check if there is another token that is also using the same value as
    // the template-defined Spring version.
    // If so, log a warning that Spring version cannot be replaced as the
View Full Code Here

  @Override
  public IWizardPage getNextPage(IWizardPage page) {
    // Templates are downloaded only when a user clicks "Next"
    if (page == getWizard().getMainPage()) {

      final Template template = getWizard().getModel().selectedTemplate.getValue();

      // First, clear the cached first template page, as to not show the
      // wrong page
      firstTemplatePage = null;

      if (template == null) {
        // no need to log an error that a template was not
        // selected, template validation occurs in the template
        // selection part
        // itself.
        return null;
      }
      else if (template instanceof SimpleProject && !((SimpleProject) template).hasWizardPages()) {
        // Handle the special case simple projects with no pages
        return null;
      }
      else {
        // Download the template contents for templates that contribute
        // additional UI pages, as the
        // content will determine the UI controls of the additional
        // pages.
        if (!TemplateUtils.hasBeenDownloaded(template)) {
          final IStatus[] errors = new IStatus[1];
          PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

            public void run() {

              try {
                getWizard().getContainer().run(true, true,
                    new TemplateDataUIJob(template, getWizard().getShell()));

              }
              catch (InvocationTargetException ce) {
                String errorMessage = ErrorUtils.getErrorMessage(ce);
                errors[0] = new Status(IStatus.ERROR, WizardPlugin.PLUGIN_ID, errorMessage, ce);
              }
              catch (InterruptedException ie) {
                errors[0] = new Status(IStatus.ERROR, WizardPlugin.PLUGIN_ID,
                    "Interrupt exception while downloading data for " + template.getName());
              }

            }
          });

          if (errors[0] != null && !errors[0].isOK()) {
            handleError(errors[0]);
            return null;
          }
         
          // Let the UI know that the template was downloaded. This is
          // Only needed as long as the content manager does not fire
          // a more accurate event indicating which template changed.
          // Once the content manager is updated with that change,
          // this
          // call back is no longer needed
          getWizard().getMainPage().refreshTemplateInUI();
        }

        WizardUIInfo info = getUIInfo(template);

        if (info == null || !hasTemplateWizardPages()) {
          // Update the buttons so that the "Next" button is disabled.
          // This is done
          // indirectly by the wizard which calls hasNext() once
          // again to determine the button states based on data
          // already downloaded.
          getWizard().getContainer().updateButtons();
          return null;
        }

        ITemplateWizardPage previousPage = null;

        ITemplateWizardPage templatePage = null;

        ITemplateWizardPage firstPage = null;

        try {

          for (int i = 0; i < info.getPageCount(); i++) {

            List<WizardUIInfoElement> pageElements = info.getElementsForPage(i);
            if (pageElements == null || pageElements.isEmpty()) {
              continue;
            }
            templatePage = new NewTemplateWizardPage(info.getPage(i).getDescription(), template,
                new TemplateInputCollector(pageElements));
            templatePage.setWizard(getWizard());

            // Always set a new first template page, as the template
            // selection may have changed and may
            // have a different associated template page
            if (firstPage == null) {
              firstPage = templatePage;
            }

            if (previousPage != null) {
              previousPage.setNextPage(templatePage);
            }

            previousPage = templatePage;
          }
        }
        catch (Exception e) {
          String error = ErrorUtils.getErrorMessage("Failed to load wizard page for project template for "
              + template.getName(), e);
          handleError(new Status(Status.ERROR, WizardPlugin.PLUGIN_ID, error, e));
        }

        // Regardless of whether wizard pages where successfully
        // resolved for the given template, update
View Full Code Here

  @Override
  public boolean canFinish() {
    boolean canFinish = super.canFinish();

    if (canFinish) {
      Template template = getWizard().getModel().selectedTemplate.getValue();
      // For now, any simple template project can complete from the first
      // wizard page.
      if (!(template instanceof SimpleProject)) {
        // Non-simple project templates should already be downloaded by
        // now, and therefore
View Full Code Here

    // This check is performed to enable/disable the Next button without
    // having to download the contents of the template
    // Only check if there is one more page after the main page. Any
    // subsequent pages after the second page added by the second page.
    if (currentPage == getWizard().getMainPage()) {
      Template template = getWizard().getModel().selectedTemplate.getValue();
      if (template == null) {
        return false;
      }
      else if (template instanceof SimpleProject) {
        return ((SimpleProject) template).hasWizardPages();
View Full Code Here

   * downloaded yet, and a template is selected, it will assume it does
   * contribute pages. This does not handle Simple Projects, which should not
   * be contributing wizard pages through the wizard UI info.
   */
  protected boolean hasTemplateWizardPages() {
    Template template = getWizard().getModel().selectedTemplate.getValue();
    if (template == null || template instanceof SimpleProject) {
      return false;
    }
    // If it hasn't been download, there is no way to know if the template
    // contributes pages or not, so
View Full Code Here

  }

  @Override
  public ProjectConfiguration getProjectConfiguration() throws CoreException {

    Template template = getWizard().getModel().selectedTemplate.getValue();

    final WizardUIInfo uiInfo = getUIInfo(template);

    if (uiInfo == null) {
      throw new CoreException(new Status(IStatus.ERROR, WizardPlugin.PLUGIN_ID,
          "Failed to read template wizard UI info file for template: " + template.getName()
              + ". Check the template installation location and verify that the files are accessible."));
    }

    String projectName = getWizard().getModel().projectName.getValue();
    String uriValue = getWizard().getModel().projectLocation.getValue();
View Full Code Here

  public Object[] getElements(Object inputElement) {
    List<ITemplateElement> elements = new ArrayList<ITemplateElement>();

    List<Object> templates;
    Template template;

    if ((inputElement instanceof List)) {
      templates = (List<Object>) inputElement;

      // create categories as needed and sort into tree
      Map<String, TemplateCategory> pathToCategory = new HashMap<String, TemplateCategory>();
      for (Object obj : templates) {
        if ((obj instanceof Template)) {
          template = (Template) obj;

          Descriptor descriptor = template.getItem().getLocalDescriptor();
          if (descriptor == null) {
            descriptor = template.getItem().getRemoteDescriptor();
          }
          String categoryPath = descriptor.getCategory();
          if (categoryPath == null) {
            elements.add(template);
          }
View Full Code Here

        return;
      }

      String descriptorVersion = null;

      Template template = ((NewSpringProjectWizard) getWizard()).getModel().selectedTemplate.getValue();

      if (template != null) {
        Descriptor descriptor = template.getItem().getLocalDescriptor();
        if (descriptor == null) {
          descriptor = template.getItem().getRemoteDescriptor();
        }
        if (descriptor != null) {
          descriptorVersion = descriptor.getSpringVersion();
        }
      }
View Full Code Here

    return canFinish;
  }

  protected SpringProjectWizardSection getSection() {
    Template template = getModel().selectedTemplate.getValue();

    if (template != null) {
      ProjectWizardDescriptor descriptor = new ProjectWizardDescriptor(template);
      return sectionFactory.getSection(descriptor);
    }
View Full Code Here

TOP

Related Classes of org.springframework.ide.eclipse.wizard.template.infrastructure.Template

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.