コード例 #1
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    BorderPane outerPane = new BorderPane();
    HBox topBox = new HBox(20);
    HBox bottomBox = new HBox(20);
    outerPane.setCenter(newText);

    fontChoice.setValue("Times New Roman");
    sizeChoice.setValue(12);

    topBox.setPadding(new Insets(20, 20, 20, 20));
    bottomBox.setPadding(new Insets(20, 20, 20, 20));

    List<String> items = Font.getFamilies();
    fontChoice.getItems().addAll(items);

    for (int i = 1; i <= 100; i++) sizeChoice.getItems().add(i);

    topBox.getChildren().addAll(fontName, fontChoice, fontSize, sizeChoice);
    bottomBox.getChildren().addAll(bold, italic);
    topBox.setAlignment(Pos.CENTER);
    bottomBox.setAlignment(Pos.CENTER);

    outerPane.setTop(topBox);
    outerPane.setCenter(newText);
    outerPane.setBottom(bottomBox);

    fontChoice.setOnAction(
        e -> {
          setFont();
        });

    sizeChoice.setOnAction(
        e -> {
          setFont();
        });

    bold.setOnAction(
        e -> {
          setFont();
        });
    italic.setOnAction(
        e -> {
          setFont();
        });

    Scene scene = new Scene(outerPane, X, Y);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
コード例 #2
0
  @FXML
  public void initialize(URL location, ResourceBundle resources) {
    for (String s : Main.settings.getSkins()) {
      skin.getItems().add(s);
    }
    skin.setValue(Main.settings.getSkin());

    skin.setOnAction(
        event -> {
          Main.settings.setSkin(skin.getSelectionModel().getSelectedItem());
          save();
        });

    for (String list : Main.settings.getLists().keySet()) {
      TextField k = new TextField(list);
      k.setId(list);

      String listName = Main.settings.getLists().get(list);
      TextField v = new TextField(listName);
      v.setId("V" + list);

      Button deleteButton = new Button();
      deleteButton.setText("Delete");

      addListListener(k, v, deleteButton);

      lists.getChildren().add(k);
      listsName.getChildren().add(v);
      deleteButtons.getChildren().add(deleteButton);
    }
  }
コード例 #3
0
  @Override
  protected void activate() {
    currencyComboBox.setItems(model.getTradeCurrencies());
    currencyComboBox.getSelectionModel().select(model.getTradeCurrency());
    currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25));
    currencyComboBox.setOnAction(
        e -> {
          model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
          updateChartData();
        });

    model.getOfferBookListItems().addListener(changeListener);
    tradeCurrencySubscriber =
        EasyBind.subscribe(
            model.tradeCurrency,
            newValue -> {
              String code = newValue.getCode();
              areaChart.setTitle("Offer book for " + newValue.getName());
              priceColumnLabel.set("Price (" + code + "/BTC)");
              volumeColumnLabel.set("Volume (" + code + ")");
              xAxis.setLabel(priceColumnLabel.get());
              xAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(xAxis, "", ""));
            });

    buyOfferTableView.setItems(model.getBuyOfferList());
    sellOfferTableView.setItems(model.getSellOfferList());

    updateChartData();
  }
コード例 #4
0
  private void initializeWorkflowProcessesComboBox() {
    workflowProcessesComboBox.setEditable(false);
    workflowProcessesComboBox.setPromptText("Select Workflow Process");
    workflowProcessesComboBox.setCellFactory(
        (p) -> {
          final ListCell<WorkflowProcess> cell =
              new ListCell<WorkflowProcess>() {
                @Override
                protected void updateItem(WorkflowProcess a, boolean bln) {
                  super.updateItem(a, bln);

                  if (a != null) {
                    setText(a.getText());
                  } else {
                    setText(null);
                  }
                }
              };

          return cell;
        });

    workflowProcessesComboBox.setButtonCell(
        new ListCell<WorkflowProcess>() {
          @Override
          protected void updateItem(WorkflowProcess t, boolean bln) {
            super.updateItem(t, bln);
            if (bln) {
              setText("");
              initiateButton.setDisable(true);
            } else {
              setText(t.getText());
              initiateButton.setDisable(!isDataRequiredForInitiateOk());
            }
          }
        });
    workflowProcessesComboBox.setOnAction(
        (event) -> {
          LOG.trace(
              "workflowProcessesComboBox event (selected: "
                  + workflowProcessesComboBox.getSelectionModel().getSelectedItem()
                  + ")");

          initiateButton.setDisable(!isDataRequiredForInitiateOk());
        });
  }
 public SoapServiceVirtualUiMainPanel(
     final SoapServiceVirtualizeDto soap, final VirtualizationUiOptions wireMockOptions) {
   this.soap = soap;
   this.wireMockOptions = wireMockOptions;
   GridPane pane = new GridPane();
   pane.setAlignment(Pos.TOP_LEFT);
   pane.setHgap(10);
   pane.setVgap(10);
   setPadding(new Insets(5, 10, 5, 10));
   Label wsdlUrl = new Label("Wsdl URL:");
   Text requestXml = new Text("Request\nXml");
   requestXml.setTextAlignment(TextAlignment.JUSTIFY);
   Text responseXml = new Text("Response\nXml");
   responseXml.setTextAlignment(TextAlignment.JUSTIFY);
   loadWsdlButton = new MsstButton("LoadWsdl");
   wsdrlUrlTextField = new MsstTextField();
   wsdrlUrlTextField.setText(soap.getWsdlURL());
   GridPane.setHalignment(wsdrlUrlTextField, HPos.LEFT);
   Text endPointUrl = new Text("End point\nURL");
   operationList = new ComboBox<String>();
   serviceEndPointUrl = new MsstTextField();
   pane.add(wsdlUrl, 0, 1, 1, 1);
   pane.add(wsdrlUrlTextField, 1, 1, 5, 1);
   pane.add(loadWsdlButton, 6, 1, 2, 1);
   pane.add(endPointUrl, 0, 2);
   pane.add(serviceEndPointUrl, 1, 2, 5, 1);
   pane.add(operationList, 6, 2, 1, 1);
   saveButton = new MsstButton("Save Stub");
   requestTextArea = new MsstTextArea(soap.getRequestXml());
   responseTextArea = new MsstTextArea(soap.getResponseXml());
   requestTextArea.setMinWidth(300);
   responseTextArea.setMinWidth(300);
   GridPane.setHalignment(saveButton, HPos.CENTER);
   pane.add(requestXml, 0, 3, 1, 1);
   pane.add(requestTextArea, 1, 3, 2, 1);
   pane.add(responseXml, 3, 3, 1, 1);
   pane.add(responseTextArea, 4, 3, 3, 1);
   pane.add(saveButton, 0, 4, 5, 1);
   saveButton.setOnAction(saveButtonActionEvent);
   operationList.setOnAction(listActionListener);
   loadWsdlButton.setOnAction(loadWsdlActionListener);
   setFitToHeight(true);
   setFitToWidth(true);
   setContent(pane);
 }
コード例 #6
0
ファイル: Part3.java プロジェクト: RikClaes/project-ogp
 @Override
 protected Node createStart() {
   Node startButton = super.createStart();
   VBox startGroup = new VBox(10);
   ComboBox<String> levelChoice = new ComboBox<>();
   levelChoice.setOnAction(e -> levelFilename = levelChoice.getValue());
   levelChoice.getItems().addAll(getLevelFilenames());
   if (!levelChoice.getItems().isEmpty()) {
     levelChoice.getSelectionModel().clearAndSelect(0);
     levelFilename = levelChoice.getItems().get(0);
   } else {
     startButton.setDisable(true);
   }
   startGroup.getChildren().add(levelChoice);
   startGroup.getChildren().add(startButton);
   startGroup.setAlignment(Pos.CENTER);
   return startGroup;
 }
コード例 #7
0
  private void addBottomComponentListeners() {

    occupancyCBox.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {

            String item = (String) occupancyCBox.getSelectionModel().getSelectedItem();

            if (item == null) {

            } else if (item.equals("Employed") || item.equals("Self-Employed")) {
              underEmployedCBox.setDisable(false);
            } else {
              underEmployedCBox.getSelectionModel().clearSelection();
              underEmployedCBox.setDisable(true);
            }
          }
        });

    ///////// return to normal node if this nodes are disable underEmployedCBox

    underEmployedCBox
        .disabledProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean notDisable,
                  Boolean isDisable) {
                if (isDisable) {
                  System.out.println(" underEmployedCBox Disable");
                  underEmployedCBox.getStyleClass().remove("combo-box-error");
                }
              }
            });
  }
