View Javadoc
1   /*
2    * Copyright (c) Patrick Magauran 2018.
3    *   Licensed under the AGPLv3. All conditions of said license apply.
4    *       This file is part of ABOS.
5    *
6    *       ABOS is free software: you can redistribute it and/or modify
7    *       it under the terms of the GNU Affero General Public License as published by
8    *       the Free Software Foundation, either version 3 of the License, or
9    *       (at your option) any later version.
10   *
11   *       ABOS is distributed in the hope that it will be useful,
12   *       but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   *       GNU Affero General Public License for more details.
15   *
16   *       You should have received a copy of the GNU Affero General Public License
17   *       along with ABOS.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  
20  package Utilities;
21  
22  import javafx.concurrent.Task;
23  import javafx.geometry.Pos;
24  import javafx.scene.Scene;
25  import javafx.scene.control.Label;
26  import javafx.scene.control.ProgressBar;
27  import javafx.scene.layout.VBox;
28  import javafx.stage.Modality;
29  import javafx.stage.Stage;
30  import javafx.stage.StageStyle;
31  
32  /**
33   * Created by patrick on 5/27/17.
34   */
35  public class ProgressForm {
36      final Label label = new Label();
37      private final Stage dialogStage;
38      private final ProgressBar pb = new ProgressBar();
39      //  private final ProgressIndicator pin = new ProgressIndicator();
40  
41      public ProgressForm() {
42          dialogStage = new Stage();
43          dialogStage.initStyle(StageStyle.UTILITY);
44          dialogStage.setResizable(false);
45          dialogStage.initModality(Modality.APPLICATION_MODAL);
46  
47          // PROGRESS BAR
48          label.setText("alerto");
49  
50          pb.setProgress(-1F);
51  
52          final VBox vb = new VBox();
53          vb.setSpacing(5);
54          vb.setAlignment(Pos.CENTER);
55          vb.getChildren().addAll(label, pb);
56  
57          Scene scene = new Scene(vb);
58          dialogStage.setScene(scene);
59      }
60  
61      public void activateProgressBar(final Task<?> task) {
62          pb.progressProperty().bind(task.progressProperty());
63          label.textProperty().bind(task.messageProperty());
64  
65          dialogStage.show();
66      }
67  
68      public Stage getDialogStage() {
69          return dialogStage;
70      }
71  }