@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;
          }
        }
コード例 #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
  /**
   * @param ji
   * @param job
   */
  private void execute(JobInfo ji, Job job) {

    Object prop = job.getProperty(IProgressConstants.ACTION_PROPERTY);
    if (prop instanceof IAction && ((IAction) prop).isEnabled()) {
      IAction action = (IAction) prop;
      action.run();
      removeTopElement(ji);
    }

    prop = job.getProperty(IProgressConstants2.COMMAND_PROPERTY);
    if (prop instanceof ParameterizedCommand) {
      ParameterizedCommand command = (ParameterizedCommand) prop;
      IWorkbenchWindow window = getWindow();
      IHandlerService service = (IHandlerService) window.getService(IHandlerService.class);
      Exception exception = null;
      try {
        service.executeCommand(command, null);
        removeTopElement(ji);
      } catch (ExecutionException e) {
        exception = e;
      } catch (NotDefinedException e) {
        exception = e;
      } catch (NotEnabledException e) {
        exception = e;
      } catch (NotHandledException e) {
        exception = e;
      }

      if (exception != null) {
        Status status =
            new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, exception.getMessage(), exception);
        StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.SHOW);
      }
    }
  }
コード例 #4
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();
            }
          }
        }
      }
    }
コード例 #5
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();
  }
コード例 #6
0
ファイル: UIJobCollector.java プロジェクト: xored/rcptt
  public static JobStatus detectJobStatus(Job job, long delay) {
    JobStatus status = null;
    IJobCollector[] collectors = JobCollectorExtensions.getDefault().getCollectors();

    // Take first status
    for (IJobCollector cl : collectors) {
      JobStatus jobStatus = cl.testJob(job);
      if (jobStatus != null && (!jobStatus.equals(JobStatus.UNKNOWN) && status == null)) {
        status = jobStatus;
        break;
      }
    }
    // Allow override some default
    if (status == null) {
      if ((delay < TeslaLimits.getJobWaitForDelayedTimeout())) {
        status = JobStatus.REQUIRED;
      }
      if (job.belongsTo(getFamilyAutoBuild())) {
        status = JobStatus.REQUIRED;
      }
      if (job.isUser()) {
        status = JobStatus.REQUIRED;
      }
      // if (TeslaSWTAccess.isDefferedTreeContentProvider(job)) {
      // status = JobStatus.REQUIRED;
      // }
      String jClassName = job.getClass().getName();
      if (IGNORED_BY_DEFAULT.contains(jClassName)) status = JobStatus.IGNORED;
    }
    return status;
  }
コード例 #7
0
 public void testWorkspaceResolutionOfInterModuleDependenciesDuringImport() throws Exception {
   String oldSettings = mavenConfiguration.getUserSettingsFile();
   try {
     injectFilexWagon();
     FilexWagon.setRequestFilterPattern("test/.*", true);
     IJobChangeListener jobChangeListener =
         new JobChangeAdapter() {
           public void scheduled(IJobChangeEvent event) {
             if (event.getJob() instanceof ProjectRegistryRefreshJob) {
               // cancel all those concurrent refresh jobs, we want to monitor the main thread only
               event.getJob().cancel();
             }
           }
         };
     Job.getJobManager().addJobChangeListener(jobChangeListener);
     mavenConfiguration.setUserSettingsFile(
         new File("projects/MNGECLIPSE-1990/settings.xml").getAbsolutePath());
     List<String> requests;
     try {
       importProjects(
           "projects/MNGECLIPSE-1990",
           new String[] {"pom.xml", "dependent/pom.xml", "dependency/pom.xml", "parent/pom.xml"},
           new ResolverConfiguration());
       requests = FilexWagon.getRequests();
     } finally {
       Job.getJobManager().removeJobChangeListener(jobChangeListener);
     }
     assertTrue(
         "Dependency resolution was attempted from remote repository: " + requests,
         requests.isEmpty());
   } finally {
     mavenConfiguration.setUserSettingsFile(oldSettings);
   }
 }
コード例 #8
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
    }
  }
コード例 #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
  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();
  }
コード例 #11
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();
  }