コード例 #8
0
  public AddDeviceWidget(@NotNull DeviceController deviceController, @NotNull ActorRef tmServer) {
    super(I.addDevice());
    this.tmServer = tmServer;
    this.deviceController = deviceController;
    ObservableList<DeviceTypeInfo> deviceTypes =
        FXCollections.observableArrayList(new ModelDeviceTypeInfo(), new MavlinkDeviceTypeInfo());
    Label typeLabel = new Label(I.deviceType());
    ComboBox<DeviceTypeInfo> deviceTypeComboBox = new ComboBox<>(deviceTypes);

    Group deviceTypeConfigPane = new Group();

    Runnable deviceTypeSelectAction =
        () -> {
          deviceTypeConfigPane.getChildren().clear();
          deviceTypeComboBox
              .getSelectionModel()
              .getSelectedItem()
              .getTypedConfigFormNode()
              .ifPresent((n) -> deviceTypeConfigPane.getChildren().add(n));
        };

    deviceTypeComboBox.setOnAction(e -> deviceTypeSelectAction.run());
    deviceTypeComboBox.getSelectionModel().selectFirst();
    deviceTypeSelectAction.run();

    Button addButton = new Button(I.add());
    addButton.setOnAction(
        (e) ->
            deviceController
                .getDeviceRegistry()
                .getDevices()
                .addAll(deviceTypeComboBox.getSelectionModel().getSelectedItem().newDevice()));
    VBox box = new VBox(typeLabel, deviceTypeComboBox, deviceTypeConfigPane, addButton);
    box.setAlignment(Pos.CENTER_LEFT);
    box.setSpacing(5);
    setContent(box);
  }
コード例 #9
0
ファイル: Main.java プロジェクト: Team13Avengers/PubFinder
  /* ADMIN SCENE */
  public void start(Stage primaryStage) throws Exception {
    /** Done by Marco */
    primaryStage.setTitle("PubFinder");
    primaryStage.setResizable(false);
    PubDataAccessor.PubDataAccessor();

    /*Welcome scene*/
    WelcomeScene.welcomeScene();
    welcomeScene = WelcomeScene.welcomeScene;
    /*Welcome scene*/
    /** End of Marcos Work */
    /** Done by Shafiq and Anotnino */
    /* Admin add scene*/
    AdminAddScene.adminAddscene();
    adminAddScene = AdminAddScene.adminAddScene;
    /* Admin add scene*/

    /*Admin login scene*/
    AdminLoginScene.adminloginscene();
    adminLoginScene = AdminLoginScene.adminLoginScene;
    /*Admin login scene*/

    /*Admin choice scene*/
    AdminChoiceScene.adminchoicescene();
    adminChoiceScene = AdminChoiceScene.adminChoiceScene;
    /*Admin choice scene*/

    /* Admin Edit Scene*/
    adminEditScene = AdminEditScene.editScene;
    /* Admin Edit Scene*/
    /** End of Shafiq and Anotonino's Work */

    /*Pub button scene*/
    pubLayout = new StackPane();
    /** Done by Ahmad */
    searchNameInput = new TextField();
    searchNameInput.setId("search-field");
    searchNameInput.setPromptText("NAME");
    /** End of Ahmad's Work */
    searchStreetInput = new TextField();
    searchStreetInput.setId("search-field");
    searchStreetInput.setPromptText("STREET");
    searchAgeInput = new TextField();
    searchAgeInput.setId("search-field");
    searchAgeInput.setPromptText("AGE");
    /** Done by Aseel */
    CheckBox searchStudentDiscount = new CheckBox("DISCOUNTS");
    CheckBox searchBySpecialEvents = new CheckBox("EVENTS");
    CheckBox searchWithoutFees = new CheckBox("NO FEES");
    searchStudentDiscount.setId("check-search");
    searchBySpecialEvents.setId("check-search");
    searchWithoutFees.setId("check-search");
    ComboBox searchByRating =
        new ComboBox(
            FXCollections.observableArrayList(
                "\uF005",
                "\uF005\uF005",
                "\uF005\uF005\uF005",
                "\uF005\uF005\uF005\uF005",
                "\uF005\uF005\uF005\uF005\uF005"));
    searchByRating.setTooltip(new Tooltip("RATING"));
    searchByRating.setPromptText("RATING");
    searchByRating.setId("combo-search");
    ComboBox searchByArea =
        new ComboBox(
            FXCollections.observableArrayList(
                "All",
                "Avenyn",
                "Linné",
                "Haga",
                "Järntorget",
                "Magasinsgatan",
                "Vasastaden",
                "Gamlestaden",
                "Heden",
                "Masthugget",
                "Stigberget",
                "Other"));
    searchByArea.setTooltip(new Tooltip("AREA"));
    searchByArea.setPromptText("AREA");
    searchByArea.setId("combo-search");
    /** End of Aseel's Work */

    /** Done by Marco */
    pubLayout.setId("pubs");
    search = new Button("SEARCH");
    search.setId("button-search");
    GridPane inputGrid = new GridPane();
    inputGrid.setMaxHeight(100);
    inputGrid.setHgap(10);
    inputGrid.setVgap(10);
    inputGrid.setId("searchGrid");
    StackPane.setAlignment(inputGrid, Pos.TOP_LEFT);
    StackPane.setAlignment(search, Pos.TOP_RIGHT);
    /** End of Marco's Work */
    search.setOnAction(e -> searchForPubs());
    /** Done by Ahmad */
    searchNameInput.setOnKeyReleased(
        event1 -> {
          if (event1.getCode() == KeyCode.ENTER) {
            searchForPubs();
          }
        });
    /** End of Ahmad's Work */

    /** Done by Marco */
    searchStreetInput.setOnKeyReleased(
        event2 -> {
          if (event2.getCode() == KeyCode.ENTER) {
            searchForPubs();
          }
        });
    /** End of Marco's Work */

    /** Done by Ahmad */
    searchAgeInput.setOnKeyReleased(
        event3 -> {
          if (event3.getCode() == KeyCode.ENTER) {
            searchForPubs();
          }
        });
    /** End of Ahmad's Work */

    /** Done by Shafiq & Anotnino */
    searchStudentDiscount.setOnAction(
        event4 -> {
          if (searchStudentDiscount.isSelected()) {
            discount = 1;
          }
          if (!searchStudentDiscount.isSelected()) {
            discount = 0;
          }
        });

    searchWithoutFees.setOnAction(
        event5 -> {
          if (searchWithoutFees.isSelected()) {
            fee = 0;
          }
          if (!searchWithoutFees.isSelected()) {
            fee = 1;
          }
        });

    searchBySpecialEvents.setOnAction(
        event6 -> {
          if (searchBySpecialEvents.isSelected()) {

            searchEvent = true;
          }
          if (!searchBySpecialEvents.isSelected()) {
            searchEvent = false;
          }
        });

    searchByRating.setOnAction(
        event7 -> {
          if (searchByRating.getSelectionModel().isSelected(0)) {
            numberOfStars = 1;
          } else if (searchByRating.getSelectionModel().isSelected(1)) {
            numberOfStars = 2;
          } else if (searchByRating.getSelectionModel().isSelected(2)) {
            numberOfStars = 3;
          } else if (searchByRating.getSelectionModel().isSelected(3)) {
            numberOfStars = 4;
          } else if (searchByRating.getSelectionModel().isSelected(4)) {
            numberOfStars = 5;
          }
        });
    /** End of Shafiq and Anotino's Work */

    /** Done by Aseel and Antonino */
    searchByArea.setOnAction(
        event8 -> {
          if (searchByArea.getSelectionModel().isSelected(0)) {
            area_checker = 2;
          }
          if (searchByArea.getSelectionModel().isSelected(1)) {
            area = 0;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(2)) {
            area = 2;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(3)) {
            area = 3;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(4)) {
            area = 4;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(5)) {
            area = 5;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(6)) {
            area = 6;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(7)) {
            area = 7;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(8)) {
            area = 8;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(9)) {
            area = 9;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(10)) {
            area = 10;
            area_checker = 1;
          } else if (searchByArea.getSelectionModel().isSelected(11)) {
            area = 11;
            area_checker = 1;
          }
        });
    /** End of Aeel and Antonino's Work */

    /** Done by marco */
    ScrollPane pubScroll = new ScrollPane();
    pubScroll.setId("scroll");
    pubScroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    pubScroll.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);

    pubs = new GridPane();
    pubScroll.setContent(pubs);
    pubs.setId("pub-grid");
    pubs.setAlignment(Pos.CENTER);
    pubLayout.getChildren().add(pubScroll);

    inputGrid.add(searchNameInput, 1, 1);
    inputGrid.add(searchStreetInput, 2, 1);
    inputGrid.add(searchAgeInput, 3, 1);

    inputGrid.add(searchByRating, 4, 1);
    inputGrid.add(searchByArea, 5, 1);
    inputGrid.add(searchStudentDiscount, 6, 1);
    inputGrid.add(searchBySpecialEvents, 7, 1);
    inputGrid.add(searchWithoutFees, 8, 1);

    pubLayout.getChildren().add(inputGrid);
    pubLayout.getChildren().add(search);
    noPub = new Label("No pubs found");
    searchForPubs();

    pubScene = new Scene(pubLayout, 1000, 600);
    pubScene.getStylesheets().addAll(this.getClass().getResource("style.css").toExternalForm());
    /*Pub button scene*/

    /*Pub scene*/
    ScrollPane pubPageLayout = new ScrollPane();
    pubPageLayout.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    pubPageLayout.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    pubPageLayout.setFitToWidth(true);
    pubPageLayout.setContent(xPane);
    xPane.setId("pubScene");
    pubPageLayout.setId("gej");
    star.setId("starButton");
    eventLabel.setId("eventLabel");

    /*Items*/
    xPane.add(back, 1, 1);
    back.setId("button-logout");

    back.setOnAction(
        (event) -> {
          primaryStage.setScene(pubScene);
          xPane
              .getChildren()
              .removeAll(description, rating, overlay, pubName, map, star, rates, events);
          descriptionGrid
              .getChildren()
              .removeAll(age, open, address, type, discountForStudents, entranceFees);
          events.getChildren().removeAll(eventDescriptionGrid);
          eventDescriptionGrid.getChildren().removeAll(eventLabel, eventPane);
          eventPane.getChildren().removeAll(eventGrid);
          eventGrid.getChildren().removeAll(eventName, eventDescription);

          star.setText("0 \uF08A");
          star.setStyle(
              "#starButton{-fx-text-fill: #fff;}  #starButton:hover{-fx-text-fill: #fff;}");
        });
    /** End of Marco's work */

    /** Done by Shafiq & Antonino */
    star.setOnAction(
        event -> {
          int rate = PubDataAccessor.checkRate(this.id);
          int rateUpdate = rate + 1;
          /** End of Shafiq & Antonino's Work */

          /** Done by marco */
          star.setText((rateUpdate) + " \uF004");
          PubDataAccessor.updateRate(this.id);
          star.setStyle("-fx-text-fill: #731a2b;");
        });

    overlay.setHeight(header.getFitHeight());
    overlay.setWidth(header.getFitWidth() + 24);
    overlay.setX(0);
    overlay.setY(0);
    overlay.fillProperty().set(javafx.scene.paint.Color.rgb(115, 26, 43, 0.3));

    pubPage = new Scene(pubPageLayout, 1000, 600);
    pubPage.getStylesheets().addAll(this.getClass().getResource("style.css").toExternalForm());
    /*Pub scene*/

    primaryStage.setScene(welcomeScene);
    primaryStage.show();
    Main.primaryStage = primaryStage;
    /** End of Marcos work */
  }
