/** @see javafx.scene.control.Cell#updateItem(java.lang.Object, boolean) */ @Override protected void updateItem(ResultsItem item, boolean empty) { super.updateItem(item, empty); if (item != null) { setText(""); GridPane gp = new GridPane(); gp.setHgap(0.0); gp.setVgap(0.0); gp.setPadding(new Insets(5, 5, 5, 5)); gp.setMinWidth(250); ColumnConstraints constraint1 = new ColumnConstraints(); constraint1.setFillWidth(false); constraint1.setHgrow(Priority.NEVER); constraint1.setMinWidth(160); constraint1.setMaxWidth(160); gp.getColumnConstraints().add(constraint1); ColumnConstraints constraint2 = new ColumnConstraints(); constraint2.setFillWidth(true); constraint2.setHgrow(Priority.SOMETIMES); gp.getColumnConstraints().add(constraint2); int row = 0; gp.add(wrapAndStyle(makeBoldLabel("Message"), row), 0, row); Label message = new Label(item.getMessage()); message.setWrapText(true); message.maxWidthProperty().bind(this.widthProperty().subtract(180)); gp.add(wrapAndStyle(message, row), 1, row++); gp.add(wrapAndStyle(makeBoldLabel("Severity"), row), 0, row); Label severity = new Label(item.getSeverity().getName()); severity.setWrapText(true); severity.maxWidthProperty().bind(this.widthProperty().subtract(180)); gp.add(wrapAndStyle(severity, row), 1, row++); gp.add(wrapAndStyle(makeBoldLabel("Rule UUID"), row), 0, row); Label ruleUUID = new Label(item.getRuleUuid()); ruleUUID.setWrapText(true); ruleUUID.maxWidthProperty().bind(this.widthProperty().subtract(180)); gp.add(wrapAndStyle(ruleUUID, row), 1, row++); gp.add(wrapAndStyle(makeBoldLabel("Error Code"), row), 0, row); Label errorCode = new Label(item.getErrorCode() + ""); errorCode.setWrapText(true); errorCode.maxWidthProperty().bind(this.widthProperty().subtract(180)); gp.add(wrapAndStyle(errorCode, row), 1, row++); setGraphic(gp); this.setStyle("-fx-border-width: 0 0 2 0; -fx-border-color: grey; "); } else { setText(""); setGraphic(null); this.setStyle(""); } }
private void initTopBar() { title.setId("title"); title.setWrapText(true); toggleEarthMode.setId("button"); title.setTextAlignment(TextAlignment.CENTER); toggleEarthMode.setTextAlignment(TextAlignment.CENTER); toggleEarthMode.setWrapText(true); topBar.setHgap(7); topBar.add(title, 15, 0); topBar.add(toggleEarthMode, 0, 0); }
public AlertHandler(String message, EventHandler<ActionEvent> confirmHandler) { super(14); // add controls to the popup. final Label promptMessage = new Label(message); final ImageView alertImage = new ImageView(ResourceUtil.getImage("alert_48.png")); alertImage.setFitHeight(32); alertImage.setPreserveRatio(true); promptMessage.setGraphic(alertImage); promptMessage.setWrapText(true); promptMessage.setPrefWidth(350); // action button text setup. HBox buttonBar = new HBox(20); final Button confirmButton = new Button(getString("dialog.continue")); confirmButton.setDefaultButton(true); buttonBar.getChildren().addAll(confirmButton); // layout the popup. setPadding(new Insets(10)); getStyleClass().add("alert-dialog"); getChildren().addAll(promptMessage, buttonBar); final DropShadow dropShadow = new DropShadow(); setEffect(dropShadow); // confirm and close the popup. confirmButton.setOnAction(confirmHandler); }
@Override public void initialize() { disputesTable = new TableView<>(); VBox.setVgrow(disputesTable, Priority.SOMETIMES); disputesTable.setMinHeight(150); root.getChildren().add(disputesTable); TableColumn<Dispute, Dispute> tradeIdColumn = getTradeIdColumn(); disputesTable.getColumns().add(tradeIdColumn); TableColumn<Dispute, Dispute> roleColumn = getRoleColumn(); disputesTable.getColumns().add(roleColumn); TableColumn<Dispute, Dispute> dateColumn = getDateColumn(); disputesTable.getColumns().add(dateColumn); TableColumn<Dispute, Dispute> contractColumn = getContractColumn(); disputesTable.getColumns().add(contractColumn); TableColumn<Dispute, Dispute> stateColumn = getStateColumn(); disputesTable.getColumns().add(stateColumn); disputesTable.getSortOrder().add(dateColumn); disputesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); Label placeholder = new Label("There are no open tickets"); placeholder.setWrapText(true); disputesTable.setPlaceholder(placeholder); disputesTable.getSelectionModel().clearSelection(); disputeChangeListener = (observableValue, oldValue, newValue) -> onSelectDispute(newValue); }
@Override public void setupHelp() { Label helpText = new Label(help.get(Help.HelpKey.HOMEPAGE_HELP)); helpText.setMaxWidth(300); helpText.setWrapText(true); helpText.setTextAlignment(TextAlignment.CENTER); setHelpPopupContent(helpText); }
/** * Creates the inheritance tab in the popup. * * @param artifact The popup artifact * @return inheritance tab or null if nothing to do */ public VBox createInheritanceTab(final PackageArtifact artifact) { final VBox inheritanceBox = new VBox(12); inheritanceBox.getStyleClass().add(PACKAGE_TOOL_POPUP_PROPERTY_TAB); boolean hasInheritableProperties = false; // create label to explain what this tab is about. Label inheritanceTabIntroLabel = new Label(labels.get(Labels.LabelKey.INHERITANCE_TAB_INTRO)); inheritanceTabIntroLabel.setPrefWidth(450); inheritanceTabIntroLabel.setWrapText(true); inheritanceBox.getChildren().add(inheritanceTabIntroLabel); // create label to explain usage of buttons. Label inheritanceButtonExplainedLabel = new Label(labels.get(Labels.LabelKey.INHERITANCE_BUTTON_EXPLAINED)); inheritanceButtonExplainedLabel.setPrefWidth(450); inheritanceButtonExplainedLabel.setWrapText(true); inheritanceBox.getChildren().add(inheritanceButtonExplainedLabel); Separator groupSeparator = new Separator(); inheritanceBox.getChildren().add(groupSeparator); // Loop through properties for the given artifact. for (String propertyName : packageOntologyService.getProperties(artifact).keySet()) { // If the property is inheritable, create a button which would allow the values to be apply to // children // appropriately if (packageOntologyService.isInheritableProperty(artifact, propertyName)) { inheritanceBox.getChildren().add(createInheritanceBox(artifact.getType(), propertyName)); groupSeparator = new Separator(); inheritanceBox.getChildren().add(groupSeparator); hasInheritableProperties = true; } } if (!hasInheritableProperties) { Label noInheritablePropertyLabel = new Label(labels.get(Labels.LabelKey.NO_INHERITABLE_PROPERTY)); inheritanceTabIntroLabel.setPrefWidth(450); inheritanceTabIntroLabel.setWrapText(true); inheritanceBox.getChildren().add(noInheritablePropertyLabel); } return inheritanceBox; }
private VBox setUpTop() { topLabel = new Label("Лучший онлайн12 121 12 12121212 1212 12 12 12 кредит №" + counter++); topLabel.setWrapText(true); topLabel.getStyleClass().add("credit-view_top-label"); topContainer = new VBox(topLabel); topContainer.getStyleClass().add("credit-view_top-container"); this.setTop(topContainer); return topContainer; }
public static Label addMultilineLabel(GridPane gridPane, int rowIndex, String text, double top) { Label label = new Label(text); label.setWrapText(true); GridPane.setHalignment(label, HPos.LEFT); GridPane.setRowIndex(label, rowIndex); GridPane.setColumnSpan(label, 2); GridPane.setMargin(label, new Insets(top, 0, 0, 0)); gridPane.getChildren().add(label); return label; }
@Override public void initialize() { buildForm(); paymentAccountChangeListener = (observable, oldValue, newValue) -> { if (newValue != null) onSelectAccount(newValue); }; Label placeholder = new Label("There are no accounts set up yet"); placeholder.setWrapText(true); paymentAccountsListView.setPlaceholder(placeholder); }
private TitledPane createTitledPane(CreditInfo creditInfo) { TitledPane titledPane = new TitledPane(); titledPane.setText("Credit Info ID: " + creditInfo.getCreditInfoId()); TextFlow textFlow = new TextFlow(); Label creditInfoLabel = new Label(creditInfo.toString()); creditInfoLabel.setWrapText(true); textFlow.getChildren().add(creditInfoLabel); titledPane.setContent(textFlow); return titledPane; }
private TitledPane createTitledPane(CreditRequest creditRequest) { TitledPane titledPane = new TitledPane(); titledPane.setText("UserId: " + creditRequest.getUserId()); VBox vBox = new VBox(); TextFlow textFlow = new TextFlow(); Label label = new Label(creditRequest.toString()); label.setWrapText(true); textFlow.getChildren().add(label); textFlow.getChildren().add(new Label("Validate: ")); CheckBox isValidCheckBox = new CheckBox(); CheckBox rejectCheckBox = new CheckBox(); isValidCheckBox .selectedProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue == true) { rejectCheckBox.setSelected(false); creditRequest.setValidated(true); } else { creditRequest.setValidated(null); } }); textFlow.getChildren().add(isValidCheckBox); textFlow.getChildren().add(new Label("Reject: ")); rejectCheckBox .selectedProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue == true) { isValidCheckBox.setSelected(false); creditRequest.setValidated(false); } else { creditRequest.setValidated(null); } }); textFlow.getChildren().add(rejectCheckBox); Button creditHistoryButton = new Button("View Credit History"); creditHistoryButton.setOnAction( e -> { session.setUserUnderValidationId(creditRequest.getUserId()); screens.toCreditHistoryPage(); }); vBox.getChildren().add(textFlow); vBox.getChildren().add(creditHistoryButton); titledPane.setContent(vBox); return titledPane; }
/** * Builds the element that lets the user add this exercise * * @param screenWidth * @param screenHeight * @param sourceFile * @param workoutBuilder */ public ExerciseContent( double screenWidth, double screenHeight, File sourceFile, CreateWorkout workoutBuilder) { // get the exercise details this.sourceFile = sourceFile; XMLParser parser = new XMLParser(sourceFile.getName()); exerciseLabel = new Label(parser.getDocumentInfo().getTitle()); exerciseLabel.setMinWidth(screenWidth * 0.1); exerciseLabel.setMinWidth(screenWidth * 0.075); descriptionLabel = new Label(parser.getDocumentInfo().getComment()); descriptionLabel.setMinWidth(screenWidth * 0.2); descriptionLabel.setMaxWidth(screenWidth * 0.2); descriptionLabel.setWrapText(true); repAmount = new TextField(); repAmount.setPrefWidth(screenWidth * 0.05); setAmount = new TextField(); setAmount.setPrefWidth(screenWidth * 0.05); addExercise = new Button("ADD"); addExercise.setPrefSize(screenWidth * 0.05, screenHeight * 0.025); setNodeCursor(addExercise); // add the exercise to the selected exercise list addExercise.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { if ((isInt(setAmount.getText())) && (isInt(repAmount.getText()))) { workoutBuilder.addToList( sourceFile.getName(), exerciseLabel.getText(), Integer.parseInt(setAmount.getText()), Integer.parseInt(repAmount.getText())); } } }); getChildren().addAll(exerciseLabel, descriptionLabel, repAmount, setAmount, addExercise); setWidth(screenWidth * 0.4); setHeight(screenHeight * 0.2); setSpacing(screenWidth * 0.01); setPadding(new Insets(0, 0, 0, screenWidth * 0.01)); }
public FileGridCell() { Label titleLabel = new Label(); titleLabel.setPrefWidth(80); titleLabel.setWrapText(true); titleLabel.setTextAlignment(TextAlignment.CENTER); title = titleLabel.textProperty(); ImageView iconView = new ImageView(); icon = iconView.imageProperty(); VBox vbox = new VBox(iconView, titleLabel); vbox.setAlignment(Pos.TOP_CENTER); setGraphic(vbox); }
public static void rightVisuaalid() { rightVbox = new VBox(); rightVbox.setSpacing(5); rightVbox.setPadding(new Insets(15, 0, 0, 10)); jaatmejaamadeVastuvottLabel1 = new Label("Jäätmejaamades võetakse elanikelt tasuta vastu:"); jaatmejaamadeVastuvottLabel1.setStyle("-fx-font: 12 helvetica;-fx-font-weight: bold"); Label jaatmejaamadeVastuvottLabel2 = new Label( "* pakendeid " + "\n" + "* plaste" + "\n" + "* paberit ja pappi" + "\n" + "* immutamata/töötlemata puitu" + "\n" + "* betooni ja telliseid (va Rahumäe jäätmejaam, kus kehtib eraldi hinnakiri)" + "\n" + "* vanametalli" + "\n" + "* toiduõli" + "\n" + "* kasutuskõlblikku vanamööblit" + "\n" + "* sõiduauto rehve" + "\n" + "* elektri- ja elektroonikajäätmeid" + "\n" + "* klaasi" + "\n" + "* kasutatud riideid" + "\n" + "* biolagunevaid aia- ja haljastusjäätmeid" + "\n" + "* koduseid ohtlikke jäätmeid" + "\n"); jaatmejaamadeVastuvottLabel2.setMaxWidth(250); jaatmejaamadeVastuvottLabel2.setWrapText(true); kaardiNupp = new Button("Jäätmejaamade kaart"); nupuvajutus(); rightVbox .getChildren() .addAll(jaatmejaamadeVastuvottLabel1, jaatmejaamadeVastuvottLabel2, kaardiNupp); Java_fx.border.setRight(rightVbox); }
private HBox createSkipLoginBar() { HBox hbox = createHBox(); Label labelWarning = new Label(); labelWarning.setText(skipWarning); labelWarning.setWrapText(true); Button skipButton = new Button("Skip login"); skipButton.setOnAction( event -> { // skip login, direct to preferencesUI with default user settings buildDefaultUser(); stage.setScene(preferenceUI.createPreferenceScene()); }); hbox.getChildren().addAll(labelWarning, skipButton); return hbox; }
@Override public void start(Stage stage) { StackPane root = new StackPane(); Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds(); Scene scene = new Scene(root, visualBounds.getWidth(), visualBounds.getHeight()); stage .getIcons() .add(new Image(SamplePropertiesJavaFxPorts.class.getResourceAsStream("/icon.png"))); stage.setScene(scene); stage.show(); Label label = new Label(); root.getChildren().add(label); // Create a properties file PropertiesJavaFxPorts propertiesJavaFxPorts = new PropertiesJavaFxPorts("app.properties"); // Get value for "counter" key if exists String strCounter = propertiesJavaFxPorts.getProperty("counter"); if (strCounter == null) { strCounter = "0"; } int counter = Integer.valueOf(strCounter); counter++; strCounter = String.valueOf(counter); // Store new value for "counter" key in properties file propertiesJavaFxPorts.setProperty("counter", strCounter); label.setText("Counter = " + strCounter + "\n" + propertiesJavaFxPorts.getPath()); label.setWrapText(true); scene.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { switch (event.getCode()) { case ESCAPE: Platform.exit(); System.exit(0); break; } event.consume(); } }); }
public static void nupuvajutus(Button sorteeriNupp, TextField kasutajaInput) { // "Sorteeri!" nupp ACTION! Pane sobivKonteinerLayout = new Pane(); sorteeriNupp.setOnAction( event -> { voimalikPrygiList.getPrygi().clear(); sobivKonteinerLayout.getChildren().clear(); String input = kasutajaInput.getText().toLowerCase(); String sobivKonteiner = ""; if (input.isEmpty()) { sobivKonteiner = "Unustasid pürgi sisestada!"; } else if (TopView.bio.kuhuVisata(input) != "") { sobivKonteiner = TopView.bio.kuhuVisata(input); } else if (TopView.elektroonika.kuhuVisata(input) != "") { sobivKonteiner = TopView.elektroonika.kuhuVisata(input); } else if (TopView.paberPapp.kuhuVisata(input) != "") { sobivKonteiner = TopView.paberPapp.kuhuVisata(input); } else if (TopView.ohtlikud.kuhuVisata(input) != "") { sobivKonteiner = TopView.ohtlikud.kuhuVisata(input); } else if (TopView.metallpakend.kuhuVisata(input) != "") { sobivKonteiner = TopView.metallpakend.kuhuVisata(input); } else if (TopView.klaaspakend.kuhuVisata(input) != "") { sobivKonteiner = TopView.klaaspakend.kuhuVisata(input); } else if (TopView.plastpakend.kuhuVisata(input) != "") { sobivKonteiner = TopView.plastpakend.kuhuVisata(input); } else if (voimalikPrygiList.getPrygi().isEmpty()) { sobivKonteiner = "Kahjuks ei leidnud hetkel sobivat konteinerit, vaata äkki leiad midagi sarnast pürgikonteineritele klikkides."; } else { sobivKonteiner = "Prügi " + kasutajaInput.getText() + " ei leitud, äkki mõtlesid hoopis midagi neist : " + "\n" + voimalikPrygiList.prindiKonteineriList(); } kasutajaInput.clear(); Label sobivKonteinerLabel = new Label(sobivKonteiner); sobivKonteinerLabel.setMaxWidth(180); sobivKonteinerLabel.setWrapText(true); sobivKonteinerLayout.getChildren().add(sobivKonteinerLabel); }); leftVbox.getChildren().add(sobivKonteinerLayout); }
/** Set the Labels */ protected void setLabels() { mLabels = new HashMap<String, Label>(); mValues = new HashMap<String, Label>(); for (String name : mLabelNames) { Label newLabel1 = new Label(name); Label newLabel2 = new Label(); newLabel1.setFont(new Font("Arial", 20)); newLabel2.setFont(new Font("Arial", 20)); mLabels.put(name, newLabel1); mValues.put(name, newLabel2); } Label upgradeLabel = new Label(mUpgradeName); upgradeLabel.setFont(new Font("Arial", 25)); upgradeLabel.setWrapText(true); mLabels.put(mUpgradeName, upgradeLabel); update(); }
public static void displaySimple(String title, String message) { Stage window = new Stage(); window.initModality(Modality.APPLICATION_MODAL); window.setTitle(title); window.setWidth(450); window.setHeight(200); Label label = new Label(); label.setWrapText(true); label.setText(message); label.setTextAlignment(TextAlignment.CENTER); Button closeButton = new Button("Close"); closeButton.setOnAction(e -> window.close()); VBox layout = new VBox(20); layout.getChildren().addAll(label, closeButton); layout.setAlignment(Pos.CENTER); Scene scene = new Scene(layout); window.setScene(scene); window.showAndWait(); }
public static boolean displayConfirmation() { Stage window = new Stage(); window.initModality(Modality.APPLICATION_MODAL); window.setTitle("Exit?"); window.setWidth(300); window.setHeight(250); Label label = new Label(); label.setWrapText(true); label.setText("Are you sure you want to quit?"); label.setTextAlignment(TextAlignment.CENTER); label.setPadding(new Insets(20, 20, 20, 20)); Button yesButton = new Button("Yes"); yesButton.setOnAction( e -> { yesNo = true; window.close(); }); Button noButton = new Button("No"); noButton.setOnAction( e -> { yesNo = false; window.close(); }); VBox layout = new VBox(20); layout.getChildren().addAll(label, yesButton, noButton); layout.setAlignment(Pos.CENTER); Scene scene = new Scene(layout); window.setScene(scene); window.showAndWait(); return yesNo; }
private HBox createInheritanceBox(String artifactType, String propertyName) { HBox propertyBox = new HBox(30); VBox propNameAndExplation = new VBox(); final Label propertyNameLabel = new Label(ontologyLabels.get(propertyName)); propertyNameLabel.setPrefWidth(400); propertyNameLabel.getStyleClass().add(CssConstants.BOLD_TEXT_CLASS); // propertyNameLabel.setStyle(CssConstants.BOLD_TEXT_CLASS); StringBuilder sb = new StringBuilder(); final String typeSeparator = ", "; for (String inheritingTypes : presenter.getInheritingTypes(artifactType, propertyName)) { sb.append(ontologyLabels.get(inheritingTypes)); sb.append(typeSeparator); } sb.deleteCharAt(sb.lastIndexOf(typeSeparator)); final Label descendantTypesLabel = new Label( String.format(labels.get(Labels.LabelKey.INHERITANCE_DESCENDANT_TYPE), sb.toString())); descendantTypesLabel.setPrefWidth(400); descendantTypesLabel.setWrapText(true); propNameAndExplation.getChildren().add(propertyNameLabel); propNameAndExplation.getChildren().add(descendantTypesLabel); // propertyBox.getChildren().add(propertyNameLabel); propertyBox.getChildren().add(propNameAndExplation); final CheckBox applyPropertyValueToChildrenCheckBox = new CheckBox(); propertyBox.getChildren().add(applyPropertyValueToChildrenCheckBox); // Add inheritance to map metadataInheritanceButtonMap.put(propertyName, applyPropertyValueToChildrenCheckBox); return propertyBox; }
public GridPaneSample() { VBox vbox = new VBox(); // grid1 places the child by specifying the rows and columns in // GridPane.setContraints() Label grid1Caption = new Label( "The example below shows GridPane content placement by specifying rows and columns:"); grid1Caption.setWrapText(true); GridPane grid1 = new GridPane(); grid1.setHgap(4); grid1.setVgap(6); grid1.setPadding(new Insets(18, 18, 18, 18)); ObservableList<Node> content = grid1.getChildren(); Label label = new Label("Name:"); GridPane.setConstraints(label, 0, 0); GridPane.setHalignment(label, HPos.RIGHT); content.add(label); label = new Label("John Q. Public"); GridPane.setConstraints(label, 1, 0, 2, 1); GridPane.setHalignment(label, HPos.LEFT); content.add(label); label = new Label("Address:"); GridPane.setConstraints(label, 0, 1); GridPane.setHalignment(label, HPos.RIGHT); content.add(label); label = new Label("12345 Main Street, Some City, CA"); GridPane.setConstraints(label, 1, 1, 5, 1); GridPane.setHalignment(label, HPos.LEFT); content.add(label); vbox.getChildren().addAll(grid1Caption, grid1, new Separator()); // grid2 places the child by influencing the rows and columns themselves // via GridRowInfo and GridColumnInfo. This grid uses the preferred // width/height and max/min width/height. Label grid2Caption = new Label( "The example below shows GridPane content placement by influencing the rows and columns themselves."); grid2Caption.setWrapText(true); grid2Caption.setWrapText(true); GridPane grid2 = new GridPane(); grid2.setPadding(new Insets(18, 18, 18, 18)); RowConstraints rowinfo = new RowConstraints(40, 40, 40); ColumnConstraints colinfo = new ColumnConstraints(90, 90, 90); for (int i = 0; i <= 2; i++) { grid2.getRowConstraints().add(rowinfo); } for (int j = 0; j <= 2; j++) { grid2.getColumnConstraints().add(colinfo); } Label category = new Label("Category:"); GridPane.setHalignment(category, HPos.RIGHT); Label categoryValue = new Label("Wines"); Label company = new Label("Company:"); GridPane.setHalignment(company, HPos.RIGHT); Label companyValue = new Label("Acme Winery"); Label rating = new Label("Rating:"); GridPane.setHalignment(rating, HPos.RIGHT); Label ratingValue = new Label("Excellent"); ImageView imageView = new ImageView(ICON_48); GridPane.setHalignment(imageView, HPos.CENTER); // Place content GridPane.setConstraints(category, 0, 0); GridPane.setConstraints(categoryValue, 1, 0); GridPane.setConstraints(company, 0, 1); GridPane.setConstraints(companyValue, 1, 1); GridPane.setConstraints(imageView, 2, 1); GridPane.setConstraints(rating, 0, 2); GridPane.setConstraints(ratingValue, 1, 2); grid2 .getChildren() .addAll(category, categoryValue, company, companyValue, imageView, rating, ratingValue); vbox.getChildren().addAll(grid2Caption, grid2, new Separator()); // grid3 places the child by influencing the rows and columns // via GridRowInfo and GridColumnInfo. This grid uses the percentages Label grid3Caption = new Label( "The example below shows GridPane content placement by influencing row and column percentages. Also, grid lines are made visible in this example. The lines can be helpful in debugging."); grid3Caption.setWrapText(true); GridPane grid3 = new GridPane(); grid3.setPadding(new Insets(18, 18, 18, 18)); grid3.setGridLinesVisible(true); RowConstraints rowinfo3 = new RowConstraints(); rowinfo3.setPercentHeight(50); ColumnConstraints colInfo2 = new ColumnConstraints(); colInfo2.setPercentWidth(25); ColumnConstraints colInfo3 = new ColumnConstraints(); colInfo3.setPercentWidth(50); grid3.getRowConstraints().add(rowinfo3); // 2*50 percent grid3.getRowConstraints().add(rowinfo3); grid3.getColumnConstraints().add(colInfo2); // 25 percent grid3.getColumnConstraints().add(colInfo3); // 50 percent grid3.getColumnConstraints().add(colInfo2); // 25 percent Label condLabel = new Label(" Member Name:"); GridPane.setHalignment(condLabel, HPos.RIGHT); GridPane.setConstraints(condLabel, 0, 0); Label condValue = new Label("MyName"); GridPane.setMargin(condValue, new Insets(0, 0, 0, 10)); GridPane.setConstraints(condValue, 1, 0); Label acctLabel = new Label("Member Number:"); GridPane.setHalignment(acctLabel, HPos.RIGHT); GridPane.setConstraints(acctLabel, 0, 1); TextField textBox = new TextField("Your number"); GridPane.setMargin(textBox, new Insets(10, 10, 10, 10)); GridPane.setConstraints(textBox, 1, 1); Button button = new Button("Help"); GridPane.setConstraints(button, 2, 1); GridPane.setMargin(button, new Insets(10, 10, 10, 10)); GridPane.setHalignment(button, HPos.CENTER); GridPane.setConstraints(condValue, 1, 0); grid3.getChildren().addAll(condLabel, condValue, button, acctLabel, textBox); vbox.getChildren().addAll(grid3Caption, grid3); getChildren().add(vbox); }
/** * @param owner * @param title * @param titleLong * @param message * @return */ public Response show(Stage owner, String title, String titleLong, String message) { final Stage stage = new Stage(); final BooleanProperty isOK = new SimpleBooleanProperty(false); stage.setTitle(title); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(owner); // BorderPane root = new BorderPane(); VBox root = new VBox(); Scene scene = new Scene(root); stage.setScene(scene); stage.setWidth(500); stage.setHeight(250); stage.initStyle(StageStyle.UTILITY); stage.setResizable(false); Node header = DialogHeader.getDialogHeader(ICON, titleLong); ImageView imageView = ResourceLoader.getImage(ICON, 65, 65); stage.getIcons().add(imageView.getImage()); HBox buttonPanel = new HBox(); Button ok = new Button("OK"); ok.setDefaultButton(true); buttonPanel.getChildren().addAll(ok); buttonPanel.setAlignment(Pos.CENTER_RIGHT); buttonPanel.setPadding(new Insets(10, 10, 10, 10)); buttonPanel.setSpacing(10); buttonPanel.setMaxHeight(25); HBox messagePanel = new HBox(); messagePanel.setPadding(new Insets(30, 30, 30, 30)); Label mewssage = new Label(message); messagePanel.getChildren().add(mewssage); mewssage.setWrapText(true); mewssage.setAlignment(Pos.CENTER_LEFT); Separator sep = new Separator(Orientation.HORIZONTAL); sep.setMinHeight(10); root.getChildren() .addAll(header, new Separator(Orientation.HORIZONTAL), messagePanel, buttonPanel); VBox.setVgrow(messagePanel, Priority.ALWAYS); VBox.setVgrow(buttonPanel, Priority.NEVER); VBox.setVgrow(header, Priority.NEVER); ok.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { // System.out.println("Size: h:" + stage.getHeight() + " w:" + // stage.getWidth()); stage.close(); // isOK.setValue(true); response = Response.OK; } }); stage.showAndWait(); return response; }
private Tuple2<TableView<Offer>, VBox> getOfferTable(Offer.Direction direction) { TableView<Offer> tableView = new TableView(); // price TableColumn<Offer, Offer> priceColumn = new TableColumn<>(); priceColumn.textProperty().bind(priceColumnLabel); priceColumn.setMinWidth(120); priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue())); priceColumn.setCellFactory( new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() { @Override public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) { return new TableCell<Offer, Offer>() { @Override public void updateItem(final Offer item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) setText(formatter.formatFiat(item.getPrice())); else setText(""); } }; } }); tableView.getColumns().add(priceColumn); // amount TableColumn<Offer, Offer> amountColumn = new TableColumn<>("Amount (BTC)"); amountColumn.setText("Amount (BTC)"); amountColumn.setMinWidth(120); amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue())); amountColumn.setCellFactory( new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() { @Override public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) { return new TableCell<Offer, Offer>() { @Override public void updateItem(final Offer item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) setText(formatter.formatCoin(item.getAmount())); else setText(""); } }; } }); tableView.getColumns().add(amountColumn); // volume TableColumn<Offer, Offer> volumeColumn = new TableColumn<>("Amount (BTC)"); volumeColumn.setMinWidth(120); volumeColumn.textProperty().bind(volumeColumnLabel); volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue())); volumeColumn.setCellFactory( new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() { @Override public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) { return new TableCell<Offer, Offer>() { @Override public void updateItem(final Offer item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) setText(formatter.formatFiat(item.getOfferVolume())); else setText(""); } }; } }); tableView.getColumns().add(volumeColumn); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); Label placeholder = new Label("Currently there are no offers available"); placeholder.setWrapText(true); tableView.setPlaceholder(placeholder); Label titleLabel = new Label( direction.equals(Offer.Direction.BUY) ? "Offers for buy bitcoin (bid)" : "Offers for sell bitcoin (ask)"); titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16; -fx-alignment: center"); UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty())); VBox vBox = new VBox(); vBox.setSpacing(10); vBox.setFillWidth(true); vBox.setMinHeight(150); vBox.getChildren().addAll(titleLabel, tableView); return new Tuple2<>(tableView, vBox); }
/* * Creates the general properties tab, general properties are any properties that aren't defined to be creator properties, * by the ontology. * @param artifact * @return the VBox for the general tab */ private VBox createGeneralTab(final PackageArtifact artifact) { final VBox propertiesBox = new VBox(12); propertiesBox.getStyleClass().add(PACKAGE_TOOL_POPUP_PROPERTY_TAB); Set<String> creatorProperties = packageOntologyService.getCreatorProperties(artifact); final Map<String, String> properties = packageOntologyService.getProperties(artifact); Label requiredLabel = new Label(labels.get(Labels.LabelKey.REQUIRED_FIELDS_LABEL)); requiredLabel.setMaxWidth(400); requiredLabel.setWrapText(true); requiredLabel.setTextAlignment(TextAlignment.CENTER); propertiesBox.getChildren().add(requiredLabel); List<String> sortedProperties = new ArrayList<>(); // Get the property name key set and then create a sorted list from it. sortedProperties.addAll(properties.keySet()); sortProperties(sortedProperties, artifact, ""); // Loop through all the available properties for (final String property : sortedProperties) { // If the property isn't a creator property we include it in this tab if (!creatorProperties.contains(property)) { final PackageDescriptionViewImpl.ArtifactPropertyContainer container = new PackageDescriptionViewImpl.ArtifactPropertyContainer(); // If the property is complex use the group property creation. if (packageOntologyService.isPropertyComplex(properties.get(property))) { container.isComplex = true; VBox complexPropertyBox = createGroupPropertySection( artifact, property, properties.get(property), false, container); propertiesBox.getChildren().add(complexPropertyBox); int maxOccurrences = packageOntologyService.getPropertyMaxOccurrences(artifact, property, ""); // If the property allows for more than one value include a button to add more fields. if (maxOccurrences > 1) { final Button addNewButton = new Button( labels.get(Labels.LabelKey.ADD_NEW_BUTTON) + " " + ontologyLabels.get(property)); addNewButton.setMaxWidth(addNewButtonMaxWidth); addNewButton.setDisable(true); propertiesBox.getChildren().add(addNewButton); final GroupPropertyChangeListener listener = new GroupPropertyChangeListener(addNewButton, container); for (Node n : propertiesBox.getChildren()) { if (n instanceof VBox) { addChangeListenerToSectionFields((VBox) n, listener); } } listener.changed(null, "n/a", "n/a"); addNewButton.setOnAction( arg0 -> { VBox complexPropertyBox1 = createGroupPropertySection( artifact, property, properties.get(property), true, container); int buttonIndex = propertiesBox.getChildren().indexOf(addNewButton); propertiesBox.getChildren().add(buttonIndex, complexPropertyBox1); addChangeListenerToSectionFields(complexPropertyBox1, listener); addNewButton.setDisable(true); requestFocusForNewGroup(complexPropertyBox1); }); Separator groupSeparator = new Separator(); propertiesBox.getChildren().add(groupSeparator); } } else { // If it's a simple property use the create property box. int maxOccurances = packageOntologyService.getPropertyMaxOccurrences(artifact, property, ""); int minOccurances = packageOntologyService.getPropertyMinOccurrences(artifact, property, ""); boolean systemGenerated = packageOntologyService.isSystemSuppliedProperty(artifact, property); Set<StringProperty> fieldProperties = new HashSet<>(); if (packageOntologyService.isDisciplineProperty(artifact, property)) { propertiesBox .getChildren() .add( new DisciplinePropertyBox( ontologyLabels.get(property), artifact.getSimplePropertyValues(property), maxOccurances, fieldProperties, minOccurances, systemGenerated, availableDisciplines)); } else { propertiesBox .getChildren() .add( new TextPropertyBox( artifact, "", ontologyLabels.get(property), property, artifact.getSimplePropertyValues(property), maxOccurances, fieldProperties, minOccurances, systemGenerated, packageOntologyService, labels, messages, applyButtonValidationListener)); } container.values = fieldProperties; } artifactPropertyFields.put(property, container); } } return propertiesBox; }
private Button createCommandLinksButton(ButtonType buttonType) { // look up the CommandLinkButtonType for the given ButtonType CommandLinksButtonType commandLink = typeMap.getOrDefault(buttonType, new CommandLinksButtonType(buttonType)); // put the content inside a button final Button button = new Button(); button.getStyleClass().addAll("command-link-button"); // $NON-NLS-1$ button.setMaxHeight(Double.MAX_VALUE); button.setMaxWidth(Double.MAX_VALUE); button.setAlignment(Pos.CENTER_LEFT); final ButtonData buttonData = buttonType.getButtonData(); button.setDefaultButton(buttonData != null && buttonData.isDefaultButton()); button.setOnAction(ae -> setResult(buttonType)); final Label titleLabel = new Label(commandLink.getButtonType().getText()); titleLabel .minWidthProperty() .bind( new DoubleBinding() { { bind(titleLabel.prefWidthProperty()); } @Override protected double computeValue() { return titleLabel.getPrefWidth() + 400; } }); titleLabel.getStyleClass().addAll("line-1"); // $NON-NLS-1$ titleLabel.setWrapText(true); titleLabel.setAlignment(Pos.TOP_LEFT); GridPane.setVgrow(titleLabel, Priority.NEVER); Label messageLabel = new Label(commandLink.getLongText()); messageLabel.getStyleClass().addAll("line-2"); // $NON-NLS-1$ messageLabel.setWrapText(true); messageLabel.setAlignment(Pos.TOP_LEFT); messageLabel.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(messageLabel, Priority.SOMETIMES); Node commandLinkImage = commandLink.getGraphic(); Node view = commandLinkImage == null ? new ImageView( CommandLinksDialog.class.getResource("arrow-green-right.png").toExternalForm()) : //$NON-NLS-1$ commandLinkImage; Pane graphicContainer = new Pane(view); graphicContainer.getStyleClass().add("graphic-container"); // $NON-NLS-1$ GridPane.setValignment(graphicContainer, VPos.TOP); GridPane.setMargin(graphicContainer, new Insets(0, 10, 0, 0)); GridPane grid = new GridPane(); grid.minWidthProperty().bind(titleLabel.prefWidthProperty()); grid.setMaxHeight(Double.MAX_VALUE); grid.setMaxWidth(Double.MAX_VALUE); grid.getStyleClass().add("container"); // $NON-NLS-1$ grid.add(graphicContainer, 0, 0, 1, 2); grid.add(titleLabel, 1, 0); grid.add(messageLabel, 1, 1); button.setGraphic(grid); button.minWidthProperty().bind(titleLabel.prefWidthProperty()); if (commandLink.isHidden) { button.setVisible(false); button.setPrefHeight(1); } return button; }
/** * Creates the tab for displaying creator properties. This tab is constructed using the {@code * createPropertyBox} and {@code createGroupPropertySection} methods found below. * * @param artifact The popup artifact * @return content or null if nothing for user to do */ private VBox createCreatorTab(final PackageArtifact artifact) { final VBox propertiesBox = new VBox(12); propertiesBox.getStyleClass().add(PACKAGE_TOOL_POPUP_PROPERTY_TAB); Label requiredLabel = new Label(labels.get(Labels.LabelKey.REQUIRED_FIELDS_LABEL)); requiredLabel.setMaxWidth(300); requiredLabel.setWrapText(true); requiredLabel.setTextAlignment(TextAlignment.CENTER); propertiesBox.getChildren().add(requiredLabel); final Map<String, String> properties = packageOntologyService.getProperties(artifact); List<String> sortedProperties = new ArrayList<>(); // Get the creator property set and then create a sorted list from it. sortedProperties.addAll(packageOntologyService.getCreatorProperties(artifact)); sortProperties(sortedProperties, artifact, ""); // Loop through all the creator properties as defined in the ontology. for (final String property : sortedProperties) { final PackageDescriptionViewImpl.ArtifactPropertyContainer container = new PackageDescriptionViewImpl.ArtifactPropertyContainer(); // If the property is complex use the group property creation, otherwise use the simple // property set up. if (packageOntologyService.isPropertyComplex(properties.get(property))) { container.isComplex = true; VBox complexPropertyBox = createGroupPropertySection( artifact, property, properties.get(property), false, container); propertiesBox.getChildren().add(complexPropertyBox); int maxOccurances = packageOntologyService.getPropertyMaxOccurrences(artifact, property, ""); // If the ontology allows for more than one of the property add a button which will add more // groups when pressed. if (maxOccurances > 1) { final Button addNewButton = new Button(labels.get(Labels.LabelKey.ADD_NEW_BUTTON) + " " + property); addNewButton.setMaxWidth(addNewButtonMaxWidth); propertiesBox.getChildren().add(addNewButton); addNewButton.setDisable(true); final GroupPropertyChangeListener listener = new GroupPropertyChangeListener(addNewButton, container); for (Node n : propertiesBox.getChildren()) { if (n instanceof VBox) { addChangeListenerToSectionFields((VBox) n, listener); } } listener.changed(null, "n/a", "n/a"); addNewButton.setOnAction( arg0 -> { VBox complexPropertyBox1 = createGroupPropertySection( artifact, property, properties.get(property), true, container); int buttonIndex = propertiesBox.getChildren().indexOf(addNewButton); propertiesBox.getChildren().add(buttonIndex, complexPropertyBox1); addChangeListenerToSectionFields(complexPropertyBox1, listener); addNewButton.setDisable(true); requestFocusForNewGroup(complexPropertyBox1); }); } } else { // Otherwise create just the simple property int maxOccurances = packageOntologyService.getPropertyMaxOccurrences(artifact, property, ""); int minOccurances = packageOntologyService.getPropertyMinOccurrences(artifact, property, ""); boolean systemGenerated = packageOntologyService.isSystemSuppliedProperty(artifact, property); Set<StringProperty> fields = new HashSet<>(); propertiesBox .getChildren() .add( new TextPropertyBox( artifact, "", ontologyLabels.get(property), property, artifact.getSimplePropertyValues(property), maxOccurances, fields, minOccurances, systemGenerated, packageOntologyService, labels, messages, applyButtonValidationListener)); container.values = fields; } artifactPropertyFields.put(property, container); } // Return null if nothing to edit. if (propertiesBox.getChildren().size() == 1) { return null; } return propertiesBox; }
/** * Handles the creation of group properties, group properties are properties that are linked together in some manner. * Group properties are constructed using the {@code createPropertyBox) method found below. * * @param artifact * @param propertyName * @param propertyType * @param empty * @param container * @return the VBox */ private VBox createGroupPropertySection( PackageArtifact artifact, String propertyName, String propertyType, boolean empty, PackageDescriptionViewImpl.ArtifactPropertyContainer container) { VBox complexPropertyBox = new VBox(8); Separator separator = new Separator(); complexPropertyBox.getChildren().add(separator); // If the artifact has the property and we're not adding an empty field add the sub property // values if (artifact.getPropertyNames().contains(propertyName) && !empty) { for (PackageArtifact.PropertyValueGroup group : artifact.getPropertyValueGroups(propertyName)) { Map<String, Set<StringProperty>> subPropertyFields = new HashMap<>(); Label propertyNameLabel = new Label(ontologyLabels.get(propertyName)); propertyNameLabel.setPrefWidth(100); propertyNameLabel.setWrapText(true); complexPropertyBox.getChildren().add(propertyNameLabel); List<String> sortedProperties = new ArrayList<>(); // Get the creator property set and then create a sorted list from it. sortedProperties.addAll(packageOntologyService.getGroupPropertyNames(propertyType)); sortProperties(sortedProperties, artifact, propertyType); for (String fieldName : sortedProperties) { Set<String> values = group.getSubPropertyValues(fieldName); int maxOccurs = packageOntologyService.getPropertyMaxOccurrences(artifact, fieldName, propertyType); int minOccurs = packageOntologyService.getPropertyMinOccurrences(artifact, fieldName, propertyType); boolean systemGenerated = packageOntologyService.isSystemSuppliedProperty(artifact, fieldName); Set<StringProperty> fields = new HashSet<>(); complexPropertyBox .getChildren() .add( new TextPropertyBox( artifact, propertyName, ontologyLabels.get(fieldName), fieldName, values, maxOccurs, fields, minOccurs, systemGenerated, packageOntologyService, labels, messages, applyButtonValidationListener)); subPropertyFields.put(fieldName, fields); } container.subProperties.add(subPropertyFields); } // Otherwise just add the empty text fields for the possible property values. } else { Map<String, Set<StringProperty>> subPropertyFields = new HashMap<>(); Label propertyNameLabel = new Label(ontologyLabels.get(propertyName)); propertyNameLabel.setPrefWidth(100); propertyNameLabel.setWrapText(true); complexPropertyBox.getChildren().add(propertyNameLabel); List<String> sortedProperties = new ArrayList<>(); // Get the creator property set and then create a sorted list from it. sortedProperties.addAll(packageOntologyService.getGroupPropertyNames(propertyType)); sortProperties(sortedProperties, artifact, propertyType); // For each field create a property box for (String fieldName : sortedProperties) { // String fieldType = packageOntologyService.getComplexPropertySubPropertyType(propertyType, // fieldName); int maxOccurs = packageOntologyService.getPropertyMaxOccurrences(artifact, fieldName, propertyType); int minOccurs = packageOntologyService.getPropertyMinOccurrences(artifact, fieldName, propertyType); boolean systemGenerated = packageOntologyService.isSystemSuppliedProperty(artifact, fieldName); Set<StringProperty> fields = new HashSet<>(); complexPropertyBox .getChildren() .add( new TextPropertyBox( artifact, propertyName, ontologyLabels.get(fieldName), fieldName, null, maxOccurs, fields, minOccurs, systemGenerated, packageOntologyService, labels, messages, applyButtonValidationListener)); subPropertyFields.put(fieldName, fields); } container.subProperties.add(subPropertyFields); } return complexPropertyBox; }