Example #1
0
 public NodeModel getVisibleAncestorOrSelf() {
   NodeModel node = this;
   while (!node.isVisible()) {
     node = node.getParentNode();
   }
   return node;
 }
 public void actionPerformed(ActionEvent event) {
   NodeModel selected = Controller.getCurrentController().getSelection().getSelected();
   if (selected == null) {
     return;
   } else {
     URI uri = URIUtils.getAbsoluteURI(selected);
     try {
       ReadOnlyExceptionWarningHandler warningHandler = new ReadOnlyExceptionWarningHandler();
       warningHandler.prepare();
       while (warningHandler.retry()) {
         try {
           PdfAnnotationImporter importer = new PdfAnnotationImporter();
           List<AnnotationModel> annotations = importer.importAnnotations(uri);
           MonitoringUtils.insertChildNodesFrom(annotations, selected.isLeft(), selected);
           warningHandler.consume();
         } catch (DocumentReadOnlyException e) {
           if (warningHandler.skip()) {
             break;
           }
           warningHandler.showDialog(URIUtils.getFile(uri));
         }
       }
     } catch (IOException e) {
       LogUtils.severe(
           "ImportAllAnnotationsAction IOException at URI(" + uri + "): ",
           e); //$NON-NLS-1$ //$NON-NLS-2$
     } catch (COSRuntimeException e) {
       LogUtils.severe(
           "ImportAllAnnotationsAction COSRuntimeException at URI(" + uri + "): ",
           e); //$NON-NLS-1$ //$NON-NLS-2$
     }
   }
 }
Example #3
0
 public int depth() {
   final NodeModel parentNode = getParentNode();
   if (parentNode == null) {
     return 0;
   }
   return parentNode.depth() + 1;
 }
 public void actionPerformed(final ActionEvent e) {
   final ASelectableCondition condition = filterEditor.getCondition();
   if (condition == null) {
     return;
   }
   final IMapSelection selection = Controller.getCurrentController().getSelection();
   final MapController mapController = Controller.getCurrentModeController().getMapController();
   final NodeModel selected = selection.getSelected();
   final NodeModel rootNode = selected.getMap().getRootNode();
   boolean nodeFound = condition.checkNode(rootNode);
   if (nodeFound) {
     selection.selectAsTheOnlyOneSelected(rootNode);
   }
   NodeModel next = rootNode;
   for (; ; ) {
     next = filterController.findNext(next, rootNode, Direction.FORWARD, condition);
     if (next == null) {
       break;
     }
     mapController.displayNode(next);
     if (nodeFound) {
       selection.toggleSelected(next);
     } else {
       selection.selectAsTheOnlyOneSelected(next);
       nodeFound = true;
     }
   }
   if (condition.checkNode(selected)) selection.makeTheSelected(selected);
 }
  public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    final Controller controller = modeController.getController();
    final NodeModel selected = controller.getSelection().getSelected();
    if (selected.depth() < 2) {
      UITools.errorMessage(TextUtils.getText("can_not_delete_style_group"));
      return;
    }
    final MapModel map = selected.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final NodeModel styleNodeGroup = styleModel.getStyleNodeGroup(selected);
    if (!((StyleNamedObject) styleNodeGroup.getUserObject())
        .getObject()
        .equals("styles.user-defined")) {
      UITools.errorMessage(TextUtils.getText("can_not_delete_predefined_style"));
      return;
    }
    final MMapController mapController = (MMapController) modeController.getMapController();
    mapController.deleteNode(selected);
    final IActor actor =
        new IActor() {
          public void undo() {
            styleModel.addStyleNode(selected);
          }

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

          public void act() {
            styleModel.removeStyleNode(selected);
          }
        };
    Controller.getCurrentModeController().execute(actor, map);
  }
Example #6
0
 public int getNodeLevel(final boolean countHidden) {
   int level = 0;
   NodeModel parent;
   for (parent = getParentNode(); parent != null; parent = parent.getParentNode()) {
     if (countHidden || parent.isVisible()) {
       level++;
     }
   }
   return level;
 }
