コード例 #1
0
ファイル: ProcessUIPanel.java プロジェクト: glandais/orbisgis
 /**
  * Add the provided text with the provided color to the GUI document
  *
  * @param text The text that will be added
  * @param color The color used to show the text
  */
 public void print(String text, Color color) {
   StyleContext sc = StyleContext.getDefaultStyleContext();
   AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color);
   int len = logPane.getDocument().getLength();
   try {
     logPane.setCaretPosition(len);
     logPane.getDocument().insertString(len, text + "\n", aset);
   } catch (BadLocationException e) {
     LoggerFactory.getLogger(ProcessUIPanel.class).error("Cannot show the log message", e);
   }
   logPane.setCaretPosition(logPane.getDocument().getLength());
 }
コード例 #2
0
  @Override
  public synchronized void run() {
    try {
      for (int i = 0; i < NUM_PIPES; i++) {
        while (Thread.currentThread() == reader[i]) {
          try {
            this.wait(100);
          } catch (InterruptedException ie) {
          }
          if (pin[i].available() != 0) {
            String input = this.readLine(pin[i]);
            appendMsg(htmlize(input));
            if (textArea.getDocument().getLength() > 0) {
              textArea.setCaretPosition(textArea.getDocument().getLength() - 1);
            }
          }
          if (quit) {
            return;
          }
        }
      }

    } catch (Exception e) {
      Debug.error(me + "Console reports an internal error:\n%s", e.getMessage());
    }
  }
コード例 #3
0
ファイル: HtmlPanel.java プロジェクト: marayl/doogal
  private final void find(Pattern pattern) {
    final WriteOnce<Integer> once = new WriteOnce<Integer>();
    final Highlighter highlighter = textPane.getHighlighter();
    highlighter.removeAllHighlights();

    int matches = 0;

    final HTMLDocument doc = (HTMLDocument) textPane.getDocument();
    for (final HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.CONTENT);
        it.isValid();
        it.next())
      try {
        final String fragment =
            doc.getText(it.getStartOffset(), it.getEndOffset() - it.getStartOffset());
        final Matcher matcher = pattern.matcher(fragment);
        while (matcher.find()) {
          highlighter.addHighlight(
              it.getStartOffset() + matcher.start(),
              it.getStartOffset() + matcher.end(),
              HIGHLIGHTER);
          once.set(it.getStartOffset());
          ++matches;
        }
      } catch (final BadLocationException ex) {
      }
    if (!once.isEmpty()) textPane.setCaretPosition(once.get());
    this.matches.setText(String.format("%d matches", matches));
  }
コード例 #4
0
  public void toScreen(String s, Class module, String TYPE) {
    Color c = Color.BLACK;
    if (TYPE != null) {
      if (TYPE.contains("ERROR")) c = Color.RED;
      if (TYPE.contains("WARNING")) c = new Color(255, 106, 0);
      if (TYPE.contains("DEBUG")) c = Color.BLUE;
      if (module.toString().equalsIgnoreCase("Exception")) c = Color.RED;
    }
    StyleContext sc = StyleContext.getDefaultStyleContext();
    javax.swing.text.AttributeSet aset =
        sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
    int len = SCREEN.getDocument().getLength(); // same value as
    SCREEN.setCaretPosition(len); // place caret at the end (with no selection)
    SCREEN.setCharacterAttributes(aset, false);
    SCREEN.replaceSelection(
        "["
            + getData()
            + " - "
            + module.getSimpleName()
            + " - "
            + TYPE
            + "] "
            + s
            + "\n"); // there is no selection, so inserts at caret
    SCREEN.setFont(new Font("Monospaced", Font.PLAIN, 14));

    aggiungiRiga(s, module, TYPE);
  }
