コード例 #1
0
  /**
   * Propagates the markers of the given source file, to the corresponding file at the features
   * folder.
   *
   * @param sourceFile The composed file
   */
  public void addFile(IFile sourceFile) {
    String fileExtension = sourceFile.getFileExtension();
    if (fileExtension == null) {
      return;
    }
    if ("java".equals(fileExtension) || "c".equals(fileExtension) || "h".equals(fileExtension)) {
      if (!composedFiles.contains(sourceFile)) {
        addComposedFile(sourceFile);
      }
      if (job == null) {
        job =
            new Job("Propagate problem markers") {
              @Override
              public IStatus run(IProgressMonitor monitor) {
                propagateMarkers();
                return Status.OK_STATUS;
              }
            };
        job.setPriority(Job.SHORT);
        job.schedule();
      }

      if (job.getState() == Job.NONE) {
        job.schedule();
      }
    }
  }
コード例 #2
0
  /** Execution of the start ZAP job. */
  @Override
  protected IStatus run(IProgressMonitor monitor) {
    // Signal that the ZAP start action is starting.
    Job signalZAPStartJob =
        new SignalZAPEventJob(
            display, "Signal ZAP Start...", ZAPEventType.SERVER_STARTED, eventHandler);
    signalZAPStartJob.setPriority(Job.INTERACTIVE);
    signalZAPStartJob.schedule();

    // Run the start ZAP job.
    Job startZAPJob = new StartZAPJob("Running ZAP Start Job...");
    startZAPJob.setPriority(Job.LONG);
    startZAPJob.schedule();
    while (startZAPJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    // Signal that the ZAp start action is complete.
    Job signalZAPStartCompleteJob =
        new SignalZAPEventJob(
            display, "ZAP Start Complete", ZAPEventType.SERVER_STARTUP_COMPLETE, eventHandler);
    signalZAPStartCompleteJob.setPriority(Job.INTERACTIVE);
    signalZAPStartCompleteJob.schedule();

    return Status.OK_STATUS;
  }
コード例 #3
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ptp.rtsystem.IMonitoringSystem#startEvents()
  */
 public void startEvents() throws CoreException {
   DebugUtil.trace(
       DebugUtil.RTS_TRACING,
       "RTS {0}: start events",
       getResourceManager().getConfiguration().getName()); // $NON-NLS-1$
   /*
    * Create monitor jobs, if they do not already exist. They may exist but
    * be suspended. If the job is not applicable, then no job will be
    * created, according to capabilities for the RM.
    */
   if (periodicMonitorJob == null) {
     periodicMonitorJob = createPeriodicMonitorJob();
   }
   if (continousMonitorJob == null) {
     continousMonitorJob = createContinuousMonitorJob();
   }
   /*
    * Only schedule the job if they are available. If the job does not
    * exists, then it was not created because the capability is not defined
    * in the RM.
    */
   if (periodicMonitorJob != null) {
     periodicMonitorJob.schedule();
   }
   if (continousMonitorJob != null) {
     continousMonitorJob.schedule();
   }
   doStartEvents();
 }
コード例 #4
0
    @Override
    public void run() {
      Job j =
          new Job(getToolTipText()) {
            @Override
            protected IStatus run(IProgressMonitor monitor) {
              try {
                PrologConsole c = getConsole();
                ConsoleModel model = c.getModel();
                model.setLineBuffer(" ");
                model.commitLineBuffer();
                model.setLineBuffer(getQuery());
                model.commitLineBuffer();
              } catch (Throwable e) {
                Debug.report(e);
                return Status.CANCEL_STATUS;
              } finally {
                monitor.done();
              }
              return Status.OK_STATUS;
            }

            private PrologConsole getConsole() {
              return PrologConsoleView.this;
            }
          };
      j.schedule();
    }
  private void disableGlobalCDTIndexer() {
    // The Job code is borrowed from CCoreInternals ...
    final Job job =
        new Job("Disable CDT Indexer") {
          @Override
          protected IStatus run(final IProgressMonitor monitor) {
            try {
              final Properties props = new Properties();
              props.setProperty(IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
              IndexerPreferences.setProperties(null, IndexerPreferences.SCOPE_INSTANCE, props);
              InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).flush();
            } catch (final BackingStoreException e) {
              CCorePlugin.log(e);
            }
            return Status.OK_STATUS;
          }
        };
    job.setSystem(true);
    job.schedule();
    try {
      job.join();
    } catch (final InterruptedException e) {
      System.out.println("Exception waiting for indexer disable: " + e.getMessage());
    }

    // Join any auto builds currently running (should be none)
    try {
      Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
    } catch (final Exception e1) {
      // PASS
    }
  }
コード例 #6
0
  public static List<INamespaceDefinition> getNamespaceDefinitions(
      final IProject project, final INamespaceDefinitionTemplate definitionTemplate) {
    if (definitionTemplate != null) {

      Job namespaceDefinitionJob =
          new Job(
              (project != null
                  ? String.format("Loading namespaces for project '%s'", project.getName())
                  : "Loading namespaces")) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
              List<INamespaceDefinition> namespaceDefinitions = getNamespaceDefinitions(project);
              definitionTemplate.doWithNamespaceDefinitions(
                  (INamespaceDefinition[])
                      namespaceDefinitions.toArray(
                          new INamespaceDefinition[namespaceDefinitions.size()]),
                  project);
              return Status.OK_STATUS;
            }
          };
      namespaceDefinitionJob.setPriority(Job.INTERACTIVE);
      namespaceDefinitionJob.schedule();

      return Collections.emptyList();
    }
    return getNamespaceDefinitions(project);
  }
