Exemple #1
0
  private void selectFileTreeItemForSelectedFile(final File file) {
    if (updatingSelectedFiles) return;

    updatingSelectedFiles = true;
    try {
      final FileTreeItem<?> fileTreeItem = rootFileTreeItem.findFirst(file);
      if (fileTreeItem == null) {
        IllegalStateException x =
            new IllegalStateException("File does not have corresponding FileTreeItem: " + file);
        logger.warn("selectFileTreeItemForSelectedFile: " + x, x);
      } else {
        TreeItem<?> ti = fileTreeItem.getParent();
        while (ti != null) {
          ti.setExpanded(true);
          ti = ti.getParent();
        }

        // TODO maybe, instead of scrolling here (after each single item is selected), immediately,
        // we should wait (=> Timer) and scroll to the *first* selection, later?!
        treeTableView.getSelectionModel().select(fileTreeItem);
        int row = treeTableView.getRow(fileTreeItem);
        if (row >= 0) treeTableView.scrollTo(row);
      }
    } finally {
      updatingSelectedFiles = false;
    }
  }
 @SuppressWarnings("rawtypes")
 @Test
 public void assertContent() {
   TreeView treeView = (TreeView) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
   int expandedItemCount = treeView.getExpandedItemCount();
   TreeItem treeItem = treeView.getTreeItem(expandedItemCount - 1);
   treeItem.setExpanded(true);
   final Object[] content = new Object[] {null};
   Platform.runLater(
       new Runnable() {
         @Override
         public void run() {
           RFXTreeView rTreeView = new RFXTreeView(treeView, null, null, null);
           content[0] = rTreeView.getContent();
         }
       });
   new Wait("Waiting for contents.") {
     @Override
     public boolean until() {
       return content[0] != null;
     }
   };
   JSONArray a = new JSONArray(content[0]);
   Assert.assertEquals(
       "[[\"Root node\",\"Child Node 1\",\"Child Node 2\",\"Child Node 3\",\"Child Node 4\",\"Child Node 5\",\"Child Node 6\",\"Child Node 7\",\"Child Node 8\",\"Child Node 9\",\"Child Node 10\",\"Child Node 11\",\"Child Node 12\",\"Child Node 13\",\"Child Node 14\",\"Child Node 15\",\"Child Node 16\",\"Child Node 17\",\"Child Node 18\",\"Child Node 19\",\"Child Node 20\",\"Child Node 21\",\"Child Node 22\",\"Child Node 23\",\"Child Node 24\"]]",
       a.toString());
 }
  @Override
  public void initialize(URL arg0, ResourceBundle arg1) {
    storedPreferences = Preferences.userRoot().node(PrefsConstants.PREFS_NODE);
    // DynamiPrefs.Basic.prefs().read(preferences);
    TreeItem<PrefsItem> root = new TreeItem<PrefsItem>(new PrefsItem(null, "General", ""));
    for (DynamiPrefs p : prefsPages) {
      final Prefs prefsNode = p.prefs();
      prefsNode.read(storedPreferences);
      final Prefs.Panel panel = p.prefs().getClass().getAnnotation(Prefs.Panel.class);
      TreeItem<PrefsItem> child =
          new TreeItem<PrefsItem>(new PrefsItem(prefsNode, panel.name(), panel.description()));

      root.getChildren().add(child);
    }

    root.setExpanded(true);
    tree.setRoot(root);

    tree.getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue.getValue().prefs != null) {
                main.detailNodeProperty().set(new PrefsPage(newValue.getValue().prefs).getNode());
              }
            });
  }
  private void filterForFunctionTextMatch(String search) {
    String[] split = search.split(":");

    if (split.length == 0) return;

    final String moduleName = split[0];
    final String funcName = (split.length > 1) ? split[1] : "";

    if (search.contains(":")) {
      for (TreeItem<ModFunc> treeItem : filteredTreeModules) {
        treeItem.setExpanded(true);
      }
    }

    for (FilteredList<TreeItem<ModFunc>> funcItemList : functionLists) {
      funcItemList.setPredicate(
          (t) -> {
            return isMatchingModFunc(funcName, t);
          });
    }

    filteredTreeModules.setPredicate(
        (t) -> {
          return isMatchingModFunc(moduleName, t) && !t.getChildren().isEmpty();
        });
  }
 @Test
 public void testCollapsedBranch() {
   TreeItem childBranch = createBranch("collapsedChild");
   TreeItem grandChildBranch = createBranch("expandedGrandChild");
   grandChildBranch.setExpanded(true);
   childBranch.getChildren().add(0, grandChildBranch);
   getRootChildren().add(0, childBranch);
   int index = 6;
   getSelectionModel().select(index);
   TreeItem selectedItem = getSelectedItems().get(0);
   grandChildBranch.setExpanded(false);
   assertEquals(index, getSelectedIndex());
   assertEquals(index, getSelectedIndices().get(0).intValue());
   assertEquals(selectedItem, getSelectedItems().get(0));
   assertEquals(selectedItem, getSelectedItem());
 }
  private void addItemToTree(DicomFile dicomFile) {
    final TreeItem<DicomFileTreeNode> node =
        new TreeItem<DicomFileTreeNode>(new DicomFileTreeNode(dicomFile));

    if (root.getChildren().size() > 0) {
      TreeItem<DicomFileTreeNode> dicomdir = root.getChildren().get(0);
      dicomdir.getChildren().add(node);
    } else {
      node.setExpanded(true);
      /*
      node.addEventHandler(TreeItem.branchCollapsedEvent(), new EventHandler<TreeItem.TreeModificationEvent<DicomFileTreeNode>>() {

          @Override
          public void handle(TreeItem.TreeModificationEvent<DicomFileTreeNode> event) {
              treeView.refresh();
          }
      });
      node.addEventHandler(TreeItem.branchExpandedEvent(), new EventHandler<TreeItem.TreeModificationEvent<DicomFileTreeNode>>() {
          @Override
          public void handle(TreeItem.TreeModificationEvent<DicomFileTreeNode> event) {
              treeView.refresh();
          }
      });
      */
      root.getChildren().add(node); // DICOMDIR
    }
  }
  @Override
  public void initialize(URL location, ResourceBundle resources) {

    // dummy entries
    TreeItem<String> rootItem = new TreeItem<String>("Dummy");
    rootItem.setExpanded(true);
    for (int i = 1; i < 6; i++) {
      TreeItem<String> item = new TreeItem<String>("Sub Dummy " + i);
      rootItem.getChildren().add(item);
    }

    treeView = new TreeView<>(rootItem);

    treeView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<TreeItem>() {

              @Override
              public void changed(
                  ObservableValue<? extends TreeItem> observable,
                  TreeItem oldValue,
                  TreeItem newValue) {
                Logger.getLogger(SystemtreePresenter.class.getName())
                    .log(Level.INFO, "Tree selection changed: {0}", newValue);
                someLogic.doSomething();
              }
            });
    rootPane.getChildren().add(treeView);
  }
 /**
  * IndicesList is throwing IllegalState: on hiding a collapsed root, the root is forced to
  * expanded (in the showRoot property invalidation) Need to cope.
  */
 @Test
 public void testHideCollapsedRoot() {
   getView().setShowRoot(true);
   TreeItem root = getView().getRoot();
   assertTrue("snaity: root expanded", root.isExpanded());
   root.setExpanded(false);
   getView().setShowRoot(false);
 }
  /** Replace selected expanded child with an expanded child with more items than the old. */
  @Test
  public void testSetExpandedChildAtExpandedSame() {
    getView().setShowRoot(true);
    TreeItem child = createBranch("single-replaced-child");
    child.setExpanded(true);
    int index = 3;
    setItem(index - 1, child);
    getSelectionModel().select(index);
    // replacingChild has same # of children
    TreeItem expandedChild = createBranch("another-single-replaced");
    expandedChild.setExpanded(true);
    assertEquals(
        "sanity: same # of children and both expanded",
        child.getChildren().size(),
        expandedChild.getChildren().size());
    setItem(index - 1, expandedChild);

    assertEquals(index, getSelectedIndex());
    assertEquals(expandedChild, getSelectedItem());
  }
