Example #1
0
 @Override
 public void handle(MouseEvent event) {
   // TODO Auto-generated method stub
   if (event.getClickCount() == 2) {
     subirElementos();
   }
 }
 /*     */ public void handle(MouseEvent paramAnonymousMouseEvent) {
   /* 270 */ Rectangle localRectangle1 = (Rectangle) paramAnonymousMouseEvent.getSource();
   /* 271 */ TableColumn localTableColumn =
       (TableColumn) localRectangle1.getProperties().get("TableColumn");
   /* 272 */ NestedTableColumnHeader localNestedTableColumnHeader =
       (NestedTableColumnHeader) localRectangle1.getProperties().get("TableColumnHeader");
   /*     */
   /* 274 */ if (!localNestedTableColumnHeader.isColumnResizingEnabled()) return;
   /*     */
   /* 276 */ if ((paramAnonymousMouseEvent.getClickCount() == 2)
       && (paramAnonymousMouseEvent.isPrimaryButtonDown()))
   /*     */ {
     /* 279 */ localNestedTableColumnHeader.resizeToFit(localTableColumn, -1);
     /*     */ }
   /*     */ else
   /*     */ {
     /* 283 */ Rectangle localRectangle2 = (Rectangle) paramAnonymousMouseEvent.getSource();
     /* 284 */ double d =
         localNestedTableColumnHeader
                 .getTableHeaderRow()
                 .sceneToLocal(
                     localRectangle2.localToScene(localRectangle2.getBoundsInLocal()))
                 .getMinX()
             + 2.0D;
     /* 285 */ localNestedTableColumnHeader.dragAnchorX =
         paramAnonymousMouseEvent.getSceneX();
     /* 286 */ localNestedTableColumnHeader.columnResizingStarted(d);
     /*     */ }
   /* 288 */ paramAnonymousMouseEvent.consume();
   /*     */ }
 @FXML
 void onMouseClickGameStatus(MouseEvent mouseEvent) {
   GameStatus gameStatus = playerInfoBean.getGameStatus();
   if (gameStatus == GameStatus.NONE) {
     return;
   }
   if (mouseEvent.getButton() == MouseButton.PRIMARY && mouseEvent.getClickCount() == 2) {
     int uid = playerInfoBean.getGameUid();
     if (gameStatus == GameStatus.LOBBY || gameStatus == GameStatus.HOST) {
       GameInfoBean gameInfoBean = gameService.getByUid(uid);
       gamesController.onJoinGame(
           gameInfoBean, null, mouseEvent.getScreenX(), mouseEvent.getScreenY());
     } else if (gameStatus == GameStatus.PLAYING) {
       try {
         replayService.runLiveReplay(uid, playerInfoBean.getUsername());
       } catch (IOException e) {
         notificationService.addNotification(
             new ImmediateNotification(
                 i18n.get("errorTitle"),
                 i18n.get("replayCouldNotBeStarted.text"),
                 Severity.ERROR,
                 e,
                 singletonList(new ReportAction(i18n, reportingService, e))));
       }
     }
   }
 }
  private void handleMouseEvent(MouseEvent me) {
    // Handle cursor
    final Scene scene = getScene();

    if (scene == null) {
      return;
    }

    // When another window is focused (just like the preview window),
    // we use default cursor
    if (scene.getWindow() != null && !scene.getWindow().isFocused()) {
      setCursor(Cursor.DEFAULT);
      return;
    }

    final LibraryListItem listItem = getItem();
    ILibraryItem item = null;

    if (listItem != null) {
      item = listItem.getLibItem();
    }

    boolean isSection = false;
    if (listItem != null && listItem.getSectionName() != null) {
      isSection = true;
    }

    if (me.getEventType() == MouseEvent.MOUSE_ENTERED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.OPEN_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_PRESSED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.CLOSED_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_RELEASED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.OPEN_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_EXITED) {
      setCursor(Cursor.DEFAULT);
    } else if (me.getEventType() == MouseEvent.MOUSE_CLICKED) {
      // On double click ask for addition of the drag able item on Content
      if (me.getClickCount() == 2 && me.getButton() == MouseButton.PRIMARY) {
        if (!isEmpty() && !isSection && item != null) {
          if (editorController.canPerformInsert(item)) {
            editorController.performInsert(item);
          }
        }
      }
    }
  }
