use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project dbeaver by serge-rider.
the class DataSourceManagementToolbar method fillDatabaseCombo.
private void fillDatabaseCombo() {
if (databaseCombo != null && !databaseCombo.isDisposed()) {
final DBPDataSourceContainer dsContainer = getDataSourceContainer();
databaseCombo.setEnabled(dsContainer != null);
if (dsContainer != null && dsContainer.isConnected()) {
final DBPDataSource dataSource = dsContainer.getDataSource();
if (dataSource != null) {
synchronized (dbListReads) {
for (DatabaseListReader reader : dbListReads) {
if (reader.getExecutionContext().getDataSource() == dataSource) {
return;
}
}
DatabaseListReader databaseReader = new DatabaseListReader(dataSource.getDefaultContext(true));
databaseReader.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
DBeaverUI.syncExec(new Runnable() {
@Override
public void run() {
fillDatabaseList((DatabaseListReader) event.getJob());
}
});
}
});
dbListReads.add(databaseReader);
databaseReader.schedule();
}
}
curDataSourceContainer = new SoftReference<>(dsContainer);
} else {
curDataSourceContainer = null;
databaseCombo.removeAll();
}
}
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project translationstudio8 by heartsome.
the class ExportTbxDialog method okPressed.
@Override
protected void okPressed() {
String encoding = "UTF-8";
if (hasChangedCodingCbtn.getSelection()) {
encoding = this.encodingComboViewer.getCombo().getText();
}
String exportPath = this.tbxFileText.getText();
ExportFilterBean filterBean = null;
if (hasFilterChangedBtn.getSelection()) {
IStructuredSelection sel = (IStructuredSelection) filterComboViewer.getSelection();
filterBean = (ExportFilterBean) sel.getFirstElement();
if (filterBean.equals(filterList.get(0))) {
filterBean = null;
}
}
if (this.dbList.size() == 0) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg3"));
return;
}
for (Iterator<ExportDatabaseBean> iterator = dbList.iterator(); iterator.hasNext(); ) {
ExportDatabaseBean dbBean = iterator.next();
if (dbBean.getHasSelectedLangs().size() < 2) {
String dbType = dbBean.getDbBean().getDbType();
String name = dbBean.getDbBean().getDatabaseName();
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTbxDialog.msg4"), dbType, name));
return;
}
}
if (exportPath == null || exportPath.equals("")) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg5"));
return;
}
if (this.dbList.size() > 1) {
File f = new File(exportPath);
if (!f.isDirectory()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg7"));
return;
}
}
if (this.dbList.size() == 1) {
File f = new File(exportPath);
if (f.isDirectory()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), Messages.getString("dialog.ExportTbxDialog.msg8"));
return;
}
}
if (this.dbList.size() == 1) {
dbList.get(0).setExportFilePath(exportPath);
File file = new File(exportPath);
if (file.exists()) {
if (!MessageDialog.openConfirm(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTbxDialog.msg6"), exportPath))) {
return;
}
}
} else {
for (Iterator<ExportDatabaseBean> iterator = dbList.iterator(); iterator.hasNext(); ) {
ExportDatabaseBean db = iterator.next();
String databaseName = db.getDbBean().getDatabaseName();
String path = exportPath + System.getProperty("file.separator") + databaseName + db.getDbBean().getDbType() + ".tbx";
File file = new File(path);
if (file.exists()) {
if (!MessageDialog.openConfirm(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), MessageFormat.format(Messages.getString("dialog.ExportTbxDialog.msg6"), path))) {
return;
}
}
db.setExportFilePath(path);
}
}
final ExportAbstract exportor = new ExportTbxImpl(this.dbList, filterBean, encoding);
Job job = new Job(Messages.getString("dialog.ExportTbxDialog.job")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
final String result = DatabaseService.executeExport(exportor, monitor);
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportTbxDialog.msgTitle"), result);
}
});
return Status.OK_STATUS;
}
};
// 当程序退出时,检测当前 job 是否正常关闭
CommonFunction.jobCantCancelTip(job);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void running(IJobChangeEvent event) {
ProgressIndicatorManager.displayProgressIndicator();
super.running(event);
}
@Override
public void done(IJobChangeEvent event) {
ProgressIndicatorManager.hideProgressIndicator();
super.done(event);
}
});
job.setUser(true);
job.schedule();
super.okPressed();
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project translationstudio8 by heartsome.
the class QualityAssurance method beginMultiFileQA.
/**
* 开始处理多个合并打开文件的品质检查,由于合并打开文件的处理,是个很特殊的例子,因为处理对像不再是单个文件,而是针对语言对。
* @param qaResult ;
*/
public void beginMultiFileQA(final QAResult qaResult) {
this.qaResult = qaResult;
handler = new QAXmlHandler();
Job job = new Job(Messages.getString("qa.all.qa")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
long time1 = System.currentTimeMillis();
int fileNum = model.getQaXlfList().size();
// 定义的进度条总共五格,其中,解析文件1格,进行检查9格
monitor.beginTask(Messages.getString("qa.QualityAssurance.tip1"), fileNum * 10);
//先将所有的文件进行解析
if (!openFile(monitor)) {
monitor.done();
return Status.CANCEL_STATUS;
}
if (model.getQaXlfList().size() == 0) {
MessageDialog.openInformation(shell, _INFO, Messages.getString("qa.QualityAssurance.tip2"));
return Status.CANCEL_STATUS;
}
initWorkInterval();
int allTUSize = handler.getAllTUSize();
//遍历tu节点的序列号
int traversalTuIndex = 0;
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, fileNum * 9, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
subMonitor.beginTask("", allTUSize % workInterval == 0 ? (allTUSize / workInterval) : (allTUSize / workInterval) + 1);
QARealization realization = null;
Map<String, ArrayList<String>> languageList = handler.getLanguages();
int lineNumber = 0;
IFile iFile;
for (Entry<String, ArrayList<String>> langEntry : languageList.entrySet()) {
String srcLang = langEntry.getKey();
for (String tgtLang : langEntry.getValue()) {
List<String> rowIdsList = handler.getAllRowIdsByLanguages(srcLang.toUpperCase(), tgtLang.toUpperCase());
model.setRowIdsList(rowIdsList);
//开始针对每一个文本段进行检查
for (String rowId : rowIdsList) {
traversalTuIndex++;
//行号
lineNumber = rowIdsList.indexOf(rowId) + 1;
String filePath = RowIdUtil.getFileNameByRowId(rowId);
iFile = ResourceUtils.fileToIFile(filePath);
String langPair = srcLang + Hyphen + tgtLang;
QATUDataBean tuDataBean = handler.getFilteredTUText(filePath, RowIdUtil.parseRowIdToXPath(rowId), model.getNotInclude());
if (tuDataBean == null) {
if (!monitorWork(subMonitor, traversalTuIndex, false)) {
closeDB();
return Status.CANCEL_STATUS;
}
continue;
}
if (!tuDataBean.isPassFilter()) {
if (!monitorWork(subMonitor, traversalTuIndex, false)) {
closeDB();
return Status.CANCEL_STATUS;
}
continue;
}
tuDataBean.setLineNumber(lineNumber + "");
tuDataBean.setFileName(iFile.getName());
tuDataBean.setSrcLang(srcLang);
tuDataBean.setTgtLang(tgtLang);
for (int i = 0; i < model.getBatchQAItemIdList().size(); i++) {
final String qaItemId = model.getBatchQAItemIdList().get(i);
realization = getClassInstance(qaItemId);
// 若没有该项检查的实例,提示出错
if (realization == null) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
MessageDialog.openError(shell, _ERROR, MessageFormat.format(Messages.getString("qa.QualityAssurance.tip4"), new Object[] { model.getQaItemId_Name_Class().get(qaItemId).get(QAConstant.QA_ITEM_NAME) }));
}
});
closeDB();
return Status.CANCEL_STATUS;
}
// 开始进行该项文件的该项检查
final String result = realization.startQA(model, subMonitor, iFile, handler, tuDataBean);
// // 当未设置术语库、拼写检查词典配置 错误时才会返回 null,所以这时可以直接删。
if (result == null) {
model.getBatchQAItemIdList().remove(qaItemId);
i--;
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
qaResult.sendDataToViewer(null);
if (!monitorWork(subMonitor, traversalTuIndex, false)) {
closeDB();
return Status.CANCEL_STATUS;
}
}
}
if (!monitorWork(subMonitor, traversalTuIndex, true)) {
closeDB();
return Status.CANCEL_STATUS;
}
}
closeDB();
qaResult.informQAEndFlag();
subMonitor.done();
monitor.done();
System.out.println("所用时间为" + (System.currentTimeMillis() - time1));
return Status.OK_STATUS;
}
};
// 当程序退出时,检测当前 job 是否正常关闭
CommonFunction.jobCantCancelTip(job);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void running(IJobChangeEvent event) {
ProgressIndicatorManager.displayProgressIndicator();
super.running(event);
}
@Override
public void done(IJobChangeEvent event) {
ProgressIndicatorManager.hideProgressIndicator();
super.done(event);
}
});
job.setUser(true);
job.schedule();
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project azure-tools-for-java by Microsoft.
the class SparkSubmitModel method action.
public void action(@NotNull SparkSubmissionParameter submissionParameter) {
this.submissionParameter = submissionParameter;
if (isLocalArtifact()) {
submit();
} else {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject proj = root.getProject(submissionParameter.getArtifactName());
JarExportJob job = new JarExportJob("Building jar", proj);
job.schedule();
job.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
submit();
}
}
;
});
}
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter in project tdi-studio-se by Talend.
the class UploadRevisionAction method run.
public void run() {
if (extension == null) {
return;
}
try {
final UploadRevisionJob job = new UploadRevisionJob(extension);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
updateUI(job, event);
}
});
}
});
ExchangeUtils.scheduleUserJob(job);
} catch (Throwable e) {
ExceptionHandler.process(e);
}
}
Aggregations