Пример #1
0
 /**
  * Sets up the add button, which is used to add filters to the graph and to the table view.
  *
  * @return The fully configured add button.
  */
 private Button setAddButton() {
   final Button addButton = new ImageButton("add.png");
   addButton.setOnAction(actionEvent -> filterEditingMenu.showMenu());
   addButton.setScaleX(0.5);
   addButton.setScaleY(0.5);
   return addButton;
 }
Пример #2
0
  /**
   * Sets up the remove button, which is used to remove filters from the table view and the graph.
   *
   * @param tableView The table view needed to get the currently selected filter.
   * @return The fully configured remove button.
   */
  private Button setRemoveButton(TableView tableView) {
    final Button removeButton = new ImageButton("remove.png");
    removeButton.setOnAction(
        actionEvent -> {
          final FilterInput filterInput =
              (FilterInput) tableView.getSelectionModel().getSelectedItem();
          if (!data.isEmpty() && filterInput != null) {

            // Update model
            final IUserCommand updateGraphFilterCommand =
                interactionMap.get(FilterInteraction.REMOVE);

            if (updateGraphFilterCommand != null) {

              filterInput.setDeleted();
              updateGraphFilterCommand.setSelection(filterInput);
              notifyListeners(updateGraphFilterCommand);
              logger.debug(
                  "Removed FilterInput: "
                      + filterInput.getName()
                      + " from table view and database.");
            } else {
              logger.warn("no remove command mapped");
            }
          }
        });
    removeButton.setScaleX(0.5);
    removeButton.setScaleY(0.5);
    return removeButton;
  }
Пример #3
0
  public void start(Stage stage) {
    Button button = new Button("Click me!");
    button.setOnAction(
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            System.out.println("Thanks for clicking!");
          }
        });

    stage.setScene(new Scene(button));
    stage.show();
  }
Пример #4
0
 /**
  * Set up the edit button. This button is used to edit existing filters.
  *
  * @param tableView The table view needed to get the currently selected filter.
  * @return The fully configured edit button.
  */
 private Button setEditButton(TableView tableView) {
   final Button editButton = new ImageButton("edit.png");
   editButton.setOnAction(
       actionEvent -> {
         final FilterInput filterInput =
             (FilterInput) tableView.getSelectionModel().getSelectedItem();
         if (!data.isEmpty() && filterInput != null) {
           filterEditingMenu.showMenu(filterInput);
         }
       });
   editButton.setScaleX(0.45);
   editButton.setScaleY(0.45);
   return editButton;
 }
Пример #5
0
  /** Initializer */
  protected void init() {
    mFossilUpgradesPane = new FossilUpgradePane(mModel);

    EventHandler<ActionEvent> upgradeEvent = new PanelChangeEvent(mFossilUpgradesPane);
    mFossilUpgrades = new ImageButton("fossilfuelupgrade.png", upgradeEvent);
    mApply = new Button("Apply");

    EventHandler<ActionEvent> applyEvent =
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            mModel
                .getEnergyManager()
                .getFossil()
                .setAmount(Integer.parseInt(mValues.get("Plants in Operation").getText()));
          }
        };

    EventHandler<ActionEvent> upEvent =
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            mValues
                .get("Plants in Operation")
                .setText("" + (Integer.parseInt(mValues.get("Plants in Operation").getText()) + 1));
          }
        };

    EventHandler<ActionEvent> downEvent =
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            if (Integer.parseInt(mValues.get("Plants in Operation").getText()) != 0) {
              mValues
                  .get("Plants in Operation")
                  .setText(
                      "" + (Integer.parseInt(mValues.get("Plants in Operation").getText()) - 1));
            }
          }
        };

    mApply.setOnAction(applyEvent);
    mUp = new ImageButton("up.png", upEvent);
    mDown = new ImageButton("down.png", downEvent);
    mUp.setPrefSize(0, 0);
    mDown.setPrefSize(0, 0);
    setHalignment(mDown, HPos.CENTER);
    setHalignment(mUp, HPos.CENTER);
    setHalignment(mApply, HPos.CENTER);
    setHalignment(mFossilUpgrades, HPos.RIGHT);
  }
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    urlField.setOnAction(
        event -> {
          String text = urlField.getText();
          urlField.setText("tetetetetetetete");
          webView.getEngine().load(text);
        });

    webView
        .getEngine()
        .getLoadWorker()
        .stateProperty()
        .addListener(
            (ov, oldState, newState) -> {
              if (newState == State.SUCCEEDED) {
                String url = webView.getEngine().getLocation();
                urlField.setText(url);
                if (Pattern.compile("http://item.rakuten.co.jp/.*").matcher(url).find()) {
                  try {
                    Elements tmp;
                    Document document = Jsoup.connect(url).get();
                    tmp = document.select("input");
                    tmp = tmp.select("#etime");
                    if (tmp.size() != 0) {
                      if (!(Long.parseLong(tmp.first().val()) < new Date().getTime())) {
                        entryButton.setDisable(false);
                      }
                    } else {
                      entryButton.setDisable(false);
                    }
                  } catch (Exception e) {
                    // TODO 自動生成された catch ブロック
                    e.printStackTrace();
                  }
                }
              }
              ;
            });

    entryButton.setOnAction(
        event -> {
          urlField.setText("webView disable");
          sendEntryTaskController();
        });
  }
