use of org.eclipse.swt.custom.StyleRange in project cubrid-manager by CUBRID.
the class ProductInfoDialog method setBoldRanges.
/**
* Sets the styled text's bold ranges
*
* @param styledText the styledText
* @param boldRanges the range array
*/
protected void setBoldRanges(StyledText styledText, int[][] boldRanges) {
for (int i = 0; i < boldRanges.length; i++) {
StyleRange r = new StyleRange(boldRanges[i][0], boldRanges[i][1], null, null, SWT.BOLD);
styledText.setStyleRange(r);
}
}
use of org.eclipse.swt.custom.StyleRange in project cubrid-manager by CUBRID.
the class ViewSQLLogDialog method updateDetialInfo.
private void updateDetialInfo(SqlRunnerFailed runSQLFaild) {
String strLine = Messages.lblLine;
String strSQL = Messages.lblSql;
String strErr = Messages.lblError;
StyleRange lineLabelStyle = new StyleRange();
lineLabelStyle.fontStyle = SWT.BOLD;
StyleRange sqlLabelStyle = new StyleRange();
sqlLabelStyle.fontStyle = SWT.BOLD;
StyleRange errorLabelStyle = new StyleRange();
errorLabelStyle.fontStyle = SWT.BOLD;
StringBuilder sb = new StringBuilder();
lineLabelStyle.start = sb.length();
lineLabelStyle.length = strLine.length();
sb.append(strLine).append(StringUtil.NEWLINE);
sb.append(runSQLFaild.getLineIndex()).append(StringUtil.NEWLINE);
boolean isShowSql = StringUtil.isNotEmpty(runSQLFaild.getSql());
if (isShowSql) {
sqlLabelStyle.start = sb.length();
sqlLabelStyle.length = strSQL.length();
sb.append(strSQL).append(StringUtil.NEWLINE);
sb.append(runSQLFaild.getSql()).append(StringUtil.NEWLINE);
}
errorLabelStyle.start = sb.length();
errorLabelStyle.length = strErr.length();
errorLabelStyle.foreground = ResourceManager.getColor(SWT.COLOR_RED);
sb.append(strErr).append(StringUtil.NEWLINE);
sb.append(runSQLFaild.getErrorMessage());
detailText.setText(sb.toString());
detailText.setStyleRange(lineLabelStyle);
if (isShowSql) {
detailText.setStyleRange(sqlLabelStyle);
}
detailText.setStyleRange(errorLabelStyle);
}
use of org.eclipse.swt.custom.StyleRange in project cubrid-manager by CUBRID.
the class QueryExecuter method updateStyledLogTextForTrace.
private void updateStyledLogTextForTrace(StyledText messageText) {
String text = messageText.getText();
final String[] titleString = { "Trace Statistics:" };
for (int i = 0, sp = -1, ep = 0, len = titleString.length; i < len; i++) {
sp = text.indexOf(titleString[i], ep);
if (sp != -1) {
StyleRange eachStyle = new StyleRange();
eachStyle.start = sp;
eachStyle.length = titleString[i].length();
eachStyle.fontStyle = SWT.BOLD;
eachStyle.foreground = ResourceManager.getColor(SWT.COLOR_BLUE);
messageText.setStyleRange(eachStyle);
}
ep = sp + 1;
}
}
use of org.eclipse.swt.custom.StyleRange in project cubrid-manager by CUBRID.
the class QueryExecuter method makeResult.
/**
* Make query editor result panel,including table panel and sql text and
* message text
*
* @param resultTbl the Table.
* @param sqlText the Text.
* @param messageText the StyledText.
*/
public void makeResult(final TableSelectSupport tableSelectSupport, StyledText messageText, boolean multiQueryResult) {
this.selectableSupport = tableSelectSupport;
this.tblResult = tableSelectSupport.getTable();
logMessageText = messageText;
int[] queryInfoRange = new int[2];
int[] queryRange = new int[2];
StringBuilder resultMessage = new StringBuilder();
resultMessage.append(getQueryMsg() == null ? "" : getQueryMsg().trim());
queryInfoRange[0] = 0;
queryInfoRange[1] = resultMessage.length();
resultMessage.append(StringUtil.NEWLINE).append(QueryUtil.SPLIT_LINE_FOR_QUERY_RESULT).append(StringUtil.NEWLINE);
queryRange[0] = resultMessage.length();
resultMessage.append(query);
queryRange[1] = query.length();
ServerInfo serverInfo = database.getServer() == null ? null : database.getServer().getServerInfo();
String fontString = QueryOptions.getFontString(serverInfo);
Font tmpFont = ResourceManager.getFont(fontString);
if (tmpFont == null) {
String[] fontData = QueryOptions.getDefaultFont();
tmpFont = ResourceManager.getFont(fontData[0], Integer.valueOf(fontData[1]), Integer.valueOf(fontData[2]));
}
font = tmpFont;
tblResult.setFont(font);
int[] fontColor = QueryOptions.getFontColor(serverInfo);
color = ResourceManager.getColor(fontColor[0], fontColor[1], fontColor[2]);
tblResult.setForeground(color);
// Set font and foreground
selectableSupport.getTableCursor().setFont(font);
selectableSupport.getTableCursor().setForeground(color);
selectableSupport.setShowDetailOperator(this);
tblResult.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
selectableSupport.redrawMoreButton();
}
});
if (queryEditor != null) {
if (!multiQueryResult) {
createContextMenuItems();
}
editor = new ControlEditor(selectableSupport.getTableCursor());
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.grabVertical = true;
bindEvents();
addTableItemToolTips();
}
makeColumn();
makeItem();
if (!StringUtil.isEmpty(queryPlanLog)) {
resultMessage.append(StringUtil.NEWLINE).append(QueryUtil.SPLIT_LINE_FOR_QUERY_RESULT);
resultMessage.append(StringUtil.NEWLINE).append(queryPlanLog);
}
if (!StringUtil.isEmpty(statsLog)) {
resultMessage.append(StringUtil.NEWLINE).append(Messages.queryStat).append(":");
resultMessage.append(StringUtil.NEWLINE).append(QueryUtil.SPLIT_LINE_FOR_QUERY_RESULT);
resultMessage.append(StringUtil.NEWLINE).append(statsLog);
}
messageText.setText(resultMessage.toString());
// Styled Query info
StyleRange queryInfoStyle = new StyleRange();
queryInfoStyle.start = queryInfoRange[0];
queryInfoStyle.length = queryInfoRange[1];
queryInfoStyle.fontStyle = SWT.NORMAL;
queryInfoStyle.foreground = ResourceManager.getColor(SWT.COLOR_BLUE);
messageText.setStyleRange(queryInfoStyle);
StyleRange queryStyle = new StyleRange();
queryStyle.start = queryRange[0];
queryStyle.length = queryRange[1];
queryStyle.fontStyle = SWT.BOLD;
messageText.setStyleRange(queryStyle);
// styled log text
updateStyledLogTextForStatistics(messageText);
updateStyledLogTextForPlan(messageText);
updateStyledLogTextForTrace(messageText);
}
use of org.eclipse.swt.custom.StyleRange in project cubrid-manager by CUBRID.
the class QueryExecuter method updateStyledLogTextForStatistics.
private void updateStyledLogTextForStatistics(StyledText messageText) {
String text = messageText.getText();
final String[] titleString = { Messages.queryStat };
for (int i = 0, sp = -1, ep = 0, len = titleString.length; i < len; i++) {
sp = text.indexOf(titleString[i], ep);
if (sp != -1) {
StyleRange eachStyle = new StyleRange();
eachStyle.start = sp;
eachStyle.length = titleString[i].length();
eachStyle.fontStyle = SWT.NORMAL;
eachStyle.foreground = ResourceManager.getColor(SWT.COLOR_BLUE);
messageText.setStyleRange(eachStyle);
}
ep = sp + 1;
}
}
Aggregations