예제 #1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * freemind.controller.MenuItemEnabledListener#isEnabled(javax.swing
  * .JMenuItem, javax.swing.Action)
  */
 public boolean isEnabled(JMenuItem item, Action action) {
   String hookName = ((NodeHookAction) action).getHookName();
   // the following function does not work without a running valid
   // controller, so we comment it out.
   // if(hookName.equals("accessories/plugins/NewEncryptedMap.properties"))
   // {
   // return true;
   // }
   if (!enabled) return false;
   boolean isEncryptedNode = false;
   boolean isOpened = false;
   if (controller.getSelected() != null
       && controller.getSelected() instanceof EncryptedMindMapNode) {
     isEncryptedNode = true;
     EncryptedMindMapNode enode = (EncryptedMindMapNode) controller.getSelected();
     isOpened = enode.isAccessible();
   }
   if (hookName.equals("accessories/plugins/EnterPassword.properties")) {
     return isEncryptedNode;
   } else {
     /*
      * you can insert an encrypted node, if the current selected
      * node is not encrypted, or if it is opened.
      */
     return (!isEncryptedNode || isOpened);
   }
 }
예제 #2
0
 private void toggleCryptState(MindMapNode node) {
   final MindMapController mindMapController = getMindMapController();
   if (node instanceof EncryptedMindMapNode) {
     EncryptedMindMapNode encNode = (EncryptedMindMapNode) node;
     if (encNode.isAccessible()) {
       // to remove all children views:
       encNode.encrypt();
       encNode.setShuttingDown(true);
     } else {
       doPasswordCheckAndDecryptNode(encNode);
     }
     mindMapController.nodeStructureChanged(encNode);
     final MapView mapView = mindMapController.getView();
     mapView.selectAsTheOnlyOneSelected(mapView.getNodeView(encNode));
     encNode.setShuttingDown(false);
   } else {
     // box:
     JOptionPane.showMessageDialog(
         mindMapController.getFrame().getContentPane(),
         mindMapController.getText(
             "accessories/plugins/EncryptNode.properties_insert_encrypted_node_first"),
         "Freemind",
         JOptionPane.INFORMATION_MESSAGE);
   }
 }
예제 #3
0
 private void newEncryptedMap() {
   final StringBuffer password = getUsersPassword();
   if (password == null) {
     return;
   }
   ModeController newModeController = getMindMapController().getMode().createModeController();
   EncryptedMindMapNode encryptedMindMapNode =
       new EncryptedMindMapNode(
           getMindMapController().getText("accessories/plugins/EncryptNode.properties_select_me"),
           getMindMapController().getFrame(),
           null);
   encryptedMindMapNode.setPassword(password);
   MapAdapter newModel =
       new MindMapMapModel(
           encryptedMindMapNode, getMindMapController().getFrame(), newModeController);
   MindMapController mindmapcontroller = getMindMapController();
   encryptedMindMapNode.setMap(newModel);
   mindmapcontroller.newMap(newModel);
 }
예제 #4
0
 private void doPasswordCheckAndDecryptNode(EncryptedMindMapNode encNode) {
   while (true) {
     // get password:
     final EnterPasswordDialog pwdDialog =
         new EnterPasswordDialog(
             (JFrame) getMindMapController().getFrame(), getMindMapController(), false);
     pwdDialog.setModal(true);
     pwdDialog.setVisible(true);
     if (pwdDialog.getResult() == EnterPasswordDialog.CANCEL) {
       return;
     }
     if (!encNode.decrypt(pwdDialog.getPassword())) {
       // box:
       JOptionPane.showMessageDialog(
           getMindMapController().getFrame().getContentPane(),
           getMindMapController()
               .getText("accessories/plugins/EncryptNode.properties_wrong_password"),
           "Freemind",
           JOptionPane.ERROR_MESSAGE);
     } else {
       return; // correct password.
     }
   }
 }