Ejemplo n.º 1
0
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    table = new TableView<>();
    data = new ProjectData();

    TableColumn idProjectCol = new TableColumn("ID");
    idProjectCol.setCellValueFactory(
        new PropertyValueFactory<ProjectDataItem, String>("IDProject"));
    idProjectCol.setCellFactory(new EditableCell());

    TableColumn nameCol = new TableColumn("Name");
    nameCol.setCellValueFactory(new PropertyValueFactory<ProjectDataItem, String>("Name"));
    nameCol.setCellFactory(new EditableCell());

    TableColumn descriptionCol = new TableColumn("Description");
    descriptionCol.setCellValueFactory(
        new PropertyValueFactory<ProjectDataItem, String>("Description"));
    descriptionCol.setCellFactory(new EditableCell());

    table.setItems(data.getData());
    table.getColumns().addAll(idProjectCol, nameCol, descriptionCol);
    table.setEditable(true);
    table.setTableMenuButtonVisible(true);
    table.setContextMenu(new ProjectFormController.ProjectContextMenu());
    table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    paneTable.getChildren().add(table);
    AnchorPane.setTopAnchor(table, 0.0);
    AnchorPane.setLeftAnchor(table, 0.0);
    AnchorPane.setRightAnchor(table, 0.0);
    AnchorPane.setBottomAnchor(table, 50.0);
  }
Ejemplo n.º 2
0
  private void setupPlaylistsView() {
    TableColumn titleColumn = new TableColumn("Title");
    titleColumn.setMinWidth(USE_COMPUTED_SIZE);
    titleColumn.setSortable(false);
    titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));

    TableColumn countColumn = new TableColumn("Tracks");
    countColumn.setMinWidth(60);
    countColumn.setMaxWidth(60);
    countColumn.setSortable(false);
    countColumn.setCellValueFactory(new PropertyValueFactory<>("count"));
    countColumn.getStyleClass().add("text-layout-right");

    playlistsView.getColumns().clear();
    playlistsView.getColumns().addAll(titleColumn, countColumn);
    playlistsView.setContextMenu(playlistsContextMenu);
    playlistsView.setPlaceholder(playlistPlaceholder);
    playlistsView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
  }
  @Override
  public Node showView() {

    Tab tab = new Tab("View Heat CHart : Search");

    try {
      VBox main = ViewLayout.getMainVBox("View Heat Chart", "Details");

      final ObservableList<HeatChartMaster> mailboxData = FXCollections.observableArrayList();
      main.getChildren()
          .addAll(SearchBoxUtil.getHeatChartSearchBox("Heat Chart Number", mailboxData));

      final TableView<HeatChartMaster> tableMailbox = TableUtil.createSearchHeatChartTable();

      main.getChildren().add(ControlsUtil.makeScrollable(tableMailbox));

      tableMailbox.setItems(mailboxData);

      tableMailbox.setOnMouseClicked(
          new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent mouseEvent) {

              if (mouseEvent.getClickCount() == 2) {

                HeatChartMaster selHeatChart = tableMailbox.getSelectionModel().getSelectedItem();
                if (selHeatChart != null) {

                  createViewTab(selHeatChart);
                }
              }
            }
          });

      EventHandler<ActionEvent> viewHeatChartEventHandler =
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent e) {

              HeatChartMaster heatChart = tableMailbox.getSelectionModel().getSelectedItem();
              if (heatChart != null) {

                createViewTab(heatChart);
              }
            }
          };

      tableMailbox.setContextMenu(
          TableContextMenu.getViewHeatChartContextMenu(viewHeatChartEventHandler));

      tab.setContent(ControlsUtil.makeScrollable(main));
      tab.setClosable(false);
      pane.getTabs().add(tab);
      pane.setSide(Side.TOP);

      return pane;
    } catch (HibernateException e) {
      LoggerUtil.getLogger().debug(e);
      Alert.showAlert(
          Context.getWindowStage(),
          "Error",
          "Error",
          "Some error occured. Details...\n" + e.getMessage());

      return new ErrorView().showView();
    } catch (MalformedURLException ex) {
      LoggerUtil.getLogger().debug(ex);
      Alert.showAlert(
          Context.getWindowStage(),
          "Error",
          "Error",
          "Some error occured. Details...\n" + ex.getMessage());

      return new ErrorView().showView();
    }
  }
