Package org.eclipse.core.runtime.jobs

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


  }

  public static void call() {
    final WGARuntime temp = TomcatUtils.getInstance().getCurrentRuntime();
    if (temp != null && TomcatUtils.getInstance().isRunning(temp)) {
      Job job = new Job("WGA Runtime stop") {
 
        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {
            monitor.beginTask("Stopping WGA runtime '" + temp.getName() + "'.", 1);
            TomcatUtils.getInstance().stop(new SubProgressMonitor(monitor, 1));             
            return Status.OK_STATUS;
          } catch (Exception e) {
            return new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to stop WGA runtime '" + temp.getName() + "'.", e);
          } finally {
            monitor.done();
          }
        }
       
      };
      job.setPriority(Job.SHORT);
      job.schedule();
    }
  }
View Full Code Here


  }

  public static void call() {
    final WGARuntime temp = TomcatUtils.getInstance().getCurrentRuntime();
    if (temp != null && TomcatUtils.getInstance().isRunning(temp)) {
      Job job = new Job("WGA Runtime restart") {
 
        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {
            monitor.beginTask("Restarting WGA runtime '" + temp.getName() + "'.", 2);
            TomcatUtils.getInstance().stop(new SubProgressMonitor(monitor, 1));   
            TomcatUtils.getInstance().start(temp, new SubProgressMonitor(monitor, 1));
            return Status.OK_STATUS;
          } catch (Exception e) {
            return new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to restart WGA runtime '" + temp.getName() + "'.", e);
          } finally {
            monitor.done();
          }
        }
       
      };
      job.setPriority(Job.SHORT);
      job.schedule();
    }
  }
View Full Code Here

      }
      _resourceIndexManager = new ResourceIndexManager(resourceManager);
     
     

      Job job = new Job("Indexing TML-files") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
         
          try {
            _resourceIndexManager.init();
            return Status.OK_STATUS;
           
          } catch (CoreException e) {
            return new Status(Status.ERROR, Plugin.PLUGIN_ID, "Unable to indexworkspacefilerefs", e);
          }     
         
        }

      };
      job.setPriority(Job.SHORT);
      job.schedule();
     
    } catch (Exception e) {
      logError("unable to initialize resourceIndexManager", e);
    }
   
View Full Code Here

    try {
      if (shell != null) {
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
        dialog.run(true, true, runnable);
      } else {
        Job job = new Job("validation") {

          @Override
          protected IStatus run(IProgressMonitor monitor) {
            try {
              runnable.run(monitor);
              return Status.OK_STATUS;
            } catch (Exception e) {
              return new Status(Status.ERROR, Plugin.PLUGIN_ID, "Validation failed", e);
            }
          }
         
        };
        job.setPriority(Job.SHORT);
        job.schedule();
      }
    } catch (InvocationTargetException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
View Full Code Here

     
    }
  }
 
  public void performPluginStartup() {
    Job builderUpdate = new Job("Updating project builders") {
      @Override
      protected IStatus run(IProgressMonitor monitor) {       
        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
        try {
          monitor.beginTask("Updating project builders", projects.length);       
          for (IProject project : projects) {
            monitor.worked(1);
            try {   
              createOrUpdateBuilders(project);
            } catch (Exception e) {
              Plugin.getDefault().logError("Unable to update builders on project '" + project.getName(), e);             
            }
          }
        } finally {
          monitor.done();
        }
        return Status.OK_STATUS;
      }
    };
    builderUpdate.setPriority(Job.SHORT);
    builderUpdate.schedule();
  }
