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();
}
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();
}
})));
}
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();
}
}
}
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);
}
}
}
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;
}
Aggregations