private void showDialog(String title, String message, Throwable throwable) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(title); alert.setHeaderText(title); alert.setContentText(message); StringWriter stringWriter = new StringWriter(); PrintWriter printwriter = new PrintWriter(stringWriter); throwable.printStackTrace(printwriter); String exceptionText = stringWriter.toString(); Label label = new Label("The exception stacktrace was:"); TextArea textArea = new TextArea(exceptionText); textArea.setEditable(false); textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(textArea, Priority.ALWAYS); GridPane.setHgrow(textArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent); alert.showAndWait(); }
@FXML private void handleAction(ActionEvent event) { TextArea textarea = (TextArea) menuBar.getScene().lookup("#textarea"); if (event.getSource() == chmiWordWrap) { wordWrapOn = chmiWordWrap.isSelected(); textarea.setWrapText(wordWrapOn); } else if (event.getSource() == miChangeCase) { try { if (changeCaseDialog == null) { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ChangeCaseDialog.fxml")); Parent root = fxmlLoader.load(); controller = fxmlLoader.getController(); controller.setSelectedCase(prefs.get(strSelectedCase, "UPPERCASE")); changeCaseDialog = new Stage(); changeCaseDialog.setResizable(false); changeCaseDialog.initStyle(StageStyle.UTILITY); changeCaseDialog.setAlwaysOnTop(true); changeCaseDialog.setX(prefs.getDouble(strChangeCaseX, changeCaseDialog.getX())); changeCaseDialog.setY(prefs.getDouble(strChangeCaseY, changeCaseDialog.getY())); Scene scene = new Scene(root); changeCaseDialog.setScene(scene); changeCaseDialog.setTitle("Change Case"); } changeCaseDialog.toFront(); changeCaseDialog.show(); } catch (Exception e) { } } else if (event.getSource() == miRemoveLineBreaks) { if (textarea.getSelectedText().length() == 0) { textarea.selectAll(); if (textarea.getSelectedText().length() == 0) { return; } } String result = TextUtilities.removeLineBreaks(textarea.getSelectedText()); int start = textarea.getSelection().getStart(); textarea.replaceSelection(result); textarea.selectRange(start, start + result.length()); } else if (event.getSource() == miFont) { Font font = textarea.getFont(); FontSelectorDialog dialog = new FontSelectorDialog(font); Optional<Font> op = dialog.showAndWait(); if (op.isPresent()) { textarea.setFont(op.get()); } } }
private VBox initGUIcenterLinks() { VBox senkrecht = new VBox(); HBox zeile1 = new HBox(10); zeile1.setPadding(new Insets(5, 5, 5, 5)); zeile1.setStyle(Css.boxgrau()); TextArea zustandDatenbank = new TextArea(); zustandDatenbank.getStyleClass().add("textarea80"); zustandDatenbank.setStyle(Css.focusrahmenWeg()); zustandDatenbank.setEditable(false); zustandDatenbank.setPrefRowCount(2); zustandDatenbank.setPrefColumnCount(23); zustandDatenbank.setWrapText(true); RahmenTitelWeiss rahmenZustandDatenbank = new RahmenTitelWeiss("Zustand der Datenbank", zustandDatenbank); Button knopfDatenbank = new Button("aktualisieren"); zeile1.getChildren().add(rahmenZustandDatenbank); zeile1.getChildren().add(knopfDatenbank); VBox zeile2 = new VBox(10); zeile2.setPadding(new Insets(10, 10, 10, 10)); zeile2.setStyle(Css.boxgrau()); HBox zeileTabelle = new HBox(10); Button knopfAlle = new Button("alle auswählen"); Button knopfKeinen = new Button("keinen auswählen"); zeileTabelle.getChildren().add(knopfAlle); zeileTabelle.getChildren().add(knopfKeinen); zeile2.getChildren().add(initGUItabelle()); zeile2.getChildren().add(zeileTabelle); VBox zeile3 = new VBox(10); zeile3.setPadding(new Insets(10, 10, 10, 10)); zeile3.setStyle(Css.boxhellblaugrau()); Button knopfDateiTextAlles = new Button("Projektstammdaten als Datei speichern (Text)"); Button knopfDateiXmlAlles = new Button("Projektstammdaten als Datei speichern (Xml)"); zeile3.getChildren().add(knopfDateiTextAlles); zeile3.getChildren().add(knopfDateiXmlAlles); VBox zeile4 = new VBox(10); zeile4.setPadding(new Insets(10, 10, 10, 10)); zeile4.setStyle(Css.boxhellblau()); Button knopfProjektAlles = new Button("alle Daten und Datein lokal speichern"); zeile4.getChildren().add(knopfProjektAlles); senkrecht.getChildren().add(zeile1); senkrecht.getChildren().add(zeile2); senkrecht.getChildren().add(zeile3); senkrecht.getChildren().add(zeile4); return senkrecht; }
public static Tuple2<Label, TextArea> addLabelTextArea( GridPane gridPane, int rowIndex, String title, String prompt, double top) { Label label = addLabel(gridPane, rowIndex, title, 0); GridPane.setMargin(label, new Insets(top + 4, 0, 0, 0)); GridPane.setValignment(label, VPos.TOP); TextArea textArea = new TextArea(); textArea.setPromptText(prompt); textArea.setWrapText(true); GridPane.setRowIndex(textArea, rowIndex); GridPane.setColumnIndex(textArea, 1); GridPane.setMargin(textArea, new Insets(top, 0, 0, 0)); gridPane.getChildren().add(textArea); return new Tuple2<>(label, textArea); }
private HBox initGUIcenterRechtsZeile7() { HBox zeile = new HBox(10); TextArea info = new TextArea(); info.setPrefRowCount(6); info.setPrefColumnCount(36); info.setWrapText(true); info.setEditable(false); RahmenTitelWeiss rahmenLoginname = new RahmenTitelWeiss("Info", info); ListView<String> gruppen = new ListView<String>(); gruppen.setPrefWidth(190); gruppen.setPrefHeight(50); RahmenTitelWeiss rahmenGruppen = new RahmenTitelWeiss("Gruppen", gruppen); zeile.getChildren().add(rahmenLoginname); zeile.getChildren().add(rahmenGruppen); return zeile; }
@FXML private void initialize() { ideaCategoryColumn.setCellValueFactory(cellData -> cellData.getValue().categoryProperty()); ideaNameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty()); ideaStatusColumn.setCellValueFactory(cellData -> cellData.getValue().statusProperty()); ideasTable .getSelectionModel() .selectedItemProperty() .addListener((observable, oldValue, newValue) -> showIdea(newValue)); int divider = 3; // amount of column to divide equal ideaCategoryColumn.prefWidthProperty().bind(ideasTable.widthProperty().divide(divider)); ideaArea.setEditable(false); ideaArea.setWrapText(true); new Thread( new Runnable() { @Override public void run() { IdeaDaoImpl ideaDaoImpl = new IdeaDaoImpl(); ideaDaoImpl.createConnection(); ideasList.addAll(ideaDaoImpl.getAllIdeasList()); ideaDaoImpl.closeConnection(); Platform.runLater( new Runnable() { @Override public void run() { ideasTable.setItems(ideasList); } }); } }) .start(); }
/** * Create a scroll pane of one of the databases * * @param type A string of either SQLInterface.TABITEM or SQLInterface.TABPERSON used to determine * which database to print. * @return A scroll pane showing the database chosen in the parameter or the person database by * default. * @throws IOException */ public static ScrollPane printDatabase(String type) throws IOException { TextArea textArea; switch (type) { case (SQLInterface.TABITEM): textArea = new TextArea(itemDatabase.getDatabase().toString()); break; case (SQLInterface.TABPERSON): textArea = new TextArea(personDatabase.getDatabase().toString()); break; default: textArea = new TextArea(personDatabase.getDatabase().toString()); break; } textArea.setEditable(false); // stop the user being able to edit this and thinking it will save. ScrollPane scrollPane = new ScrollPane(textArea); textArea.setWrapText(true); scrollPane.setHvalue(600); scrollPane.setVvalue(800); return scrollPane; }
public FileViewerPane() { // Top border pane custom settings HBox topPane = new HBox(10, lblFilePath, tfFilePath); topPane.setPadding(new Insets(10)); topPane.setAlignment(Pos.BASELINE_LEFT); // Bottom border pane custom settings HBox bottomPane = new HBox(btnSave); bottomPane.setAlignment(Pos.BASELINE_CENTER); bottomPane.setPadding(new Insets(10)); // Member nodes custom settings tfFilePath.setPrefColumnCount(32); taContent.setWrapText(true); // Adding panes to borderPane setTop(topPane); setCenter(new ScrollPane(taContent)); setBottom(bottomPane); }
/** Initializes the main text area. */ public void initialzeTextArea() { textArea.setWrapText(false); setRowHeights(Integer.parseInt(mediator.getDesktopController().getTextFontData().fontSize)); textArea .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( final ObservableValue<? extends String> observable, final String oldValue, final String newValue) { int numLines = numberOfLinesInString(newValue); ObservableList<DebugCellData> debugItems = EditorPaneController.this.debugListView.getItems(); ObservableList<LineNumberCellData> lineNumberItems = EditorPaneController.this.lineNumberListView.getItems(); if (currentNumLines > numLines) { while (debugItems.size() != numLines) { debugItems.remove(debugItems.size() - 1); } while (lineNumberItems.size() != numLines) { lineNumberItems.remove(lineNumberItems.size() - 1); } } else if (currentNumLines < numLines) { while (debugItems.size() != numLines) { debugItems.add(newDebugCellData()); } while (lineNumberItems.size() != numLines) { lineNumberItems.add(new LineNumberCellData(lineNumberItems.size() + 1)); } } currentNumLines = numLines; } }); }
private HBox initGUIcenterRechtsDatenbank() { HBox zeile = new HBox(20); zeile.setPadding(new Insets(5, 5, 5, 5)); zeile.setStyle(Css.boxhellblaugrau()); TextArea antwortDatenbank = new TextArea(); antwortDatenbank.getStyleClass().add("textareaFlat"); antwortDatenbank.setStyle(Css.focusrahmenWeg()); antwortDatenbank.setEditable(false); antwortDatenbank.setPrefRowCount(3); antwortDatenbank.setPrefColumnCount(25); antwortDatenbank.setWrapText(true); RahmenTitelWeiss rahmenAntwortDatenbank = new RahmenTitelWeiss("Antwort Datenbank", antwortDatenbank); VBox senkrecht = new VBox(5); Label schildchenAktion = new Label("Aktion"); schildchenAktion.setStyle(CssExtras.titel()); ToggleGroup gruppe = new ToggleGroup(); RadioButton knopfArchivieren = new RadioButton("aktivieren"); knopfArchivieren.setToggleGroup(gruppe); RadioButton knopfLöschen = new RadioButton("löschen"); knopfLöschen.setToggleGroup(gruppe); senkrecht.getChildren().add(schildchenAktion); senkrecht.getChildren().add(knopfArchivieren); senkrecht.getChildren().add(knopfLöschen); Button knopfSenden = new Button("senden"); zeile.getChildren().add(rahmenAntwortDatenbank); zeile.getChildren().add(senkrecht); zeile.getChildren().add(knopfSenden); return zeile; }
@Override public void start(Stage stage) { try { Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); } catch (Exception ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Lobo Software"); alert.setHeaderText("Se ha presentado un error inesperado"); alert.setContentText("El error técnico se muestra a continuación:"); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); String exceptionText = sw.toString(); TextArea textArea = new TextArea(exceptionText); textArea.setEditable(false); textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(textArea, Priority.ALWAYS); GridPane.setHgrow(textArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(textArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent); alert.showAndWait(); } }
public SaveDialog(final Stage stg, String text) { width = 300; height = 100; final Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(stg); stage.setTitle("提示框"); Group root = new Group(); AnchorPane anchorPane = new AnchorPane(); area = new TextArea(); area.setFont(new Font(30)); area.setEditable(false); area.setWrapText(true); area.setPrefWidth(width); area.setPrefHeight(height); System.out.println(area.getWidth()); System.out.println(area.getHeight()); Scene scene = new Scene(root, width, height); area.setText(text); anchorPane.getChildren().add(area); root.getChildren().add(anchorPane); stage.setScene(scene); stage.show(); }
@Override public void start(Stage primaryStage) { try { BorderPane root = (BorderPane) FXMLLoader.load(getClass().getResource("FinanceMainForm.fxml")); // ------------------------------------------------------------------------------------ // MD Alexis code // Grid to arrange buttons and text controls GridPane grid = new GridPane(); grid.setAlignment(Pos.TOP_LEFT); grid.setPrefWidth(400); // TODO: One column may be better, or a multicolumn single row for buttons. ColumnConstraints col1 = new ColumnConstraints(); col1.setPercentWidth(90); col1.setMinWidth(200); ColumnConstraints col2 = new ColumnConstraints(); col2.setPercentWidth(10); col2.setMinWidth(200); grid.getColumnConstraints().addAll(col1, col2); grid.setHgap(10); grid.setVgap(10); // grid.setGridLinesVisible(true); //Turn this on for debug and layout javafx.geometry.Insets ins = new javafx.geometry.Insets(5, 5, 5, 5); grid.setPadding(ins); // Fill the grid with controls Text scenetitle = new Text("Modeler"); scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(scenetitle, 0, 0, 2, 1); // Add Buttons----------------------------------------- bthRun.setOnAction(bthHandlerRun); grid.add(bthRun, 0, 2); // grid.add(child, columnIndex, rowIndex); // Add textArea control to show results textStatus.setPrefRowCount(10); textStatus.setPrefColumnCount(100); textStatus.setWrapText(false); textStatus.setPrefWidth(300); grid.add(textStatus, 0, 3); // -------------------Table View - use to display results // -------------------------------------------- // Set up table columns and their data sources TableColumn indexCol = new TableColumn("Index"); TableColumn yearCol = new TableColumn("Year"); yearCol.setCellValueFactory(new PropertyValueFactory<YearData, String>("year")); TableColumn balanceCol = new TableColumn("StartBalance"); balanceCol.setCellValueFactory( new PropertyValueFactory<YearData, String>("startBalanceFormatted")); TableColumn mktGainCol = new TableColumn("Gains"); mktGainCol.setCellValueFactory( new PropertyValueFactory<YearData, String>("marketGainsFormatted")); TableColumn incGoalCol = new TableColumn("Income Goal"); incGoalCol.setCellValueFactory( new PropertyValueFactory<YearData, String>("incomeGoalWithInflationFormatted")); TableColumn totalIncomeCol = new TableColumn("Total Income"); totalIncomeCol.setCellValueFactory( new PropertyValueFactory<YearData, String>("incomeTotalFormatted")); tableV .getColumns() .addAll(indexCol, yearCol, balanceCol, mktGainCol, incGoalCol, totalIncomeCol); grid.add(tableV, 0, 4); // ------------------------------- Chart --------------------------------------------- final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); // final BarChart barchartResults = new BarChart<>(xAxis,yAxis); final AreaChart areachartResults = new AreaChart<>(xAxis, yAxis); areachartResults.setTitle("Results Chart"); xAxis.setLabel("Year"); yAxis.setLabel("Dollars"); // Series // TODO: Connect this to an observable list in ModelUtility // final XYChart.Series<int[], double[]> seriesBalance = new XYChart.Series(); final XYChart.Series<String, Double> seriesBalance = new Series<String, Double>(); seriesBalance.setName("Balance"); // seriesBalance.setData(MU.balanceDataList); areachartResults.setData(MU.balanceDataList); // Add the Series to the chart areachartResults.getData().addAll(seriesBalance); grid.add(areachartResults, 0, 5); // ------------------------------------------------------------------------------------ // Below lines are from initial project setup // Scene scene = new Scene(root,600,400); Scene scene = new Scene(grid, 1200, 600); scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } catch (Exception e) { e.printStackTrace(); } }
@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); } }); }
@Override public void start(Stage primaryStage) { // Create a scene and place it in the stage ta.setPrefSize(445, 195); ta.setWrapText(true); Scene scene = new Scene(new ScrollPane(ta), 450, 200); primaryStage.setTitle("ChatServer"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage new Thread( () -> { // connection thread try { // System.out.println("sss"); ServerSocket serverSocket = new ServerSocket(SERVER_PORT); printString("Server started!"); // InetAddress ip = InetAddress.getLocalHost; try { printString( "Server connection is: " + InetAddress.getLocalHost() + ":" + SERVER_PORT); } catch (Exception ex) { System.out.println(ex); } while (true) { System.out.println("Waiting for connection..."); Socket socket = serverSocket.accept(); System.out.println("got connection " + ++connectionCount); printString("got connection " + connectionCount); // InetAddress inetAddress = socket.getInetAddress(); new Thread(new HandleAClient(socket)).start(); } } catch (IOException ex) { // Logger.getLogger(ChatRoomServer.class.getName()).log(Level.SEVERE, null, ex); System.out.println("fail starting the server: " + ex); } }) .start(); new Thread( () -> { // send out messages to all user that is in the chat while (true) { while (member == 0) { try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException ex) { System.out.println(ex); } } // System.out.println("message output thread started"); //////////////////////////// try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException ex) { System.out.println(ex); } // System.out.println("Que peek:" + Que); // System.out.println("uName peek:" + uName); /////////////////////////// if (Que.peek() != null && uName.peek() != null) { // System.out.println("message output thread started"); for (int i = 0; i < member; i++) { // if (uName.peek() == i) { // i++; // } else { if (i == member - 1) { try { System.out.println(" member-1 stage"); writeString(mArr[i].out, mArr[uName.poll()].userName); writeString(mArr[i].out, Que.poll()); } catch (ConnectException ex) { System.out.println("Connection:" + ex); } catch (IOException ex) { System.out.println("IO:" + ex); } } else { try { System.out.println(" else stage " + i); System.out.println("Que peek:" + Que.peek()); System.out.println("uName peek:" + uName.peek().intValue()); writeString(mArr[i].out, mArr[uName.peek().intValue()].userName); writeString(mArr[i].out, Que.peek()); } catch (ConnectException ex) { System.out.println("Connection:" + ex); } catch (IOException ex) { System.out.println("IO:" + ex); } // } } } } } }) .start(); /* new Thread(() -> { //check if anyone left }).start(); */ }
@Override public void start(Stage primaryStage) throws Exception { try { screenSize = Screen.getPrimary().getVisualBounds(); width = screenSize.getWidth(); // gd.getDisplayMode().getWidth(); height = screenSize.getHeight(); // gd.getDisplayMode().getHeight(); } catch (Exception excep) { System.out.println("<----- Exception in Get Screen Size ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } try { dbCon = DriverManager.getConnection( "jdbc:mysql://192.168.1.6:3306/ale", "Root", "oqu#$XQgHFzDj@1MGg1G8"); estCon = true; } catch (SQLException sqlExcep) { System.out.println("<----- SQL Exception in Establishing Database Connection ----->"); sqlExcep.printStackTrace(); System.out.println("<---------->\n"); } xmlParser.generateUserInfo(); superUser = xmlParser.getSuperUser(); // ----------------------------------------------------------------------------------------------------> Top Panel Start closeBtn = new Button(""); closeBtn.getStyleClass().add("systemBtn"); closeBtn.setOnAction( e -> { systemClose(); }); minimizeBtn = new Button(""); minimizeBtn.getStyleClass().add("systemBtn"); minimizeBtn.setOnAction( e -> { primaryStage.setIconified(true); }); miscContainer = new HBox(); calcBtn = new Button(); calcBtn.getStyleClass().addAll("calcBtn"); calcBtn.setOnAction( e -> { calculator calculator = new calculator(); scientificCalculator scientificCalculator = new scientificCalculator(); calculator.start(calculatorName); }); miscContainer.getChildren().add(calcBtn); topPanel = new HBox(1); topPanel.getStyleClass().add("topPanel"); topPanel.setPrefWidth(width); topPanel.setAlignment(Pos.CENTER_RIGHT); topPanel.setPadding(new Insets(0, 0, 0, 0)); topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn); // ------------------------------------------------------------------------------------------------------> Top Panel End // ----------------------------------------------------------------------------------------------> Navigation Panel Start Line initDivider = new Line(); initDivider.setStartX(0.0f); initDivider.setEndX(205.0f); initDivider.setStroke(Color.GRAY); // <----- Dashboard -----> dashboardToolTip = new Tooltip("Dashboard"); dashboardBtn = new Button(""); dashboardBtn.getStyleClass().add("dashboardBtn"); dashboardBtn.setTooltip(dashboardToolTip); dashboardBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(dashBoardBase); }); // <----- Profile -----> profileToolTip = new Tooltip("Profile"); profileBtn = new Button(); profileBtn.getStyleClass().add("profileBtn"); profileBtn.setTooltip(profileToolTip); profileBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(profilePanel); }); // <----- Courses -----> courseToolTip = new Tooltip("Courses"); coursesBtn = new Button(""); coursesBtn.getStyleClass().add("coursesBtn"); coursesBtn.setTooltip(courseToolTip); coursesBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(coursesPanel); // miscContainer.getChildren().addAll(watchVidBtn); coursesPanel.setContent(coursesGridPanel); }); Line mainDivider = new Line(); mainDivider.setStartX(0.0f); mainDivider.setEndX(205.0f); mainDivider.setStroke(Color.GRAY); // <----- Simulations -----> simsToolTip = new Tooltip("Simulations"); simsBtn = new Button(); simsBtn.getStyleClass().add("simsBtn"); simsBtn.setTooltip(simsToolTip); simsBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(simsPanel); simsPanel.setContent(simsGridPanel); }); // <----- Text Editor -----> textEditorToolTip = new Tooltip("Text Editor"); textEditorBtn = new Button(); textEditorBtn.getStyleClass().add("textEditorBtn"); textEditorBtn.setTooltip(textEditorToolTip); textEditorBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(textEditorPanel); miscContainer.getChildren().addAll(saveDocBtn); }); Line toolsDivider = new Line(); toolsDivider.setStartX(0.0f); toolsDivider.setEndX(205.0f); toolsDivider.setStroke(Color.GRAY); // <----- Wolfram Alpha -----> wolframToolTip = new Tooltip("Wolfram Alpha"); wolframBtn = new Button(); wolframBtn.getStyleClass().add("wolframBtn"); wolframBtn.setTooltip(wolframToolTip); wolframBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(wolframPanel); }); // <----- Wikipedia -----> wikipediaToolTip = new Tooltip(); wikipediaBtn = new Button(); wikipediaBtn.getStyleClass().add("wikipediaBtn"); wikipediaBtn.setTooltip(wikipediaToolTip); wikipediaBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(wikipediaPanel); }); Line sitesDivider = new Line(); sitesDivider.setStartX(0.0f); sitesDivider.setEndX(205.0f); sitesDivider.setStroke(Color.GRAY); // <----- Settings -----> settingsToolTip = new Tooltip("Settings"); settingsBtn = new Button(); settingsBtn.getStyleClass().add("settingsBtn"); settingsBtn.setTooltip(settingsToolTip); settingsBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(settingsPanel); }); leftPanel = new VBox(0); // leftPanel.setPrefWidth(1); leftPanel.getStyleClass().add("leftPane"); leftPanel .getChildren() .addAll( initDivider, dashboardBtn, profileBtn, coursesBtn, mainDivider, simsBtn, textEditorBtn, toolsDivider, wolframBtn, wikipediaBtn, sitesDivider, settingsBtn); topPanel = new HBox(1); topPanel.getStyleClass().add("topPanel"); topPanel.setPrefWidth(width); topPanel.setAlignment(Pos.CENTER_RIGHT); topPanel.setPadding(new Insets(0, 0, 0, 0)); topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn); // ------------------------------------------------------------------------------------------------> Navigation Panel End // -----------------------------------------------------------------------------------------------> Dashboard Pane Start final WebView webVid = new WebView(); final WebEngine webVidEngine = webVid.getEngine(); webVid.setPrefHeight(860); webVid.setPrefWidth(width - 118); webVidEngine.loadContent(""); final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Day"); yAxis.setLabel("Score"); final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Line Chart"); XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>(); series.setName("My Data"); // populating the series with data series.getData().add(new XYChart.Data<Number, Number>(0.25, 36)); series.getData().add(new XYChart.Data<Number, Number>(1, 23)); series.getData().add(new XYChart.Data<Number, Number>(2, 114)); series.getData().add(new XYChart.Data<Number, Number>(3, 15)); series.getData().add(new XYChart.Data<Number, Number>(4, 124)); lineChart.getData().add(series); lineChart.setPrefWidth(400); lineChart.setPrefHeight(300); lineChart.setLegendVisible(false); chatRoomField = new TextField(); chatRoomField.getStyleClass().add("textField"); chatRoomField.setPromptText("Enter Chat Room"); chatRoomField.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { chatRoom = chatRoomField.getText(); client.connect(messageArea, messageInputArea, superUser, chatRoom); } } }); messageArea = new TextArea(); messageArea.getStyleClass().add("textArea"); messageArea.setWrapText(true); messageArea.setPrefHeight(740); messageArea.setEditable(false); messageInputArea = new TextArea(); messageInputArea.getStyleClass().add("textArea"); messageInputArea.setWrapText(true); messageInputArea.setPrefHeight(100); messageInputArea.setPromptText("Enter Message"); messageInputArea.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { client.send(messageArea, messageInputArea, superUser, chatRoom); event.consume(); } } }); chatBox = new VBox(); chatBox.setPrefWidth(250); chatBox.setMaxWidth(250); chatBox.getStyleClass().add("chatBox"); chatBox.getChildren().addAll(chatRoomField, messageArea, messageInputArea); // client.test(messageArea, messageInputArea); dashboardGridPanel = new GridPane(); dashboardGridPanel.getStyleClass().add("gridPane"); dashboardGridPanel.setVgap(5); dashboardGridPanel.setHgap(5); dashboardGridPanel.setGridLinesVisible(false); dashboardGridPanel.setPrefWidth(width - 430); dashboardGridPanel.setPrefHeight(860); dashboardGridPanel.setColumnIndex(lineChart, 0); dashboardGridPanel.setRowIndex(lineChart, 0); dashboardGridPanel.getChildren().addAll(lineChart); dashboardPanel = new ScrollPane(); dashboardPanel.getStyleClass().add("scrollPane"); dashboardPanel.setPrefWidth(width - 400); dashboardPanel.setPrefHeight(860); dashboardPanel.setContent(dashboardGridPanel); dashBoardBase = new HBox(); dashBoardBase.setPrefWidth(width - (leftPanel.getWidth() + chatBox.getWidth())); dashBoardBase.setPrefHeight(860); dashBoardBase.getChildren().addAll(dashboardPanel, chatBox); // -------------------------------------------------------------------------------------------------> Dashboard Pane End // -------------------------------------------------------------------------------------------------> Profile Pane Start profilePictureBtn = new Button(); profilePictureBtn.getStyleClass().addAll("profilePictureBtn"); String profileUserName = xmlParser.getSuperUser(); String profileEmail = xmlParser.getEmail(); String profileAge = xmlParser.getAge(); String profileSchool = xmlParser.getSchool(); String profileCountry = ""; String profileCity = ""; userNameLbl = new Label(profileUserName); userNameLbl.getStyleClass().add("profileLbl"); userNameLbl.setAlignment(Pos.CENTER); emailLbl = new Label(profileEmail); emailLbl.getStyleClass().add("profileLbl"); ageLbl = new Label(profileAge); ageLbl.getStyleClass().add("profileLbl"); schoolLbl = new Label(profileSchool); schoolLbl.getStyleClass().add("profileLbl"); profileGridPanel = new GridPane(); profileGridPanel.getStyleClass().add("gridPane"); profileGridPanel.setVgap(5); profileGridPanel.setHgap(5); profileGridPanel.setGridLinesVisible(false); profileGridPanel.setPrefWidth(width - 208); profileGridPanel.setPrefHeight(860); profileGridPanel.setAlignment(Pos.TOP_CENTER); profileGridPanel.setRowIndex(profilePictureBtn, 0); profileGridPanel.setColumnIndex(profilePictureBtn, 0); profileGridPanel.setRowIndex(userNameLbl, 1); profileGridPanel.setColumnIndex(userNameLbl, 0); profileGridPanel.setRowIndex(emailLbl, 2); profileGridPanel.setColumnIndex(emailLbl, 0); profileGridPanel.setRowIndex(ageLbl, 3); profileGridPanel.setColumnIndex(ageLbl, 0); profileGridPanel.setRowIndex(schoolLbl, 4); profileGridPanel.setColumnIndex(schoolLbl, 0); profileGridPanel .getChildren() .addAll(profilePictureBtn, userNameLbl, emailLbl, ageLbl, schoolLbl); profilePanel = new ScrollPane(); profilePanel.getStyleClass().add("scrollPane"); profilePanel.setContent(profileGridPanel); // ---------------------------------------------------------------------------------------------------> Profile Pane End // -------------------------------------------------------------------------------------------------> Courses Pane Start String course = ""; // Media media = new Media("media.mp4"); // mediaPlayer = new MediaPlayer(media); // mediaPlayer.setAutoPlay(true); // mediaView = new MediaView(mediaPlayer); watchVidBtn = new Button("Watch Video"); watchVidBtn.getStyleClass().add("btn"); watchVidBtn.setOnAction( e -> { // coursesPanel.setContent(mediaView); }); chemistryBtn = new Button(); chemistryBtn.getStyleClass().add("chemistryBtn"); chemistryBtn.setOnAction( e -> { displayCourse("chemistry"); }); physicsBtn = new Button(); physicsBtn.getStyleClass().add("physicsBtn"); physicsBtn.setOnAction( e -> { displayCourse("physics"); }); mathsBtn = new Button(); mathsBtn.getStyleClass().add("mathsBtn"); bioBtn = new Button(); bioBtn.getStyleClass().add("bioBtn"); bioBtn.setOnAction( e -> { rootPane.setCenter(biologyCourse.biologyPane()); }); // Course Web View try { courseView = new WebView(); courseWebEngine = courseView.getEngine(); courseView.setPrefHeight(860); courseView.setPrefWidth(width - 208); } catch (Exception excep) { System.out.println("<----- Exception in Course Web ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } coursesGridPanel = new GridPane(); coursesGridPanel.getStyleClass().add("gridPane"); coursesGridPanel.setVgap(5); coursesGridPanel.setHgap(5); coursesGridPanel.setGridLinesVisible(false); coursesGridPanel.setPrefWidth(width - 208); coursesGridPanel.setPrefHeight(860); coursesGridPanel.setRowIndex(chemistryBtn, 1); coursesGridPanel.setColumnIndex(chemistryBtn, 1); coursesGridPanel.setRowIndex(physicsBtn, 1); coursesGridPanel.setColumnIndex(physicsBtn, 2); coursesGridPanel.setRowIndex(mathsBtn, 1); coursesGridPanel.setColumnIndex(mathsBtn, 3); coursesGridPanel.setRowIndex(bioBtn, 1); coursesGridPanel.setColumnIndex(bioBtn, 4); coursesGridPanel.getChildren().addAll(chemistryBtn, physicsBtn, mathsBtn, bioBtn); coursesPanel = new ScrollPane(); coursesPanel.getStyleClass().add("scrollPane"); coursesPanel.setPrefWidth(width - 118); coursesPanel.setPrefHeight(860); coursesPanel.setContent(coursesGridPanel); // ---------------------------------------------------------------------------------------------------> Courses Pane End // ---------------------------------------------------------------------------------------------> Simulations Pane Start final WebView browser = new WebView(); final WebEngine webEngine = browser.getEngine(); browser.setPrefHeight(860); browser.setPrefWidth(width - 208); /* File phetImageFile = new File("img/styleDark/poweredByPHET.png"); String phetImageURL = phetImageFile.toURI().toURL().toString(); Image phetImage = new Image(phetImageURL, false); */ final ImageView phetImageView = new ImageView(); final Image phetImage = new Image(Main.class.getResourceAsStream("img/styleDark/poweredByPHET.png")); phetImageView.setImage(phetImage); Label motionLbl = new Label("Motion"); motionLbl.getStyleClass().add("lbl"); forcesAndMotionBtn = new Button(); forcesAndMotionBtn.getStyleClass().add("forcesAndMotionBtn"); forcesAndMotionBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html"); simsPanel.setContent(browser); }); balancingActBtn = new Button(); balancingActBtn.getStyleClass().add("balancingActBtn"); balancingActBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html"); simsPanel.setContent(browser); }); energySkateParkBtn = new Button(); energySkateParkBtn.getStyleClass().add("energySkateParkBtn"); energySkateParkBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/energy-skate-park-basics/latest/" + "energy-skate-park-basics_en.html"); simsPanel.setContent(browser); }); balloonsAndStaticElectricityBtn = new Button(); balloonsAndStaticElectricityBtn.getStyleClass().add("balloonsAndStaticElectricityBtn"); balloonsAndStaticElectricityBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/" + "balloons-and-static-electricity_en.html"); simsPanel.setContent(browser); }); buildAnAtomBtn = new Button(); buildAnAtomBtn.getStyleClass().add("buildAnAtomBtn"); buildAnAtomBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/build-an-atom/latest/build-an-atom_en.html"); simsPanel.setContent(browser); }); colorVisionBtn = new Button(); colorVisionBtn.getStyleClass().add("colorVisionBtn"); colorVisionBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/color-vision/latest/color-vision_en.html"); simsPanel.setContent(browser); }); Label soundAndWavesLbl = new Label("Sound and Waves"); soundAndWavesLbl.getStyleClass().add("lbl"); wavesOnAStringBtn = new Button(); wavesOnAStringBtn.getStyleClass().add("wavesOnAStringBtn"); wavesOnAStringBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/wave-on-a-string/latest/wave-on-a-string_en.html"); simsPanel.setContent(browser); }); /* motionSimsFlowPane = new FlowPane(); motionSimsFlowPane.getStyleClass().add("flowPane"); motionSimsFlowPane.setVgap(5); motionSimsFlowPane.setHgap(5); motionSimsFlowPane.setAlignment(Pos.TOP_LEFT); motionSimsFlowPane.getChildren().addAll(forcesAndMotionBtn, balancingActBtn, energySkateParkBtn, buildAnAtomBtn, colorVisionBtn, wavesOnAStringBtn); soundAndWavesFlowPane = new FlowPane(); soundAndWavesFlowPane.getStyleClass().add("flowPane"); soundAndWavesFlowPane.setVgap(5); soundAndWavesFlowPane.setHgap(5); soundAndWavesFlowPane.setAlignment(Pos.TOP_LEFT); soundAndWavesFlowPane.getChildren().addAll(wavesOnAStringBtn); simsBox = new VBox(); simsBox.getStyleClass().add("vbox"); simsBox.setPrefHeight(height); simsBox.setPrefWidth(width); simsBox.getChildren().addAll(motionLbl, motionSimsFlowPane, soundAndWavesLbl, soundAndWavesFlowPane); */ simsGridPanel = new GridPane(); simsGridPanel.getStyleClass().add("gridPane"); simsGridPanel.setVgap(5); simsGridPanel.setHgap(5); simsGridPanel.setGridLinesVisible(false); simsGridPanel.setPrefWidth(width - 208); simsGridPanel.setPrefHeight(860); simsGridPanel.setRowIndex(phetImageView, 0); simsGridPanel.setColumnIndex(phetImageView, 4); simsGridPanel.setRowIndex(motionLbl, 0); simsGridPanel.setColumnIndex(motionLbl, 0); simsGridPanel.setRowIndex(forcesAndMotionBtn, 1); simsGridPanel.setColumnIndex(forcesAndMotionBtn, 0); simsGridPanel.setRowIndex(balancingActBtn, 1); simsGridPanel.setColumnIndex(balancingActBtn, 1); simsGridPanel.setRowIndex(energySkateParkBtn, 1); simsGridPanel.setColumnIndex(energySkateParkBtn, 2); simsGridPanel.setRowIndex(buildAnAtomBtn, 1); simsGridPanel.setColumnIndex(buildAnAtomBtn, 3); simsGridPanel.setRowIndex(colorVisionBtn, 1); simsGridPanel.setColumnIndex(colorVisionBtn, 4); simsGridPanel.setRowIndex(soundAndWavesLbl, 2); simsGridPanel.setColumnIndex(soundAndWavesLbl, 0); simsGridPanel.setColumnSpan(soundAndWavesLbl, 4); simsGridPanel.setRowIndex(wavesOnAStringBtn, 3); simsGridPanel.setColumnIndex(wavesOnAStringBtn, 0); simsGridPanel .getChildren() .addAll( phetImageView, motionLbl, forcesAndMotionBtn, balancingActBtn, energySkateParkBtn, buildAnAtomBtn, colorVisionBtn, soundAndWavesLbl, wavesOnAStringBtn); simsPanel = new ScrollPane(); simsPanel.getStyleClass().add("scrollPane"); simsPanel.setContent(simsGridPanel); // -----------------------------------------------------------------------------------------------> Simulations Pane End // ---------------------------------------------------------------------------------------------> Text Editor Pane Start htmlEditor = new HTMLEditor(); htmlEditor.setPrefHeight(860); htmlEditor.setPrefWidth(width - 208); // Prevents Scroll on Space Pressed htmlEditor.addEventFilter( KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getEventType() == KeyEvent.KEY_PRESSED) { if (event.getCode() == KeyCode.SPACE) { event.consume(); } } } }); XWPFDocument document = new XWPFDocument(); XWPFParagraph tmpParagraph = document.createParagraph(); XWPFRun tmpRun = tmpParagraph.createRun(); saveDocBtn = new Button(); saveDocBtn.getStyleClass().add("btn"); saveDocBtn.setText("Save"); saveDocBtn.setOnAction( e -> { tmpRun.setText(tools.stripHTMLTags(htmlEditor.getHtmlText())); tmpRun.setFontSize(12); saveDocument(document, primaryStage); }); textEditorPanel = new ScrollPane(); textEditorPanel.getStyleClass().add("scrollPane"); textEditorPanel.setContent(htmlEditor); // -----------------------------------------------------------------------------------------------> Text Editor Pane End // -------------------------------------------------------------------------------------------------> Wolfram Pane Start Boolean wolframActive = false; try { final WebView wolframWeb = new WebView(); wolframWeb.getStyleClass().add("webView"); final WebEngine wolframWebEngine = wolframWeb.getEngine(); wolframWeb.setPrefHeight(860); wolframWeb.setPrefWidth(width - 208); if (wolframActive == false) { wolframWebEngine.load("http://www.wolframalpha.com/"); wolframActive = true; } wolframPanel = new ScrollPane(); wolframPanel.setContent(wolframWeb); } catch (Exception excep) { System.out.println("<----- Exception in Wolfram Alpha Web ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } // ---------------------------------------------------------------------------------------------------> Wolfram Pane End // ------------------------------------------------------------------------------------------------> Wikipedia Pane Start Boolean wikipediaActive = false; try { final WebView wikipediaWeb = new WebView(); wikipediaWeb.getStyleClass().add("scrollPane"); wikipediaWebEngine = wikipediaWeb.getEngine(); wikipediaWeb.setPrefHeight(860); wikipediaWeb.setPrefWidth(width - 208); if (wikipediaActive == false) { wikipediaWebEngine.load("https://en.wikipedia.org/wiki/Main_Page"); wikipediaActive = true; } wikipediaPanel = new ScrollPane(); wikipediaPanel.setContent(wikipediaWeb); } catch (Exception e) { e.printStackTrace(); } // --------------------------------------------------------------------------------------------------> Wikipedia Pane End // -------------------------------------------------------------------------------------------------> Settings Pane Start settingsGridPanel = new GridPane(); settingsGridPanel.getStyleClass().add("gridPane"); settingsGridPanel.setPrefWidth(width - 208); settingsGridPanel.setPrefHeight(height); settingsGridPanel.setVgap(5); settingsGridPanel.setHgap(5); settingsPanel = new ScrollPane(); settingsPanel.getStyleClass().add("scrollPane"); settingsPanel.setContent(settingsGridPanel); // ---------------------------------------------------------------------------------------------------> Settings Pane End rootPane = new BorderPane(); rootPane.setLeft(leftPanel); rootPane.setTop(topPanel); rootPane.setCenter(dashBoardBase); rootPane.getStyleClass().add("rootPane"); rootPane.getStylesheets().add(Main.class.getResource("css/styleDark.css").toExternalForm()); programWidth = primaryStage.getWidth(); programHeight = primaryStage.getHeight(); primaryStage.setTitle("ALE"); primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage .getIcons() .add(new javafx.scene.image.Image(Main.class.getResourceAsStream("img/aleIcon.png"))); primaryStage.setScene(new Scene(rootPane, width, height)); primaryStage.show(); }
public EditorPane(ISandboxStage stage) { this.sandboxStage = stage; lblTitle = new Label("New File"); Button btnOpen = StyleUtil.buildButton("Open"); btnOpen.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { promptSave(); chooseFile(); } }); btnSave = StyleUtil.buildButton("Save"); btnSave.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { saveFile(); } }); btnSave.setDisable(!isModified); Button btnClear = StyleUtil.buildButton("Clear"); btnClear.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { lblTitle.setText("New File"); taSource.setText(S_EMPTY); } }); Button btnClose = StyleUtil.buildButton("Close"); btnClose.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { promptSave(); sandboxStage.editorClosed(EditorPane.this); } }); Button btnRun = StyleUtil.buildButton("Run"); btnRun.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (isModified) { promptSave(); } setVMLanguage(); sandboxStage.runFile(EditorPane.this); } }); hBoxTitle = new HBox(); hBoxTitle.setSpacing(10); hBoxTitle.setPadding(new Insets(0, 10, 0, 10)); hBoxTitle.getChildren().add(lblTitle); hBoxTitle.getChildren().add(btnOpen); hBoxTitle.getChildren().add(btnSave); hBoxTitle.getChildren().add(btnClear); hBoxTitle.getChildren().add(btnClose); hBoxTitle.getChildren().add(btnRun); hBoxTitle.setStyle("-fx-background-color:#dddddd; -fx-padding:4px;"); taSource = new TextArea(); String styleSource = "-fx-font-family:monospace; -fx-font-size:12px; -fx-background-color:white;"; taSource.setStyle(styleSource); taSource .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( final ObservableValue<? extends String> observable, final String oldValue, final String newValue) { setModified(true); } }); taSource .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> arg0, Boolean oldValue, Boolean newValue) { if (Boolean.TRUE.equals(newValue)) { setVMLanguage(); } } }); setTextAreaSaveCombo(taSource); taLineNumbers = new TextArea(); String styleLineNumber = "-fx-padding:0; -fx-font-family:monospace; -fx-font-size:12px; -fx-background-color:#eeeeee;"; taLineNumbers.setStyle(styleLineNumber); taLineNumbers.setEditable(false); taLineNumbers.setWrapText(true); HBox hBoxTextAreas = new HBox(); hBoxTextAreas.getChildren().add(taLineNumbers); hBoxTextAreas.getChildren().add(taSource); taSource.prefWidthProperty().bind(hBoxTextAreas.widthProperty()); getChildren().add(hBoxTitle); getChildren().add(hBoxTextAreas); hBoxTitle.prefWidthProperty().bind(widthProperty()); hBoxTitle.prefHeightProperty().bind(heightProperty().multiply(0.1)); hBoxTextAreas.prefWidthProperty().bind(widthProperty()); hBoxTextAreas.prefHeightProperty().bind(heightProperty().multiply(0.9)); }
private void onSelectDispute(Dispute dispute) { if (dispute == null) { if (root.getChildren().size() > 1) root.getChildren().remove(1); selectedDispute = null; } else if (selectedDispute != dispute) { this.selectedDispute = dispute; boolean isTrader = disputeManager.isTrader(dispute); TableGroupHeadline tableGroupHeadline = new TableGroupHeadline(); tableGroupHeadline.setText("Messages"); tableGroupHeadline.prefWidthProperty().bind(root.widthProperty()); AnchorPane.setTopAnchor(tableGroupHeadline, 10d); AnchorPane.setRightAnchor(tableGroupHeadline, 0d); AnchorPane.setBottomAnchor(tableGroupHeadline, 0d); AnchorPane.setLeftAnchor(tableGroupHeadline, 0d); ObservableList<DisputeDirectMessage> list = dispute.getDisputeDirectMessagesAsObservableList(); SortedList<DisputeDirectMessage> sortedList = new SortedList<>(list); sortedList.setComparator((o1, o2) -> o1.getDate().compareTo(o2.getDate())); list.addListener((ListChangeListener<DisputeDirectMessage>) c -> scrollToBottom()); messageListView = new ListView<>(sortedList); messageListView.setId("message-list-view"); messageListView.prefWidthProperty().bind(root.widthProperty()); messageListView.setMinHeight(150); AnchorPane.setTopAnchor(messageListView, 30d); AnchorPane.setRightAnchor(messageListView, 0d); AnchorPane.setLeftAnchor(messageListView, 0d); messagesAnchorPane = new AnchorPane(); messagesAnchorPane.prefWidthProperty().bind(root.widthProperty()); VBox.setVgrow(messagesAnchorPane, Priority.ALWAYS); inputTextArea = new TextArea(); inputTextArea.setPrefHeight(70); inputTextArea.setWrapText(true); Button sendButton = new Button("Send"); sendButton.setDefaultButton(true); sendButton.setOnAction(e -> onSendMessage(inputTextArea.getText(), dispute)); sendButton.setDisable(true); inputTextArea .textProperty() .addListener( (observable, oldValue, newValue) -> { sendButton.setDisable( newValue.length() == 0 && tempAttachments.size() == 0 && dispute.disputeResultProperty().get() == null); }); Button uploadButton = new Button("Add attachments"); uploadButton.setOnAction(e -> onRequestUpload()); sendMsgInfoLabel = new Label(); sendMsgInfoLabel.setVisible(false); sendMsgInfoLabel.setManaged(false); sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0)); sendMsgProgressIndicator = new ProgressIndicator(0); sendMsgProgressIndicator.setPrefHeight(24); sendMsgProgressIndicator.setPrefWidth(24); sendMsgProgressIndicator.setVisible(false); sendMsgProgressIndicator.setManaged(false); dispute .isClosedProperty() .addListener( (observable, oldValue, newValue) -> { messagesInputBox.setVisible(!newValue); messagesInputBox.setManaged(!newValue); AnchorPane.setBottomAnchor(messageListView, newValue ? 0d : 120d); }); if (!dispute.isClosed()) { HBox buttonBox = new HBox(); buttonBox.setSpacing(10); buttonBox .getChildren() .addAll(sendButton, uploadButton, sendMsgProgressIndicator, sendMsgInfoLabel); if (!isTrader) { Button closeDisputeButton = new Button("Close ticket"); closeDisputeButton.setOnAction(e -> onCloseDispute(dispute)); closeDisputeButton.setDefaultButton(true); Pane spacer = new Pane(); HBox.setHgrow(spacer, Priority.ALWAYS); buttonBox.getChildren().addAll(spacer, closeDisputeButton); } messagesInputBox = new VBox(); messagesInputBox.setSpacing(10); messagesInputBox.getChildren().addAll(inputTextArea, buttonBox); VBox.setVgrow(buttonBox, Priority.ALWAYS); AnchorPane.setRightAnchor(messagesInputBox, 0d); AnchorPane.setBottomAnchor(messagesInputBox, 5d); AnchorPane.setLeftAnchor(messagesInputBox, 0d); AnchorPane.setBottomAnchor(messageListView, 120d); messagesAnchorPane .getChildren() .addAll(tableGroupHeadline, messageListView, messagesInputBox); } else { AnchorPane.setBottomAnchor(messageListView, 0d); messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView); } messageListView.setCellFactory( new Callback<ListView<DisputeDirectMessage>, ListCell<DisputeDirectMessage>>() { @Override public ListCell<DisputeDirectMessage> call(ListView<DisputeDirectMessage> list) { return new ListCell<DisputeDirectMessage>() { final Pane bg = new Pane(); final ImageView arrow = new ImageView(); final Label headerLabel = new Label(); final Label messageLabel = new Label(); final HBox attachmentsBox = new HBox(); final AnchorPane messageAnchorPane = new AnchorPane(); final Label statusIcon = new Label(); final double arrowWidth = 15d; final double attachmentsBoxHeight = 20d; final double border = 10d; final double bottomBorder = 25d; final double padding = border + 10d; { bg.setMinHeight(30); messageLabel.setWrapText(true); headerLabel.setTextAlignment(TextAlignment.CENTER); attachmentsBox.setSpacing(5); statusIcon.setStyle("-fx-font-size: 10;"); messageAnchorPane .getChildren() .addAll(bg, arrow, headerLabel, messageLabel, attachmentsBox, statusIcon); } @Override public void updateItem(final DisputeDirectMessage item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { /* messageAnchorPane.prefWidthProperty().bind(EasyBind.map(messageListView.widthProperty(), w -> (double) w - padding - GUIUtil.getScrollbarWidth(messageListView)));*/ if (!messageAnchorPane.prefWidthProperty().isBound()) messageAnchorPane .prefWidthProperty() .bind( messageListView .widthProperty() .subtract(padding + GUIUtil.getScrollbarWidth(messageListView))); AnchorPane.setTopAnchor(bg, 15d); AnchorPane.setBottomAnchor(bg, bottomBorder); AnchorPane.setTopAnchor(headerLabel, 0d); AnchorPane.setBottomAnchor(arrow, bottomBorder + 5d); AnchorPane.setTopAnchor(messageLabel, 25d); AnchorPane.setBottomAnchor(attachmentsBox, bottomBorder + 10); boolean senderIsTrader = item.isSenderIsTrader(); boolean isMyMsg = isTrader ? senderIsTrader : !senderIsTrader; arrow.setVisible(!item.isSystemMessage()); arrow.setManaged(!item.isSystemMessage()); statusIcon.setVisible(false); if (item.isSystemMessage()) { headerLabel.setStyle("-fx-text-fill: -bs-green; -fx-font-size: 11;"); bg.setId("message-bubble-green"); messageLabel.setStyle("-fx-text-fill: white;"); } else if (isMyMsg) { headerLabel.setStyle("-fx-text-fill: -fx-accent; -fx-font-size: 11;"); bg.setId("message-bubble-blue"); messageLabel.setStyle("-fx-text-fill: white;"); if (isTrader) arrow.setId("bubble_arrow_blue_left"); else arrow.setId("bubble_arrow_blue_right"); sendMsgProgressIndicator .progressProperty() .addListener( (observable, oldValue, newValue) -> { if ((double) oldValue == -1 && (double) newValue == 0) { if (item.arrivedProperty().get()) showArrivedIcon(); else if (item.storedInMailboxProperty().get()) showMailboxIcon(); } }); if (item.arrivedProperty().get()) showArrivedIcon(); else if (item.storedInMailboxProperty().get()) showMailboxIcon(); // TODO show that icon on error /*else if (sendMsgProgressIndicator.getProgress() == 0) showNotArrivedIcon();*/ } else { headerLabel.setStyle("-fx-text-fill: -bs-light-grey; -fx-font-size: 11;"); bg.setId("message-bubble-grey"); messageLabel.setStyle("-fx-text-fill: black;"); if (isTrader) arrow.setId("bubble_arrow_grey_right"); else arrow.setId("bubble_arrow_grey_left"); } if (item.isSystemMessage()) { AnchorPane.setLeftAnchor(headerLabel, padding); AnchorPane.setRightAnchor(headerLabel, padding); AnchorPane.setLeftAnchor(bg, border); AnchorPane.setRightAnchor(bg, border); AnchorPane.setLeftAnchor(messageLabel, padding); AnchorPane.setRightAnchor(messageLabel, padding); AnchorPane.setLeftAnchor(attachmentsBox, padding); AnchorPane.setRightAnchor(attachmentsBox, padding); } else if (senderIsTrader) { AnchorPane.setLeftAnchor(headerLabel, padding + arrowWidth); AnchorPane.setLeftAnchor(bg, border + arrowWidth); AnchorPane.setRightAnchor(bg, border); AnchorPane.setLeftAnchor(arrow, border); AnchorPane.setLeftAnchor(messageLabel, padding + arrowWidth); AnchorPane.setRightAnchor(messageLabel, padding); AnchorPane.setLeftAnchor(attachmentsBox, padding + arrowWidth); AnchorPane.setRightAnchor(attachmentsBox, padding); AnchorPane.setRightAnchor(statusIcon, padding); } else { AnchorPane.setRightAnchor(headerLabel, padding + arrowWidth); AnchorPane.setLeftAnchor(bg, border); AnchorPane.setRightAnchor(bg, border + arrowWidth); AnchorPane.setRightAnchor(arrow, border); AnchorPane.setLeftAnchor(messageLabel, padding); AnchorPane.setRightAnchor(messageLabel, padding + arrowWidth); AnchorPane.setLeftAnchor(attachmentsBox, padding); AnchorPane.setRightAnchor(attachmentsBox, padding + arrowWidth); AnchorPane.setLeftAnchor(statusIcon, padding); } AnchorPane.setBottomAnchor(statusIcon, 7d); headerLabel.setText(formatter.formatDateTime(item.getDate())); messageLabel.setText(item.getMessage()); if (item.getAttachments().size() > 0) { AnchorPane.setBottomAnchor( messageLabel, bottomBorder + attachmentsBoxHeight + 10); attachmentsBox .getChildren() .add( new Label("Attachments: ") { { setPadding(new Insets(0, 0, 3, 0)); if (isMyMsg) setStyle("-fx-text-fill: white;"); else setStyle("-fx-text-fill: black;"); } }); item.getAttachments() .stream() .forEach( attachment -> { final Label icon = new Label(); setPadding(new Insets(0, 0, 3, 0)); if (isMyMsg) icon.getStyleClass().add("attachment-icon"); else icon.getStyleClass().add("attachment-icon-black"); AwesomeDude.setIcon(icon, AwesomeIcon.FILE_TEXT); icon.setPadding(new Insets(-2, 0, 0, 0)); icon.setTooltip(new Tooltip(attachment.getFileName())); icon.setOnMouseClicked(event -> onOpenAttachment(attachment)); attachmentsBox.getChildren().add(icon); }); } else { attachmentsBox.getChildren().clear(); AnchorPane.setBottomAnchor(messageLabel, bottomBorder + 10); } // TODO There are still some cell rendering issues on updates setGraphic(messageAnchorPane); } else { messageAnchorPane.prefWidthProperty().unbind(); AnchorPane.clearConstraints(bg); AnchorPane.clearConstraints(headerLabel); AnchorPane.clearConstraints(arrow); AnchorPane.clearConstraints(messageLabel); AnchorPane.clearConstraints(statusIcon); AnchorPane.clearConstraints(attachmentsBox); setGraphic(null); } } /* private void showNotArrivedIcon() { statusIcon.setVisible(true); AwesomeDude.setIcon(statusIcon, AwesomeIcon.WARNING_SIGN, "14"); Tooltip.install(statusIcon, new Tooltip("Message did not arrive. Please try to send again.")); statusIcon.setTextFill(Paint.valueOf("#dd0000")); }*/ private void showMailboxIcon() { statusIcon.setVisible(true); AwesomeDude.setIcon(statusIcon, AwesomeIcon.ENVELOPE_ALT, "14"); Tooltip.install(statusIcon, new Tooltip("Message saved in receivers mailbox")); statusIcon.setTextFill(Paint.valueOf("#0f87c3")); } private void showArrivedIcon() { statusIcon.setVisible(true); AwesomeDude.setIcon(statusIcon, AwesomeIcon.OK, "14"); Tooltip.install(statusIcon, new Tooltip("Message arrived at receiver")); statusIcon.setTextFill(Paint.valueOf("#0f87c3")); } }; } }); if (root.getChildren().size() > 1) root.getChildren().remove(1); root.getChildren().add(1, messagesAnchorPane); scrollToBottom(); } }
public SerieInfo(final Serie serie) { // TODO Auto-generated constructor stub GridPane grid = new GridPane(); FlowPane flow = new FlowPane(Orientation.HORIZONTAL); flow.setAlignment(Pos.TOP_LEFT); flow.setHgap(40); DropShadow dropShadow = new DropShadow(); dropShadow.setOffsetX(10); dropShadow.setOffsetY(10); dropShadow.setColor(Color.rgb(50, 50, 50, 0.7)); Label poster = new Label(); String style_inner = "-fx-font: Gill Sans;" + "-fx-font-family: Gill Sans;" + "-fx-effect: dropshadow(one-pass-box, black, 8, 0, 4, 4);"; poster.setStyle(style_inner); final Label star = new Label(); Image stella = new Image("img/greentick.png", 35, 35, true, true, true); star.setGraphic(new ImageView(stella)); star.setVisible(false); ImageView image = new ImageView(serie.getPoster()); poster.setGraphic(image); TextArea text = new TextArea(); text.setPrefSize(600, 160); text.setText(serie.getOverview()); text.setWrapText(true); text.setEditable(false); /* * text.setStyle("-fx-text-fill: black;"+ "-fx-font: Gill Sans;"+ * "-fx-font-size: 13;" + "-fx-height:400"); */ text.setStyle(LABEL_STYLE); String name = null; if (serie.getNome().length() > 16) { name = serie.getNome().substring(0, 15); name = name.concat("..."); } else { name = serie.getNome(); } Label nome = new Label(name); nome.setTextFill(Color.BLACK); nome.setFont(Font.font("Helvetica", 28)); final Button btn = new Button(" Add "); ImageView imageview = new ImageView(new Image("img/add.png", 12, 12, true, true, true)); btn.setGraphic(imageview); btn.setContentDisplay(ContentDisplay.LEFT); /* * String buttonCss = SerieInfo.class.getResource("CustomButton.css") * .toExternalForm(); btn.getStylesheets().add(buttonCss); */ btn.getStyleClass().add("custom-browse"); btn.setCursor(Cursor.HAND); btn.setTextFill(Color.WHITE); btn.addEventHandler( MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { star.setVisible(true); if (Preferiti.getInstance().addToPreferiti(serie) == false) { /* * new MyDialog(Guiseries2.stage, * Modality.APPLICATION_MODAL, "Warning!", serie); */ } else { btn.setDisable(true); btn.setText(" Added "); btn.setGraphic(null); // torrent... DaemonManager manager = new DaemonManager(); Search search = new Search( serie, manager, "ENG", new SearchListener() { @Override public void SearchListener() { Platform.runLater( new Runnable() { @Override public void run() { boolean compare = false; for (int i = 0; i < serie.getStagioni().size(); i++) { for (int j = 0; j < serie.getStagioni().get(i).getEpisodiStagione().size(); j++) { compare = false; if ((serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent() != null)) { for (int k = (1 + j); k < serie .getStagioni() .get(i) .getEpisodiStagione() .size(); k++) { if (serie .getStagioni() .get(i) .getEpisodiStagione() .get(k) .getTorrent() != null) { if (serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent() .getName() .equals( serie .getStagioni() .get(i) .getEpisodiStagione() .get(k) .getTorrent() .getName())) { compare = true; } } } if (compare == false) { TorrentSeriesElement.getInstance() .addToTorrents( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent()); if ((TorrentSeriesElement.getInstance() .torrents .indexOf( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent()) % 2) == 0) { TabDownload.mainDownload .getChildren() .add( TabDownload.addTorrentEvenToDownloadTab( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent())); } else { TabDownload.mainDownload .getChildren() .add( TabDownload.addTorrentOddToDownloadTab( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent())); } System.out.println( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent() .getName()); } } } } try { FilmistaDb.getInstance().addSeriesToFilmistaDb(serie); } catch (ClassNotFoundException e1) { // TODO Auto-generated // catch // block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated // catch // block e1.printStackTrace(); } catch (SQLException e1) { // TODO Auto-generated // catch // block e1.printStackTrace(); } TabPreferiti.updateTab(); } }); } }); } } }); flow.getChildren().add(btn); flow.getChildren().add(nome); if (Preferiti.getInstance().series.contains(serie) == true) { btn.setText(" Added "); btn.setDisable(true); star.setVisible(true); btn.setGraphic(null); } grid.setHgap(25); grid.setVgap(15); grid.add(poster, 0, 0, 1, 2); grid.add(flow, 1, 0); FlowPane paneStar = new FlowPane(Orientation.HORIZONTAL); paneStar.setAlignment(Pos.TOP_RIGHT); paneStar.getChildren().add(star); grid.add(paneStar, 2, 0, 1, 1); grid.add(text, 1, 1, 2, 1); grid.getColumnConstraints().add(0, new ColumnConstraints()); grid.getColumnConstraints().add(1, new ColumnConstraints()); grid.getColumnConstraints().add(2, new ColumnConstraints(150)); // grid.setGridLinesVisible(true); grid.setHgrow(text, Priority.ALWAYS); grid.setVgrow(poster, Priority.ALWAYS); grid.setPadding(new Insets(25, 25, 25, 25)); this.setCenter(grid); String customCss = SerieInfo.class.getResource("CustomBorder.css").toExternalForm(); this.getStylesheets().add(customCss); this.getStyleClass().add("custom-border"); }