Search in sources :

Example 6 with DBPPreferenceStore

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

the class SQLEditorSourceViewerConfiguration method getContentAssistant.

/**
     * Creates, initializes, and returns the ContentAssistant to use with this editor.
     */
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    DBPPreferenceStore store = editor.getActivePreferenceStore();
    final DBPPreferenceStore configStore = store;
    final SQLContentAssistant assistant = new SQLContentAssistant();
    assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    // Set content assist processors for various content types.
    if (completionProcessor != null) {
        assistant.setContentAssistProcessor(completionProcessor, IDocument.DEFAULT_CONTENT_TYPE);
    }
    // Configure how content assist information will appear.
    assistant.enableAutoActivation(store.getBoolean(SQLPreferenceConstants.ENABLE_AUTO_ACTIVATION));
    assistant.setAutoActivationDelay(store.getInt(SQLPreferenceConstants.AUTO_ACTIVATION_DELAY));
    assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
    assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
    //In the future, a preference page will be added to customize foreground and background.
    Color foreground = new Color(DBeaverUI.getDisplay(), 0, 0, 0);
    Color background = new Color(DBeaverUI.getDisplay(), 255, 255, 255);
    assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    assistant.setContextInformationPopupForeground(foreground);
    assistant.setContextInformationPopupBackground(background);
    //Set auto insert mode.
    assistant.enableAutoInsert(store.getBoolean(SQLPreferenceConstants.INSERT_SINGLE_PROPOSALS_AUTO));
    assistant.setShowEmptyList(true);
    final DBPPreferenceListener prefListener = new DBPPreferenceListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent event) {
            switch(event.getProperty()) {
                case SQLPreferenceConstants.ENABLE_AUTO_ACTIVATION:
                    assistant.enableAutoActivation(configStore.getBoolean(SQLPreferenceConstants.ENABLE_AUTO_ACTIVATION));
                    break;
                case SQLPreferenceConstants.AUTO_ACTIVATION_DELAY:
                    assistant.setAutoActivationDelay(configStore.getInt(SQLPreferenceConstants.AUTO_ACTIVATION_DELAY));
                    break;
                case SQLPreferenceConstants.INSERT_SINGLE_PROPOSALS_AUTO:
                    assistant.enableAutoInsert(configStore.getBoolean(SQLPreferenceConstants.INSERT_SINGLE_PROPOSALS_AUTO));
                    break;
            }
        }
    };
    configStore.addPropertyChangeListener(prefListener);
    editor.getTextViewer().getControl().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            configStore.removePropertyChangeListener(prefListener);
        }
    });
    return assistant;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Color(org.eclipse.swt.graphics.Color) DisposeEvent(org.eclipse.swt.events.DisposeEvent) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)

Example 7 with DBPPreferenceStore

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

the class ERDPreferencePage method performOk.

@Override
public boolean performOk() {
    DBPPreferenceStore store = ERDActivator.getDefault().getPreferences();
    store.setValue(ERDConstants.PREF_DIAGRAM_SHOW_VIEWS, contentsShowViews.getSelection());
    store.setValue(ERDConstants.PREF_GRID_ENABLED, gridCheck.getSelection());
    store.setValue(ERDConstants.PREF_GRID_SNAP_ENABLED, snapCheck.getSelection());
    store.setValue(ERDConstants.PREF_GRID_WIDTH, spinnerGridWidth.getSelection());
    store.setValue(ERDConstants.PREF_GRID_HEIGHT, spinnerGridHeight.getSelection());
    int pageMode;
    switch(modeCombo.getSelectionIndex()) {
        case 1:
            pageMode = PrintFigureOperation.FIT_PAGE;
            break;
        case 2:
            pageMode = PrintFigureOperation.FIT_WIDTH;
            break;
        case 3:
            pageMode = PrintFigureOperation.FIT_HEIGHT;
            break;
        default:
            pageMode = PrintFigureOperation.TILE;
            break;
    }
    store.setValue(ERDConstants.PREF_PRINT_PAGE_MODE, pageMode);
    store.setValue(ERDConstants.PREF_PRINT_MARGIN_TOP, spinnerMarginTop.getSelection());
    store.setValue(ERDConstants.PREF_PRINT_MARGIN_BOTTOM, spinnerMarginBottom.getSelection());
    store.setValue(ERDConstants.PREF_PRINT_MARGIN_LEFT, spinnerMarginLeft.getSelection());
    store.setValue(ERDConstants.PREF_PRINT_MARGIN_RIGHT, spinnerMarginRight.getSelection());
    for (Button radio : visibilityButtons) {
        if (radio.getSelection()) {
            ERDAttributeVisibility.setDefaultVisibility(store, (ERDAttributeVisibility) radio.getData());
        }
    }
    List<ERDAttributeStyle> enabledStyles = new ArrayList<>();
    for (Button check : styleButtons) {
        if (check.getSelection()) {
            enabledStyles.add((ERDAttributeStyle) check.getData());
        }
    }
    ERDAttributeStyle.setDefaultStyles(store, enabledStyles.toArray(new ERDAttributeStyle[enabledStyles.size()]));
    PrefUtils.savePreferenceStore(store);
    return true;
}
Also used : ArrayList(java.util.ArrayList) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 8 with DBPPreferenceStore

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