Ejemplo n.º 4
0
  public EditUser() {

    Tab tab = new Tab("Edit User : Details");

    try {
      VBox main = ViewLayout.getMainVBox("Edit User", "Details");

      final TableView<UserMaster> table = TableUtil.createEditUserTable();

      main.getChildren().add(table);

      final ObservableList<UserMaster> mailboxData =
          FXCollections.observableArrayList(UserData.getUserList());

      table.setItems(mailboxData);

      EventHandler<ActionEvent> editUserEventHandler =
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {

              UserMaster user = table.getSelectionModel().getSelectedItem();
              if (user != null) {

                createEditTab(user);
              }
            }
          };

      EventHandler<ActionEvent> deleteUserEventHandler =
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {

              final UserMaster user = table.getSelectionModel().getSelectedItem();

              EventHandler<ActionEvent> delUserEvent =
                  new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent arg0) {

                      PersistUserDetails pud =
                          ServiceManager.getUserDetailsService(user, PersistType.DELETE);

                      pud.restart();

                      pud.setOnSucceeded(
                          new EventHandler<WorkerStateEvent>() {

                            @Override
                            public void handle(WorkerStateEvent e) {

                              mailboxData.remove(user);
                            }
                          });
                    }
                  };

              Confirm.showConfirm(
                  Context.getWindowStage(),
                  "Confirm",
                  "Confirm",
                  "Delete User : "******". Are you sure?",
                  delUserEvent);
            }
          };

      table.setContextMenu(
          TableContextMenu.getEditUserContextMenu(editUserEventHandler, deleteUserEventHandler));

      table.setOnMouseClicked(
          new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent mouseEvent) {

              if (mouseEvent.getClickCount() == 2) {

                UserMaster user = table.getSelectionModel().getSelectedItem();

                if (user != null) {
                  createEditTab(user);
                }
              }
            }
          });

      tab.setContent(ControlsUtil.makeScrollable(main));
      tab.setClosable(false);
      getTabs().add(tab);
      setSide(Side.TOP);
    } catch (Exception e) {
      LoggerUtil.getLogger().debug(e);
      Alert.showAlert(
          Context.getWindowStage(),
          "Error",
          "Error",
          "Some error occured. Details...\n" + e.getMessage());
    }
  }
  /** This method initializes the DateColumn */
  private void initializeDateTable() {
    // initialize datetable
    dateTable.setEditable(true);
    dateTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    ;

    ContextMenu menu = new ContextMenu();
    MenuItem holidayChanger = new MenuItem("Holiday");
    MenuItem summerChanger = new MenuItem("Summer Day");
    MenuItem schoolDayChanger = new MenuItem("School Day");
    MenuItem weekendChanger = new MenuItem("Weekend");
    holidayChanger.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            dateTable.getSelectionModel().getSelectedItem().setDayType(DayType.HOLIDAY);
            updateDayType(dateTable.getSelectionModel().getSelectedItems(), DayType.HOLIDAY);
            // update Column
            dateTable.getColumns().get(1).setVisible(false);
            dateTable.getColumns().get(1).setVisible(true);
            dailyDayTypeChartPanel.addNewSeries(dailyIntervalData);
          }
        });

    summerChanger.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            dateTable.getSelectionModel().getSelectedItem().setDayType(DayType.SUMMER_DAY);
            updateDayType(dateTable.getSelectionModel().getSelectedItems(), DayType.SUMMER_DAY);
            // update Column
            dateTable.getColumns().get(1).setVisible(false);
            dateTable.getColumns().get(1).setVisible(true);
            dailyDayTypeChartPanel.addNewSeries(dailyIntervalData);
          }
        });

    schoolDayChanger.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            dateTable.getSelectionModel().getSelectedItem().setDayType(DayType.SCHOOL_DAY);
            updateDayType(dateTable.getSelectionModel().getSelectedItems(), DayType.SCHOOL_DAY);
            // update Column
            dateTable.getColumns().get(1).setVisible(false);
            dateTable.getColumns().get(1).setVisible(true);
            dailyDayTypeChartPanel.addNewSeries(dailyIntervalData);
          }
        });

    weekendChanger.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            dateTable.getSelectionModel().getSelectedItem().setDayType(DayType.WEEKEND);
            updateDayType(dateTable.getSelectionModel().getSelectedItems(), DayType.WEEKEND);
            // update Column
            dateTable.getColumns().get(1).setVisible(false);
            dateTable.getColumns().get(1).setVisible(true);
            dailyDayTypeChartPanel.addNewSeries(dailyIntervalData);
          }
        });

    menu.getItems().add(holidayChanger);
    menu.getItems().add(summerChanger);
    menu.getItems().add(schoolDayChanger);
    menu.getItems().add(weekendChanger);

    dateTable.setContextMenu(menu);

    dateColumn.setCellValueFactory(
        cellData -> Assistant.parsePropertiesString(cellData.getValue().getDate().toString()));

    dayTypeColumn.setCellValueFactory(
        cellData -> Assistant.parsePropertiesString(cellData.getValue().getDayType().toString()));
  }