コード例 #7
0
  private void retrieveNewProjectMetadata() {

    String templateUrl =
        Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.P_TEMPLATES_URL);

    this.retriever = new NewProjectMetadataRetriever(templateUrl);

    Job job = new Job("Retrieving new project metadata") { // $NON-NLS-1$

          @Override
          protected IStatus run(IProgressMonitor monitor) {
            try {
              retriever.retrieveMetadata();
              return Status.OK_STATUS;
            } catch (Exception e) {
              return new Status(
                  IStatus.ERROR, Activator.PLUGIN_ID, "Cannot retrieve new project metadata", e);
            }
          }
        };

    job.addJobChangeListener(
        new JobChangeAdapter() {

          @Override
          public void done(IJobChangeEvent event) {
            generalPage.updateControls(retriever.getProjectTypes());
            providerPage.updateControls(retriever.getProviders());
            themePage.updateControls(retriever.getThemes());
          }
        });

    job.setPriority(Job.LONG);
    job.schedule();
  }
コード例 #8
0
  private void copyFiles(
      final IFileStore[] sources, final IFileStore destination, IJobChangeListener listener) {
    Job job =
        new Job("Copying files") {

          @Override
          protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Copying files", sources.length);
            IStatus status = copyFiles(sources, destination, monitor);
            monitor.done();

            return status;
          }

          public boolean belongsTo(Object family) {
            if ("Copying files".equals(family)) {
              return true;
            }
            return super.belongsTo(family);
          }
        };
    if (listener != null) {
      job.addJobChangeListener(listener);
    }
    job.schedule();
  }
