use of com.cubrid.common.ui.query.control.QueryResultComposite in project cubrid-manager by CUBRID.
the class QueryEditorPart method runQueryPlanOnly.
/**
* Fetch execution plans while running SQLs
*
* @param queries String
*/
private void runQueryPlanOnly(Vector<String> qVector) {
try {
connection.getConnection(true);
} catch (SQLException e) {
CommonUITool.openErrorBox(e.getLocalizedMessage());
return;
}
if (!connection.hasConnection()) {
return;
}
// clearPlan();
CUBRIDStatementProxy statement = null;
int i = 0;
try {
int len = qVector.size();
for (i = 0; i < len; i++) {
String sql = qVector.get(i).toString();
statement = getStatement(connection.getConnection(), false);
StructQueryPlan sq = new StructQueryPlan(sql, statement.getQueryplan(sql), new Date());
if (combinedQueryComposite.getQueryPlanResultComp().isDisposed()) {
combinedQueryComposite.newQueryPlanComp();
}
combinedQueryComposite.getQueryPlanResultComp().makePlan(sq, i);
QueryUtil.freeQuery(statement);
statement = null;
if (collectExecStats) {
displayTuneModeResult(new TuneModeModel(sq, null));
}
}
} catch (Exception ee) {
int errorCode = 0;
if (SQLException.class.isInstance(ee)) {
errorCode = ((SQLException) ee).getErrorCode();
}
String errmsg = "";
if (isAutocommit) {
try {
queryAction(QUERY_ACTION.ROLLBACK);
} catch (SQLException e1) {
LOGGER.error("", e1);
}
}
SQLEditorComposite sqlEditorComp = combinedQueryComposite.getSqlEditorComp();
sqlEditorComp.txtFind((String) qVector.get(i), 0, false, false, true, false);
StyledText txaEdit = sqlEditorComp.getText();
int line = txaEdit.getLineAtOffset(txaEdit.getSelection().x) + 1;
String errorLineMsg = Messages.bind(Messages.errWhere, line);
errmsg += Messages.runError + errorCode + StringUtil.NEWLINE + errorLineMsg + StringUtil.NEWLINE + Messages.errorHead + ee.getMessage();
CTabFolder queryResultTabFolder = combinedQueryComposite.getQueryResultComp().getQueryResultTabFolder();
StyledText logMessagesArea = combinedQueryComposite.getQueryResultComp().getLogMessagesArea();
QueryResultComposite queryResult = combinedQueryComposite.getQueryResultComp();
queryResultTabFolder.setSelection(0);
String logMessage = logMessagesArea.getText();
if (logMessage != null && logMessage.length() > 0) {
logMessage += StringUtil.NEWLINE;
}
logMessagesArea.setText(logMessage + StringUtil.NEWLINE + errmsg);
logMessagesArea.setTopIndex(logMessagesArea.getLineCount() - 1);
queryResult.setSelection();
LOGGER.error(ee.getMessage(), ee);
} finally {
QueryUtil.freeQuery(statement);
statement = null;
}
autoCommitItem.setEnabled(true);
queryPlanItem.setEnabled(true);
setPstmtParaItem.setEnabled(true);
isRunning = false;
}
use of com.cubrid.common.ui.query.control.QueryResultComposite in project cubrid-manager by CUBRID.
the class QueryEditorPart method refreshQueryOptions.
// /**
// * Set query connection
// *
// * @param queryConn Connection
// */
// public void setQueryConn(Connection queryConn) {
// this.queryConn = queryConn;
// }
/**
* When query options change or database and server refresh, refresh this
* query style
*/
public void refreshQueryOptions() {
CubridDatabase database = getSelectedDatabase();
boolean enabled = (database != DatabaseNavigatorMenu.NULL_DATABASE);
if (enabled && !connection.hasConnection()) {
this.initConnection(database);
}
enabled = enabled && connection.hasConnection();
if (enabled) {
for (CombinedQueryEditorComposite combinedQueryEditorComposite : getAllCombinedQueryEditorComposite()) {
combinedQueryEditorComposite.getMultiDBQueryComp().setMainDatabase(database);
}
}
queryPlanItem.setEnabled(enabled);
setPstmtParaItem.setEnabled(enabled);
ServerInfo serverInfo = getSelectedServer() == null ? null : getSelectedServer().getServerInfo();
String fontString = QueryOptions.getFontString(serverInfo);
Font font = ResourceManager.getFont(fontString);
if (font == null) {
String[] fontData = QueryOptions.getDefaultFont();
font = ResourceManager.getFont(fontData[0], Integer.valueOf(fontData[1]), Integer.valueOf(fontData[2]));
}
int[] fontColor = QueryOptions.getFontColor(serverInfo);
final Color color = ResourceManager.getColor(fontColor[0], fontColor[1], fontColor[2]);
// Change SQL editor font
if (font != null) {
getSqlTextEditor().setFont(font);
}
getSqlTextEditor().setForeground(color);
for (CombinedQueryEditorComposite combinedQueryEditorComposite : getAllCombinedQueryEditorComposite()) {
combinedQueryEditorComposite.getSqlEditorComp().getTextViewer().refresh();
// Change the table result font
QueryResultComposite queryResultComp = combinedQueryComposite.getQueryResultComp();
if (queryResultComp == null || queryResultComp.isDisposed()) {
return;
}
Table resultTable = queryResultComp.getResultTable();
if (resultTable != null && !resultTable.isDisposed()) {
resultTable.setFont(font);
resultTable.setForeground(color);
}
// Update editor config
if (database != null) {
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, isCMMode);
if (editorConfig != null && editorConfig.getBackGround() != null) {
setEditorBackground(ResourceManager.getColor(editorConfig.getBackGround()));
} else {
setEditorBackground(ResourceManager.getColor(EditorConstance.getDefaultBackground()));
}
}
//query plan
combinedQueryComposite.getQueryPlanResultComp().fillPlanHistory();
//sql history
combinedQueryComposite.getRecentlyUsedSQLComposite().fillRecentlyUsedSQLList();
/*Fire database changed*/
combinedQueryComposite.fireDatabaseChanged(database);
}
}
Aggregations