Example #7
0
 public NodeModel[] getPathToRoot() {
   int i = getNodeLevel(true);
   final NodeModel[] path = new NodeModel[i + 1];
   NodeModel node = this;
   while (i >= 0) {
     path[i--] = node;
     node = node.getParentNode();
   }
   return path;
 }
Example #8
0
 public void setLeft(final boolean isLeft) {
   position = isLeft ? NodeModel.LEFT_POSITION : NodeModel.RIGHT_POSITION;
   if (!isRoot()) {
     for (int i = 0; i < getChildCount(); i++) {
       final NodeModel child = (NodeModel) getChildAt(i);
       if (child.position != position) {
         child.setLeft(isLeft);
       }
     }
   }
 }
 @Override
 protected void actionPerformed(final ActionEvent e, final NodeModel node) {
   final String nodeText = node.getText();
   if (HtmlUtils.isHtmlNode(nodeText)) {
     ((MTextController) TextController.getController())
         .setNodeText(node, HtmlUtils.htmlToPlain(nodeText));
   }
 }
 /**
  * @param node
  * @return
  */
 private boolean updateNodesRecursive(NodeModel node) {
   boolean changes = false;
   for (NodeModel child : node.getChildren()) {
     changes = changes | updateNodesRecursive(child);
   }
   changes = changes | ReferencesController.getController().getSplmmAttributes().translate(node);
   return changes;
 }
Example #11
0
 /**
  * Returns whether the argument is parent or parent of one of the grandpa's of this node.
  * (transitive)
  */
 public boolean isDescendantOf(final NodeModel node) {
   if (parent == null) {
     return false;
   } else if (node == parent) {
     return true;
   } else {
     return parent.isDescendantOf(node);
   }
 }
 private List<NodeModel> getMonitorNodes(NodeModel node) {
   List<NodeModel> result = new ArrayList<NodeModel>();
   if (MonitoringUtils.isMonitoringNode(node)) {
     result.add(node);
   }
   for (NodeModel child : node.getChildren()) {
     result.addAll(getMonitorNodes(child));
   }
   return result;
 }