コード例 #12
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();
  }
 /*
  * @see Wizard#performFinish
  */
 public boolean performFinish() {
   IWorkspaceRunnable op =
       new IWorkspaceRunnable() {
         public void run(IProgressMonitor monitor)
             throws CoreException, OperationCanceledException {
           try {
             finishPage(monitor);
           } catch (InterruptedException e) {
             throw new OperationCanceledException(e.getMessage());
           }
         }
       };
   try {
     ISchedulingRule rule = null;
     Job job = Job.getJobManager().currentJob();
     if (job != null) rule = job.getRule();
     IRunnableWithProgress runnable = null;
     if (rule != null) runnable = new WorkbenchRunnableAdapter(op, rule, true);
     else runnable = new WorkbenchRunnableAdapter(op, getSchedulingRule());
     getContainer().run(canRunForked(), true, runnable);
   } catch (InvocationTargetException e) {
     handleFinishException(getShell(), e);
     return false;
   } catch (InterruptedException e) {
     return false;
   }
   return true;
 }
コード例 #14
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();
      }
    }
  }
コード例 #15
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);
  }
コード例 #16
0
ファイル: AtsBranchUtil.java プロジェクト: pkdevboxy/osee
  public static Job createWorkingBranch(
      final TeamWorkFlowArtifact teamArt, final TransactionRecord parentTransactionId, boolean pend)
      throws OseeCoreException {
    final String branchName =
        Strings.truncate(TeamWorkFlowManager.getBranchName(teamArt), 195, true);
    Conditions.checkNotNull(teamArt, "Parent Team Workflow");
    Conditions.checkNotNull(parentTransactionId, "Parent Branch");

    IExceptionableRunnable runnable =
        new IExceptionableRunnable() {

          @Override
          public IStatus run(IProgressMonitor monitor) throws OseeCoreException {
            teamArt.setWorkingBranchCreationInProgress(true);
            BranchManager.createWorkingBranch(parentTransactionId, branchName, teamArt);
            teamArt.setWorkingBranchCreationInProgress(false);
            performPostBranchCreationTasks(teamArt);
            return Status.OK_STATUS;
          }
        };

    //            Jobs.runInJob("Create Branch", runnable, Activator.class, Activator.PLUGIN_ID);
    Job job =
        Jobs.startJob(
            new CatchAndReleaseJob("Create Branch", runnable, Activator.class, Activator.PLUGIN_ID),
            true);
    if (pend) {
      try {
        job.join();
      } catch (InterruptedException ex) {
        throw new OseeWrappedException(ex);
      }
    }
    return job;
  }
コード例 #17
0
 private boolean suppressAuthentication() {
   Job job = Job.getJobManager().currentJob();
   if (job != null) {
     return job.getProperty(SUPPRESS_AUTHENTICATION_JOB_MARKER) != null;
   }
   return false;
 }
コード例 #18
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'
  }
コード例 #19
0
ファイル: UIJobCollector.java プロジェクト: xored/rcptt
  private boolean logReturnResult(
      boolean result, List<Job> realJobs, List<Job> jobsInUI, Q7WaitInfoRoot info) {
    try {
      long curTime = System.currentTimeMillis();
      if (result) {
        lastSuccessTime = curTime;
        return result;
      }
      for (Job job : jobsInUI) {
        Q7WaitUtils.updateInfo("job.ui", job.getClass().getName(), info);
      }
      for (Job job : realJobs) {
        Q7WaitUtils.updateInfo("job", job.getClass().getName(), info);
      }

      if (lastSuccessTime == 0) {
        lastSuccessTime = curTime;
        return result;
      }
      if (curTime - lastSuccessTime > TeslaLimits.getJobLoggingTimeout()) {
        lastSuccessTime = curTime;
        logJobInformation(realJobs, jobsInUI);
      }
    } catch (Exception e) {
      SWTTeslaActivator.log(e);
    }

    return result;
  }
コード例 #20
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();
  }
