⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logbrokermonitor.java

📁 apache的log4j源码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            updateStatusLabel();          }        }    );    return editRestoreAllNDCMI;  }  protected JToolBar createToolBar() {    JToolBar tb = new JToolBar();    tb.putClientProperty("JToolBar.isRollover", Boolean.TRUE);    JComboBox fontCombo = new JComboBox();    JComboBox fontSizeCombo = new JComboBox();    _fontSizeCombo = fontSizeCombo;    ClassLoader cl = this.getClass().getClassLoader();    if(cl == null) {        cl = ClassLoader.getSystemClassLoader();    }    URL newIconURL = cl.getResource("org/apache/log4j/lf5/viewer/" +        "images/channelexplorer_new.gif");    ImageIcon newIcon = null;    if (newIconURL != null) {      newIcon = new ImageIcon(newIconURL);    }    JButton newButton = new JButton("Clear Log Table");    if (newIcon != null) {      newButton.setIcon(newIcon);    }    newButton.setToolTipText("Clear Log Table.");    //newButton.setBorder(BorderFactory.createEtchedBorder());    newButton.addActionListener(        new ActionListener() {          public void actionPerformed(ActionEvent e) {            _table.clearLogRecords();            _categoryExplorerTree.getExplorerModel().resetAllNodeCounts();            updateStatusLabel();            clearDetailTextArea();            LogRecord.resetSequenceNumber();          }        }    );    Toolkit tk = Toolkit.getDefaultToolkit();    // This will actually grab all the fonts    String[] fonts;    if (_loadSystemFonts) {      fonts = GraphicsEnvironment.          getLocalGraphicsEnvironment().getAvailableFontFamilyNames();    } else {      fonts = tk.getFontList();    }    for (int j = 0; j < fonts.length; j++) {      fontCombo.addItem(fonts[j]);    }    fontCombo.setSelectedItem(_fontName);    fontCombo.addActionListener(        new ActionListener() {          public void actionPerformed(ActionEvent e) {            JComboBox box = (JComboBox) e.getSource();            String font = (String) box.getSelectedItem();            _table.setFont(new Font(font, Font.PLAIN, _fontSize));            _fontName = font;          }        }    );    fontSizeCombo.addItem("8");    fontSizeCombo.addItem("9");    fontSizeCombo.addItem("10");    fontSizeCombo.addItem("12");    fontSizeCombo.addItem("14");    fontSizeCombo.addItem("16");    fontSizeCombo.addItem("18");    fontSizeCombo.addItem("24");    fontSizeCombo.setSelectedItem(String.valueOf(_fontSize));    fontSizeCombo.addActionListener(        new ActionListener() {          public void actionPerformed(ActionEvent e) {            JComboBox box = (JComboBox) e.getSource();            String size = (String) box.getSelectedItem();            int s = Integer.valueOf(size).intValue();            setFontSizeSilently(s);            refreshDetailTextArea();            _fontSize = s;          }        }    );    tb.add(new JLabel(" Font: "));    tb.add(fontCombo);    tb.add(fontSizeCombo);    tb.addSeparator();    tb.addSeparator();    tb.add(newButton);    newButton.setAlignmentY(0.5f);    newButton.setAlignmentX(0.5f);    fontCombo.setMaximumSize(fontCombo.getPreferredSize());    fontSizeCombo.setMaximumSize(        fontSizeCombo.getPreferredSize());    return (tb);  }//    protected void setView(String viewString, LogTable table) {//        if (STANDARD_VIEW.equals(viewString)) {//            table.setStandardView();//        } else if (COMPACT_VIEW.equals(viewString)) {//            table.setCompactView();//        } else if (DETAILED_VIEW.equals(viewString)) {//            table.setDetailedView();//        } else {//            String message = viewString + "does not match a supported view.";//            throw new IllegalArgumentException(message);//        }//        _currentView = viewString;//    }  protected void setView(String viewString, LogTable table) {    if (DETAILED_VIEW.equals(viewString)) {      table.setDetailedView();    } else {      String message = viewString + "does not match a supported view.";      throw new IllegalArgumentException(message);    }    _currentView = viewString;  }  protected JComboBox createLogLevelCombo() {    JComboBox result = new JComboBox();    Iterator levels = getLogLevels();    while (levels.hasNext()) {      result.addItem(levels.next());    }    result.setSelectedItem(_leastSevereDisplayedLogLevel);    result.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        JComboBox box = (JComboBox) e.getSource();        LogLevel level = (LogLevel) box.getSelectedItem();        setLeastSevereDisplayedLogLevel(level);      }    });    result.setMaximumSize(result.getPreferredSize());    return result;  }  protected void setLeastSevereDisplayedLogLevel(LogLevel level) {    if (level == null || _leastSevereDisplayedLogLevel == level) {      return; // nothing to do    }    _leastSevereDisplayedLogLevel = level;    _table.getFilteredLogTableModel().refresh();    updateStatusLabel();  }  /**   * Ensures that the Table's ScrollPane Viewport will "track" with updates   * to the Table.  When the vertical scroll bar is at its bottom anchor   * and tracking is enabled then viewport will stay at the bottom most   * point of the component.  The purpose of this feature is to allow   * a developer to watch the table as messages arrive and not have to   * scroll after each new message arrives.  When the vertical scroll bar   * is at any other location, then no tracking will happen.   * @deprecated tracking is now done automatically.   */  protected void trackTableScrollPane() {    // do nothing  }  protected void centerFrame(JFrame frame) {    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();    Dimension comp = frame.getSize();    frame.setLocation(((screen.width - comp.width) / 2),        ((screen.height - comp.height) / 2));  }  /**   * Uses a JFileChooser to select a file to opened with the   * LF5 GUI.   */  protected void requestOpen() {    JFileChooser chooser;    if (_fileLocation == null) {      chooser = new JFileChooser();    } else {      chooser = new JFileChooser(_fileLocation);    }    int returnVal = chooser.showOpenDialog(_logMonitorFrame);    if (returnVal == JFileChooser.APPROVE_OPTION) {      File f = chooser.getSelectedFile();      if (loadLogFile(f)) {        _fileLocation = chooser.getSelectedFile();        _mruFileManager.set(f);        updateMRUList();      }    }  }  /**   * Uses a Dialog box to accept a URL to a file to be opened   * with the LF5 GUI.   */  protected void requestOpenURL() {    LogFactor5InputDialog inputDialog = new LogFactor5InputDialog(        getBaseFrame(), "Open URL", "URL:");    String temp = inputDialog.getText();    if (temp != null) {      if (temp.indexOf("://") == -1) {        temp = "http://" + temp;      }      try {        URL url = new URL(temp);        if (loadLogFile(url)) {          _mruFileManager.set(url);          updateMRUList();        }      } catch (MalformedURLException e) {        LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(            getBaseFrame(), "Error reading URL.");      }    }  }  /**   * Removes old file list and creates a new file list   * with the updated MRU list.   */  protected void updateMRUList() {    JMenu menu = _logMonitorFrame.getJMenuBar().getMenu(0);    menu.removeAll();    menu.add(createOpenMI());    menu.add(createOpenURLMI());    menu.addSeparator();    menu.add(createCloseMI());    createMRUFileListMI(menu);    menu.addSeparator();    menu.add(createExitMI());  }  protected void requestClose() {    setCallSystemExitOnClose(false);    closeAfterConfirm();  }  /**   * Opens a file in the MRU list.   */  protected void requestOpenMRU(ActionEvent e) {    String file = e.getActionCommand();    StringTokenizer st = new StringTokenizer(file);    String num = st.nextToken().trim();    file = st.nextToken("\n");    try {      int index = Integer.parseInt(num) - 1;      InputStream in = _mruFileManager.getInputStream(index);      LogFileParser lfp = new LogFileParser(in);      lfp.parse(this);      _mruFileManager.moveToTop(index);      updateMRUList();    } catch (Exception me) {      LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(          getBaseFrame(), "Unable to load file " + file);    }  }  protected void requestExit() {    _mruFileManager.save();    setCallSystemExitOnClose(true);    closeAfterConfirm();  }  protected void closeAfterConfirm() {    StringBuffer message = new StringBuffer();    if (_callSystemExitOnClose == false) {      message.append("Are you sure you want to close the logging ");      message.append("console?\n");      message.append("(Note: This will not shut down the Virtual Machine,\n");      message.append("or the Swing event thread.)");    } else {      message.append("Are you sure you want to exit?\n");      message.append("This will shut down the Virtual Machine.\n");    }    String title =        "Are you sure you want to dispose of the Logging Console?";    if (_callSystemExitOnClose == true) {      title = "Are you sure you want to exit?";    }    int value = JOptionPane.showConfirmDialog(        _logMonitorFrame,        message.toString(),        title,        JOptionPane.OK_CANCEL_OPTION,        JOptionPane.QUESTION_MESSAGE,        null    );    if (value == JOptionPane.OK_OPTION) {      dispose();    }  }  protected Iterator getLogLevels() {    return _levels.iterator();  }  protected Iterator getLogTableColumns() {    return _columns.iterator();  }  /**   * Loads and parses a log file.   */  protected boolean loadLogFile(File file) {    boolean ok = false;    try {      LogFileParser lfp = new LogFileParser(file);      lfp.parse(this);      ok = true;    } catch (IOException e) {      LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(          getBaseFrame(), "Error reading " + file.getName());    }    return ok;  }  /**   * Loads a parses a log file running on a server.   */  protected boolean loadLogFile(URL url) {    boolean ok = false;    try {      LogFileParser lfp = new LogFileParser(url.openStream());      lfp.parse(this);      ok = true;    } catch (IOException e) {      LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(          getBaseFrame(), "Error reading URL:" + url.getFile());    }    return ok;  }  //--------------------------------------------------------------------------  //   Private Methods:  //--------------------------------------------------------------------------  //--------------------------------------------------------------------------  //   Nested Top-Level Classes or Interfaces:  //--------------------------------------------------------------------------  class LogBrokerMonitorWindowAdaptor extends WindowAdapter {    protected LogBrokerMonitor _monitor;    public LogBrokerMonitorWindowAdaptor(LogBrokerMonitor monitor) {      _monitor = monitor;    }    public void windowClosing(WindowEvent ev) {      _monitor.requestClose();    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -