@FXML private void buttonCheckClicked(Event event) { DefectSet leftSide = new DefectSet(prefix); DefectSet rightSide = new DefectSet(prefix); leftSide.load(textInputLeft.getText(), textPrefix.getText(), textMax.getText()); rightSide.load(textInputRight.getText(), textPrefix.getText(), textMax.getText()); labelInputLeft.setText(leftSide.size() + " defect(s) found."); labelInputRight.setText(rightSide.size() + " defect(s) found."); DefectSet outputLeft = leftSide.subtract(rightSide); DefectSet outputRight = rightSide.subtract(leftSide); DefectSet intersect = leftSide.intersect(rightSide); textOutputLeft.setStyle("-fx-text-fill: blue;"); textOutputLeft.setText(outputLeft.listAll()); labelOutputLeft.setText(outputLeft.size() + " missed defect(s) found."); textOutputRight.setStyle("-fx-text-fill: red;"); textOutputRight.setText(outputRight.listAll()); labelOutputRight.setText(outputRight.size() + " missed defect(s) found."); textOutputCenter.setStyle("-fx-text-fill: green;"); textOutputCenter.setText(intersect.listAll()); labelOutputCenter.setText(intersect.size() + " defect(s) covered by both side."); }
@FXML private void onTempModificationButtonClicked(MouseEvent event) throws IOException { PreparedStatement statement; ResultSet result; Connection connection; String insertStatement = "UPDATE ATRACAO SET DESCRICAO = \'" + textArea2.getText() + "\', CLASSIFICACAOETARIA = " + textField3.getText() + ",DATA = TO_DATE(\'" + textField6.getText() + "\',\'MM/DD/YYYY\')" + "WHERE ATRACAO.IDATRACAO = " + textField1.getText(); System.out.println(insertStatement); try { Class.forName("oracle.jdbc.driver.OracleDriver"); connection = DriverManager.getConnection( "jdbc:oracle:thin:@grad.icmc.usp.br:15215:orcl", "7960690", "a"); System.out.println(insertStatement); statement = connection.prepareStatement(insertStatement); statement.executeUpdate(); statement.close(); connection.close(); atracoes.get(currentSelectedRow).setDescricao(textArea2.getText()); atracoes.get(currentSelectedRow).setClassificacaoEtaria(textField3.getText()); atracoes.get(currentSelectedRow).setData(textField6.getText()); } catch (SQLException | ClassNotFoundException ex) { Logger.getLogger(IncludeTupleController.class.getName()).log(Level.SEVERE, null, ex); } }
private boolean validate(String title) { if (instructionsTextArea.getText() == null || instructionsTextArea.getText().length() == 0) { String msg = "Instructions text field is empty"; String details = "Must enter instructions into instructions text field"; AppContext.getCommonDialogs().showErrorDialog(title, msg, details, workflowInitiationView); return false; } if (workflowProcessesComboBox.getSelectionModel().getSelectedItem() == WorkflowProcess.REVIEW3) { // if (editPathCoordinateTextField.getText() == null // || editPathCoordinateTextField.getText().length() == 0) { // String msg = "Edit view coordinate UUID text field is empty"; // String details = "Must enter edit view coordinate UUID into edit coordinate text field"; // AppContext.getCommonDialogs().showErrorDialog(title, msg, details, // AppContext.getMainApplicationWindow().getPrimaryStage()); // return false; // } if (promotionPathCoordinateLabel.getText() == null || promotionPathCoordinateLabel.getText().length() == 0) { String msg = "Promotion view coordinate is unset"; String details = "Promotion view coordinate must be set in config file app.xml"; AppContext.getCommonDialogs().showErrorDialog(title, msg, details, workflowInitiationView); return false; } } else if (workflowProcessesComboBox.getSelectionModel().getSelectedItem() == WorkflowProcess.DUAL_REVIEW) { // if (editPathCoordinateTextField.getText() == null // || editPathCoordinateTextField.getText().length() == 0) { // String msg = "Edit view coordinate UUID text field is empty"; // String details = "Must enter edit view coordinate UUID into edit coordinate text field"; // AppContext.getCommonDialogs().showErrorDialog(title, msg, details, // AppContext.getMainApplicationWindow().getPrimaryStage()); // return false; // } if (promotionPathCoordinateLabel.getText() == null || promotionPathCoordinateLabel.getText().length() == 0) { String msg = "Promotion view coordinate is unset"; String details = "Promotion view coordinate must be set in config file app.xml"; AppContext.getCommonDialogs().showErrorDialog(title, msg, details, workflowInitiationView); return false; } } else { String msg = "Unsupported WorkflowProcessModel: " + workflowProcessesComboBox.getSelectionModel().getSelectedItem(); String details = "Only WorkflowProcess." + WorkflowProcess.REVIEW3 + " and WorkflowProcess." + WorkflowProcess.DUAL_REVIEW + " currently supported"; AppContext.getCommonDialogs().showErrorDialog(title, msg, details, workflowInitiationView); return false; } return true; }
@FXML public void sendGameLobbyMessage(Event evt) throws RemoteException { if (!"".equals(TaGameChat.getText())) { LobbySession.game.addToGameChat(LobbySession.user.getName() + ": " + TaGameChat.getText()); initGameLobbyViews(); TaGameChat.clear(); loadGameLobbyChat(); } }
@Override public void start(Stage primaryStage) { Label inputLabel = new Label("Input"); TextArea input = new TextArea(); input.setFont(MONOSPACE_FONT); setSize(input, INPUT_WIDTH, INPUT_HEIGHT); Label outputLabel = new Label("Output"); TextArea output = new TextArea(); output.setEditable(false); output.setFont(MONOSPACE_FONT); setSize(output, OUTPUT_WIDTH, OUTPUT_HEIGHT); TextArea codeArea = new TextArea(); codeArea.setFont(MONOSPACE_FONT); setSize(codeArea, EDITOR_WIDTH, EDITOR_HEIGHT); Button runButton = new Button("Run"); runButton.setOnAction( e -> { try { output.setText(new A_RayCode(codeArea.getText(), input.getText()).runAndGetOutput()); } catch (RuntimeException exception) { output.setText("Error"); exception.printStackTrace(); } }); Button clearOutput = new Button("Clear Output"); clearOutput.setOnAction( e -> { output.setText(""); }); HBox buttonPane = new HBox(); buttonPane.setSpacing(PANE_SPACING); buttonPane.setAlignment(Pos.CENTER_RIGHT); buttonPane.getChildren().addAll(clearOutput, runButton); VBox mainPane = new VBox(); mainPane.setPadding(MAIN_PANE_INSETS); mainPane.setSpacing(PANE_SPACING); mainPane.getChildren().addAll(codeArea, buttonPane, inputLabel, input, outputLabel, output); BorderPane content = new BorderPane(mainPane); Scene scene = new Scene(content, WIDTH, HEIGHT); primaryStage.setScene(scene); primaryStage.setResizable(false); primaryStage.show(); }
// Send a message to the chat. Adding it to the lobbychat. @FXML public void sendLobbyMessage(Event evt) throws RemoteException { if (!"".equals(tfLobbyChat.getText())) { gameManager.addToChat(LobbySession.user.getName() + ": " + tfLobbyChat.getText()); initViews(); tfLobbyChat.clear(); loadLobbyChat(); } }
@FXML public void next() { if ((text.getText() != null) && (text.getText().equals("") == false)) { Analyzer.getInstance().productions.insertProduction(new Production(text.getText())); } else { showTextAlert(); } clean(); }
@Override public void handle(ActionEvent event) { if (!commentaarveld.getText().isEmpty()) { if (exclamationField == null) { System.out.println("! = null"); } if (commentaarveld == null) { System.out.println("Commentaarveld = null"); } String timeStamp = new SimpleDateFormat("dd/MM/yyyy - HH:mm").format(Calendar.getInstance().getTime()); exclamationField.setText( exclamationField.getText() + timeStamp + ": " + commentaarveld.getText() + "\n"); } }
private void onRequestUpload() { if (tempAttachments.size() < 3) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open file to attach"); /* if (Utilities.isUnix()) fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));*/ File result = fileChooser.showOpenDialog(stage); if (result != null) { try { URL url = result.toURI().toURL(); try (InputStream inputStream = url.openStream()) { byte[] filesAsBytes = ByteStreams.toByteArray(inputStream); if (filesAsBytes.length <= Connection.getMaxMsgSize()) { tempAttachments.add( new DisputeDirectMessage.Attachment(result.getName(), filesAsBytes)); inputTextArea.setText( inputTextArea.getText() + "\n[Attachment " + result.getName() + "]"); } else { new Popup().error("The max. allowed file size is 100 kB.").show(); } } catch (java.io.IOException e) { e.printStackTrace(); log.error(e.getMessage()); } } catch (MalformedURLException e2) { e2.printStackTrace(); log.error(e2.getMessage()); } } } else { new Popup().error("You cannot send more then 3 attachments in one message.").show(); } }
public void confirm(ActionEvent event) { String name = nameField.getText(); if (S.isEmpty(name)) { tipsLabel.setText("错误:工具名字不能为空!"); nameField.requestFocus(); return; } String command = commandText.getText(); String order = orderField.getText(); ToolsTray bandeja = (ToolsTray) parentCombo.getSelectionModel().getSelectedItem(); Integer parentId = bandeja.getId(); ToolType toolType = (ToolType) typeCombo.getSelectionModel().getSelectedItem(); String type = toolType.getToolType(); ToolsTray toolsTray = new ToolsTray(); toolsTray.setTrayName(name); toolsTray.setCommand(command); toolsTray.setParentId(parentId); toolsTray.setToolOrder(order); toolsTray.setToolType(type); if (null == id) { dao.insert(toolsTray); id = toolsTray.getId(); tipsLabel.setText("添加成功:" + name); } else { toolsTray.setId(id); dao.update(toolsTray); tipsLabel.setText("更新成功:" + name); } refresh(null); }
@SuppressWarnings("restriction") @FXML private void sendButtonPressed(ActionEvent action) { // Send message to server String text = sendTextArea.getText(); websocketClientEndpoint.sendTextToServer(text); }
private void setOperaciones() { txtArea.setText(""); ArrayList aux = interprete.getOperaciones(); int i = 0; while (i < aux.size()) { txtArea.setText(txtArea.getText() + "\n" + aux.get(i++)); } }
@Override public void saveFileContent() { try (FileOutputStream fos = new FileOutputStream(file); BufferedOutputStream bos = new BufferedOutputStream(fos)) { String text = textArea.getText(); bos.write(text.getBytes()); bos.flush(); } catch (Exception e) { throw new RuntimeException("Cannot save file " + file.getName(), e); } }
@FXML public void analyse() { if ((text.getText() != null) && (text.getText().equals("") == false)) { Analyzer.getInstance().productions.insertProduction(new Production(text.getText())); } if (Analyzer.getInstance().productions.size() > 0) { Main.showProcessing(); Analyzer.getInstance().analyzeAllProductions(); Main.showResults(); } else { showTextAlert(); } }
@FXML void onTweetButton(ActionEvent event) { String tweet = tweetTextArea.getText(); try { @SuppressWarnings("unused") Status status = twitter.updateStatus(tweet); reloadHomeTL(lastStatusId); } catch (TwitterException e) { e.printStackTrace(); } tweetTextArea.clear(); }
private Map<String, String> getOutputVariablesMap() { Map<String, String> map = new HashMap<>(); switch (workflowProcessesComboBox.getSelectionModel().getSelectedItem()) { case REVIEW3: map.put( Review3WorkflowProcessVariables.instructions.name(), instructionsTextArea.getText()); map.put( Review3WorkflowProcessVariables.edit_coordinate.name(), "default REVIEW3 edit coordinate"); map.put( Review3WorkflowProcessVariables.edit_coordinate_promotion.name(), promotionPathCoordinateLabel.getText()); map.put(Review3WorkflowProcessVariables.skip_to_review.name(), Boolean.toString(false)); break; case DUAL_REVIEW: map.put( DualReviewWorkflowProcessVariables.instructions.name(), instructionsTextArea.getText()); map.put( DualReviewWorkflowProcessVariables.edit_coordinate_1.name(), "default DUAL_REVIEW edit coordinate 1"); map.put( DualReviewWorkflowProcessVariables.edit_coordinate_2.name(), "default DUAL_REVIEW edit coordinate 2"); map.put( DualReviewWorkflowProcessVariables.edit_coordinate_promotion.name(), promotionPathCoordinateLabel.getText()); map.put( DualReviewWorkflowProcessVariables.edit_coordinate_adjudicator.name(), "default DUAL_REVIEW adjudicator coordinate"); map.put(DualReviewWorkflowProcessVariables.skip_to_review.name(), Boolean.toString(false)); break; default: return null; } return map; }
/** ButtonMethod for updating data into the recipes */ public void SubmitButtonAction() { String values = ""; String columns = "Name, Type, Cuisine, Difficulty, Diet, Time, Description"; String[] fields = { recipeName.getText(), recipeType.getText(), recipeCuisine.getText(), recipeDifficulty.getText(), recipeDiet.getText(), recipeTime.getText(), recipeDescription.getText() }; // Array with Values for (String value : fields) values += "'" + value + "',"; values = values.substring(0, values.length() - 1); try { System.out.println("- SubmitButtonAction"); insertInto("Recipes", columns, values); // Update data in columns with values System.out.println("- End of SubmitButtonAction"); recipeID = fetchData("recipes", "ID", "Name='" + recipeName.getText() + "'").get(0).get(0); for (Object o : addedIngredientTable.getItems()) { // Foreach object in the list, getItems String iName = Name.getCellData(o).toString(); // iName = ingredientName String iAmount = Amount.getCellData(o).toString(); // iAmount = ingredientAmount String iUnit = Unit.getCellData(o).toString(); // iUnit = ingredientUnit System.out.println("TESTING" + iName); String currentId = fetchData("Ingredients", "ID", "Name='" + iName + "'") .toString(); // Fetches id where name currentId = currentId.replaceAll("\\[", "").replaceAll("\\]", ""); // is column-name System.out.println("RECIPE ID" + recipeID); System.out.println("Current ID" + currentId); insertInto( "RUI", "RID, IID, Quantity, Unit", "'" + recipeID + "','" + currentId + "','" + iAmount + "','" + iUnit + "'"); // Inserts recipe id, current id, } // amount, and unit } catch (SQLException e) { e.printStackTrace(); } Recipe.setSelectedByID(recipeID); VistaNavigator.loadVista(VistaNavigator.RECIPE); }
// Private helper method to test validity of data required for save private boolean isDataRequiredForInitiateOk() { WorkflowProcess selectedProcess = null; if (workflowProcessesComboBox != null) { selectedProcess = workflowProcessesComboBox.getSelectionModel().getSelectedItem(); } else { return false; } String instructions = null; if (instructionsTextArea != null) { instructions = instructionsTextArea.getText(); } if (selectedProcess != null && instructions != null && instructions.length() > 0) { return true; } else { return false; } }
@FXML private void handlerEnviar() { if (combo.getValue() != "Sucursal") { SistemaEncomienda.getInstance() .enviarMensaje( SistemaEncomienda.getInstance().compararSucursal(combo.getValue().toString()), SistemaEncomienda.getInstance() .devolverMensaje( mensaje.getText(), SistemaEncomienda.getInstance().compararSucursal(combo.getValue().toString()), SistemaEncomienda.getInstance() .compararSucursal(SistemaEncomienda.getInstance().getSucursalActual()), asunto.getText())); mainApp.mostrarMenuComo(SistemaEncomienda.getInstance().getSucursalActual()); mainApp.mostrarMessage("Haz enviado un mensaje"); } else { mainApp.mostrarMessage("Elige una sucursal"); } }
public boolean validate() { String nameStr = nameInput.getText(); if (nameStr == null || "".equals(nameStr.trim())) { nameInput.requestFocus(); return false; } String tagStr = tagInput.getText(); if (tagStr != null && !"".equals(tagStr.trim())) { String[] tags = tagStr.split(","); for (String t : tags) { if (XmlUtil.all_data_tag.equals(t)) { AlertUtil.alertError(this.currentStage, "加个全部干啥`````"); tagInput.requestFocus(); return false; } } } return true; }
@FXML private void btn_sendOnAction() throws IOException { boolean mailSuccess = false; String errorMessage = ""; try { Mailer.send( tf_login.getText(), pf_password.getText(), tf_emailFrom.getText(), tf_emailTo.getText(), tf_subject.getText(), ta_message.getText()); mailSuccess = true; } catch (MessagingException e) { errorMessage = e.getMessage(); } new SendingMailStage(mailSuccess, errorMessage); }
/** Checks if the name is inserted and changes the StringProperties of the JournalEntry object. */ @FXML private void ok() { try { String idString = id.getText(); if (idString == null || idString.isEmpty()) { BetonQuestEditor.showError("name-not-null"); return; } data.getId().set(idString.trim()); String entryText = text.getText(); if (entryText != null && !entryText.isEmpty()) { entry.set(entryText); } else { entry.set(new String()); } BetonQuestEditor.getInstance().refresh(); result = true; stage.close(); } catch (Exception e) { ExceptionController.display(e); } }
@FXML public void InsertUser() throws SQLException { int selectedOption = JOptionPane.showConfirmDialog( null, "هل انت متاكد من هذة العملية ؟", "Choose", JOptionPane.YES_NO_OPTION); if (selectedOption == JOptionPane.YES_OPTION) { boolean value1 = CB1.isSelected(); boolean value2 = CB2.isSelected(); DB.rs = DB.statemen.executeQuery( "SELECT * FROM users WHERE user_name ='" + User_name.getText() + "'"); if (User_name.getText().equals("")) { Erromassage.setText("من فضلك ادخل البياناتالمطلوبة"); User_name.requestFocus(); } else if (DB.rs.next()) { Erromassage.setText("هذا الاسم موجود مسبقا"); User_name.requestFocus(); } else { DB.statemen.executeUpdate( "INSERT INTO users( user_name, pass, note, permission1, permission2) VALUES ('" + User_name.getText() + "','" + pass.getText() + "','" + note.getText() + "','" + value1 + "','" + value2 + "')"); FillTable(); clear(); } } }
@FXML public void registrarArticulo(ActionEvent e) { Articulo art = new Articulo(); cruds = new CRUDArticulos(); boolean registrado; int indiceCategoria = cmbCategorias.getSelectionModel().getSelectedIndex() + 1; art.setNombre(tfNombreArticulo.getText()); art.setMarca(tfMarca.getText()); art.setDescripcion_estado(txaDescripcion.getText()); art.setEstado(true); RadioButton chk = (RadioButton) acceso.getSelectedToggle(); if (chk.getText().equals("Prestable")) art.setAcceso(true); else art.setAcceso(false); art.setIdcategoria(indiceCategoria); registrado = cruds.registrarArticulo(art); System.out.println(art.getIdcategoria() + "" + art.isAcceso()); if (registrado) JOptionPane.showMessageDialog(null, "algo salio mal menor"); else JOptionPane.showMessageDialog(null, "se ha registrado con exito menor"); }
public void save(File f) { Properties save = new Properties(); OutputStream output = null; try { save.setProperty("provider", selectProviderCb.getValue()); save.setProperty("grain", selectGrainCb.getValue()); save.setProperty("weight", weightTf.getText()); save.setProperty("info", infoTa.getText()); for (Entry<String, TextField> entry : propertiesTf.entrySet()) { TextField tf = entry.getValue(); String propertyName = entry.getKey(); save.setProperty(propertyName, tf.getText()); if (tf.isDisable()) { save.setProperty(propertyName + "_ENABLED", "OFF"); } else { save.setProperty(propertyName + "_ENABLED", "ON"); } } output = new FileOutputStream(f); save.store(output, null); mainStage.setTitle(f.getName()); } catch (Exception ex) { infoTa.setText("Не могу сохранить в файл"); } finally { if (output != null) { try { output.close(); } catch (IOException e) { e.printStackTrace(); } } } }
@FXML public void UpdataUser() throws SQLException { int selectedOption = JOptionPane.showConfirmDialog( null, "هل انت متاكد من هذة العملية ؟", "Choose", JOptionPane.YES_NO_OPTION); if (selectedOption == JOptionPane.YES_OPTION) { TuserPermission InsertData = (TuserPermission) tableUser.getSelectionModel().getSelectedItem(); boolean value1 = CB1.isSelected(); boolean value2 = CB2.isSelected(); Erromassage.setText(""); System.out.println(selected); if (User_name.getText().equals("")) { Erromassage.setText("من فضلك ادخل البياناتالمطلوبة"); User_name.requestFocus(); } else { DB.statemen.executeUpdate( "UPDATE users SET user_name='" + User_name.getText() + "',pass='******',note='" + note.getText() + "',permission1='" + value1 + "',permission2='" + value2 + "' WHERE id = " + selected + ""); FillTable(); clear(); } } }
@FXML public void decipherButtonClick(ActionEvent event) { deOpenLabel.setText(""); enSaveLabel.setText(""); switch (choiceBox.getSelectionModel().getSelectedItem()) { case "Simple ASCII Cipher": textArea.setText(CipherMaker.decipherSimple(textArea.getText())); break; case "Cesar Chiper": textArea.setText(CipherMaker.decipherCesar(textArea.getText())); break; case "Vigenere": if (!textArea.getText().equals("")) { TextInputDialog dialog = new TextInputDialog(); dialog.setTitle("Cipher-Code"); dialog.setHeaderText("Type in a Password to decipher your text with!"); dialog.setContentText("Enter your password here..."); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { textArea.setText(CipherMaker.decipherVigenere(textArea.getText(), result.get())); } } break; case "RC4": if (!textArea.getText().equals("")) { TextInputDialog dialog = new TextInputDialog(); dialog.setTitle("Cipher-Code"); dialog.setHeaderText("Type in the number to decipher!"); dialog.setContentText("Enter your number here..."); Optional<String> result = dialog.showAndWait(); if (result.isPresent() && result.get().matches("[0-9]+")) { textArea.setText( CipherMaker.decipherRC4(textArea.getText(), Integer.parseInt(result.get()))); } else { deOpenLabel.setText("Decipher not possible..."); } } break; } }
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(); } }
/** * sets the current Task's comment text field * * @param event */ @FXML private void comment(ActionEvent event) { shl.getCurrentTab().setComment(comment.getText()); lstView.notify(); }
@FXML protected void handleCongratulationTextChanged(KeyEvent event) { details.congratulationText = congratulationText.getText(); }