org.eclipse.core.runtime.jobs.IJobChangeEvent Java Examples

The following examples show how to use org.eclipse.core.runtime.jobs.IJobChangeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MavenBuildSupportTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testIgnoreInnerPomChanges() throws Exception {
	IProject project = importMavenProject("archetyped");
	assertEquals("The inner pom should not have been imported", 2, WorkspaceHelper.getAllProjects().size());

	IFile innerPom = project.getFile("src/main/resources/archetype-resources/pom.xml");

	preferences.setUpdateBuildConfigurationStatus(FeatureStatus.automatic);
	boolean[] updateTriggered = new boolean[1];
	IJobChangeListener listener = new JobChangeAdapter() {
		@Override
		public void scheduled(IJobChangeEvent event) {
			if (event.getJob().getName().contains("Update project")) {
				updateTriggered[0] = true;
			}
		}
	};
	try {
		Job.getJobManager().addJobChangeListener(listener);
		projectsManager.fileChanged(innerPom.getRawLocationURI().toString(), CHANGE_TYPE.CHANGED);
		waitForBackgroundJobs();
		assertFalse("Update project should not have been triggered", updateTriggered[0]);
	} finally {
		Job.getJobManager().removeJobChangeListener(listener);
	}
}
 
Example #2
Source File: CompositeArtifactsDowloadJobChangeListener.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private JobChangeAdapter getSiteDownloadJobChangeListener(
    final File tempFile, final UpdateSiteToken token) {

  return new JobChangeAdapter() {
    @Override
    public void done(IJobChangeEvent event) {
      IStatus result = event.getResult();
      if (result != null && result.isOK()) {
        Element rootElement = getRootElement(tempFile);
        if (rootElement != null) {
          List<UpdateInfo> updates =
              updateCheckersMap.get(token).checkForUpdates(rootElement);
          assert (updates != null);
          if (!updates.isEmpty()) {
            updateList.addAll(updates);
          }
        }
      }
      // Signal the parent on completion of the download.
      siteXmlDownloadJobsCountDownLatch.countDown();
    }
  };
}
 
Example #3
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void upgradeProject(final File path) {

	UpgradeJob job = new UpgradeJob("upgrade", path);

	job.setUser(true);
	job.schedule();
	job.getState();
	job.addJobChangeListener(new JobChangeAdapter() {
		public void done(IJobChangeEvent event) {
			if (event.getResult().isOK())
				Display.getDefault().asyncExec(new Runnable() {
					public void run() {
						MessageDialog.openInformation(null,
								"upgrade is over", "SVN升级完毕,请重新操作!");
					}
				});
		}
	});
}
 
Example #4
Source File: PyProjectPythonDetails.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private JobChangeAdapter createOnJobComplete() {
    JobChangeAdapter onJobComplete = new JobChangeAdapter() {
        @Override
        public void done(IJobChangeEvent event) {
            //Update the display when the configuration has ended.
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    //Only update if the page is still there.
                    //If something is disposed, it has been closed.
                    if (!interpreterNoteText.isDisposed()) {
                        updateInterpretersAndDefaultInCombo();
                    }
                }
            });
        };
    };
    return onJobComplete;
}
 
Example #5
Source File: ConfigurationEditorInput.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings ( "unchecked" )
public void performSave ( final IProgressMonitor monitor )
{
    // provide a copy so that it can be accessed outside the realm
    final UpdateJob updateJob = update ( new HashMap<String, String> ( this.dataMap ), null );

    updateJob.setProgressGroup ( monitor, 2 );

    updateJob.addJobChangeListener ( new JobChangeAdapter () {
        @Override
        public void done ( final IJobChangeEvent event )
        {
            performLoad ( monitor );
        }
    } );

    updateJob.schedule ();
}
 
Example #6
Source File: XViewerWorkbenchJob.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Add a job change listeners that handles a done event if the result was IStatus.OK.
 */
