use of org.eclipse.core.runtime.Preferences in project tdi-studio-se by Talend.
the class OracleExplainPlanAction method run.
/*
* (non-Javadoc)
*
* @see org.talend.sqlbuilder.actions.AbstractEditorAction#run()
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
@Override
public void run() {
RepositoryNode node = editor.getRepositoryNode();
SessionTreeNodeManager nodeManager = new SessionTreeNodeManager();
SessionTreeNode runNode = null;
try {
runNode = nodeManager.getSessionTreeNode(node, editor.getDialog().getSelectedContext());
} catch (Exception e) {
//$NON-NLS-1$
MessageDialog.openError(null, Messages.getString("AbstractSQLExecution.Executing.Error"), e.getMessage());
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage1"), e);
return;
}
Preferences prefs = SqlBuilderPlugin.getDefault().getPluginPreferences();
String queryDelimiter = prefs.getString(IConstants.QUERY_DELIMITER);
String alternateDelimiter = prefs.getString(IConstants.ALTERNATE_DELIMITER);
String commentDelimiter = prefs.getString(IConstants.COMMENT_DELIMITER);
QueryTokenizer qt = new QueryTokenizer(getSQLToBeExecuted(), queryDelimiter, alternateDelimiter, commentDelimiter);
List queryStrings = new ArrayList();
while (qt.hasQuery()) {
final String querySql = qt.nextQuery();
// ignore commented lines.
if (!querySql.startsWith("--")) {
//$NON-NLS-1$
queryStrings.add(querySql);
}
}
// check if we can run explain plans
try {
Statement st = runNode.getInteractiveConnection().createStatement();
boolean createPlanTable = false;
boolean notFoundTable = true;
try {
//$NON-NLS-1$
ResultSet rs = st.executeQuery("select statement_id from plan_table");
notFoundTable = false;
rs.close();
} catch (Throwable e) {
createPlanTable = MessageDialog.openQuestion(null, //$NON-NLS-1$
Messages.getString("oracle.editor.actions.explain.notFound.Title"), //$NON-NLS-1$
Messages.getString("oracle.editor.actions.explain.notFound"));
} finally {
try {
st.close();
} catch (Throwable e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage2"), e);
}
}
if (notFoundTable && !createPlanTable) {
return;
}
if (notFoundTable && createPlanTable) {
SQLConnection conn = runNode.getInteractiveConnection();
st = conn.createStatement();
try {
st.execute(createPlanTableScript);
if (!conn.getAutoCommit()) {
conn.commit();
}
} catch (Throwable e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage2"), e);
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
null, //$NON-NLS-1$
Messages.getString("oracle.editor.actions.explain.createError.Title"), //$NON-NLS-1$
Messages.getString("oracle.editor.actions.explain.createError"));
try {
st.close();
} catch (Throwable e1) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage3"), e1);
}
return;
}
try {
st.close();
} catch (Throwable e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage3"), e);
}
}
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage4"), e);
}
try {
while (!queryStrings.isEmpty()) {
String querySql = (String) queryStrings.remove(0);
if (querySql != null) {
resultDisplayer.addSQLExecution(new OracleExplainPlanExecution(querySql, runNode));
}
}
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage5"), e);
}
}
use of org.eclipse.core.runtime.Preferences in project liferay-ide by liferay.
the class Plugin method initializeDefaultPluginPreferences.
/**
* Initializes the plugin preferences with default preference values for
* this plug-in.
*/
protected void initializeDefaultPluginPreferences() {
Preferences prefs = getPluginPreferences();
prefs.setDefault(Constants.HIGHLIGHT_RELATED_ITEMS, true);
// $NON-NLS-1$
prefs.setDefault(Constants.COLOR_COMMENT, "170,0,0");
// $NON-NLS-1$
prefs.setDefault(Constants.COLOR_TEXT, "0,0,0");
// $NON-NLS-1$
prefs.setDefault(Constants.COLOR_INTERPOLATION, "255,0,128");
// $NON-NLS-1$
prefs.setDefault(Constants.COLOR_DIRECTIVE, "0,0,255");
// $NON-NLS-1$
prefs.setDefault(Constants.COLOR_STRING, "0,128,128");
// $NON-NLS-1$
prefs.setDefault(Constants.COLOR_XML_COMMENT, "128,128,128");
// $NON-NLS-1$
prefs.setDefault(Constants.COLOR_XML_TAG, "0,0,128");
// $NON-NLS-1$
prefs.setDefault(Constants.COLOR_RELATED_ITEM, "255,255,128");
}
use of org.eclipse.core.runtime.Preferences in project jbosstools-hibernate by jbosstools.
the class ToggleLayoutAction method valueChanged.
private void valueChanged(boolean value, boolean doStore) {
setChecked(!value);
view.setManualLayout(value);
setToolTipText(value ? HibernateConsoleMessages.ToggleLayoutAction_manual_layout_active : HibernateConsoleMessages.ToggleLayoutAction_auto_layout_active);
setDescription(value ? HibernateConsoleMessages.ToggleLayoutAction_enable_auto_layout : HibernateConsoleMessages.ToggleLayoutAction_enable_manual_layout);
if (doStore) {
Preferences prefs = HibernateConsolePlugin.getDefault().getPluginPreferences();
prefs.setValue(pluginKey, value);
HibernateConsolePlugin.getDefault().savePluginPreferences();
}
}
use of org.eclipse.core.runtime.Preferences in project tdq-studio-se by Talend.
the class BasicQueryParser method parse.
/* (non-JavaDoc)
* @see net.sourceforge.sqlexplorer.parsers.QueryParser#parse()
*/
public void parse() throws ParserException {
if (sql == null)
return;
Preferences prefs = SQLExplorerPlugin.getDefault().getPluginPreferences();
if (prefs.getBoolean(IConstants.ENABLE_STRUCTURED_COMMENTS)) {
StringBuffer buffer = new StringBuffer(sql.toString());
Tokenizer tokenizer = new Tokenizer(buffer);
StructuredCommentParser structuredComments = new StructuredCommentParser(this, buffer);
// Otherwise just use a standard tokenizer
try {
Token token;
while ((token = tokenizer.nextToken()) != null) {
if (token.getTokenType() == Tokenizer.TokenType.EOL_COMMENT || token.getTokenType() == Tokenizer.TokenType.ML_COMMENT) {
structuredComments.addComment(token);
}
}
} catch (StructuredCommentException e) {
}
// Do the structured comments and then reset the tokenizer
structuredComments.process();
tokenizer.reset();
tokenizer = null;
sql = buffer;
}
_sQuerys = prepareSQL(sql.toString());
_sNextQuery = doParse();
sql = null;
}
use of org.eclipse.core.runtime.Preferences in project webtools.servertools by eclipse.
the class MonitorManager method loadMonitors.
protected synchronized void loadMonitors() {
if (Trace.FINEST) {
Trace.trace(Trace.STRING_FINEST, "Loading monitors");
}
monitors = new ArrayList<IMonitor>();
Preferences prefs = MonitorPlugin.getInstance().getPluginPreferences();
String xmlString = prefs.getString("monitors");
if (xmlString != null && xmlString.length() > 0) {
try {
ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
IMemento memento = XMLMemento.loadMemento(in);
IMemento[] children = memento.getChildren("monitor");
if (children != null) {
int size = children.length;
for (int i = 0; i < size; i++) {
Monitor monitor = new Monitor();
monitor.load(children[i]);
monitors.add(monitor);
}
}
} catch (Exception e) {
if (Trace.WARNING) {
Trace.trace(Trace.STRING_WARNING, "Could not load monitors", e);
}
}
}
}
Aggregations