コード例 #1
0
ファイル: GanttTree2.java プロジェクト: rudaondo/ganttproject
  /** Edits the <code>t</code> task name in the treetable. */
  public void setEditingTask(Task t) {
    getTreeTable().getTreeTable().editingStopped(new ChangeEvent(getTreeTable().getTreeTable()));

    TaskSelectionManager taskSelectionManager = getTaskSelectionManager();
    taskSelectionManager.clear();
    taskSelectionManager.addTask(t);

    getTreeTable().editSelectedTask();
    getTreeTable().centerViewOnSelectedCell();
  }
コード例 #2
0
ファイル: GanttTree2.java プロジェクト: rudaondo/ganttproject
 @Override
 protected void onSelectionChanged(List<DefaultMutableTreeTableNode> selection) {
   if (isOnTaskSelectionEventProcessing) {
     return;
   }
   List<Task> selectedTasks = Lists.newArrayList();
   for (DefaultMutableTreeTableNode node : selection) {
     if (node instanceof TaskNode) {
       selectedTasks.add((Task) node.getUserObject());
     }
   }
   mySelectionManager.setSelectedTasks(selectedTasks);
 }
コード例 #3
0
ファイル: GanttTree2.java プロジェクト: rudaondo/ganttproject
  @Override
  protected void init() {
    getTreeTable().initTreeTable();
    // Create the root node
    initRootNode();

    getTreeTable()
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.ALT_DOWN_MASK), "cutTask");
    getTreeTable()
        .getTree()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              @Override
              public void valueChanged(TreeSelectionEvent e) {}
            });

    getTreeTable().getTree().addTreeExpansionListener(new GanttTreeExpansionListener());

    ToolTipManager.sharedInstance().registerComponent(getTreeTable());

    getTreeTable().insertWithLeftyScrollBar(this);
    mySelectionManager.addSelectionListener(
        new Listener() {
          @Override
          public void selectionChanged(List<Task> currentSelection) {}

          @Override
          public void userInputConsumerChanged(Object newConsumer) {
            if (getTreeTable().getTable().isEditing()) {
              getTreeTable()
                  .getTable()
                  .editingStopped(new ChangeEvent(getTreeTable().getTreeTable()));
            }
          }
        });
    getTreeTable()
        .getTree()
        .addFocusListener(
            new FocusAdapter() {
              @Override
              public void focusGained(FocusEvent e) {
                super.focusGained(e);
                mySelectionManager.setUserInputConsumer(this);
              }
            });
    try {
      GanttTreeDropListener dropListener = new GanttTreeDropListener();
      getTreeTable().getDropTarget().addDropTargetListener(dropListener);
      Color selectionBackground = UIManager.getColor("Table.selectionBackground");
      Color dropBackground =
          new Color(
              selectionBackground.getRed(),
              selectionBackground.getGreen(),
              selectionBackground.getBlue(),
              64);
      Color foreground = UIManager.getColor("Table.selectionForeground");
      myDragHighlighter = new ColorHighlighter(dropListener, dropBackground, foreground);
    } catch (TooManyListenersException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
  }
コード例 #4
0
ファイル: GanttTree2.java プロジェクト: rudaondo/ganttproject
  public GanttTree2(
      final GanttProject project,
      TaskManager taskManager,
      TaskSelectionManager selectionManager,
      final UIFacade uiFacade) {

    super(createTreeTable(project.getProject(), createDirtyfier(project), uiFacade));
    myUIFacade = uiFacade;
    myProject = project;
    myTaskManager = taskManager;
    mySelectionManager = selectionManager;

    myTaskManager.addTaskListener(
        new TaskListenerAdapter() {
          @Override
          public void taskModelReset() {
            clearTree();
          }

          @Override
          public void taskRemoved(TaskHierarchyEvent e) {
            MutableTreeTableNode node = getNode(e.getTask());
            if (node == null) {
              return;
            }
            TreeNode parent = node.getParent();
            if (parent != null) {
              getTreeModel().removeNodeFromParent(node);
            }
          }
        });
    mySelectionManager.addSelectionListener(
        new TaskSelectionManager.Listener() {
          @Override
          public void userInputConsumerChanged(Object newConsumer) {}

          @Override
          public void selectionChanged(List<Task> currentSelection) {
            onTaskSelectionChanged(currentSelection);
          }
        });

    // Create Actions
    GPAction propertiesAction =
        new TaskPropertiesAction(project.getProject(), selectionManager, uiFacade);
    GPAction deleteAction = new TaskDeleteAction(taskManager, selectionManager, uiFacade, this);
    GPAction newAction = new TaskNewAction(project.getProject(), uiFacade);

    setArtefactActions(newAction, propertiesAction, deleteAction);
    myLinkTasksAction = new TaskLinkAction(taskManager, selectionManager, uiFacade);
    myUnlinkTasksAction = new TaskUnlinkAction(taskManager, selectionManager, uiFacade);
    myIndentAction = new TaskIndentAction(taskManager, selectionManager, uiFacade, this);
    myUnindentAction = new TaskUnindentAction(taskManager, selectionManager, uiFacade, this);
    myMoveUpAction = new TaskMoveUpAction(taskManager, selectionManager, uiFacade, this);
    myMoveDownAction = new TaskMoveDownAction(taskManager, selectionManager, uiFacade, this);
    getTreeTable()
        .setupActionMaps(
            myMoveUpAction,
            myMoveDownAction,
            myIndentAction,
            myUnindentAction,
            newAction,
            myProject.getCutAction(),
            myProject.getCopyAction(),
            myProject.getPasteAction(),
            propertiesAction,
            deleteAction);
  }