Search in sources :

Example 1 with ControlEnableState

use of org.eclipse.jface.dialogs.ControlEnableState in project eclipse.platform.text by eclipse.

the class ExtendedDialogWindow method restoreUIState.

// ---- UI state save and restoring ---------------------------------------------
private void restoreUIState(HashMap<Object, Object> state) {
    restoreEnableState(fCancelButton, state);
    for (Button button : fActionButtons) {
        restoreEnableState(button, state);
    }
    // $NON-NLS-1$
    ControlEnableState pageState = (ControlEnableState) state.get("tabForm");
    pageState.restore();
}
Also used : Button(org.eclipse.swt.widgets.Button) ControlEnableState(org.eclipse.jface.dialogs.ControlEnableState)

Example 2 with ControlEnableState

use of org.eclipse.jface.dialogs.ControlEnableState in project dbeaver by serge-rider.

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 3 with ControlEnableState

use of org.eclipse.jface.dialogs.ControlEnableState in project dbeaver by serge-rider.

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)

Example 4 with ControlEnableState

use of org.eclipse.jface.dialogs.ControlEnableState in project dbeaver by serge-rider.

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 5 with ControlEnableState

use of org.eclipse.jface.dialogs.ControlEnableState in project webtools.sourceediting by eclipse.

the class TaskTagPreferencePage method createCommonContents.

protected Control createCommonContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout compositeLayout = new GridLayout();
    compositeLayout.marginLeft = 0;
    compositeLayout.marginRight = 0;
    composite.setLayout(compositeLayout);
    IScopeContext[] preferenceScopes = createPreferenceScopes();
    fOriginalEnableTaskTags = fEnableTaskTags = fPreferencesService.getBoolean(getPreferenceNodeQualifier(), TaskTagPreferenceKeys.TASK_TAG_ENABLE, false, preferenceScopes);
    fEnableCheckbox = new Button(composite, SWT.CHECK);
    fEnableCheckbox.setSelection(fEnableTaskTags);
    // $NON-NLS-1$
    fEnableCheckbox.setText(SSEUIMessages.TaskTagPreferenceTab_31);
    fEnableCheckbox.setSelection(fEnableTaskTags);
    fEnableCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_END, false, false, 1, 1));
    fTabFolder = new TabFolder(composite, SWT.NONE);
    fTabFolder.setLayout(new TabFolderLayout());
    fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    TabItem taskItem = new TabItem(fTabFolder, SWT.NONE);
    MainTab mainTab = new MainTab(this, fPreferencesService, preferenceScopes);
    taskItem.setText(mainTab.getTitle());
    final Control taskTagsControl = mainTab.createContents(fTabFolder);
    taskItem.setControl(taskTagsControl);
    TabItem exclusionItem = new TabItem(fTabFolder, SWT.NONE);
    ExclusionsTab exclusionsTab = new ExclusionsTab(this, fPreferencesService, preferenceScopes);
    exclusionItem.setText(exclusionsTab.getTitle());
    final Control exclusionControl = exclusionsTab.createContents(fTabFolder);
    exclusionItem.setControl(exclusionControl);
    fTabs = new IPreferenceTab[] { mainTab, exclusionsTab };
    fTabEnablementListener = new SelectionAdapter() {

        ControlEnableState[] lastEnableStates = null;

        public void widgetSelected(SelectionEvent e) {
            fEnableTaskTags = fEnableCheckbox.getSelection();
            if (fEnableTaskTags) {
                if (lastEnableStates != null) {
                    for (int i = 0; i < lastEnableStates.length; i++) {
                        if (lastEnableStates[i] != null) {
                            lastEnableStates[i].restore();
                        }
                    }
                    lastEnableStates = null;
                    fTabFolder.redraw();
                }
            } else if (lastEnableStates == null) {
                lastEnableStates = new ControlEnableState[fTabs.length + 1];
                lastEnableStates[0] = ControlEnableState.disable(taskTagsControl);
                lastEnableStates[1] = ControlEnableState.disable(exclusionControl);
                if (fRedetectButton != null) {
                    lastEnableStates[2] = ControlEnableState.disable(fRedetectButton);
                }
            }
        }
    };
    fTabEnablementListener.widgetSelected(null);
    fEnableCheckbox.addSelectionListener(fTabEnablementListener);
    // restore last selected tab
    int activeTab = new DefaultScope().getNode(getPreferenceNodeQualifier()).getInt(TASK_TAG_LAST_TAB, 0);
    if (activeTab > 0) {
        fTabFolder.setSelection(activeTab);
    }
    SSEUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PREFWEBX_TASKTAGS_HELPID);
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TabFolder(org.eclipse.swt.widgets.TabFolder) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) TabFolderLayout(org.eclipse.wst.sse.ui.internal.preferences.TabFolderLayout) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) 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