Search in sources :

Example 71 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.

the class AbstractJob method runBlockCanceler.

private void runBlockCanceler() {
    final List<DBRBlockingObject> activeBlocks = new ArrayList<>(CommonUtils.safeList(progressMonitor.getActiveBlocks()));
    if (activeBlocks.isEmpty()) {
        // Nothing to cancel
        return;
    }
    final DBRBlockingObject lastBlock = activeBlocks.remove(activeBlocks.size() - 1);
    try {
        new JobCanceler(lastBlock).schedule();
    } catch (Exception e) {
        // If this happens during shutdown and job manager is not active
        log.debug(e);
    }
    if (!activeBlocks.isEmpty()) {
        DBPPreferenceStore preferenceStore;
        if (activeBlocks.get(0) instanceof DBCSession) {
            DBPDataSource dataSource = ((DBCSession) activeBlocks.get(0)).getDataSource();
            if (dataSource == null) {
                return;
            }
            preferenceStore = dataSource.getContainer().getPreferenceStore();
        } else {
            preferenceStore = ModelPreferences.getPreferences();
        }
        int cancelCheckTimeout = preferenceStore.getInt(ModelPreferences.EXECUTE_CANCEL_CHECK_TIMEOUT);
        if (cancelCheckTimeout > 0) {
            // There are other blocks. If last one can't be canceled then try others
            Job cancelChecker = new // $NON-N LS-1$
            Job(// $NON-N LS-1$
            "Cancel checker block") {

                {
                    setSystem(true);
                    setUser(false);
                }

                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    if (!finished) {
                        DBRBlockingObject nextBlock = activeBlocks.remove(activeBlocks.size() - 1);
                        new JobCanceler(nextBlock).schedule();
                        if (!activeBlocks.isEmpty()) {
                            schedule(cancelCheckTimeout);
                        }
                    }
                    return Status.OK_STATUS;
                }
            };
            cancelChecker.schedule(cancelCheckTimeout);
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) Job(org.eclipse.core.runtime.jobs.Job) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) DBException(org.jkiss.dbeaver.DBException) DBCSession(org.jkiss.dbeaver.model.exec.DBCSession)

Example 72 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.

the class PrefPageDrivers method performDefaults.

@Override
protected void performDefaults() {
    DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
    versionUpdateCheck.setSelection(store.getBoolean(ModelPreferences.UI_DRIVERS_VERSION_UPDATE));
    proxyHostText.setText(store.getString(ModelPreferences.UI_PROXY_HOST));
    proxyPortSpinner.setSelection(store.getInt(ModelPreferences.UI_PROXY_PORT));
    proxyUserText.setText(store.getString(ModelPreferences.UI_PROXY_USER));
    // Load and decrypt password
    String passwordString = store.getString(ModelPreferences.UI_PROXY_PASSWORD);
    if (!CommonUtils.isEmpty(passwordString) && encrypter != null) {
        try {
            passwordString = encrypter.decrypt(passwordString);
        } catch (EncryptionException e) {
            log.warn(e);
        }
    }
    proxyPasswordText.setText(passwordString);
    customDriversHome.setText(DriverDescriptor.getCustomDriversHome().getAbsolutePath());
    for (String source : DriverDescriptor.getDriversSources()) {
        sourceList.add(source);
    }
    super.performDefaults();
}
Also used : EncryptionException(org.jkiss.dbeaver.runtime.encode.EncryptionException) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 73 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.

the class UINavigatorPreferencesInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    // Init default preferences
    DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
    // Navigator
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_EXPAND_ON_CONNECT, false);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_RESTORE_STATE_DEPTH, 0);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_COLOR_ALL_NODES, false);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_SYNC_EDITOR_DATASOURCE, false);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_REFRESH_EDITORS_ON_OPEN, false);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_GROUP_BY_DRIVER, false);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_EDITOR_SHOW_TABLE_GRID, true);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_OBJECT_DOUBLE_CLICK, NavigatorPreferences.DoubleClickBehavior.EDIT.name());
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_CONNECTION_DOUBLE_CLICK, NavigatorPreferences.DoubleClickBehavior.EXPAND.name());
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_DEFAULT_EDITOR_PAGE, "");
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_SHOW_SQL_PREVIEW, true);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_SHOW_OBJECT_TIPS, true);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_LONG_LIST_FETCH_SIZE, 5000);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_SHOW_STATISTICS_INFO, true);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_SHOW_CONNECTION_HOST_NAME, true);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_SHOW_NODE_ACTIONS, true);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.ENTITY_EDITOR_DETACH_INFO, true);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_SHOW_TOOLTIPS, true);
    PrefUtils.setDefaultPreferenceValue(store, NavigatorPreferences.NAVIGATOR_SHOW_CONTENTS_IN_TOOLTIP, false);
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 74 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.

the class PrefPagePostgreSQL method performOk.

