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 ConfigurationsDialogBuilder create( DependencyDotFileGenerator dependencyDotFileGenerator, GradleScriptPreferences preferences, Os os, String outputFileName) { this.outputFileName = outputFileName; this.dependencyDotFileGenerator = dependencyDotFileGenerator; this.preferences = preferences; this.os = os; dialog = new ConfigurationChoiceDialog(this); dialog.setResizable(true); dialog.initStyle(UTILITY); dialog.initModality(APPLICATION_MODAL); dialog.setIconified(false); dialog.centerOnScreen(); dialog.borderPanel = BorderPaneBuilder.create().styleClass("dialog").build(); dialog.stackPane = new StackPane(); StackPane stackPane = dialog.stackPane; dialog.log = new TextArea(); TextArea log = dialog.log; BorderPane borderPanel = dialog.borderPanel; // message dialog.configurationsBox = new VBox(); VBox configurationsBox = dialog.configurationsBox; dialog.configurationsBox = configurationsBox; dialog.progressIndicator = new ProgressIndicator(); ProgressIndicator progressIndicator = dialog.progressIndicator; stackPane.getChildren().add(log); stackPane.getChildren().add(progressIndicator); progressIndicator.setPrefSize(50, 50); progressIndicator.setMaxSize(50, 50); configurationsBox.setSpacing(15); configurationsBox.setAlignment(CENTER_LEFT); dialog.scrollPane = new ScrollPane(); ScrollPane scrollPane = dialog.scrollPane; scrollPane.setContent(configurationsBox); dialog.borderPanel.setCenter(stackPane); BorderPane.setAlignment(configurationsBox, CENTER_LEFT); BorderPane.setMargin(configurationsBox, new Insets(MARGIN, MARGIN, MARGIN, 2 * MARGIN)); // buttons dialog.buttonsPanel = new HBox(); final HBox buttonsPanel = dialog.buttonsPanel; buttonsPanel.setSpacing(MARGIN); buttonsPanel.setAlignment(BOTTOM_CENTER); BorderPane.setMargin(buttonsPanel, new Insets(0, 0, 1.5 * MARGIN, 0)); borderPanel.setBottom(buttonsPanel); borderPanel .widthProperty() .addListener( new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) { buttonsPanel.layout(); } }); dialog.scene = new Scene(borderPanel); dialog.setScene(dialog.scene); URL resource = ConfigurationsDialogBuilder.class.getResource( "/com/nurflugel/gradle/ui/dialogservice/dialog.css"); String externalForm = resource.toExternalForm(); // dialog.borderPanel.styleClass("dialog"); dialog.getScene().getStylesheets().add(externalForm); return this; }
private void updateSelectedEntry() { ObservableList<PolizistDaten> Nutzerauswahl = Tabelle.getSelectionModel().getSelectedItems(); if (Nutzerauswahl.size() != 1) { IM.setErrorText("Es muss genau ein Element ausgewählt werden"); return; } PolizistDaten Auswahl = Nutzerauswahl.get(0); // Jetzt erzeugen wir ein PopUp zum veraendern des Eintrags Stage PopUp = new Stage(); PopUp.initModality(Modality.APPLICATION_MODAL); PopUp.setTitle("Neuer Eintrag"); PopUp.setAlwaysOnTop(true); PopUp.setResizable(false); GridPane Gitter = new GridPane(); Gitter.setHgap(10); Gitter.setVgap(10); Label LabelA = new Label("PersonenID"); Label LabelAWert = new Label(Integer.toString(Auswahl.getPersonenID())); Label LabelB = new Label("Name"); TextField LabelBWert = new TextField(); Label LabelC = new Label("Geburtsdatum"); DatePicker LabelCWert = new DatePicker(); Label LabelD = new Label("Nationalität"); TextField LabelDWert = new TextField(); Label LabelE = new Label("Geschlecht"); ComboBox LabelEWert = new ComboBox(); Label LabelF = new Label("Todesdatum"); DatePicker LabelFWert = new DatePicker(); Label LabelG = new Label("Dienstgrad"); TextField LabelGWert = new TextField(); final Callback<DatePicker, DateCell> TagesZellenFabtrik = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker DP) { return new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); if (item.isBefore(LabelCWert.getValue().plusDays(1))) { setDisable(true); setStyle("-fx-background-color: #ffc0cb;"); } } }; } }; LabelFWert.setDayCellFactory(TagesZellenFabtrik); LabelEWert.getItems().addAll("m", "w"); LabelEWert.setValue(Auswahl.getGeschlecht()); LabelBWert.setText(Auswahl.getName()); LabelCWert.setValue(LocalDate.parse(Auswahl.getGebDatum())); // TODO exception LabelDWert.setText(Auswahl.getNation()); if (!Auswahl.getTodDatum().isEmpty()) { LabelFWert.setValue(LocalDate.parse(Auswahl.getTodDatum())); // TODO exception } LabelGWert.setText(Auswahl.getDienstgrad()); Button ButtonFort = new Button("Fortfahren"); Button ButtonAbb = new Button("Abbrechen"); ButtonFort.defaultButtonProperty(); ButtonAbb.cancelButtonProperty(); ButtonFort.setMaxWidth(Double.MAX_VALUE); ButtonAbb.setMaxWidth(Double.MAX_VALUE); Gitter.addColumn(0, LabelA, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG); Gitter.addColumn( 1, LabelAWert, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert); VBox AussenBox = new VBox(10); HBox InnenBox = new HBox(); AussenBox.setSpacing(10); AussenBox.setPadding(new Insets(10)); InnenBox.setSpacing(10); AussenBox.setAlignment(Pos.CENTER); InnenBox.setAlignment(Pos.BOTTOM_CENTER); AussenBox.getChildren().addAll(Gitter, InnenBox); InnenBox.getChildren().addAll(ButtonFort, ButtonAbb); ButtonAbb.setOnAction(event -> PopUp.close()); ButtonFort.setOnAction( event -> { String SQLString; if (LabelFWert.getEditor().getText().isEmpty()) { SQLString = "UPDATE PERSON SET Name=?, Geburtsdatum=?, Nationalität=?, Geschlecht=?, Todesdatum=NULL WHERE PersonenID = " + Auswahl.getPersonenID(); } else { SQLString = "UPDATE PERSON SET Name=?, Geburtsdatum=?, Nationalität=?, Geschlecht=?, Todesdatum=? WHERE PersonenID = " + Auswahl.getPersonenID(); } try { PreparedStatement InsertStatement = DH.prepareStatement(SQLString); InsertStatement.setString(1, LabelBWert.getText()); InsertStatement.setString(2, LabelCWert.getValue().toString()); // TODO exception InsertStatement.setString(3, LabelDWert.getText()); InsertStatement.setString(4, LabelEWert.getValue().toString()); if (LabelFWert.getValue() != null && !LabelFWert.getEditor().getText().isEmpty()) { InsertStatement.setString(5, LabelFWert.getValue().toString()); } InsertStatement.executeUpdate(); SQLString = "UPDATE POLIZIST SET Dienstgrad = ? WHERE PersonenID = " + Auswahl.getPersonenID(); InsertStatement = DH.prepareStatement(SQLString); InsertStatement.setString(1, LabelGWert.getText()); InsertStatement.execute(); IM.setInfoText("Änderung durchgeführt"); } catch (SQLException e) { IM.setErrorText("Ändern Fehlgeschlagen", e); } refreshPolizistAnsicht(); PopUp.close(); }); PopUp.setScene(new Scene(AussenBox)); PopUp.showAndWait(); }
private void insertNewEntry() { Stage PopUp = new Stage(); PopUp.initModality(Modality.APPLICATION_MODAL); PopUp.setTitle("Neuer Eintrag"); PopUp.setAlwaysOnTop(true); PopUp.setResizable(false); GridPane Gitter = new GridPane(); Gitter.setHgap(10); Gitter.setVgap(10); Label LabelB = new Label("Name"); TextField LabelBWert = new TextField(); Label LabelC = new Label("Geburtsdatum"); DatePicker LabelCWert = new DatePicker(); Label LabelD = new Label("Nationalität"); TextField LabelDWert = new TextField(); Label LabelE = new Label("Geschlecht"); ComboBox LabelEWert = new ComboBox(); Label LabelF = new Label("Todesdatum"); DatePicker LabelFWert = new DatePicker(); Label LabelG = new Label("Dienstgrad"); TextField LabelGWert = new TextField(); final Callback<DatePicker, DateCell> TagesZellenFabtrik = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker DP) { return new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); if (item.isBefore(LabelCWert.getValue().plusDays(1))) { setDisable(true); setStyle("-fx-background-color: #ffc0cb;"); } } }; } }; LabelFWert.setDayCellFactory(TagesZellenFabtrik); LabelEWert.getItems().addAll("m", "w"); LabelEWert.setValue("m"); Button ButtonFort = new Button("Fortfahren"); Button ButtonAbb = new Button("Abbrechen"); ButtonFort.defaultButtonProperty(); ButtonAbb.cancelButtonProperty(); ButtonFort.setMaxWidth(Double.MAX_VALUE); ButtonAbb.setMaxWidth(Double.MAX_VALUE); Gitter.addColumn(0, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG); Gitter.addColumn(1, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert); VBox AussenBox = new VBox(10); HBox InnenBox = new HBox(); AussenBox.setSpacing(10); AussenBox.setPadding(new Insets(10)); InnenBox.setSpacing(10); AussenBox.setAlignment(Pos.CENTER); InnenBox.setAlignment(Pos.BOTTOM_CENTER); AussenBox.getChildren().addAll(Gitter, InnenBox); InnenBox.getChildren().addAll(ButtonFort, ButtonAbb); ButtonAbb.setOnAction(event -> PopUp.close()); ButtonFort.setOnAction( event -> { String SQLString; if (LabelFWert.getValue() != null) { SQLString = "INSERT INTO PERSON (Name, Geburtsdatum, Nationalität, Geschlecht, Todesdatum) VALUES (?, ?, ?, ?, ?)"; } else { SQLString = "INSERT INTO PERSON (Name, Geburtsdatum, Nationalität, Geschlecht) VALUES (?, ?, ?, ?)"; } try { PreparedStatement InsertStatement = DH.prepareStatement(SQLString); InsertStatement.setString(1, LabelBWert.getText()); InsertStatement.setString(2, LabelCWert.getValue().toString()); // TODO exception InsertStatement.setString(3, LabelDWert.getText()); InsertStatement.setString(4, LabelEWert.getValue().toString()); if (LabelFWert.getValue() != null) { InsertStatement.setString(5, LabelFWert.getValue().toString()); // TODO exception } InsertStatement.executeUpdate(); ResultSet PersID = DH.getAnfrageObjekt().executeQuery("SELECT last_insert_rowid();"); if (!PersID.next()) { IM.setErrorText("Konnte Primärschlüssel nicht mehr bestimmen."); } SQLString = "INSERT INTO POLIZIST (PersonenID, Dienstgrad) VALUES (?, ?)"; InsertStatement = DH.prepareStatement(SQLString); InsertStatement.setInt(1, PersID.getInt(1)); // TODO das hier verifizieren InsertStatement.setString(2, LabelGWert.getText()); InsertStatement.executeUpdate(); IM.setInfoText("Einfügen durchgeführt"); } catch (SQLException e) { IM.setErrorText("Einfügen Fehlgeschlagen", e); } refreshPolizistAnsicht(); PopUp.close(); }); PopUp.setScene(new Scene(AussenBox)); PopUp.showAndWait(); }
@Override public void start(Stage primaryStage) { VBox loginPane = new VBox(); loginPane.setAlignment(Pos.CENTER); primaryStage.setTitle("Amoeba"); primaryStage.setScene(new Scene(loginPane, 800, 600)); primaryStage.show(); TextField username = new TextField(); username.setPromptText("Username"); username.setMaxSize(200, 50); Timeline renderTimer = new Timeline(); Timeline inputTimer = new Timeline(); ColorPicker colorPicker = new ColorPicker(); colorPicker.setEditable(true); colorPicker.setValue(Color.BLACK); lagLabel.setTranslateX(25); lagLabel.setTranslateY(10); lagLabel.setTextFill(Color.RED); TextField address = new TextField("localhost"); address.setPromptText("Server IP Address"); address.setMaxSize(200, 50); TextField port = new TextField("8080"); port.setPromptText("Port Number"); port.setMaxSize(200, 50); Button btn = new Button("Play"); btn.setDefaultButton(true); loginPane.getChildren().addAll(username, colorPicker, address, port, btn); primaryStage.setResizable(false); music.setCycleCount(MediaPlayer.INDEFINITE); renderPane.setBackground(new Background(backgroundImage)); renderPane.setPrefSize(800, 600); chatBox.setPrefSize(400, 100); chatBox.setTranslateX(0); chatBox.setTranslateY(468); chatBox.setWrapText(true); chatBox.setEditable(false); chatBox.setStyle("-fx-opacity: 0.5"); chatInput.setPrefSize(400, 10); chatInput.setTranslateX(0); chatInput.setTranslateY(570); chatInput.setStyle("-fx-opacity: 0.8"); highScores.setPrefSize(400, 210); highScores.setEditable(false); currentScores.setPrefSize(400, 250); currentScores.setEditable(false); currentScores.setLayoutY(210); scores.setTranslateX(-390); scores.setTranslateY(0); scores.setStyle("-fx-opacity: 0.8"); scores.setOnMouseEntered( (e) -> { scores.setTranslateX(0); }); scores.setOnMouseExited( (e) -> { if (e.getX() > 350) { scores.setTranslateX(-390); } }); btn.setOnAction( (e) -> { if (!networkController.isConnected()) { networkController.connect(address.getText(), Integer.parseInt(port.getText())); if (username.getText().isEmpty()) { username.setText("Anonymous"); } networkController.sendMessage(new LoginMessage(username.getText(), "")); ArrayList<KeyValuePair> properties = new ArrayList<>(); properties.add(new KeyValuePair("color", colorPicker.getValue().toString())); networkController.sendMessage(new SetBlobPropertiesMessage(properties)); primaryStage.setScene(new Scene(renderPane)); renderTimer.play(); inputTimer.play(); music.play(); } }); inputTimer.setCycleCount(Timeline.INDEFINITE); inputTimer .getKeyFrames() .add( new KeyFrame( Duration.seconds(0.05), (e) -> { if (sendCoordinates) { networkController.sendMessage(new MoveTowardCoordinatesMessage(x, y)); } })); renderTimer.setCycleCount(Timeline.INDEFINITE); renderTimer .getKeyFrames() .add( new KeyFrame( Duration.seconds(0.01), (e) -> { render(); })); renderPane.setOnMouseReleased( (e) -> { this.sendCoordinates = false; }); renderPane.setOnMouseDragged( (e) -> { this.sendCoordinates = true; this.x = e.getX(); this.y = e.getY(); }); renderPane.setOnMouseClicked( (e) -> { if (e.getButton() == MouseButton.SECONDARY) { networkController.sendMessage(new BoostMessage()); } else if (e.getClickCount() > 1 || e.getButton() == MouseButton.MIDDLE) { networkController.sendMessage(new SplitMessage()); } }); renderPane.setOnKeyPressed( (e) -> { if (e.getCode().equals(KeyCode.ENTER) && !chatInput.getText().isEmpty()) { networkController.sendMessage(new ChatMessage("", chatInput.getText())); chatInput.clear(); } }); primaryStage.setOnCloseRequest( (e) -> { networkController.sendMessage(new LogoutMessage()); try { Thread.sleep(100); } catch (InterruptedException ex) { Logger.getLogger(AmoebaClient.class.getName()).log(Level.WARNING, null, ex); } finally { System.exit(0); } }); }