Example #1
2
  public static void message(String msg, StackPane pane) {

    Label warningL = new Label(msg);
    Labels.setLabelStyle(warningL, Custom.TEXT_SIZE_LARGER, true);
    warningL.setTextAlignment(TextAlignment.CENTER);

    StackPane warningPane = new StackPane();
    warningPane.getChildren().add(warningL);
    warningPane.setStyle(Custom.WINDOW_STYLING);
    warningPane.setMinWidth(Custom.SCREEN_WIDTH * 95 / 100);
    warningPane.setMaxWidth(Custom.SCREEN_WIDTH * 95 / 100);
    warningPane.setMinHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    warningPane.setMaxHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    warningPane.setBorder(
        new Border(
            new BorderStroke(
                Paint.valueOf("#000000"),
                BorderStrokeStyle.SOLID,
                new CornerRadii(30),
                new BorderWidths(5))));

    pane.getChildren().add(warningPane);

    PauseTransition pause = new PauseTransition(Duration.millis(1500));
    pause.setOnFinished(
        (f) -> {
          pane.getChildren().remove(warningPane);
          goBack();
        });
    pause.play();
  }
Example #2
1
  private static void layoutizeLabelCreator(
      ICreatorCustomLabel myLabel, double r, double g, double b) {
    Color color = Color.color(r, g, b);
    ((Label) myLabel)
        .setBackground(
            new Background(new BackgroundFill(color, new CornerRadii(3), new Insets(0))));
    ((Label) myLabel).setStyle("-fx-border-color: white;");
    ((Label) myLabel).setMinSize(400, 35);
    ((Label) myLabel).setTextAlignment(TextAlignment.CENTER);
    ((Label) myLabel).setFont(Font.font(20));
    ((Label) myLabel)
        .setOnDragDetected(
            new EventHandler<MouseEvent>() {
              @Override
              public void handle(MouseEvent event) {
                Dragboard db = ((Label) event.getSource()).startDragAndDrop(TransferMode.ANY);

                ClipboardContent content = new ClipboardContent();
                content.putString("clipboardString");
                db.setContent(content);

                event.consume();
              }
            });
    ((Label) myLabel).setVisible(true);
  }
 private void initTopBar() {
   title.setId("title");
   title.setWrapText(true);
   toggleEarthMode.setId("button");
   title.setTextAlignment(TextAlignment.CENTER);
   toggleEarthMode.setTextAlignment(TextAlignment.CENTER);
   toggleEarthMode.setWrapText(true);
   topBar.setHgap(7);
   topBar.add(title, 15, 0);
   topBar.add(toggleEarthMode, 0, 0);
 }
Example #4
0
 @Override
 public void setupHelp() {
   Label helpText = new Label(help.get(Help.HelpKey.HOMEPAGE_HELP));
   helpText.setMaxWidth(300);
   helpText.setWrapText(true);
   helpText.setTextAlignment(TextAlignment.CENTER);
   setHelpPopupContent(helpText);
 }
  private static Label createLabel(String pText, String pColor) {
    Label label = new Label(pText);
    label.setAlignment(Pos.CENTER);
    label.setTextAlignment(TextAlignment.CENTER);
    label.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    label.setStyle("-fx-background-color: #" + pColor + ";");

    return label;
  }
Example #6
0
 public static void layoutizeLabel(ICustomLabel myLabel, Color color) {
   ((Label) myLabel)
       .setBackground(
           new Background(new BackgroundFill(color, new CornerRadii(3), new Insets(0))));
   ((Label) myLabel).setBorder(Border.EMPTY);
   ((Label) myLabel).setStyle("-fx-border-color: white;");
   ((Label) myLabel).setMinSize(400, 35);
   ((Label) myLabel).setText(myLabel.getName());
   myLabel.setDescription(myLabel.getDescription());
   ((Label) myLabel).setTextAlignment(TextAlignment.CENTER);
   ((Label) myLabel).setFont(Font.font(20));
   ((Label) myLabel).setVisible(true);
 }
