Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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());
       }
     }
   }
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
  @SuppressWarnings("serial")
  @Override
  public void init() {
    try {
      appletLock.lock();
      appletResourceController = new AppletResourceController(this);
      if (appletResourceController == null) {
        appletResourceController = new AppletResourceController(this);
      }
      new ParserDelegator() {
        {
          setDefaultDTD();
        }
      };
      updateLookAndFeel();
      createRootPane();
      controller = new Controller(appletResourceController);
      appletResourceController.init();
      Controller.setCurrentController(controller);
      final Container contentPane = getContentPane();
      contentPane.setLayout(new BorderLayout());
      MapViewController mapViewController = new MapViewController(controller);
      appletViewController = new AppletViewController(this, controller, mapViewController);
      controller.addAction(new ViewLayoutTypeAction(MapViewLayout.OUTLINE));
      FilterController.install();
      PrintController.install();
      HelpController.install();
      NodeHistory.install(controller);
      FormatController.install(new FormatController());
      ModelessAttributeController.install();
      TextController.install();
      MapController.install();

      TimeController.install();
      LinkController.install();
      IconController.install();
      FilterController.getCurrentFilterController()
          .getConditionFactory()
          .addConditionController(7, new LogicalStyleFilterController());
      final BModeController browseController = BModeControllerFactory.createModeController();
      final Set<String> emptySet = Collections.emptySet();
      FilterController.getController(controller).loadDefaultConditions();
      browseController.updateMenus("/xml/appletMenu.xml", emptySet);
      controller.addAction(new ShowSelectionAsRectangleAction());
      controller.addAction(new NextNodeAction(Direction.FORWARD));
      controller.addAction(new NextNodeAction(Direction.BACK));
      controller.addAction(new NextPresentationItemAction());
      controller.selectMode(browseController);
      appletResourceController.setPropertyByParameter(this, "browsemode_initial_map");
      appletViewController.init(controller);
      final GlassPane glassPane = new GlassPane();
      setGlassPane(glassPane);
      glassPane.setVisible(true);
      controller.getViewController().setMenubarVisible(false);
    } catch (RuntimeException e) {
      e.printStackTrace();
      throw e;
    } finally {
      appletLock.unlock();
    }
  }
Ejemplo n.º 5
0
  private void addListeners() {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    mapController.addNodeSelectionListener(
        new INodeSelectionListener() {
          public void onSelect(final NodeModel node) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
              return;
            }
            if (selection.size() == 1) {
              setStyle(node);
            }
          }

          public void onDeselect(final NodeModel node) {}
        });
    mapController.addNodeChangeListener(
        new INodeChangeListener() {
          public void nodeChanged(final NodeChangeEvent event) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
              return;
            }
            final NodeModel node = event.getNode();
            if (selection.getSelected().equals(node)) {
              setStyle(node);
            }
          }
        });
    mapController.addMapChangeListener(
        new AMapChangeListenerAdapter() {

          @Override
          public void mapChanged(MapChangeEvent event) {
            if (!MapStyle.MAP_STYLES.equals(event.getProperty())) return;
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
              return;
            }
            final NodeModel node = selection.getSelected();
            setStyle(node);
          }
        });
    final IMapViewManager mapViewManager = controller.getMapViewManager();
    mapViewManager.addMapViewChangeListener(
        new IMapViewChangeListener() {
          public void beforeViewChange(final Component oldView, final Component newView) {}

          public void afterViewCreated(final Component mapView) {}

          public void afterViewClose(final Component oldView) {}

          public void afterViewChange(final Component oldView, final Component newView) {
            final Container panel = (Container) getComponent(0);
            for (int i = 0; i < panel.getComponentCount(); i++) {
              panel.getComponent(i).setEnabled(newView != null);
            }
          }
        });
  }
  public DocearNodeModifiedExtensionController(final ModeController modeController) {
    final MapController mapController = Controller.getCurrentModeController().getMapController();
    final ReadManager readManager = mapController.getReadManager();
    final WriteManager writeManager = mapController.getWriteManager();
    // read the last moved time attribute
    readManager.addAttributeHandler(
        "node",
        "MOVED",
        new IAttributeHandler() {
          public void setAttribute(Object node, String value) {
            if (node == null || value == null) {
              return;
            }
            try {
              getController(modeController)
                  .updateMovedTime((NodeModel) node, Long.decode(value).longValue());
            } catch (Exception e) {
              LogUtils.warn(e);
            }
          }
        });
    // read the last folded time attribute
    readManager.addAttributeHandler(
        "node",
        "LAST_FOLDED",
        new IAttributeHandler() {
          public void setAttribute(Object node, String value) {
            if (node == null || value == null) {
              return;
            }
            try {
              getController(modeController)
                  .updateFoldedTime((NodeModel) node, Long.decode(value).longValue());
            } catch (Exception e) {
              LogUtils.warn(e);
            }
          }
        });
    // read the last link opened time attribute
    readManager.addAttributeHandler(
        "node",
        "LINK_OPENED",
        new IAttributeHandler() {
          public void setAttribute(Object node, String value) {
            if (node == null || value == null) {
              return;
            }
            try {
              getController(modeController)
                  .updateLinkOpenedTime((NodeModel) node, Long.decode(value).longValue());
            } catch (Exception e) {
              LogUtils.warn(e);
            }
          }
        });

    writeManager.addExtensionAttributeWriter(
        DocearNodeModifiedExtension.class,
        new IExtensionAttributeWriter() {
          public void writeAttributes(ITreeWriter writer, Object userObject, IExtension extension) {
            try {
              final DocearNodeModifiedExtension modelExtension =
                  extension != null
                      ? (DocearNodeModifiedExtension) extension
                      : DocearNodeModifiedExtensionController.getExtension((NodeModel) userObject);
              if (modelExtension == null) {
                return;
              }
              if (modelExtension.getLastMovedTime() > -1) {
                writer.addAttribute("MOVED", Long.toString(modelExtension.getLastMovedTime()));
              }
              if (modelExtension.getLastFoldedTime() > -1) {
                writer.addAttribute(
                    "LAST_FOLDED", Long.toString(modelExtension.getLastFoldedTime()));
              }
              if (modelExtension.getLastLinkOpenedTime() > -1) {
                writer.addAttribute(
                    "LINK_OPENED", Long.toString(modelExtension.getLastLinkOpenedTime()));
              }
            } catch (Exception e) {
              LogUtils.warn(e);
            }
          }
        });
  }