Exemplo n.º 1
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    primaryStage.setMaximized(true);
    Context context = new Context(primaryStage, new Board());
    new MenuScreen(context);

    primaryStage.show();
  }
Exemplo n.º 2
0
  /** se inicia la aplicacion */
  @Override
  public void start(Stage primaryStage) throws Exception {
    this.primaryStage = primaryStage;
    this.primaryStage.setTitle(" My GitHub Profile");
    // this.primaryStage.getIcons().add(new Image("file:resources/images/AddressApp.png"));

    initRootLayout();
    primaryStage.setMaximized(false);
  }
Exemplo n.º 3
0
  private void showUI(Stage primaryStage, String name, String version) {
    SmartCSVController smartCVSController = appContext.getBean(SmartCSVController.class);
    Scene scene = new Scene((Parent) smartCVSController.getView());

    primaryStage.setScene(scene);
    primaryStage.setTitle(String.format("%s %s", name, version));
    primaryStage.show();
    primaryStage.setMaximized(true);

    primaryStage.setOnCloseRequest(
        event -> {
          if (!smartCVSController.canExit()) {
            event.consume();
          } else {
            exit();
          }
        });
  }
Exemplo n.º 4
0
  /**
   * The opening class. When the launch method is run, the code in here begins to execute. All code
   *
   * @param primaryStage The intial stage opened on run
   * @throws Exception
   */
  @SuppressWarnings("unchecked")
  public void start(Stage primaryStage) throws Exception {
    primaryStage.setMaximized(true);
    primaryStage.setTitle("Equipment Manager");
    Button executive = new Button("Executive Options");
    TextField search = new TextField();
    search.setPromptText("Search");
    TableView<Item> table;

    // create filenames
    String fileName = System.getProperty("user.home") + "/item.csv";
    String passFileName = System.getProperty("user.home") + "/notoflookinghere.csv";
    String IDFileName = System.getProperty("user.home") + "/memberlist.csv";
    String logFileName = System.getProperty("user.home") + "/Log.csv";
    File x = new File(fileName);
    // if no file exists with given names, create default files
    if (!x.exists()) {
      csvFileWriter write = new csvFileWriter();
      write.writeCsvFile(logFileName);
      write.writeCsvFile(fileName);
      write.writeCsvFile(IDFileName);
      ArrayList<Item> list = new ArrayList<>();
      list.add(new Item(1000, "password", true, "none", false));
      write.enterData(list);
      write.writeCsvFile(passFileName);
    } else {
      System.out.println("Files Read");
    }

    manage.searchFor(fileName, search.getText());

    table = new TableView<>();
    table.setItems(UIManager.getItems(fileName, search.getText()));
    table.setMaxWidth(675);
    table
        .getColumns()
        .addAll(
            UIManager.referenceColumn(),
            UIManager.nameColumn(),
            UIManager.availableColumn(),
            UIManager.IDColumn(),
            UIManager.permColumn());

    Button checkout = new Button("Checkout");
    checkout.setOnAction(
        e -> {
          Checking.checkOut(fileName, IDFileName, passFileName);
          table.setItems(UIManager.getItems(fileName, search.getText()));
        });

    Button checkIn = new Button("Checkin");
    checkIn.setOnAction(
        e -> {
          Checking.checkIn(fileName);
          table.setItems(UIManager.getItems(fileName, search.getText()));
        });

    search.setOnKeyPressed(e -> table.setItems(UIManager.getItems(fileName, search.getText())));

    // This creates and sets up all the menu bars on the top of the page
    MenuBar menuBar = new MenuBar();

    // Menu Tabs
    Menu help = new Menu("_Help");
    Menu exec = new Menu("_Executive Settings");
    menuBar.getMenus().addAll(help, exec);

    // Menu Items
    MenuItem code = new MenuItem("View Code");
    MenuItem report = new MenuItem("Report a Bug");
    MenuItem openOptions = new MenuItem("Open Executive Options");
    help.getItems().addAll(code, report);
    exec.getItems().addAll(openOptions);

    // Menu External Links
    URI codeLink = new URI("https://github.com/NHSTechTeam/Equipment-System");
    URI reportLink = new URI("https://github.com/NHSTechTeam/Equipment-System/issues");

    // Menu Actions
    code.setOnAction(e -> UIManager.openWebpage(codeLink));
    report.setOnAction(e -> UIManager.openWebpage(reportLink));
    openOptions.setOnAction(
        e -> {
          try {
            ExecutiveMain.executive(fileName, passFileName, logFileName, IDFileName);
          } catch (URISyntaxException e1) {
            e1.printStackTrace();
          }
        });

    HBox menu = new HBox();
    menu.setPadding(new Insets(10, 10, 10, 10));
    menu.setSpacing(10);
    menu.setAlignment(Pos.CENTER);
    menu.getChildren().addAll(checkout, checkIn);

    executive.setOnAction(
        e -> {
          try {
            ExecutiveMain.executive(fileName, passFileName, logFileName, IDFileName);
          } catch (URISyntaxException e1) {
            e1.printStackTrace();
          }
        });

    BorderPane borderLayout = new BorderPane();
    VBox layout = new VBox(10);
    borderLayout.setTop(menuBar);
    borderLayout.setCenter(layout);
    layout.getChildren().addAll(search, table, menu, executive);
    layout.setAlignment(Pos.CENTER);
    Scene scene = new Scene(borderLayout, 300, 250);
    scene.getStylesheets().add("style.css");
    primaryStage.getIcons().add(new Image("images/icon.png"));
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Exemplo n.º 5
0
  private void setStageParams(Stage stage) {
    Controller ctrlr = MainStage.controller;
    ProgramSettings ps = SingleObject.getProgramSettings();
    WindowState ws = ps.getWinState();
    Window w = stage.getScene().getWindow();
    w.setX(ws.getX());
    w.setY(ws.getY());
    w.setWidth(ws.getWidth());
    w.setHeight(ws.getHeight());
    stage.setMaximized(ws.isMaximized());

    double oldDuration = ctrlr.getAlarmSplitPane().getDuration();
    ctrlr.getAlarmSplitPane().setDuration(0);
    ctrlr.getAlarmSplitPane().setExpandedSize(ws.getAlarmDividerPositions());
    if (ws.isAlarmsShowing()) {
      ctrlr.getAlarmSplitPane().showSide();
    } else {
      ctrlr.getAlarmSplitPane().hideSide();
    }
    ctrlr.getAlarmSplitPane().setDuration(oldDuration);

    ctrlr.getTreeSplitPane().setExpandedSize(ws.getTreeDividerPositions());
    oldDuration = ctrlr.getTreeSplitPane().getDuration();
    ctrlr.getTreeSplitPane().setDuration(0);
    if (ws.isTreeShowing()) {
      Platform.runLater(() -> ctrlr.getTreeSplitPane().showSide());
    } else {
      Platform.runLater(() -> ctrlr.getTreeSplitPane().hideSide());
    }
    ctrlr.getTreeSplitPane().setDuration(oldDuration);
    Platform.runLater(() -> ctrlr.getSpTreeController().getTvSchemes().requestFocus());

    ctrlr
        .getMainPane()
        .isShowingProperty()
        .bind(
            SingleObject.mainStage
                .fullScreenProperty()
                .isNotEqualTo(new SimpleBooleanProperty(true)));
    ctrlr.getvToolBarPane().isShowingProperty().bind(ctrlr.getMainPane().isShowingProperty());

    ctrlr
        .getMainPane()
        .getSideBar()
        .visibleProperty()
        .addListener(
            (observ, old, newValue) -> {
              if (newValue) {
                String[] state = ctrlr.getMainPane().getUserData().toString().split(";");
                if (Boolean.valueOf(state[0])) {
                  Platform.runLater(() -> ctrlr.getAlarmSplitPane().showSide());
                } else {
                  if (Boolean.valueOf(state[1]))
                    Platform.runLater(() -> ctrlr.getTreeSplitPane().showSide());
                }
              } else {
                ctrlr
                    .getMainPane()
                    .setUserData(
                        ctrlr.getAlarmSplitPane().isShowingProperty().get()
                            + ";"
                            + ctrlr.getTreeSplitPane().isShowingProperty().get());
                if (ctrlr.getAlarmSplitPane().isShowingProperty().get()) {
                  Platform.runLater(() -> ctrlr.getAlarmSplitPane().hideSide());
                } else {
                  Platform.runLater(() -> ctrlr.getTreeSplitPane().hideSide());
                }
              }
            });

    ctrlr
        .getAlarmSplitPane()
        .getSideBar()
        .visibleProperty()
        .addListener(
            (observ, old, newValue) -> {
              if (!ctrlr.getMainPane().isShowingProperty().get()) {
                Platform.runLater(() -> ctrlr.getTreeSplitPane().hideSide());
              } else {
                if (ctrlr.getMainPane().getUserData() != null) {
                  String[] state = ctrlr.getMainPane().getUserData().toString().split(";");
                  if (Boolean.valueOf(state[1]))
                    Platform.runLater(() -> ctrlr.getTreeSplitPane().showSide());
                  ctrlr.getMainPane().setUserData(null);
                }
              }
            });

    ctrlr
        .getAlarmSplitPane()
        .getSideBar()
        .visibleProperty()
        .addListener(
            (observ, old, newVal) -> {
              if (newVal) {
                ctrlr.getShowAlarm().getStyleClass().add("hide-down");
                ctrlr.getShowAlarm().getStyleClass().remove("show-up");
              } else {
                ctrlr.getShowAlarm().getStyleClass().remove("hide-down");
                ctrlr.getShowAlarm().getStyleClass().add("show-up");
              }
            });

    ctrlr.getToolBarController().getHideLeft().setGraphic(null);
    ctrlr
        .getTreeSplitPane()
        .isShowingProperty()
        .addListener(
            (observ, old, newValue) -> {
              if (newValue) {
                ctrlr.getToolBarController().getHideLeft().getStyleClass().add("hide-left");
                ctrlr.getToolBarController().getHideLeft().getStyleClass().remove("show-right");
              } else {
                ctrlr.getToolBarController().getHideLeft().getStyleClass().remove("hide-left");
                ctrlr.getToolBarController().getHideLeft().getStyleClass().add("show-right");
              }
            });

    ctrlr.getToolBarController().getFit().setGraphic(null);
    SingleObject.mainStage
        .fullScreenProperty()
        .addListener(
            (observ, old, newValue) -> {
              if (newValue) {
                ctrlr.getToolBarController().getFit().getStyleClass().add("full-screen-on");
                ctrlr.getToolBarController().getFit().getStyleClass().remove("full-screen-off");
              } else {
                ctrlr.getToolBarController().getFit().getStyleClass().remove("full-screen-on");
                ctrlr.getToolBarController().getFit().getStyleClass().add("full-screen-off");
              }
            });

    SchemeSettings ss = ps.getSchemeSettings();
    SingleObject.mainScheme.getRoot().setScaleX(ss.getSchemeScale());
    SingleObject.mainScheme.getRoot().setScaleY(ss.getSchemeScale());
    ctrlr.getMenuBarController().setLocaleName(ps.getLocaleName());

    ps.getHotkeys().forEach(e -> SingleObject.hotkeys.put(e.getIdCode(), e));
  }
Exemplo n.º 6
0
  @Override
  /** Starts the application. */
  public void start(final Stage primaryStage) {
    final EventManager eventManager = new EventManager();
    final IdGenerator connectionIdGenerator = new IdGenerator();

    try {
      final ConfigurationManager configurationManager =
          new ConfigurationManager(eventManager, connectionIdGenerator);

      // Load the main window
      FxmlUtils.setParentClass(getClass());
      final FXMLLoader loader = FxmlUtils.createFxmlLoaderForProjectFile("MainWindow.fxml");

      // Get the associated pane
      AnchorPane pane = (AnchorPane) loader.load();

      final Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();

      // Set scene width, height and style
      final double height =
          Math.min(
              UiProperties.getApplicationHeight(configurationManager),
              primaryScreenBounds.getHeight());
      final double width =
          Math.min(
              UiProperties.getApplicationWidth(configurationManager),
              primaryScreenBounds.getWidth());

      final Scene scene = new Scene(pane, width, height);
      scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());

      // Get the associated controller
      final MainController mainController = (MainController) loader.getController();
      mainController.setEventManager(eventManager);
      mainController.setConfigurationManager(configurationManager);
      mainController.setSelectedPerspective(
          UiProperties.getApplicationPerspective(configurationManager));
      mainController
          .getResizeMessagePaneMenu()
          .setSelected(UiProperties.getResizeMessagePane(configurationManager));

      // Set the stage's properties
      primaryStage.setScene(scene);
      primaryStage.setMaximized(UiProperties.getApplicationMaximized(configurationManager));

      // Initialise resources in the main controller
      mainController.setApplication(this);
      mainController.setStage(primaryStage);
      mainController.setLastHeight(height);
      mainController.setLastWidth(width);
      mainController.init();
      final Image applicationIcon =
          new Image(getClass().getResourceAsStream("/images/mqtt-spy-logo.png"));
      primaryStage.getIcons().add(applicationIcon);

      // Show the main window
      primaryStage.show();

      // Load the config file if specified
      final String noConfig = this.getParameters().getNamed().get(NO_CONFIGURATION_PARAMETER_NAME);
      final String configurationFileLocation =
          this.getParameters().getNamed().get(CONFIGURATION_PARAMETER_NAME);

      if (noConfig != null) {
        // Do nothing - no config wanted
      } else if (configurationFileLocation != null) {
        mainController.loadConfigurationFileAndShowErrorWhenApplicable(
            new File(configurationFileLocation));
      } else {
        // If no configuration parameter is specified, use the user's home directory and the default
        // configuration file name
        mainController.loadDefaultConfigurationFile();
      }
    } catch (Exception e) {
      LoggerFactory.getLogger(Main.class).error("Error while loading the main window", e);
    }
  }
