use of org.eclipse.jface.dialogs.ControlEnableState in project dbeaver by dbeaver.
the class TabbedFolderPageForm method refreshPropertyValues.
private void refreshPropertyValues(List<DBPPropertyDescriptor> allProps, boolean disableControls) {
DBSObject databaseObject = input.getDatabaseObject();
if (databaseObject == null) {
// Disposed
return;
}
disableControls = false;
ControlEnableState blockEnableState = disableControls ? ControlEnableState.disable(propertiesGroup) : null;
ownerControl.runService(LoadingJob.createService(new DatabaseLoadService<Map<DBPPropertyDescriptor, Object>>("Load main properties", databaseObject.getDataSource()) {
@Override
public Map<DBPPropertyDescriptor, Object> evaluate(DBRProgressMonitor monitor) {
DBPPropertySource propertySource = TabbedFolderPageForm.this.curPropertySource;
monitor.beginTask("Load '" + DBValueFormatting.getDefaultValueDisplayString(propertySource.getEditableValue(), DBDDisplayFormat.UI) + "' properties", allProps.size());
Map<DBPPropertyDescriptor, Object> propValues = new HashMap<>();
for (DBPPropertyDescriptor prop : allProps) {
if (monitor.isCanceled()) {
break;
}
Object value = propertySource.getPropertyValue(monitor, prop.getId());
propValues.put(prop, value);
monitor.worked(1);
}
monitor.done();
return propValues;
}
}, ownerControl.createDefaultLoadVisualizer(editorValues -> {
loadEditorValues(editorValues);
if (blockEnableState != null) {
blockEnableState.restore();
}
})));
}
use of org.eclipse.jface.dialogs.ControlEnableState in project dbeaver by dbeaver.
the class MultiPageWizardDialog method run.
@Override
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
// Code copied from WizardDialog
if (monitorPart != null) {
monitorPart.setVisible(true);
monitorPart.layout();
monitorPart.attachToCancelComponent(null);
}
ControlEnableState pageEnableState = ControlEnableState.disable(wizardSash);
ControlEnableState buttonsEnableState = ControlEnableState.disable(getButtonBar());
try {
runningOperations++;
ModalContext.run(runnable, true, monitorPart, getShell().getDisplay());
} finally {
runningOperations--;
buttonsEnableState.restore();
pageEnableState.restore();
if (monitorPart != null) {
monitorPart.done();
monitorPart.setVisible(false);
}
}
}
use of org.eclipse.jface.dialogs.ControlEnableState in project dbeaver by dbeaver.
the class BaseProgressDialog method run.
@Override
public void run(boolean fork, boolean cancelable, DBRRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
// Code copied from WizardDialog
if (monitorPart != null) {
((GridData) monitorPart.getLayoutData()).exclude = false;
monitorPart.setVisible(true);
monitorPart.getParent().layout();
monitorPart.attachToCancelComponent(null);
}
// ControlEnableState pageEnableState = ControlEnableState.disable(mainComposite);
ControlEnableState buttonsEnableState = ControlEnableState.disable(getButtonBar());
try {
runningOperations++;
ModalContext.run(monitor -> runnable.run(new DefaultProgressMonitor(monitor)), true, monitorPart, getShell().getDisplay());
} finally {
runningOperations--;
buttonsEnableState.restore();
// pageEnableState.restore();
if (monitorPart != null) {
monitorPart.done();
((GridData) monitorPart.getLayoutData()).exclude = true;
monitorPart.setVisible(false);
monitorPart.getParent().layout();
}
}
}
Aggregations