Example #5
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();
       }
     }
   }
 }
  /**
   * Click and Hold to make window draggable
   *
   * @param event
   */
  public void handleAppMouseClick_Hold(MouseEvent event) {

    Stage stage = OnlineQuizzingApp.getInstance().getStage();

    xOffset = event.getSceneX();
    yOffset = event.getSceneY();

    if (event.getButton().equals(MouseButton.PRIMARY)) {
      if (event.getClickCount() == 2) {
        if (stage.isFullScreen()) {
          stage.setFullScreen(false);
        } else {
          stage.setFullScreen(true);
        }
      }
    }
  }
 @FXML
 void onUsernameClicked(MouseEvent mouseEvent) {
   if (mouseEvent.getButton() == MouseButton.PRIMARY && mouseEvent.getClickCount() == 2) {
     chatController.openPrivateMessageTabForUser(playerInfoBean.getUsername());
   }
 }
Example #8
0
  @Override
  public void handle(MouseEvent event) {
    if (event.getEventType() == MouseEvent.MOUSE_PRESSED) {
      if (dockNode.isFloating()
          && event.getClickCount() == 2
          && event.getButton() == MouseButton.PRIMARY) {
        dockNode.setMaximized(!dockNode.isMaximized());
      } else {
        // drag detected is used in place of mouse pressed so there is some threshold for the
        // dragging which is determined by the default drag detection threshold
        dragStart = new Point2D(event.getX(), event.getY());
      }
    } else if (event.getEventType() == MouseEvent.DRAG_DETECTED) {
      if (!dockNode.isFloating()) {
        // if we are not using a custom title bar and the user
        // is not forcing the default one for floating and
        // the dock node does have native window decorations
        // then we need to offset the stage position by
        // the height of this title bar
        if (!dockNode.isCustomTitleBar() && dockNode.isDecorated()) {
          dockNode.setFloating(true, new Point2D(0, DockTitleBar.this.getHeight()));
        } else {
          dockNode.setFloating(true);
        }

        // TODO: Find a better solution.
        // Temporary work around for nodes losing the drag event when removed from
        // the scene graph.
        // A possible alternative is to use "ghost" panes in the DockPane layout
        // while making DockNode simply an overlay stage that is always shown.
        // However since flickering when popping out was already eliminated that would
        // be overkill and is not a suitable solution for native decorations.
        // Bug report open: https://bugs.openjdk.java.net/browse/JDK-8133335
        DockPane dockPane = this.getDockNode().getDockPane();
        if (dockPane != null) {
          dockPane.addEventFilter(MouseEvent.MOUSE_DRAGGED, this);
          dockPane.addEventFilter(MouseEvent.MOUSE_RELEASED, this);
        }
      } else if (dockNode.isMaximized()) {
        double ratioX = event.getX() / this.getDockNode().getWidth();
        double ratioY = event.getY() / this.getDockNode().getHeight();

        // Please note that setMaximized is ruined by width and height changes occurring on the
        // stage and there is currently a bug report filed for this though I did not give them an
        // accurate test case which I should and wish I would have. This was causing issues in the
        // original release requiring maximized behavior to be implemented manually by saving the
        // restored bounds. The problem was that the resize functionality in DockNode.java was
        // executing at the same time canceling the maximized change.
        // https://bugs.openjdk.java.net/browse/JDK-8133334

        // restore/minimize the window after we have obtained its dimensions
        dockNode.setMaximized(false);

        // scale the drag start location by our restored dimensions
        dragStart = new Point2D(ratioX * dockNode.getWidth(), ratioY * dockNode.getHeight());
      }
      dragging = true;
      event.consume();
    } else if (event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
      if (dockNode.isFloating()
          && event.getClickCount() == 2
          && event.getButton() == MouseButton.PRIMARY) {
        event.setDragDetect(false);
        event.consume();
        return;
      }

      if (!dragging) return;

      Stage stage = dockNode.getStage();
      Insets insetsDelta = this.getDockNode().getBorderPane().getInsets();

      // dragging this way makes the interface more responsive in the event
      // the system is lagging as is the case with most current JavaFX
      // implementations on Linux
      stage.setX(event.getScreenX() - dragStart.getX() - insetsDelta.getLeft());
      stage.setY(event.getScreenY() - dragStart.getY() - insetsDelta.getTop());

      // TODO: change the pick result by adding a copyForPick()
      DockEvent dockEnterEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_ENTER,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);
      DockEvent dockOverEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_OVER,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);
      DockEvent dockExitEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_EXIT,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);

      EventTask eventTask =
          new EventTask() {
            @Override
            public void run(Node node, Node dragNode) {
              executions++;

              if (dragNode != node) {
                Event.fireEvent(node, dockEnterEvent.copyFor(DockTitleBar.this, node));

                if (dragNode != null) {
                  // fire the dock exit first so listeners
                  // can actually keep track of the node we
                  // are currently over and know when we
                  // aren't over any which DOCK_OVER
                  // does not provide
                  Event.fireEvent(dragNode, dockExitEvent.copyFor(DockTitleBar.this, dragNode));
                }

                dragNodes.put(node.getScene().getWindow(), node);
              }
              Event.fireEvent(node, dockOverEvent.copyFor(DockTitleBar.this, node));
            }
          };

      this.pickEventTarget(
          new Point2D(event.getScreenX(), event.getScreenY()), eventTask, dockExitEvent);
    } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) {
      dragging = false;

      DockEvent dockReleasedEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_RELEASED,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null,
              this.getDockNode());

      EventTask eventTask =
          new EventTask() {
            @Override
            public void run(Node node, Node dragNode) {
              executions++;
              if (dragNode != node) {
                Event.fireEvent(node, dockReleasedEvent.copyFor(DockTitleBar.this, node));
              }
              Event.fireEvent(node, dockReleasedEvent.copyFor(DockTitleBar.this, node));
            }
          };

      this.pickEventTarget(new Point2D(event.getScreenX(), event.getScreenY()), eventTask, null);

      dragNodes.clear();

      // Remove temporary event handler for bug mentioned above.
      DockPane dockPane = this.getDockNode().getDockPane();
      if (dockPane != null) {
        dockPane.removeEventFilter(MouseEvent.MOUSE_DRAGGED, this);
        dockPane.removeEventFilter(MouseEvent.MOUSE_RELEASED, this);
      }
    }
  }