コード例 #10
0
  private void addTopComponentListeners() {

    //  validate number of children field
    numofChildrenF
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean outFocused,
                  Boolean focused) {

                if (focused) {

                } else if (outFocused) {

                  if (numofChildrenF.getText().matches("\\d+")) {
                    int children = Integer.parseInt(numofChildrenF.getText());
                    if (children > 1) {
                      numofChildrenF.setText(String.valueOf(children));
                      if (!childrenSchlCBox.getItems().contains(ChildrenSchoolCategory.SOME)) {
                        childrenSchlCBox.getItems().add(ChildrenSchoolCategory.SOME);
                      }
                      childrenSchlCBox.setDisable(false);
                    } else if (children == 1) {
                      numofChildrenF.setText(String.valueOf(children));
                      childrenSchlCBox.setDisable(false);
                      childrenSchlCBox.getItems().remove(ChildrenSchoolCategory.SOME);
                    } else {
                      numofChildrenF.setText("0");
                      childrenSchlCBox.setDisable(true);
                      childrenSchlCBox.getSelectionModel().clearSelection();
                    }
                  } else {
                    numofChildrenF.setText("0");
                  }
                }
              }
            });

    // add Change listener to validate number of children field
    agefield
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable, Boolean outFocus, Boolean focus) {

                if (outFocus) {
                  if (agefield.getText().matches("\\d+")) {
                    int age = Integer.parseInt(agefield.getText());
                    agefield.setText(String.valueOf(age));
                  } else {
                    agefield.setText("");
                  }
                }
              }
            });

    maritalCBox.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            String item = (String) maritalCBox.getSelectionModel().getSelectedItem();
            if (item == null) {

            } else if (item.equals("Married") || item.equals("Live-in")) {
              SpouseName.setDisable(false);
            } else {
              SpouseName.getStyleClass().remove("text-field-error");
              SpouseName.setText("");
              SpouseName.setDisable(true);
            }
          }
        });
  }
コード例 #11
0
ファイル: WebBrowser.java プロジェクト: TriMontana/douggithub
  public Browser(final Stage stage) {
    // apply the styles
    getStyleClass().add("browser");

    for (int i = 0; i < captions.length; i++) {
      // create hyperlinks
      Hyperlink hpl = hpls[i] = new Hyperlink(captions[i]);
      Image image = images[i] = new Image(getClass().getResourceAsStream(imageFiles[i]));
      hpl.setGraphic(new ImageView(image));
      final String url = urls[i];
      final boolean addButton = (hpl.getText().equals("Help"));

      // process event
      hpl.setOnAction(
          (ActionEvent e) -> {
            needDocumentationButton = addButton;
            webEngine.load(url);
          });
    }

    comboBox.setPrefWidth(60);

    // create the toolbar
    toolBar = new HBox();
    toolBar.setAlignment(Pos.CENTER);
    toolBar.getStyleClass().add("browser-toolbar");
    toolBar.getChildren().add(comboBox);
    toolBar.getChildren().addAll(hpls);
    toolBar.getChildren().add(createSpacer());

    // set action for the button
    toggleHelpTopics.setOnAction(
        (ActionEvent t) -> {
          webEngine.executeScript("toggle_visibility('help_topics')");
        });

    smallView.setPrefSize(120, 80);

    // handle popup windows
    webEngine.setCreatePopupHandler(
        (PopupFeatures config) -> {
          smallView.setFontScale(0.8);
          if (!toolBar.getChildren().contains(smallView)) {
            toolBar.getChildren().add(smallView);
          }
          return smallView.getEngine();
        });

    // process history
    final WebHistory history = webEngine.getHistory();
    history
        .getEntries()
        .addListener(
            (Change<? extends Entry> c) -> {
              c.next();
              c.getRemoved()
                  .stream()
                  .forEach(
                      (e) -> {
                        comboBox.getItems().remove(e.getUrl());
                      });
              c.getAddedSubList()
                  .stream()
                  .forEach(
                      (e) -> {
                        comboBox.getItems().add(e.getUrl());
                      });
            });

    // set the behavior for the history combobox
    comboBox.setOnAction(
        (Event ev) -> {
          int offset = comboBox.getSelectionModel().getSelectedIndex() - history.getCurrentIndex();
          history.go(offset);
        });

    // process page loading
    webEngine
        .getLoadWorker()
        .stateProperty()
        .addListener(
            (ObservableValue<? extends State> ov, State oldState, State newState) -> {
              toolBar.getChildren().remove(toggleHelpTopics);
              if (newState == State.SUCCEEDED) {
                JSObject win = (JSObject) webEngine.executeScript("window");
                win.setMember("app", new JavaApp());
                if (needDocumentationButton) {
                  toolBar.getChildren().add(toggleHelpTopics);
                }
              }
            });
    // adding context menu
    final ContextMenu cm = new ContextMenu();
    MenuItem cmItem1 = new MenuItem("Print");
    cm.getItems().add(cmItem1);
    toolBar.addEventHandler(
        MouseEvent.MOUSE_CLICKED,
        (MouseEvent e) -> {
          if (e.getButton() == MouseButton.SECONDARY) {
            cm.show(toolBar, e.getScreenX(), e.getScreenY());
          }
        });

    // processing print job
    cmItem1.setOnAction(
        (ActionEvent e) -> {
          PrinterJob job = PrinterJob.createPrinterJob();
          if (job != null) {
            webEngine.print(job);
            job.endJob();
          }
        });

    // load the home page
    webEngine.load("http://www.cnn.com");

    // add components
    getChildren().add(toolBar);
    getChildren().add(browser);
  }
コード例 #12
0
ファイル: RichText.java プロジェクト: Stefan-Fuchs/RichTextFX
  @Override
  public void start(Stage primaryStage) {
    CheckBox wrapToggle = new CheckBox("Wrap");
    wrapToggle.setSelected(true);
    area.wrapTextProperty().bind(wrapToggle.selectedProperty());
    Button undoBtn = createButton("undo", () -> area.undo());
    Button redoBtn = createButton("redo", () -> area.redo());
    Button cutBtn = createButton("cut", () -> area.cut());
    Button copyBtn = createButton("copy", () -> area.copy());
    Button pasteBtn = createButton("paste", () -> area.paste());
    Button boldBtn = createButton("bold", () -> toggleBold());
    Button italicBtn = createButton("italic", () -> toggleItalic());
    Button underlineBtn = createButton("underline", () -> toggleUnderline());
    Button strikeBtn = createButton("strikethrough", () -> toggleStrikethrough());
    ComboBox<Integer> sizeCombo =
        new ComboBox<>(
            FXCollections.observableArrayList(
                5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 48, 56, 64,
                72));
    sizeCombo.getSelectionModel().select(Integer.valueOf(12));
    ComboBox<String> familyCombo = new ComboBox<>(FXCollections.observableList(Font.getFamilies()));
    familyCombo.getSelectionModel().select("Serif");
    ColorPicker textColorPicker = new ColorPicker(Color.BLACK);
    ColorPicker backgroundColorPicker = new ColorPicker();

    sizeCombo.setOnAction(evt -> updateFontSize(sizeCombo.getValue()));
    familyCombo.setOnAction(evt -> updateFontFamily(familyCombo.getValue()));
    textColorPicker.valueProperty().addListener((o, old, color) -> updateTextColor(color));
    backgroundColorPicker
        .valueProperty()
        .addListener((o, old, color) -> updateBackgroundColor(color));

    undoBtn.disableProperty().bind(Bindings.not(area.undoAvailableProperty()));
    redoBtn.disableProperty().bind(Bindings.not(area.redoAvailableProperty()));

    BooleanBinding selectionEmpty =
        new BooleanBinding() {
          {
            bind(area.selectionProperty());
          }

          @Override
          protected boolean computeValue() {
            return area.getSelection().getLength() == 0;
          }
        };

    cutBtn.disableProperty().bind(selectionEmpty);
    copyBtn.disableProperty().bind(selectionEmpty);

    area.beingUpdatedProperty()
        .addListener(
            (o, old, beingUpdated) -> {
              if (!beingUpdated) {
                boolean bold, italic, underline, strike;
                Integer fontSize;
                String fontFamily;
                Color textColor;
                Color backgroundColor;

                IndexRange selection = area.getSelection();
                if (selection.getLength() != 0) {
                  StyleSpans<StyleInfo> styles = area.getStyleSpans(selection);
                  bold = styles.styleStream().anyMatch(s -> s.bold.orElse(false));
                  italic = styles.styleStream().anyMatch(s -> s.italic.orElse(false));
                  underline = styles.styleStream().anyMatch(s -> s.underline.orElse(false));
                  strike = styles.styleStream().anyMatch(s -> s.strikethrough.orElse(false));
                  int[] sizes =
                      styles
                          .styleStream()
                          .mapToInt(s -> s.fontSize.orElse(-1))
                          .distinct()
                          .toArray();
                  fontSize = sizes.length == 1 ? sizes[0] : -1;
                  String[] families =
                      styles
                          .styleStream()
                          .map(s -> s.fontFamily.orElse(null))
                          .distinct()
                          .toArray(i -> new String[i]);
                  fontFamily = families.length == 1 ? families[0] : null;
                  Color[] colors =
                      styles
                          .styleStream()
                          .map(s -> s.textColor.orElse(null))
                          .distinct()
                          .toArray(i -> new Color[i]);
                  textColor = colors.length == 1 ? colors[0] : null;
                  Color[] backgrounds =
                      styles
                          .styleStream()
                          .map(s -> s.backgroundColor.orElse(null))
                          .distinct()
                          .toArray(i -> new Color[i]);
                  backgroundColor = backgrounds.length == 1 ? backgrounds[0] : null;
                } else {
                  int p = area.getCurrentParagraph();
                  int col = area.getCaretColumn();
                  StyleInfo style = area.getStyleAtPosition(p, col);
                  bold = style.bold.orElse(false);
                  italic = style.italic.orElse(false);
                  underline = style.underline.orElse(false);
                  strike = style.strikethrough.orElse(false);
                  fontSize = style.fontSize.orElse(-1);
                  fontFamily = style.fontFamily.orElse(null);
                  textColor = style.textColor.orElse(null);
                  backgroundColor = style.backgroundColor.orElse(null);
                }

                updatingToolbar.suspendWhile(
                    () -> {
                      if (bold) {
                        if (!boldBtn.getStyleClass().contains("pressed")) {
                          boldBtn.getStyleClass().add("pressed");
                        }
                      } else {
                        boldBtn.getStyleClass().remove("pressed");
                      }

                      if (italic) {
                        if (!italicBtn.getStyleClass().contains("pressed")) {
                          italicBtn.getStyleClass().add("pressed");
                        }
                      } else {
                        italicBtn.getStyleClass().remove("pressed");
                      }

                      if (underline) {
                        if (!underlineBtn.getStyleClass().contains("pressed")) {
                          underlineBtn.getStyleClass().add("pressed");
                        }
                      } else {
                        underlineBtn.getStyleClass().remove("pressed");
                      }

                      if (strike) {
                        if (!strikeBtn.getStyleClass().contains("pressed")) {
                          strikeBtn.getStyleClass().add("pressed");
                        }
                      } else {
                        strikeBtn.getStyleClass().remove("pressed");
                      }

                      if (fontSize != -1) {
                        sizeCombo.getSelectionModel().select(fontSize);
                      } else {
                        sizeCombo.getSelectionModel().clearSelection();
                      }

                      if (fontFamily != null) {
                        familyCombo.getSelectionModel().select(fontFamily);
                      } else {
                        familyCombo.getSelectionModel().clearSelection();
                      }

                      if (textColor != null) {
                        textColorPicker.setValue(textColor);
                      }

                      backgroundColorPicker.setValue(backgroundColor);
                    });
              }
            });

    HBox panel1 = new HBox(3.0);
    HBox panel2 = new HBox(3.0);
    panel1
        .getChildren()
        .addAll(
            wrapToggle,
            undoBtn,
            redoBtn,
            cutBtn,
            copyBtn,
            pasteBtn,
            boldBtn,
            italicBtn,
            underlineBtn,
            strikeBtn);
    panel2.getChildren().addAll(sizeCombo, familyCombo, textColorPicker, backgroundColorPicker);

    VBox vbox = new VBox();
    VBox.setVgrow(area, Priority.ALWAYS);
    vbox.getChildren().addAll(panel1, panel2, area);

    Scene scene = new Scene(vbox, 600, 400);
    scene.getStylesheets().add(RichText.class.getResource("rich-text.css").toExternalForm());
    primaryStage.setScene(scene);
    area.requestFocus();
    primaryStage.setTitle("Rich Text Demo");
    primaryStage.show();
  }