Пример #7
0
  /**
   * Set up the selection button used to create a filter from a selection.
   *
   * @return The fully configured selection button.
   */
  private Button setSelectionButton() {
    final Button selectionButton = new ImageButton("select.png");
    selectionButton.setScaleX(0.5);
    selectionButton.setScaleY(0.5);

    selectionButton.setOnAction(
        actionEvent -> {
          final Set<INode> selected = new HashSet<>(pickedState.getPicked());
          final List<String> filterStringList =
              selected
                  .stream()
                  .map(node -> node.getAddress().toString())
                  .collect(Collectors.toList());
          filterEditingMenu.showMenu(filterStringList);
        });

    return selectionButton;
  }
Пример #8
0
  protected void init() {
    mActionButton = new Button("Apply");

    mActionButton.setOnAction(
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            mModel.getUpgradeManager().addLobby(mLobby.getChange());
            mModel.getResourceManager().spendActionPoints(Math.abs(mLobby.getChange()));
            mModel.getUpgradeManager().addOilDrilling(mOil.getChange());
            mModel.getResourceManager().spendActionPoints(Math.abs(mOil.getChange()));
            mModel.getUpgradeManager().addPriceChange(mPrice.getChange());
            mModel.getResourceManager().spendActionPoints(Math.abs(mPrice.getChange()));
            mLobby.saveChanges();
            mOil.saveChanges();
            mPrice.saveChanges();
            update();
          }
        });

    setHalignment(mActionButton, HPos.LEFT);
  }
Пример #9
0
  public static void setJar(final Tile node) {
    node.data.put("type", "Jar");
    List<Node> toRemove = new ArrayList<>();
    for (Node n : node.node.getChildren()) {
      if (!n.getId().equals("delete")) {
        if (n.getId().equals("typeLabel")) {
          Label l = (Label) n;
          l.setText("jar");
          l.setTranslateY(l.getTranslateY() - 1);
        } else {
          toRemove.add(n);
        }
      }
    }

    VBox leftPadding = new VBox();
    leftPadding.setPrefWidth(14);
    VBox buttons = new VBox();
    VBox textBoxes = new VBox();
    VBox extra = new VBox();

    buttons.setSpacing(5);
    textBoxes.setSpacing(5);
    extra.setSpacing(5);

    buttons.setPadding(new Insets(7, 0, 0, 0));
    textBoxes.setPadding(new Insets(7, 0, 0, 0));
    extra.setPadding(new Insets(7, 0, 0, 0));

    textBoxes.setTranslateX(17);
    extra.setTranslateX(32);

    node.node.getChildren().removeAll(toRemove);

    final String name = "Package Name";
    final String name2 = "Jar Name";

    Button findPkg = new Button();
    final TextField pkgText = new TextField();
    final TextField jarName = new TextField();

    findPkg.getStyleClass().add("defaultButton");
    findPkg.setText("Find Package Name");
    findPkg.setPrefHeight(25);
    findPkg.setTranslateX(12);

    findPkg.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            String mainClassName = Util.packageNameFromTile();
            if (mainClassName != null) {
              pkgText.setText(mainClassName);
            }
          }
        });

    pkgText.setText(name);
    pkgText.setPrefSize(150, 27);
    pkgText.setFont(Font.font("Segoe UI"));
    pkgText.setId("textBox");
    pkgText
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("package", pkgText.getText().trim());
              }
            });
    pkgText
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && pkgText.getText().equals(name)) {
                  pkgText.setText("");
                } else if (newValue == false && pkgText.getText().trim().equals("")) {
                  pkgText.setText(name);
                }
              }
            });

    jarName.setText(name2);
    jarName.setPrefSize(150, 27);
    jarName.setFont(Font.font("Segoe UI"));
    jarName.setId("textBox");
    jarName
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("jarname", jarName.getText().trim());
              }
            });
    jarName
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && jarName.getText().equals(name2)) {
                  jarName.setText("");
                } else if (newValue == false && jarName.getText().trim().equals("")) {
                  jarName.setText(name2);
                }
              }
            });

    final String defTxt = "Additional Flags";
    final TextField flags = new TextField();
    flags.setText(defTxt);
    flags.setPrefSize(150, 27);
    flags.setFont(Font.font("Segoe UI"));
    flags.setId("textBox");

    flags
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && flags.getText().equals(defTxt)) {
                  flags.setText("");
                } else if (newValue == false && flags.getText().trim().equals("")) {
                  flags.setText(defTxt);
                }
              }
            });
    flags
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("flags", flags.getText().trim());
              }
            });

    final String defTxt2 = "Output Directory";
    final TextField outputDir = new TextField();
    outputDir.setText(defTxt2);
    outputDir.setPrefSize(150, 27);
    outputDir.setFont(Font.font("Segoe UI"));
    outputDir.setId("textBox");

    outputDir
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && outputDir.getText().equals(defTxt2)) {
                  outputDir.setText("");
                } else if (newValue == false && outputDir.getText().trim().equals("")) {
                  outputDir.setText(defTxt2);
                }
              }
            });
    outputDir
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("output", outputDir.getText().trim());
              }
            });

    buttons.getChildren().addAll(findPkg);
    textBoxes.getChildren().addAll(pkgText, jarName);
    extra.getChildren().addAll(flags, outputDir);
    node.node.getChildren().addAll(leftPadding, buttons, textBoxes, extra);
  }
Пример #10
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();
        });
  }