Example #13
0
 private static NodeModel insertAsNodeModel(
     final NodeModel nodeModel,
     final DefaultMutableTreeNode treeNode,
     final MapController mapController) {
   final MenuEntry menuEntry = (MenuEntry) treeNode.getUserObject();
   final String text =
       menuEntry.getKeyStroke() == null
           ? menuEntry.getLabel()
           : menuEntry.getLabel() + ": " + MenuUtils.formatKeyStroke(menuEntry.getKeyStroke());
   final NodeModel newNodeModel = mapController.newNode(text, nodeModel.getMap());
   if (!treeNode.isLeaf()) {
     newNodeModel.setFolded(true);
   }
   if (menuEntry.getIconKey() != null) {
     final MindIcon mindIcon = menuEntry.createMindIcon();
     if (mindIcon != null) newNodeModel.addIcon(mindIcon);
   }
   nodeModel.insert(newNodeModel);
   return newNodeModel;
 }
 public void updateFoldedTime(NodeModel node, long timeMillis) {
   if (node == null) {
     return;
   }
   DocearNodeModifiedExtension model = getExtension(node);
   if (model == null) {
     model = new DocearNodeModifiedExtension();
     node.addExtension(model);
   }
   model.setLastFoldedTime(timeMillis);
 }
 public void actionPerformed(final ActionEvent arg0) {
   final ProgressUtilities progUtil = new ProgressUtilities();
   final MapController mapController = Controller.getCurrentModeController().getMapController();
   final Collection<NodeModel> nodes = mapController.getSelectedNodes();
   final ViewerController vc =
       ((ViewerController)
           Controller.getCurrentController()
               .getModeController()
               .getExtension(ViewerController.class));
   final NodeModel selectedNode = mapController.getSelectedNode();
   final ExternalResource extRes = (ExternalResource) vc.createExtension(selectedNode);
   if (extRes != null) {
     final File file = new File(extRes.getAbsoluteUri(selectedNode.getMap()));
     for (final NodeModel node : nodes) {
       if (!progUtil.hasExternalResource(node)) {
         vc.paste(file, node, node.isLeft());
       }
     }
   }
 }
 public NodeLinkModel cloneForSource(NodeModel sourceClone) {
   final NodeModel source = getSource();
   if (sourceClone == source) return this;
   final NodeModel target = getTarget();
   if (target != null && target.getParentNode() != null && source.getParentNode() != null) {
     final NodeRelativePath nodeRelativePath = new NodeRelativePath(source, target);
     final NodeModel commonAncestor = nodeRelativePath.commonAncestor();
     final NodeModel ancestorClone = nodeRelativePath.ancestorForBegin(sourceClone);
     if (commonAncestor.isSubtreeCloneOf(ancestorClone)) {
       final NodeRelativePath pathAncestorToSource = new NodeRelativePath(commonAncestor, source);
       final NodeRelativePath clonePath = new NodeRelativePath(ancestorClone, sourceClone);
       if (pathAncestorToSource.equalPathsTo(clonePath)) {
         final NodeModel targetClone = nodeRelativePath.pathEnd(ancestorClone);
         String targetID = targetClone.createID();
         return cloneForSource(sourceClone, targetID);
       }
     }
   }
   return null;
 }
  public void mouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof MainView) {
      MainView view = (MainView) e.getSource();
      Rectangle bounds = ((ZoomableLabelUI) view.getUI()).getIconR(view);
      Point p = e.getPoint();
      if (bounds.contains(p)) {
        if (view.getIcon() instanceof MultipleImage) {
          Rectangle iconR =
              ((MultipleImage) view.getIcon())
                  .getIconR(PdfUtilitiesController.REFRESH_MONITORING_ICON);
          if (iconR != null) {
            float zoom = Controller.getCurrentController().getViewController().getZoom();
            iconR.setLocation((int) (iconR.x * zoom), iconR.y);
            iconR.setSize((int) (iconR.width * zoom), (int) (iconR.height * zoom));
            iconR.translate(bounds.x, bounds.y);
            if (iconR.contains(p)) {
              UpdateMonitoringFolderAction.updateNodesAgainstMonitoringDir(
                  getMonitorNodes(
                      Controller.getCurrentController().getViewController().getMap().getRootNode()),
                  false);
              return;
            }
          }
        }
      }
      //			StringBuilder sb = new StringBuilder();
      //			pdfHeaderExtraction(e, sb);
    }
    boolean openOnPage =
        ResourceController.getResourceController()
            .getBooleanProperty(PdfUtilitiesController.OPEN_PDF_VIEWER_ON_PAGE_KEY);

    if (!openOnPage) {
      this.mouseListener.mouseClicked(e);
      return;
    }

    if (
    /*wasFocused() && */ (e.getModifiers() & ~(InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK))
        == InputEvent.BUTTON1_MASK) {
      final MainView component = (MainView) e.getComponent();
      final ModeController modeController = Controller.getCurrentModeController();
      NodeModel node = null;
      try {
        node = ((MainView) e.getSource()).getNodeView().getModel();
      } catch (Exception ex) {
      }

      if (node == null) {
        node = modeController.getMapController().getSelectedNode();
      }

      if (component.isInFollowLinkRegion(e.getX())) {
        writeToLog(node);
      }
      if (!component.isInFollowLinkRegion(e.getX()) || !MonitoringUtils.isPdfLinkedNode(node)) {
        this.mouseListener.mouseClicked(e);
        return;
      }

      URI uri = Tools.getAbsoluteUri(node);
      if (uri == null) {
        this.mouseListener.mouseClicked(e);
        return;
      }

      IAnnotation annotation = null;
      try {
        annotation = node.getExtension(AnnotationModel.class);
      } catch (Exception ex) {
      }

      LinkController.getController().onDeselect(node);
      if (!PdfUtilitiesController.getController().openPdfOnPage(uri, annotation)) {
        this.mouseListener.mouseClicked(e);
        return;
      }
      LinkController.getController().onSelect(node);

    } else {
      this.mouseListener.mouseClicked(e);
    }
  }
 public Object transformContent(
     TextController textController, Object content, NodeModel node, Object transformedExtension) {
   if (PatternFormat.IDENTITY_PATTERN.equals(textController.getNodeFormat(node))) return content;
   final MapModel map = node.getMap();
   return transformContent(content, map);
 }