コード例 #13
0
  public void init(Model model, Terminal terminal) {

    // ==============================================//
    // ================ DECODING SETUP ==============//
    // ==============================================//

    // Populate decoding options combobox
    layoutOptionsComboBox.getItems().setAll(Display.LayoutOptions.values());

    // Add listener to combobox
    layoutOptionsComboBox.setOnAction(
        event -> {

          // Bind the decoder decoding option to what has been selected in the
          // combobox
          terminal.txRx.display.selLayoutOption.set(
              layoutOptionsComboBox.getSelectionModel().getSelectedItem());
        });

    // Set default
    layoutOptionsComboBox.getSelectionModel().select(terminal.txRx.display.selLayoutOption.get());

    TooltipUtil.addDefaultTooltip(
        layoutOptionsComboBox,
        "Separate mode displays a separate pane for RX data (top), and TX data (bottom). Combined mode shows one pane for both RX and TX data (if local echo is enabled). Combined mode with local echo turned on behaves similarly to a terminal.");

    // ==============================================//
    // ============= SETUP LOCAL TX ECHO ============//
    // ==============================================//

    // Bind the model boolean to the checkbox
    terminal.txRx.display.localTxEcho.bind(localTxEchoCheckBox.selectedProperty());

    TooltipUtil.addDefaultTooltip(
        localTxEchoCheckBox,
        "If enabled, sent TX data will be copied (echoed) into the RX display.");

    // ==============================================//
    // =============== BACKSPACE SETUP ==============//
    // ==============================================//

    Bindings.bindBidirectional(
        backspaceRemovesLastTypedCharCheckBox.selectedProperty(),
        terminal.txRx.display.backspaceRemovesLastTypedChar);

    // Enable this checkbox only if the selected TX sending option is
    // on press on the "enter" key (this is the only way that this functionality makes sense)
    ChangeListener<Formatting.TxCharSendingOptions> changeListener =
        (observable, oldValue, newValue) -> {
          switch (newValue) {
            case SEND_TX_CHARS_IMMEDIATELY:
              backspaceRemovesLastTypedCharCheckBox.setDisable(true);
              break;
            case SEND_TX_CHARS_ON_ENTER:
              backspaceRemovesLastTypedCharCheckBox.setDisable(false);
              break;
            default:
              throw new RuntimeException("TxCharSendingOptions option not recognised.");
          }
        };
    terminal.txRx.formatting.selTxCharSendingOption.addListener(changeListener);

    // Update disabled state to default
    changeListener.changed(
        terminal.txRx.formatting.selTxCharSendingOption,
        terminal.txRx.formatting.selTxCharSendingOption.get(),
        terminal.txRx.formatting.selTxCharSendingOption.get());

    TooltipUtil.addDefaultTooltip(
        backspaceRemovesLastTypedCharCheckBox,
        "Enabling this will allow you to use backspace to delete TX chars before they are sent (on applicable if 'Send TX chars on enter' is selected). Disabling this will instead send the backspace character to the COM port.");

    // ==============================================//
    // ================ SETUP WRAPPING ==============//
    // ==============================================//

    // Bind "wrapping enabled" checkbox to model
    terminal.txRx.display.wrappingEnabled.bind(wrappingCheckBox.selectedProperty());

    TooltipUtil.addDefaultTooltip(
        wrappingCheckBox,
        "Enable this to wrap at a certain pixel width (as defined below). If this is disabled, long lines of TX/RX text will cause horizontal scroll-bars to appear.");

    // Upon pressing enter or loosing focus, try and convert the wrapping width value and
    // update the model
    wrappingWidthTextField.onApply.addListener(
        (observable, oldValue, newValue) -> {
          // Convert wrapping width string into double, and then perform
          // sanity checks
          Double wrappingWidth;
          try {
            wrappingWidth = Double.parseDouble(newValue);
          } catch (NumberFormatException e) {
            model.status.addErr("Wrapping width was not a valid number.");
            wrappingWidth = 0.0;
          }

          if (wrappingWidth <= 0.0) {
            model.status.addErr("Wrapping width must be greater than 0.");
            wrappingWidth = 0.0;
          }

          terminal.txRx.display.wrappingWidth.set(wrappingWidth);
        });

    // Set default value from model
    // (we assume the value in the model to be valid and no checking needed)
    wrappingWidthTextField
        .textProperty()
        .set(Double.toString(terminal.txRx.display.wrappingWidth.get()));

    // Disable the wrapping width textfield if wrapping is disabled.
    terminal.txRx.display.wrappingEnabled.addListener(
        (observable, oldValue, newValue) -> {
          wrappingWidthTextField.setDisable(!newValue);
        });

    // Set default state
    wrappingWidthTextField.setDisable(!terminal.txRx.display.wrappingEnabled.get());

    TooltipUtil.addDefaultTooltip(
        wrappingWidthTextField, "The width (in pixels) that you want TX/RX data to wrap at.");

    // ==============================================//
    // ============== BUFFER-SIZE SETUP =============//
    // ==============================================//

    // Perform a bi-directional bind, with custom string-to-number conversion which takes care
    // of any errors.
    Bindings.bindBidirectional(
        bufferSizeTextField.onApply,
        terminal.txRx.display.bufferSizeChars,
        new NumberStringConverter() {
          @Override
          public Number fromString(String value) {

            // Convert wrapping width string into double, and then perform
            // sanity checks
            Integer intValue;
            try {
              intValue = Integer.parseInt(value);
            } catch (NumberFormatException e) {
              model.status.addErr("Buffer size is not a valid integer.");
              return terminal.txRx.display.DEFAULT_BUFFER_SIZE_CHARS;
            }

            if (intValue <= 0.0) {
              model.status.addErr("Buffer size must be greater than 0.");
              return terminal.txRx.display.DEFAULT_BUFFER_SIZE_CHARS;
            }

            return intValue;
          }

          @Override
          public String toString(Number value) {
            return ((Integer) value).toString();
          }
        });

    // Add validation support for the buffer size
    ValidationSupport support = new ValidationSupport();

    Validator<String> validator =
        (Control control, String value) -> {
          boolean condition;
          try {
            Integer.parseInt(value);
            condition = false;
          } catch (RuntimeException e) {
            condition = true;
          }

          return ValidationResult.fromMessageIf(
              control, "Not a valid integer", Severity.ERROR, condition);
        };

    support.registerValidator(bufferSizeTextField, true, validator);

    TooltipUtil.addDefaultTooltip(
        bufferSizeTextField,
        "The max. number of characters to store in the TX and RX panes. Once the num. of characters exceeds this limit, the oldest characters are removed from the UI (this does not affect logging).");

    // ==============================================//
    // =========== SCROLL BEHAVIOUR SETUP ===========//
    // ==============================================//

    //        ToggleGroupValue<Display.ScrollBehaviour> scrollBehaviourToggleGroup = new
    // ToggleGroupValue();
    //        scrollBehaviourToggleGroup.add(scrollBehaviourStandardRadioButton,
    // Display.ScrollBehaviour.STANDARD);
    //        scrollBehaviourToggleGroup.add(scrollBehaviourSmartRadioButton,
    // Display.ScrollBehaviour.SMART);
    //
    //        Bindings.bindBidirectional(scrollBehaviourToggleGroup.valueProperty(),
    // terminal.txRx.display.scrollBehaviour);
    //
    //        TooltipUtil.addDefaultTooltip(scrollBehaviourStandardRadioButton, "When the RX buffer
    // is full, the RX pane will not scroll automatically to keep the same lines of RX text in
    // view.");
    //        TooltipUtil.addDefaultTooltip(scrollBehaviourSmartRadioButton, "When the RX buffer is
    // full, the RX pane will scroll automatically to keep the same lines of RX text in view (only
    // when scroll-to-bottom is not currently active).");

  }
  public VBox addScheduleAppoinment(
      Appointment appointment, AppointmentViewController parentController) {

    VBox baseVbox = new VBox();
    baseVbox.setPadding(new Insets(15));
    baseVbox.setSpacing(8);
    baseVbox.setStyle("-fx-background-color: #336699;");

    Text title = new Text("Schedule Appoinment");
    title.setFont(Font.font("Tahoma", FontWeight.NORMAL, 15));
    title.setFill(Color.WHITE);

    baseVbox.getChildren().add(title);

    HBox hbox = new HBox();
    hbox.setSpacing(10);

    Label dateLabel = new Label("Date:");
    dateLabel.setTextFill(Color.WHITE);

    datePicker = new DatePicker();
    datePicker.setPromptText("mm/dd/yyyy");
    datePicker.setMaxSize(120, 5);

    // following code makes it impossible to schedule appointment in the past
    LocalDate currentDate = LocalDate.now(); // current date
    /*if(datePicker.isBefore(currentDate)) {
    }*/
    final Callback<DatePicker, DateCell> dayCellFactory =
        new Callback<DatePicker, DateCell>() {
          @Override
          public DateCell call(final DatePicker datePicker) {
            return new DateCell() {
              @Override
              public void updateItem(LocalDate item, boolean empty) {
                super.updateItem(item, empty);

                if (item.isBefore(currentDate)) {
                  setDisable(true);
                  setStyle("-fx-background-color: #ffc0cb;");
                }
              }
            };
          }
        };
    datePicker.setDayCellFactory(dayCellFactory);

    Label timeLabel = new Label("Time:");
    timeLabel.setTextFill(Color.WHITE);
    timeComboBox = new ComboBox<String>();
    timeComboBox.getItems().addAll(Helper.getTimeSlots());

    hbox.getChildren().addAll(dateLabel, datePicker, timeLabel, timeComboBox);
    ComboBox<String> catPatientBox = new ComboBox<String>();
    if (UserSession.getInstance().getCurrentUser().getUsertype() != UserType.PATIENT) {
      Label patientLabel = new Label("Patient:");
      patientLabel.setTextFill(Color.WHITE);
      catPatientBox.getItems().addAll(Helper.getPatientList());

      hbox.getChildren().add(patientLabel);
      hbox.getChildren().add(catPatientBox);
    }
    baseVbox.getChildren().add(hbox);

    HBox hbox2 = new HBox();
    hbox2.setSpacing(10);

    Label docLabel = new Label("Doctor:");
    docLabel.setTextFill(Color.WHITE);

    docComboBox = new ComboBox<String>();
    docComboBox.getItems().addAll(Helper.getDoctorList());

    Label orLabel = new Label("OR");
    orLabel.setTextFill(Color.WHITE);

    Label categoryLabel = new Label("Category:");
    categoryLabel.setTextFill(Color.WHITE);
    catComboBox = new ComboBox<String>();
    catComboBox.getItems().addAll(Helper.getCategoryList());
    hbox2.getChildren().addAll(docLabel, docComboBox, orLabel, categoryLabel, catComboBox);

    // Patient can select either doctor or category. So when the select one, make the
    // other null.
    //
    catComboBox.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            docComboBox.setValue(null);
          }
        });
    docComboBox.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            catComboBox.setValue(null);
          }
        });

    baseVbox.getChildren().add(hbox2);

    // Fill in values for update
    if (appointment != null) {

      title.setText("Update Appointment");
      datePicker.setValue(appointment.getDate());
      timeComboBox.setValue(appointment.getTime());
      if (appointment.getDoctor() != null) docComboBox.setValue(appointment.getDoctor().getName());

      if (catPatientBox != null) {
        catPatientBox.setValue(appointment.getPatient().getName());
      }
      // Add update and cancel buttons
      //
      HBox hbBtn = new HBox(10);
      Button updateBtn = new Button("Update Appointment");
      hbBtn.getChildren().add(updateBtn);
      updateBtn.setOnAction(
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent e) {
              Doctor doctor =
                  Helper.getDoctorAtIndex(docComboBox.getSelectionModel().getSelectedIndex());
              Patient patient = null;
              if (UserSession.getInstance().getCurrentUser().getUsertype() == UserType.PATIENT) {
                patient = (Patient) UserSession.getInstance().getCurrentUser();
              } else {
                patient =
                    Helper.getPatientAtIndex(catPatientBox.getSelectionModel().getSelectedIndex());
              }

              Appointment newApp =
                  new Appointment(
                      datePicker.getValue(),
                      timeComboBox.getValue(),
                      doctor,
                      patient,
                      catComboBox.getSelectionModel().getSelectedItem());

              parentController.handleUpdateClick(newApp);
            }
          });

      Button cancelBtn = new Button("Cancel Appointment");
      hbBtn.getChildren().add(cancelBtn);
      cancelBtn.setOnAction(
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent e) {
              parentController.handleAppointmentCancellation();
            }
          });
      baseVbox.getChildren().add(hbBtn);

    } else {
      Button scheduleAppBtn = new Button("Submit");
      scheduleAppBtn.setOnAction(
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent e) {

              Doctor doctor =
                  Helper.getDoctorAtIndex(docComboBox.getSelectionModel().getSelectedIndex());
              Patient patient = null;
              if (UserSession.getInstance().getCurrentUser().getUsertype() == UserType.PATIENT) {
                patient = (Patient) UserSession.getInstance().getCurrentUser();
              } else {
                patient =
                    Helper.getPatientAtIndex(catPatientBox.getSelectionModel().getSelectedIndex());
              }

              Appointment newApp =
                  new Appointment(
                      datePicker.getValue(),
                      timeComboBox.getValue(),
                      doctor,
                      patient,
                      catComboBox.getSelectionModel().getSelectedItem());
              parentController.handleSubmitClick(newApp);
            }
          });

      baseVbox.getChildren().add(scheduleAppBtn);
    }

    return baseVbox;
  }
