Exemplo n.º 1
0
  public void disposeDialog() {
    mUpdateTextAreaThread.commitSuicide();
    mUpdateTextAreaThread = null;
    LogFileLogHandler baseHandler = getBaseHandler();
    if (baseHandler != null) {
      baseHandler.setLogReceiver(null);
    }
    // store window positions:
    LogFileViewerConfigurationStorage storage = new LogFileViewerConfigurationStorage();
    // put_additional_data_here
    getMindMapController()
        .storeDialogPositions(mLogFileViewer, storage, WINDOW_PREFERENCE_STORAGE_PROPERTY);

    getMindMapController().getController().getMapModuleManager().removeListener(this);
    mLogFileViewer.setVisible(false);
    mLogFileViewer.dispose();
  }
Exemplo n.º 2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * accessories.plugins.LogFileLogHandler.LogReceiver#receiveLog(java.util
  * .logging.LogRecord)
  */
 public void receiveLog(final LogRecord record) {
   String msg = mSimpleFormatter.format(record);
   mUpdateTextAreaThread.addToInbox(msg);
 }
Exemplo n.º 3
0
  /*
   * (non-Javadoc)
   *
   * @see freemind.extensions.HookAdapter#startupMapHook()
   */
  public void startupMapHook() {
    super.startupMapHook();
    if (logger == null) {
      logger = freemind.main.Resources.getInstance().getLogger(this.getClass().getName());
    }
    mMyMindMapController = super.getMindMapController();
    mSimpleFormatter = new SimpleFormatter();
    // retrieve content
    final String pathname =
        getMindMapController().getFrame().getFreemindDirectory()
            + File.separator
            + FreeMind.LOG_FILE_NAME
            + ".0";
    String logFileContents = Tools.getFile(new File(pathname));
    // done.
    getMindMapController().getController().getMapModuleManager().addListener(this);
    mLogFileViewer = new JDialog(getController().getFrame().getJFrame(), false);
    mLogFileViewer.setTitle(getResourceString("LogFileViewer_title") + pathname);
    mLogFileViewer.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    mLogFileViewer.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent event) {
            disposeDialog();
          }
        });
    mCloseAction = new CloseAction();
    // the action title is changed by the following method, thus we create
    // another close action.
    Tools.addEscapeActionToDialog(mLogFileViewer, new CloseAction());

    /** Menu * */
    StructuredMenuHolder menuHolder = new StructuredMenuHolder();
    mMenuBar = new JMenuBar();
    JMenu mainItem = new JMenu(getResourceString("MapControllerPopupDialog.Actions"));
    menuHolder.addMenu(mainItem, "main/actions/.");
    Action printOperationAction = new PrintOperationAction();
    addAccelerator(
        menuHolder.addAction(printOperationAction, "main/actions/printOperationAction"),
        "keystroke_accessories/plugins/LogFileViewer_printOperationAction");
    JMenu loggerItem = new JMenu(getResourceString("MapControllerPopupDialog.LogLevels"));
    menuHolder.addMenu(loggerItem, "main/loglevel/.");
    Level[] levels =
        new Level[] {
          Level.FINEST, Level.FINER, Level.FINE, Level.INFO, Level.WARNING, Level.SEVERE, Level.OFF
        };
    for (int i = 0; i < levels.length; i++) {
      Level level = levels[i];
      menuHolder.addAction(
          new SetLogLevelAction(level), "main/loglevel/setLogLevel_" + level.getName());
    }
    menuHolder.updateMenus(mMenuBar, "main/");
    mLogFileViewer.setJMenuBar(mMenuBar);
    mLogFileViewer.setSize(400, 400);
    mLogFileViewer.setLayout(new BorderLayout());
    mTextArea = new JTextArea(logFileContents);
    mTextArea.setEditable(false);
    mTextArea.getCaret().setVisible(true);
    // scroll at the end
    mTextArea.setCaretPosition(logFileContents.length());
    mLogFileViewer.add(new JScrollPane(mTextArea), BorderLayout.CENTER);
    // restore preferences:
    // Retrieve window size and column positions.
    LogFileViewerConfigurationStorage storage =
        (LogFileViewerConfigurationStorage)
            getMindMapController()
                .decorateDialog(mLogFileViewer, WINDOW_PREFERENCE_STORAGE_PROPERTY);
    if (storage != null) {
      // retrieve_additional_data_here
    }
    mLogFileViewer.setVisible(true);
    mUpdateTextAreaThread = new UpdateTextAreaThread();
    mUpdateTextAreaThread.start();
    LogFileLogHandler baseHandler = getBaseHandler();
    if (baseHandler != null) {
      baseHandler.setLogReceiver(this);
    }
  }