コード例 #21
0
ファイル: JobsCommand.java プロジェクト: ambrice/eclim
  /**
   * {@inheritDoc}
   *
   * @see org.eclim.command.Command#execute(CommandLine)
   */
  public String execute(CommandLine commandLine) throws Exception {
    Object family = getFamily(commandLine.getValue(Options.FAMILY_OPTION));
    IJobManager manager = Job.getJobManager();
    Job[] jobs = manager.find(family);

    StringBuffer buffer = new StringBuffer();
    int maxlength = 0;
    for (Job job : jobs) {
      int length = job.toString().length();
      if (length > maxlength) {
        maxlength = length;
      }
    }

    for (Job job : jobs) {
      if (buffer.length() > 0) {
        buffer.append('\n');
      }
      buffer
          .append(StringUtils.rightPad(job.toString(), maxlength))
          .append(" - ")
          .append(getStatus(job));
    }
    return buffer.toString();
  }
コード例 #22
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);
  }
  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
    }
  }
コード例 #24
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();
  }
コード例 #25
0
ファイル: PyEditTitle.java プロジェクト: pmahoney/Pydev
  /**
   * Sadly, we have to restore all pydev editors that have a different icon to make it correct.
   *
   * <p>See https://bugs.eclipse.org/bugs/show_bug.cgi?id=308740
   */
  private void restoreAllPydevEditorsWithDifferentIcon() {
    if (!PyTitlePreferencesPage.useCustomInitIcon()) {
      return;
    }
    Job job =
        new Job("Invalidate images") {

          @Override
          protected IStatus run(IProgressMonitor monitor) {
            try {
              while (PydevPlugin.isAlive()
                  && !doRestoreAllPydevEditorsWithDifferentIcons()) { // stop trying if the plugin
                // is stopped
                synchronized (this) {
                  try {
                    Thread.sleep(200);
                  } catch (InterruptedException e) {
                    // ignore.
                  }
                }
              }
              ;
            } finally {
              jobPool.removeJob(this);
            }
            return Status.OK_STATUS;
          }
        };
    job.setPriority(Job.SHORT);
    jobPool.addJob(job);
  }
コード例 #26
0
  private JobTreeElement[] findJobsToRemove(JobTreeElement info) {

    if (info.isJobInfo()) {
      Job myJob = ((JobInfo) info).getJob();

      if (myJob != null) {

        Object prop = myJob.getProperty(ProgressManagerUtil.KEEPONE_PROPERTY);
        if (prop instanceof Boolean && ((Boolean) prop).booleanValue()) {
          ArrayList found = null;
          JobTreeElement[] all;
          synchronized (keptjobinfos) {
            all = (JobTreeElement[]) keptjobinfos.toArray(new JobTreeElement[keptjobinfos.size()]);
          }
          for (int i = 0; i < all.length; i++) {
            JobTreeElement jte = all[i];
            if (jte != info && jte.isJobInfo()) {
              Job job = ((JobInfo) jte).getJob();
              if (job != null && job != myJob && job.belongsTo(myJob)) {
                if (found == null) {
                  found = new ArrayList();
                }
                found.add(jte);
              }
            }
          }
          if (found != null) {
            return (JobTreeElement[]) found.toArray(new JobTreeElement[found.size()]);
          }
        }
      }
    }
    return null;
  }
コード例 #27
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();
  }
コード例 #28
0
 public void run() {
   Job job = createJob();
   job.setUser(true);
   job.setProperty(
       IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_PSEARCH_OBJ.createImage());
   job.schedule();
 }
コード例 #29
0
  void doAction() {

    JobTreeElement[] jobTreeElements = FinishedJobs.getInstance().getKeptElements();
    // search from end (youngest)
    for (int i = jobTreeElements.length - 1; i >= 0; i--) {
      if (jobTreeElements[i] instanceof JobInfo) {
        JobInfo ji = (JobInfo) jobTreeElements[i];
        Job job = ji.getJob();
        if (job != null) {

          IStatus status = job.getResult();
          if (status != null && status.getSeverity() == IStatus.ERROR) {
            StatusAdapter statusAdapter = StatusAdapterHelper.getInstance().getStatusAdapter(ji);

            if (statusAdapter == null) statusAdapter = new StatusAdapter(status);

            StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW);

            removeTopElement(ji);
          }

          execute(ji, job);
        }
      }
    }

    progressRegion.processDoubleClick();
    refresh();
  }
コード例 #30
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();
 }