/** *************************Get Initial File Line************************** */
 private void getIniLine(TreeItem<StrucTree> item) throws SQLException {
   if (item.getValue().isFile()) {
     Statement st = conn.createStatement();
     String query = "SELECT pflhead FROM PFiles WHERE pfid LIKE '" + item.getValue().getID() + "'";
     ResultSet rs = st.executeQuery(query);
     if (rs.next()) {
       item.getValue().setLine(rs.getInt("pflhead"));
     }
   }
 }
  /** *************************Read File Data************************** */
  private void readFile(TreeItem<StrucTree> item) throws SQLException {
    StringBuilder pos = new StringBuilder("");

    if (item.getValue().isFile()
        && (Objects.equals(tempFileData, "") || tempFileId != item.getValue().getID())) {
      //    		System.out.println(getLine(item.getValue().getLine(),pos).toString());
      tempFileData = getLine(item.getValue().getLine(), pos).toString();
      tempFileId = item.getValue().getID();
      fileData.setText(tempFileData);
    }
  }
 /**
  * TreeViewで板を選択する。
  *
  * <p>仮実装で二階層まで対応
  *
  * @param board
  */
 public void setSelection(Board board) {
   TreeItem<Board> root = boardTreeView.getRoot();
   for (TreeItem<Board> boardItem1 : root.getChildren()) {
     for (TreeItem<Board> boardItem2 : boardItem1.getChildren()) {
       if (boardItem2.getValue() != null
           && boardItem2.getValue().getId() != null
           && boardItem2.getValue().getId().equals(board.getId())) {
         boardTreeView.getSelectionModel().select(boardItem2);
       }
     }
   }
 }
  /**
   * 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 writeClipMenuItemChildren(TreeItem<Clip> parentTreeItem, Menu parentMenu) {
   List<TreeItem<Clip>> children = parentTreeItem.getChildren();
   for (TreeItem<Clip> child : children) {
     if (child.getValue().isGroup()) {
       Menu menu = new Menu(child.getValue().getName());
       parentMenu.getItems().add(menu);
       writeClipMenuItemChildren(child, menu);
     } else {
       MenuItem menuItem = new MenuItem(child.getValue().getName());
       parentMenu.getItems().add(menuItem);
       menuItem.setOnAction(
           event -> {
             insertClip(child.getValue());
           });
     }
   }
 }
  /** *************************Display Current Position************************** */
  private String getCurrPosition(TreeItem<StrucTree> item) {
    StringBuilder pos = new StringBuilder(currProjectName);
    if (!selected.getValue().isProject()) {
      printpath(item, pos);
    }

    return pos.toString();
  }
  /**
   * Expands all items in the tree by mapping all of the items inside of it to true, and then
   * restoring the map state from the dictionary
   *
   * @param tree The tree to expand all items of
   */
  public static void expandAll(TreeViewWithItems<SaharaItem> tree) {
    /*for (TreeItem<SaharaItem> item : tree.getTreeItems()) {
        collapseMap.put(item.getValue(), Boolean.TRUE);
    }*/

    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);
      }
      collapseParentMap.put(entry, Boolean.TRUE);
    }

    restoreMap(tree);
  }
  private Optional<Account> getSelectedAccount() {
    final TreeItem<Account> treeItem = treeTableView.getSelectionModel().getSelectedItem();

    if (treeItem != null) {
      return Optional.ofNullable(treeItem.getValue());
    }

    return Optional.empty();
  }
  /**
   * Refreshes the mapping of the tree items and if they are expanded or not.
   *
   * @param tree The tree to map items for
   */
  public static void refreshMap(TreeViewWithItems<SaharaItem> tree) {
    /*for (TreeItem<SaharaItem> item : tree.getTreeItems()) {
        //System.out.println(item + " " + item.isExpanded());
        collapseMap.put(item.getValue(), item.isExpanded());
    }*/

    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);
      }

      collapseParentMap.put(entry, item.isExpanded());
    }
  }
Exemple #10
0
  public void onDisconnectDb(ActionEvent ev) {
    TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem();
    if (selectedItem == null) {
      return;
    }

    selectedItem.getValue().getMongoConnection().close();
    removeFromRoot(selectedItem);
  }
 private StringBuilder printpath(TreeItem<StrucTree> item, StringBuilder temp) {
   if (item.getParent() != null && !item.getParent().getValue().isProject()) {
     printpath(item.getParent(), temp);
   }
   if (!Objects.equals(currProjectName, "")) {
     temp.append("/");
   }
   temp.append(item.getValue().toString());
   return temp;
 }
 /** *************************Initialize File Line************************** */
 private void iniFile(TreeItem<StrucTree> item) throws SQLException {
   if (item.getValue().isFile()) {
     Statement st = conn.createStatement();
     String query = "INSERT INTO PFLines(text) VALUE('')";
     st.executeUpdate(query);
     query = "SELECT LAST_INSERT_ID()";
     ResultSet rs = st.executeQuery(query);
     if (rs.next()) {
       int currID = rs.getInt("LAST_INSERT_ID()");
       query =
           "UPDATE PFiles SET pflhead='"
               + currID
               + "' WHERE pfid='"
               + item.getValue().getID()
               + "'";
       st.executeUpdate(query);
       item.getValue().setLine(currID);
     }
   }
 }