@Override
public boolean performOk() {
    DBPPreferenceStore preferenceStore = DBWorkbench.getPlatform().getPreferenceStore();
    preferenceStore.setValue(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB, String.valueOf(showNonDefault.getSelection()));
    preferenceStore.setValue(PostgreConstants.PROP_SHOW_TEMPLATES_DB, String.valueOf(showTemplates.getSelection()));
    preferenceStore.setValue(PostgreConstants.PROP_SHOW_UNAVAILABLE_DB, String.valueOf(showUnavailable.getSelection()));
    preferenceStore.setValue(PostgreConstants.PROP_DD_PLAIN_STRING, ddPlainBehaviorCombo.getSelectionIndex() == 0);
    preferenceStore.setValue(PostgreConstants.PROP_DD_TAG_STRING, ddTagBehaviorCombo.getSelectionIndex() == 0);
    return super.performOk();
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 75 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.

the class PrefPagePostgreSQL method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite cfgGroup = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout(1, false);
    gl.marginHeight = 10;
    gl.marginWidth = 10;
    cfgGroup.setLayout(gl);
    cfgGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    DBPPreferenceStore globalPrefs = DBWorkbench.getPlatform().getPreferenceStore();
    {
        Group secureGroup = new Group(cfgGroup, SWT.NONE);
        secureGroup.setText(PostgreMessages.dialog_setting_connection_settings);
        secureGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        secureGroup.setLayout(new GridLayout(2, false));
        showNonDefault = UIUtils.createCheckbox(secureGroup, PostgreMessages.dialog_setting_connection_nondefaultDatabase, PostgreMessages.dialog_setting_connection_nondefaultDatabase_tip, globalPrefs.getBoolean(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB), 2);
        showNonDefault.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                showTemplates.setEnabled(showNonDefault.getSelection());
                showUnavailable.setEnabled(showNonDefault.getSelection());
            }
        });
        showTemplates = UIUtils.createCheckbox(secureGroup, PostgreMessages.dialog_setting_connection_show_templates, PostgreMessages.dialog_setting_connection_show_templates_tip, globalPrefs.getBoolean(PostgreConstants.PROP_SHOW_TEMPLATES_DB), 2);
        showUnavailable = UIUtils.createCheckbox(secureGroup, PostgreMessages.dialog_setting_connection_show_not_available_for_conn, PostgreMessages.dialog_setting_connection_show_not_available_for_conn_tip, globalPrefs.getBoolean(PostgreConstants.PROP_SHOW_UNAVAILABLE_DB), 2);
    }
    {
        Group secureGroup = new Group(cfgGroup, SWT.NONE);
        secureGroup.setText(PostgreMessages.dialog_setting_group_sql);
        secureGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        secureGroup.setLayout(new GridLayout(2, false));
        ddPlainBehaviorCombo = UIUtils.createLabelCombo(secureGroup, PostgreMessages.dialog_setting_sql_dd_plain_label, PostgreMessages.dialog_setting_sql_dd_plain_tip, SWT.DROP_DOWN | SWT.READ_ONLY);
        ddPlainBehaviorCombo.add(PostgreMessages.dialog_setting_sql_dd_string);
        ddPlainBehaviorCombo.add(PostgreMessages.dialog_setting_sql_dd_code_block);
        ddTagBehaviorCombo = UIUtils.createLabelCombo(secureGroup, PostgreMessages.dialog_setting_sql_dd_tag_label, PostgreMessages.dialog_setting_sql_dd_tag_tip, SWT.DROP_DOWN | SWT.READ_ONLY);
        ddTagBehaviorCombo.add(PostgreMessages.dialog_setting_sql_dd_string);
        ddTagBehaviorCombo.add(PostgreMessages.dialog_setting_sql_dd_code_block);
        ddPlainBehaviorCombo.select(globalPrefs.getBoolean(PostgreConstants.PROP_DD_PLAIN_STRING) ? 0 : 1);
        ddTagBehaviorCombo.select(globalPrefs.getBoolean(PostgreConstants.PROP_DD_TAG_STRING) ? 0 : 1);
    }
    return cfgGroup;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Aggregations

DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)201 DBPPreferenceListener (org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)10 ExecutionException (org.eclipse.core.commands.ExecutionException)8 GridData (org.eclipse.swt.layout.GridData)8 NotNull (org.jkiss.code.NotNull)8 BundlePreferenceStore (org.jkiss.dbeaver.model.impl.preferences.BundlePreferenceStore)8 Color (org.eclipse.swt.graphics.Color)6 FontData (org.eclipse.swt.graphics.FontData)6 DBException (org.jkiss.dbeaver.DBException)6 DBDDisplayFormat (org.jkiss.dbeaver.model.data.DBDDisplayFormat)6 QMObjectType (org.jkiss.dbeaver.model.qm.QMObjectType)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)4 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)4