private void addDefaultJobChangeListener() {
   addJobChangeListener(new JobChangeAdapter() {
      /**
       * (non-Javadoc)
       * @see org.eclipse.core.runtime.jobs.JobChangeAdapter#done(org.eclipse.core.runtime.jobs.IJobChangeEvent)
       */
      @Override
      public void done(IJobChangeEvent event) {

         //Abort if it is not running
         if (!XViewerDisplay.isStandaloneXViewer() && !XViewerDisplay.isWorkbenchRunning()) {
            return;
         }

         if (event.getResult().getCode() == IStatus.OK) {
            performDone(event);
         }
      }
   });
}
 
Example #7
Source File: DeployDiagramHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void runInJob(DiagramFileStore diagramFileStore, DeployProcessOperation deployOperation) {
    Job deployJob = new Job(String.format(Messages.deployingProcessesFrom, diagramFileStore.getName())) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            return deployOperation.run(monitor);
        }
    };
    deployJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            Display.getDefault().syncExec(() -> displayDeployResult(event.getResult()));
        }
    });
    deployJob.setUser(true);
    deployJob.schedule();
}
 
Example #8
Source File: SVNTeamProviderType.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static AutoShareJob getAutoShareJob() {
    if (autoShareJob == null) {
        autoShareJob = new AutoShareJob();
        autoShareJob.addJobChangeListener(new JobChangeAdapter() {
            public void done(IJobChangeEvent event) {
                // Reschedule the job if it has unprocessed projects
                if (!autoShareJob.isQueueEmpty()) {
                    autoShareJob.schedule();
                }
            }
        });
        autoShareJob.setSystem(true);
        autoShareJob.setPriority(Job.SHORT);
        // Must run with the workspace rule to ensure that projects added while we're running
        // can be shared
        autoShareJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
    }
    return autoShareJob;
}
 
Example #9
Source File: EditorPartListener.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void partOpened(IWorkbenchPart part) {
    Logger.log(IStatus.INFO, "Editor Opened : " + part.getClass().getName());
    // if an editor is opened parse the reports if there is any.
    IFile file;
    try {
        file = ((IFileEditorInput) ((IEditorPart) part).getEditorInput()).getFile();
    } catch (ClassCastException e) {
        Logger.log(IStatus.WARNING, "Not a File Editor,early returning");
        return;
    }

    IProject project = file.getProject();
    if (CodeCheckerContext.getInstance().getCcProject(project) == null)
        return;

    AnalyzeJob analyzeJob = new AnalyzeJob(project, file.getLocation().toFile().toPath());
    PlistParseJob plistParseJob = new PlistParseJob(project);
    analyzeJob.setRule(project);
    plistParseJob.setRule(project);
    plistParseJob.addJobChangeListener(new JobDoneChangeListener() {
        @Override
        public void done(IJobChangeEvent event) {
            CodeCheckerContext.getInstance().refresAsync(project);
        }
    });
    analyzeJob.schedule();
    plistParseJob.schedule();
}
 
Example #10
Source File: FactoryEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public void refresh ()
{
    final LoadFactoryJob job = this.factoryInput.createLoadJob ();
    job.addJobChangeListener ( new JobChangeAdapter () {
        @Override
        public void done ( final IJobChangeEvent event )
        {
            FactoryEditor.this.handleSetResult ( job.getFactory (), FactoryEditor.this.factoryInput.getConnectionUri () );
        }
    } );
    job.schedule ();
}
 
Example #11
Source File: StartupJob.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param project The project that got opened.
 */