Exemple #13
0
 private void buildCollectionDetail(MongoDatabase db, TreeItem<DbTreeValue> ti) {
   DbTreeValue indexCategory = new DbTreeValue(db, "Indexes", TreeValueType.CATEGORY);
   indexCategory.setCollectionName(ti.getValue().getDisplayValue());
   ti.getChildren()
       .add(
           new DynamicTreeItem(
               indexCategory,
               new FontAwesomeIconView(FontAwesomeIcon.FOLDER),
               executor,
               popupService,
               this::buildIndexes));
 }
 @FXML
 public void showPassword() throws SQLException {
   if (selected == null) {
     warning("No project selected.");
   } else if (selected.getValue().isProject()) {
     System.out.println(selected.getValue().getID());
     String query = "SELECT * FROM Projects WHERE PID LIKE '" + selected.getValue().getID() + "'";
     System.out.println(query);
     Statement st = conn.createStatement();
     ResultSet rs = st.executeQuery(query);
     if (rs.next()) {
       if (rs.getInt("projectOwnerID") == MyuserID) {
         warning("Password: "******"passHash"));
       } else {
         warning("You are not the owner of this project.");
       }
     }
   } else {
     warning("No project selected.");
   }
 }
  protected TreeItem<Node> buildTree(Node node, boolean showIgnoredArtifacts) {
    final TreeItem<Node> item = new TreeItem<>(node);

    item.expandedProperty()
        .addListener(
            (observableValue, oldValue, newValue) -> {
              if (!oldValue && newValue) {
                expandedNodes.add(item.getValue().getIdentifier());
              } else if (oldValue && !newValue) {
                expandedNodes.remove(item.getValue().getIdentifier());
              }
            });

    if (node.getChildren() != null) {
      node.getChildren()
          .stream()
          .filter(child -> showIgnoredArtifacts || !child.isIgnored())
          .forEach(child -> item.getChildren().add(buildTree(child, showIgnoredArtifacts)));
    }

    return item;
  }
Exemple #16
0
 public void treeViewClicked(MouseEvent ev) {
   if (ev.getClickCount() == 2) {
     // don't process click on triangle
     EventTarget target = ev.getTarget();
     if (target instanceof Node && !"arrow".equals(((Node) target).getStyleClass())) {
       TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem();
       if (selectedItem != null
           && selectedItem.getValue().getValueType() == TreeValueType.COLLECTION) {
         mainFrameController.openTab();
         ev.consume();
       }
     }
   }
 }
  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;
      }
    }
  }
Exemple #18
0
  public void onCreateNewDb(ActionEvent ev) {
    TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem();
    if (selectedItem == null
        || selectedItem.getValue().getValueType() != TreeValueType.CONNECTION) {
      return;
    }

    TextInputDialog dialog = new TextInputDialog();
    dialog.setContentText("Enter Name:");
    dialog.setHeaderText("Create new db");
    dialog
        .showAndWait()
        .ifPresent(
            r ->
                selectedItem
                    .getChildren()
                    .add(
                        createDbItem(
                            selectedItem
                                .getValue()
                                .getMongoConnection()
                                .createMongoDB(dialog.getResult()))));
  }
 @Override
 public void changed(
     ObservableValue<? extends TreeItem<Box>> observableValue,
     TreeItem<Box> boxTreeItem,
     TreeItem<Box> boxTreeItem2) {
   if (boxTreeItem2 == null) {
     return;
   }
   String id = Path.createPath(boxTreeItem2.getValue());
   Tab t = null;
   for (Tab tab : tabPane.getTabs()) {
     if (tab.getId().equals(id)) {
       tabPane.getSelectionModel().select(tab);
       t = tab;
     }
   }
   if (t == null) {
     t = new Tab(id);
     t.setId(id);
     tabPane.getTabs().addAll(t);
     t.setContent(new BoxPane(boxTreeItem2.getValue()));
     tabPane.getSelectionModel().select(t);
   }
 }
  private TreeItem<Node> findItem(TreeItem<Node> treeNode, URI id) {
    if (treeNode.getValue().getIdentifier().equals(id)) {
      return treeNode;
    }

    for (TreeItem<Node> child : treeNode.getChildren()) {
      TreeItem<Node> result = findItem(child, id);

      if (result != null) {
        return result;
      }
    }

    return null;
  }
  private TreeItem<Node> findItem(TreeItem<Node> tree, Node node) {
    if (node.equals(tree.getValue())) {
      return tree;
    }

    for (TreeItem<Node> child : tree.getChildren()) {
      TreeItem<Node> result = findItem(child, node);

      if (result != null) {
        return result;
      }
    }

    return 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);
    }
  }
