Java 类org.hibernate.jdbc.util.BasicFormatterImpl 实例源码

项目:scouter    文件:DigestDetailDialog.java   
private Control getExampleQuery(Composite parent, MapPack m) {
    int sqlHash = m.getInt("sql_text");
    long time = m.getLong("time");
    long threadId = m.getLong("thread_id");
    long timer = m.getLong("timer");
    long lock_time = m.getLong("lock_time");


    Font boldFont = new Font(Display.getDefault(), "Arial", 9, SWT.BOLD);
    resources.add(boldFont);
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, true));
    StyledText sqlText = new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 500;
    gd.heightHint = 150;
    sqlText.setLayoutData(gd);
    String sql = TextProxy.maria.getLoadText(date, sqlHash, serverId);
    if (StringUtil.isEmpty(sql) == false) {
        sql = new BasicFormatterImpl().format(TextProxy.maria.getLoadText(date, sqlHash, serverId));
        SqlFormatUtil.applyStyledFormat(sqlText, sql);
    }

    Label label1 = new Label(composite, SWT.NONE);
    label1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    label1.setText("Execution Time");
    label1.setFont(boldFont);
    Label timerLbl = new Label(composite, SWT.NONE);
    timerLbl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    timerLbl.setText(FormatUtil.print(timer  * PICO, "#,##0.00#") + " sec");

    Label label2 = new Label(composite, SWT.NONE);
    label2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    label2.setText("Date");
    label2.setFont(boldFont);
    Label dateLbl = new Label(composite, SWT.NONE);
    dateLbl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    dateLbl.setText(DateUtil.format(time, "yyyy-MM-dd HH:mm:ss"));

    Label label3 = new Label(composite, SWT.NONE);
    label3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    label3.setText("Thread ID");
    label3.setFont(boldFont);
    Label threadLbl = new Label(composite, SWT.NONE);
    threadLbl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    threadLbl.setText(CastUtil.cString(threadId));

    Label label4 = new Label(composite, SWT.NONE);
    label4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    label4.setText("Lock Time");
    label4.setFont(boldFont);
    Label lockLbl = new Label(composite, SWT.NONE);
    lockLbl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    lockLbl.setText(FormatUtil.print(lock_time  * PICO, "#,##0.00#") + " sec");
    return composite;
}
项目:ERDesignerNG    文件:SQLUtils.java   
/**
 * Prettyformat a SQL Statement.
 * 
 * This is based on the Hibernate Formatter implementation.
 * 
 * @param aSQLStatement
 *        - SQL statement to format
 * @return pretty formatted SQL
 */
public static String prettyFormat(String aSQLStatement) {
    if (StringUtils.isEmpty(aSQLStatement)) {
        return aSQLStatement;
    }
    return new BasicFormatterImpl().format(aSQLStatement);
}