private void projectOpened(IProject project) {
    // We should return if the project is inaccessible.
    if (project == null || !project.isAccessible())
        return;
    try {
        // If CodecheCker nature is not set or the project is non-CDT we can't parse anything.
        if (!project.hasNature(CodeCheckerNature.NATURE_ID) || 
                CoreModel.getDefault().getProjectDescription(project, true)==null) {
            return;
        }
    } catch (CoreException e) {
        Logger.log(IStatus.ERROR, e.getMessage());
        Logger.log(IStatus.INFO, Logger.getStackTrace(e));
    }
    Logger.log(IStatus.INFO, "CodeChecker nature found!");
    
    CodeCheckerProject cCProject = new CodeCheckerProject(project);
    CodeCheckerContext.getInstance().addCodeCheckerProject(cCProject);

    PlistParseJob plistParseJob = new PlistParseJob(project);
    plistParseJob.addJobChangeListener(new JobDoneChangeListener() {
        @Override
        public void done(IJobChangeEvent event) {
            CodeCheckerContext.getInstance().refresAsync(project);
        }
    });
    plistParseJob.schedule();
}
 
Example #12
Source File: ClearMarkersAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Clear the FindBugs markers on each project in the given selection,
 * displaying a progress monitor.
 */
@Override
protected void work(final IWorkbenchPart part, IResource resource, final List<WorkItem> resources) {
    FindBugsJob clearMarkersJob = new ClearMarkersJob(resource, resources);
    clearMarkersJob.addJobChangeListener(new JobChangeAdapter() {
        @Override
        public void done(IJobChangeEvent event) {
            refreshViewer(part, resources);
        }
    });
    clearMarkersJob.scheduleInteractive();
}
 
Example #13
Source File: DeployConsole.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public void setJob(DeployJob newJob) {
  DeployJob oldJob = job;
  job = newJob;
  firePropertyChange(this, PROPERTY_JOB, oldJob, newJob);
  job.addJobChangeListener(new JobChangeAdapter() {
    @Override
    public void done(IJobChangeEvent event) {
      PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
        setName(Messages.getString("job.terminated.template", getName()));
      });
    }
  });
}
 
Example #14
Source File: DeployConsolePageParticipant.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private void addJobChangeListener() {
  DeployJob job = console.getJob();
  if (job != null) {
    job.addJobChangeListener(new JobChangeAdapter() {
      @Override
      public void done(IJobChangeEvent event) {
        update();
      }
    });
  }
}
 
Example #15
Source File: FactoryEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void insertEntry ( final String value )
{
    final Job job = this.factoryInput.createCreateJob ( value );
    job.addJobChangeListener ( new JobChangeAdapter () {
        @Override
        public void done ( final IJobChangeEvent event )
        {
            refresh ();
        }
    } );
    job.schedule ();
}
 
Example #16
Source File: BonitaStudioApplicationTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_start_add_auto_build_job_listener_that_cancel_autobuild_jobs_until_workbench_is_ready()
        throws Exception {
    doReturn("1.8").when(application).getJavaVersion();

    application.start(null);

    final Job job = new Job("auto build job") {

        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            return Status.OK_STATUS;
        }

        @Override
        public boolean belongsTo(final Object family) {
            return ResourcesPlugin.FAMILY_AUTO_BUILD.equals(family);
        }
    };

    job.schedule();
    Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);

    assertThat(job.getResult()).isNull();

    doReturn(true).when(application).isWorkbenchRunning();
    job.schedule();
    Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);

    assertThat(job.getResult()).isEqualTo(Status.OK_STATUS);

    verify(application, times(2)).cancelAutoBuildJobDuringStartup(any(IJobChangeEvent.class));
}
 
Example #17
Source File: BonitaProjectExplorer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void done(IJobChangeEvent event) {
    Job job = event.getJob();
    if (Objects.equals(job.getName(), getTitle())) {
        PlatformUtil.openIntroIfNoOtherEditorOpen();
    }
}
 
Example #18
Source File: ConfigurationEditorInput.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public void performLoad ( final IProgressMonitor monitor )
{
    final LoadJob job = load ();
    job.addJobChangeListener ( new JobChangeAdapter () {
        @Override
        public void done ( final IJobChangeEvent event )
        {
            handleSetResult ( job.getConfiguration () );
        }
    } );
    job.setProgressGroup ( monitor, 2 );
    job.schedule ();
}
 