Exemple #23
0
  protected void createAndUpdateFooter() {
    Task computeThread =
        new Task() {
          @Override
          protected Object call() throws Exception {
            Set<SipPreview> sipPreviews = new HashSet<>();
            for (TreeItem<String> item : input) {
              if (item instanceof SipPreviewNode) {
                sipPreviews.add(((SipPreviewNode) item).getSip());
              } else if (item instanceof SchemaNode) {
                sipPreviews.addAll(((SchemaNode) item).getSipPreviews().keySet());
              }
            }
            sips = sipPreviews.size();
            compute(sipPreviews);
            return null;
          }
        };

    computeThread.setOnSucceeded(
        event -> {
          if (input.size() == 1) {
            TreeItem item = input.get(0);
            if (item == null) {
              Footer.setClassPlanStatus("");
              return;
            }
            sb.append(item.getValue()).append(": ");
            if (item instanceof SipPreviewNode) {
              sb.append(representations).append(" ").append("reps");
              sb.append(", ");
            } else {
              sb.append(sips).append(" SIP").append(", ");
            }
          } else {
            sb.append(input.size()).append(" ").append(I18n.t("items")).append(": ");
            sb.append(sips).append(" SIP").append(", ");
          }
          sb.append(folders).append(" ").append(I18n.t("folders"));
          sb.append(", ");
          sb.append(files).append(" ").append(I18n.t("files"));
          sb.append(", ");
          sb.append(Utils.formatSize(size));
          Footer.setClassPlanStatus(sb.toString());
        });
    new Thread(computeThread).start();
  }
  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);
              }
            });
  }
  @Override
  public void toggleItemIgnore(ObservableList<TreeItem<Node>> nodesToIgnore, boolean ignored) {
    for (TreeItem<Node> nodeToIgnore : nodesToIgnore) {
      ipmService.ignoreNode(nodeToIgnore.getValue(), ignored);

      view.getErrorLabel().setVisible(false);
    }

    // To aid in being able to unignore multiple items at once we just check the entire tree for
    // validity and then walk the tree to find types that need to be changed.
    if (!ignored
        && !getController().getDomainProfileService().validateTree(controller.getPackageTree())) {
      updateUnassignedNode(controller.getPackageTree());
    }

    // If the tree still isn't valid, try reassigning types to all nodes we changes.
    // This is almost guaranteed to never happen but is here as an ultimate safety check to ensure
    // we always have a valid tree.
    if (!ignored
        && !getController().getDomainProfileService().validateTree(controller.getPackageTree())) {

      nodesToIgnore
          .stream()
          .filter(
              nodeToIgnore ->
                  !getController()
                      .getDomainProfileService()
                      .assignNodeTypes(
                          getController().getPrimaryDomainProfile(), nodeToIgnore.getValue()))
          .forEach(
              nodeToIgnore -> {
                ipmService.ignoreNode(nodeToIgnore.getValue(), true);
                view.getErrorLabel().setText(TextFactory.getText(ErrorKey.UNIGNORE_ERROR));
                view.getErrorLabel().setVisible(true);
              });
    }

    // Rebuild the entire TreeView and reselect the previously selected nodes
    rebuildTreeView();

    for (TreeItem<Node> ignoredNode : nodesToIgnore) {
      view.getArtifactTreeView().getSelectionModel().select(ignoredNode);
    }
  }
Exemple #26
0
  private void onReanameCollection(ActionEvent actionEvent) {
    TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem();
    if (selectedItem == null) {
      return;
    }

    DbTreeValue value = selectedItem.getValue();
    TextInputDialog dialog = new TextInputDialog(value.getDisplayValue());
    dialog.setContentText("New collection name:");
    dialog.setHeaderText("Rename collection");
    dialog
        .showAndWait()
        .ifPresent(
            targetCollection -> {
              MongoCollection<Document> collection =
                  value.getMongoDatabase().getMongoDb().getCollection(value.getDisplayValue());
              collection.renameCollection(
                  new MongoNamespace(value.getMongoDatabase().getName(), targetCollection));
              ((DynamicTreeItem) selectedItem.getParent()).reload();
            });
  }
Exemple #27
0
  private void onCopyCollection(ActionEvent actionEvent) {
    TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem();
    if (selectedItem == null) {
      return;
    }

    DbTreeValue value = selectedItem.getValue();
    String sourceCollectionName = value.getDisplayValue();
    TextInputDialog dialog = new TextInputDialog(sourceCollectionName + "_copy");
    dialog.setContentText("New collection name:");
    dialog.setHeaderText("Copy collection");
    dialog
        .showAndWait()
        .ifPresent(
            targetCollection -> {
              new CopyCollectionHelper(
                      value.getMongoDatabase(), sourceCollectionName, targetCollection)
                  .copy();
              ((DynamicTreeItem) selectedItem.getParent()).reload();
              popupService.showInfo(
                  String.format(
                      "Collection %s copied to %s", sourceCollectionName, targetCollection));
            });
  }
 @Override
 public int compare(TreeItem o1, TreeItem o2) {
   return ((Comparable) o1.getValue()).compareTo(o2.getValue());
 }
 @Override
 protected TreeItem modifyItem(Object treeItem, String mod) {
   TreeItem old = (TreeItem) treeItem;
   return createItem(old.getValue() + mod);
 }
  /** *************************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);
          }
        }
      }
    }
  }