Package javax.swing.text

Examples of javax.swing.text.StyledDocument


    /**
     * Выполняется в потоке AWT
     */
    private void awtThreadHighlight()
    {
        StyledDocument sdoc = textPane.getStyledDocument();
        int sdocLen = sdoc.getLength();
        String sdocText = null;
        try {
            sdocText = sdoc.getText(0, sdocLen);
        }
        catch (BadLocationException ex) {
            ex.printStackTrace();
        }
        if( sdocText==null )return;
View Full Code Here


    {
        if( textPane==null )return;
        if( ptrn==null )return;
        if( styles==null )return;
       
        StyledDocument sdoc = textPane.getStyledDocument();
        int sdocLen = sdoc.getLength();
        String __sourceText = null;
       
        try {
            __sourceText = sdoc.getText(0, sdocLen);
        }
        catch (BadLocationException ex) {
            return;
        }
View Full Code Here

        if( getStyles()==null )return;

        JTextPane tp = getTextPane();
        if( tp==null )return;

        StyledDocument doc = tp.getStyledDocument();
        TextStyleObject so = getStyles().get(id);
        Style s = so==null ? null : so.getStyle();
        if( s==null )return;

        int begin = m.getBegin();
        int len = m.getLength();

        doc.setCharacterAttributes(begin, len, s, true);
    }
View Full Code Here

     * @throws javax.swing.text.BadLocationException
     */
    public static void insert(final String s, final JTextComponent target,
            final int caretShift) throws BadLocationException {

        final StyledDocument doc = (StyledDocument) target.getDocument();

        class AtomicChange implements Runnable {

            public void run() {
                Document value = target.getDocument();
View Full Code Here

    private void load() {

// Get the text pane's document

        StyledDocument doc = (StyledDocument) jTextPane1.getDocument();
// Create a style object and then set the style attributes
        Style style = doc.addStyle("StyleName", null);
// Italic
        StyleConstants.setItalic(style, true);
// Bold
        StyleConstants.setBold(style, false);
// Font family
        StyleConstants.setFontFamily(style, "SansSerif");
// Font size
        StyleConstants.setFontSize(style, 11);
// Background color
        StyleConstants.setBackground(style, Color.white);
// Foreground color
        StyleConstants.setForeground(style, Color.BLACK);
// Append to document

        try {
            BufferedReader in = new BufferedReader(new FileReader(org.salamanca.
                    commands.CommandLogger.getLogFilePath()));
            String str;
            while ((str = in.readLine()) != null) {
                doc.insertString(doc.getLength(), str+lineSeparator, style);
            }
            in.close();
        } catch (IOException e) {
        } catch (BadLocationException ex) {
            /** @todo Handle this exception */
 
View Full Code Here

    /**
     * Creates the panel that contains all of the about box's text.
     */
    private JScrollPane createCreditsPanel() {
        JTextPane      text;
        StyledDocument doc;

        text = new JTextPane();
        doc  = text.getStyledDocument();

        text.setBackground(ThemeManager.getCurrentColor(Theme.FILE_TABLE_BACKGROUND_COLOR));
View Full Code Here

    private void initTextAreaLogger()
    {
        Style def = StyleContext.getDefaultStyleContext().
        getStyle(StyleContext.DEFAULT_STYLE);
       
        StyledDocument doc = txtLog.getStyledDocument();
       
        Style inStyle = doc.addStyle("bold", def);
        StyleConstants.setBold(inStyle, true);
       
        Style outStyle = doc.addStyle("bold", def);
        StyleConstants.setItalic(outStyle, true);
       
        PrintWriter pwIN = new PrintWriter(new DocumentWriter(txtLog.getStyledDocument(),inStyle));
        PrintWriter pwOUT = new PrintWriter(new DocumentWriter(txtLog.getStyledDocument(),outStyle));
        LoggingOutInterceptor out = new LoggingOutInterceptor(pwIN);
View Full Code Here

    private JTextPane getJEditorPane()
    {
        if (txtLog == null)
        {
            txtLog = new JTextPane();
            StyledDocument doc = txtLog.getStyledDocument();
           
            Style def = StyleContext.getDefaultStyleContext().
            getStyle(StyleContext.DEFAULT_STYLE);

            Style b = doc.addStyle("bold", def);
            StyleConstants.setBold(b, true);

        }
        return txtLog;
    }
View Full Code Here

    @SuppressWarnings("boxing")
    public void setupTabPane() {
        // Clear all data before display a new
        this.clearData();
        StyledDocument statsDoc = stats.getStyledDocument();
        try {
            if (userObject instanceof SampleResult) {
                sampleResult = (SampleResult) userObject;
                // We are displaying a SampleResult
                setupTabPaneForSampleResult();
                requestPanel.setSamplerResult(sampleResult);               

                final String samplerClass = sampleResult.getClass().getName();
                String typeResult = samplerClass.substring(1 + samplerClass.lastIndexOf('.'));
               
                StringBuilder statsBuff = new StringBuilder(200);
                statsBuff.append(JMeterUtils.getResString("view_results_thread_name")).append(sampleResult.getThreadName()).append(NL); //$NON-NLS-1$
                String startTime = dateFormat.format(new Date(sampleResult.getStartTime()));
                statsBuff.append(JMeterUtils.getResString("view_results_sample_start")).append(startTime).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_load_time")).append(sampleResult.getTime()).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_latency")).append(sampleResult.getLatency()).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_size_in_bytes")).append(sampleResult.getBytes()).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_size_headers_in_bytes")).append(sampleResult.getHeadersSize()).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_size_body_in_bytes")).append(sampleResult.getBodySize()).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_sample_count")).append(sampleResult.getSampleCount()).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_error_count")).append(sampleResult.getErrorCount()).append(NL); //$NON-NLS-1$
                statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null);
                statsBuff.setLength(0); // reset for reuse

                String responseCode = sampleResult.getResponseCode();

                int responseLevel = 0;
                if (responseCode != null) {
                    try {
                        responseLevel = Integer.parseInt(responseCode) / 100;
                    } catch (NumberFormatException numberFormatException) {
                        // no need to change the foreground color
                    }
                }

                Style style = null;
                switch (responseLevel) {
                case 3:
                    style = statsDoc.getStyle(STYLE_REDIRECT);
                    break;
                case 4:
                    style = statsDoc.getStyle(STYLE_CLIENT_ERROR);
                    break;
                case 5:
                    style = statsDoc.getStyle(STYLE_SERVER_ERROR);
                    break;
                }

                statsBuff.append(JMeterUtils.getResString("view_results_response_code")).append(responseCode).append(NL); //$NON-NLS-1$
                statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), style);
                statsBuff.setLength(0); // reset for reuse

                // response message label
                String responseMsgStr = sampleResult.getResponseMessage();

                statsBuff.append(JMeterUtils.getResString("view_results_response_message")).append(responseMsgStr).append(NL); //$NON-NLS-1$
                statsBuff.append(NL);
                statsBuff.append(JMeterUtils.getResString("view_results_response_headers")).append(NL); //$NON-NLS-1$
                statsBuff.append(sampleResult.getResponseHeaders()).append(NL);
                statsBuff.append(NL);
                statsBuff.append(typeResult + " "+ JMeterUtils.getResString("view_results_fields")).append(NL); //$NON-NLS-1$ $NON-NLS-2$
                statsBuff.append("ContentType: ").append(sampleResult.getContentType()).append(NL); //$NON-NLS-1$
                statsBuff.append("DataEncoding: ").append(sampleResult.getDataEncodingNoDefault()).append(NL); //$NON-NLS-1$
                statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null);
                statsBuff = null; // Done
               
                // Tabbed results: fill table
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_thread_name"), sampleResult.getThreadName())); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_sample_start"), startTime)); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_load_time"), sampleResult.getTime())); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_latency"), sampleResult.getLatency())); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_size_in_bytes"), sampleResult.getBytes())); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_size_headers_in_bytes"), sampleResult.getHeadersSize())); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_size_body_in_bytes"), sampleResult.getBodySize())); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_sample_count"), sampleResult.getSampleCount())); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_error_count"), sampleResult.getErrorCount())); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_response_code"), responseCode)); //$NON-NLS-1$
                resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_response_message"), responseMsgStr)); //$NON-NLS-1$
               
                // Parsed response headers
                LinkedHashMap<String, String> lhm = JMeterUtils.parseHeaders(sampleResult.getResponseHeaders());
                Set<Entry<String, String>> keySet = lhm.entrySet();
                for (Entry<String, String> entry : keySet) {
                    resHeadersModel.addRow(new RowResult(entry.getKey(), entry.getValue()));
                }
               
                // Fields table
                resFieldsModel.addRow(new RowResult("Type Result ", typeResult)); //$NON-NLS-1$
                //not sure needs I18N?
                resFieldsModel.addRow(new RowResult("ContentType", sampleResult.getContentType())); //$NON-NLS-1$
                resFieldsModel.addRow(new RowResult("DataEncoding", sampleResult.getDataEncodingNoDefault())); //$NON-NLS-1$
               
                // Reset search
                if (activateSearchExtension) {
                    searchTextExtension.resetTextToFind();
                }

            } else if (userObject instanceof AssertionResult) {
                assertionResult = (AssertionResult) userObject;

                // We are displaying an AssertionResult
                setupTabPaneForAssertionResult();

                StringBuilder statsBuff = new StringBuilder(100);
                statsBuff.append(JMeterUtils.getResString("view_results_assertion_error")).append(assertionResult.isError()).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_assertion_failure")).append(assertionResult.isFailure()).append(NL); //$NON-NLS-1$
                statsBuff.append(JMeterUtils.getResString("view_results_assertion_failure_message")).append(assertionResult.getFailureMessage()).append(NL); //$NON-NLS-1$
                statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null);
            }
        } catch (BadLocationException exc) {
            stats.setText(exc.getLocalizedMessage());
        }
    }
View Full Code Here

        stats = new JTextPane();
        stats.setEditable(false);
        stats.setBackground(backGround);

        // Add styles to use for different types of status messages
        StyledDocument doc = (StyledDocument) stats.getDocument();

        Style style = doc.addStyle(STYLE_REDIRECT, null);
        StyleConstants.setForeground(style, REDIRECT_COLOR);

        style = doc.addStyle(STYLE_CLIENT_ERROR, null);
        StyleConstants.setForeground(style, CLIENT_ERROR_COLOR);

        style = doc.addStyle(STYLE_SERVER_ERROR, null);
        StyleConstants.setForeground(style, SERVER_ERROR_COLOR);

        paneRaw = GuiUtils.makeScrollPane(stats);
        paneRaw.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
View Full Code Here

TOP

Related Classes of javax.swing.text.StyledDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.