protected ILiferayRuntime getLiferayRuntime() {
   IRuntimeWorkingCopy runtimeWC =
       (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
   ILiferayRuntime liferayRuntime =
       (ILiferayRuntime) runtimeWC.loadAdapter(ILiferayRuntime.class, null);
   return liferayRuntime;
 }
예제 #2
0
  public static Object getRuntimeAdapter(
      org.eclipse.wst.common.project.facet.core.runtime.IRuntime facetRuntime,
      Class<?> adapterClass) {

    String runtimeId = facetRuntime.getProperty("id");

    for (org.eclipse.wst.server.core.IRuntime runtime : ServerCore.getRuntimes()) {
      if (runtime.getId().equals(runtimeId)) {

        if (IRuntime.class.equals(adapterClass)) {
          return runtime;
        }

        IRuntimeWorkingCopy runtimeWC = null;

        if (!runtime.isWorkingCopy()) {
          runtimeWC = runtime.createWorkingCopy();
        } else {
          runtimeWC = (IRuntimeWorkingCopy) runtime;
        }

        return (ILiferayRuntime) runtimeWC.loadAdapter(adapterClass, null);
      }
    }

    return null;
  }
  public boolean isComplete() {
    IRuntimeWorkingCopy runtime =
        (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);

    if (runtime == null) {
      return false;
    }

    IStatus status = runtime.validate(null);

    return status != null && status.getSeverity() != IStatus.ERROR;
  }
 /** updates the model from runtime. */
 protected void populateModel() {
   IRuntimeWorkingCopy workingCopy = getRuntimeWorkingCopy();
   if (workingCopy != null) {
     // workCopy will be instance of ServerDelegate classs.
     // We need to get the params, so IFuseESBRuntime will be enough.
     IKarafRuntime karafRuntime =
         (IKarafRuntime) workingCopy.loadAdapter(IKarafRuntime.class, new NullProgressMonitor());
     if (karafRuntime != null) {
       model.setKarafInstallDir(karafRuntime.getKarafInstallDir());
       model.setKarafVersion(FuseESBUtils.getVersion(new File(model.getKarafInstallDir())));
     }
   }
 }
  public boolean isComplete() {
    runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);

    if (runtime != null) {
      GenericServerRuntime gRuntime =
          (GenericServerRuntime)
              runtime.loadAdapter(GenericServerRuntime.class, new NullProgressMonitor());

      Map properties = gRuntime.getServerInstanceProperties();
      String serverName = (String) properties.get("server.name");
      if (serverName != null) {
        runtime.setName(serverName);
      }
    }
    return super.isComplete();
  }
예제 #6
0
  public static IRuntimeWorkingCopy getRuntime(String runtimeTypeId, IPath location) {
    IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypeId);

    try {
      IRuntime runtime = runtimeType.createRuntime("runtime", null);

      IRuntimeWorkingCopy runtimeWC = runtime.createWorkingCopy();
      runtimeWC.setName("Runtime");
      runtimeWC.setLocation(location);

      return runtimeWC;
    } catch (CoreException e) {
      e.printStackTrace();
    }

    return null;
  }
  public void setRuntime(IRuntimeWorkingCopy newRuntime) {
    if (newRuntime == null) {
      runtimeWC = null;
      liferayRuntime = null;
    } else {
      runtimeWC = newRuntime;
      liferayRuntime = (ILiferayRuntime) newRuntime.loadAdapter(ILiferayRuntime.class, null);
    }

    initialize();
    validate();
  }
  protected void textInstallDirChanged(String text) {
    if (ignoreModifyEvent) {
      return;
    }

    runtimeWC.setLocation(new Path(text));

    validate();

    // IStatus status = getRuntime().validate(null);

  }
  protected void initialize() {
    if (textName == null || liferayRuntime == null) {
      return;
    }

    ignoreModifyEvent = true;

    if (runtimeWC.getName() != null) {
      textName.setText(runtimeWC.getName());
    } else {
      textName.setText(StringPool.EMPTY);
    }

    if (runtimeWC.getLocation() != null) {
      textInstallDir.setText(runtimeWC.getLocation().toOSString());
    } else {
      textInstallDir.setText(StringPool.EMPTY);
    }

    updateStubs();

    ignoreModifyEvent = false;
  }
  protected IStatus validate() {
    if (liferayRuntime == null) {
      wizard.setMessage(StringPool.EMPTY, IMessageProvider.ERROR);
      return Status.OK_STATUS;
    }

    IStatus status = runtimeWC.validate(null);

    if (status == null || status.isOK()) {
      wizard.setMessage(null, IMessageProvider.NONE);
    } else if (status.getSeverity() == IStatus.WARNING) {
      wizard.setMessage(status.getMessage(), IMessageProvider.WARNING);
    } else {
      wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
    }

    wizard.update();

    return status;
  }
 protected LiferayRuntimeStubDelegate getStubDelegate() {
   return (LiferayRuntimeStubDelegate)
       runtimeWC.loadAdapter(LiferayRuntimeStubDelegate.class, new NullProgressMonitor());
 }