コード例 #9
0
ファイル: PHPCorePlugin.java プロジェクト: KopjeKoffie/pdt
  /** This method is used for later initialization. This trick should release plug-in start-up. */
  void initializeAfterStart() {
    Job job = new Job("") { // $NON-NLS-1$
          protected IStatus run(IProgressMonitor monitor) {

            // start the include path manager
            IncludePathManager.getInstance();

            // start the library folder manager
            LibraryFolderManager.getInstance();

            // register the listener in charge of converting the projects -
            // applies for projects being opened during work
            ResourcesPlugin.getWorkspace()
                .addResourceChangeListener(projectConvertListener, IResourceChangeEvent.PRE_BUILD);

            ResourcesPlugin.getWorkspace()
                .addResourceChangeListener(
                    reindexOperationListener, IResourceChangeEvent.PRE_BUILD);

            // run the conversion over all the projects in the workspace -
            // all open projects will be converted
            try {
              convertProjects(monitor);
            } catch (CoreException e) {
              log(e);
            }

            rebuildProjects();

            return Status.OK_STATUS;
          }
        };
    job.schedule(Job.LONG);
  }
コード例 #10
0
  /** {@inheritDoc} */
  @Override
  protected void runModelAction() throws Exception {
    if (!MessageDialog.openConfirm(shell, Messages.RemoveScan, Messages.RemoveSelectedScan)) return;

    // Job because removal of many scans and data in log can be slow
    final ScanClient client = model.getScanClient();
    final Job job =
        new Job(Messages.RemoveScan) {
          @Override
          protected IStatus run(final IProgressMonitor monitor) {
            try {
              for (ScanInfo info : infos) client.removeScan(info.getId());
            } catch (final Exception ex) {
              shell
                  .getDisplay()
                  .asyncExec(
                      new Runnable() {
                        @Override
                        public void run() {
                          ExceptionDetailsErrorDialog.openError(shell, Messages.Error, ex);
                        }
                      });
            }
            return Status.OK_STATUS;
          }
        };
    job.setUser(true);
    job.schedule();
  }
コード例 #11
0
  private void refreshAll(final boolean updateSelection) {

    queue.clear();

    // We use a job for this as the file list can be large
    final Job refresh =
        new Job("Refresh Image Monitor") {
          @Override
          protected IStatus run(IProgressMonitor monitor) {

            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        galleryGroup.clearAll();
                        galleryGroup.setItemCount(info.getSize());
                        galleryGroup.setExpanded(true);
                        galleryGroup.setText(info.getName());

                        gallery.update();
                        gallery.getParent().layout(new Control[] {gallery});

                        GalleryItem item = galleryGroup.getItem(galleryGroup.getItemCount() - 1);
                        gallery.setSelection(new GalleryItem[] {item});
                      }
                    });

            return Status.OK_STATUS;
          }
        };
    refresh.setPriority(Job.INTERACTIVE);
    refresh.schedule();
  }
コード例 #12
0
  /*
   * Refreshes the external folders referenced on the buildpath of the given
   * source project
   */
  public void refreshReferences(IProject source, IProgressMonitor monitor) {
    IProject externalProject = getExternalFoldersProject();
    if (source.equals(externalProject)) return;
    if (!ScriptProject.hasScriptNature(source)) return;
    try {
      HashSet externalFolders =
          getExternalFolders(((ScriptProject) DLTKCore.create(source)).getResolvedBuildpath());
      if (externalFolders == null) return;
      final Iterator iterator = externalFolders.iterator();
      Job refreshJob =
          new Job(Messages.refreshing_external_folders) {
            public boolean belongsTo(Object family) {
              return family == ResourcesPlugin.FAMILY_MANUAL_REFRESH;
            }

            protected IStatus run(IProgressMonitor pm) {
              try {
                while (iterator.hasNext()) {
                  IPath externalPath = (IPath) iterator.next();
                  IFolder folder = getFolder(externalPath);
                  if (folder != null) folder.refreshLocal(IResource.DEPTH_INFINITE, pm);
                }
              } catch (CoreException e) {
                return e.getStatus();
              }
              return Status.OK_STATUS;
            }
          };
      refreshJob.schedule();
    } catch (CoreException e) {
      Util.log(e, "Exception while refreshing external project"); // $NON-NLS-1$
    }
    return;
  }
