Example #1
0
  private void create(final IBranchPart sourceBranch, boolean newTopic) {
    topic = createDummyTopic(sourceBranch, newTopic);

    if (sourceBranch != null || !newTopic) {
      PartRegistry partRegistry = viewer.getPartRegistry();
      if (viewer instanceof AbstractViewer) ((AbstractViewer) viewer).setPartRegistry(null);
      BranchPart branchPart = new BranchPart();
      if (sourceBranch != null) branchPart.setOverrideBranchType(sourceBranch.getBranchType());
      branch = branchPart;
      branch.setModel(topic);
      branch.setParent(viewer.getRootPart());
      addBranchView();
      branch.addNotify();
      branch.getStatus().activate();
      removeShadow();
      if (sourceBranch != null)
        ((BranchPart) branch).setGraphicalPolicy(new DummyBranchPolicy(sourceBranch));
      if (viewer instanceof AbstractViewer) ((AbstractViewer) viewer).setPartRegistry(partRegistry);
    } else {
      IPart topicPart = viewer.findPart(topic);
      branch = MindMapUtils.findBranch(topicPart);
      branch.getFigure().setEnabled(false);
    }

    branch.refresh();
  }
Example #2
0
 private Point calcInitialLocation(IGraphicalViewer viewer, Rectangle bounds) {
   ZoomManager zoom = viewer.getZoomManager();
   bounds =
       bounds
           .scale(zoom.getScale())
           .expand(1, 1)
           .translate(viewer.getScrollPosition().getNegated());
   return viewer.getControl().toDisplay(bounds.x, bounds.y + bounds.height);
 }
Example #3
0
 private ITopic createDummyTopic(IBranchPart sourceBranch, boolean newTopic) {
   ITopic topic;
   if (sourceBranch == null && newTopic) {
     ITopic centralTopic = (ITopic) viewer.getAdapter(ITopic.class);
     topic = centralTopic.getOwnedWorkbook().createTopic();
     centralTopic.add(topic, ITopic.DETACHED);
   } else if (sourceBranch != null) {
     ITopic sourceTopic = sourceBranch.getTopic();
     topic = sourceTopic.getOwnedWorkbook().createTopic();
     topic.setTitleText(sourceTopic.getTitleText());
     topic.setStyleId(sourceTopic.getStyleId());
     topic.setTitleWidth(sourceTopic.getTitleWidth());
     ((TopicImpl) topic).setCoreEventSupport(new CoreEventSupport());
   } else {
     topic = Core.getWorkbookBuilder().createWorkbook().createTopic();
   }
   return topic;
 }
Example #4
0
 private void addBranchView() {
   Layer layer = viewer.getLayer(GEF.LAYER_PRESENTATION);
   if (layer != null) {
     layer.add(branch.getFigure());
   }
 }
Example #5
0
 private void removeShadow() {
   IShadowService shadowService = (IShadowService) viewer.getService(IShadowService.class);
   if (shadowService != null) {
     shadowService.removeShadow(branch.getTopicPart().getFigure());
   }
 }