Example #9
0
 private boolean isDoubleClick(MouseEvent e) {
   return e.getButton() == MouseButton.PRIMARY && e.getClickCount() == 2;
 }
Example #10
0
  /** *************************Selection Tasks************************** */
  @FXML
  private void file_select(MouseEvent mouse) throws SQLException {
    TreeItem<StrucTree> item = structure_tree.getSelectionModel().getSelectedItem();

    if (mouse.getClickCount() == 1 && item != null) {
      selected = item;

      if (item.getValue().isProject()) {
        info.setText(
            " [Project: "
                + item.getValue().toString()
                + "]  [ID: "
                + item.getValue().getID()
                + "]");
      } else if (item.getValue().isDirectory()) {
        info.setText(
            " [Directory: "
                + item.getValue().toString()
                + "]   [ID: "
                + item.getValue().getID()
                + "]  [Parent ID: "
                + item.getValue().getPID()
                + "]");
      } else if (item.getValue().isFile()) {
        String query = "SELECT * FROM PFiles WHERE pfid like '" + item.getValue().getID() + "'";
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(query);
        if (rs.next()) {
          if (rs.getInt("creatorID") == 0) {
            info.setText(
                " [File: "
                    + item.getValue().toString()
                    + "]  [ID: "
                    + item.getValue().getID()
                    + "]  [Created Time: "
                    + rs.getTimestamp("timeCreated")
                    + "]");
          } else {
            query = "SELECT userName from Users WHERE userID like '" + rs.getInt("creatorID") + "'";
            Statement st1 = conn.createStatement();
            ResultSet rs1 = st1.executeQuery(query);
            if (rs1.next()) {
              info.setText(
                  " [File: "
                      + item.getValue().toString()
                      + "]  [ID: "
                      + item.getValue().getID()
                      + "]  [Creator: "
                      + rs1.getString("userName")
                      + "]  [Created Time: "
                      + rs.getTimestamp("timeCreated")
                      + "]");
            }
          }
        }
      } else {
        info.setText(" *sQuire Project Menu*");
      }

      if (Objects.equals(currProjectName, "")) {
        curr_position.setText(item.getValue().toString());
      } else {
        curr_position.setText(getCurrPosition(item));
      }
    }
    if (mouse.getClickCount() == 2 && item != null) {
      selected = item;
      curr_position.setText(item.getValue().toString());

      if (currPID == 0 && !Objects.equals(item.getValue().toString(), "sQuire Project")) {
        currProjectName = item.getValue().toString();

        currPID = item.getValue().getID();
        setTree(null, 0);
      } else {
        curr_position.setText(getCurrPosition(item));
      }

      if (item.getValue().isFile()) {
        selectedFile = item;
        readFile(selectedFile);
      }
    }
  }