Example #19
Source File: BonitaStudioApplication.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void cancelAutoBuildJobDuringStartup(final IJobChangeEvent event) {
    if (event.getJob().belongsTo(ResourcesPlugin.FAMILY_AUTO_BUILD)) {
        if (!isWorkbenchRunning()) {
            event.getJob().cancel();
        }
    }
}
 
Example #20
Source File: BackgroundUpdaterTaskListener.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
@Override
public void done(IJobChangeEvent event) {
	// if scheduled job
	if (event.getResult().isOK()) {
		executeUpdateJob();
	}
}
 
Example #21
Source File: UpdateCheckerJobListener.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
@Override
public void done(IJobChangeEvent event) {
	if (event.getResult().isOK()) {
		Display.getDefault().syncExec(new Runnable() {
			@Override
			public void run() {
				try {
					// Wait half a second to let progress reporting complete
					// FIXME: Find a proper fix
					Thread.sleep(500);
					// Set last check for Updates Time-stamp in OSGI bundle
					// prefs
					Preferences preferences = ConfigurationScope.INSTANCE.getNode(Constants.NODE_UPDATE_HANDER);
					preferences.putLong(Constants.PREF_LAST_PROMPT_FOR_UPDATES, new Date().getTime());
					preferences.flush();
					UpdateCheckerJob.setIsJobRunning(false);
					if (isAutomaticUpdater && !updateManager.hasPossibleUpdates()) {
						// no updates - no need to open the window
						return;
					}

					UpdaterDialog dialog = new UpdaterDialog(updateManager, activeTab);
					dialog.open();
				} catch (Exception e) {
					log.error(Messages.UpdateCheckerJobListener_0, e);
				}
			}
		});
	}
}
 
Example #22
Source File: UpdateMetaFileReaderJobListener.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
@Override
public void done(IJobChangeEvent event) {

	if (event.getResult().isOK()) {
		UpdateMetaFileReaderJob = ((UpdateMetaFileReaderJob) event.getJob());
		final int count = UpdateMetaFileReaderJob.getUpdateCount();
		Display.getDefault().syncExec(new Runnable() {
			@Override
			public void run() {
				try {
					String displayMsg = String.valueOf(count)
							+ " update(s) available for developer studio. List them now ?";
					int userPref = getUserPreference(UPDATER_DIALOG_TITLE, displayMsg);
					if (userPref == 0 || userPref == USER_SCHEDULED_AUTOMATIC_INSTALL) {
						executeUpdateJob();
					} 
				} catch (Exception e) {
					log.error(Messages.UpdatemetaFileReaderJobListener_0, e);
				}
			}

			private void executeUpdateJob() {
				Job updateJob = new UpdateCheckerJob(updateManager);
				updateJob.schedule();
				updateJob.addJobChangeListener(
						new UpdateCheckerJobListener(updateManager, ActiveTab.UPDATE_FEATURES, true));
			}
		});
	}
}
 
Example #23
Source File: JobChangeListener.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public synchronized void done(final IJobChangeEvent event) {
  final String jobName = event.getJob().getName();
  jobNames.remove(jobName);
  // remember completed jobs
  completedJobs.put(jobName, event.getResult());
}
 