コード例 #5
0
ファイル: DecisionAnalyzer.java プロジェクト: CaoAo/BeehiveZ
  /**
   * Creates an evaluation overview of the built classifier.
   *
   * @return the panel to be displayed as result evaluation view for the current decision point
   */
  protected JPanel createEvaluationVisualization(Instances data) {
    // build text field to display evaluation statistics
    JTextPane statistic = new JTextPane();

    try {
      // build evaluation statistics
      Evaluation evaluation = new Evaluation(data);
      evaluation.evaluateModel(myClassifier, data);
      statistic.setText(
          evaluation.toSummaryString()
              + "\n\n"
              + evaluation.toClassDetailsString()
              + "\n\n"
              + evaluation.toMatrixString());

    } catch (Exception ex) {
      ex.printStackTrace();
      return createMessagePanel("Error while creating the decision tree evaluation view");
    }

    statistic.setFont(new Font("Courier", Font.PLAIN, 14));
    statistic.setEditable(false);
    statistic.setCaretPosition(0);

    JPanel resultViewPanel = new JPanel();
    resultViewPanel.setLayout(new BoxLayout(resultViewPanel, BoxLayout.PAGE_AXIS));
    resultViewPanel.add(new JScrollPane(statistic));

    return resultViewPanel;
  }
コード例 #6
0
  public void toChatScreen(String toScreen, boolean selfSeen)
      throws IOException, BadLocationException {
    // Timestamp ts = new Timestamp();
    String toScreenFinal = "";
    Date now = Calendar.getInstance().getTime();
    SimpleDateFormat format = new SimpleDateFormat("hh:mm");
    String ts = format.format(now);

    // chatScreen.append(ts + " " + toScreen + "\n");
    toScreenFinal = "<font color=gray>" + ts + "</font> ";
    if (selfSeen) toScreenFinal = toScreenFinal + "<font color=red>" + toScreen + "</font>";
    else toScreenFinal = toScreenFinal + toScreen;

    // chatter.addTo(toScreen);

    // if(standardWindow) {
    //    chatScreen.setCaretPosition(chatScreen.getDocument().getLength());
    // }
    // else {
    JScrollBar vBar = scrollChat.getVerticalScrollBar();
    int vSize = vBar.getVisibleAmount();
    int maxVBar = vBar.getMaximum();
    int currVBar = vBar.getValue() + vSize;
    kit.insertHTML(doc, doc.getLength(), toScreenFinal, 0, 0, null);
    if (maxVBar == currVBar) {
      chatScreen.setCaretPosition(chatScreen.getDocument().getLength());
    }

    // }

    // kit.insertHTML(doc, doc.getLength(), toScreenFinal, 0, 0, null);

  }
コード例 #7
0
ファイル: TabHelper.java プロジェクト: javalovercn/homecenter
  public static boolean pushTabOrEnterKey() {
    if (currentTabBlock != null) {
      if (parameterIdx == currentTabBlock.parameterBeginOffsetIdx.length - 1) {
        // 最后一个参数
        final TabBlock popBlock = (TabBlock) tabBlockStack.pop();
        if (popBlock != null) {
          currentTabBlock = popBlock;
          parameterIdx = currentTabBlock.lastParameterIdxBeforeStack;
          currentTabBlock.parameterEndOffsetIdx[parameterIdx] += inputShiftOffset;
          inputShiftOffset = 0;
          pushTabOrEnterKey();
          return true;
        }
        calculateIdx(); // 重新更新currFocusHighlightEndIdx标位
        clearHighlight();

        // 跳到方法尾
        currentTabBlock = null;
        scriptPanel.setCaretPosition(currFocusHighlightEndIdx + 1); // +1=)
        return true;
      } else {
        parameterIdx++;
        focusParameter();
        return true;
      }
    }
    return false;
  }
