use of net.sourceforge.sqlexplorer.SQLCannotConnectException in project tdq-studio-se by Talend.
the class SQLExplorerPlugin method startDefaultConnections.
/**
* Open all connections that have the 'open on startup property'. This method should be called from within the UI
* thread!
*/
public void startDefaultConnections(ConnectionsView connectionsView) {
this.connectionsView = connectionsView;
if (_defaultConnectionsStarted) {
return;
}
String fontDesc = getPluginPreferences().getString(IConstants.FONT);
FontData fontData = null;
try {
try {
fontData = new FontData(fontDesc);
} catch (IllegalArgumentException e) {
fontData = new FontData("1|Courier New|10|0|WINDOWS|1|-13|0|0|0|400|0|0|0|0|3|2|1|49|Courier New");
}
PreferenceConverter.setValue(getPreferenceStore(), IConstants.FONT, fontData);
} catch (IllegalArgumentException e) {
error("Error setting font", e);
}
boolean openEditor = SQLExplorerPlugin.getDefault().getPluginPreferences().getBoolean(IConstants.AUTO_OPEN_EDITOR);
// Get the database structure view - NOTE: we don't use SQLExplorerPlugin.getDatabaseView()
// because it may not have an active page yet
DatabaseStructureView dbView = null;
IWorkbenchSite site = connectionsView.getSite();
if (site.getPage() != null) {
dbView = (DatabaseStructureView) site.getPage().findView(DatabaseStructureView.class.getName());
}
for (Alias alias : aliasManager.getAliases()) {
if (alias.isConnectAtStartup() && alias.isAutoLogon() && alias.getDefaultUser() != null) {
if (dbView != null) {
try {
dbView.addUser(alias.getDefaultUser());
} catch (SQLCannotConnectException e) {
// Ignore it; the problem is already in the log, we do not want to delay startup, and the
// problem will
// be apparent as soon as the user tries to use the connection
}
}
if (openEditor) {
SQLEditorInput input = new SQLEditorInput(SQL_EDITOR + SQLExplorerPlugin.getDefault().getEditorSerialNo() + SQL);
input.setUser(alias.getDefaultUser());
try {
site.getPage().openEditor(input, SQLEditor.class.getName());
} catch (PartInitException e) {
SQLExplorerPlugin.error("Cannot open SQL editor", e);
}
}
}
}
_defaultConnectionsStarted = true;
}
use of net.sourceforge.sqlexplorer.SQLCannotConnectException in project tdq-studio-se by Talend.
the class SQLExplorerPlugin method error.
/**
* Global log method.
*
* @param message
* @param t
*/
public static void error(String message, Throwable t) {
if (t instanceof SQLCannotConnectException) {
getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, String.valueOf(message), null));
} else {
getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, String.valueOf(message), t));
_logger.error(message, t);
}
}
Aggregations