/**
   * Sets the new state of the map sharing controller and updates the Freemind window title to
   * indicate the state.
   *
   * @param newState
   */
  private void setState(int newState) {
    state = newState;

    // TODO: Hack alert. Window title setting belongs into a view...
    // Set the window title:
    switch (newState) {
      case STATE_CONNECTED:
        // TODO: Update resource files.
        controller.getFrame().setTitle(frameTitle + " - " + "Connected");
        //
        //	controller.getFrame().getFreeMindMenuBar().getMenu(0).getItem(7).setText("Disconnect");
        break;
      case STATE_NOT_CONNECTED:
        controller.getFrame().setTitle(frameTitle);
        // TODO: Update resource files.
        // Change the "File->Share" menu item to be "File->Share"
        //				if(controller.getFrame().getFreeMindMenuBar() != null)
        //					controller.getFrame().getFreeMindMenuBar().getMenu(0).getItem(7).setText("Share");

        break;
      case STATE_SENT_SHARE_REQUEST_PENDING:
        break;
      case STATE_RECEIVED_SHARE_REQUEST_PENDING:
        break;
      case STATE_SHARING_MAP:
        // TODO: Update resource files.
        controller.getFrame().setTitle(frameTitle + " - " + "Sharing Map");
        // Change the "File->Share" menu item to be "File->Stop Sharing"
        //				if(controller.getFrame().getFreeMindMenuBar() != null)
        //					controller.getFrame().getFreeMindMenuBar().getMenu(0).getItem(7).setText("Stop
        // Sharing");
        break;
      default:
    } // endswitch
  }
Example #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);
   }
 }
Example #3
0
 protected void exportSelectedRowsAndClose() {
   int[] selectedRows = timeTable.getSelectedRows();
   Vector selectedNodes = new Vector();
   for (int i = 0; i < selectedRows.length; i++) {
     int row = selectedRows[i];
     selectedNodes.add(getMindMapNode(row));
   }
   // create new map:
   MindMap newMap = getMindMapController().newMap();
   MindMapController newMindMapController = (MindMapController) newMap.getModeController();
   // Tools.BooleanHolder booleanHolder = new Tools.BooleanHolder();
   // booleanHolder.setValue(false);
   for (Iterator iter = selectedNodes.iterator(); iter.hasNext(); ) {
     MindMapNode node = (MindMapNode) iter.next();
     // MindMapNode newNode = newMindMapController.addNewNode(
     // newMap.getRootNode(), 0, booleanHolder);
     // // copy style:
     // freemind.controller.actions.generated.instance.Pattern pattern =
     // StylePatternFactory.createPatternFromNode(node);
     // newMindMapController.applyPattern(newNode, pattern);
     // // copy text:
     // newMindMapController.setNodeText(newNode, node.getText());
     MindMapNode copy = node.shallowCopy();
     if (copy != null) {
       newMindMapController.insertNodeInto(copy, newMap.getRootNode());
     }
   }
   disposeDialog();
 }
 public void xmlActionPerformed(ActionEvent e) {
   if (singleNodeOperation != null) {
     for (ListIterator it = modeController.getSelecteds().listIterator(); it.hasNext(); ) {
       MindMapNodeModel selected = (MindMapNodeModel) it.next();
       singleNodeOperation.apply((MindMapMapModel) this.modeController.getMap(), selected);
     }
   } else {
     // xml action:
     // Do-action
     CompoundAction doAction = new CompoundAction();
     // Undo-action
     CompoundAction undo = new CompoundAction();
     // sort selectedNodes list by depth, in order to guarantee that
     // sons are deleted first:
     for (ListIterator it = modeController.getSelecteds().listIterator(); it.hasNext(); ) {
       MindMapNodeModel selected = (MindMapNodeModel) it.next();
       ActionPair pair = actor.apply(this.modeController.getMap(), selected);
       if (pair != null) {
         doAction.addChoice(pair.getDoAction());
         undo.addAtChoice(0, pair.getUndoAction());
       }
     }
     if (doAction.sizeChoiceList() == 0) return;
     modeController.getActionFactory().startTransaction((String) getValue(NAME));
     modeController.getActionFactory().executeAction(new ActionPair(doAction, undo));
     modeController.getActionFactory().endTransaction((String) getValue(NAME));
   }
 }
 private void removeAllIcons() {
   for (ListIterator it = modeController.getSelecteds().listIterator(); it.hasNext(); ) {
     MindMapNodeModel selected = (MindMapNodeModel) it.next();
     if (selected.getIcons().size() > 0) {
       modeController.removeAllIcons(selected);
     }
   }
 }
 private void removeIcon(MindMapNode node, MindIcon icon, boolean removeFirst) {
   final ActionPair removeIconActionPair = getRemoveIconActionPair(node, icon, removeFirst);
   if (removeIconActionPair == null) {
     return;
   }
   modeController.getActionFactory().startTransaction((String) getValue(NAME));
   modeController.getActionFactory().executeAction(removeIconActionPair);
   modeController.getActionFactory().endTransaction((String) getValue(NAME));
 }
 public void act(XmlAction action) {
   if (action instanceof AddIconAction) {
     AddIconAction iconAction = (AddIconAction) action;
     MindMapNode node = modeController.getNodeFromID(iconAction.getNode());
     String iconName = iconAction.getIconName();
     int position = iconAction.getIconPosition();
     MindIcon icon = MindIcon.factory(iconName);
     node.addIcon(icon, position);
     modeController.nodeChanged(node);
   }
 }
