Package org.eclipse.core.runtime.jobs

Examples of org.eclipse.core.runtime.jobs.Job


    return null;
  }
 
  protected void doRun(CloudFoundryServer server, CloudFoundryApplicationModule appModule) {
    final CloudFoundryServer cloudServer = server;
    Job job = new Job(getJobName()) {

      protected IStatus run(IProgressMonitor monitor) {

        try {
          // FIXNS: Disabled debug for CF 1.5.0 until v2 supports
          // debug
          // if
          // (CloudFoundryProperties.isApplicationRunningInDebugMode.testProperty(modules,
          // getCloudFoundryServer())) {
          // cloudServer.getBehaviour().updateRestartDebugModule(modules,
          // getIncrementalPublish(), monitor);
          // }
          // else {
          // }

          cloudServer.getBehaviour().getUpdateRestartOperation(new IModule[] {selectedModule}).run(monitor);

        }
        catch (CoreException e) {
          CloudFoundryPlugin.getDefault().getLog()
              .log(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID, getFailureMessage(), e));
          return Status.CANCEL_STATUS;
        }
        return Status.OK_STATUS;
      }
    };

    job.schedule();
  }
View Full Code Here


    return true;
  }

  @Override
  public void run() {
    Job job = getJob();
    runJob(job);
  }