コード例 #8
0
 void editorPane_keyPressed(KeyEvent e) {
   StyledDocument doc = editorPane.getStyledDocument();
   int pos = editorPane.getCaretPosition();
   int code = e.getKeyCode();
   Element el;
   switch (code) {
     case KeyEvent.VK_BACK_SPACE:
     case KeyEvent.VK_DELETE:
     case KeyEvent.VK_LEFT:
     case KeyEvent.VK_KP_LEFT:
       if (pos == 0) return;
       // we want to get the element to the left of position.
       el = doc.getCharacterElement(pos - 1);
       break;
     case KeyEvent.VK_RIGHT:
     case KeyEvent.VK_KP_RIGHT:
       // we want to get the element to the right of position.
       el = doc.getCharacterElement(pos + 1);
       break;
     default:
       return; // bail we don't handle it.
   }
   AttributeSet attr = el.getAttributes();
   String el_name = (String) attr.getAttribute(StyleConstants.NameAttribute);
   int el_range = el.getEndOffset() - el.getStartOffset() - 1;
   if (el_name.startsWith("Parameter") && StyleConstants.getComponent(attr) != null) {
     try {
       switch (code) {
         case KeyEvent.VK_BACK_SPACE:
         case KeyEvent.VK_DELETE:
           doc.remove(el.getStartOffset(), el_range);
           break;
         case KeyEvent.VK_LEFT:
         case KeyEvent.VK_KP_LEFT:
           editorPane.setCaretPosition(pos - el_range);
           break;
         case KeyEvent.VK_RIGHT:
         case KeyEvent.VK_KP_RIGHT:
           editorPane.setCaretPosition(pos + (el_range));
           break;
       }
     } catch (BadLocationException ex) {
     }
   }
 }
コード例 #9
0
ファイル: ChatPanel.java プロジェクト: Cosmack/HexScape
 public void addPlayerAction(Player player, String line) {
   try {
     StyleConstants.setForeground(actionStyle, player.getColor().getColor());
     text.insertString(text.getEndPosition().getOffset(), "* " + line + " *\n", actionStyle);
     // The pane auto-scrolls with each new response added
     textPane.setCaretPosition(text.getEndPosition().getOffset() - 1);
   } catch (BadLocationException e) {
     e.printStackTrace();
   }
 }
コード例 #10
0
ファイル: GUI.java プロジェクト: unsingefou/CodeSample
  public void appendToPane(String msg, Color c) {
    if (inputText.isEnabled()) {
      StyleContext sc = StyleContext.getDefaultStyleContext();
      AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

      textArea.setCharacterAttributes(aset, false);
      textArea.replaceSelection(msg);
      textArea.setCaretPosition(textArea.getDocument().getLength());
    }
  }
コード例 #11
0
 /*
  * append(String s, Color color){...}
  * This method is the same as append(String s) except
  * that this method also changes the color of the
  * indicated text instead of defaulting to white.
  */
 public static void append(String s, Color color) {
   style = tPane.addStyle("Styles", null);
   StyleConstants.setForeground(style, color);
   try {
     doc.insertString(doc.getLength(), s, style);
   } catch (BadLocationException ex) {
     System.out.println("BadLocationException ex caught.");
   }
   tPane.setCaretPosition(tPane.getDocument().getLength());
 }
コード例 #12
0
ファイル: ChatPanel.java プロジェクト: Cosmack/HexScape
 public void addMessage(String user, Color color, String line) {
   try {
     StyleConstants.setForeground(userNameStyle, color);
     text.insertString(text.getEndPosition().getOffset(), user + " : ", userNameStyle);
     text.insertString(text.getEndPosition().getOffset(), line + "\n", textStyle);
     // The pane auto-scrolls with each new response added
     textPane.setCaretPosition(text.getEndPosition().getOffset() - 1);
   } catch (BadLocationException e) {
     e.printStackTrace();
   }
 }
コード例 #13
0
ファイル: MainWindow.java プロジェクト: pavs/ripme
  private void appendLog(final String text, final Color color) {
    SimpleAttributeSet sas = new SimpleAttributeSet();
    StyleConstants.setForeground(sas, color);
    StyledDocument sd = logText.getStyledDocument();
    try {
      sd.insertString(sd.getLength(), text + "\n", sas);
    } catch (BadLocationException e) {
    }

    logText.setCaretPosition(sd.getLength());
  }
コード例 #14
0
ファイル: Main.java プロジェクト: davidsjoo/chat_client
  public static 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);
    tp.setCharacterAttributes(aset, false);
    tp.replaceSelection(msg);
  }
コード例 #15
0
  private void displayMessage(String text, AttributeSet as) {
    try {
      if (!text.endsWith("\n")) {
        text += "\n";
      }
      jTextPaneDisplayMessages
          .getDocument()
          .insertString(jTextPaneDisplayMessages.getDocument().getLength(), text, as);

      jTextPaneDisplayMessages.setCaretPosition(jTextPaneDisplayMessages.getDocument().getLength());
    } catch (BadLocationException ex) {
    }
  }
コード例 #16
0
  void updateGui() {
    final Font sysFont = pluginAuthorLabel.getFont();
    final Image img = plugin.getImage();
    final String description = plugin.getDescription();
    final String changesLog = plugin.getChangeLog();
    final String author = plugin.getAuthor();
    final String email = plugin.getEmail();
    final String web = plugin.getWeb();

    if (img == null) pluginImage.setImage(PluginDescriptor.DEFAULT_IMAGE);
    else pluginImage.setImage(img);

    if (StringUtil.isEmpty(description)) pluginDescriptionText.setText("No description");
    else {
      if (StringUtil.containHtmlCR(description))
        pluginDescriptionText.setText(StringUtil.removeCR(description));
      else pluginDescriptionText.setText(StringUtil.toHtmlCR(description));

      pluginDescriptionText.setCaretPosition(0);
    }

    ComponentUtil.setJTextPaneFont(pluginDescriptionText, sysFont, Color.black);

    if (StringUtil.isEmpty(changesLog)) pluginChangeLogText.setText("---");
    else {
      pluginChangeLogText.setText(StringUtil.toHtmlCR(changesLog));
      pluginChangeLogText.setCaretPosition(0);
    }
    ComponentUtil.setJTextPaneFont(
        pluginChangeLogText, new Font("courier", Font.PLAIN, 11), Color.black);
    if (StringUtil.isEmpty(author)) pluginAuthorLabel.setText("---");
    else pluginAuthorLabel.setText(author);
    if (StringUtil.isEmpty(email)) pluginEmailLabel.setText("---");
    else pluginEmailLabel.setText(email);
    if (StringUtil.isEmpty(web)) pluginWebsiteLabel.setText("---");
    else pluginWebsiteLabel.setText(web);

    pack();
  }
コード例 #17
0
  public void highlightSelectedPart(DataPartNode node) {
    Style style = _hexStyledDoc.getStyle("selected");

    try {
      String text = _hexStyledDoc.getText(node.getOffset(), node.getLength());
      // _hexStyledDoc.remove(node.getOffset(), node.getLength());
      // _hexStyledDoc.insertString(node.getOffset(), text, style);
      _hexStyledDoc.replace(node.getOffset(), node.getLength(), text, style);
      _hexDumpArea.setCaretPosition(node.getOffset());
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
  }
コード例 #18
0
ファイル: EditorWindow.java プロジェクト: Janl1/RedJ
 public void gotoError(int pos) {
   errorPane.requestFocus();
   errorPane.grabFocus();
   errorPane.requestFocusInWindow();
   errorPane.transferFocus();
   errorPane.setCaretColor(Color.RED);
   errorPane.setCaretPosition(pos);
   if (errorPane.hasFocus()) {
     System.out.println("Has Focus!");
   } else {
     System.out.println("Has no Focus!");
   }
 }
  /** Create the dialog. */
  public ModalMethodDescription(JFrame frame, String mensaje) {

    super(frame, true);

    setTitle("Descripci\u00F3n del m\u00E9todo");
    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(
                ModalMethodDescription.class.getResource(
                    "/icons/imagen de respuessta transitoria.jpg")));
    setResizable(false);
    setBounds(100, 100, 600, 500);
    setMinimumSize(new Dimension(600, 500));
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(null);

    JLabel label = new JLabel();
    label.setIcon(
        new ImageIcon(
            ModalMethodDescription.class.getResource(
                "/javax/swing/plaf/metal/icons/ocean/info.png")));
    label.setBounds(10, 10, 32, 43);
    contentPanel.add(label);

    JTextPane textPane = new JTextPane();
    textPane.setText(mensaje);
    JScrollPane scrollPane = new JScrollPane(textPane);
    textPane.setBounds(40, 18, 550, 400);
    scrollPane.setBounds(40, 18, 530, 400);
    textPane.setEditable(false);
    textPane.setFont(new Font("Tahoma", Font.PLAIN, 13));
    textPane.setBackground(SystemColor.control);
    // textPane.setSize(textPane.getPreferredSize());
    contentPanel.add(scrollPane);
    textPane.setCaretPosition(0);

    JButton btnAceptar = new JButton("Aceptar");
    btnAceptar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    btnAceptar.setBounds(250, 420, 100, 40);
    contentPanel.add(btnAceptar);
  }
