Package org.freeplane.features.mode

Examples of org.freeplane.features.mode.Controller


  public void mouseMoved(final MouseEvent e) {
      final ZoomableLabel node = ((ZoomableLabel) e.getComponent());
      String link = node.getLink(e.getPoint());
      boolean followLink = link != null;
      Controller currentController = Controller.getCurrentController();
        final int requiredCursor;
        if(followLink){
        currentController.getViewController().out(link);
        requiredCursor = Cursor.HAND_CURSOR;
        }
        else{
          requiredCursor = Cursor.DEFAULT_CURSOR;
        }
View Full Code Here


public class NodeTooltip extends JToolTip {
  class LinkMouseListener extends MouseAdapter implements MouseMotionListener{
      public void mouseMoved(final MouseEvent ev) {
        final String link = HtmlUtils.getURLOfExistingLink((HTMLDocument) tip.getDocument(), tip.viewToModel(ev.getPoint()));
        boolean followLink = link != null;
        Controller currentController = Controller.getCurrentController();
          final int requiredCursor;
          if(followLink){
          currentController.getViewController().out(link);
          requiredCursor = Cursor.HAND_CURSOR;
          }
          else{
            requiredCursor = Cursor.DEFAULT_CURSOR;
          }
View Full Code Here

  public void mouseClicked(final MouseEvent e) {
    final Object source = e.getSource();
    if(! (source instanceof MapView))
      return;
    final MapView map = (MapView) source;
    final Controller controller = map.getModeController().getController();
    final IMapSelection selection = controller.getSelection();
    if(selection != null){
      final NodeModel selected = selection.getSelected();
      if(selected != null)
        controller.getMapViewManager().getComponent(selected).requestFocusInWindow();
    }
  }
View Full Code Here

  static public void install(final Controller controller) {
    controller.addExtension(NodeHistory.class, new NodeHistory(controller));
  }

  static public void install(final ModeController modeController) {
    final Controller controller = modeController.getController();
    final NodeHistory history = (NodeHistory) controller.getExtension(NodeHistory.class);
    modeController.getMapController().addNodeSelectionListener(history.getMapSelectionListener());
    LinkController.getController(modeController).addNodeSelectionListener(history.getLinkSelectionListener());
    history.backAction = new BackAction(controller, history);
    modeController.addAction(history.backAction);
    history.forwardAction = new ForwardAction(controller, history);
View Full Code Here

    }
    final boolean fChangeModule = changeModule;
    final MapView newView;
    if (fChangeModule) {
      newView = newModule;
      final Controller controller = newView.getModeController().getController();
      final IMapViewManager mapViewManager = controller.getMapViewManager();
      final boolean res = mapViewManager.changeToMapView(newView);
      if (!res) {
        LogUtils.warn("Can't change to map mapView " + newView);
        return;
      }
View Full Code Here

      final MainView mainView = (MainView) dtde.getDropTargetContext().getComponent();
      final NodeView targetNodeView = mainView.getNodeView();
      final MapView mapView = targetNodeView.getMap();
      mapView.select();
      final NodeModel targetNode = targetNodeView.getModel();
      final Controller controller = Controller.getCurrentController();
      if (dtde.isLocalTransfer() && t.isDataFlavorSupported(MindMapNodesSelection.dropActionFlavor)) {
        final String sourceAction = (String) t.getTransferData(MindMapNodesSelection.dropActionFlavor);
        if (sourceAction.equals("LINK")) {
          dropAction = DnDConstants.ACTION_LINK;
        }
        if (sourceAction.equals("COPY")) {
          dropAction = DnDConstants.ACTION_COPY;
        }
      }
      mainView.setDraggedOver(NodeView.DRAGGED_OVER_NO);
      mainView.repaint();
      if (dtde.isLocalTransfer() && (dropAction == DnDConstants.ACTION_MOVE) && !isDropAcceptable(dtde)) {
        dtde.rejectDrop();
        return;
      }
      final boolean dropAsSibling = mainView.dropAsSibling(dtde.getLocation().getX());
      ModeController modeController = controller.getModeController();
      final MMapController mapController = (MMapController) modeController.getMapController();
      if ((dropAction == DnDConstants.ACTION_MOVE || dropAction == DnDConstants.ACTION_COPY)) {
        final NodeModel parent = dropAsSibling ? targetNode.getParentNode() : targetNode;
        if (!mapController.isWriteable(parent)) {
          dtde.rejectDrop();
          final String message = TextUtils.getText("node_is_write_protected");
          UITools.errorMessage(message);
          return;
        }
      }
      final boolean isLeft = mainView.dropLeft(dtde.getLocation().getX());
      if (!dtde.isLocalTransfer()) {
        dtde.acceptDrop(DnDConstants.ACTION_COPY);
        ((MClipboardController) ClipboardController.getController()).paste(t, targetNode, dropAsSibling, isLeft, dropAction);
        dtde.dropComplete(true);
        return;
      }
      dtde.acceptDrop(dropAction);
      if (dropAction == DnDConstants.ACTION_LINK) {
        int yesorno = JOptionPane.YES_OPTION;
        if (controller.getSelection().size() >= 5) {
          yesorno = JOptionPane.showConfirmDialog(controller.getViewController().getContentPane(), TextUtils
              .getText("lots_of_links_warning"), Integer.toString(controller.getSelection().size())
                  + " links to the same node", JOptionPane.YES_NO_OPTION);
        }
        if (yesorno == JOptionPane.YES_OPTION) {
          for (final Iterator<NodeModel> it = controller.getSelection().getSelection().iterator(); it
              .hasNext();) {
            final NodeModel selectedNodeModel = (it.next());
            ((MLinkController) LinkController.getController(modeController)).addConnector(
                selectedNodeModel, targetNode);
          }
        }
      }
      else {
        Transferable trans = null;
        final Collection<NodeModel> selecteds = mapController.getSelectedNodes();
        if (DnDConstants.ACTION_MOVE == dropAction) {
          NodeModel actualNode = targetNode;
          do {
            if (selecteds.contains(actualNode)) {
              final String message = TextUtils.getText("cannot_move_to_child");
              JOptionPane.showMessageDialog(controller.getViewController().getContentPane(), message,
                  "Freeplane", JOptionPane.WARNING_MESSAGE);
              dtde.dropComplete(true);
              return;
            }
            actualNode = (actualNode.isRoot()) ? null : actualNode.getParentNode();
          } while (actualNode != null);
                  final NodeModel[] array = selecteds.toArray(new NodeModel[selecteds.size()]);
          final List<NodeModel> sortedSelection = controller.getSelection().getSortedSelection(true);
          for (final NodeModel node : sortedSelection) {
            boolean changeSide = isLeft != node.isLeft();
                        if (dropAsSibling) {
                          mapController.moveNodeBefore(node, targetNode, isLeft, changeSide);
                        }
                        else {
                          mapController.moveNodeAsChild(node, targetNode, isLeft, changeSide);
                        }
          }
         
          if(dropAsSibling || ! targetNode.isFolded())
              controller.getSelection().replaceSelection(array);
          else
              controller.getSelection().selectAsTheOnlyOneSelected(targetNode);
        }
        else {
          trans = ClipboardController.getController().copy(controller.getSelection());
          ((MClipboardController) ClipboardController.getController()).paste(trans, targetNode, dropAsSibling, isLeft);
                  controller.getSelection().selectAsTheOnlyOneSelected(targetNode);
        }
      }
    }
    catch (final Exception e) {
      LogUtils.severe("Drop exception:", e);
View Full Code Here

    return mMapView.get();
  }

  MapView getMapView() {
    final MapView mapView = mMapView.get();
    final Controller controller = mapView.getModeController().getController();
    final MapViewController mapViewManager = (MapViewController) controller.getMapViewManager();
    for (final MapView m : mapViewManager.getMapViewVector()) {
      if (m == mapView) {
        return mapView;
      }
    }
View Full Code Here

    if (!nodeSelector.isRelevant(e))
      return;
    final MainView node = ((MainView) e.getComponent());
    String link = node.getLink(e.getPoint());
    boolean followLink = link != null;
    Controller currentController = Controller.getCurrentController();
        if(! followLink){
          followLink = node.isInFollowLinkRegion(e.getX());
          if(followLink){
        link = LinkController.getController(currentController.getModeController()).getLinkShortText(node.getNodeView().getModel());
          }
        }
        final Cursor requiredCursor;
        if(followLink){
      currentController.getViewController().out(link);
      requiredCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
      node.setMouseArea(MouseArea.LINK);
        }
        else if (isInFoldingRegion(e)){
          requiredCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
View Full Code Here

    ProgressIcons.updateExtendedProgressIcons(node, input.getName());
    return preview;
  }
 
  protected URI createURI(final NodeModel node) {
    final Controller controller = Controller.getCurrentController();
    final ViewController viewController = controller.getViewController();
    final MapModel map = node.getMap();
    final File file = map.getFile();
    final boolean useRelativeUri = ResourceController.getResourceController().getProperty("links").equals(
        "relative");
    if (file == null && useRelativeUri) {
      JOptionPane.showMessageDialog(viewController.getContentPane(), TextUtils
          .getText("not_saved_for_image_error"), "Freeplane", JOptionPane.WARNING_MESSAGE);
      return null;
    }
    final UrlManager urlManager = controller.getModeController().getExtension(UrlManager.class);
    final JFileChooser chooser = urlManager.getFileChooser(null, false);
    chooser.setAcceptAllFileFilterUsed(false);
    if (factories.size() > 1) {
      final FileFilter combiFileFilter = getCombiFileFilter();
      chooser.addChoosableFileFilter(combiFileFilter);
View Full Code Here

    final IScriptStarter starter = (IScriptStarter) modeController.getExtension(IScriptStarter.class);
    if(starter == null)
      return;
    final NodeModel node = reminderExtension.getNode();
    final MapModel map = node.getMap();
    final Controller controller = modeController.getController();
    if(! controller.getMapViewManager().getMaps(modeController.getModeName()).containsValue(map))
      return;
    starter.executeScript(node, script);
    }
View Full Code Here

TOP

Related Classes of org.freeplane.features.mode.Controller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.