Search in sources :

Example 21 with StyleRange

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);
    }
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange) Point(org.eclipse.swt.graphics.Point)

Example 22 with StyleRange

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);
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange)

Example 23 with StyleRange

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;
    }
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange) Point(org.eclipse.swt.graphics.Point)

Example 24 with StyleRange

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);
}
Also used : ControlEditor(org.eclipse.swt.custom.ControlEditor) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) StyleRange(org.eclipse.swt.custom.StyleRange) Font(org.eclipse.swt.graphics.Font)

Example 25 with StyleRange

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;
    }
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange) Point(org.eclipse.swt.graphics.Point)

Aggregations

StyleRange (org.eclipse.swt.custom.StyleRange)51 Point (org.eclipse.swt.graphics.Point)24 ArrayList (java.util.ArrayList)13 Color (org.eclipse.swt.graphics.Color)9 StyledText (org.eclipse.swt.custom.StyledText)7 Matcher (java.util.regex.Matcher)6 TextStyle (org.eclipse.swt.graphics.TextStyle)5 LinkedList (java.util.LinkedList)2 List (java.util.List)2 InnerTag (net.heartsome.cat.common.ui.innertag.InnerTag)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 KeyEvent (org.eclipse.swt.events.KeyEvent)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)2 GlyphMetrics (org.eclipse.swt.graphics.GlyphMetrics)2 ParamSetException (com.cubrid.common.ui.spi.util.paramSetter.ParamSetException)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1