View Full Code Here

      job.schedule();
    }
  }

  protected Job getJob() {
    Job job = new Job(getJobName()) {
      @Override
      protected IStatus run(IProgressMonitor monitor) {
        IStatus status = Status.OK_STATUS;
        try {
          ICloudFoundryOperation operation = getOperation(monitor);
          if (operation == null) {
            return CloudFoundryPlugin.getStatus(Messages.CloudFoundryEditorAction_TEXT_NO_OP_EXECUTE, IStatus.WARNING);
          }
          operation.run(monitor);
        }
        catch (CoreException e) {
          CloudFoundryException cfe = e.getCause() instanceof CloudFoundryException ? (CloudFoundryException) e
              .getCause() : null;
          if (cfe instanceof NotFinishedStagingException) {
            status = new Status(IStatus.WARNING, CloudFoundryServerUiPlugin.PLUGIN_ID,
                Messages.CloudFoundryEditorAction_WARNING_RESTART_APP);

          }
          else if (shouldLogException(e)) {
            status = new Status(Status.ERROR, CloudFoundryServerUiPlugin.PLUGIN_ID, e.getMessage(), e);
          }
          else {
            status = new Status(Status.CANCEL, CloudFoundryServerUiPlugin.PLUGIN_ID, e.getMessage(), e);
          }
        }
        return status;
      }
    };

    job.addJobChangeListener(new JobChangeAdapter() {
      @Override
      public void done(final IJobChangeEvent event) {
        Display.getDefault().asyncExec(new Runnable() {

          public void run() {
View Full Code Here

    ServerLifecycleAdapter listener = new ServerLifecycleAdapter() {
      @Override
      public void serverAdded(IServer server) {
        ServerCore.removeServerLifecycleListener(this);

        Job job = new ConnectJob(cloudServer, server);
        // this is getting called before
        // CloudFoundryServer.saveConfiguration() has flushed the
        // configuration therefore delay job
        job.schedule(500L);
      }
    };
    ServerCore.addServerLifecycleListener(listener);
    dispose();
  }
View Full Code Here

    }

    public void run() {
      final CloudFoundryServer cloudFoundryServer = descriptor.getCloudFoundryServer();
      final ApplicationAction debugAction = descriptor.getApplicationAction();
      Job job = new Job(debugAction.getDisplayName()) {

        protected IStatus run(IProgressMonitor monitor) {

          IModule[] modules = descriptor.getServerModule().getModule();

          switch (debugAction) {
          case DEBUG:
            new DebugCommandBuilder(modules, cloudFoundryServer).getDefaultDeployInDebugModeCommand().run(
                monitor);
            break;
          case CONNECT_TO_DEBUGGER:
            new DebugCommandBuilder(modules, cloudFoundryServer).getDebugCommand(
                ApplicationAction.CONNECT_TO_DEBUGGER, null).run(monitor);
            break;
          }

          return Status.OK_STATUS;
        }
      };

      job.schedule();
    }
View Full Code Here

      }
    }
  }

  private void deleteModules(final Set<IModule> deletedModules) {
    Job deleteJob = new Job(Messages.CloudFoundryServer_JOB_UPDATE) {
      @Override
      protected IStatus run(IProgressMonitor arg0) {
        return doDeleteModules(deletedModules);
      }
    };
    deleteJob.schedule();
  }
View Full Code Here

    setEnabled(true);
  }

  public void run() {

    Job job = new Job(NLS.bind(Messages.CaldecottDisconnectAllAction_JOB_STOP, cloudServer.getDeploymentName())) {

      @Override
      protected IStatus run(IProgressMonitor monitor) {
        try {
          new TunnelBehaviour(cloudServer).stopAndDeleteAllTunnels(monitor);
        }
        catch (CoreException e) {
          return CloudFoundryPlugin.getErrorStatus(e);
        }
        return Status.OK_STATUS;
      }

    };
    job.setSystem(false);
    job.schedule();
  }
View Full Code Here

  public Object execute(ExecutionEvent event) throws ExecutionException {
    // Always init first
    initializeSelection(event);
   
    final CloudFoundryServer cloudServer = (CloudFoundryServer) selectedServer.loadAdapter(CloudFoundryServer.class, null);
    Job connectJob = new Job(Messages.ConnectCommand_JOB_CONN_SERVER) {
      @Override
      protected IStatus run(IProgressMonitor monitor) {
        try {
          cloudServer.getBehaviour().connect(monitor);
        }
        catch (OperationCanceledException e) {
          return Status.CANCEL_STATUS;
        }
        catch (CoreException e) {
//          Trace.trace(Trace.STRING_SEVERE, "Error calling connect() ", e);
          return new Status(IStatus.ERROR, CloudFoundryServerUiPlugin.PLUGIN_ID,
              NLS.bind(Messages.ConnectCommand_ERROR_CONNECT, e.getMessage()));
        }
        return Status.OK_STATUS;
      }
    };
    connectJob.schedule();

    return null;
  }
View Full Code Here

    setText(Messages.ShowConsoleEditorAction_TEXT_SHOW_CONSOLE);
  }

  @Override
  public void run() {
    Job job = new Job(Messages.SHOWING_CONSOLE) {

      @Override
      public IStatus run(IProgressMonitor monitor) {
        if (CloudFoundryPlugin.getCallback() != null) {
          CloudFoundryPlugin.getCallback().stopApplicationConsole(appModule, server);

          CloudFoundryPlugin.getCallback().printToConsole(server, appModule, Messages.SHOWING_CONSOLE, true,
              false);

          CloudFoundryPlugin.getCallback().showCloudFoundryLogs(server, appModule, instanceIndex, monitor);
          return Status.OK_STATUS;
        }
        else {
          return CloudFoundryPlugin
              .getErrorStatus("Internal Error: No Cloud Foundry console callback available. Unable to refresh console contents."); //$NON-NLS-1$
        }
      }

    };
    job.setSystem(true);
    job.setPriority(Job.INTERACTIVE);
    job.schedule();

  }
View Full Code Here

public class DisconnectCommand extends BaseCommandHandler {

  public Object execute(ExecutionEvent event) throws ExecutionException {
    initializeSelection(event);
    final CloudFoundryServer cloudServer = (CloudFoundryServer) selectedServer.loadAdapter(CloudFoundryServer.class, null);
    Job disconnectJob = new Job(Messages.DisconnectCommand_JOB_DISCONN_SERVER) {
      @Override
      protected IStatus run(IProgressMonitor monitor) {
        try {
          cloudServer.getBehaviour().disconnect(monitor);
        }
        catch (OperationCanceledException e) {
          return Status.CANCEL_STATUS;
        }
        catch (CoreException e) {
//          Trace.trace(Trace.STRING_SEVERE, "Error calling disconnect() ", e);
          return new Status(IStatus.ERROR, CloudFoundryServerUiPlugin.PLUGIN_ID, NLS.bind(
              "Failed to disconnect from server: {0}", e.getMessage())); //$NON-NLS-1$
        }
        return Status.OK_STATUS;
      }
    };
    disconnectJob.schedule();   
    return null;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.jobs.Job

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.