コード例 #13
0
ファイル: CSSPlugin.java プロジェクト: arcaneadam/studio3
  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
   */
  public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    Job job = new CSSMetadataLoader();
    job.schedule();
  }
コード例 #14
0
  /**
   * Schedule (or postpone) the job to execute after a given delay. Any previous pending job is
   * canceled.
   */
  public final void reschedule(int delay) {
    final Job newJob =
        new Job(actualJob.getName() + " (Delayed)") {
          protected IStatus run(IProgressMonitor monitor) {
            synchronized (jobLock) {
              if (job == this) {
                actualJob.schedule();
                return Status.OK_STATUS;
              } else {
                return Status.CANCEL_STATUS;
              }
            }
          }
        };
    newJob.setPriority(Job.INTERACTIVE);

    // System jobs are not visible in the GUI. I leave it for now, it's quite
    // interesting to see auto update tasks in the jobs panel.
    //
    // newJob.setSystem(true);

    synchronized (jobLock) {
      /*
       * Cancel previous job, but start the new one regardless of the previous job's
       * running state.
       */
      if (job != null && job.getState() == Job.SLEEPING) {
        job.cancel();
      }

      job = newJob;
      job.schedule(delay);
    }
  }
コード例 #15
0
  /** This method starts the job that populates the list of events. */
  synchronized void startContentJob() {
    if (contentJob != null) return;
    contentJob =
        new Job("Generate Usage Data Upload Preview") { // $NON-NLS-1$
          @Override
          protected IStatus run(IProgressMonitor monitor) {
            setTableCursor(busyCursor);
            processFiles(monitor);
            setTableCursor(null);
            if (monitor.isCanceled()) return Status.CANCEL_STATUS;
            return Status.OK_STATUS;
          }

          private void setTableCursor(final Cursor cursor) {
            if (isDisposed()) return;
            getDisplay()
                .syncExec(
                    new Runnable() {
                      public void run() {
                        if (isDisposed()) return;
                        viewer.getTable().setCursor(cursor);
                      }
                    });
          }
        };
    contentJob.setPriority(Job.LONG);
    contentJob.schedule();
  }
コード例 #16
0
  /**
   * Notify registered {@link RepositoryChangeListener}s of a change.
   *
   * @param which the repository which has had changes occur within it.
   */
  static void fireRepositoryChanged(final RepositoryMapping which) {
    Job job =
        new Job(CoreText.GitProjectData_repositoryChangedJobName) {

          @Override
          protected IStatus run(IProgressMonitor monitor) {
            RepositoryChangeListener[] listeners = getRepositoryChangeListeners();
            monitor.beginTask(CoreText.GitProjectData_repositoryChangedTaskName, listeners.length);

            for (RepositoryChangeListener listener : listeners) {
              listener.repositoryChanged(which);
              monitor.worked(1);
            }

            monitor.done();

            return Status.OK_STATUS;
          }

          @Override
          public boolean belongsTo(Object family) {
            if (JobFamilies.REPOSITORY_CHANGED.equals(family)) return true;

            return super.belongsTo(family);
          }
        };

    job.schedule();
  }
コード例 #17
0
  private void runWorkbenchCommands(final List<WorkbenchCommand> commands) {
    // TODO: provide a specialized job name...
    Job job =
        new Job("Executing Workbench Commands...") {
          protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Executing workbench commands ...", commands.size());
            int steps = 0;
            for (WorkbenchCommand workbenchCommand : commands) {
              workbenchCommand.execute(CMakeWorkbench.this);
              steps++;
              monitor.worked(steps);
            }
            return Status.OK_STATUS;
          }
        };

    String info = createInfoStringFromCommands(commands);
    Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
    ScrollableInfoMessage dialog = new ScrollableInfoMessage(shell, "CMakeWorkbench Changes", info);
    boolean confirmed = (dialog.open() == 0);
    if (confirmed) {
      job.setPriority(Job.LONG);
      job.schedule(); // start as soon as possible
    }
  }