Example #7
0
  /** Creates a new Footer object */
  private Footer() {
    super();
    getStyleClass().add("footer");

    Separator separator = new Separator();

    splitPane = new SplitPane();
    splitPane.setId("footer-split-pane");

    fileExplorerBox = new HBox();
    fileExplorerStatus = new Label();
    fileExplorerStatus.setPadding(new Insets(5, 5, 5, 15));
    fileExplorerStatus.setAlignment(Pos.CENTER_LEFT);
    fileExplorerStatus.setTextAlignment(TextAlignment.CENTER);
    fileExplorerBox.getChildren().add(fileExplorerStatus);

    HBox otherBox = new HBox();
    classPlanStatus = new Label();
    classPlanStatus.setPadding(new Insets(5, 5, 5, 15));
    classPlanStatus.setAlignment(Pos.CENTER_LEFT);
    classPlanStatus.setTextAlignment(TextAlignment.CENTER);

    HBox space = new HBox();
    HBox.setHgrow(space, Priority.ALWAYS);

    memoryUsage = new Label();
    memoryUsage.setPadding(new Insets(5, 15, 5, 5));
    memoryUsage.setAlignment(Pos.CENTER_RIGHT);
    memoryUsage.setTextAlignment(TextAlignment.CENTER);

    otherBox.getChildren().addAll(classPlanStatus, space, memoryUsage);

    splitPane.getItems().addAll(fileExplorerBox, otherBox);
    this.getChildren().addAll(separator, splitPane);

    memoryAutoUpdater();
  }
    public FileGridCell() {
      Label titleLabel = new Label();
      titleLabel.setPrefWidth(80);
      titleLabel.setWrapText(true);
      titleLabel.setTextAlignment(TextAlignment.CENTER);
      title = titleLabel.textProperty();

      ImageView iconView = new ImageView();
      icon = iconView.imageProperty();

      VBox vbox = new VBox(iconView, titleLabel);
      vbox.setAlignment(Pos.TOP_CENTER);

      setGraphic(vbox);
    }
Example #9
0
  public static void displaySimple(String title, String message) {
    Stage window = new Stage();

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle(title);
    window.setWidth(450);
    window.setHeight(200);

    Label label = new Label();
    label.setWrapText(true);
    label.setText(message);
    label.setTextAlignment(TextAlignment.CENTER);
    Button closeButton = new Button("Close");
    closeButton.setOnAction(e -> window.close());

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, closeButton);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
Example #10
0
  public static boolean displayConfirmation() {

    Stage window = new Stage();

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Exit?");
    window.setWidth(300);
    window.setHeight(250);

    Label label = new Label();
    label.setWrapText(true);
    label.setText("Are you sure you want to quit?");
    label.setTextAlignment(TextAlignment.CENTER);
    label.setPadding(new Insets(20, 20, 20, 20));
    Button yesButton = new Button("Yes");
    yesButton.setOnAction(
        e -> {
          yesNo = true;
          window.close();
        });
    Button noButton = new Button("No");
    noButton.setOnAction(
        e -> {
          yesNo = false;
          window.close();
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, yesButton, noButton);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();

    return yesNo;
  }
  /**
   * Creates the tab for displaying creator properties. This tab is constructed using the {@code
   * createPropertyBox} and {@code createGroupPropertySection} methods found below.
   *
   * @param artifact The popup artifact
   * @return content or null if nothing for user to do
   */
  private VBox createCreatorTab(final PackageArtifact artifact) {
    final VBox propertiesBox = new VBox(12);
    propertiesBox.getStyleClass().add(PACKAGE_TOOL_POPUP_PROPERTY_TAB);

    Label requiredLabel = new Label(labels.get(Labels.LabelKey.REQUIRED_FIELDS_LABEL));
    requiredLabel.setMaxWidth(300);
    requiredLabel.setWrapText(true);
    requiredLabel.setTextAlignment(TextAlignment.CENTER);

    propertiesBox.getChildren().add(requiredLabel);

    final Map<String, String> properties = packageOntologyService.getProperties(artifact);

    List<String> sortedProperties = new ArrayList<>();

    // Get the creator property set and then create a sorted list from it.
    sortedProperties.addAll(packageOntologyService.getCreatorProperties(artifact));
    sortProperties(sortedProperties, artifact, "");

    // Loop through all the creator properties as defined in the ontology.
    for (final String property : sortedProperties) {
      final PackageDescriptionViewImpl.ArtifactPropertyContainer container =
          new PackageDescriptionViewImpl.ArtifactPropertyContainer();

      // If the property is complex use the group property creation, otherwise use the simple
      // property set up.
      if (packageOntologyService.isPropertyComplex(properties.get(property))) {
        container.isComplex = true;
        VBox complexPropertyBox =
            createGroupPropertySection(
                artifact, property, properties.get(property), false, container);
        propertiesBox.getChildren().add(complexPropertyBox);
        int maxOccurances =
            packageOntologyService.getPropertyMaxOccurrences(artifact, property, "");

        // If the ontology allows for more than one of the property add a button which will add more
        // groups when pressed.
        if (maxOccurances > 1) {
          final Button addNewButton =
              new Button(labels.get(Labels.LabelKey.ADD_NEW_BUTTON) + " " + property);
          addNewButton.setMaxWidth(addNewButtonMaxWidth);
          propertiesBox.getChildren().add(addNewButton);
          addNewButton.setDisable(true);

          final GroupPropertyChangeListener listener =
              new GroupPropertyChangeListener(addNewButton, container);

          for (Node n : propertiesBox.getChildren()) {
            if (n instanceof VBox) {
              addChangeListenerToSectionFields((VBox) n, listener);
            }
          }

          listener.changed(null, "n/a", "n/a");

          addNewButton.setOnAction(
              arg0 -> {
                VBox complexPropertyBox1 =
                    createGroupPropertySection(
                        artifact, property, properties.get(property), true, container);
                int buttonIndex = propertiesBox.getChildren().indexOf(addNewButton);

                propertiesBox.getChildren().add(buttonIndex, complexPropertyBox1);

                addChangeListenerToSectionFields(complexPropertyBox1, listener);
                addNewButton.setDisable(true);
                requestFocusForNewGroup(complexPropertyBox1);
              });
        }
      } else {
        // Otherwise create just the simple property
        int maxOccurances =
            packageOntologyService.getPropertyMaxOccurrences(artifact, property, "");
        int minOccurances =
            packageOntologyService.getPropertyMinOccurrences(artifact, property, "");
        boolean systemGenerated =
            packageOntologyService.isSystemSuppliedProperty(artifact, property);

        Set<StringProperty> fields = new HashSet<>();

        propertiesBox
            .getChildren()
            .add(
                new TextPropertyBox(
                    artifact,
                    "",
                    ontologyLabels.get(property),
                    property,
                    artifact.getSimplePropertyValues(property),
                    maxOccurances,
                    fields,
                    minOccurances,
                    systemGenerated,
                    packageOntologyService,
                    labels,
                    messages,
                    applyButtonValidationListener));
        container.values = fields;
      }

      artifactPropertyFields.put(property, container);
    }

    // Return null if nothing to edit.
    if (propertiesBox.getChildren().size() == 1) {
      return null;
    }

    return propertiesBox;
  }
  /*
   * Creates the general properties tab, general properties are any properties that aren't defined to be creator properties,
   * by the ontology.
   * @param artifact
   * @return the VBox for the general tab
   */
  private VBox createGeneralTab(final PackageArtifact artifact) {
    final VBox propertiesBox = new VBox(12);

    propertiesBox.getStyleClass().add(PACKAGE_TOOL_POPUP_PROPERTY_TAB);
    Set<String> creatorProperties = packageOntologyService.getCreatorProperties(artifact);
    final Map<String, String> properties = packageOntologyService.getProperties(artifact);

    Label requiredLabel = new Label(labels.get(Labels.LabelKey.REQUIRED_FIELDS_LABEL));
    requiredLabel.setMaxWidth(400);
    requiredLabel.setWrapText(true);
    requiredLabel.setTextAlignment(TextAlignment.CENTER);

    propertiesBox.getChildren().add(requiredLabel);
    List<String> sortedProperties = new ArrayList<>();

    // Get the property name key set and then create a sorted list from it.
    sortedProperties.addAll(properties.keySet());
    sortProperties(sortedProperties, artifact, "");

    // Loop through all the available properties
    for (final String property : sortedProperties) {
      // If the property isn't a creator property we include it in this tab
      if (!creatorProperties.contains(property)) {
        final PackageDescriptionViewImpl.ArtifactPropertyContainer container =
            new PackageDescriptionViewImpl.ArtifactPropertyContainer();

        // If the property is complex use the group property creation.
        if (packageOntologyService.isPropertyComplex(properties.get(property))) {
          container.isComplex = true;
          VBox complexPropertyBox =
              createGroupPropertySection(
                  artifact, property, properties.get(property), false, container);
          propertiesBox.getChildren().add(complexPropertyBox);
          int maxOccurrences =
              packageOntologyService.getPropertyMaxOccurrences(artifact, property, "");

          // If the property allows for more than one value include a button to add more fields.
          if (maxOccurrences > 1) {
            final Button addNewButton =
                new Button(
                    labels.get(Labels.LabelKey.ADD_NEW_BUTTON)
                        + " "
                        + ontologyLabels.get(property));
            addNewButton.setMaxWidth(addNewButtonMaxWidth);
            addNewButton.setDisable(true);
            propertiesBox.getChildren().add(addNewButton);

            final GroupPropertyChangeListener listener =
                new GroupPropertyChangeListener(addNewButton, container);

            for (Node n : propertiesBox.getChildren()) {
              if (n instanceof VBox) {
                addChangeListenerToSectionFields((VBox) n, listener);
              }
            }

            listener.changed(null, "n/a", "n/a");

            addNewButton.setOnAction(
                arg0 -> {
                  VBox complexPropertyBox1 =
                      createGroupPropertySection(
                          artifact, property, properties.get(property), true, container);
                  int buttonIndex = propertiesBox.getChildren().indexOf(addNewButton);

                  propertiesBox.getChildren().add(buttonIndex, complexPropertyBox1);

                  addChangeListenerToSectionFields(complexPropertyBox1, listener);
                  addNewButton.setDisable(true);
                  requestFocusForNewGroup(complexPropertyBox1);
                });
            Separator groupSeparator = new Separator();
            propertiesBox.getChildren().add(groupSeparator);
          }

        } else {
          // If it's a simple property use the create property box.
          int maxOccurances =
              packageOntologyService.getPropertyMaxOccurrences(artifact, property, "");
          int minOccurances =
              packageOntologyService.getPropertyMinOccurrences(artifact, property, "");
          boolean systemGenerated =
              packageOntologyService.isSystemSuppliedProperty(artifact, property);

          Set<StringProperty> fieldProperties = new HashSet<>();
          if (packageOntologyService.isDisciplineProperty(artifact, property)) {
            propertiesBox
                .getChildren()
                .add(
                    new DisciplinePropertyBox(
                        ontologyLabels.get(property),
                        artifact.getSimplePropertyValues(property),
                        maxOccurances,
                        fieldProperties,
                        minOccurances,
                        systemGenerated,
                        availableDisciplines));
          } else {
            propertiesBox
                .getChildren()
                .add(
                    new TextPropertyBox(
                        artifact,
                        "",
                        ontologyLabels.get(property),
                        property,
                        artifact.getSimplePropertyValues(property),
                        maxOccurances,
                        fieldProperties,
                        minOccurances,
                        systemGenerated,
                        packageOntologyService,
                        labels,
                        messages,
                        applyButtonValidationListener));
          }
          container.values = fieldProperties;
        }

        artifactPropertyFields.put(property, container);
      }
    }
    return propertiesBox;
  }
  @Override
  protected void updateItem(ShoppingItem item, boolean empty) {
    super.updateItem(item, empty);

    if (item != null) {
      if (empty) {
        setText(null);
        setGraphic(null);
      } else {
        setText(null);

        BorderPane pane = new BorderPane();
        pane.setPadding(new Insets(2, 5, 2, 5));
        TextField txtField = new TextField((int) item.getAmount() + "");
        txtField.setMaxWidth(40);
        txtField.setDisable(false);
        txtField.setEditable(true);
        pane.setLeft(txtField);

        Label name = new Label(item.getProduct().getName());
        BorderPane.setAlignment(name, Pos.CENTER_LEFT);
        BorderPane.setMargin(name, new Insets(0, 0, 0, 10));
        name.getStyleClass().add("produktnamn");
        pane.setCenter(name);

        GridPane priceAndDelete = new GridPane();
        double cost = item.getTotal();
        Label price = new Label(String.format("%.2f", cost) + " kr");
        price.setTextAlignment(TextAlignment.CENTER);
        GridPane.setMargin(price, new Insets(0, 10, 0, 0));
        priceAndDelete.add(price, 0, 0);

        Button delete = new Button("X");
        priceAndDelete.add(delete, 1, 0);

        pane.setRight(priceAndDelete);
        setGraphic(pane);

        delete.setOnMouseClicked(
            new EventHandler<MouseEvent>() {
              @Override
              public void handle(MouseEvent event) {
                IMatDataHandler.getInstance().getShoppingCart().removeItem(item);
                IMatDataHandler.getInstance()
                    .getShoppingCart()
                    .fireShoppingCartChanged(item, false);
              }
            });

        // Listen for TextField text changes
        txtField
            .textProperty()
            .addListener(
                new ChangeListener<String>() {
                  @Override
                  public void changed(
                      ObservableValue<? extends String> observable,
                      String oldValue,
                      String newValue) {
                    try {
                      if (!txtField.getText().equals("")) {
                        int amount = Integer.parseInt(txtField.getText());
                        if (amount < 1) {
                          txtField.setText(1 + "");
                        } else if (amount > 99) {
                          txtField.setText(99 + "");
                        }
                        item.setAmount(Integer.parseInt(txtField.getText()));
                        double cost2 = item.getTotal();
                        price.setText(String.format("%.2f", cost2) + " kr");
                        // IMatDataHandler.getInstance().getShoppingCart().fireShoppingCartChanged(item, true);
                        lastValidProductAmountString = txtField.getText();
                      }
                    } catch (NumberFormatException e) {
                      txtField.setText(lastValidProductAmountString);
                    }
                  }
                });
      }
    } else {
      if (count < 1) {
        Label noProducts = new Label("Din kundvagn är tom");
        noProducts.getStyleClass().add("produktnamn");
        setGraphic(noProducts);
        count++;
      } else {
        setText(null);
        setGraphic(null);
      }
    }
  }