예제 #1
0
 public void invoke(MindMapNode node) {
   super.invoke(node);
   boolean foldState = Tools.xmlToBoolean(getResourceString("foldingState"));
   String foldingType = getResourceString("foldingType");
   String applyTo = getResourceString("applyTo");
   if ("root".equals(applyTo)) {
     node = getMindMapController().getRootNode();
   }
   if (foldingType.equals("All")) {
     if (foldState) {
       foldAll(node);
     } else {
       unfoldAll(node);
     }
   } else {
     if (foldState) {
       foldOneStage(node);
     } else {
       unfoldOneStage(node);
     }
   }
 }
예제 #2
0
  public void startupMapHook() {
    super.startupMapHook();

    mMyMindMapController = super.getMindMapController();
    getMindMapController().getController().getMapModuleManager().addListener(this);

    // get strings from resources:
    COLUMN_MODIFIED = getResourceString("plugins/TimeList.xml_Modified");
    COLUMN_CREATED = getResourceString("plugins/TimeList.xml_Created");
    COLUMN_ICONS = getResourceString("plugins/TimeList.xml_Icons");
    COLUMN_TEXT = getResourceString("plugins/TimeList.xml_Text");
    COLUMN_DATE = getResourceString("plugins/TimeList.xml_Date");
    COLUMN_NOTES = getResourceString("plugins/TimeList.xml_Notes");

    showAllNodes = Tools.xmlToBoolean(getResourceString("show_all_nodes"));
    dialog = new JDialog(getController().getFrame().getJFrame(), false /* unmodal */);
    String windowTitle;
    if (showAllNodes) {
      windowTitle = "plugins/TimeManagement.xml_WindowTitle_All_Nodes";
    } else {
      windowTitle = "plugins/TimeManagement.xml_WindowTitle";
    }
    dialog.setTitle(getResourceString(windowTitle));
    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent event) {
            disposeDialog();
          }
        });
    Tools.addEscapeActionToDialog(
        dialog,
        new AbstractAction() {
          public void actionPerformed(ActionEvent arg0) {
            disposeDialog();
          }
        });
    Container contentPane = dialog.getContentPane();
    GridBagLayout gbl = new GridBagLayout();
    gbl.columnWeights = new double[] {1.0f};
    gbl.rowWeights = new double[] {1.0f};
    contentPane.setLayout(gbl);
    contentPane.add(
        new JLabel(getResourceString("plugins/TimeManagement.xml_Find")),
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mFilterTextSearchField = new JTextField();
    mFilterTextSearchField.getDocument().addDocumentListener(new FilterTextDocumentListener());
    mFilterTextSearchField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent pEvent) {
            // logger.info("Key event:" + pEvent.getKeyCode());
            if (pEvent.getKeyCode() == KeyEvent.VK_DOWN) {
              logger.info("Set Focus to replace fields");
              mFilterTextReplaceField.requestFocusInWindow();
            }
          }
        });
    contentPane.add(
        /* new JScrollPane */ (mFilterTextSearchField),
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    contentPane.add(
        new JLabel(getResourceString("plugins/TimeManagement.xml_Replace")),
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mFilterTextReplaceField = new JTextField();
    contentPane.add(
        /* new JScrollPane */ (mFilterTextReplaceField),
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mFilterTextReplaceField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent pEvent) {
            if (pEvent.getKeyCode() == KeyEvent.VK_DOWN) {
              logger.info("Set Focus to table");
              timeTable.requestFocusInWindow();
            } else if (pEvent.getKeyCode() == KeyEvent.VK_UP) {
              logger.info("Set Focus to table");
              mFilterTextSearchField.requestFocusInWindow();
            }
          }
        });
    dateRenderer = new DateRenderer();
    nodeRenderer = new NodeRenderer();
    notesRenderer = new NotesRenderer();
    iconsRenderer = new IconsRenderer(getController());
    timeTable = new FlatNodeTable();
    timeTable.addKeyListener(new FlatNodeTableKeyListener());
    // double click = goto.
    timeTable.addMouseListener(new FlatNodeTableMouseAdapter());
    // disable moving:
    timeTable.getTableHeader().setReorderingAllowed(false);
    updateModel();

    sorter.setTableHeader(timeTable.getTableHeader());
    sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMAPRATOR);
    sorter.setColumnComparator(NodeHolder.class, TableSorter.LEXICAL_COMPARATOR);
    sorter.setColumnComparator(NotesHolder.class, TableSorter.LEXICAL_COMPARATOR);
    sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMAPRATOR);
    // Sort by default by date.
    sorter.setSortingStatus(DATE_COLUMN, TableSorter.ASCENDING);
    JScrollPane pane = new JScrollPane(timeTable);
    contentPane.add(
        pane,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            1.0,
            10.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    mTreeLabel = new JLabel();
    contentPane.add(
        new JScrollPane(mTreeLabel),
        new GridBagConstraints(
            0,
            5,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    // button bar
    AbstractAction selectAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Select")) {
          public void actionPerformed(ActionEvent arg0) {
            selectSelectedRows();
          }
        };
    AbstractAction exportAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Export")) {
          public void actionPerformed(ActionEvent arg0) {
            exportSelectedRowsAndClose();
          }
        };
    AbstractAction replaceAllAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Replace_All")) {
          public void actionPerformed(ActionEvent arg0) {
            replace(new ReplaceAllInfo());
          }
        };
    AbstractAction replaceSelectedAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Replace_Selected")) {
          public void actionPerformed(ActionEvent arg0) {
            replace(new ReplaceSelectedInfo());
          }
        };
    AbstractAction gotoAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Goto")) {
          public void actionPerformed(ActionEvent arg0) {
            selectSelectedRows();
            disposeDialog();
          }
        };
    AbstractAction disposeAction =
        new AbstractAction(getResourceString("plugins/TimeManagement.xml_Cancel")) {
          public void actionPerformed(ActionEvent arg0) {
            disposeDialog();
          }
        };

    AbstractAction toggleViewFoldedNodesAction =
        new ToggleViewFoldedNodesAction(
            getResourceString("plugins/TimeManagement.xml_ToggleViewFoldedNodesAction"));

    /** Menu * */
    StructuredMenuHolder menuHolder = new StructuredMenuHolder();
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu(getResourceString("plugins/TimeManagement.xml_menu_actions"));
    menuHolder.addMenu(menu, "main/actions/.");
    final JMenuItem selectMenuItem =
        addAccelerator(
            menuHolder.addAction(selectAction, "main/actions/select"),
            "keystroke_plugins/TimeList_select");
    final JMenuItem gotoMenuItem =
        addAccelerator(
            menuHolder.addAction(gotoAction, "main/actions/goto"),
            "keystroke_plugins/TimeList_goto");
    final JMenuItem replaceSelectedMenuItem =
        addAccelerator(
            menuHolder.addAction(replaceSelectedAction, "main/actions/replaceSelected"),
            "keystroke_plugins/TimeList_replaceSelected");
    final JMenuItem replaceAllMenuItem =
        addAccelerator(
            menuHolder.addAction(replaceAllAction, "main/actions/replaceAll"),
            "keystroke_plugins/TimeList_replaceAll");

    final JMenuItem exportMenuItem =
        addAccelerator(
            menuHolder.addAction(exportAction, "main/actions/export"),
            "keystroke_plugins/TimeList_export");
    addAccelerator(
        menuHolder.addAction(disposeAction, "main/actions/dispose"),
        "keystroke_plugins/TimeList_dispose");
    JMenu viewMenu = new JMenu(getResourceString("plugins/TimeManagement.xml_menu_view"));
    menuHolder.addMenu(viewMenu, "main/view/.");
    addAccelerator(
        menuHolder.addAction(toggleViewFoldedNodesAction, "main/view/showFoldedNodes"),
        "keystroke_plugins/TimeList_showFoldedNodes");
    menuHolder.updateMenus(menuBar, "main/");
    dialog.setJMenuBar(menuBar);

    /* Initial State */
    selectMenuItem.setEnabled(false);
    gotoMenuItem.setEnabled(false);
    exportMenuItem.setEnabled(false);
    replaceSelectedMenuItem.setEnabled(false);

    // table selection listeners to enable/disable menu actions:
    ListSelectionModel rowSM = timeTable.getSelectionModel();
    rowSM.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            // Ignore extra messages.
            if (e.getValueIsAdjusting()) return;

            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            boolean enable = !(lsm.isSelectionEmpty());
            replaceSelectedMenuItem.setEnabled(enable);
            selectMenuItem.setEnabled(enable);
            gotoMenuItem.setEnabled(enable);
            exportMenuItem.setEnabled(enable);
          }
        });
    // table selection listener to display the history of the selected nodes
    rowSM.addListSelectionListener(
        new ListSelectionListener() {
          String getNodeText(MindMapNode node) {
            return Tools.getNodeTextHierarchy(node, getMindMapController());
          }

          public void valueChanged(ListSelectionEvent e) {
            // Ignore extra messages.
            if (e.getValueIsAdjusting()) return;

            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            if (lsm.isSelectionEmpty()) {
              mTreeLabel.setText("");
              return;
            }
            int selectedRow = lsm.getLeadSelectionIndex();
            MindMapNode mindMapNode = getMindMapNode(selectedRow);
            mTreeLabel.setText(getNodeText(mindMapNode));
          }
        });

    // restore preferences:
    // Retrieve window size and column positions.
    WindowConfigurationStorage storage =
        getMindMapController().decorateDialog(dialog, WINDOW_PREFERENCE_STORAGE_PROPERTY);
    if (storage != null) {
      setTableConfiguration(storage);
    }
    dialog.setVisible(true);
  }