the class DiagramToggleGridAction method run.

@Override
public void run() {
    final DBPPreferenceStore store = ERDActivator.getDefault().getPreferences();
    final boolean gridEnabled = store.getBoolean(ERDConstants.PREF_GRID_ENABLED);
    store.setValue(ERDConstants.PREF_GRID_ENABLED, !gridEnabled);
    PrefUtils.savePreferenceStore(store);
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 9 with DBPPreferenceStore

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

the class WebUtils method openConnection.

@NotNull
public static URLConnection openConnection(String urlString, DBAAuthInfo authInfo) throws IOException {
    log.debug("Open [" + urlString + "]");
    DBPPreferenceStore prefs = DBeaverCore.getGlobalPreferenceStore();
    String proxyHost = prefs.getString(DBeaverPreferences.UI_PROXY_HOST);
    Proxy proxy = null;
    if (!CommonUtils.isEmpty(proxyHost)) {
        int proxyPort = prefs.getInt(DBeaverPreferences.UI_PROXY_PORT);
        if (proxyPort <= 0) {
            log.warn("Invalid proxy port: " + proxyPort);
        }
        proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
    }
    URL url = new URL(urlString);
    final URLConnection connection = (proxy == null ? url.openConnection() : url.openConnection(proxy));
    connection.setReadTimeout(10000);
    connection.setConnectTimeout(10000);
    if (connection instanceof HttpURLConnection) {
        final HttpURLConnection httpConnection = (HttpURLConnection) connection;
        //$NON-NLS-1$
        httpConnection.setRequestMethod("GET");
        httpConnection.setInstanceFollowRedirects(true);
        connection.setRequestProperty(//$NON-NLS-1$
        "User-Agent", GeneralUtils.getProductTitle());
        if (authInfo != null && !CommonUtils.isEmpty(authInfo.getUserName())) {
            // Set auth info
            String encoded = Base64.getEncoder().encodeToString((authInfo.getUserName() + ":" + CommonUtils.notEmpty(authInfo.getUserPassword())).getBytes(GeneralUtils.UTF8_CHARSET));
            connection.setRequestProperty("Authorization", "Basic " + encoded);
        }
    }
    connection.connect();
    if (connection instanceof HttpURLConnection) {
        final HttpURLConnection httpConnection = (HttpURLConnection) connection;
        final int responseCode = httpConnection.getResponseCode();
        if (responseCode != 200) {
            throw new IOException("Can't open '" + urlString + "': " + httpConnection.getResponseMessage());
        }
    }
    return connection;
}
Also used : IOException(java.io.IOException) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) NotNull(org.jkiss.code.NotNull)

Example 10 with DBPPreferenceStore

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

the class MySQLExportWizard method performFinish.

@Override
public boolean performFinish() {
    objectsPage.saveState();
    final DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
    store.setValue("MySQL.export.outputFilePattern", this.outputFilePattern);
    store.setValue("MySQL.export.noCreateStatements", noCreateStatements);
    store.setValue("MySQL.export.addDropStatements", addDropStatements);
    store.setValue("MySQL.export.disableKeys", disableKeys);
    store.setValue("MySQL.export.extendedInserts", extendedInserts);
    store.setValue("MySQL.export.dumpEvents", dumpEvents);
    store.setValue("MySQL.export.comments", comments);
    store.setValue("MySQL.export.removeDefiner", removeDefiner);
    store.setValue("MySQL.export.binariesInHex", binariesInHex);
    store.setValue("MySQL.export.noData", noData);
    store.setValue("MySQL.export.showViews", showViews);
    return super.performFinish();
}
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