Example usage for javax.swing.text SimpleAttributeSet EMPTY

List of usage examples for javax.swing.text SimpleAttributeSet EMPTY

Introduction

In this page you can find the example usage for javax.swing.text SimpleAttributeSet EMPTY.

Prototype

AttributeSet EMPTY

To view the source code for javax.swing.text SimpleAttributeSet EMPTY.

Click Source Link

Document

An empty attribute set.

Usage

From source file:me.mayo.telnetkek.MainPanel.java

private void writeToConsoleImmediately(final ConsoleMessage message, final boolean isTelnetError) {
    SwingUtilities.invokeLater(() -> {
        if (isTelnetError && chkIgnoreErrors.isSelected()) {
            return;
        }//from ww w .  j  av a2 s  . co m

        final StyledDocument styledDocument = mainOutput.getStyledDocument();

        int startLength = styledDocument.getLength();

        try {
            styledDocument.insertString(styledDocument.getLength(),
                    message.getMessage() + System.lineSeparator(),
                    StyleContext.getDefaultStyleContext().addAttribute(SimpleAttributeSet.EMPTY,
                            StyleConstants.Foreground, message.getColor()));
        } catch (BadLocationException ex) {
            throw new RuntimeException(ex);
        }

        if (MainPanel.this.chkAutoScroll.isSelected() && MainPanel.this.mainOutput.getSelectedText() == null) {
            final JScrollBar vScroll = mainOutputScoll.getVerticalScrollBar();

            if (!vScroll.getValueIsAdjusting()) {
                if (vScroll.getValue() + vScroll.getModel().getExtent() >= (vScroll.getMaximum() - 50)) {
                    MainPanel.this.mainOutput.setCaretPosition(startLength);

                    final Timer timer = new Timer(10, (ActionEvent ae) -> {
                        vScroll.setValue(vScroll.getMaximum());
                    });
                    timer.setRepeats(false);
                    timer.start();
                }
            }
        }
    });
}

From source file:com.NewJFrame.java

private void appendToPane(JTextPane tp, String msg, Color c) {
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

    //        aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
    //        aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);
    int len = tp.getDocument().getLength();
    tp.setCaretPosition(len);/*from  w w  w  .j ava2  s . c  om*/
    tp.setCharacterAttributes(aset, false);
    tp.replaceSelection(msg);

}

From source file:dataviewer.DataViewer.java

