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