コード例 #18
0
 /** Run the "pub get" command against every pubspec in the workspace. */
 private void runPubNow() {
   final String pubCmd = RunPubJob.INSTALL_COMMAND;
   Job firstJob = null;
   Job previousJob = null;
   for (Project proj : DartCore.getProjectManager().getProjects()) {
     for (final PubFolder pubFolder : proj.getPubFolders()) {
       final RunPubJob job = new RunPubJob(pubFolder.getResource(), pubCmd, true);
       if (firstJob == null) {
         firstJob = job;
       } else {
         previousJob.addJobChangeListener(
             new JobChangeAdapter() {
               @Override
               public void done(IJobChangeEvent event) {
                 //
                 // When one job completes, schedule the next unless the user cancels
                 //
                 if (event.getResult().getSeverity() != IStatus.CANCEL) {
                   job.schedule();
                 }
               }
             });
       }
       previousJob = job;
     }
   }
   firstJob.schedule();
 }
コード例 #19
0
  public void runAsUserJob(String name, final Object jobFamiliy) {
    Job buildJob =
        new Job(name) {
          /* (non-Javadoc)
           * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
           */
          protected IStatus run(IProgressMonitor monitor) {
            try {
              WorkbenchRunnableAdapter.this.run(monitor);
            } catch (InvocationTargetException e) {
              Throwable cause = e.getCause();
              if (cause instanceof CoreException) {
                return ((CoreException) cause).getStatus();
              } else {
                return RubyUIStatus.createError(IStatus.ERROR, cause);
              }
            } catch (InterruptedException e) {
              return Status.CANCEL_STATUS;
            } finally {
              monitor.done();
            }
            return Status.OK_STATUS;
          }

          public boolean belongsTo(Object family) {
            return jobFamiliy == family;
          }
        };
    buildJob.setRule(fRule);
    buildJob.setUser(true);
    buildJob.schedule();

    // TODO: should block until user pressed 'to background'
  }
コード例 #20
0
 private void validate() {
   setErrorMessage(null);
   setValid(false);
   final Display display = getShell().getDisplay();
   Job validator =
       new Job("JSHint preferences validation") {
         @Override
         protected IStatus run(IProgressMonitor monitor) {
           try {
             monitor.beginTask("checking preferences", 1);
             validatePrefs();
             display.asyncExec(
                 new Runnable() {
                   public void run() {
                     setValid(true);
                   }
                 });
           } catch (final IllegalArgumentException exception) {
             display.asyncExec(
                 new Runnable() {
                   public void run() {
                     setErrorMessage(exception.getMessage());
                   }
                 });
           } finally {
             monitor.done();
           }
           return Status.OK_STATUS;
         }
       };
   validator.schedule();
 }
コード例 #21
0
  public void start(long delay) {

    if (runBackup != null) {
      stop();
    }

    runBackup =
        new Job("Task Data Snapshot") { // $NON-NLS-1$

          @Override
          protected IStatus run(IProgressMonitor monitor) {
            try {
              if (TasksUiPlugin.getTaskList().getAllTasks().size() > 0) {
                backupNow(false, monitor);
              }
              return Status.OK_STATUS;
            } finally {
              schedule(STANDARD_DELAY);
            }
          }
        };
    runBackup.setPriority(Job.BUILD);
    runBackup.setSystem(true);
    runBackup.schedule(delay);
  }
コード例 #22
0
 protected void launchJob(IWorkbenchPage page, Integer lineNumber, String filePath) {
   Job job = new OpenInEditorJob(page, lineNumber, filePath);
   job.addJobChangeListener(
       new CompletionPopupJobChangeListener(
           "ORG CheatSheet Helpers Notification", "Opening file in editor:\n"));
   job.schedule();
 }
