use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.
the class ExchangeLoginTask method run.
/* (non-Javadoc)
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (!PluginChecker.isExchangeSystemLoaded() || TalendPropertiesUtil.isHideExchange()) {
return;
}
Job job = new //$NON-NLS-1$
Job(//$NON-NLS-1$
"Check Exchange") {
@Override
protected IStatus run(IProgressMonitor monitor) {
// check for Talendforge
IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
boolean checkTisVersion = prefStore.getBoolean(ITalendCorePrefConstants.EXCHANGE_CHECK_TIS_VERSION);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (!checkTisVersion && brandingService.isPoweredbyTalend()) {
int count = prefStore.getInt(TalendForgeDialog.LOGINCOUNT);
if (count < 0) {
count = 1;
}
ExchangeUser exchangeUser = ProjectManager.getInstance().getCurrentProject().getExchangeUser();
//$NON-NLS-1$
boolean isExchangeLogon = exchangeUser.getLogin() != null && !exchangeUser.getLogin().equals("");
boolean isUserPassRight = true;
if (isExchangeLogon) {
IExchangeService service = (IExchangeService) GlobalServiceRegister.getDefault().getService(IExchangeService.class);
if (service.checkUserAndPass(exchangeUser.getUsername(), exchangeUser.getPassword()) != null) {
isUserPassRight = false;
}
}
if (!isExchangeLogon || !isUserPassRight) {
if ((count + 1) % 4 == 0) {
// if (Platform.getOS().equals(Platform.OS_LINUX)) {
// TalendForgeDialog tfDialog = new TalendForgeDialog(this.getShell(), project);
// tfDialog.open();
// } else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
Project project = ProjectManager.getInstance().getCurrentProject();
String userEmail = null;
if (project.getAuthor() != null) {
userEmail = project.getAuthor().getLogin();
}
TalendForgeDialog tfDialog = new TalendForgeDialog(DisplayUtils.getDefaultShell(), userEmail);
tfDialog.setBlockOnOpen(true);
tfDialog.open();
}
});
}
prefStore.setValue(TalendForgeDialog.LOGINCOUNT, count + 1);
}
}
return org.eclipse.core.runtime.Status.OK_STATUS;
}
};
job.setSystem(true);
job.setUser(false);
job.setPriority(Job.INTERACTIVE);
// start as soon as possible
job.schedule();
}
use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.
the class TalendEditorPaletteFactory method getRelatedComponentNamesFromHelp.
protected static Set<String> getRelatedComponentNamesFromHelp(final String keyword) {
if (keyword == null || keyword.isEmpty()) {
return null;
}
// This method will cost lots of time to complete when it is called the first time
final List<SearchHit> querySearchResult = new ArrayList<SearchHit>();
if (searchInHelpJob != null && searchInHelpJob.getState() != Job.NONE) {
searchInHelpJob.cancel();
}
searchInHelpJob = new Job(SEARCHING_FROM_HELP) {
@SuppressWarnings("restriction")
@Override
protected IStatus run(IProgressMonitor monitor) {
String helpKeyword = keyword;
try {
TalendPaletteSearchIndex searchIndex = TalendPaletteSearchIndex.getInstance();
LocalSearchManager localSearchManager = BaseHelpSystem.getLocalSearchManager();
// if not work or null, maybe should throw a warn to inform user and help us trace
// if (searchIndex != null && localSearchManager != null) {
localSearchManager.ensureIndexUpdated(monitor, searchIndex);
//$NON-NLS-1$
final String WHITESPACE = " ";
//$NON-NLS-1$//$NON-NLS-2$
helpKeyword = helpKeyword + WHITESPACE + "OR" + WHITESPACE + helpKeyword + "*";
ISearchQuery searchQuery = new SearchQuery(helpKeyword, false, new ArrayList<String>(), Platform.getNL());
searchIndex.search(searchQuery, new ISearchHitCollector() {
@Override
public void addQTCException(QueryTooComplexException exception) throws QueryTooComplexException {
// nothing need to do
}
@Override
public void addHits(List<SearchHit> hits, String wordsSearched) {
querySearchResult.addAll(hits);
}
});
// }
} catch (Throwable e) {
CommonExceptionHandler.process(e, Priority.WARN);
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
return family.equals(FederatedSearchJob.FAMILY);
}
};
try {
searchInHelpJob.setPriority(Job.INTERACTIVE);
searchInHelpJob.schedule();
searchInHelpJob.join();
} catch (Throwable e) {
CommonExceptionHandler.process(e, Priority.WARN);
}
Set<String> componentNames = new LinkedHashSet<String>();
// the limitation has been moved to it's caller
// int limit = PaletteSettingsPreferencePage.getPaletteSearchResultLimitFromHelp();
// int i = 1;
Iterator<SearchHit> iter = querySearchResult.iterator();
while (iter.hasNext()) {
// if (limit < i) {
// break;
// }
SearchHit result = iter.next();
String label = result.getLabel();
if (label == null || label.trim().length() == 0) {
continue;
}
componentNames.add(label);
// i++;
}
return componentNames;
}
use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.
the class LoginProjectPage method fetchLicense.
private Job fetchLicense(Project proj) {
String url = getAdminURL();
String userId = loginHelper.getCurrentSelectedConnBean().getUser();
String key = loginHelper.getLicenseMapKey(url, proj.getLabel(), userId);
String license = null;
try {
license = loginHelper.getLicense(key);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
Job fetchJob = null;
if (license == null || license.isEmpty()) {
fetchJob = fetchLicenseJobMap.get(proj);
boolean createJob = true;
if (fetchJob != null) {
if (fetchJob.getResult() == null) {
// just wait finish, click refresh may clear all running jobs
createJob = false;
} else {
createJob = true;
}
}
if (createJob) {
fetchJob = createFetchLicenseJob(proj);
fetchJob.setUser(false);
fetchJob.schedule();
}
}
return fetchJob;
}
use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method generateCode.
/**
* DOC bqian Comment method "generateCode".
*/
protected void generateCode() {
final IProcess2 process = getProcess();
if (!(process.getProperty().getItem() instanceof ProcessItem)) {
// shouldn't work for joblet
return;
}
if (process.getGeneratingNodes().size() != 0) {
Job job = new //$NON-NLS-1$
AccessingEmfJob(//$NON-NLS-1$
"Generating code") {
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), false, false, true, ProcessorUtilities.GENERATE_WITH_FIRST_CHILD);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.setPriority(Job.BUILD);
// start as soon as possible
job.schedule();
}
}
use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.
the class ConfigureCpuProfilerAction method run.
/*
* @see Action#run()
*/
@Override
public void run() {
// get the profiled packages
final Job getProfiledPackagesJob = new Job(Messages.getProfiledPackagesJobLabel) {
@Override
protected IStatus run(IProgressMonitor monitor) {
IActiveJvm jvm = cpuSection.getJvm();
if (jvm == null) {
return Status.CANCEL_STATUS;
}
try {
packages = jvm.getCpuProfiler().getProfiledPackages();
} catch (JvmCoreException e) {
Activator.log(Messages.getProfiledPackagesFailedMsg, e);
}
return Status.OK_STATUS;
}
};
getProfiledPackagesJob.schedule();
// open CPU profiler configuration dialog
Job openDialogJob = new Job(Messages.openDialogJobLabel) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
getProfiledPackagesJob.join();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
openDialog();
}
});
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
openDialogJob.schedule();
}
Aggregations