private void cb_tableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_tableActionPerformed
    try {// www. jav  a2 s  .  c  o m
        table = cb_table.getSelectedItem().toString();
        DB db = new DB("./db/" + table + ".db");
        db.open();
        String[] cols = db.get_table_columns(table);
        db.close();

        DefaultTableModel model = new DefaultTableModel();
        //model.addColumn("Column Index");
        model.addColumn("Field");
        int i = 1;

        StyleContext sc = StyleContext.getDefaultStyleContext();
        TabSet tabs = new TabSet(new TabStop[] { new TabStop(20) });
        AttributeSet paraSet = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabs);
        tp_sql.setParagraphAttributes(paraSet, false);

        StyledDocument doc = tp_sql.getStyledDocument();

        doc.remove(0, doc.getLength());

        doc.insertString(doc.getLength(), "SELECT", null);
        doc.insertString(doc.getLength(), "\n", null);

        for (int j = 1; j < cols.length; ++j) {
            String s = cols[j];
            //model.addRow(new Object[]{i++, s});
            model.addRow(new Object[] { s });
            doc.insertString(doc.getLength(), "\t", null);
            doc.insertString(doc.getLength(), s, null);
            if (j < cols.length - 1) {
                doc.insertString(doc.getLength(), ",", null);
            }
            doc.insertString(doc.getLength(), "\n", null);
        }

        doc.insertString(doc.getLength(), "FROM", null);
        doc.insertString(doc.getLength(), "\n", null);
        doc.insertString(doc.getLength(), "\t", null);
        doc.insertString(doc.getLength(), table, null);
        /*doc.insertString(doc.getLength(), "\n", null);
         doc.insertString(doc.getLength(), "WHERE", null);
         doc.insertString(doc.getLength(), "\n", null);
         doc.insertString(doc.getLength(), "\t", null);
         doc.insertString(doc.getLength(), "_N_ <= " + N, null);
         doc.insertString(doc.getLength(), ";", null);*/

        tb_columns.setModel(model);

        TableRowSorter trs = new TableRowSorter(model);
        trs.setComparator(0, new IntComparator());
        tb_columns.setRowSorter(trs);

        //highline();
    } catch (Exception e) {
        txt_count.setText(e.getMessage());
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.label.PainelLabel.java

private void aplicarRotuloActionPerformed(ActionEvent e) {
    aplicarRotulo.setEnabled(false);// w  ww  .  j  av  a  2 s.c o m
    salvaAlteracoes.setAlterado();
    // salvar.setEnabled(true);
    // btnSalvar.setEnabled(true);
    int selectedStart = 0;
    int selectedEnd = 0;
    int caret = getPosTagRepInit();
    boolean possuiId = false;
    int corretordePosicoesdoLabel = 0;
    int corretordePosicoesdoControle = 0;
    ArrayList<Integer> ordenador = new ArrayList<Integer>();
    ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>();
    conteudoParticRotulo = null;
    conteudoParticRotulo = tArParticipRotulo.getTextoEPos();
    String[] conteudo = new String[3];
    String codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
    //System.out.println(codHTML.substring((Integer) (getPosTagRepEnd() + corretordePosicoesdoControle - 1), (getPosTagRepEnd() + corretordePosicoesdoControle - 1) + 36));
    //Descobre o ultimo indice
    while (codHTML.indexOf("SIL" + inicial) != -1) {
        inicial++;
    }
    StringBuilder identificador = new StringBuilder();
    String tag = codHTML.substring(getPosTagRepInit(), getPosTagRepEnd());
    System.out.println("tag='" + tag + "'");
    int posId = tag.indexOf("id=");
    int posAspa;
    char caract = '_';
    if (posId != -1) {
        posAspa = posId + "id=".length();
        caract = tag.charAt(posAspa);
        int posFinalValId;
        if (caract == '\'') {
            posFinalValId = tag.indexOf('\'', posId + "id=".length() + 1);
        } else if (caract == '\"') {
            posFinalValId = tag.indexOf('\"', posId + "id=".length() + 1);
        } else {
            posFinalValId = tag.indexOf(' ', posId + "id=".length());
            if (posFinalValId == -1) {
                posFinalValId = tag.indexOf('>', posId + "id=".length() + 1);
            }
            posFinalValId--;

        }
        possuiId = true;
        if (caract == '\"' || caract == '\'') {
            identificador.append(tag.substring(posAspa + 1, posFinalValId));
        } else {
            identificador.append(tag.substring(posAspa, posFinalValId + 1));
        }

    } else {
        identificador.append("SIL" + inicial);
    }

    String strId = identificador.toString();
    for (String conteudoPR : conteudoParticRotulo) {
        conteudo = conteudoPR.split("@");
        ordenador.add(Integer.parseInt(conteudo[1]));
    }

    int[] ordem = new int[ordenador.size()];
    for (int i = 0; i < ordem.length; i++) {
        ordem[i] = ordenador.get(i);
    }

    Arrays.sort(ordem);

    for (int i = 0; i < ordem.length; i++) {
        for (String conteudoPR : conteudoParticRotulo) {
            conteudo = conteudoPR.split("@");

            if (Integer.parseInt(conteudo[1]) == ordem[i]) {
                conteudoParticRotuloOrdenado.add(conteudoPR);
            }

        }
    }
    for (String conteudoPR : conteudoParticRotuloOrdenado) {
        conteudo = conteudoPR.split("@");

        System.out.println("posico: " + Integer.parseInt(conteudo[1]));

    }

    for (String conteudoPR : conteudoParticRotuloOrdenado) {

        conteudo = conteudoPR.split("@");
        conteudo[0] = "<label for=\"" + strId + "\">" + conteudo[0] + "</label>";
        selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel;
        selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel;
        //so conta o que foi acrescentado
        corretordePosicoesdoLabel += ("<label for=\"" + strId + "\"></label>").length();

        if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) {
            corretordePosicoesdoControle = corretordePosicoesdoLabel;

        }
        /*
         * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){
         * //arTextPainelCorrecao.select(selectedStart+("id=x").length(),
         * selectedEnd+("id=x").length());
         * 
         * }else{ }
         */
        textAreaSourceCode.getTextPane().select(selectedStart, selectedEnd);

        arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]);

        arTextPainelCorrecao.setASet(
                arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY, SimpleAttributeSet.EMPTY));
        textAreaSourceCode.getTextPane().select(0, textAreaSourceCode.getTextPane().getText().length());
        arTextPainelCorrecao.setColorForSelectedText(new Color(255, 255, 255), new Color(0, 0, 0));
        textAreaSourceCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

    }
    if (!possuiId) {
        char c = codHTML.charAt(getPosTagRepEnd() - 2);
        if (c == '/') {
            textAreaSourceCode.getTextPane().select(getPosTagRepEnd() + corretordePosicoesdoControle - 2,
                    getPosTagRepEnd() + corretordePosicoesdoControle);
            arTextPainelCorrecao.setTextoParaSelecionado(" id=\"" + strId + "\"/>");
        } else {
            textAreaSourceCode.getTextPane().select(getPosTagRepEnd() + corretordePosicoesdoControle - 1,
                    getPosTagRepEnd() + corretordePosicoesdoControle);
            arTextPainelCorrecao.setTextoParaSelecionado(" id=\"" + strId + "\">");
        }
    }

    tArParticipRotulo.apagaTexto();
    codigo = textAreaSourceCode.getTextPane().getText();

    //G_File arq = new G_File("C:\\ buffer");
    //arq.write(textAreaSourceCode.getTextPane().getText());
    new FerramentaLabelCtrl(codigo, true);
    textAreaSourceCode.coloreSource();
    tableLinCod.delAtualLinha();
    textAreaSourceCode.getTextPane().setCaretPosition(caret);
    TxtBuffer.setContent(textAreaSourceCode.getTextPane().getText());
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.PanelDescricaoImagens.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd == "Salvar") {
        salvaAlteracoes.salvar();/*from   w ww .  j  ava2s  .c o  m*/

    } else if (cmd == "Abrir") {
        abrirArquivoLocal();
    } else if (cmd.equals("SelecionarTudo")) {
        textAreaSourceCode.getTextPane().selectAll();
        textAreaSourceCode.getTextPane().requestFocus();
    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Desfazer") {
        textAreaSourceCode.undo();
    } else if (cmd == "AumentaFonte") {
        textAreaSourceCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        textAreaSourceCode.diminuiFontSize();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Contraste") {
        textAreaSourceCode.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        ArrayList<Integer> ordenador = new ArrayList<Integer>();
        ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>();
        conteudoParticRotulo = null;
        conteudoParticRotulo = tArParticipRotulo.getTextoEPos();
        String[] conteudo = new String[3];
        String codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
        // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd()
        // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() +
        // corretordePosicoesdoControle - 1) + 36));

        while (codHTML.indexOf("SIL" + inicial) != -1) {
            inicial++;
        }

        for (String conteudoPR : conteudoParticRotulo) {
            conteudo = conteudoPR.split("@");
            ordenador.add(Integer.parseInt(conteudo[1]));
        }

        int[] ordem = new int[ordenador.size()];
        for (int i = 0; i < ordem.length; i++) {
            ordem[i] = ordenador.get(i);
        }

        Arrays.sort(ordem);

        for (int i = 0; i < ordem.length; i++) {
            for (String conteudoPR : conteudoParticRotulo) {
                conteudo = conteudoPR.split("@");

                if (Integer.parseInt(conteudo[1]) == ordem[i]) {
                    conteudoParticRotuloOrdenado.add(conteudoPR);
                }

            }
        }
        for (String conteudoPR : conteudoParticRotuloOrdenado) {
            conteudo = conteudoPR.split("@");

            // System.out.println("posico: " +
            // Integer.parseInt(conteudo[1]));

        }

        for (String conteudoPR : conteudoParticRotuloOrdenado) {

            conteudo = conteudoPR.split("@");
            conteudo[0] = "<label for=\"SIL" + inicial + "\">" + conteudo[0] + "</label>";
            selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel;
            selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel;
            // corretordePosicoesdoLabel += ("<label for=\"SIL" + inicial +
            // "\"></label>").length();

            if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) {

            }
            /*
             * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){
             * //arTextPainelCorrecao.select(selectedStart+("id=x").length(),
             * selectedEnd+("id=x").length());
             * 
             * }else{ }
             */
            // scrollPaneCorrecaoLabel.getTextPane().select(selectedStart,
            // selectedEnd);
            // arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]);
            arTextPainelCorrecao.setASet(arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY,
                    SimpleAttributeSet.EMPTY));
            textAreaSourceCode.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            textAreaSourceCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

        }

        // arTextPainelCorrecao.formataHTML();
        // tArParticipRotulo.apagaTexto();

        TabelaDescricao tcl = tableLinCod;
        int linha = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 0);
        int coluna = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 1);
        // int endTag = 0;
        int posAtual = 0;
        int posFinal = 0;
        codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // Adaptao provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

        setPosTagRepInit(posFinal);
        setPosTagRepEnd(posFinal + i + 1);

        textAreaSourceCode.goToLine(linha);
        textAreaSourceCode.getTextPane().select(getPosTagRepInit(), getPosTagRepEnd());

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd == "Salvar") {
        // salvaAlteracoes.salvar();

    } else if (cmd.equals("SelecionarTudo")) {
        boxCode.getTextPane().selectAll();
        boxCode.getTextPane().requestFocus();
    } else if (cmd == "Abrir") {
        abrirArquivoLocal();/*from w w  w .j a  va  2s .co  m*/
    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Desfazer") {
        // boxCode.undo();
        // boxCode.coloreSource();
        // reavalia(boxCode.getText());
    } else if (cmd == "AumentaFonte") {
        boxCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        boxCode.diminuiFontSize();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Contraste") {
        boxCode.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 0;
        ArrayList<Integer> ordenador = new ArrayList<Integer>();
        ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>();
        conteudoParticRotulo = null;
        conteudoParticRotulo = tArParticipRotulo.getTextoEPos();
        String[] conteudo = new String[3];
        String codHTML = boxCode.getTextPane().getText().replace("\r", "");
        // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd()
        // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() +
        // corretordePosicoesdoControle - 1) + 36));

        while (codHTML.indexOf("SIL" + inicial) != -1) {
            inicial++;
        }

        ColorModel cm = tArParticipRotulo.getColorModel();

        for (String conteudoPR : conteudoParticRotulo) {
            conteudo = conteudoPR.split("@");
            ordenador.add(Integer.parseInt(conteudo[1]));
        }

        int[] ordem = new int[ordenador.size()];
        for (int i = 0; i < ordem.length; i++) {
            ordem[i] = ordenador.get(i);
        }

        Arrays.sort(ordem);

        for (int i = 0; i < ordem.length; i++) {
            for (String conteudoPR : conteudoParticRotulo) {
                conteudo = conteudoPR.split("@");

                if (Integer.parseInt(conteudo[1]) == ordem[i]) {
                    conteudoParticRotuloOrdenado.add(conteudoPR);
                }

            }
        }
        for (String conteudoPR : conteudoParticRotuloOrdenado) {
            conteudo = conteudoPR.split("@");

            // System.out.println("posico: " +
            // Integer.parseInt(conteudo[1]));

        }

        for (String conteudoPR : conteudoParticRotuloOrdenado) {

            conteudo = conteudoPR.split("@");
            conteudo[0] = "<label for=\"SIL" + inicial + "\">" + conteudo[0] + "</label>";
            selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel;
            selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel;
            // corretordePosicoesdoLabel += ("<label for=\"SIL" + inicial +
            // "\"></label>").length();

            if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) {
                corretordePosicoesdoControle = corretordePosicoesdoLabel;

            }
            /*
             * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){
             * //arTextPainelCorrecao.select(selectedStart+("id=x").length(),
             * selectedEnd+("id=x").length());
             * 
             * }else{ }
             */
            // scrollPaneCorrecaoLabel.getTextPane().select(selectedStart,
            // selectedEnd);
            // arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]);
            arTextPainelCorrecao.setASet(arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY,
                    SimpleAttributeSet.EMPTY));
            boxCode.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            boxCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

        }

        // arTextPainelCorrecao.formataHTML();
        // tArParticipRotulo.apagaTexto();

        TabelaAnaliseGeral tcl = tableLinCod;
        int linha = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 0);
        int coluna = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 1);
        int endTag = 0;
        int posAtual = 0;
        int posFinal = 0;
        codHTML = boxCode.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // gambiarra provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

        setPosTagRepInit(posFinal);
        setPosTagRepEnd(posFinal + i + 1);

        boxCode.goToLine(linha);
        boxCode.getTextPane().select(getPosTagRepInit(), getPosTagRepEnd());

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.script.PainelScript.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();//from  ww  w.j av a  2 s  .  c  om
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    }

    else if (cmd == "Salvar") {
        salvaAlteracoes.salvar();
    } else if (cmd == "Abrir") {
        Abrir();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd.equals("SelecionarTudo")) {
        textAreaSourceCode.getTextPane().selectAll();
        textAreaSourceCode.getTextPane().requestFocus();
    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Desfazer") {
        // boxCode.undo();
        // boxCode.coloreSource();
        // reavalia(boxCode.getText());
    } else if (cmd == "AumentaFonte") {
        textAreaSourceCode.aumentaFontSize();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "DiminuiFonte") {
        textAreaSourceCode.diminuiFontSize();
    } else if (cmd == "Contraste") {
        textAreaSourceCode.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 0;
        ArrayList<Integer> ordenador = new ArrayList<Integer>();
        ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>();
        conteudoParticRotulo = null;
        conteudoParticRotulo = tArParticipRotulo.getTextoEPos();
        String[] conteudo = new String[3];
        String codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
        // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd()
        // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() +
        // corretordePosicoesdoControle - 1) + 36));

        while (codHTML.indexOf("SIL" + inicial) != -1) {
            inicial++;
        }

        ColorModel cm = tArParticipRotulo.getColorModel();

        for (String conteudoPR : conteudoParticRotulo) {
            conteudo = conteudoPR.split("@");
            ordenador.add(Integer.parseInt(conteudo[1]));
        }

        int[] ordem = new int[ordenador.size()];
        for (int i = 0; i < ordem.length; i++) {
            ordem[i] = ordenador.get(i);
        }

        Arrays.sort(ordem);

        for (int i = 0; i < ordem.length; i++) {
            for (String conteudoPR : conteudoParticRotulo) {
                conteudo = conteudoPR.split("@");

                if (Integer.parseInt(conteudo[1]) == ordem[i]) {
                    conteudoParticRotuloOrdenado.add(conteudoPR);
                }

            }
        }
        for (String conteudoPR : conteudoParticRotuloOrdenado) {
            conteudo = conteudoPR.split("@");

            // System.out.println("posico: " +
            // Integer.parseInt(conteudo[1]));

        }

        for (String conteudoPR : conteudoParticRotuloOrdenado) {

            conteudo = conteudoPR.split("@");
            conteudo[0] = "<label for=\"SIL" + inicial + "\">" + conteudo[0] + "</label>";
            selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel;
            selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel;
            // corretordePosicoesdoLabel += ("<label for=\"SIL" + inicial +
            // "\"></label>").length();

            if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) {
                corretordePosicoesdoControle = corretordePosicoesdoLabel;

            }
            /*
             * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){
             * //arTextPainelCorrecao.select(selectedStart+("id=x").length(),
             * selectedEnd+("id=x").length());
             * 
             * }else{ }
             */
            // scrollPaneCorrecaoLabel.getTextPane().select(selectedStart,
            // selectedEnd);
            // arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]);
            arTextPainelCorrecao.setASet(arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY,
                    SimpleAttributeSet.EMPTY));
            textAreaSourceCode.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            textAreaSourceCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

        }

        // arTextPainelCorrecao.formataHTML();
        // tArParticipRotulo.apagaTexto();

        TabelaDescricao tcl = tableLinCod;
        int linha = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 0);
        int coluna = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 1);
        int endTag = 0;
        int posAtual = 0;
        int posFinal = 0;
        codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // gambiarra provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

        setPosTagRepInit(posFinal);
        setPosTagRepEnd(posFinal + i + 1);

        textAreaSourceCode.goToLine(linha);
        textAreaSourceCode.getTextPane().select(getPosTagRepInit(), getPosTagRepEnd());

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.objeto.PainelObjeto.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd == "Procurar") {
        scrollPaneDescricao.buscar();/* ww  w . j  av  a2  s  .c o m*/
    } else

    if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    }

    else

    if (cmd == "Salvar") {
        salvaAlteracoes.salvar();

    } else if (cmd == "Abrir") {
        // abrirArquivo();
        Abrir();

    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd.equals("SelecionarTudo")) {
        scrollPaneDescricao.getTextPane().selectAll();
        scrollPaneDescricao.getTextPane().requestFocus();
    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Desfazer") {
        // boxCode.undo();
        // boxCode.coloreSource();
        // reavalia(boxCode.getText());
    } else if (cmd == "AumentaFonte") {
        scrollPaneDescricao.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        scrollPaneDescricao.diminuiFontSize();
    } else if (cmd == "Contraste") {
        scrollPaneDescricao.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 0;
        ArrayList<Integer> ordenador = new ArrayList<Integer>();
        ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>();
        conteudoParticRotulo = null;
        conteudoParticRotulo = tArParticipRotulo.getTextoEPos();
        String[] conteudo = new String[3];
        String codHTML = scrollPaneDescricao.getTextPane().getText().replace("\r", "");
        // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd()
        // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() +
        // corretordePosicoesdoControle - 1) + 36));

        while (codHTML.indexOf("SIL" + inicial) != -1) {
            inicial++;
        }

        ColorModel cm = tArParticipRotulo.getColorModel();

        for (String conteudoPR : conteudoParticRotulo) {
            conteudo = conteudoPR.split("@");
            ordenador.add(Integer.parseInt(conteudo[1]));
        }

        int[] ordem = new int[ordenador.size()];
        for (int i = 0; i < ordem.length; i++) {
            ordem[i] = ordenador.get(i);
        }

        Arrays.sort(ordem);

        for (int i = 0; i < ordem.length; i++) {
            for (String conteudoPR : conteudoParticRotulo) {
                conteudo = conteudoPR.split("@");

                if (Integer.parseInt(conteudo[1]) == ordem[i]) {
                    conteudoParticRotuloOrdenado.add(conteudoPR);
                }

            }
        }
        for (String conteudoPR : conteudoParticRotuloOrdenado) {
            conteudo = conteudoPR.split("@");

            // System.out.println("posico: " +
            // Integer.parseInt(conteudo[1]));

        }

        for (String conteudoPR : conteudoParticRotuloOrdenado) {

            conteudo = conteudoPR.split("@");
            conteudo[0] = "<label for=\"SIL" + inicial + "\">" + conteudo[0] + "</label>";
            selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel;
            selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel;
            // corretordePosicoesdoLabel += ("<label for=\"SIL" + inicial +
            // "\"></label>").length();

            if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) {
                corretordePosicoesdoControle = corretordePosicoesdoLabel;

            }
            /*
             * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){
             * //arTextPainelCorrecao.select(selectedStart+("id=x").length(),
             * selectedEnd+("id=x").length());
             * 
             * }else{ }
             */
            // scrollPaneCorrecaoLabel.getTextPane().select(selectedStart,
            // selectedEnd);
            // arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]);
            arTextPainelCorrecao.setASet(arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY,
                    SimpleAttributeSet.EMPTY));
            scrollPaneDescricao.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            scrollPaneDescricao.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

        }

        // arTextPainelCorrecao.formataHTML();
        // tArParticipRotulo.apagaTexto();

        TabelaDescricao tcl = tableLinCod;
        int linha = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 0);
        int coluna = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 1);
        int endTag = 0;
        int posAtual = 0;
        int posFinal = 0;
        codHTML = scrollPaneDescricao.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // gambiarra provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

        setPosTagRepInit(posFinal);
        setPosTagRepEnd(posFinal + i + 1);

        scrollPaneDescricao.goToLine(linha);
        scrollPaneDescricao.getTextPane().select(getPosTagRepInit(), getPosTagRepEnd());

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.label.PainelLabel.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd == "Salvar") {
        System.out.println("action Salvar");
        salvaAlteracoes.salvar();// www  .  j  av  a  2  s .  c om

    } else if (cmd == "Abrir") {
        // abrirArquivo();

        abrir();
    } else if (cmd.equals("SelecionarTudo")) {
        textAreaSourceCode.getTextPane().selectAll();
        textAreaSourceCode.getTextPane().requestFocus();
    } else if (cmd == "AbrirURL") {
        abreUrl();

    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Desfazer") {
        // boxCode.undo();
        // boxCode.coloreSource();
        // reavalia(boxCode.getText());
    } else if (cmd == "AumentaFonte") {
        textAreaSourceCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        textAreaSourceCode.diminuiFontSize();
    } else if (cmd == "Contraste") {
        textAreaSourceCode.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 0;
        ArrayList<Integer> ordenador = new ArrayList<Integer>();
        ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>();
        conteudoParticRotulo = null;
        conteudoParticRotulo = tArParticipRotulo.getTextoEPos();
        String[] conteudo = new String[3];
        String codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
        System.out.println(codHTML.substring((Integer) (getPosTagRepEnd() + corretordePosicoesdoControle - 1),
                (getPosTagRepEnd() + corretordePosicoesdoControle - 1) + 36));

        while (codHTML.indexOf("SIL" + inicial) != -1) {
            inicial++;
        }

        ColorModel cm = tArParticipRotulo.getColorModel();

        for (String conteudoPR : conteudoParticRotulo) {
            conteudo = conteudoPR.split("@");
            ordenador.add(Integer.parseInt(conteudo[1]));
        }

        int[] ordem = new int[ordenador.size()];
        for (int i = 0; i < ordem.length; i++) {
            ordem[i] = ordenador.get(i);
        }

        Arrays.sort(ordem);

        for (int i = 0; i < ordem.length; i++) {
            for (String conteudoPR : conteudoParticRotulo) {
                conteudo = conteudoPR.split("@");

                if (Integer.parseInt(conteudo[1]) == ordem[i]) {
                    conteudoParticRotuloOrdenado.add(conteudoPR);
                }

            }
        }
        for (String conteudoPR : conteudoParticRotuloOrdenado) {
            conteudo = conteudoPR.split("@");

            System.out.println("posico: " + Integer.parseInt(conteudo[1]));

        }

        for (String conteudoPR : conteudoParticRotuloOrdenado) {

            conteudo = conteudoPR.split("@");
            conteudo[0] = "<label for=\"SIL" + inicial + "\">" + conteudo[0] + "</label>";
            selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel;
            selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel;
            // corretordePosicoesdoLabel += ("<label for=\"SIL" + inicial +
            // "\"></label>").length();

            if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) {
                corretordePosicoesdoControle = corretordePosicoesdoLabel;

            }
            /*
             * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){
             * //arTextPainelCorrecao.select(selectedStart+("id=x").length(),
             * selectedEnd+("id=x").length());
             * 
             * }else{ }
             */
            // scrollPaneCorrecaoLabel.getTextPane().select(selectedStart,
            // selectedEnd);
            // arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]);
            arTextPainelCorrecao.setASet(arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY,
                    SimpleAttributeSet.EMPTY));
            textAreaSourceCode.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            textAreaSourceCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

        }

        // arTextPainelCorrecao.formataHTML();
        // tArParticipRotulo.apagaTexto();

        TabelaCorrecaoLabel tcl = tableLinCod;
        int linha = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 0);
        int coluna = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 1);
        int endTag = 0;
        int posAtual = 0;
        int posFinal = 0;
        codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // gambiarra provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

        setPosTagRepInit(posFinal);
        setPosTagRepEnd(posFinal + i + 1);

        textAreaSourceCode.goToLine(linha);
        textAreaSourceCode.getTextPane().select(getPosTagRepInit(), getPosTagRepEnd());

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}

From source file:org.zephyrsoft.sdb2.presenter.SongView.java

private void appendText(String string, String type) {
    try {//from   w w  w. ja va  2s  .c  o m
        int offset = document.getLength();
        // add style only if type is anything apart from NEW_LINE
        AttributeSet style = SimpleAttributeSet.EMPTY;
        if (type != null && type != SongElementEnum.NEW_LINE.name()) {
            style = document.getStyle(type);
        }
        document.insertString(offset, string, style);
    } catch (BadLocationException e) {
        throw new IllegalStateException("could not insert text into document", e);
    }
}