Package org.freeplane.features.map

Examples of org.freeplane.features.map.MapModel


  }

  @Override
  public ConditionalStyleModel getConditionalStyleModel() {
    final Controller controller = Controller.getCurrentController();
    final MapModel map = controller.getMap();
      final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final ConditionalStyleModel conditionalStyleModel = styleModel.getConditionalStyleModel();
      return conditionalStyleModel;
    }
View Full Code Here


          final NodeModel node = (NodeModel) userObject;
          final MapStyleModel mapStyleModel = MapStyleModel.getExtension(node);
          if (mapStyleModel == null) {
            return;
          }
          final MapModel map = node.getMap();
          mapStyleModel.createStyleMap(map, mapStyleModel, content);
          map.getIconRegistry().addIcons(mapStyleModel.getStyleMap());
        }
        private boolean isContentEmpty(final String content) {
          return content.indexOf('<') == -1;
        }
View Full Code Here

  private void createDefaultStyleMap(final MapModel map) {
    UrlManager loader = UrlManager.getController();
    final File file = loader.defaultTemplateFile();
    if (file != null) {
      try {
        MapModel styleMapContainer = new MapModel();
        loader.load(Compat.fileToUrl(file), styleMapContainer);
        if (null != MapStyleModel.getExtension(styleMapContainer)){
          moveStyle(styleMapContainer, map, false);
          return;
        }
      }
      catch (Exception e) {
        LogUtils.warn(e);
        UITools.errorMessage(TextUtils.format("error_in_template", file));
      }
    };
    MapModel styleMapContainer = new MapModel();
    try {
      loader.load(ResourceController.getResourceController().getResource("/styles/viewer_standard.mm"), styleMapContainer);
      moveStyle(styleMapContainer, map, false);
    } catch (Exception e) {
      throw new RuntimeException(e);
View Full Code Here

    protected HookAction createHookAction() {
      return null;
    }
 
  public void copyStyle(final URL source, final MapModel targetMap, boolean undoable) {
      final MapModel styleMapContainer = new MapModel();
    final IExtension oldStyleModel = targetMap.getRootNode().removeExtension(MapStyleModel.class);
    UrlManager.getController().loadCatchExceptions(source, styleMapContainer);
    onCreate(styleMapContainer);
    moveStyle(styleMapContainer, targetMap, true);
    LogicalStyleController.getController().refreshMap(targetMap);
View Full Code Here

  protected class XmlWriter implements IExtensionElementWriter {
    public void writeContent(final ITreeWriter writer, final Object object, final IExtension extension)
            throws IOException {
      final MapStyleModel mapStyleModel = (MapStyleModel) extension;
      final MapModel styleMap = mapStyleModel.getStyleMap();
      final String el = System.getProperty("line.separator");
      if (styleMap == null) {
        return;
      }
      final MapWriter mapWriter = Controller.getCurrentModeController().getMapController().getMapWriter();
      final StringWriter sw = new StringWriter();
      sw.append(el);
      sw.append("<map_styles>");
      sw.append(el);
      final NodeModel rootNode = styleMap.getRootNode();
      final boolean forceFormatting = Boolean.TRUE.equals(writer.getHint(MapWriter.WriterHint.FORCE_FORMATTING));
      try {
        mapWriter.writeNodeAsXml(sw, rootNode, Mode.STYLE, true, true, forceFormatting);
      }
      catch (final IOException e) {
View Full Code Here

  public void removeArrowlink(final NodeLinkModel link) {
    final NodeModel node = link.getSource();
    for (final NodeLinkModel i : NodeLinks.getLinkExtension(node).links) {
      if (i.cloneForSource(link.getSource()).equals(link)) {
        links.remove(i);
        final MapModel map = link.getSource().getMap();
        removeLinkFromMap(map, i);
        return;
      }
    }
  }
View Full Code Here

  }

  public void actionPerformed(final ActionEvent e) {
    final NodeModel existingNode = Controller.getCurrentModeController().getMapController().getSelectedNode();
    final Controller controller = Controller.getCurrentController();
    final MapModel parentMap = controller.getMap();
    if (parentMap == null || existingNode == null || existingNode.isRoot()) {
      controller.getViewController().err("Could not export branch.");
      return;
    }
    if (parentMap.getFile() == null) {
      controller.getViewController().out("You must save the current map first!");
      ((MModeController) Controller.getCurrentModeController()).save();
    }
    JFileChooser chooser;
    final File file = parentMap.getFile();
    if (file == null) {
      return;
    }
    chooser = new JFileChooser(file.getParentFile());
    chooser.setSelectedFile(new File(createFileName(TextController.getController().getShortText(existingNode))));
    if (((MFileManager) UrlManager.getController()).getFileFilter() != null) {
      chooser.addChoosableFileFilter(((MFileManager) UrlManager.getController())
          .getFileFilter());
    }
    final int returnVal = chooser.showSaveDialog(controller.getViewController().getContentPane());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File chosenFile = chooser.getSelectedFile();
      final String ext = FileUtils.getExtension(chosenFile.getName());
      if (!ext.equals(org.freeplane.features.url.UrlManager.FREEPLANE_FILE_EXTENSION_WITHOUT_DOT)) {
        chosenFile = new File(chosenFile.getParent(), chosenFile.getName()
                + org.freeplane.features.url.UrlManager.FREEPLANE_FILE_EXTENSION);
      }
      try {
        Compat.fileToUrl(chosenFile);
      }
      catch (final MalformedURLException ex) {
        UITools.errorMessage(TextUtils.getText("invalid_url"));
        return;
      }
      if (chosenFile.exists()) {
        final int overwriteMap = JOptionPane.showConfirmDialog(controller.getMapViewManager().getMapViewComponent(),
            TextUtils.getText("map_already_exists"), "Freeplane", JOptionPane.YES_NO_OPTION);
        if (overwriteMap != JOptionPane.YES_OPTION) {
          return;
        }
      }
      /*
       * Now make a copy from the node, remove the node from the map and
       * create a new Map with the node as root, store the new Map, add
       * the copy of the node to the parent, and set a link from the copy
       * to the new Map.
       */
      final NodeModel parent = existingNode.getParentNode();
      final File oldFile = parentMap.getFile();
 
      final URI newUri = LinkController.toLinkTypeDependantURI(oldFile, chosenFile);
      final URI oldUri = LinkController.toLinkTypeDependantURI(chosenFile, file);
      ((MLinkController) LinkController.getController()).setLink(existingNode,
          oldUri, LinkController.LINK_ABSOLUTE);
      final int nodePosition = parent.getChildPosition(existingNode);
      final ModeController modeController = Controller.getCurrentModeController();
      modeController.undoableResolveParentExtensions(LogicalStyleKeys.NODE_STYLE, existingNode);
      final MMapController mMapController = (MMapController) modeController.getMapController();
      mMapController.deleteNode(existingNode);
      {
        final IActor actor = new IActor() {
          private final boolean wasFolded = existingNode.isFolded();

          public void undo() {
            PersistentNodeHook.removeMapExtensions(existingNode);
            existingNode.setMap(parentMap);
            existingNode.setFolded(wasFolded);
          }

          public String getDescription() {
            return "ExportBranchAction";
          }

          public void act() {
            existingNode.setParent(null);
            existingNode.setFolded(false);
            mMapController.newModel(existingNode);
          }
        };
        Controller.getCurrentModeController().execute(actor, parentMap);
      }
      final MapModel map = existingNode.getMap();
      IExtension[] oldExtensions = map.getRootNode().getSharedExtensions().values().toArray(new IExtension[]{});
      for(final IExtension extension : oldExtensions){
        final Class<? extends IExtension> clazz = extension.getClass();
        if(PersistentNodeHook.isMapExtension(clazz)){
          existingNode.removeExtension(clazz);
        }
      }
      final Collection<IExtension> newExtensions = parentMap.getRootNode().getSharedExtensions().values();
      for(final IExtension extension : newExtensions){
        final Class<? extends IExtension> clazz = extension.getClass();
        if(PersistentNodeHook.isMapExtension(clazz)){
          existingNode.addExtension(extension);
        }
      }
      ((MFileManager) UrlManager.getController()).save(map, chosenFile);
      final NodeModel newNode = mMapController.addNewNode(parent, nodePosition, existingNode.isLeft());
      ((MTextController) TextController.getController()).setNodeText(newNode, existingNode.getText());
      modeController.undoableCopyExtensions(LogicalStyleKeys.NODE_STYLE, existingNode, newNode);
      map.getFile();
      ((MLinkController) LinkController.getController()).setLink(newNode, newUri, LinkController.LINK_ABSOLUTE);
      map.destroy();
    }
  }
View Full Code Here

  }
 
  @Override
  public void setEnabled() {
    final Controller controller = Controller.getCurrentController();
    MapModel map = controller.getMap();
    setEnabled(map != null && ! map.isSaved() && ! map.isReadOnly());
  }
View Full Code Here

  /**@deprecated -- use LinkController*/
  @Deprecated
  @Override
  public void loadURL(final URI relative) {
    final MapModel map = Controller.getCurrentController().getMap();
    if (map == null || map.getURL() == null) {
      if (!relative.toString().startsWith("#") && !relative.isAbsolute() || relative.isOpaque()) {
        Controller.getCurrentController().getViewController().out("You must save the current map first!");
        final boolean result = ((MFileManager) UrlManager.getController()).save(map);
        if (!result) {
          return;
View Full Code Here

    final File file = defaultTemplateFile();
    if (file != null) {
      return newMapFromTemplate(file);
    }
    final MapController mapController = Controller.getCurrentModeController().getMapController();
    final MapModel map = mapController.newMap();
    mapController.setSaved(map, true);
    return map;
  }
View Full Code Here

TOP

Related Classes of org.freeplane.features.map.MapModel

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.