Exemplo n.º 7
0
  /**
   * Build an new JEConfig Login and main frame/stage
   *
   * @param primaryStage
   */
  private void initGUI(Stage primaryStage) {
    Scene scene;
    LoginGlass login = new LoginGlass(primaryStage);

    AnchorPane jeconfigRoot = new AnchorPane();
    AnchorPane.setTopAnchor(jeconfigRoot, 0.0);
    AnchorPane.setRightAnchor(jeconfigRoot, 0.0);
    AnchorPane.setLeftAnchor(jeconfigRoot, 0.0);
    AnchorPane.setBottomAnchor(jeconfigRoot, 0.0);

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    login
        .getLoginStatus()
        .addListener(
            new ChangeListener<Boolean>() {

              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue) {
                  System.out.println("after request");
                  _mainDS = login.getDataSource();
                  ds = _mainDS;
                  _currentUser = new User(ds);

                  Platform.runLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          FadeTransition ft = new FadeTransition(Duration.millis(1500), login);
                          ft.setFromValue(1.0);
                          ft.setToValue(0);
                          ft.setCycleCount(1);
                          ft.play();
                        }
                      });

                  JEConfig.PROGRAMM_INFO.setJEVisAPI(ds.getInfo());
                  JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.commons.application.Info.INFO);
                  JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.application.Info.INFO);

                  preLodedClasses = login.getAllClasses();
                  preLodedRootObjects = login.getRootObjects();

                  PluginManager pMan = new PluginManager(ds);
                  GlobalToolBar toolbar = new GlobalToolBar(pMan);
                  pMan.addPluginsByUserSetting(null);

                  BorderPane border = new BorderPane();
                  VBox vbox = new VBox();
                  vbox.setStyle("-fx-background-color: black;");
                  //                    vbox.getChildren().addAll(new TopMenu(),
                  // toolbar.ToolBarFactory());
                  vbox.getChildren().addAll(new TopMenu(), pMan.getToolbar());
                  border.setTop(vbox);
                  border.setCenter(pMan.getView());

                  Statusbar statusBar = new Statusbar(ds);

                  border.setBottom(statusBar);

                  // Disable GUI is StatusBar note an disconnect
                  border.disableProperty().bind(statusBar.connectedProperty.not());

                  Platform.runLater(
                      new Runnable() {
                        @Override
                        public void run() {

                          AnchorPane.setTopAnchor(border, 0.0);
                          AnchorPane.setRightAnchor(border, 0.0);
                          AnchorPane.setLeftAnchor(border, 0.0);
                          AnchorPane.setBottomAnchor(border, 0.0);

                          jeconfigRoot.getChildren().setAll(border);
                          try {
                            WelcomePage welcome =
                                new WelcomePage(primaryStage, _config.getWelcomeURL());
                          } catch (URISyntaxException ex) {
                            Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                          } catch (MalformedURLException ex) {
                            Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                          }
                        }
                      });
                }
              }
            });

    AnchorPane.setTopAnchor(login, 0.0);
    AnchorPane.setRightAnchor(login, 0.0);
    AnchorPane.setLeftAnchor(login, 0.0);
    AnchorPane.setBottomAnchor(login, 0.0);

    scene = new Scene(jeconfigRoot, bounds.getWidth(), bounds.getHeight());
    scene.getStylesheets().add("/styles/Styles.css");
    primaryStage.getIcons().add(getImage("JEVisIconBlue.png"));

    primaryStage.setTitle("JEConfig");
    primaryStage.setScene(scene);
    primaryStage.setMaximized(true);
    //        maximize(primaryStage);
    primaryStage.show();

    jeconfigRoot.getChildren().setAll(login);

    primaryStage
        .onCloseRequestProperty()
        .addListener(
            new ChangeListener<EventHandler<WindowEvent>>() {

              @Override
              public void changed(
                  ObservableValue<? extends EventHandler<WindowEvent>> ov,
                  EventHandler<WindowEvent> t,
                  EventHandler<WindowEvent> t1) {
                try {
                  System.out.println("Disconnect");
                  ds.disconnect();
                } catch (JEVisException ex) {
                  Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                }
              }
            });
  }