use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project tdi-studio-se by Talend.
the class InsertionExtensionAction method run.
public void run() {
if (extension == null) {
return;
}
try {
final InsertionExtensionJob job = new InsertionExtensionJob(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);
}
}
use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project tdi-studio-se by Talend.
the class RefreshComponenentsAction method run.
public void run(String[] refreshTypes, final String pageToDispaly) {
List typesToRefresh = null;
if (refreshTypes == null || refreshTypes.length == 0) {
typesToRefresh = new ArrayList();
typesToRefresh.add(REFRESH_ALL);
} else {
typesToRefresh = Arrays.asList(refreshTypes);
}
if (typesToRefresh.contains(REFRESH_ALL) || typesToRefresh.contains(REFRESH_AVAILABLES)) {
try {
final RefreshJob job = new RefreshJob();
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
updateUI(job, event);
String toDisplay = pageToDispaly == null ? ContentConstants.UL_LIST_AVAILABLE_EXTENSIONS : pageToDispaly;
ExchangeManager.getInstance().generateXHTMLPage(toDisplay, new String[] { ContentConstants.INSERT_EXTENSION_DATA });
}
});
}
});
ExchangeUtils.scheduleUserJob(job);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
// Show Installed Extensions
if (typesToRefresh.contains(REFRESH_ALL) || typesToRefresh.contains(REFRESH_INSTALLED)) {
try {
final ShowInstalledExtensionsJob showInstalledJob = new ShowInstalledExtensionsJob();
showInstalledJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
updateInstalledUI(showInstalledJob, event);
ExchangeManager.getInstance().generateXHTMLPage(pageToDispaly, new String[] { ContentConstants.DOWNLOADEXTENSION_DATA });
}
});
}
});
ExchangeUtils.scheduleUserJob(showInstalledJob);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
// Show Contributed Extensions
if (typesToRefresh.contains(REFRESH_ALL) || typesToRefresh.contains(REFRESH_MY_EXTENSIONS)) {
try {
final ShowContributedExtensionsJob showContributedJob = new ShowContributedExtensionsJob();
showContributedJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
updateContributedUI(showContributedJob, event);
ExchangeManager.getInstance().generateXHTMLPage(pageToDispaly, new String[] { ContentConstants.LIST_MY_EXTENSION });
}
});
}
});
ExchangeUtils.scheduleUserJob(showContributedJob);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
//
getVersionRevisionsAndCategorys();
// refreshHTML();
}
use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project cubrid-manager by CUBRID.
the class ObjectInfoComposite method init.
public void init() {
/*Tool bar composite*/
Composite toolBarComposite = new Composite(this, SWT.NONE);
RowLayout rowLayout = new RowLayout();
toolBarComposite.setLayout(rowLayout);
toolBarComposite.setLayoutData(CommonUITool.createGridData(-1, -1, -1, 25));
dataTabButton = new Button(toolBarComposite, SWT.None);
dataTabButton.setText(Messages.tabTitleData);
dataTabButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
if (objInfoFolder == null) {
return;
}
objInfoFolder.setSelection(0);
}
});
ddlTabButton = new Button(toolBarComposite, SWT.None);
ddlTabButton.setText(Messages.tabTitleDDL);
ddlTabButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
if (objInfoFolder == null) {
return;
}
objInfoFolder.setSelection(1);
}
});
columnTabButton = new Button(toolBarComposite, SWT.None);
columnTabButton.setText(Messages.tabTitleColumn);
columnTabButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
if (objInfoFolder == null) {
return;
}
objInfoFolder.setSelection(2);
}
});
indexTabButton = new Button(toolBarComposite, SWT.None);
indexTabButton.setText(Messages.tabTitleIndex);
indexTabButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
if (objInfoFolder == null) {
return;
}
objInfoFolder.setSelection(3);
}
});
new Label(toolBarComposite, SWT.None).setText(" ");
/*Select * button*/
selectButton = new Button(toolBarComposite, SWT.None);
selectButton.setText(Messages.txtSelect);
selectButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
processSelectAction();
}
});
/*Select column button*/
selectColumnButton = new Button(toolBarComposite, SWT.None);
selectColumnButton.setText(Messages.txtSelectColumn);
selectColumnButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
processSelectColumnAction();
}
});
/*Insert Button*/
insertButton = new Button(toolBarComposite, SWT.None);
insertButton.setText(Messages.txtInsert);
insertButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
processInsertAction();
}
});
/*Update button*/
updateButton = new Button(toolBarComposite, SWT.None);
updateButton.setText(Messages.txtUpdate);
updateButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
processUpdateAction();
}
});
/*Delete button*/
deleteButton = new Button(toolBarComposite, SWT.None);
deleteButton.setText(Messages.txtDelete);
deleteButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
processDeleteAction();
}
});
/*Database object information*/
objInfoFolder = new CTabFolder(this, SWT.BOTTOM);
objInfoFolder.setSimple(false);
objInfoFolder.setUnselectedImageVisible(true);
objInfoFolder.setUnselectedCloseVisible(true);
objInfoFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
objInfoFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
objInfoFolder.setLayout(new GridLayout(1, true));
objInfoFolder.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, -1, -1, -1, -1));
/*Demo data tab item*/
initDataTabItem();
/*DDL tab item*/
initDDLTabItem();
/*Column tab item*/
initColumnTabItem();
/*If is table, create index tab item*/
if (isTable) {
initIndexTabItem();
}
/*Initial the data*/
TaskJobExecutor taskExec = new CommonTaskJobExec() {
public IStatus exec(IProgressMonitor monitor) {
IStatus status = super.exec(monitor);
if (Status.CANCEL_STATUS == status) {
return status;
}
return Status.OK_STATUS;
}
public void done(IJobChangeEvent event) {
getInfoDataTask = null;
}
};
GetInfoDataTask getInfoDataTask = new GetInfoDataTask(Messages.getInfoJobName, this, schemaNode, isTable);
taskExec.addTask(getInfoDataTask);
/*Get data job*/
TaskJob job = new TaskJob(Messages.bind(Messages.getInfoJobName, schemaNode.getName()), taskExec);
job.setPriority(Job.LONG);
job.setUser(false);
job.schedule();
}
use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project cubrid-manager by CUBRID.
the class BackupDatabaseDialog method backupDb.
/**
*
* Execute task and backup database
*
* @param buttonId the button id
*/
private void backupDb(final int buttonId) {
isCanFinished = true;
TaskJobExecutor taskExcutor = new TaskJobExecutor() {
private String backupVolInfo;
public IStatus exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
getShell().setVisible(false);
}
});
if (monitor.isCanceled()) {
cancel();
display.syncExec(new Runnable() {
public void run() {
setReturnCode(buttonId);
close();
}
});
return Status.CANCEL_STATUS;
}
for (ITask task : taskList) {
if (!(task instanceof GetBackupVolInfoTask) || database.getRunningType() != DbRunningType.CS) {
task.execute();
final String msg = task.getErrorMsg();
if (msg != null && msg.length() > 0 && !monitor.isCanceled() && !isCanceled()) {
display.syncExec(new Runnable() {
public void run() {
getShell().setVisible(true);
}
});
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
}
if (isCanceled()) {
return Status.CANCEL_STATUS;
}
if (task instanceof CheckDirTask) {
CheckDirTask checkDirTask = (CheckDirTask) task;
final String[] dirs = checkDirTask.getNoExistDirectory();
if (dirs != null && dirs.length > 0) {
display.syncExec(new Runnable() {
public void run() {
CreateDirDialog dialog = new CreateDirDialog(getShell());
dialog.setDirs(dirs);
if (dialog.open() != IDialogConstants.OK_ID) {
isCanFinished = false;
getShell().setVisible(true);
}
}
});
}
} else if (task instanceof CheckFileTask) {
CheckFileTask checkFileTask = (CheckFileTask) task;
final String[] files = checkFileTask.getExistFiles();
if (files != null && files.length > 0) {
display.syncExec(new Runnable() {
public void run() {
OverrideFileDialog dialog = new OverrideFileDialog(getShell());
dialog.setFiles(files);
if (dialog.open() != IDialogConstants.OK_ID) {
isCanFinished = false;
getShell().setVisible(true);
}
}
});
}
} else if (task instanceof GetBackupVolInfoTask && database.getRunningType() == DbRunningType.STANDALONE) {
GetBackupVolInfoTask getBackupVolInfoTask = (GetBackupVolInfoTask) task;
backupVolInfo = getBackupVolInfoTask.getDbBackupVolInfo();
}
if (!isCanFinished) {
return Status.CANCEL_STATUS;
}
if (monitor.isCanceled()) {
cancel();
Display.getDefault().syncExec(new Runnable() {
public void run() {
close();
}
});
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
public void done(IJobChangeEvent event) {
if (event.getResult() == Status.OK_STATUS) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (database.getRunningType() == DbRunningType.CS) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
CommonUITool.openInformationBox(getShell(), Messages.titleSuccess, Messages.msgBackupSuccess);
}
});
} else {
if (backupVolInfo != null && backupVolInfo.length() > 0) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
BackupDbVolumeInfoDialog backupDbResultInfoDialog = new BackupDbVolumeInfoDialog(getShell());
backupDbResultInfoDialog.setResultInfoStr(backupVolInfo);
backupDbResultInfoDialog.open();
}
});
}
}
close();
}
});
}
}
};
String backupDir = backupDirText.getText();
CheckDirTask checkDirTask = new CheckDirTask(database.getServer().getServerInfo());
checkDirTask.setDirectory(new String[] { backupDir });
CheckFileTask checkFileTask = new CheckFileTask(database.getServer().getServerInfo());
String fileName = backupDirText.getText() + database.getServer().getServerInfo().getPathSeparator() + volumeNameText.getText();
checkFileTask.setFile(new String[] { fileName });
String databaseName = databaseNameText.getText();
String level = backupLevelCombo.getText().replaceAll("Level", "");
String volName = volumeNameText.getText();
boolean isRemoveLog = archiveLogButton.getSelection();
boolean isCheckDbCons = consistentButton.getSelection();
boolean isZip = useCompressButton.getSelection();
boolean isSafeReplication = safeBackupButton.getSelection();
int threadNum = spnThreadNum.getSelection();
BackupDbTask backupDbTask = new BackupDbTask(database.getServer().getServerInfo());
backupDbTask.setDbName(databaseName);
backupDbTask.setLevel(level);
backupDbTask.setVolumeName(volName);
backupDbTask.setBackupDir(backupDir);
backupDbTask.setRemoveLog(isRemoveLog);
backupDbTask.setCheckDatabaseConsist(isCheckDbCons);
backupDbTask.setThreadCount(String.valueOf(threadNum));
backupDbTask.setZiped(isZip);
backupDbTask.setSafeReplication(isSafeReplication);
GetBackupVolInfoTask getBackupVolInfoTask = new GetBackupVolInfoTask(database.getServer().getServerInfo());
getBackupVolInfoTask.setDbName(databaseName);
taskExcutor.addTask(checkDirTask);
taskExcutor.addTask(checkFileTask);
taskExcutor.addTask(backupDbTask);
taskExcutor.addTask(getBackupVolInfoTask);
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
String jobName = Messages.msgBackupDBRearJobName + " - " + dbName + "@" + serverName;
taskExcutor.schedule(jobName, jobFamily, true, Job.SHORT);
}
use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project dbeaver by serge-rider.
the class NavigatorHandlerRefresh method refreshNavigator.
public static void refreshNavigator(final Collection<? extends DBNNode> refreshObjects) {
Job refreshJob = new AbstractJob("Refresh navigator object(s)") {
public Throwable error;
@Override
protected IStatus run(DBRProgressMonitor monitor) {
addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (error != null) {
UIUtils.showErrorDialog(null, "Refresh", "Error refreshing node", error);
}
}
});
Set<DBNNode> refreshedSet = new HashSet<>();
for (DBNNode node : refreshObjects) {
if (node.isDisposed() || node.isLocked()) {
// Skip locked nodes
continue;
}
// Check this node was already refreshed
if (!refreshedSet.isEmpty()) {
boolean skip = false;
for (DBNNode refreshed : refreshedSet) {
if (node == refreshed || node.isChildOf(refreshed)) {
skip = true;
break;
}
}
if (skip) {
continue;
}
}
setName("Refresh '" + node.getNodeName() + "'...");
try {
DBNNode refreshed = node.refreshNode(monitor, DBNEvent.FORCE_REFRESH);
if (refreshed != null) {
refreshedSet.add(refreshed);
}
} catch (Throwable ex) {
error = ex;
}
}
return Status.OK_STATUS;
}
};
refreshJob.setUser(true);
refreshJob.schedule();
}
Aggregations