コード例 #23
0
 public void run() {
   Job job = createJob();
   job.setUser(true);
   job.setProperty(
       IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_PSEARCH_OBJ.createImage());
   job.schedule();
 }
        @Override
        public void notifyChanged(final Notification msg) {
          switch (msg.getFeatureID(SdrPackage.class)) {
            case SdrPackage.SDR_ROOT__LOAD_STATUS:
              // The value is the changed load status which will go to null during loading
              // once loading is finished the status will change to reflect that of the SDRROOT.
              if (msg.getNewValue() != null) {
                Job refreshExternalSettingProviderJob =
                    new Job("Refresh External Settings Providers") {

                      @Override
                      protected IStatus run(IProgressMonitor monitor) {
                        CoreModel.getDefault()
                            .getProjectDescriptionManager()
                            .updateExternalSettingsProviders(
                                new String[] {ExternalSettingProvider.ID}, monitor);
                        return Status.OK_STATUS;
                      }
                    };
                refreshExternalSettingProviderJob.setSystem(true); // hide from progress monitor
                refreshExternalSettingProviderJob.setUser(false);
                refreshExternalSettingProviderJob.schedule(1000);
              }
              break;
            default:
              break;
          }
        }
コード例 #25
0
    public void handleDebugEvents(DebugEvent[] events) {
      if (events != null && project != null) {
        int size = events.length;
        for (int i = 0; i < size; i++) {
          for (IProcess process : processes) {
            if (process != null
                && process.equals(events[i].getSource())
                && events[i].getKind() == DebugEvent.TERMINATE) {

              DebugPlugin.getDefault().removeDebugEventListener(this);
              terminateForked();
              Job job =
                  new Job("refresh project") {

                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                      try {
                        project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                      } catch (CoreException e) {
                      }
                      GrailsCoreActivator.getDefault().notifyCommandFinish(project);
                      return Status.OK_STATUS;
                    }
                  };
              job.setSystem(true);
              job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
              job.setPriority(Job.INTERACTIVE);
              job.schedule();
            }
          }
        }
      }
    }
コード例 #26
0
  @DsfServiceEventHandler
  public void eventDispatched(IExitedDMEvent event) {
    // If a memory context is exiting, save expressions and clean its used resources
    if (event.getDMContext() instanceof IMemoryDMContext) {
      IMemoryDMContext memDmc = (IMemoryDMContext) event.getDMContext();
      // Remove entry if it exists
      final IMemoryBlockRetrieval retrieval = fMapMemDMCToBlockRetrieval.remove(memDmc);
      if (retrieval != null) {
        if (retrieval instanceof DsfMemoryBlockRetrieval) {
          ((DsfMemoryBlockRetrieval) retrieval).saveMemoryBlocks();
        }
        // Fire a terminate event for the memory retrieval object so
        // that the hosting memory views can clean up. See 255120 and
        // 283586
        DebugPlugin.getDefault()
            .fireDebugEventSet(new DebugEvent[] {new DebugEvent(retrieval, DebugEvent.TERMINATE)});

        Job removeJob = new Job("Removing memory blocks") { // $NON-NLS-1$

              @Override
              protected IStatus run(IProgressMonitor monitor) {
                IMemoryBlockManager mbm = DebugPlugin.getDefault().getMemoryBlockManager();
                IMemoryBlock[] deletedMemoryBlocks = mbm.getMemoryBlocks(retrieval);
                mbm.removeMemoryBlocks(deletedMemoryBlocks);
                return Status.OK_STATUS;
              }
            };
        removeJob.schedule();
      }
    }
  }