コード例 #20
0
ファイル: Compiler.java プロジェクト: gorik07/SmallIDE
 private void appendText(String s, Color c) {
   // System.out.println(s);
   StyledDocument doc = console.getStyledDocument();
   SimpleAttributeSet col = new SimpleAttributeSet();
   StyleConstants.setForeground(col, c);
   synchronized (doc) {
     try {
       doc.removeDocumentListener(dl);
       doc.insertString(doc.getLength(), s, col);
       doc.addDocumentListener(dl);
     } catch (BadLocationException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   console.setCaretPosition(doc.getLength());
   console.repaint();
 }
コード例 #21
0
ファイル: ChatPanel.java プロジェクト: Cosmack/HexScape
 public void addDiceRoll(Player player, DiceType type, List<DiceFace> result) {
   try {
     StyleConstants.setForeground(userNameStyle, player.getColor().getColor());
     String line = player.getName() + " rolled " + result.size() + " " + type.getName() + " :\n";
     text.insertString(text.getEndPosition().getOffset(), line, userNameStyle);
     for (DiceFace face : result) {
       ImageIcon icon = new ImageIcon(face.getImage().getAbsolutePath());
       StyleConstants.setIcon(iconStyle, icon);
       text.insertString(text.getEndPosition().getOffset(), " ", iconStyle);
       text.insertString(text.getEndPosition().getOffset(), " ", textStyle);
     }
     text.insertString(text.getEndPosition().getOffset(), "\n", userNameStyle);
     // The pane auto-scrolls with each new response added
     textPane.setCaretPosition(text.getEndPosition().getOffset() - 1);
   } catch (BadLocationException e) {
     e.printStackTrace();
   }
 }
コード例 #22
0
ファイル: CaptureReplay.java プロジェクト: easilyBaffled/435
  // Update the box that shows current actions.
  public void updateGUI(String message) {
    StyledDocument text = updateBox.getStyledDocument();
    SimpleAttributeSet currentWords = new SimpleAttributeSet();
    StyleConstants.setBold(currentWords, true);
    SimpleAttributeSet pastWords = new SimpleAttributeSet();
    StyleConstants.setBold(pastWords, false);

    try {
      text.setCharacterAttributes(0, text.getLength(), pastWords, true);
      text.insertString(0, message + "\n", currentWords);
    } catch (BadLocationException e) {
      // TODO Auto-generated catch block
      System.err.println("Bad location exception while styling updateBox.");
      e.printStackTrace();
    }

    updateBox.setCaretPosition(0);
  }
コード例 #23
0
ファイル: TabHelper.java プロジェクト: javalovercn/homecenter
  private static void focusParameter() {
    calculateIdx();

    clearHighlight();

    try {
      currFocusHighlight =
          scriptPanel
              .getHighlighter()
              .addHighlight(currFocusHighlightStartIdx, currFocusHighlightEndIdx, CODE_LIGHTER);
    } catch (final BadLocationException e) {
      ExceptionReporter.printStackTrace(e);
    }

    scriptPanel.setSelectionStart(currFocusHighlightStartIdx);
    scriptPanel.setSelectionEnd(currFocusHighlightEndIdx);
    scriptPanel.setCaretPosition(currFocusHighlightEndIdx);
    isFocusFullParameter = true;
  }
コード例 #24
0
  /**
   * Log a message.
   *
   * @param category The logger category.
   * @param source The logging source.
   * @param message The log message.
   * @param level The logging level.
   */
  public void log(String category, String source, String message, int level) {
    if (dialog == null) {
      createDialog();
    }

    messages.setCaretPosition(messages.getDocument().getLength());

    currentTime.setTime(System.currentTimeMillis());
    messages.replaceSelection(
        ""
            + timeFormat.format(currentTime)
            + " "
            + Log.logLevelName(level)
            + " ["
            + category
            + "] ["
            + source
            + "] "
            + message
            + "\n");
  }
コード例 #25
0
ファイル: BumpServer.java プロジェクト: vistuo/Bump
  // Mise à jour de l'affichage des rooms
  void updateCanaux() {
    boolean connected = !B_ToggleConnect.getText().equals("Connexion");
    TA_ListRooms.setText("");

    // Les rooms ne sont affichées que si le serveur est connecté
    if (connected) {
      for (int i = 0; i < canalId.length; i++) {
        if (canalId[i] != 0) {
          try {
            SD_ListRoomsDoc.insertString(
                SD_ListRoomsDoc.getLength(), String.format("%02d ", i), SAS_error);
            SD_ListRoomsDoc.insertString(SD_ListRoomsDoc.getLength(), canaux[i] + "\n", null);
          } catch (Exception ex) {
          }
        }
      }
    }

    // On descend le scroll à la fin
    TA_ListRooms.setCaretPosition(TA_ListRooms.getDocument().getLength());
  }
コード例 #26
0
ファイル: LogBook.java プロジェクト: NTNU-MCS/neptus
  private synchronized void writeMessageText(String message) {
    SimpleAttributeSet attrTS = new SimpleAttributeSet();
    attrTS.addAttribute(ColorConstants.Foreground, Color.DARK_GRAY);
    attrTS.addAttribute(StyleConstants.Bold, true);
    logMsg.setValue("source", "ccu");
    logMsg.setValue("destination", "ccu");

    Document doc = msgTextArea.getDocument();
    try {
      SimpleAttributeSet attr = new SimpleAttributeSet();
      attr.addAttribute(ColorConstants.Foreground, Color.blue);
      doc.insertString(doc.getLength(), "[" + getTimeStamp() + "]: ", attrTS);

      attr = new SimpleAttributeSet();
      attr.addAttribute(ColorConstants.Foreground, Color.black);
      doc.insertString(doc.getLength(), message + "\n", attr);

      msgTextArea.setCaretPosition(doc.getLength());
    } catch (Exception e) {
    }
  }
コード例 #27
0
  private synchronized void append(LogRecord record) {
    Document doc = textArea.getStyledDocument();
    String formatted = formatter.format(record);

    if (record.getLevel().intValue() >= Level.SEVERE.intValue()) {
      StyleConstants.setForeground(attributeSet, COLOR_ERROR);
      StyleConstants.setBold(attributeSet, true);
    } else if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
      StyleConstants.setForeground(attributeSet, COLOR_WARNING);
      StyleConstants.setBold(attributeSet, true);
    } else if (record.getLevel().intValue() >= Level.INFO.intValue()) {
      StyleConstants.setForeground(attributeSet, COLOR_INFO);
      StyleConstants.setBold(attributeSet, false);
    } else {
      StyleConstants.setForeground(attributeSet, COLOR_DEFAULT);
      StyleConstants.setBold(attributeSet, false);
    }

    try {
      doc.insertString(doc.getLength(), formatted, attributeSet);
    } catch (BadLocationException e) {
      // cannot happen
      // rather dump to stderr than logging and having this method called back
      e.printStackTrace();
    }

    if (maxRows >= 0) {
      int removeLength = 0;
      while (lineLengths.size() > maxRows) {
        removeLength += lineLengths.removeFirst();
      }
      try {
        doc.remove(0, removeLength);
      } catch (BadLocationException e) {
        SwingTools.showSimpleErrorMessage("error_during_logging", e);
      }
    }
    textArea.setCaretPosition(textArea.getDocument().getLength());
  }
コード例 #28
0
ファイル: DecompileForm.java プロジェクト: albfan/jclazz
  private void decompile(Map params) {
    try {
      ClazzSourceView csv = ClazzSourceViewFactory.getClazzSourceView(clazz);
      csv.setDecompileParameters(params);
      source = csv.getSource();

      String sourceText = source;

      sourceText = sourceText.replaceAll(" ", "&nbsp;");
      sourceText = sourceText.replaceAll("<", "&lt;");
      sourceText = sourceText.replaceAll(">", "&gt;");
      sourceText = sourceText.replaceAll("\n", "<BR>");
      sourcePane.setText(sourceText);
      sourcePane.setCaretPosition(0);
    } catch (Throwable ex) {
      if (Utils.hasDebug()) {
        ex.printStackTrace();
      }
      sourcePane.setText("Exception occured while decompiling");

      String link = "http://sourceforge.net/tracker/?group_id=226227&atid=1066690";
      String exception = unpackException(ex);

      JTextPane text = new JTextPane();
      text.setContentType("text/html");
      text.setText(
          "<html>Error occured while decompiling!<BR>Please submit bug at <b>"
              + link
              + "</b><BR>"
              + exception
              + "</html>");
      text.setEditable(false);
      text.setBackground(this.getBackground());

      JOptionPane.showMessageDialog(this, text, "Error", JOptionPane.ERROR_MESSAGE);

      throw new IllegalArgumentException("Error decompiling");
    }
  }
コード例 #29
0
ファイル: PluginShell.java プロジェクト: JimmyFarcy/orbisgis
  private void executeCommand(String command) {
    // Get shell service.
    ServiceReference ref = hostBundle.getServiceReference(SHELL_SERVICE_REFERENCE);
    if (ref == null) {
      LOGGER.error(I18N.tr("No shell service is available."));
      return;
    }
    ShellService shell = (ShellService) hostBundle.getService(ref);
    try {
      // Print the command line in the output window.
      try {
        outputField
            .getDocument()
            .insertString(outputField.getDocument().getLength(), "osgi> " + command + "\n", null);
      } catch (BadLocationException ex) {
        LOGGER.debug(ex.getLocalizedMessage(), ex);
        // ignore
      }

      try {
        shell.executeCommand(command, new PrintStream(info), new PrintStream(error));
      } catch (Exception ex) {
        LOGGER.error(ex.getLocalizedMessage(), ex);
      } finally {
        try {
          // Send messages to the window
          info.flush();
          error.flush();
          outputField.setCaretPosition(outputField.getDocument().getLength());
        } catch (IOException ex) {
          LOGGER.error(ex.getLocalizedMessage(), ex);
        }
      }
    } finally {
      hostBundle.ungetService(ref);
    }
  }
コード例 #30
0
ファイル: ProcessUIPanel.java プロジェクト: glandais/orbisgis
  /**
   * Build the UI of the given process according to the given data.
   *
   * @param processExecutionData Process data.
   * @return The UI for the configuration of the process.
   */
  public JComponent buildUIExec(ProcessExecutionData processExecutionData) {
    JPanel panel = new JPanel(new MigLayout("fill"));

    JPanel executorPanel = new JPanel(new MigLayout());
    executorPanel.setBorder(BorderFactory.createTitledBorder("Executor :"));
    executorPanel.add(new JLabel("localhost"));

    JPanel statusPanel = new JPanel(new MigLayout());
    statusPanel.setBorder(BorderFactory.createTitledBorder("Status :"));
    stateLabel = new JLabel(processExecutionData.getState().getValue());
    statusPanel.add(stateLabel);

    JPanel resultPanel = new JPanel(new MigLayout());
    resultPanel.setBorder(BorderFactory.createTitledBorder("Result :"));
    for (Output o : processExecutionData.getProcess().getOutput()) {
      JLabel title = new JLabel(o.getTitle() + " : ");
      JLabel result = new JLabel();
      result.putClientProperty("URI", o.getIdentifier());
      outputJLabelList.add(result);
      resultPanel.add(title);
      resultPanel.add(result, "wrap");
    }

    JPanel logPanel = new JPanel(new BorderLayout());
    logPanel.setBorder(BorderFactory.createTitledBorder("Log :"));
    logPane = new JTextPane();
    logPane.setCaretPosition(0);
    JScrollPane scrollPane = new JScrollPane(logPane);
    logPanel.add(scrollPane, BorderLayout.CENTER);

    panel.add(executorPanel, "growx, wrap");
    panel.add(statusPanel, "growx, wrap");
    panel.add(resultPanel, "growx, wrap");
    panel.add(logPanel, "growx, growy, wrap");

    return panel;
  }