コード例 #15
0
ファイル: WebBrowser.java プロジェクト: M-Sayed/Gravity-OS
  private BorderPane webViewScene() {
    url = new TextField();
    url.setPrefWidth(800);
    browser = new WebView();
    engine = browser.getEngine();

    url.setText(fileUrl);
    engine.load(fileUrl);

    history = browser.getEngine().getHistory();

    backButton = new Button(null, new ImageView(new Image("res/BrowserIcons/back.png")));
    backButton.setOnAction(
        (ActionEvent e) -> {
          if (!checkIntConnection(defaultUrl)) {
            alert();
          } else browser.getEngine().load(goBack());
        });
    backButton.addEventHandler(
        MouseEvent.MOUSE_ENTERED, event -> backButton.setEffect(new DropShadow()));
    backButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> backButton.setEffect(null));

    forwardButton = new Button(null, new ImageView(new Image("res/BrowserIcons/forward.png")));
    forwardButton.setOnAction(
        (ActionEvent e) -> {
          if (!checkIntConnection(defaultUrl)) {
            alert();
          } else browser.getEngine().load(goForward());
        });
    forwardButton.addEventHandler(
        MouseEvent.MOUSE_ENTERED, event -> forwardButton.setEffect(new DropShadow()));
    forwardButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> forwardButton.setEffect(null));

    reloadButton = new Button(null, new ImageView(new Image("res/BrowserIcons/reload.png")));
    reloadButton.setOnAction(
        event -> {
          if (!checkIntConnection(defaultUrl)) {
            alert();
          } else browser.getEngine().reload();
        });
    reloadButton.addEventHandler(
        MouseEvent.MOUSE_ENTERED, event -> reloadButton.setEffect(new DropShadow()));
    reloadButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> reloadButton.setEffect(null));

    goButton = new Button(null, new ImageView(new Image("res/BrowserIcons/go.jpg")));
    goButton.setOnAction(
        event -> {
          // adding the http or https prefix if user didn't type it
          if (!checkIntConnection(defaultUrl)) {
            alert();
          } else {
            if (url.getText().length() > 7
                && (url.getText(0, 7).equals("http://") || url.getText(0, 8).equals("https://"))) {
              browser.getEngine().load(url.getText());
            } else if (url.getText().length() > 7 && !url.getText(0, 7).equals("http://")) {
              browser.getEngine().load("http://" + url.getText());
            } else {
              browser.getEngine().load("https://" + url.getText());
            }
          }
        });
    goButton.addEventHandler(
        MouseEvent.MOUSE_ENTERED, event -> goButton.setEffect(new DropShadow()));
    goButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> goButton.setEffect(null));

    webHistoryComboBox = new ComboBox();
    webHistoryComboBox.setPromptText("Web History");
    webHistoryComboBox.setPrefWidth(200);
    webHistoryComboBox.setOnAction(
        event -> {
          // Navigate to the link in the history index
          int offset =
              webHistoryComboBox.getSelectionModel().getSelectedIndex() - history.getCurrentIndex();
          history.go(offset);
        });

    // Displying browse history in a combo box
    history
        .getEntries()
        .addListener(
            (ListChangeListener<WebHistory.Entry>)
                c -> {
                  c.next();
                  for (WebHistory.Entry e : c.getRemoved())
                    webHistoryComboBox.getItems().remove(e.getUrl());
                  for (WebHistory.Entry e : c.getAddedSubList())
                    webHistoryComboBox.getItems().add(e.getUrl());
                });

    // Enabling and Disabling back and forward buttons
    browser
        .getEngine()
        .getLoadWorker()
        .stateProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (!browser.getEngine().getHistory().getEntries().isEmpty()) {
                int index = browser.getEngine().getHistory().getCurrentIndex();
                url.setText(browser.getEngine().getHistory().getEntries().get(index).getUrl());
                if (index == 0) {
                  backButton.setDisable(true);
                } else {
                  backButton.setDisable(false);
                }
                if (browser.getEngine().getHistory().getEntries().size() == 1) {
                  forwardButton.setDisable(true);
                } else if (index < browser.getEngine().getHistory().getEntries().size() - 2) {
                  forwardButton.setDisable(false);
                } else if (index < browser.getEngine().getHistory().getEntries().size() - 1) {
                  forwardButton.setDisable(false);
                } else if (index == browser.getEngine().getHistory().getEntries().size() - 1) {
                  forwardButton.setDisable(true);
                }
              }
            });

    progress.setPrefSize(25, 25);
    progress.visibleProperty().bind(browser.getEngine().getLoadWorker().runningProperty());
    BorderPane border = new BorderPane();
    HBox topBar = new HBox();
    topBar.setAlignment(Pos.CENTER);
    topBar.setSpacing(10);
    topBar.setPadding(new Insets(10, 10, 10, 10));
    topBar
        .getChildren()
        .addAll(
            progress, reloadButton, url, goButton, backButton, forwardButton, webHistoryComboBox);

    border.setTop(topBar);
    border.setCenter(browser);
    border.setPrefHeight(Screen.getPrimary().getVisualBounds().getHeight());
    border.setPrefWidth(Screen.getPrimary().getVisualBounds().getWidth());

    return border;
  }