Ejemplo n.º 6
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    AppController.instance = this;
    this.res = resources;

    ObservableList<String> modeItems =
        FXCollections.observableArrayList(
            Settings.MODE_NEXT, Settings.MODE_RANDOM, Settings.MODE_SAME);
    modeList.setItems(modeItems);
    modeList.getSelectionModel().select(Settings.currentMode);
    modeList
        .valueProperty()
        .addListener(
            (ObservableValue ov, Object oldVal, Object newVal) -> {
              Settings.currentMode = (String) newVal;
            });

    setupPlaylistsView();
    setupPlaylistsContextMenu();

    setupTracksView();

    tracksView.setContextMenu(tracksContextMenu);
    tracksView.setOnContextMenuRequested(
        (ContextMenuEvent evt) -> {
          setupTracksContextMenu();
          evt.consume();
        });
    tracksView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (ObservableValue observable, Object oldValue, Object newValue) -> {
              Settings.lastTrackId = newValue != null ? ((Track) newValue).getId() : null;
            });

    playlistsView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (ObservableValue observable, Object oldValue, Object newValue) -> {
              loadSelectedPlaylist();
              Settings.lastPlaylistId = newValue != null ? ((Playlist) newValue).getId() : null;
              searching = false;
              searchText.setText(StringUtils.EMPTY);
            });

    volumeSlider.setCursor(Cursor.HAND);
    volumeSlider
        .valueProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldVal, Number newVal) -> {
              if (player != null) {
                player.setVolume(newVal.doubleValue());
              }
              Settings.currentVolume = newVal.doubleValue();
              volumeLabel.setText(
                  String.valueOf((int) Math.ceil(newVal.doubleValue() * 100)) + "%");
            });
    volumeSlider.setValue(Settings.currentVolume);

    imagePlay = new ImageView(new Image(getClass().getResourceAsStream("/images/button_play.png")));
    imagePlay.setScaleX(0.40);
    imagePlay.setScaleY(0.40);
    imagePause =
        new ImageView(new Image(getClass().getResourceAsStream("/images/button_pause.png")));
    imagePause.setScaleX(0.5);
    imagePause.setScaleY(0.5);
    imageSettings =
        new ImageView(new Image(getClass().getResourceAsStream("/images/settings.png")));
    imageSettings.setScaleX(0.5);
    imageSettings.setScaleY(0.5);
    imageUpdate = new ImageView(new Image(getClass().getResourceAsStream("/images/refresh.png")));
    imageUpdate.setScaleX(0.5);
    imageUpdate.setScaleY(0.5);
    imageAdd = new ImageView(new Image(getClass().getResourceAsStream("/images/add.png")));
    imageAdd.setScaleX(0.5);
    imageAdd.setScaleY(0.5);
    imageRename = new ImageView(new Image(getClass().getResourceAsStream("/images/rename.png")));
    imageRename.setScaleX(0.5);
    imageRename.setScaleY(0.5);
    imageDelete = new ImageView(new Image(getClass().getResourceAsStream("/images/delete.png")));
    imageDelete.setScaleX(0.5);
    imageDelete.setScaleY(0.5);

    stateButton.setGraphic(imagePlay);
    settingsButton.setGraphic(imageSettings);
    refreshButton.setGraphic(imageUpdate);
    refreshButton.setTooltip(new Tooltip(res.getString("tooltip_sync")));

    addButton.setGraphic(imageAdd);
    addButton.setOnAction((evt) -> createOfflinePlaylist());
    addButton.setTooltip(new Tooltip(res.getString("tooltip_add_offline")));
    renameButton.setGraphic(imageRename);
    renameButton.setOnAction(evt -> renamePlaylist());
    renameButton.setTooltip(new Tooltip(res.getString("rename_playlist")));
    deleteButton.setGraphic(imageDelete);
    deleteButton.setOnAction(evt -> deletePlaylist());
    deleteButton.setTooltip(new Tooltip(res.getString("delete_playlist")));

    loadProgressBar.setCursor(Cursor.HAND);
    volumeSlider.setCursor(Cursor.HAND);
    updatePlaylists();
    if (Settings.lastPlaylistId != null) {
      currentPlaylist =
          ((ObservableList<Playlist>) playlistsView.getItems())
              .stream()
              .filter((playlist) -> playlist.getId().equals(Settings.lastPlaylistId))
              .findFirst()
              .orElse(null);
      playlistsView.getSelectionModel().select(currentPlaylist);
      playlistsView.scrollTo(currentPlaylist);
      Platform.runLater(
          () -> {
            if (Settings.lastTrackId != null) {
              currentTrack =
                  ((ObservableList<Track>) tracksView.getItems())
                      .stream()
                      .filter((track) -> track.getId().equals(Settings.lastTrackId))
                      .findFirst()
                      .orElse(null);
              tracksView.getSelectionModel().select(currentTrack);
              tracksView.scrollTo(currentTrack);
            }
          });
    }
    new Timer()
        .scheduleAtFixedRate(
            new TimerTask() {
              @Override
              public void run() {
                updatePlayProgress();
              }
            },
            100,
            100);
    setupTracksContextMenu();

    setupShortcuts();

    Platform.runLater(
        () -> {
          tracksView.requestFocus();
        });
  }