private Map<String, IRuntime> getServerRuntimes(IProjectFacetVersion facetVersion) {
    Set<org.eclipse.wst.common.project.facet.core.runtime.IRuntime> runtimesSet;
    if (facetVersion == null) {
      runtimesSet = RuntimeManager.getRuntimes();
    } else {
      runtimesSet = RuntimeManager.getRuntimes(Collections.singleton(facetVersion));
    }

    Map<String, IRuntime> runtimesMap = new LinkedHashMap<>();
    for (org.eclipse.wst.common.project.facet.core.runtime.IRuntime r : runtimesSet) {
      IRuntime serverRuntime = FacetUtil.getRuntime(r);
      if (serverRuntime != null) {
        runtimesMap.put(r.getLocalizedName(), serverRuntime);
      }
    }
    return runtimesMap;
  }
コード例 #2
0
  @Override
  public boolean performOk() {
    final String selectedRuntimeName = this.runtimeCombo.getText();

    if (!CoreUtil.isNullOrEmpty(selectedRuntimeName)) {
      final org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime =
          RuntimeManager.getRuntime(selectedRuntimeName);

      if (runtime != null) {
        final IFacetedProject fProject = ProjectUtil.getFacetedProject(getProject());

        final org.eclipse.wst.common.project.facet.core.runtime.IRuntime primaryRuntime =
            fProject.getPrimaryRuntime();

        if (!runtime.equals(primaryRuntime)) {
          Job job = new WorkspaceJob("Setting targeted runtime for project.") // $NON-NLS-1$
              {
                @Override
                public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                  IStatus retval = Status.OK_STATUS;

                  try {
                    fProject.setTargetedRuntimes(Collections.singleton(runtime), monitor);
                    fProject.setPrimaryRuntime(runtime, monitor);
                  } catch (Exception e) {
                    retval =
                        ProjectUIPlugin.createErrorStatus(
                            "Could not set targeted runtime", e); // $NON-NLS-1$
                  }

                  return retval;
                }
              };

          job.schedule();
        }
      } else {
        return false;
      }
    }

    return true;
  }
コード例 #3
0
 /** @see IValidator#validate(Object, Object) */
 public Map<String, IStatus> validate(Object value, Object context) {
   final String deploymentType = value.toString();
   if (!ISeamFacetDataModelProperties.DEPLOY_AS_WAR.equals(deploymentType)) {
     Object runtimeName =
         model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
     if (runtimeName != null) {
       IRuntime rt = RuntimeManager.getRuntime(runtimeName.toString());
       if (!rt.supports(EJB_30) || !rt.supports(EAR_50)) {
         return SeamValidatorFactory.createErrormessage(
             propertyName,
             new Status(
                 IStatus.ERROR,
                 SeamCorePlugin.PLUGIN_ID,
                 NLS.bind(
                     SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_CANNOT_USE_SELECTED_DEPLOYMENT6,
                     new String[] {deploymentType.toUpperCase(), runtimeName.toString()})));
       }
     }
   }
   return SeamValidatorFactory.NO_ERRORS;
 }