예제 #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);
   }
 }