@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(); }
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"); } } }); }
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); }
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); } } }); }
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); }
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; }
/* 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 */ }