Search in sources :

Example 6 with ControlEnableState

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();
        }
    })));
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBPPropertySource(org.jkiss.dbeaver.model.preferences.DBPPropertySource) DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBPNamedObject(org.jkiss.dbeaver.model.DBPNamedObject) ControlEnableState(org.eclipse.jface.dialogs.ControlEnableState) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)

Example 7 with ControlEnableState

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);
        }
    }
}
Also used : ControlEnableState(org.eclipse.jface.dialogs.ControlEnableState)

Example 8 with ControlEnableState

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();
        }
    }
}
Also used : DefaultProgressMonitor(org.jkiss.dbeaver.model.runtime.DefaultProgressMonitor) ControlEnableState(org.eclipse.jface.dialogs.ControlEnableState)

Aggregations

ControlEnableState (org.eclipse.jface.dialogs.ControlEnableState)8 Button (org.eclipse.swt.widgets.Button)2 DBPNamedObject (org.jkiss.dbeaver.model.DBPNamedObject)2 DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)2 DBPPropertySource (org.jkiss.dbeaver.model.preferences.DBPPropertySource)2 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)2 DefaultProgressMonitor (org.jkiss.dbeaver.model.runtime.DefaultProgressMonitor)2 DatabaseLoadService (org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)1 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 TabFolder (org.eclipse.swt.widgets.TabFolder)1 TabItem (org.eclipse.swt.widgets.TabItem)1 TabFolderLayout (org.eclipse.wst.sse.ui.internal.preferences.TabFolderLayout)1