Example #24
Source File: CheckLoaderDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void downloadBaseloader(final Shell shell, int id) {
	try {
		DownLoadJob downloadjob = new DownLoadJob(Messages.DOWNLOADOFFICIALLOADER, id);
		downloadjob.setUser(true);
		downloadjob.schedule();

		downloadjob.addJobChangeListener(new JobChangeAdapter() {
			public void done(IJobChangeEvent event) {
				if (event.getResult().isOK())
					Display.getDefault().syncExec(new Runnable() {
						public void run() {
							MessageDialog.openInformation(null, Messages.DOWNLOADSUCCESS,
									Messages.LOADERDOWNLOADSUCC);
						}
					});
				else
					Display.getDefault().syncExec(new Runnable() {
						public void run() {
							MessageDialog.openError(null, Messages.DOWNLOADEXCEPTION, Messages.DOWNLOADERROR);
						}
					});
				close();
			}
		});

		ResourcesPlugin.getWorkspace().build(
				IncrementalProjectBuilder.CLEAN_BUILD, null);
		ResourcesPlugin.getWorkspace().getRoot()
				.refreshLocal(IResource.DEPTH_INFINITE, null);
	com.apicloud.loader.platforms.android.ADBActivator.setHasBaseLoader(true);
	com.apicloud.loader.platforms.android.ADBActivator.setHasAppLoader(true);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #25
Source File: ADBService.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void syncLog() throws ADBException {
	if (!logListenning) {
		ScriptingConsole.getInstance().clear();
		ScriptLogger.logError("开启日志监听...");
		logListenning = true;
		Job startADBJob = new Job("Start ADB log") {
			protected IStatus run(IProgressMonitor monitor) {
				if (isStarted) {
					try {
						ADBCmdProcessor.callProcess(new ADBCommand(
								ADBCommand.CMD_TYPE_LOGCAT));
						logListenning = true;
					} catch (ADBException e) {
						e.printStackTrace();
						logListenning = false;
						//throw adbEx;
					}
				}
				return Status.OK_STATUS;
			}
		};
		
		startADBJob.setSystem(true);
		startADBJob.schedule(500L);
		startADBJob.addJobChangeListener(new JobChangeAdapter() {
			public void done(IJobChangeEvent event) {
				if (event.getResult().isOK()) {
					ScriptLogger.logError("\u65AD\u5F00\u8FDE\u63A5...");
					logListenning = false;
				}
			}
		});

	}
}
 
Example #26
Source File: JobMatcher.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public synchronized void scheduled(final IJobChangeEvent event) {
  Job job = event.getJob();
  if (finder.apply(job)) {
    newJobs.add(job);
  }
}
 
Example #27
Source File: JobMatcher.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public synchronized void done(final IJobChangeEvent event) {
  Job job = event.getJob();
  if (finder.apply(job)) {
    jobQueue.add(job);
  }
}
 
Example #28
Source File: DummyJobChangeListener.java    From tlaplus with MIT License 5 votes vote down vote up
public void done(IJobChangeEvent event) {
	final Job j = event.getJob();
	if(j.belongsTo(ToolboxJob.FAMILY)) {
		final String jobName = j.getName();
		if(jobName.endsWith(model.getName())) {
			job = j;
		}
	}
}
 
Example #29
Source File: PreloadingRepositoryHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
void doExecuteAndLoad(){
	if (preloadRepositories()) {
		// cancel any load that is already running
		Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
		final LoadMetadataRepositoryJob loadJob =
			new LoadMetadataRepositoryJob(getProvisioningUI());
		setLoadJobProperties(loadJob);
		if (waitForPreload()) {
			loadJob.addJobChangeListener(new JobChangeAdapter() {
				public void done(IJobChangeEvent event){
					if (PlatformUI.isWorkbenchRunning())
						if (event.getResult().isOK()) {
							PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
								public void run(){
									doExecute(loadJob);
								}
							});
						}
				}
			});
			loadJob.setUser(true);
			loadJob.schedule();
			
		} else {
			loadJob.setSystem(true);
			loadJob.setUser(false);
			loadJob.schedule();
			doExecute(null);
		}
	} else {
		doExecute(null);
	}
}
 
Example #30
Source File: TriStateFilteredCheckboxTree.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected WorkbenchJob doCreateRefreshJob() {
    WorkbenchJob job = super.doCreateRefreshJob();
    job.addJobChangeListener(new JobChangeAdapter() {
        @Override
        public void done(IJobChangeEvent event) {
            if (getCheckboxTreeViewer().getTree().isDisposed()) {
                return;
            }
            maintainAllCheckIntegrity();
        }
    });
    return job;
}