Exemple #10
0
  /**
   * Restores the mapping of the tree items from the internal dictionary of expanded items.
   *
   * @param tree The tree to restore the mapping of
   */
  public static void restoreMap(TreeViewWithItems<SaharaItem> tree) {
    /*for (TreeItem<SaharaItem> item : tree.getTreeItems()) {
        item.setExpanded(isExpanded(item.getValue()));
    }*/

    for (TreeItem<SaharaItem> item : tree.getTreeItems()) {
      TreeEntry entry;
      if (item.getParent() != null && item.getParent().getValue() != null) {
        entry = new TreeEntry(item.getValue(), item.getParent().getValue());
      } else {
        entry = new TreeEntry(item.getValue(), null);
      }
      item.setExpanded(isExpanded(entry));
    }
  }
  private void loadAccountTree() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);

    if (engine != null) {
      RootAccount r = engine.getRootAccount();

      final TreeItem<Account> root = new TreeItem<>(r);
      root.setExpanded(true);

      treeTableView.setRoot(root);
      loadChildren(root);
    } else {
      treeTableView.setRoot(null);
    }
  }
  /** 板一覧を表示 */
  public void showBoardList(List<Board> boards) {
    boardTreeView.setRoot(rootNode);
    boardTreeView.setShowRoot(false);
    rootNode.getValue().setTitle("root");
    rootNode.getValue().setId("root_");
    rootNode.setExpanded(true);

    // 履歴
    TreeItem<Board> userTree = new TreeItem<Board>(new Board());
    userTree.getValue().setTitle("ユーザ");
    userTree.getValue().setId("user_");
    userTree.setExpanded(true);
    rootNode.getChildren().add(userTree);

    TreeItem<Board> history = new TreeItem<Board>(new Board());
    history.getValue().setTitle("履歴");
    history.getValue().setId("history_");
    history.setExpanded(true);
    userTree.getChildren().add(history);

    TreeItem<Board> favorite = new TreeItem<Board>(new Board());
    favorite.getValue().setTitle("お気に入り");
    favorite.getValue().setId("favorite_");
    favorite.setExpanded(true);
    userTree.getChildren().add(favorite);

    TreeItem<Board> nichanBoard = new TreeItem<Board>(new Board());
    nichanBoard.getValue().setTitle("2ch");
    nichanBoard.getValue().setId("2ch_");
    nichanBoard.setExpanded(true);
    rootNode.getChildren().add(nichanBoard);

    for (Board board : boards) {
      setupTreeItem(nichanBoard, board);
    }
  }
 @Test
 public void testSelectedOnExpandedGrandBranchCollapsed() {
   TreeItem childBranch = createBranch("expandedChild", true);
   TreeItem grandChildBranch = createBranch("expandedGrandChild", true);
   childBranch.getChildren().add(0, grandChildBranch);
   TreeItem selected = (TreeItem) grandChildBranch.getChildren().get(rawItems.size() - 1);
   getRootChildren().add(0, childBranch);
   getSelectionModel().select(selected);
   TreeItem selectedItem = getSelectedItems().get(0);
   assertEquals(selectedItem, getSelectedItems().get(0));
   assertEquals(selectedItem, getSelectedItem());
   grandChildBranch.setExpanded(false);
   assertEquals("selected items size", 1, getSelectedItems().size());
   assertEquals(grandChildBranch, getSelectedItem());
   //        assertEquals(index, getSelectionModel().getSelectedIndex());
   //        assertEquals(index, getSelectionModel().getSelectedIndices().get(0).intValue());
 }
  private void buildObjectTreeRoot(OtpErlangList requestFunctions) {
    boolean isExported;

    for (OtpErlangObject e : requestFunctions) {
      OtpErlangTuple tuple = (OtpErlangTuple) e;

      OtpErlangAtom moduleNameAtom = (OtpErlangAtom) tuple.elementAt(0);
      OtpErlangList exportedFuncs = (OtpErlangList) tuple.elementAt(1);
      OtpErlangList localFuncs = (OtpErlangList) tuple.elementAt(2);

      TreeItem<ModFunc> moduleItem;

      moduleItem = new TreeItem<ModFunc>(ModFunc.toModule(moduleNameAtom));
      moduleItem.setGraphic(treeIcon(AwesomeIcon.CUBE));

      ObservableList<TreeItem<ModFunc>> modFuncs = FXCollections.observableArrayList();

      SortedList<TreeItem<ModFunc>> sortedFuncs = new SortedList<TreeItem<ModFunc>>(modFuncs);

      FilteredList<TreeItem<ModFunc>> filteredFuncs =
          new FilteredList<TreeItem<ModFunc>>(sortedFuncs);

      sortedFuncs.setComparator(treeItemModFuncComparator());

      isExported = true;
      addTreeItems(toModFuncs(moduleNameAtom, exportedFuncs, isExported), modFuncs);

      isExported = false;
      addTreeItems(toModFuncs(moduleNameAtom, localFuncs, isExported), modFuncs);
      functionLists.add(filteredFuncs);

      Bindings.bindContentBidirectional(moduleItem.getChildren(), filteredFuncs);

      treeModules.add(moduleItem);
    }

    TreeItem<ModFunc> root;

    root = new TreeItem<ModFunc>();
    root.setExpanded(true);

    Bindings.bindContentBidirectional(root.getChildren(), filteredTreeModules);

    modulesTree.setRoot(root);
  }
  private synchronized void loadChildren(final TreeItem<Account> parentItem) {
    parentItem
        .getValue()
        .getChildren(Comparators.getAccountByCode())
        .stream()
        .filter(typeFilter::isAccountVisible)
        .forEach(
            child -> {
              TreeItem<Account> childItem = new TreeItem<>(child);
              childItem.setExpanded(true);

              parentItem.getChildren().add(childItem);

              if (child.getChildCount() > 0) {
                loadChildren(childItem);
              }
            });
  }
  private TreeItem<ProjectFile> buildTreeItem(ProjectFile projectFile, int level) {

    TreeItem<ProjectFile> treeItem = new TreeItem<ProjectFile>(projectFile);

    treeItem.setExpanded((level < 2));

    // Has children ?
    File treeItemFile = projectFile.getFile();
    if (treeItemFile.isDirectory()) {
      File[] files = treeItemFile.listFiles();
      if (files != null) {
        for (File childFile : files) {
          ProjectFile childProjectFile = new ProjectFile(childFile);
          TreeItem<ProjectFile> item = buildTreeItem(childProjectFile, level + 1);
          treeItem.getChildren().add(item);
        }
      }
    }
    return treeItem;
  }
  private void redoTree() {
    if (study == null) {
      log.warn("Not redoing tree, since study is null");
      return;
    }

    log.trace("Redoing project tree");

    TreeItem root = new TreeItem(DisplayWrapper.of(study.getName()));

    TreeItem<DisplayWrapper<Node>> subjectNode = createTreeItem(study.getSubjects());
    TreeItem<DisplayWrapper<Node>> actionNode = createTreeItem(study.getActions());
    TreeItem<DisplayWrapper<Node>> modifierFactoryNode =
        createTreeItem(study.getModifierFactories());
    TreeItem<DisplayWrapper<Node>> observationsNode = createTreeItem(study.getObservations());

    root.getChildren().addAll(subjectNode, actionNode, modifierFactoryNode, observationsNode);
    root.setExpanded(true);

    setRoot(root);
  }
  private TreeTableView<ITreeNode> createTreeTableView(ProfileContainer container) {

    final List<Profile> profiles = container.getProfiles();
    final MyTreeNode rootNode = new MyTreeNode(null);
    for (Profile p : profiles) {
      final MyTreeNode profileNode = new MyTreeNode(p);
      rootNode.addChild(profileNode);

      profileNode.addChild(createTreeNodes(p.getTopLevelMethod()));
    }

    final MyTreeModel model = new MyTreeModel(rootNode, new MethodStatsHelper(container));

    final TreeItem<ITreeNode> root = model.toTreeItems();
    root.setExpanded(true);

    final TreeTableView<ITreeNode> treeTableView = new TreeTableView<>(root);

    for (int i = 0; i < model.getColumnCount(); i++) {
      final int columnNo = i;
      final TreeTableColumn<ITreeNode, String> newColumn =
          new TreeTableColumn<>(model.getColumnName(i));

      newColumn.setCellValueFactory(
          new Callback<
              TreeTableColumn.CellDataFeatures<ITreeNode, String>, ObservableValue<String>>() {

            @Override
            public ObservableValue<String> call(CellDataFeatures<ITreeNode, String> param) {
              return new ReadOnlyStringWrapper(
                  model.getValue(param.getValue().getValue(), columnNo));
            }
          });
      treeTableView.getColumns().add(newColumn);
    }

    treeTableView.setShowRoot(false);
    return treeTableView;
  }
  public void displayPackageTree() {
    if (controller.getPackageTree() != null) {
      view.getArtifactTreeView()
          .setRoot(
              buildTree(
                  controller.getPackageTree(),
                  view.getShowIgnored().selectedProperty().getValue()));
      view.getRoot().setExpanded(true);
      sortTree(view.getRoot());
      expandedNodes
          .stream()
          .filter(nodeID -> nodeID != null)
          .forEach(
              nodeID -> {
                TreeItem<?> expandedItem = findItem(view.getRoot(), nodeID);

                if (expandedItem != null) {
                  expandedItem.setExpanded(true);
                }
              });
    }
  }
  /**
   * remplit la TreeView sur le cote gauche avec la liste des fichiers de ".git/objects"
   *
   * @param gitDirectory dossier ".git"
   */
  public void addObjectsFiles(File gitDirectory) {

    // on vide la liste pour en refaire une nouvelle
    rootTreeListeFichiers.getChildren().clear();

    File gitObjectsDirectory = new File(gitDirectory, "objects");

    // on assigne le chemin "nomDepot/.git/objects" a l'item racine
    String[] pathDirectories =
        gitObjectsDirectory.getAbsolutePath().split(Pattern.quote(File.separator));

    String rootValue = pathDirectories[pathDirectories.length - 3];

    for (int i = pathDirectories.length - 2; i < pathDirectories.length; i++) {
      rootValue += File.separator + pathDirectories[i];
    }
    rootTreeListeFichiers.setValue(rootValue);

    // liste des dossiers deroulee par defaut
    rootTreeListeFichiers.setExpanded(true);

    File[] gitObjectsSubDirectories = gitObjectsDirectory.listFiles();

    // pour chaque dossier dans objects on ajoute un item
    for (File gitObjectsSubDirectory : gitObjectsSubDirectories) {

      TreeItem<String> subDirectoryItem = new TreeItem<>(gitObjectsSubDirectory.getName());

      File[] gitObjects = gitObjectsSubDirectory.listFiles();

      // ajout de la liste des fichiers de ce dossier
      for (File gitObject : gitObjects) {
        TreeItem<String> objectItem = new TreeItem<>(gitObject.getName());
        subDirectoryItem.getChildren().add(objectItem);
      }

      rootTreeListeFichiers.getChildren().add(subDirectoryItem);
    }
  }
  /**
   * remplit la TreeView sur le cote gauche avec la liste de GitObject du modele
   *
   * @param objects liste des objets git
   */
  public void addListObjects(ArrayList<GitObject> objects) {

    // on vide la liste pour en refaire une nouvelle
    for (TreeItem<String> itemObjectType : rootTreeListeFichiers.getChildren()) {

      itemObjectType.getChildren().clear();
    }

    for (GitObject object : objects) {

      for (int i = 0; i < this.types.length; i++) {

        if (this.types[i].contains(object.getClass().getSimpleName())) {

          TreeItem<String> item = new TreeItem<>(object.getName());
          objectsType.get(i).getChildren().add(item);
        }
      }
    }

    rootTreeListeFichiers.setExpanded(true);
  }
  public void selectByGitObject(GitObject _selectedObject) {

    //        System.out.println( "selected : " + _selectedObject.getClass().getSimpleName() );

    for (TreeItem<String> treeItem : objectsType) {

      if (treeItem.getValue().equals(_selectedObject.getClass().getSimpleName() + "s")) {

        treeItem.setExpanded(true);

        for (TreeItem<String> treeItem1 : treeItem.getChildren()) {

          if (treeItem1.getValue().equals(_selectedObject.getName())) {

            getSelectionModel().select(treeItem1);

            break;
          }
        }
        break;
      }
    }
  }
  public void initTreeView() {
    TreeItem<TreeObj> rootItem1 = new TreeItem<TreeObj>(new TreeObj("root", 123));

    for (DbConfiguration dbc : Context.DbList.getDbConfigurations()) {

      TreeNode<TreeObj> leaf1 = new TreeNode<TreeObj>(new TreeObj(dbc.getName(), new ConnObj(dbc)));
      leaf1.setGraphic(new ImageView(Context.Icon_Connector));
      leaf1.setExpanded(true);

      rootItem1.getChildren().add(leaf1);
    }
    rootItem1.setExpanded(true);

    treeView.setRoot(rootItem1);
    treeView.setEditable(false);
    treeView.setCellFactory(
        new Callback<TreeView<TreeObj>, TreeCell<TreeObj>>() {
          @Override
          public TreeCell<TreeObj> call(TreeView<TreeObj> p) {
            return new TextFieldTreeCellImpl();
          }
        });
  }
  private void processWithGrouping(List<TaskWithWorklogs> tasks, DisplayData displayData) {
    LOGGER.debug("Processing with grouping");
    List<String> distinctGroupByCriteria =
        tasks
            .stream()
            .map(TaskWithWorklogs::getDistinctGroupByCriteriaValues)
            .flatMap(Collection::stream)
            .distinct()
            .sorted(COLLATOR)
            .collect(Collectors.toList());

    distinctGroupByCriteria.forEach(
        groupByCriteria -> {
          LOGGER.debug("Gathering data for group criteria value {}", groupByCriteria);
          DisplayRow groupCaptionRow = new DisplayRow();
          groupCaptionRow.setIsGroupContainer(true);
          groupCaptionRow.setLabel(groupByCriteria);

          TreeItem<DisplayRow> groupRow = new TreeItem<>(groupCaptionRow);
          groupRow.setExpanded(true);
          Map<String, DisplayRow> ticketIdToDisplayRow = Maps.newHashMap();

          // add sub rows to groupRow
          tasks
              .stream()
              .filter(
                  taskWithWorklogs ->
                      taskWithWorklogs.getDistinctGroupByCriteriaValues().contains(groupByCriteria))
              .sorted((o1, o2) -> COLLATOR.compare(o1.getIssue(), o2.getIssue()))
              .forEach(
                  taskWithWorklogs -> {
                    // this task with worklogs contains at least one workitem
                    // having the group by criteria

                    DisplayRow ticketRowWithinThisGroup =
                        ticketIdToDisplayRow.get(taskWithWorklogs.getIssue());
                    if (ticketRowWithinThisGroup == null) {
                      ticketRowWithinThisGroup = new DisplayRow();
                      ticketRowWithinThisGroup.setLabel(taskWithWorklogs.getSummary());
                      ticketRowWithinThisGroup.setIssueId(taskWithWorklogs.getIssue());
                      ticketRowWithinThisGroup.setResolvedDate(taskWithWorklogs.getResolved());
                      groupRow.getChildren().add(new TreeItem<>(ticketRowWithinThisGroup));
                      ticketIdToDisplayRow.put(
                          taskWithWorklogs.getIssue(), ticketRowWithinThisGroup);
                    }

                    DisplayRow ticketRowWithinThisGroupAsFinal = ticketRowWithinThisGroup;

                    taskWithWorklogs
                        .getWorklogItemList()
                        .stream()
                        .filter(
                            worklogItem ->
                                StringUtils.equals(worklogItem.getGroup(), groupByCriteria))
                        .sorted((o1, o2) -> o1.getDate().compareTo(o2.getDate()))
                        .forEach(
                            worklogItem -> {
                              // this worklog item matches the critera
                              // add workday entry to current row
                              LocalDate date = worklogItem.getDate();

                              DisplayDayEntry workdayEntry =
                                  ticketRowWithinThisGroupAsFinal
                                      .getWorkdayEntry(date)
                                      .orElseGet(
                                          () -> {
                                            DisplayDayEntry displayDayEntry = new DisplayDayEntry();
                                            displayDayEntry.setDate(date);
                                            ticketRowWithinThisGroupAsFinal.addDisplayDayEntry(
                                                displayDayEntry);

                                            return displayDayEntry;
                                          });

                              workdayEntry
                                  .getSpentTime()
                                  .addAndGet(worklogItem.getDurationInMinutes());

                              // also add up the spent time in the group header per group
                              workdayEntry =
                                  groupCaptionRow
                                      .getWorkdayEntry(date)
                                      .orElseGet(
                                          () -> {
                                            DisplayDayEntry newWorkdayEntry = new DisplayDayEntry();
                                            newWorkdayEntry.setDate(date);
                                            groupCaptionRow.addDisplayDayEntry(newWorkdayEntry);
                                            return newWorkdayEntry;
                                          });
                              workdayEntry
                                  .getSpentTime()
                                  .addAndGet(worklogItem.getDurationInMinutes());
                            });
                  });

          // add groupRow to result
          displayData.addRow(groupRow);
        });
  }
 /**
  * Creates a default branch with given value, expanded controlled by flag.
  *
  * @param value
  * @param expanded
  * @return
  */
 protected TreeItem createBranch(Object value, boolean expanded) {
   TreeItem item = createItem(value);
   item.getChildren().setAll(createTreeItems(rawItems));
   item.setExpanded(expanded);
   return item;
 }
  public ErgebnisListe(Urne urne) {
    // Reset der Listenstimmen
    for (Liste l : Wahl.getInstance().getListen()) {
      l.resetStimmenTemp();
      l.resetStimmenTemp2();

      for (Kandidat k : l.getKandidaten()) {
        k.resetStimmenTemp();
      }
    }

    for (Ergebnis ergebnis : Wahl.getInstance().getErgebnisse()) {
      // Wenn spezielle Urne ausgewählt, andere auslassen
      if (urne != null && ergebnis.getUrne() != urne) continue;

      stimmenGesamt += ergebnis.getStimmenGesamt();
      stimmenUngueltig += ergebnis.getStimmenUngueltig();
      stimmenGueltig += ergebnis.getStimmenGueltig();
      stimmenEnthaltung += ergebnis.getStimmenEnthaltung();

      for (Listenergebnis lerg : ergebnis.getListenergebnisse()) {
        lerg.getListe().addStimmenTemp(lerg.getGesamtstimmen());
        lerg.getListe().addStimmenTemp2(lerg.getListenstimmen());

        for (Kandidatenergebnis kerg : lerg.getKandidatenergebnisse()) {
          kerg.getKandidat().addStimmenTemp(kerg.getStimmen());
        }
      }
    }

    TreeItem<ErgebnisEintrag> basis =
        new TreeItem<>(
            new ErgebnisEintrag("BASISDATEN: Anzahl der abgegebenen Stimmen", stimmenGesamt));
    basis.setExpanded(true);
    root.getChildren().add(basis);

    basis.getChildren().add(new TreeItem<>(new ErgebnisEintrag("Gültige Stimmen", stimmenGueltig)));
    basis
        .getChildren()
        .add(new TreeItem<>(new ErgebnisEintrag("Ungültige Stimmen", stimmenUngueltig)));
    basis.getChildren().add(new TreeItem<>(new ErgebnisEintrag("Enthaltungen", stimmenEnthaltung)));

    for (Liste l : Wahl.getInstance().getListen()) {
      TreeItem<ErgebnisEintrag> litem =
          new TreeItem<>(
              new ErgebnisEintrag(
                  "LISTE " + l.getNummer() + ": " + l.getName(), l.getStimmenTemp()));
      litem.setExpanded(true);

      TreeItem<ErgebnisEintrag> litem2 =
          new TreeItem<>(new ErgebnisEintrag("LISTENSTIMMEN", l.getStimmenTemp2()));
      litem.getChildren().add(litem2);

      for (Kandidat k : l.getKandidaten()) {
        TreeItem<ErgebnisEintrag> kitem =
            new TreeItem<>(new ErgebnisEintrag(k.getName(), k.getStimmenTemp()));
        litem.getChildren().add(kitem);
      }

      root.getChildren().add(litem);
    }
  }
 private TreeItem<String> setupNode(TreeItem<String> node, String content) {
   node = new TreeItem<>(content);
   node.setExpanded(true);
   dummyRoot.getChildren().add(node);
   return node;
 }
  /** *************************File Creation************************** */
  @FXML
  private void CreateFile() throws SQLException {
    boolean isExist = false;

    if (Objects.equals(currProjectName, "") || selected == null) {
      warning("Can't create file under the main project");
    } else if (selected.getValue().isProject()) {
      TextInputDialog dialog = new TextInputDialog("");
      dialog.setTitle("Create File");
      dialog.setHeaderText("File");
      dialog.setContentText("Please enter the file name:");
      Optional<String> result = dialog.showAndWait();

      if (result.isPresent()) {
        final String inputFileName = result.get();

        String query =
            "SELECT pfname FROM PFiles WHERE pid like '" + currPID + "' AND pdid IS NULL";
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(query);

        while (rs.next()) {
          String tempName = rs.getString("pfname");
          if (Objects.equals(tempName, inputFileName)) {
            isExist = true;
            break;
          }
        }
        if (isExist == true) {
          warning("File name already exist.");
        } else {
          query =
              "INSERT INTO PFiles(pfname, pid,creatorID) VALUE('"
                  + inputFileName
                  + "','"
                  + currPID
                  + "','"
                  + MyuserID
                  + "')";
          st = conn.createStatement();
          st.executeUpdate(query);
          query = "SELECT LAST_INSERT_ID()";
          rs = st.executeQuery(query);
          if (rs.next()) {
            int currID = rs.getInt("LAST_INSERT_ID()");
            CheckBoxTreeItem<StrucTree> temptreeItem = new CheckBoxTreeItem<>();
            temptreeItem.setValue(new StrucTree("f", inputFileName, currID));
            selected.getChildren().add(temptreeItem);
            selected.setExpanded(true);
            iniFile(temptreeItem);
          }
        }
      }
    } else if (selected.getValue().isFile()) {

      TextInputDialog dialog = new TextInputDialog("");
      dialog.setTitle("Create File");
      dialog.setHeaderText("File");
      dialog.setContentText("Please enter the file name:");
      Optional<String> result = dialog.showAndWait();

      if (result.isPresent()) {
        final String inputFileName = result.get();
        String query = "";
        if (selected.getParent().getValue().isProject()) {
          query = "SELECT pfname FROM PFiles where pid like '" + currPID + "' AND pdid IS NULL";
        } else {
          query =
              "SELECT pfname FROM PFiles where pid like '"
                  + currPID
                  + "' AND pdid LIKE '"
                  + selected.getParent().getValue().getID()
                  + "'";
        }
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(query);

        while (rs.next()) {
          String tempName = rs.getString("pfname");
          if (Objects.equals(tempName, inputFileName)) {
            isExist = true;
            break;
          }
        }
        if (isExist == true) {
          warning("File name already exist.");

        } else {
          if (selected.getParent().getValue().isProject()) {
            query =
                "INSERT INTO PFiles(pfname, pid,creatorID) VALUE('"
                    + inputFileName
                    + "','"
                    + currPID
                    + "','"
                    + MyuserID
                    + "')";
          } else {
            query =
                "INSERT INTO PFiles(pfname, pid, pdid,creatorID) VALUE('"
                    + inputFileName
                    + "','"
                    + currPID
                    + "','"
                    + selected.getParent().getValue().getID()
                    + "','"
                    + MyuserID
                    + "')";
          }
          st = conn.createStatement();
          st.executeUpdate(query);
          query = "SELECT LAST_INSERT_ID()";
          rs = st.executeQuery(query);
          if (rs.next()) {
            int currID = rs.getInt("LAST_INSERT_ID()");
            CheckBoxTreeItem<StrucTree> temptreeItem = new CheckBoxTreeItem<>();
            if (selected.getParent().getValue().isProject()) {
              temptreeItem.setValue(new StrucTree("f", inputFileName, currID));
            } else {
              temptreeItem.setValue(
                  new StrucTree(
                      "f", inputFileName, currID, selected.getParent().getValue().getID()));
            }
            selected.getParent().getChildren().add(temptreeItem);
            selected.getParent().setExpanded(true);
            iniFile(temptreeItem);
          }
        }
      }
    } else if (selected.getValue().isDirectory()) {
      TextInputDialog dialog = new TextInputDialog("");
      dialog.setTitle("Create File");
      dialog.setHeaderText("File");
      dialog.setContentText("Please enter the file name:");
      Optional<String> result = dialog.showAndWait();

      if (result.isPresent()) {
        final String inputFileName = result.get();
        String query =
            "SELECT pfname FROM PFiles where pid like '"
                + currPID
                + "' AND pdid LIKE '"
                + selected.getValue().getID()
                + "'";

        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(query);

        while (rs.next()) {
          String tempName = rs.getString("pfname");
          if (Objects.equals(tempName, inputFileName)) {
            isExist = true;
            break;
          }
        }
        if (isExist == true) {
          warning("File name already exist.");
        } else {
          query =
              "INSERT INTO PFiles(pfname, pid, pdid,creatorID) VALUE('"
                  + inputFileName
                  + "','"
                  + currPID
                  + "','"
                  + selected.getValue().getID()
                  + "','"
                  + MyuserID
                  + "')";
          st = conn.createStatement();
          st.executeUpdate(query);
          query = "SELECT LAST_INSERT_ID()";
          rs = st.executeQuery(query);
          if (rs.next()) {
            int currID = rs.getInt("LAST_INSERT_ID()");
            CheckBoxTreeItem<StrucTree> temptreeItem = new CheckBoxTreeItem<>();
            temptreeItem.setValue(
                new StrucTree("f", inputFileName, currID, selected.getValue().getID()));
            selected.getChildren().add(temptreeItem);
            selected.setExpanded(true);
            iniFile(temptreeItem);
          }
        }
      }
    }
  }