Package org.cloudfoundry.ide.eclipse.server.core.internal.client

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.client.CloudFoundryApplicationModule


  public Object execute(ExecutionEvent event) throws ExecutionException {
    initializeSelection(event);
    String error = null;
    CloudFoundryServer cloudServer = selectedServer != null ? (CloudFoundryServer) selectedServer.loadAdapter(
        CloudFoundryServer.class, null) : null;
    CloudFoundryApplicationModule appModule = cloudServer != null && selectedModule != null ? cloudServer
        .getExistingCloudModule(selectedModule) : null;
    if (selectedServer == null) {
      error = "No Cloud Foundry server instance available to run the selected action."; //$NON-NLS-1$
    }
View Full Code Here


  public void refreshUI() {
    logError(null);
    resizeTableColumns();

    canUpdate = false;
    CloudFoundryApplicationModule appModule = null;
    try {
      appModule = getUpdatedApplication();
    }
    catch (CoreException ce) {
      logApplicationModuleFailureError(Messages.ApplicationDetailsPart_ERROR_UNABLE_REFRESH_EDITOR_STATE);
    }
    // Refresh the state of the editor regardless of whether there is a
    // module or not
    refreshPublishState(appModule);

    if (appModule == null) {
      return;
    }

    if (saveManifest != null) {
      ManifestParser parser = new ManifestParser(appModule, cloudServer);
      if (!parser.canWriteToManifest()) {
        saveManifest.setEnabled(false);
        saveManifest.setToolTipText(Messages.ApplicationDetailsPart_TEXT_MANIFEST_SAVE_CREATE_TOOLTIP);
      }
      else {
        saveManifest.setEnabled(true);
        saveManifest.setToolTipText(Messages.ApplicationDetailsPart_TEXT_MANIFEST_UPDATE);
      }
    }

    // The rest of the refresh requires appModule to be non-null
    updateServerNameDisplay(appModule);

    int state = appModule.getState();

    setCurrentStartDebugApplicationAction();
    instanceSpinner.setSelection(appModule.getInstanceCount());

    refreshAndReenableDeploymentButtons(appModule);
    // refreshApplicationDeploymentButtons(appModule);

    mappedURIsLink.setEnabled(state == IServer.STATE_STARTED);

    CloudApplication cloudApplication = appModule.getApplication();

    instanceSpinner.setEnabled(cloudApplication != null);
    instancesViewer.getTable().setEnabled(cloudApplication != null);

    instancesViewer.setInput(null);

    memoryText.setEnabled(cloudApplication != null);
    if (cloudApplication != null) {
      int appMemory = appModule.getApplication().getMemory();

      if (appMemory > 0) {
        memoryText.setText(appMemory + ""); //$NON-NLS-1$
      }
    }

    List<String> currentURIs = null;
    if (cloudApplication != null) {
      currentURIs = cloudApplication.getUris();

      ApplicationStats applicationStats = appModule.getApplicationStats();
      InstancesInfo instancesInfo = appModule.getInstancesInfo();
      if (applicationStats != null) {
        List<InstanceStats> statss = applicationStats.getRecords();
        List<InstanceInfo> infos = instancesInfo != null ? instancesInfo.getInstances() : null;
        InstanceStatsAndInfo[] statsAndInfos = new InstanceStatsAndInfo[statss.size()];

        for (int i = 0; i < statss.size(); i++) {
          InstanceStats stats = statss.get(i);
          InstanceInfo info = null;
          if (infos != null && infos.size() > i) {
            info = infos.get(i);
          }

          statsAndInfos[i] = new InstanceStatsAndInfo(stats, info);
        }
        instancesViewer.setInput(statsAndInfos);
      }
    }

    if (currentURIs == null && !isPublished) {
      // At this stage, the app may not have deployed due to errors, but
      // there may already
      // be set URIs in an existing info
      currentURIs = appModule.getDeploymentInfo() != null ? appModule.getDeploymentInfo().getUris() : null;
    }

    if (currentURIs == null) {
      currentURIs = Collections.emptyList();
    }

    if (!currentURIs.equals(this.appUrls)) {
      updateAppUrls(currentURIs);
    }

    refreshServices(appModule);
    instancesViewer.refresh(true);

    canUpdate = true;

    if (appModule.getErrorMessage() != null) {
      editorPage.setMessage(appModule.getErrorMessage(), IMessageProvider.ERROR);
    }
    else {
      editorPage.setMessage(null, IMessageProvider.ERROR);
    }
  }
View Full Code Here

    editURI.addHyperlinkListener(new HyperlinkAdapter() {
      @Override
      public void linkActivated(HyperlinkEvent e) {

        try {
          CloudFoundryApplicationModule appModule = getExistingApplication();

          MappedURLsWizard wizard = new MappedURLsWizard(cloudServer, appModule, appUrls);
          WizardDialog dialog = new WizardDialog(editorPage.getEditorSite().getShell(), wizard);
          if (dialog.open() == Window.OK) {
            updateAppUrls(wizard.getURLs());
          }
        }
        catch (CoreException ce) {
          logApplicationModuleFailureError(Messages.ApplicationDetailsPart_ERROR_OPEN_URL_WIZ);
        }

      }
    });

    mappedURIsLink = new Link(uriComposite, SWT.MULTI);
    GridDataFactory.fillDefaults().grab(true, false).hint(250, SWT.DEFAULT).applyTo(mappedURIsLink);
    adaptControl(mappedURIsLink);

    mappedURIsLink.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        CloudUiUtil.openUrl("http://" + e.text); //$NON-NLS-1$
      }
    });

    createLabel(client, Messages.ApplicationDetailsPart_TEXT_INSTANCE, SWT.CENTER);

    instanceSpinner = new Spinner(client, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(instanceSpinner);
    instanceSpinner.setMinimum(0);
    instanceSpinner.addModifyListener(new ModifyListener() {

      public void modifyText(ModifyEvent e) {
        if (canUpdate) {
          try {
            CloudFoundryApplicationModule appModule = getExistingApplication();
            new UpdateInstanceCountAction(editorPage, instanceSpinner, appModule).run();
          }
          catch (CoreException ce) {
            logApplicationModuleFailureError(Messages.ApplicationDetailsPart_ERROR_UPDATE_APP_INSTANCE);
          }
View Full Code Here

          catch (NumberFormatException nfe) {
            // ignore. error is handled below
          }
          if (memory > 0) {
            try {
              CloudFoundryApplicationModule appModule = getExistingApplication();
              new UpdateApplicationMemoryAction(editorPage, memory, appModule).run();
              logError(null);
            }
            catch (CoreException ce) {
              logError(Messages.ApplicationDetailsPart_ERROR_FAILED_MEMORY_UPDATE);
            }
          }
          else {
            logError(Messages.ApplicationDetailsPart_ERROR_INVALID_MEMORY);
          }
        }
      }
    });

    createLabel(client, Messages.ApplicationDetailsPart_TEXT_ENV_VAR, SWT.CENTER);
    Button envVarsButton = createGeneralPushButton(client, Messages.COMMONTXT_EDIT);

    envVarsButton.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        try {
          final CloudFoundryApplicationModule appModule = getExistingApplication();
          if (appModule != null) {
            UIJob uiJob = new UIJob(Messages.ApplicationDetailsPart_JOB_EDIT_ENV_VAR) {

              public IStatus runInUIThread(IProgressMonitor monitor) {
                try {
                  DeploymentInfoWorkingCopy infoWorkingCopy = appModule
                      .resolveDeploymentInfoWorkingCopy(monitor);

                  EnvVarsWizard wizard = new EnvVarsWizard(cloudServer, appModule, infoWorkingCopy);
                  WizardDialog dialog = new WizardDialog(editorPage.getEditorSite().getShell(),
                      wizard);
View Full Code Here

  protected void writeToManifest() {
    final IStatus[] errorStatus = new IStatus[1];

    try {
      final CloudFoundryApplicationModule appModule = getExistingApplication();
      if (appModule != null && saveManifest != null && !saveManifest.isDisposed()) {
        if (MessageDialog.openConfirm(saveManifest.getShell(),
            Messages.ApplicationDetailsPart_TEXT_SAVE_MANIFEST,
            Messages.ApplicationDetailsPart_TEXT_SAVE_MANIFEST_BODY)) {
          Job job = new Job(NLS.bind(Messages.ApplicationDetailsPart_JOB_WRITE,
              appModule.getDeployedApplicationName())) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {

              try {
View Full Code Here

    IStructuredSelection selection = (IStructuredSelection) servicesViewer.getSelection();
    if (selection.isEmpty())
      return;

    try {
      CloudFoundryApplicationModule appModule = getExistingApplication();
      manager.add(new RemoveServicesFromApplicationAction(selection, appModule, serverBehaviour, editorPage));
    }
    catch (CoreException ce) {
      logApplicationModuleFailureError(Messages.ApplicationDetailsPart_ERROR_DETERMINE_BOUND_SERVICE);
    }
View Full Code Here

      InstanceStats stats = ((InstanceStatsAndInfo) instanceObject).getStats();

      if (stats != null) {
        try {
          CloudFoundryApplicationModule appModule = getExistingApplication();
          manager.add(new ShowConsoleEditorAction(cloudServer, appModule, Integer.parseInt(stats.getId())));
        }
        catch (CoreException ce) {
          logApplicationModuleFailureError(Messages.ApplicationDetailsPart_ERROR_GENERATE_APP_INSTANCE_CONTEXT_MENU);
        }
View Full Code Here

   * @return an existing cloud application module. Should not be null during
   * the lifecycle of the editor.
   * @throws CoreException if application module was not resolved.
   */
  protected CloudFoundryApplicationModule getExistingApplication() throws CoreException {
    CloudFoundryApplicationModule appModule = cloudServer.getExistingCloudModule(module);

    if (appModule == null) {
      String errorMessage = module != null ? NLS.bind(Messages.ApplicationDetailsPart_ERROR_NO_CF_APP_MODULE_FOR,
          module.getId()) : Messages.ApplicationDetailsPart_ERROR_NO_CF_APP_MODULE;
      throw CloudErrorUtil.toCoreException(errorMessage);
View Full Code Here

   * module during the lifecycle of the editor should always result in
   * non-null app.
   * @throws CoreException if application does not exist
   */
  protected CloudFoundryApplicationModule getUpdatedApplication() throws CoreException {
    CloudFoundryApplicationModule appModule = cloudServer.getCloudModule(module);

    if (appModule == null) {
      String errorMessage = module != null ? NLS.bind(Messages.ApplicationDetailsPart_ERROR_NO_CF_APP_MODULE_FOR,
          module.getId()) : Messages.ApplicationDetailsPart_ERROR_NO_CF_APP_MODULE;
      throw CloudErrorUtil.toCoreException(errorMessage);
View Full Code Here

    new DebugApplicationEditorAction(editorPage, command).run();
  }

  private void startStopApplication(ApplicationAction action) {
    try {
      CloudFoundryApplicationModule appModule = getExistingApplication();
      new StartStopApplicationAction(editorPage, action, appModule, serverBehaviour).run();
    }
    catch (CoreException ce) {
      logApplicationModuleFailureError(NLS.bind(Messages.ApplicationDetailsPart_ERROR_PERFORM,
          action.getDisplayName()));
View Full Code Here

TOP

Related Classes of org.cloudfoundry.ide.eclipse.server.core.internal.client.CloudFoundryApplicationModule

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.