Example #11
0
 @FXML
 public void tracksViewMouseClicked(MouseEvent evt) {
   if (evt.getClickCount() == 2) {
     playSelectedTrack();
   }
 }
  @Override
  public void handle(MouseEvent click) {
    @SuppressWarnings("rawtypes")
    TablePosition pos = groupsTable.getSelectionModel().getSelectedCells().get(0);
    if (click.getClickCount() == 2) {
      groupsTable.getSelectionModel().setCellSelectionEnabled(true);
      if (pos.getColumn() == 1) {
        try {
          TableColumn<GroupModel, String> firstNameCol = pos.getTableColumn();
          firstNameCol.setCellFactory(TextFieldTableCell.<GroupModel>forTableColumn());
          firstNameCol.setOnEditCommit(
              (TableColumn.CellEditEvent<GroupModel, String> t) -> {
                GroupModel model =
                    ((GroupModel) t.getTableView().getItems().get(t.getTablePosition().getRow()));
                if (t.getNewValue().isEmpty()) {
                  emptyCheckingError();
                } else {
                  model.setGroupName(t.getNewValue());
                  DBConnector.getInstance().updateGroupModel(model);

                  dbUpdatable.onDBUpdated();
                }
              });
        } catch (ClassCastException exc) {
          System.out.println("ClassCastException ");
        }
      } else if (pos.getColumn() == 2 || pos.getColumn() == 3) {
        TableColumn<GroupModel, Integer> firstNameCol = pos.getTableColumn();
        firstNameCol.setCellFactory(TextFieldTableCell.forTableColumn(new EditStringConverter()));
        try {
          firstNameCol.setOnEditCommit(
              new EventHandler<TableColumn.CellEditEvent<GroupModel, Integer>>() {
                @Override
                public void handle(TableColumn.CellEditEvent<GroupModel, Integer> tt) {
                  int row = tt.getTablePosition().getRow();
                  int column = tt.getTablePosition().getColumn();
                  GroupModel rowModel = ((GroupModel) tt.getTableView().getItems().get(row));
                  Integer rowNewValue = tt.getNewValue().intValue();
                  if (tt.getNewValue() == 0) {
                    emptyCheckingError();
                  } else if ((tt.getNewValue().getClass().isPrimitive())) {
                    // TODO: 1/4/2016
                    invalidDigitValue(tt.getNewValue().toString());
                  } else {
                    switch (column) {
                      case 2:
                        rowModel.setGroupYearGraduate(rowNewValue);
                        break;
                      case 3:
                        rowModel.setVillageElderId(rowNewValue);
                        break;
                    }
                    DBConnector.getInstance().updateGroupModel(rowModel);

                    dbUpdatable.onDBUpdated();
                  }
                }
              });
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }