Ejemplo n.º 1
0
  private void showAddNewComment() {
    newCommentLayout.clear();
    final TextArea comment = new TextArea();
    comment.setWidth("100%");
    newCommentLayout.add(comment);

    Button ok = new Button(constants.OK());
    Button cancel = new Button(constants.Cancel());

    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            sendNewComment(comment.getText());
          }
        });

    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            showNewCommentButton();
          }
        });

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(ok);
    hp.add(cancel);

    newCommentLayout.add(hp);

    comment.setFocus(true);
  }
Ejemplo n.º 2
0
  /** Create the tag frame. */
  TextFrame(int x, int y, String title, String text) {
    setTitle(title);
    TextArea txt = new TextArea(20, 60);
    txt.setText(text);
    txt.setEditable(false);

    add("Center", txt);

    Panel p = new Panel();
    add("South", p);
    Button b = new Button(amh.getMessage("button.dismiss", "Dismiss"));
    p.add(b);

    class ActionEventListener implements ActionListener {
      public void actionPerformed(ActionEvent evt) {
        dispose();
      }
    }
    b.addActionListener(new ActionEventListener());

    pack();
    move(x, y);
    setVisible(true);

    WindowListener windowEventListener =
        new WindowAdapter() {

          public void windowClosing(WindowEvent evt) {
            dispose();
          }
        };

    addWindowListener(windowEventListener);
  }
Ejemplo n.º 3
0
 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();
   }
 }
Ejemplo n.º 4
0
  public MainScreenView(final MainScreenController controller) {
    // Setup Job  List:
    listView_jobs.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    // Setup output area:
    textArea_output.setEditable(false);
    textArea_output.setFocusTraversable(false);

    // Set Component Tooltips:
    button_createJob.setTooltip(new Tooltip("Open the Job creation dialog to create a new Job."));
    button_deleteSelectedJobs.setTooltip(
        new Tooltip("Removes all Jobs that are currently selected on the list."));
    button_deleteAllJobs.setTooltip(new Tooltip("Clears the list of all Jobs."));
    button_clearOutput.setTooltip(new Tooltip("Clears the output screen."));
    button_editSettings.setTooltip(new Tooltip("Open the settings menu."));
    button_encode.setTooltip(new Tooltip("Encodes the selected handler(s)."));
    button_decode.setTooltip(
        new Tooltip(
            "Decodes the selected handler(s).\n\n"
                + "No checking is done to see if the files have ever been encoded,\n"
                + "so it's up to you to ensure you're decoding the correct files."));

    // Set Component EventHandlers:
    button_createJob.setOnAction(controller);
    button_encode.setOnAction(controller);
    button_decode.setOnAction(controller);
    button_deleteSelectedJobs.setOnAction(controller);
    button_deleteAllJobs.setOnAction(controller);
    button_clearOutput.setOnAction(controller);
    button_editSettings.setOnAction(controller);

    // Setup the Layout:
    final HBox panel_left_top = new HBox(10);
    panel_left_top.setAlignment(Pos.CENTER);
    panel_left_top
        .getChildren()
        .addAll(button_createJob, button_deleteSelectedJobs, button_deleteAllJobs);

    final HBox panel_left_bottom = new HBox(10);
    panel_left_bottom.setAlignment(Pos.CENTER);
    panel_left_bottom.getChildren().addAll(button_encode, button_decode);

    final VBox panel_left = new VBox(4);
    HBox.setHgrow(panel_left, Priority.ALWAYS);
    VBox.setVgrow(listView_jobs, Priority.ALWAYS);
    panel_left.getChildren().addAll(panel_left_top, listView_jobs, panel_left_bottom);

    final BorderPane panel_right_bottom = new BorderPane();
    panel_right_bottom.setLeft(button_clearOutput);
    panel_right_bottom.setRight(button_editSettings);

    final VBox panel_right = new VBox(4);
    HBox.setHgrow(panel_right, Priority.ALWAYS);
    VBox.setVgrow(textArea_output, Priority.ALWAYS);
    panel_right.getChildren().addAll(textArea_output, panel_right_bottom);

    this.setSpacing(4);
    this.getChildren().addAll(panel_left, panel_right);
  }
Ejemplo n.º 5
0
 private void storeSimpleFieldValues(NonHumanResource resource) {
   String name = (String) txtName.getText();
   if ((name != null) && (name.length() > 0)) resource.setName(name);
   String desc = (String) txtDesc.getText();
   if (desc != null) resource.setDescription(desc);
   String notes = (String) txtNotes.getText();
   if (notes != null) resource.setNotes(notes);
 }
Ejemplo n.º 6
0
  @Test
  public void updateViewTest() {
    MockPlugin mock = new MockPlugin();
    TextArea txtArea = new TextArea();
    txtArea.updateView(mock);

    assertEquals(mock.transform("SOME TEXT"), txtArea.getText());
  }
Ejemplo n.º 7
0
 // {{{ dragEnter() method
 @SuppressWarnings("deprecation")
 @Override
 public void dragEnter(DropTargetDragEvent dtde) {
   Log.log(Log.DEBUG, this, "Drag enter");
   savedBuffer = textArea.getBuffer();
   textArea.setDragInProgress(true);
   // textArea.getBuffer().beginCompoundEdit();
   savedCaret = textArea.getCaretPosition();
 } // }}}
Ejemplo n.º 8
0
 protected void disableInputFields(boolean disable) {
   txtName.setDisabled(disable);
   txtDesc.setDisabled(disable);
   txtNotes.setDisabled(disable);
   cbbMembers.setDisabled(disable);
   cbbCategory.setDisabled(disable);
   cbbSubCategory.setDisabled(disable);
   btnAddSubCat.setDisabled(disable);
   btnRemoveSubCat.setDisabled(disable || subCatUnremovable());
 }
Ejemplo n.º 9
0
  public CustomerFormPanel(String id, CompoundPropertyModel<CustomerAdminBackingBean> model) {
    super(id, model);

    GreySquaredRoundedBorder greyBorder = new GreySquaredRoundedBorder("border");
    add(greyBorder);

    setOutputMarkupId(true);

    final Form<CustomerAdminBackingBean> form =
        new Form<CustomerAdminBackingBean>("customerForm", model);

    // name
    RequiredTextField<String> nameField = new RequiredTextField<String>("customer.name");
    form.add(nameField);

    nameField.add(StringValidator.lengthBetween(0, 64));
    nameField.setLabel(new ResourceModel("admin.customer.name"));
    nameField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new AjaxFormComponentFeedbackIndicator("nameValidationError", nameField));

    // code
    final RequiredTextField<String> codeField = new RequiredTextField<String>("customer.code");
    form.add(codeField);
    codeField.add(StringValidator.lengthBetween(0, 16));
    codeField.setLabel(new ResourceModel("admin.customer.code"));
    codeField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new UniqueCustomerValidator(nameField, codeField));
    form.add(new AjaxFormComponentFeedbackIndicator("codeValidationError", codeField));

    // description
    TextArea<String> textArea = new KeepAliveTextArea("customer.description");
    textArea.setLabel(new ResourceModel("admin.customer.description"));
    form.add(textArea);

    // active
    form.add(new CheckBox("customer.active"));

    // data save label
    form.add(new ServerMessageLabel("serverMessage", "formValidationError"));

    //

    boolean deletable = model.getObject().getCustomer().isDeletable();
    FormConfig formConfig =
        new FormConfig()
            .forForm(form)
            .withDelete(deletable)
            .withSubmitTarget(this)
            .withDeleteEventType(CustomerAjaxEventType.CUSTOMER_DELETED)
            .withSubmitEventType(CustomerAjaxEventType.CUSTOMER_UPDATED);

    FormUtil.setSubmitActions(formConfig);

    greyBorder.add(form);
  }
Ejemplo n.º 10
0
 // {{{ dragExit() method
 @SuppressWarnings("deprecation")
 @Override
 public void dragExit(DropTargetEvent dtde) {
   Log.log(Log.DEBUG, this, "Drag exit");
   textArea.setDragInProgress(false);
   // textArea.getBuffer().endCompoundEdit();
   if (textArea.getBuffer() == savedBuffer) {
     textArea.moveCaretPosition(savedCaret, TextArea.ELECTRIC_SCROLL);
   }
   savedBuffer = null;
 } // }}}
Ejemplo n.º 11
0
  public void addReason(String reason_, List form, int errorFlag) throws WingException {
    TextArea reason = form.addItem("reason", null).addTextArea("reason");
    reason.setLabel(T_reason);
    reason.setHelp(T_reason_help);

    if (!isAdvancedFormEnabled) {
      if (globalReason != null) reason.setValue(globalReason);
    } else {
      if (reason_ != null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE)
        reason.setValue(reason_);
    }
  }
Ejemplo n.º 12
0
 // {{{ dragOver() method
 @Override
 public void dragOver(DropTargetDragEvent dtde) {
   Point p = dtde.getLocation();
   p = SwingUtilities.convertPoint(textArea, p, textArea.getPainter());
   int pos =
       textArea.xyToOffset(
           p.x,
           p.y,
           !(textArea.getPainter().isBlockCaretEnabled() || textArea.isOverwriteEnabled()));
   if (pos != -1) {
     textArea.moveCaretPosition(pos, TextArea.ELECTRIC_SCROLL);
   }
 } // }}}
Ejemplo n.º 13
0
    BuilderDrawer() {
      if (drawerResource != null) {
        Embedded drawerBkg = new Embedded(null, drawerResource);
        addComponent(drawerBkg, "top:0px;left:0px");
      }
      content = new TextArea();
      // only shows if no focus, and if we don't have focus, it's not normally showing
      // content.setInputPrompt("Type here to add to this card chain.");
      content.setWordwrap(true);
      content.setImmediate(true);
      content.setTextChangeEventMode(TextChangeEventMode.LAZY);
      content.setTextChangeTimeout(500);
      // cause exception w/ 2 windows?
      // content.setDebugId(CardTypeManager.getCardContentDebugId(ct));
      content.setId(
          CardDebug.getCardContentDebugId(ct)); // CardTypeManager.getCardContentDebugId(ct));

      content.addTextChangeListener(new characterTypedHandler());

      content.setWidth(CARDLISTHEADER_DRAWER_TEXT_W);
      content.setHeight(CARDLISTHEADER_DRAWER_TEXT_H);
      content.addStyleName("m-white-background");
      addComponent(content, CARDLISTHEADER_DRAWER_TEXT_POS);

      count = new Label("0/140");
      count.setWidth(CARDLISTHEADER_DRAWER_COUNT_W);
      count.setHeight(CARDLISTHEADER_DRAWER_COUNT_H);
      count.addStyleName("m-cardbuilder-count-text");
      addComponent(count, CARDLISTHEADER_DRAWER_COUNT_POS);

      cancelButt = new NativeButton("cancel");
      cancelButt.setWidth(CARDLISTHEADER_DRAWER_CANCEL_W);
      cancelButt.setHeight(CARDLISTHEADER_DRAWER_CANCEL_H);
      cancelButt.addStyleName("borderless");
      cancelButt.addStyleName("m-cardbuilder-button-text");
      cancelButt.addClickListener(new CancelHandler());
      addComponent(cancelButt, CARDLISTHEADER_DRAWER_CANCEL_POS);

      submitButt = new NativeButton("submit");
      // cause exception w/ 2 windows?
      // submitButt.setDebugId(CardTypeManager.getCardSubmitDebugId(ct));
      submitButt.setId(
          CardDebug.getCardSubmitDebugId(ct)); // CardTypeManager.getCardSubmitDebugId(ct));

      submitButt.setWidth(CARDLISTHEADER_DRAWER_OKBUTT_W);
      submitButt.setHeight(CARDLISTHEADER_DRAWER_OKBUTT_H);
      submitButt.addStyleName("borderless");
      submitButt.addStyleName("m-cardbuilder-button-text");
      submitButt.addClickListener(new CardPlayHandler());
      addComponent(submitButt, CARDLISTHEADER_DRAWER_OKBUTT_POS);

      setWidth(CARDLISTHEADER_DRAWER_W);
      setHeight(CARDLISTHEADER_DRAWER_H);
    }
Ejemplo n.º 14
0
  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);
  }
Ejemplo n.º 15
0
 @UiHandler("runButton")
 void runSQLCode(ClickEvent event) {
   resultStatusTextBox.setVisible(false);
   presenter.runSQLCode(codeEditor.getValue());
   loadingBar.setVisible(true);
   quickCodeResult.setVisible(false);
 }
Ejemplo n.º 16
0
 private void onSelect(SetStroke stroke) {
   if (stroke != null) {
     name.setText(stroke.getName());
     abbr.setText(stroke.getAbbr());
     notes.setText(stroke.getNotes());
   }
 }
Ejemplo n.º 17
0
 public void init() {
   urlTextField = new TextField();
   urlTextField.setWidth("150px");
   phoneNoField = new TextField();
   phoneNoField.setWidth("150px");
   messageField = new TextArea();
   messageField.setWidth("150px");
 }
Ejemplo n.º 18
0
 // {{{ drop() method
 @SuppressWarnings("deprecation")
 @Override
 public void drop(DropTargetDropEvent dtde) {
   Log.log(Log.DEBUG, this, "Drop");
   textArea.setDragInProgress(false);
   // textArea.getBuffer().endCompoundEdit();
   savedBuffer = null;
 } // }}}
  /*
   public PIMBrowser getPimToDo() {
      if (pimToDo == null) {
          // write pre-init user code here
          pimToDo = new PIMBrowser(getDisplay(), PIM.TODO_LIST);
          pimToDo.setTitle("To Do List");
          pimToDo.addCommand(PIMBrowser.SELECT_PIM_ITEM);
          pimToDo.addCommand(getBackCommand5());
          pimToDo.setCommandListener(this);
          // write post-init user code here
      }
      return pimToDo;
  }
  */
  public Form fullgetToDoList() {
    Form f = new Form("To Do List");
    if (frmToDoList == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      toDoList = new List();
      pim = PIM.getInstance();
      f.addComponent(toDoList);

      final TextArea searchField = TextField.create();
      f.addComponent(searchField);

      Button searchButton = new Button("Search");
      searchButton.setPreferredW(f.getWidth() / 2 - 5);
      searchButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              populateToDoList(searchField.getText());
            }
          });
      Button clearButton = new Button("Clear");
      clearButton.setPreferredW(f.getWidth() / 2 - 5);
      clearButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              searchField.setText("");
              populateToDoList("");
            }
          });
      Container buttonContainer = new Container();
      buttonContainer.setLayout(new BorderLayout());
      buttonContainer.addComponent(BorderLayout.WEST, searchButton);
      buttonContainer.addComponent(BorderLayout.EAST, clearButton);
      f.addComponent(buttonContainer);

      populateToDoList(searchField.getText());

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
Ejemplo n.º 20
0
 public MainScreen() {
   Label loginLabel =
       new Label("Welcome " + VaadinSession.getCurrent().getAttribute(String.class));
   HorizontalLayout menuBar = new HorizontalLayout(loginLabel);
   MessageTable table = new MessageTable();
   TextArea messageArea = new TextArea();
   messageArea.setWidth(100, PERCENTAGE);
   Button sendButton = new Button("Send");
   sendButton.addClickListener(new SendMessageClickListener(table, messageArea));
   HorizontalLayout lowerBar = new HorizontalLayout(messageArea, sendButton);
   lowerBar.setWidth(100, PERCENTAGE);
   lowerBar.setSpacing(true);
   VerticalLayout mainLayout = new VerticalLayout(menuBar, table, lowerBar);
   mainLayout.setSpacing(true);
   mainLayout.setMargin(true);
   mainLayout.setSizeFull();
   setCompositionRoot(mainLayout);
 }
Ejemplo n.º 21
0
  private void onSendMessage(String inputText, Dispute dispute) {
    DisputeDirectMessage disputeDirectMessage =
        disputeManager.sendDisputeDirectMessage(
            dispute, inputText, new ArrayList<>(tempAttachments));
    tempAttachments.clear();
    scrollToBottom();

    inputTextArea.setDisable(true);
    inputTextArea.clear();

    final Timer timer =
        FxTimer.runLater(
            Duration.ofMillis(500),
            () -> {
              sendMsgInfoLabel.setVisible(true);
              sendMsgInfoLabel.setManaged(true);
              sendMsgInfoLabel.setText("Sending Message...");

              sendMsgProgressIndicator.setProgress(-1);
              sendMsgProgressIndicator.setVisible(true);
              sendMsgProgressIndicator.setManaged(true);
            });

    disputeDirectMessage
        .arrivedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue) {
                hideSendMsgInfo(timer);
              }
            });
    disputeDirectMessage
        .storedInMailboxProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue) {
                sendMsgInfoLabel.setVisible(true);
                sendMsgInfoLabel.setManaged(true);
                sendMsgInfoLabel.setText(
                    "Receiver is not online. Message is saved to his mailbox.");
                hideSendMsgInfo(timer);
              }
            });
  }
Ejemplo n.º 22
0
  private void renderRejectPage(Division div) throws WingException {
    Request request = ObjectModelHelper.getRequest(objectModel);

    List form = div.addList("reject-workflow", List.TYPE_FORM);

    form.addItem(T_info2);

    TextArea reason = form.addItem().addTextArea("reason");
    reason.setLabel(T_reason);
    reason.setRequired();
    reason.setSize(15, 50);

    if (Action.getErrorFields(request).contains("reason")) reason.addError(T_reason_required);

    div.addHidden("page").setValue(ReviewAction.REJECT_PAGE);

    org.dspace.app.xmlui.wing.element.Item actions = form.addItem();
    actions.addButton("submit_reject").setValue(T_submit_reject);
    actions.addButton("submit_cancel").setValue(T_submit_cancel);
  }
Ejemplo n.º 23
0
  public void open(File f) {
    Properties open = new Properties();
    InputStream input = null;

    try {
      input = new FileInputStream(f);
      open.load(input);

      selectProviderCb.setValue(open.getProperty("provider"));
      selectGrainCb.setValue(open.getProperty("grain"));
      weightTf.setText(open.getProperty("weight"));
      infoTa.setText(open.getProperty("info"));

      for (Entry<String, TextField> entry : propertiesTf.entrySet()) {
        String propertyName = entry.getKey();
        TextField tf = entry.getValue();
        CheckBox cb = propertiesCb.get(propertyName);

        tf.setText(open.getProperty(propertyName));
        if (open.getProperty(propertyName + "_ENABLED").equals("ON")) {
          tf.setDisable(false);
          cb.setSelected(true);
        } else {
          tf.setDisable(true);
          cb.setSelected(false);
        }
      }

      mainStage.setTitle(f.getName());
    } catch (Exception ex) {
      infoTa.setText("Не могу открыть файл");
    } finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("CoAP Explorer");
    Group root = new Group();
    Scene scene = new Scene(root, 800, 600);

    TextArea hexArea = new TextArea();
    TextArea binArea = new TextArea();

    CoapPacket packet = new CoapPacket();
    packet.setPayload("PAYLOAD");
    packetProp.setValue(packet);

    binArea.textProperty().bindBidirectional(packetProp, new AsciiConverter());

    hexArea.textProperty().bindBidirectional(packetProp, new HexConverter());
    hexArea.setEditable(false);
    hexArea.setFont(javafx.scene.text.Font.font(Font.MONOSPACED));

    VBox vbox = new VBox();
    vbox.setPadding(new Insets(10));
    vbox.setSpacing(8);

    VBox.setMargin(hexArea, new Insets(0, 0, 0, 8));
    vbox.getChildren().add(hexArea);
    VBox.setMargin(binArea, new Insets(0, 0, 0, 8));
    vbox.getChildren().add(binArea);

    root.getChildren().add(vbox);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
  @FXML
  public void compute() {
    double[][] transformedTrajectory = getTransformedTrajectory();
    if (transformedTrajectory == null) return;

    // compute and display RP
    BufferedImage rp =
        DRQA.getRPImage(
            transformedTrajectory, transformedTrajectory, recurrenceThresholdSlider.getValue());
    rpImageView.setImage(SwingFXUtils.toFXImage(rp, null));
    applyImageScale();

    // compute and display CRT
    DRQA.conditional_ww_limit = Integer.parseInt(crtLimit.getText());
    DRQA.CRT_LOG_SCALE = logScaleCheckBox.isSelected();
    drqa =
        new DRQA(
            transformedTrajectory, transformedTrajectory, recurrenceThresholdSlider.getValue());
    BufferedImage crt = drqa.getCRTImage(DRQA.conditional_ww_limit, drqa.conditional_ww);
    crtImageView.setImage(SwingFXUtils.toFXImage(crt, null));
    String[] stats = drqa.crtStatistics().split("\t");
    crtStats.setText(
        String.format(
            "mean row: %.2f\tmean col: %.2f\ncorrelation: %.2f\nmax row: %s\tmax col: %s\nlocal maxima: %s\nentropy: %.2f",
            Double.parseDouble(stats[0]),
            Double.parseDouble(stats[1]),
            Double.parseDouble(stats[2]),
            stats[3],
            stats[4],
            stats[5],
            Double.parseDouble(stats[6])));

    drqa.computeRQA(2, 2, 2);
    rqaMeasures.setText(drqa.printableString(DRQA.STANDARD_RQA));

    updateTimeSeriesChart();
    updateDistanceDistributionChart();
    updateLineLengthHistogram(
        null, null, lineLengthTypeSelector.getSelectionModel().getSelectedIndex());
  }
Ejemplo n.º 26
0
  /** 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);
  }
Ejemplo n.º 27
0
  private void hideSendMsgInfo(Timer timer) {
    timer.stop();
    inputTextArea.setDisable(false);

    FxTimer.runLater(
        Duration.ofMillis(5000),
        () -> {
          sendMsgInfoLabel.setVisible(false);
          sendMsgInfoLabel.setManaged(false);
        });
    sendMsgProgressIndicator.setProgress(0);
    sendMsgProgressIndicator.setVisible(false);
    sendMsgProgressIndicator.setManaged(false);
  }
Ejemplo n.º 28
0
  /* saves a newly added resource to the org database */
  public boolean addResource(String name) {
    if (!_orgDataSet.isKnownNonHumanResourceName(name)) {
      String catID = (String) cbbCategory.getSelected();
      NonHumanCategory category = _orgDataSet.getNonHumanCategory(catID);
      String subCat = (String) cbbSubCategory.getSelected();

      NonHumanResource resource = _sb.getSelectedNonHumanResource();
      if (resource == null) resource = new NonHumanResource();
      resource.setName(name);
      resource.setCategory(category);
      resource.setSubCategory(subCat);
      resource.setDescription((String) txtDesc.getText());
      resource.setNotes((String) txtNotes.getText());
      String newID = _orgDataSet.addNonHumanResource(resource);
      if (_rm.successful(newID)) {
        updateSelectedResource(resource, false);
        _sb.setNhResourcesChoice(newID);
        return true;
      } else _msgPanel.error(_msgPanel.format(newID));
    } else addDuplicationError("Resource");

    return false;
  }
Ejemplo n.º 29
0
  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();
        }
      }
    }
  }
Ejemplo n.º 30
0
  public void newFile() {
    infoTa.setText("");
    selectProviderCb.setValue(providers.get(0).getName());
    weightTf.setText("0.0");

    for (Entry<String, TextField> entry : propertiesTf.entrySet()) {
      String propertyName = entry.getKey();
      TextField tf = entry.getValue();
      CheckBox cb = propertiesCb.get(propertyName);

      tf.setText("0.0");
      tf.setDisable(true);
      cb.setSelected(false);
    }

    file = null;
    mainStage.setTitle("unknown");
  }