コード例 #16
0
ファイル: Controller.java プロジェクト: priscilacosta/novosga
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    loading.setVisible(false);
    checkTodos.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
            boolean checked = ((CheckBox) t.getTarget()).isSelected();
            for (Node node : servicos.getChildren()) {
              ((CheckBox) node).setSelected(checked);
            }
          }
        });
    unidades.setItems(FXCollections.observableList(new ArrayList<ComboboxItem>()));
    unidades.setOnAction(
        new EventHandler() {
          @Override
          public void handle(Event t) {
            loading.setVisible(true);
            checkTodos.setSelected(false);
            ComboBox cb = (ComboBox) t.getTarget();
            cb.getSelectionModel().selectedItemProperty();
            ComboboxItem item =
                (ComboboxItem) cb.getSelectionModel().selectedItemProperty().getValue();
            if (item != null && Integer.parseInt(item.getKey()) > 0) {
              unidadeAtual = Integer.parseInt(item.getKey());
              updateServicos(main.getService().buscarServicos(unidadeAtual));
            }
            loading.setVisible(false);
          }
        });
    buscar.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
            loading.setVisible(true);
            servicos.getChildren().clear();
            unidadeAtual = 0;
            try {
              main.getService()
                  .loadUrls(
                      servidor.getText(),
                      new Runnable() {
                        @Override
                        public void run() {
                          updateUnidades(main.getService().buscarUnidades());
                          loading.setVisible(false);
                        }
                      });
            } catch (Exception e) {
              loading.setVisible(false);
            }
          }
        });
    salvar.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
            loading.setVisible(true);
            try {
              List<Integer> idServicos = new ArrayList<Integer>();
              for (Node node : servicos.getChildren()) {
                if (((CheckBox) node).isSelected()) {
                  try {
                    String id = node.getId().split("-")[1];
                    idServicos.add(Integer.parseInt(id));
                  } catch (Exception e) {
                  }
                }
              }
              PainelConfig config = main.getConfig();
              config.get(PainelConfig.KEY_SERVER).setValue(servidor.getText());
              config.get(PainelConfig.KEY_UNIDADE, Integer.class).setValue(unidadeAtual);
              config
                  .get(PainelConfig.KEY_SERVICOS, Integer[].class)
                  .setValue(idServicos.toArray(new Integer[0]));
              // som e tema
              config.get(PainelConfig.KEY_SCREENSAVER_URL).setValue(videoUrl.getText());
              config
                  .get(PainelConfig.KEY_LANGUAGE)
                  .setValue(
                      ((ComboboxItem) language.getSelectionModel().getSelectedItem()).getKey());
              config
                  .get(PainelConfig.KEY_SOUND_VOICE, Boolean.class)
                  .setValue(vocalizar.isSelected());
              config.get(PainelConfig.KEY_COR_FUNDO).setValue(colorToHex(corFundo.getValue()));
              config
                  .get(PainelConfig.KEY_COR_MENSAGEM)
                  .setValue(colorToHex(corMensagem.getValue()));
              config.get(PainelConfig.KEY_COR_SENHA).setValue(colorToHex(corSenha.getValue()));
              config.get(PainelConfig.KEY_COR_GUICHE).setValue(colorToHex(corGuiche.getValue()));
              // screensaver layout
              config
                  .get(PainelConfig.KEY_SCREENSAVER_LAYOUT, Integer.class)
                  .setValue(
                      Integer.parseInt(((RadioButton) svLayout.getSelectedToggle()).getText()));
              config.save();

              main.getService().register(servidor.getText());
            } catch (Exception e) {
              e.printStackTrace();
            }
            loading.setVisible(false);
          }
        });
    exibirPainel.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
            main.getPainel().show();
          }
        });
    // language
    language.setItems(FXCollections.observableList(new ArrayList<ComboboxItem>()));
    SortedSet<String> keys = new TreeSet<String>(Main.locales.keySet());
    for (String key : keys) {
      language.getItems().add(new ComboboxItem(key, Main.locales.get(key)));
      if (Locale.getDefault().getLanguage().equals(key)) {
        main.getConfig().get(PainelConfig.KEY_LANGUAGE).setValue(Locale.getDefault().getLanguage());
      }
    }
    String defaultLang = main.getConfig().get(PainelConfig.KEY_LANGUAGE).getValue();
    for (Object item : language.getItems()) {
      if (defaultLang.equals(((ComboboxItem) item).getKey())) {
        language.getSelectionModel().select(item);
        break;
      }
    }
    language.setOnAction(
        new EventHandler() {
          @Override
          public void handle(Event t) {
            ComboBox cb = (ComboBox) t.getTarget();
            cb.getSelectionModel().selectedItemProperty();
            ComboboxItem item =
                (ComboboxItem) cb.getSelectionModel().selectedItemProperty().getValue();
            main.getConfig().get(PainelConfig.KEY_LANGUAGE).setValue(item.getKey());
          }
        });
    // video
    monitorId.setItems(FXCollections.observableList(new ArrayList<ComboboxItem>()));
    Integer defaultId = main.getConfig().get(PainelConfig.KEY_MONITOR_ID, Integer.class).getValue();
    for (int i = 0; i < Screen.getScreens().size(); i++) {
      StringBuilder sb = new StringBuilder();
      Rectangle2D b = Screen.getScreens().get(i).getBounds();
      sb.append(i + 1)
          .append(" (")
          .append(b.getWidth())
          .append(" x ")
          .append(b.getHeight())
          .append(")");
      ComboboxItem item = new ComboboxItem(i, sb.toString());
      monitorId.getItems().add(item);
      if (defaultId.equals(i)) {
        monitorId.getSelectionModel().select(item);
      }
    }
    monitorId.setOnAction(
        new EventHandler() {
          @Override
          public void handle(Event t) {
            ComboBox cb = (ComboBox) t.getTarget();
            cb.getSelectionModel().selectedItemProperty();
            ComboboxItem item =
                (ComboboxItem) cb.getSelectionModel().selectedItemProperty().getValue();
            Integer key = Integer.parseInt(item.getKey());
            if (key >= 0 && key < Screen.getScreens().size()) {
              main.getConfig().get(PainelConfig.KEY_MONITOR_ID, Integer.class).setValue(key);
            }
          }
        });
    // screen saver
    screenSaverTimeout.setItems(FXCollections.observableList(new ArrayList<ComboboxItem>()));
    Integer defaultTimeout =
        main.getConfig().get(PainelConfig.KEY_SCREENSAVER_TIMEOUT, Integer.class).getValue();
    SortedSet<Integer> keys2 = new TreeSet<Integer>(Main.intervals.keySet());
    for (Integer key : keys2) {
      ComboboxItem item = new ComboboxItem(key, Main.intervals.get(key));
      screenSaverTimeout.getItems().add(item);
      if (defaultTimeout.equals(key)) {
        screenSaverTimeout.getSelectionModel().select(item);
      }
    }
    screenSaverTimeout.setOnAction(
        new EventHandler() {
          @Override
          public void handle(Event t) {
            ComboBox cb = (ComboBox) t.getTarget();
            cb.getSelectionModel().selectedItemProperty();
            ComboboxItem item =
                (ComboboxItem) cb.getSelectionModel().selectedItemProperty().getValue();
            main.getConfig()
                .get(PainelConfig.KEY_SCREENSAVER_TIMEOUT, Integer.class)
                .setValue(Integer.parseInt(item.getKey()));
          }
        });
    fileChooser.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("MP4", "*.mp4"));
            fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("AVI", "*.avi"));
            fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("HLS", "*.m3u8"));
            try {
              File file = fileChooser.showOpenDialog(null);
              videoUrl.setText(file.toURI().toString());
            } catch (Exception e) {
            }
          }
        });
    testVideo.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            try {
              String url = videoUrl.getText();
              if (url != null && !url.isEmpty()) {
                if (tester != null) {
                  tester.destroy();
                }
                tester = new VideoTester(url.trim());
                Stage painelStage = new Stage();
                painelStage.initOwner(stage);
                painelStage.setOnCloseRequest(
                    new EventHandler<WindowEvent>() {
                      @Override
                      public void handle(WindowEvent t) {
                        tester.destroy();
                      }
                    });
                tester.start(painelStage);
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
    // screesaver layout - marcando o padrao
    try {
      int id = main.getConfig().get(PainelConfig.KEY_SCREENSAVER_LAYOUT, Integer.class).getValue();
      svLayout.getToggles().get(id - 1).setSelected(true);
    } catch (Exception e) {
    }
    // criando stage
    this.stage = new Stage();
    stage.setTitle("Painel | Novo SGA");
    stage.setScene(new Scene(getRoot()));
    // so esconde se suportar systray
    if (SystemTray.isSupported()) {
      final Controller self = this;
      stage.setOnCloseRequest(
          new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent t) {
              self.stage.hide();
            }
          });
    }
  }
