use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.
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;
}
use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.
the class QueryLogViewer method reloadEvents.
private void reloadEvents() {
DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
this.entriesPerPage = Math.max(MIN_ENTRIES_PER_PAGE, store.getInt(QMConstants.PROP_ENTRIES_PER_PAGE));
this.defaultFilter = new DefaultEventFilter();
clearLog();
updateMetaInfo(QMUtils.getPastMetaEvents());
}
use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.
the class BinaryPanelEditor method createControl.
@Override
public HexEditControl createControl(IValueController valueController) {
HexEditControl hControl = new HexEditControl(valueController.getEditPlaceholder(), SWT.BORDER);
DBPPreferenceListener preferencesChangeListener = new DBPPreferenceListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (HexPreferencesPage.PROP_DEF_WIDTH.equals(event.getProperty())) {
String defValue = (String) event.getNewValue();
hControl.setDefWidth(Integer.valueOf(defValue));
}
}
};
DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
store.addPropertyChangeListener(preferencesChangeListener);
return hControl;
}
use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by dbeaver.
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 DBeaverApplication method initDebugWriter.
private void initDebugWriter() {
DBPPreferenceStore preferenceStore = DBeaverCore.getGlobalPreferenceStore();
if (!preferenceStore.getBoolean(DBeaverPreferences.LOGS_DEBUG_ENABLED)) {
return;
}
String logLocation = preferenceStore.getString(DBeaverPreferences.LOGS_DEBUG_LOCATION);
if (CommonUtils.isEmpty(logLocation)) {
// $NON-NLS-1$
logLocation = new File(GeneralUtils.getMetadataFolder(), "dbeaver-debug.log").getAbsolutePath();
}
logLocation = GeneralUtils.replaceVariables(logLocation, new SystemVariablesResolver());
File debugLogFile = new File(logLocation);
if (debugLogFile.exists()) {
if (!debugLogFile.delete()) {
// $NON-NLS-1$
System.err.println("Can't delete debug log file");
return;
}
}
try {
debugWriter = new FileOutputStream(debugLogFile);
oldSystemOut = System.out;
oldSystemErr = System.err;
System.setOut(new PrintStream(new ProxyPrintStream(debugWriter, oldSystemOut)));
System.setErr(new PrintStream(new ProxyPrintStream(debugWriter, oldSystemErr)));
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
Aggregations