コード例 #27
0
  public static void migrateToClasspathAttributes() {
    final Map<IPath, String> oldLocations = loadOldForCompatibility();
    if (oldLocations.isEmpty()) {
      IPreferenceStore preferenceStore = PreferenceConstants.getPreferenceStore();
      preferenceStore.setValue(PREF_JAVADOCLOCATIONS, ""); // $NON-NLS-1$
      preferenceStore.setValue(PREF_JAVADOCLOCATIONS_MIGRATED, true);
      return;
    }

    Job job =
        new Job(CorextMessages.JavaDocLocations_migratejob_name) {
          @Override
          protected IStatus run(IProgressMonitor monitor) {
            try {
              IWorkspaceRunnable runnable =
                  new IWorkspaceRunnable() {
                    @Override
                    public void run(IProgressMonitor pm) throws CoreException {
                      updateClasspathEntries(oldLocations, pm);
                      IPreferenceStore preferenceStore = PreferenceConstants.getPreferenceStore();
                      preferenceStore.setValue(PREF_JAVADOCLOCATIONS, ""); // $NON-NLS-1$
                      preferenceStore.setValue(PREF_JAVADOCLOCATIONS_MIGRATED, true);
                    }
                  };
              new WorkbenchRunnableAdapter(runnable).run(monitor);
            } catch (InvocationTargetException e) {
              JavaPlugin.log(e);
            } catch (InterruptedException e) {
              // should not happen, cannot cancel
            }
            return Status.OK_STATUS;
          }
        };
    job.schedule();
  }
コード例 #28
0
ファイル: DownloadManager.java プロジェクト: SjB/Dart
  private void doDownloadUpdate(Revision revision) {

    // ensure jobs don't stack
    if (updateJob != null) {
      return;
    }

    updateJob = new DownloadUpdatesJob(revision);
    updateJob.addJobChangeListener(
        new JobChangeAdapter() {

          @Override
          public void done(IJobChangeEvent event) {
            updateJob = null;
            IStatus result = event.getResult();
            if (result.isOK()) {
              model.enterState(State.DOWNLOADED);
            } else {
              UpdateCore.logWarning("Download cancelled [" + result.getMessage() + "]");
              model.enterState(State.DOWNLOAD_CANCELLED);
            }
          }

          @Override
          public void running(IJobChangeEvent event) {
            model.enterState(State.DOWNLOADING);
          }
        });
    updateJob.schedule();
  }
コード例 #29
0
  private void initialize() {
    Job job =
        new Job("Comparing IUs") {
          @Override
          protected IStatus run(IProgressMonitor monitor) {
            final TreeElement<Object> root = new TreeElement<Object>();
            IMetadataRepository repo = AnalysisHelper.getMetadataRepository();
            IQueryResult<IInstallableUnit> ius =
                repo.query(QueryUtil.createIUQuery(getIU().getId(), getIU().getVersion()), monitor);

            int iuCount = 0;
            for (IInstallableUnit iu : ius.toSet()) {
              TreeElement<TreeElement<String>> child = AnalysisHelper.diff(getIU(), iu);
              if (child != null) root.addChild(child);
              iuCount++;
            }
            if (root.getChildren().length == 0)
              root.addChild("No differences found between profile and source installable unit(s)");
            else if (iuCount == 0) root.addChild("No source for IU located");

            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      public void run() {
                        tree.setInput(root);
                      }
                    });
            return Status.OK_STATUS;
          }
        };
    job.schedule();
  }
コード例 #30
0
  private void refresh(final Object element) {
    Job job =
        new Job("Loading OpenShift information...") {

          @Override
          protected IStatus run(IProgressMonitor monitor) {
            try {
              monitor.beginTask("Loading OpenShift information...", IProgressMonitor.UNKNOWN);
              if (element instanceof Connection) {
                ((Connection) element).refresh();
              } else if (element instanceof IOpenShiftResource) {
                ((IOpenShiftResource) element).refresh();
              }

              // List<IApplication> applications = user.getApplications();
              RefreshViewerJob.refresh(viewer);
            } catch (OpenShiftException e) {
              Logger.error("Failed to refresh element", e);
            } finally {
              monitor.done();
            }
            return Status.OK_STATUS;
          }
        };
    job.setPriority(Job.LONG);
    job.schedule();
  }