Search in sources :

Example 1 with DBPPreferenceStore

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

the class SQLExternalFormatter method format.

@Override
public String format(String source, SQLFormatterConfiguration configuration) {
    final DBPPreferenceStore store = configuration.getSyntaxManager().getPreferenceStore();
    final String command = store.getString(ModelPreferences.SQL_FORMAT_EXTERNAL_CMD);
    int timeout = store.getInt(ModelPreferences.SQL_FORMAT_EXTERNAL_TIMEOUT);
    boolean useFile = store.getBoolean(ModelPreferences.SQL_FORMAT_EXTERNAL_FILE);
    try {
        final FormatJob formatJob = new FormatJob(configuration, command, source, useFile);
        formatJob.schedule();
        for (int i = 0; i < 10; i++) {
            Thread.sleep(timeout / 10);
            if (formatJob.finished) {
                return formatJob.result;
            }
        }
        log.warn("Formatter process hangs. Terminating.");
        formatJob.stop();
    } catch (Exception ex) {
        log.warn("Error executing external formatter [" + command + "]", ex);
    }
    return source;
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 2 with DBPPreferenceStore

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

the class CursorViewDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final IValueController valueController = getValueController();
    value = (DBDCursor) valueController.getValue();
    Composite dialogGroup = (Composite) super.createDialogArea(parent);
    if (value != null) {
        DBPPreferenceStore globalPreferenceStore = DBeaverCore.getGlobalPreferenceStore();
        if (!globalPreferenceStore.getBoolean(DBeaverPreferences.KEEP_STATEMENT_OPEN)) {
            if (ConfirmationDialog.showConfirmDialog(getShell(), DBeaverPreferences.CONFIRM_KEEP_STATEMENT_OPEN, ConfirmationDialog.QUESTION) == IDialogConstants.YES_ID) {
                globalPreferenceStore.setValue(DBeaverPreferences.KEEP_STATEMENT_OPEN, true);
                if (valueController.getValueSite().getPart() instanceof IResultSetContainer) {
                    IResultSetController rsv = ((IResultSetContainer) valueController.getValueSite().getPart()).getResultSetController();
                    if (rsv != null) {
                        rsv.refresh();
                    }
                }
            }
            DBeaverUI.asyncExec(new Runnable() {

                @Override
                public void run() {
                    close();
                }
            });
        }
    }
    resultSetViewer = new ResultSetViewer(dialogGroup, valueController.getValueSite(), this);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 300;
    gd.grabExcessVerticalSpace = true;
    resultSetViewer.getControl().setLayoutData(gd);
    resultSetViewer.refresh();
    return dialogGroup;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) IResultSetContainer(org.jkiss.dbeaver.ui.controls.resultset.IResultSetContainer) GridData(org.eclipse.swt.layout.GridData) IResultSetController(org.jkiss.dbeaver.ui.controls.resultset.IResultSetController) IValueController(org.jkiss.dbeaver.ui.data.IValueController) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) ResultSetViewer(org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer)

Example 3 with DBPPreferenceStore

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

the class PrefPageEntityEditor method performOk.

@Override
public boolean performOk() {
    DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
    store.setValue(DBeaverPreferences.UI_KEEP_DATABASE_EDITORS, keepEditorsOnRestart.getSelection());
    store.setValue(DBeaverPreferences.NAVIGATOR_REFRESH_EDITORS_ON_OPEN, refreshEditorOnOpen.getSelection());
    store.setValue(DBeaverPreferences.NAVIGATOR_EDITOR_FULL_NAME, editorFullName.getSelection());
    store.setValue(DBeaverPreferences.NAVIGATOR_SHOW_SQL_PREVIEW, showPreviewOnSave.getSelection());
    PrefUtils.savePreferenceStore(store);
    return true;
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 4 with DBPPreferenceStore

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

the class PrefPageDatabaseGeneral method performOk.

@Override
public boolean performOk() {
    DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
    store.setValue(DBeaverPreferences.UI_AUTO_UPDATE_CHECK, automaticUpdateCheck.getSelection());
    //store.setValue(DBeaverPreferences.AGENT_ENABLED, agentEnabledCheck.getSelection());
    store.setValue(DBeaverPreferences.AGENT_LONG_OPERATION_NOTIFY, longOperationsCheck.getSelection());
    store.setValue(DBeaverPreferences.AGENT_LONG_OPERATION_TIMEOUT, longOperationsTimeout.getSelection());
    store.setValue(DBeaverPreferences.DEFAULT_RESOURCE_ENCODING, defaultResourceEncoding.getText());
    PrefUtils.savePreferenceStore(store);
    return true;
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 5 with DBPPreferenceStore

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

the class PrefPageDatabaseGeneral method performDefaults.

@Override
protected void performDefaults() {
    DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
    automaticUpdateCheck.setSelection(store.getBoolean(DBeaverPreferences.UI_AUTO_UPDATE_CHECK));
    longOperationsCheck.setSelection(store.getBoolean(DBeaverPreferences.AGENT_LONG_OPERATION_NOTIFY));
    longOperationsTimeout.setSelection(store.getInt(DBeaverPreferences.AGENT_LONG_OPERATION_TIMEOUT));
    defaultResourceEncoding.setText(store.getString(DBeaverPreferences.DEFAULT_RESOURCE_ENCODING));
}
Also used : 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