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();
  }
  @Override
  public void handlePerspective(
      final Message<Event, Object> action, final PerspectiveLayout perspectiveLayout) {
    if (action.messageBodyEquals(MessageUtil.INIT)) {

      perspectiveLayout.registerRootComponent(createRoot());
      GridPane.setVgrow(perspectiveLayout.getRootComponent(), Priority.ALWAYS);
      GridPane.setHgrow(perspectiveLayout.getRootComponent(), Priority.ALWAYS);

      // register left panel
      perspectiveLayout.registerTargetLayoutComponent("content0", this.content1);
      perspectiveLayout.registerTargetLayoutComponent("content1", this.content2);
      perspectiveLayout.registerTargetLayoutComponent("content2", this.content3);
      ApplicationLauncherPerspectiveMessaginTest.latch.countDown();
    } else {
      if (counter.get() > 1) {
        counter.decrementAndGet();
        context.send("id10", "message");
      } else {
        System.out.println("Perspective id12: FINISH");
        if (wait.getCount() > 0) wait.countDown();
        if (PerspectiveMessagingTestP1.wait.getCount() > 0) context.send("id10", "message");
      }
    }
  }
  @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();
    }
  }
Example #4
0
  private void updateGrid() {
    grid.getChildren().clear();

    // add the message to the top of the dialog
    updateContentText();

    // then build all the buttons
    int row = 1;
    for (final ButtonType buttonType : getDialogPane().getButtonTypes()) {
      if (buttonType == null) continue;

      final Button button = (Button) getDialogPane().lookupButton(buttonType);

      GridPane.setHgrow(button, Priority.ALWAYS);
      GridPane.setVgrow(button, Priority.ALWAYS);
      grid.add(button, 0, row++);
    }

    //        // last button gets some extra padding (hacky)
    //        GridPane.setMargin(buttons.get(buttons.size() - 1), new Insets(0,0,10,0));

    getDialogPane().setContent(grid);
    getDialogPane().requestLayout();
  }
Example #5
0
  private Button createCommandLinksButton(ButtonType buttonType) {
    // look up the CommandLinkButtonType for the given ButtonType
    CommandLinksButtonType commandLink =
        typeMap.getOrDefault(buttonType, new CommandLinksButtonType(buttonType));

    // put the content inside a button
    final Button button = new Button();
    button.getStyleClass().addAll("command-link-button"); // $NON-NLS-1$
    button.setMaxHeight(Double.MAX_VALUE);
    button.setMaxWidth(Double.MAX_VALUE);
    button.setAlignment(Pos.CENTER_LEFT);

    final ButtonData buttonData = buttonType.getButtonData();
    button.setDefaultButton(buttonData != null && buttonData.isDefaultButton());
    button.setOnAction(ae -> setResult(buttonType));

    final Label titleLabel = new Label(commandLink.getButtonType().getText());
    titleLabel
        .minWidthProperty()
        .bind(
            new DoubleBinding() {
              {
                bind(titleLabel.prefWidthProperty());
              }

              @Override
              protected double computeValue() {
                return titleLabel.getPrefWidth() + 400;
              }
            });
    titleLabel.getStyleClass().addAll("line-1"); // $NON-NLS-1$
    titleLabel.setWrapText(true);
    titleLabel.setAlignment(Pos.TOP_LEFT);
    GridPane.setVgrow(titleLabel, Priority.NEVER);

    Label messageLabel = new Label(commandLink.getLongText());
    messageLabel.getStyleClass().addAll("line-2"); // $NON-NLS-1$
    messageLabel.setWrapText(true);
    messageLabel.setAlignment(Pos.TOP_LEFT);
    messageLabel.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(messageLabel, Priority.SOMETIMES);

    Node commandLinkImage = commandLink.getGraphic();
    Node view =
        commandLinkImage == null
            ? new ImageView(
                CommandLinksDialog.class.getResource("arrow-green-right.png").toExternalForm())
            : //$NON-NLS-1$
            commandLinkImage;
    Pane graphicContainer = new Pane(view);
    graphicContainer.getStyleClass().add("graphic-container"); // $NON-NLS-1$
    GridPane.setValignment(graphicContainer, VPos.TOP);
    GridPane.setMargin(graphicContainer, new Insets(0, 10, 0, 0));

    GridPane grid = new GridPane();
    grid.minWidthProperty().bind(titleLabel.prefWidthProperty());
    grid.setMaxHeight(Double.MAX_VALUE);
    grid.setMaxWidth(Double.MAX_VALUE);
    grid.getStyleClass().add("container"); // $NON-NLS-1$
    grid.add(graphicContainer, 0, 0, 1, 2);
    grid.add(titleLabel, 1, 0);
    grid.add(messageLabel, 1, 1);

    button.setGraphic(grid);
    button.minWidthProperty().bind(titleLabel.prefWidthProperty());

    if (commandLink.isHidden) {
      button.setVisible(false);
      button.setPrefHeight(1);
    }
    return button;
  }
Example #6
0
  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");
  }
  /** {@inheritDoc} */
  @Override
  public void buildContent() {
    Calendar calendar = calendarView.calendarProperty().get();

    // get the maximum number of days in a week for this calendar.
    numberOfDaysPerWeek = calendar.getMaximum(Calendar.DAY_OF_WEEK);

    // get the maximum number of days a month could have.
    int maxNumberOfDaysInMonth = calendar.getMaximum(Calendar.DAY_OF_MONTH);

    // assume the first row has only 1 day, then distribute the rest among the remaining weeks and
    // add the first week.
    int numberOfRows =
        (int) Math.ceil((maxNumberOfDaysInMonth - 1) / (double) numberOfDaysPerWeek) + 1;

    // remove all controls
    getChildren().clear();

    int colOffset = calendarView.getShowWeeks() ? 1 : 0;

    if (calendarView.getShowWeeks()) {
      Label empty = new Label();
      empty.setMaxWidth(Double.MAX_VALUE);
      empty.getStyleClass().add(CSS_CALENDAR_WEEKDAYS);
      add(empty, 0, 0);
    }
    // iterate through the columns
    for (int i = 0; i < numberOfDaysPerWeek; i++) {
      Label label = new Label();
      label.getStyleClass().add(CSS_CALENDAR_WEEKDAYS);
      label.setMaxWidth(Double.MAX_VALUE);
      label.setAlignment(Pos.CENTER);
      add(label, i + colOffset, 0);
    }

    // iterate through the rows
    for (int rowIndex = 0; rowIndex < numberOfRows; rowIndex++) {

      if (calendarView.getShowWeeks()) {
        Label label = new Label();
        label.setMaxWidth(Double.MAX_VALUE);
        label.setMaxHeight(Double.MAX_VALUE);
        label.getStyleClass().add(CSS_CALENDAR_WEEK_NUMBER);
        add(label, 0, rowIndex + 1);
      }

      // iterate through the columns
      for (int colIndex = 0; colIndex < numberOfDaysPerWeek; colIndex++) {
        final Button button = new Button();
        button.setMaxWidth(Double.MAX_VALUE);
        button.setMaxHeight(Double.MAX_VALUE);

        GridPane.setVgrow(button, Priority.ALWAYS);
        GridPane.setHgrow(button, Priority.ALWAYS);
        button.setOnAction(
            new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent actionEvent) {

                calendarView.selectedDate.set((Date) button.getUserData());
              }
            });
        // add the button, starting at second row.
        add(button, colIndex + colOffset, rowIndex + 1);
      }
    }
  }