View Full Code Here

  }
 
  public void initWGADistributions() {
    if (_wgaDeploymentManager.getDeployments().size() == 0) {
      final String fDownloadURL = getWGADownloadURL();
      Job createDefaultDeployment = new Job("Initializing WGA distributions") {
       
        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {     
            monitor.beginTask("Initializing WGA distributions", 100);             
            SubProgressMonitor downloadMonitor = new SubProgressMonitor(monitor, 90);             
            TemporaryFile temp = downloadCurrentWGARelease(downloadMonitor);
            SubProgressMonitor deployMonitor = new SubProgressMonitor(monitor, 10);
            getWGADeploymentManager().createOrUpdateDefaultDeployment(temp.getFile(), deployMonitor);
            temp.delete();
            return Status.OK_STATUS;
          } catch (InputStreamCanceledException e) {
            logWarning("WGA distribution download has been canceled by user.");
            return Status.CANCEL_STATUS;
          } catch (UnknownHostException e) {
            logError("Download of current OpenWGA release failed", e);
            return new Status(Status.ERROR, PLUGIN_ID, "Download of current OpenWGA release from '" + fDownloadURL + "' failed. Unknown host.");
          } catch (Exception e) {
            logError("Download of current WGA release failed.", e);
            return new Status(Status.ERROR, PLUGIN_ID, "Download of current OpenWGA release from '" + fDownloadURL + "' failed. See log for details.");         
          } finally {
            monitor.done();
          }
        }
 
        @Override
        public boolean belongsTo(Object family) {
          return JOB_FAMILY_WGA_DISTRIBUTION_DOWNLOAD.equals(family);
        }
       
       
      };       

      boolean startDownload = MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Download current OpenWGA release", "You have currently no OpenWGA distribution installed in your workspace, which is necessary to use the OpenWGA Developer Studio. The latest release will be downloaded from '" + fDownloadURL + "' now.");
      if (startDownload) {
        createDefaultDeployment.setPriority(Job.LONG);
        createDefaultDeployment.setUser(true);
        createDefaultDeployment.schedule();
      }
    }
  }
View Full Code Here

            "Unable to start WGA runtime. The socket '127.0.0.1:" + port + "' is used by another process. Please terminate this process first.");
        return;
      }

      final WGARuntime temp = runtime;
      Job job = new Job("WGA Runtime start") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {
            monitor.beginTask("Starting WGA runtime '" + temp.getName() + "'.", 2);
            TomcatUtils.getInstance().stop(new SubProgressMonitor(monitor, 1));
            TomcatUtils.getInstance().start(temp, new SubProgressMonitor(monitor, 1));
            return Status.OK_STATUS;
          } catch (Exception e) {
            return new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to start WGA runtime '" + temp.getName() + "'.", e);
          } finally {
            monitor.done();
          }
        }

      };
      job.setPriority(Job.SHORT);
      job.schedule();
    }
   
    if (joinAndWaitForStartup) {     
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        try {
View Full Code Here

    } else if (event.getType() == IResourceChangeEvent.PRE_DELETE) {
      IProject project = (IProject) event.getResource();
      if (isWGAPublisherProject(project)) {
        final WGADeployment deployment = getDeployment(project.getName());
        if (deployment != null) {
          Job job = new Job("Removing WGA Deployment '" + deployment.getName() + "'.") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
              removeDeployment(deployment, monitor)
              return Status.OK_STATUS;
            }
           
          };
          job.setPriority(Job.SHORT);
          job.schedule();           
        }
      }
    }
  }
View Full Code Here

        fScheduledJobs.decrementAndGet();
        break;
      }

      /* Create the Job */
      Job job = createJob();

      /* Listen to Job's Lifecycle */
      job.addJobChangeListener(new JobChangeAdapter() {

        /* Update Fields when a Job is Done */
        @Override
        public void done(IJobChangeEvent event) {

          /* Re-Schedule this Job if there is work left to do */
          if (!fOpenTasksQueue.isEmpty())
            event.getJob().schedule();
          else
            fScheduledJobs.decrementAndGet();
        }
      });

      /* Do not interrupt on any Error */
      job.setProperty(NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE);

      /*
       * Workaround: Since we are using our own Job for displaying Progress, we
       * don't want these Jobs show up in the Progress View. There is currently
       * no bug-free solution of aggregating the Progress of N Jobs into a
       * single Monitor.
       */
      job.setSystem(true);

      /* Schedule it immediately */
      job.schedule();
    }
    return true;
  }
View Full Code Here

    return true;
  }

  /* Create a Job for a Task to handle */
  private Job createJob() {
    Job job = new Job("") { //$NON-NLS-1$
      @Override
      protected IStatus run(final IProgressMonitor monitor) {

        /* Poll the next Task */
        final ITask task = fOpenTasksQueue.poll();
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.