コード例 #17
0
ファイル: Main.java プロジェクト: 1j4k7/Graphics
  @Override
  public void start(Stage stage) {
    sun.setFitHeight(100);
    sun.setFitWidth(100);
    sun.setX(200);
    sun.setY(200);
    quas.setFitHeight(50);
    quas.setFitWidth(50);
    wex.setFitHeight(50);
    wex.setFitWidth(50);
    exort.setFitHeight(50);
    exort.setFitWidth(50);

    Circle orbit1 = new Circle();
    orbit1.setRotate(-90);
    orbit1.setRadius(100);
    orbit1.setCenterX(250);
    orbit1.setCenterY(250);
    PathTransition path1 = new PathTransition();
    path1.setPath(orbit1);
    path1.setNode(quas);
    path1.setDuration(Duration.seconds(5));
    path1.setCycleCount(Timeline.INDEFINITE);

    Circle orbit2 = new Circle();
    orbit2.setRotate(30);
    orbit2.setRadius(100);
    orbit2.setCenterX(250);
    orbit2.setCenterY(250);
    PathTransition path2 = new PathTransition();
    path2.setPath(orbit2);
    path2.setNode(wex);
    path2.setDuration(Duration.seconds(5));
    path2.setCycleCount(Timeline.INDEFINITE);

    Circle orbit3 = new Circle();
    orbit3.setRotate(150);
    orbit3.setRadius(100);
    orbit3.setCenterX(250);
    orbit3.setCenterY(250);
    PathTransition path3 = new PathTransition();
    path3.setPath(orbit3);
    path3.setNode(exort);
    path3.setDuration(Duration.seconds(5));
    path3.setCycleCount(Timeline.INDEFINITE);

    ComboBox<String> invoke = new ComboBox<String>();
    invoke.setEditable(false);
    invoke
        .getItems()
        .addAll(
            "Cold Snap",
            "Ghost Walk",
            "Tornado",
            "EMP",
            "Alacrity",
            "Chaos Meteor",
            "Sun Strike",
            "Forge Spirit",
            "Ice Wall",
            "Deafening Blast");
    invoke.setOnAction(
        e -> {
          switch (invoke.getValue()) {
            case "Cold Snap":
              path1.setNode(quas);
              path2.setNode(quas);
              path3.setNode(quas);
              break;
            case "Ghost Walk":
              path1.setNode(quas);
              path2.setNode(quas);
              path3.setNode(wex);
              break;
            case "Tornado":
              path1.setNode(wex);
              path2.setNode(wex);
              path3.setNode(quas);
              break;
            case "EMP":
              path1.setNode(wex);
              path2.setNode(wex);
              path3.setNode(wex);
              break;
            case "Alacrity":
              path1.setNode(wex);
              path2.setNode(wex);
              path3.setNode(exort);
              break;
            case "Chaos Meteor":
              path1.setNode(exort);
              path2.setNode(exort);
              path3.setNode(wex);
              break;
            case "Sun Strike":
              path1.setNode(exort);
              path2.setNode(exort);
              path3.setNode(exort);
              break;
            case "Forge Spirit":
              path1.setNode(exort);
              path2.setNode(exort);
              path3.setNode(quas);
              break;
            case "Ice Wall":
              path1.setNode(quas);
              path2.setNode(quas);
              path3.setNode(exort);
              break;
            case "Deafening Blast":
              path1.setNode(quas);
              path2.setNode(wex);
              path3.setNode(exort);
              break;
            default:
              path1.setNode(quas);
              path2.setNode(wex);
              path3.setNode(exort);
              break;
          }
        });

    path1.play();
    path2.play();
    path3.play();

    Pane pane = new Pane();
    pane.getChildren().addAll(quas, wex, exort, sun, invoke);
    stage.setScene(new Scene(pane, 500, 500));
    stage.setTitle("Spell Combinations");
    stage.show();
  }
コード例 #18
0
  public IndividualLifeBarTitledPane(final IndividualLifeBar individualLifeBar) {
    this.individualLifeBar = individualLifeBar;

    setText("Configuração LifeBar de Objeto");

    VBox layout = new VBox();

    GridPane gridPane = new GridPane();

    ColumnConstraints col1 = new ColumnConstraints();
    col1.setPercentWidth(40);
    ColumnConstraints col2 = new ColumnConstraints();
    col2.setPercentWidth(30);
    ColumnConstraints col3 = new ColumnConstraints();
    col3.setPercentWidth(30);
    gridPane.getColumnConstraints().addAll(col1, col2, col3);

    Label label = new Label("Objeto");
    gridPane.add(label, 0, 0);

    boxLabelObjects = new ComboBox<String>();
    boxLabelObjects.getItems().addAll(individualLifeBar.getWorld().getObjectIds());

    if (individualLifeBar.getOwnerId() != null) {
      boxLabelObjects.getSelectionModel().select(individualLifeBar.getOwnerId());
    }

    boxLabelObjects.setOnMouseClicked(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            for (String label : individualLifeBar.getWorld().getObjectIds()) {
              if (!boxLabelObjects.getItems().contains(label)) {
                boxLabelObjects.getItems().add(label);
              }
            }
          }
        });

    boxLabelObjects.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            individualLifeBar.setOwner(boxLabelObjects.getValue());
          }
        });

    gridPane.add(boxLabelObjects, 1, 0);
    layout.getChildren().add(gridPane);

    Separator separator = new Separator(Orientation.HORIZONTAL);
    separator.setPadding(new Insets(5, 0, 5, 0));
    layout.getChildren().add(separator);
    layout.setPadding(new Insets(5));

    lifeBarPane = new LifebarPane(individualLifeBar);
    layout.getChildren().add(lifeBarPane);
    ScrollPane scroll = new ScrollPane(layout);
    scroll.setFitToWidth(true);
    setContent(scroll);
  }