Example #8
0
 public void togglePrintAction() {
   if (!mPrintActionHandler.containsKey(modeController)) {
     PrintActionHandler printActionHandler =
         new freemind.modes.mindmapmode.actions.xml.PrintActionHandler(modeController);
     modeController.getActionFactory().registerHandler(printActionHandler);
     mPrintActionHandler.put(modeController, printActionHandler);
   } else {
     modeController
         .getActionFactory()
         .deregisterHandler((ActionHandler) mPrintActionHandler.get(modeController));
   }
 }
Example #9
0
 public boolean handleMouseWheelEvent(MouseWheelEvent e) {
   if ((e.getModifiers() & InputEvent.ALT_MASK) != 0) {
     logger.info("handleMouseWheelEvent entered.");
     MindMapNode rootNode = mMap.getRootNode();
     if (e.getWheelRotation() > 0) {
       hookInstance.unfoldOneStage(rootNode);
     } else {
       // this is to avoid having selected nodes getting folded.
       controller.select(controller.getView().getRoot());
       hookInstance.foldOneStage(rootNode);
     }
     return true;
   }
   return false;
 }
  /**
   * null if you cannot provide a title that is present in the resources. Use the setName method to
   * set your not translateble title after that. give a resource name for the icon.
   */
  protected NodeGeneralAction(
      MindMapController modeController, final String textID, String iconPath) {
    super(
        null,
        iconPath != null ? new ImageIcon(modeController.getResource(iconPath)) : null,
        modeController);
    this.modeController = modeController;
    if (textID != null) {
      setName(modeController.getText(textID));
    }

    this.singleNodeOperation = null;
    this.actor = null;
    if (logger == null) {
      logger = modeController.getFrame().getLogger(this.getClass().getName());
    }
  }
 public IconAction(
     MindMapController controller, MindIcon _icon, RemoveIconAction removeLastIconAction) {
   super(_icon.getDescription(), _icon.getIcon(), controller);
   this.modeController = controller;
   this.removeLastIconAction = removeLastIconAction;
   putValue(Action.SHORT_DESCRIPTION, _icon.getDescription());
   this.icon = _icon;
   controller.getActionFactory().registerActor(this, getDoActionClass());
 }
Example #12
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);
 }
Example #13
0
  private void encrypt(MindMapNode node) {
    final StringBuffer password = getUsersPassword();
    if (password == null) {
      return;
    }
    MindMapController mindmapcontroller = (MindMapController) getMindMapController();
    // FIXME: not multithreading safe
    mindmapcontroller.setNewNodeCreator(
        new NewNodeCreator() {

          public MindMapNode createNode(Object userObject, MindMap map) {
            EncryptedMindMapNode encryptedMindMapNode =
                new EncryptedMindMapNode(userObject, getMindMapController().getFrame(), map);
            encryptedMindMapNode.setPassword(password);
            return encryptedMindMapNode;
          }
        });
    try {
      MindMapNode newNode = getMindMapController().addNewNode(node, 0, node.isLeft());
    } catch (Exception e) {
    }
    // normal value:
    mindmapcontroller.setNewNodeCreator(null);
  }
 private void toggleIcon(MindMapNode node, MindIcon icon) {
   modeController.getActionFactory().startTransaction((String) getValue(NAME));
   modeController.getActionFactory().executeAction(getToggleIconActionPair(node, icon));
   modeController.getActionFactory().endTransaction((String) getValue(NAME));
 }
 protected String getNodeID(MindMapNode selected) {
   // TODO Auto-generated method stub
   return modeController.getNodeID(selected);
 }
 protected NodeAdapter getNodeFromID(String string) {
   return modeController.getNodeFromID(string);
 }
 protected void execute(ActionPair pair) {
   modeController.getActionFactory().executeAction(pair);
 }
Example #18
0
 public FontFamilyAction(MindMapController modeController) {
   super(modeController, "font_family", null, (NodeActorXml) null);
   addActor(this);
   // default value:
   actionFont = modeController.getFrame().getProperty("defaultfont");
 }
 private void removeIcon(boolean removeFirst) {
   for (ListIterator it = modeController.getSelecteds().listIterator(); it.hasNext(); ) {
     MindMapNodeModel selected = (MindMapNodeModel) it.next();
     removeIcon(selected, icon, removeFirst);
   }
 }
 private void addLastIcon() {
   for (ListIterator it = modeController.getSelecteds().listIterator(); it.hasNext(); ) {
     MindMapNodeModel selected = (MindMapNodeModel) it.next();
     addIcon(selected, icon);
   }
 }
Example #21
0
 public void deRegister() {
   controller.deRegisterMouseWheelEventHandler(this);
 }
 public void addIcon(MindMapNode node, MindIcon icon) {
   modeController.getActionFactory().startTransaction((String) getValue(NAME));
   modeController.getActionFactory().executeAction(getAddLastIconActionPair(node, icon));
   modeController.getActionFactory().endTransaction((String) getValue(NAME));
 }