Example #19
0
  public void setStyle(final NodeModel node) {
    if (internalChange) {
      return;
    }
    internalChange = true;
    try {
      final LogicalStyleController logicalStyleController = LogicalStyleController.getController();
      if (addStyleBox) {
        final boolean isStyleSet = LogicalStyleModel.getStyle(node) != null;
        mSetStyle.setValue(isStyleSet);
        setStyleList(mMapStyleButton, logicalStyleController.getMapStyleNames(node, "\n"));
      }
      setStyleList(mNodeStyleButton, logicalStyleController.getNodeStyleNames(node, "\n"));
      final NodeStyleController styleController = NodeStyleController.getController();
      {
        final Color nodeColor = NodeStyleModel.getColor(node);
        final Color viewNodeColor = styleController.getColor(node);
        mSetNodeColor.setValue(nodeColor != null);
        mNodeColor.setColorValue(viewNodeColor);
      }
      {
        final Color color = NodeStyleModel.getBackgroundColor(node);
        final Color viewColor = styleController.getBackgroundColor(node);
        mSetNodeBackgroundColor.setValue(color != null);
        mNodeBackgroundColor.setColorValue(
            viewColor != null
                ? viewColor
                : Controller.getCurrentController().getMapViewManager().getBackgroundColor(node));
      }
      {
        final String shape = NodeStyleModel.getShape(node);
        final String viewShape = styleController.getShape(node);
        mSetNodeShape.setValue(shape != null);
        mNodeShape.setValue(viewShape);
      }
      final NodeSizeModel nodeSizeModel = NodeSizeModel.getModel(node);
      {
        final int width =
            nodeSizeModel != null ? nodeSizeModel.getMaxNodeWidth() : NodeSizeModel.NOT_SET;
        final int viewWidth = styleController.getMaxWidth(node);
        mSetMaxNodeWidth.setValue(width != NodeSizeModel.NOT_SET);
        mMaxNodeWidth.setValue(Integer.toString(viewWidth));
      }
      {
        final int width =
            nodeSizeModel != null ? nodeSizeModel.getMinNodeWidth() : NodeSizeModel.NOT_SET;
        final int viewWidth = styleController.getMinWidth(node);
        mSetMinNodeWidth.setValue(width != NodeSizeModel.NOT_SET);
        mMinNodeWidth.setValue(Integer.toString(viewWidth));
      }
      final EdgeController edgeController = EdgeController.getController();
      final EdgeModel edgeModel = EdgeModel.getModel(node);
      {
        final Color edgeColor = edgeModel != null ? edgeModel.getColor() : null;
        final Color viewColor = edgeController.getColor(node);
        mSetEdgeColor.setValue(edgeColor != null);
        mEdgeColor.setColorValue(viewColor);
      }
      {
        final EdgeStyle style = edgeModel != null ? edgeModel.getStyle() : null;
        final EdgeStyle viewStyle = edgeController.getStyle(node);
        mSetEdgeStyle.setValue(style != null);
        mEdgeStyle.setValue(viewStyle.toString());
      }
      {
        final int width = edgeModel != null ? edgeModel.getWidth() : EdgeModel.DEFAULT_WIDTH;
        final int viewWidth = edgeController.getWidth(node);
        mSetEdgeWidth.setValue(width != EdgeModel.DEFAULT_WIDTH);
        mEdgeWidth.setValue(Integer.toString(viewWidth));
      }
      {
        final CloudController cloudController = CloudController.getController();
        final CloudModel cloudModel = CloudModel.getModel(node);
        final Color viewCloudColor = cloudController.getColor(node);
        mSetCloud.setValue(cloudModel != null);
        mCloudColor.setColorValue(viewCloudColor);

        final CloudModel.Shape viewCloudShape = cloudController.getShape(node);
        mCloudShape.setValue(
            viewCloudShape != null ? viewCloudShape.toString() : CloudModel.Shape.ARC.toString());
      }
      {
        final String fontFamilyName = NodeStyleModel.getFontFamilyName(node);
        final String viewFontFamilyName = styleController.getFontFamilyName(node);
        mSetNodeFontName.setValue(fontFamilyName != null);
        mNodeFontName.setValue(viewFontFamilyName);
      }
      {
        final Integer fontSize = NodeStyleModel.getFontSize(node);
        final Integer viewfontSize = styleController.getFontSize(node);
        mSetNodeFontSize.setValue(fontSize != null);
        mNodeFontSize.setValue(viewfontSize.toString());
      }
      {
        final Boolean bold = NodeStyleModel.isBold(node);
        final Boolean viewbold = styleController.isBold(node);
        mSetNodeFontBold.setValue(bold != null);
        mNodeFontBold.setValue(viewbold);
      }
      {
        final Boolean italic = NodeStyleModel.isItalic(node);
        final Boolean viewitalic = styleController.isItalic(node);
        mSetNodeFontItalic.setValue(italic != null);
        mNodeFontItalic.setValue(viewitalic);
      }
      {
        final Boolean hyperlink = NodeLinks.formatNodeAsHyperlink(node);
        final Boolean viewhyperlink = LinkController.getController().formatNodeAsHyperlink(node);
        mSetNodeFontHyperlink.setValue(hyperlink != null);
        mNodeFontHyperlink.setValue(viewhyperlink);
      }
      {
        final Boolean nodeNumbering = NodeStyleModel.getNodeNumbering(node);
        final Boolean viewNodeNumbering = styleController.getNodeNumbering(node);
        mSetNodeNumbering.setValue(nodeNumbering != null);
        mNodeNumbering.setValue(viewNodeNumbering);
      }
      {
        String nodeFormat = NodeStyleModel.getNodeFormat(node);
        String viewNodeFormat = TextController.getController().getNodeFormat(node);
        mSetNodeFormat.setValue(nodeFormat != null);
        if (viewNodeFormat == null && node.getUserObject() instanceof IFormattedObject)
          viewNodeFormat = ((IFormattedObject) node.getUserObject()).getPattern();
        mNodeFormat.setValue(viewNodeFormat);
      }
      if (mAutomaticLayoutComboBox != null) {
        final ModeController modeController = Controller.getCurrentModeController();
        AutomaticLayoutController al = modeController.getExtension(AutomaticLayoutController.class);
        IExtension extension = al.getExtension(node);
        if (extension == null) mAutomaticLayoutComboBox.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
        else mAutomaticLayoutComboBox.setSelectedIndex(((AutomaticLayout) extension).ordinal());
      }
      if (mAutomaticEdgeColorCheckBox != null) {
        final ModeController modeController = Controller.getCurrentModeController();
        AutomaticEdgeColorHook al =
            (AutomaticEdgeColorHook) modeController.getExtension(AutomaticEdgeColorHook.class);
        mAutomaticEdgeColorCheckBox.setSelected(al.isActive(node));
      }
    } finally {
      internalChange = false;
    }
  }
 public static DocearNodeModifiedExtension getExtension(final NodeModel node) {
   DocearNodeModifiedExtension docearNodeModel =
       (DocearNodeModifiedExtension) node.getExtension(DocearNodeModifiedExtension.class);
   return docearNodeModel;
 }
Example #21
0
 public void removeFromParent() {
   parent.remove(this);
 }
Example #22
0
 public void setMap(final MapModel map) {
   this.map = map;
   for (final NodeModel child : children) {
     child.setMap(map);
   }
 }