// Custom function for creation of New Tabs.
  public ScriptingFileWidget createFileTab(File file) {
    if (openFiles.get(file.getAbsolutePath()) != null
        && widgets.get(file.getAbsolutePath()) != null) {
      setSelectedTab(openFiles.get(file.getAbsolutePath()));
      return widgets.get(file.getAbsolutePath()).getScripting();
    }

    Tab fileTab = new Tab(file.getName());
    openFiles.put(file.getAbsolutePath(), fileTab);
    try {
      Log.warning("Loading local file from: " + file.getAbsolutePath());
      LocalFileScriptTab t = new LocalFileScriptTab(file);

      fileTab.setContent(t);
      addTab(fileTab, true);
      widgets.put(file.getAbsolutePath(), t);
      fileTab.setOnCloseRequest(
          event -> {
            widgets.remove(file.getAbsolutePath());
            openFiles.remove(file.getAbsolutePath());
          });
      return t.getScripting();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return null;
  }
  @FXML
  public void handleInspectionButton() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File("C:\\Users\\Christoph\\OneDrive\\newAnalysis"));
    fileChooser.setTitle("Choose Invariant File");
    fileChooser.getExtensionFilters().addAll(new ExtensionFilter("Invariant Files", "*.txt"));

    File selectedFile = fileChooser.showOpenDialog(stage);
    if (selectedFile != null) {
      try {
        FXMLLoader loader = new FXMLLoader();
        BorderPane root =
            (BorderPane)
                loader.load(getClass().getResource("InvariantInspectorTab.fxml").openStream());
        InvariantInspectorTabController controller =
            (InvariantInspectorTabController) loader.getController();
        controller.setPrimaryStage(stage);
        controller.loadData(selectedFile);

        Tab tab = new Tab();
        tab.setContent(root);

        tabPane.getTabs().add(tab);

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Пример #3
0
  public void openImageFile(Resource resource) {
    Tab tab = new Tab();
    tab.setClosable(true);
    if (resource == null) {
      Dialogs.create()
          .owner(tabPane)
          .title("Datei nicht vorhanden")
          .message(
              "Die angeforderte Datei ist nicht vorhanden und kann deshalb nicht geöffnet werden.")
          .showError();
      return;
    }
    tab.setText(resource.getFileName());

    ImageResource imageResource = (ImageResource) resource;
    ImageViewerPane pane = new ImageViewerPane();
    pane.setImageResource(imageResource);

    ImageView imageView = pane.getImageView();
    imageView.setImage(imageResource.asNativeFormat());
    imageView.setFitHeight(-1);
    imageView.setFitWidth(-1);

    Label imagePropertiesLabel = pane.getImagePropertiesLabel();
    imagePropertiesLabel.setText(imageResource.getImageDescription());

    tab.setContent(pane);
    tab.setUserData(resource);
    tabPane.getTabs().add(tab);
    tabPane.getSelectionModel().select(tab);
  }
Пример #4
0
 public void addNewTab(UserInterfaceVC pane) {
   myWorkSpaces.add(pane);
   Tab t = new Tab();
   t.setContent(pane.getGroup());
   t.setText("Work Space " + String.valueOf(numTabs + 1));
   numTabs++;
   myTabPane.getTabs().add(t);
 }
Пример #5
0
  public CrashReportView() {
    VBox.setVgrow(termTreeView, Priority.ALWAYS);

    Label label;
    label = new Label("Stack Trace");
    label.setStyle("-fx-padding: 5; -fx-font-size: 14;");

    Tab stackTraceTab, argsTermsTab, termsTab;
    termsTab = new Tab("Crash Report Terms");
    termsTab.setContent(termTreeView);
    argsTermsTab = new Tab("Call Args");
    argsTermsTab.setContent(argsTreeView);
    stackTraceTab = new Tab("Stack Trace");
    stackTraceTab.setContent(new VBox(crashInfoTable, label, stackTraceView));

    getTabs().addAll(stackTraceTab, argsTermsTab, termsTab);
  }
Пример #6
0
 public AbstractTab(String name, String id, Stage stage, D dto) {
   tab = new Tab(name);
   tab.setId(id);
   this.name = name;
   this.stage = stage;
   setDTO(dto);
   tab.setContent(addTabContent(stage));
 }
Пример #7
0
 public ChartsResultsBroker(Tab tabChartsBrokerResults) {
   this.tabChartsBrokerResults = tabChartsBrokerResults;
   scpAllPage = new ScrollPane();
   scpAllPage.getStyleClass().add("bg-general-container");
   vbxAllPage = new VBox();
   vbxAllPage.setPadding(new Insets(10, 10, 10, 10));
   vbxAllPage.setSpacing(10);
   scpAllPage.setContent(vbxAllPage);
   tabChartsBrokerResults.setContent(scpAllPage);
 }
Пример #8
0
  public void initialize() {
    setupCloseMenuItem();

    checkForDefinedGitRepoDirectory();

    setupDirectorySelectMenuItem();

    aboutMenuItem.setOnAction(
        event -> {
          new About();
        });

    gitConsoleTab.setContent(new GitConsole());
  }
Пример #9
0
  private void addEditor(File filename) {
    final EditorPane pane = new EditorPane(this);

    if (filename != null) {
      pane.loadSource(filename);
    }

    final Tab tab = new Tab();
    tab.setContent(pane);
    tab.setText(pane.getName());

    EventHandler<Event> closeHandler =
        new EventHandler<Event>() {
          @Override
          public void handle(Event e) {
            if (pane.isModified()) {
              pane.promptSave();
            }

            tabPane.getTabs().remove(tab);
          }
        };

    // JavaFX 2.2 (from Java 7) has no onCloseRequestProperty
    if (JITWatchUI.IS_JAVA_FX2) {
      tab.setOnClosed(closeHandler);
    } else {
      // Use reflection to call setOnCloseRequestProperty for Java 8
      try {
        MethodType mt = MethodType.methodType(void.class, EventHandler.class);

        MethodHandle mh = MethodHandles.lookup().findVirtual(Tab.class, "setOnCloseRequest", mt);

        // fails with invokeExact due to generic type erasure?
        mh.invoke(tab, closeHandler);

      } catch (Throwable t) {
        logger.error("Exception: {}", t.getMessage(), t);
      }
    }

    tabPane.getTabs().add(tab);

    pane.requestFocus();

    setVMLanguage(pane);
    saveEditorPaneConfig();
  }
Пример #10
0
  @Override
  public void initUI() {
    AnchorPane anchorPane = new AnchorPane();
    anchorPane.setPrefHeight(90.0);
    anchorPane.setPrefWidth(384.0);

    Label label = new Label(getApplication().getMessageSource().getMessage("name.label"));
    TextField input = new TextField();
    input.setPrefWidth(200.0);

    Button button = new Button();
    button.setPrefWidth(200.0);
    JavaFXUtils.configure(
        button, (JavaFXAction) actionFor(controller, "sayHello").getToolkitAction());

    Label output = new Label();
    label.setPrefWidth(360.0);

    model.inputProperty().bindBidirectional(input.textProperty());
    model.outputProperty().bindBidirectional(output.textProperty());

    anchorPane.getChildren().addAll(label, input, button, output);

    setLeftAnchor(label, 14.0);
    setTopAnchor(label, 14.0);
    setLeftAnchor(input, 172.0);
    setTopAnchor(input, 11.0);
    setLeftAnchor(button, 172.0);
    setTopAnchor(button, 45.0);
    setLeftAnchor(output, 14.0);
    setTopAnchor(output, 80.0);

    Tab tab = new Tab("Java");
    tab.setGraphic(new FontAwesomeIcon(FontAwesome.FA_COFFEE));
    tab.setClosable(false);
    tab.setContent(anchorPane);
    parentView.getTabPane().getTabs().add(tab);
  }
Пример #11
0
 @Override
 public void changed(
     ObservableValue<? extends TreeItem<Box>> observableValue,
     TreeItem<Box> boxTreeItem,
     TreeItem<Box> boxTreeItem2) {
   if (boxTreeItem2 == null) {
     return;
   }
   String id = Path.createPath(boxTreeItem2.getValue());
   Tab t = null;
   for (Tab tab : tabPane.getTabs()) {
     if (tab.getId().equals(id)) {
       tabPane.getSelectionModel().select(tab);
       t = tab;
     }
   }
   if (t == null) {
     t = new Tab(id);
     t.setId(id);
     tabPane.getTabs().addAll(t);
     t.setContent(new BoxPane(boxTreeItem2.getValue()));
     tabPane.getSelectionModel().select(t);
   }
 }
Пример #12
0
  private void setupScene() {

    splitPane = new SplitPane();
    splitPane.setOrientation(Orientation.HORIZONTAL);
    scene = new Scene(splitPane, 800, 600);

    Insuliin insuliin = new Insuliin();

    TabPane tabPane = new TabPane();
    Tab tab1 = new Tab();
    Tab tab2 = new Tab();
    tab1.setText("Toidud");
    tab2.setText("Salvestused");

    tab1.setContent(tabel2.vBox);
    tabPane.getTabs().addAll(tab1, tab2);

    splitPane.getItems().addAll(insuliin.vBox, tabPane);
    splitPane.setDividerPositions(0.5f);

    lava.setScene(scene);
    lava.setTitle("ülemine ja alumine");
    lava.show();
  }
  @FXML
  public void handleComparisonButton() {
    InvariantParser parser = new InvariantParser();

    List<Invariant> invariants1 = new ArrayList<>();
    List<Invariant> invariants2 = new ArrayList<>();

    File file1 =
        new File("C:\\Users\\Christoph\\OneDrive\\newAnalysis\\invariant1\\invariants.txt");
    File file2 = new File("C:\\Users\\Christoph\\OneDrive\\newAnalysis\\full_eb.csv");
    // File file1 = new
    // File("C:\\Users\\Christoph\\OneDrive\\newAnalysis\\experiment_rear_fogLight_random\\invariantsPruned1.txt");
    // File file2 = new
    // File("C:\\Users\\Christoph\\OneDrive\\newAnalysis\\experiment_rear_fogLight_random\\invariantsPruned2.txt");

    parser.parse(file1, invariants1);
    parser.parse(file2, invariants2);

    List<Invariant> extra1 = new ArrayList<>();
    List<Invariant> extra2 = new ArrayList<>();
    List<Invariant> common = new ArrayList<>();

    InvariantComperator comperator = new InvariantComperator();
    comperator.compare(invariants1, invariants2, extra1, common);

    comperator.compare(invariants2, invariants1, extra2, null);

    try {
      FXMLLoader loader = new FXMLLoader();
      BorderPane root =
          (BorderPane)
              loader.load(getClass().getResource("InvariantInspectorTab.fxml").openStream());
      InvariantInspectorTabController controller =
          (InvariantInspectorTabController) loader.getController();
      controller.setPrimaryStage(stage);
      controller.loadData(extra1);

      Tab tab = new Tab("Extra1");
      tab.setContent(root);

      tabPane.getTabs().add(tab);

    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      FXMLLoader loader = new FXMLLoader();
      BorderPane root =
          (BorderPane)
              loader.load(getClass().getResource("InvariantInspectorTab.fxml").openStream());
      InvariantInspectorTabController controller =
          (InvariantInspectorTabController) loader.getController();
      controller.setPrimaryStage(stage);
      controller.loadData(extra2);

      Tab tab = new Tab("Extra2");
      tab.setContent(root);

      tabPane.getTabs().add(tab);

    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      FXMLLoader loader = new FXMLLoader();
      BorderPane root =
          (BorderPane)
              loader.load(getClass().getResource("InvariantInspectorTab.fxml").openStream());
      InvariantInspectorTabController controller =
          (InvariantInspectorTabController) loader.getController();
      controller.setPrimaryStage(stage);
      controller.loadData(common);

      Tab tab = new Tab("Common");
      tab.setContent(root);

      tabPane.getTabs().add(tab);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #14
0
 /**
  * Set content for pending tab
  *
  * @param value
  */
 public void setPendingTab(Node value) {
   assert value != null;
   pendingTab.setContent(value);
 }
Пример #15
0
 private void addTabContent() {
   publicKeysTab.setContent(new KeyDirectory());
   reposTab.setContent(new Repos());
 }
Пример #16
0
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("Chapter 15-16 Adding Tabs to a UI");
    Group root = new Group();
    Scene scene = new Scene(root, 400, 250, Color.WHITE);

    TabPane tabPane = new TabPane();

    MenuBar menuBar = new MenuBar();

    EventHandler<ActionEvent> action = changeTabPlacement(tabPane);

    Menu menu = new Menu("Tab Side");
    MenuItem left = new MenuItem("Left");

    left.setOnAction(action);
    menu.getItems().add(left);

    MenuItem right = new MenuItem("Right");
    right.setOnAction(action);
    menu.getItems().add(right);

    MenuItem top = new MenuItem("Top");
    top.setOnAction(action);
    menu.getItems().add(top);

    MenuItem bottom = new MenuItem("Bottom");
    bottom.setOnAction(action);
    menu.getItems().add(bottom);

    menuBar.getMenus().add(menu);

    BorderPane borderPane = new BorderPane();

    // generate 10 tabs
    for (int i = 0; i < 10; i++) {
      Tab tab = new Tab();
      tab.setText("Tab" + i);
      HBox hbox = new HBox();
      hbox.getChildren().add(new Label("Tab" + i));
      hbox.setAlignment(Pos.CENTER);
      tab.setContent(hbox);
      tabPane.getTabs().add(tab);
    }

    // add tab pane
    borderPane.setCenter(tabPane);

    // bind to take available space
    borderPane.prefHeightProperty().bind(scene.heightProperty());
    borderPane.prefWidthProperty().bind(scene.widthProperty());

    // added menu bar
    borderPane.setTop(menuBar);

    // add border Pane
    root.getChildren().add(borderPane);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
  /*
   * Creates an artifact details popup. This popup's content is a tabbed view, with a tab for general properties,
   * creator properties, and relationships.
   * @param artifact
   */
  private void createArtifactDetailsPopup(PackageArtifact artifact) {

    // The property popup will consist of the three tabs, general, creator and relationships.
    TabPane propertiesPopup = new TabPane();
    propertiesPopup.getStyleClass().add(PROPERTIES_POPUP_CLASS);

    // Create the general tab, all the properties that are not creator properties, as
    // defined by the ontology will be located here.
    Tab generalTab = new Tab();
    generalTab.setClosable(false);
    generalTab.setText(labels.get(Labels.LabelKey.PACKAGE_ARTIFACT_GENERAL));
    ScrollPane generalPane = new ScrollPane();
    generalPane.setHvalue(500);
    generalPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    generalPane.setContent(createGeneralTab(artifact));
    generalPane.setMinWidth(500);
    generalPane.setFitToWidth(true);
    generalTab.setContent(generalPane);

    propertiesPopup.getTabs().add(generalTab);

    // Displays all the properties that are labeled as creator properties by the
    // ontology.
    Tab creatorTab = new Tab();
    creatorTab.setClosable(false);
    ScrollPane creatorPane = new ScrollPane();
    creatorPane.setHvalue(500);
    creatorPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    creatorPane.setContent(createCreatorTab(artifact));
    creatorPane.setMinWidth(500);
    creatorPane.setFitToWidth(true);
    creatorTab.setText(labels.get(Labels.LabelKey.PACKAGE_ARTIFACT_CREATOR));
    creatorTab.setContent(creatorPane);

    if (creatorPane.getContent() != null) {
      propertiesPopup.getTabs().add(creatorTab);
    }

    // Create the relationship tab that displays all relationships the artifact has.
    Tab relationshipTab = new Tab();
    relationshipTab.setClosable(false);
    relationshipTab.setText(labels.get(Labels.LabelKey.PACKAGE_ARTIFACT_RELATIONSHIPS));
    ScrollPane relationshipPane = new ScrollPane();
    relationshipPane.setHvalue(500);
    relationshipPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    relationshipPane.setContent(createRelationshipTab(artifact));
    relationshipPane.setMinWidth(500);
    relationshipPane.setFitToWidth(true);
    relationshipTab.setContent(relationshipPane);
    propertiesPopup.getTabs().add(relationshipTab);

    // Create the inheritance tab that displays all inheritable properties that an artifact has.
    Tab inheritanceTab = new Tab();
    inheritanceTab.setClosable(false);
    inheritanceTab.setText(labels.get(Labels.LabelKey.PACKAGE_ARTIFACT_INHERITANCE));
    ScrollPane inheritancePane = new ScrollPane();
    inheritancePane.setHvalue(500);
    inheritancePane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    inheritancePane.setContent(createInheritanceTab(artifact));
    inheritancePane.setMinWidth(500);
    inheritancePane.setFitToWidth(true);
    inheritanceTab.setContent(inheritancePane);
    propertiesPopup.getTabs().add(inheritanceTab);

    artifactDetailsLayout.setCenter(propertiesPopup);

    HBox popupControls = new HBox(24);
    popupControls.setAlignment(Pos.CENTER_RIGHT);

    popupControls.getStyleClass().add(VIEW_FOOTER_CLASS);
    popupControls.setPrefHeight(40);

    popupControls.getChildren().add(cancelPopupLink);

    popupControls.getChildren().add(applyPopupButton);

    artifactDetailsLayout.setBottom(popupControls);
  }
Пример #18
0
 /**
  * Set content for complete tab
  *
  * @param value
  */
 public void setCompleteTab(Node value) {
   assert value != null;
   completeTab.setContent(value);
 }
Пример #19
0
 /** Set Empty content for complete tab */
 public void setEmptyCompleteTab() {
   Image icon = new Image(COMPLETE_IMAGE);
   ImageView iconView = new ImageView(icon);
   completeTab.setContent(iconView);
 }
Пример #20
0
 /**
  * Set content for all tab
  *
  * @param value
  */
 public void setAllTab(Node value) {
   assert value != null;
   allTab.setContent(value);
 }
Пример #21
0
  private void createEditTab(final UserMaster user) {

    for (Tab selTab : getTabs()) {
      if (selTab.getId() != null && selTab.getId().equalsIgnoreCase(user.getUserName())) {
        getSelectionModel().select(selTab);
        return;
      }
    }

    Tab tab = new Tab("Edit User : "******"User", "Details");

    GridPane form = new GridPane();
    form.setHgap(ViewLayout.H_SPACE);
    form.setVgap(ViewLayout.V_SPACE);

    Label userNameLabel = new Label("User Name");
    userNameLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    ViewBox userNameTextBox = new ViewBox(user.userNameProperty());

    Label passwordLabel = new Label("Password");
    passwordLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final PasswordBox passwordBox = new PasswordBox("Password", user.passwordProperty());

    Label confirmPasswordLabel = new Label("Confirm Password");
    confirmPasswordLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final PasswordBox confirmPasswordBox =
        new PasswordBox("Confirm Password", user.confirmPasswordProperty());

    Label roleLabel = new Label("Role");
    roleLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final RoleEditableComboBox roleChoiceBox =
        new RoleEditableComboBox("Role", user.roleProperty());

    form.add(userNameLabel, 0, 0);
    form.add(userNameTextBox, 1, 0);
    form.add(passwordLabel, 0, 1);
    form.add(passwordBox, 1, 1);
    form.add(confirmPasswordLabel, 0, 2);
    form.add(confirmPasswordBox, 1, 2);
    form.add(roleLabel, 0, 3);
    form.add(roleChoiceBox, 1, 3);

    main.getChildren().addAll(form);

    final HBox buttons = new HBox(ViewLayout.H_SPACE);
    buttons.setTranslateY(32);
    final Button updateButton = new Button("Update");
    updateButton.getStyleClass().add("submit-button");
    main.getChildren().addAll(buttons);

    updateButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent e) {

            if (Validator.validateUserData(user)) {

              ServiceManager.getUserDetailsService(user, PersistType.UPDATE).restart();
            }
          }
        });
    buttons.getChildren().addAll(updateButton);

    tab.setContent(ControlsUtil.makeScrollable(main));
    getTabs().add(tab);
  }
  @Override
  public Node showView() {

    Tab tab = new Tab("View Heat CHart : Search");

    try {
      VBox main = ViewLayout.getMainVBox("View Heat Chart", "Details");

      final ObservableList<HeatChartMaster> mailboxData = FXCollections.observableArrayList();
      main.getChildren()
          .addAll(SearchBoxUtil.getHeatChartSearchBox("Heat Chart Number", mailboxData));

      final TableView<HeatChartMaster> tableMailbox = TableUtil.createSearchHeatChartTable();

      main.getChildren().add(ControlsUtil.makeScrollable(tableMailbox));

      tableMailbox.setItems(mailboxData);

      tableMailbox.setOnMouseClicked(
          new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent mouseEvent) {

              if (mouseEvent.getClickCount() == 2) {

                HeatChartMaster selHeatChart = tableMailbox.getSelectionModel().getSelectedItem();
                if (selHeatChart != null) {

                  createViewTab(selHeatChart);
                }
              }
            }
          });

      EventHandler<ActionEvent> viewHeatChartEventHandler =
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent e) {

              HeatChartMaster heatChart = tableMailbox.getSelectionModel().getSelectedItem();
              if (heatChart != null) {

                createViewTab(heatChart);
              }
            }
          };

      tableMailbox.setContextMenu(
          TableContextMenu.getViewHeatChartContextMenu(viewHeatChartEventHandler));

      tab.setContent(ControlsUtil.makeScrollable(main));
      tab.setClosable(false);
      pane.getTabs().add(tab);
      pane.setSide(Side.TOP);

      return pane;
    } catch (HibernateException e) {
      LoggerUtil.getLogger().debug(e);
      Alert.showAlert(
          Context.getWindowStage(),
          "Error",
          "Error",
          "Some error occured. Details...\n" + e.getMessage());

      return new ErrorView().showView();
    } catch (MalformedURLException ex) {
      LoggerUtil.getLogger().debug(ex);
      Alert.showAlert(
          Context.getWindowStage(),
          "Error",
          "Error",
          "Some error occured. Details...\n" + ex.getMessage());

      return new ErrorView().showView();
    }
  }
Пример #23
0
 /**
  * Set content for floating tab
  *
  * @param value
  */
 public void setFloatingTab(Node value) {
   assert value != null;
   floatingTab.setContent(value);
 }
Пример #24
0
  public void openFileInEditor(Resource resource, MediaType mediaType)
      throws IllegalArgumentException {
    if (!isTabAlreadyOpen(resource)) {
      Tab tab = new Tab();
      tab.setClosable(true);
      if (resource == null) {
        Dialogs.create()
            .owner(tabPane)
            .title("Datei nicht vorhanden")
            .message(
                "Die angeforderte Datei ist nicht vorhanden und kann deshalb nicht geöffnet werden.")
            .showError();
        return;
      }
      tab.setText(resource.getFileName());
      resource
          .hrefProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                tab.setText(resource.getFileName());
              });

      String content = "";
      try {
        content = new String(resource.getData(), resource.getInputEncoding());
      } catch (IOException e) {
        logger.error("", e);
      }

      CodeEditor editor;
      if (mediaType.equals(MediaType.CSS)) {
        editor = new CssCodeEditor();
        editor.setContextMenu(contextMenuCSS);
      } else if (mediaType.equals(MediaType.XHTML)) {
        editor = new XHTMLCodeEditor();
        editor.setContextMenu(contextMenuXHTML);
      } else if (mediaType.equals(MediaType.XML)) {
        editor = new XMLCodeEditor();
        editor.setContextMenu(contextMenuXML);
      } else {
        throw new IllegalArgumentException("no editor for mediatype " + mediaType.getName());
      }

      tab.setContent((Node) editor);
      tab.setUserData(resource);
      tabPane.getTabs().add(tab);
      tabPane.getSelectionModel().select(tab);

      final String code = content;
      editor
          .stateProperty()
          .addListener(
              new ChangeListener<Worker.State>() {
                @Override
                public void changed(
                    ObservableValue<? extends Worker.State> observable,
                    Worker.State oldValue,
                    Worker.State newValue) {
                  if (newValue.equals(Worker.State.SUCCEEDED)) {
                    openingEditorTab = true;
                    editor.setCode(code);
                    editor.setCodeEditorSize(
                        ((AnchorPane) editor).getWidth() - 20,
                        ((AnchorPane) editor).getHeight() - 20);
                    ((AnchorPane) editor)
                        .widthProperty()
                        .addListener(
                            new ChangeListener<Number>() {
                              @Override
                              public void changed(
                                  ObservableValue<? extends Number> observable,
                                  Number oldValue,
                                  Number newValue) {
                                editor.setCodeEditorSize(
                                    newValue.doubleValue() - 20,
                                    ((AnchorPane) editor).getHeight() - 20);
                              }
                            });
                    ((AnchorPane) editor)
                        .heightProperty()
                        .addListener(
                            new ChangeListener<Number>() {
                              @Override
                              public void changed(
                                  ObservableValue<? extends Number> observable,
                                  Number oldValue,
                                  Number newValue) {
                                editor.setCodeEditorSize(
                                    ((AnchorPane) editor).getWidth() - 20,
                                    newValue.doubleValue() - 20);
                              }
                            });
                    editor.setCodeEditorSize(
                        ((AnchorPane) editor).getWidth() - 20,
                        ((AnchorPane) editor).getHeight() - 20);
                    ((AnchorPane) editor)
                        .widthProperty()
                        .addListener(
                            new ChangeListener<Number>() {
                              @Override
                              public void changed(
                                  ObservableValue<? extends Number> observable,
                                  Number oldValue,
                                  Number newValue) {
                                editor.setCodeEditorSize(
                                    newValue.doubleValue() - 20,
                                    ((AnchorPane) editor).getHeight() - 20);
                              }
                            });
                    ((AnchorPane) editor)
                        .heightProperty()
                        .addListener(
                            new ChangeListener<Number>() {
                              @Override
                              public void changed(
                                  ObservableValue<? extends Number> observable,
                                  Number oldValue,
                                  Number newValue) {
                                editor.setCodeEditorSize(
                                    ((AnchorPane) editor).getWidth() - 20,
                                    newValue.doubleValue() - 20);
                              }
                            });
                    openingEditorTab = false;
                  }
                }
              });

      editor
          .cursorPositionProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                cursorPosLabelProperty.set(newValue.getLine() + ":" + newValue.getColumn());
              });

      editor
          .codeProperty()
          .addListener(
              (observable1, oldValue, newValue) -> {
                if (openingEditorTab) {
                  return;
                }
                if (currentEditor.getValue().getMediaType().equals(MediaType.XHTML)) {
                  try {
                    currentXHTMLResource.get().setData(newValue.getBytes("UTF-8"));
                  } catch (UnsupportedEncodingException e) {
                    // never happens
                  }
                } else if (currentEditor.getValue().getMediaType().equals(MediaType.CSS)) {
                  try {
                    currentCssResource.get().setData(newValue.getBytes("UTF-8"));
                  } catch (UnsupportedEncodingException e) {
                    // never happens
                  }
                } else if (currentEditor.getValue().getMediaType().equals(MediaType.XML)) {
                  try {
                    currentXMLResource.get().setData(newValue.getBytes("UTF-8"));
                    if (((XMLResource) resource).isValidXML()
                        && MediaType.OPF.equals(resource.getMediaType())) {
                      PackageDocumentReader.read(resource, book);
                    }
                  } catch (JDOMException | IOException e) {
                    logger.error("", e);
                  }
                }

                if (scheduledService.getState().equals(Worker.State.READY)) {
                  scheduledService.start();
                } else {
                  scheduledService.restart();
                }
                book.setBookIsChanged(true);
              });
    }
  }
Пример #25
0
 /**
  * Set content for overdue tab
  *
  * @param value
  */
 public void setOverdueTab(Node value) {
   assert value != null;
   overdueTab.setContent(value);
 }
  private void createViewTab(final HeatChartMaster heatChart) {

    for (Tab selTab : pane.getTabs()) {
      if (selTab.getId() != null && selTab.getId().equalsIgnoreCase(heatChart.getChartNumber())) {
        pane.getSelectionModel().select(selTab);
        return;
      }
    }

    Tab tab = new Tab("View Heat Chart : " + heatChart.getChartNumber());
    tab.setId(heatChart.getChartNumber());

    VBox main = ViewLayout.getMainVBox("Heat Chart", "Details");

    GridPane form = new GridPane();
    form.setHgap(ViewLayout.H_SPACE);
    form.setVgap(ViewLayout.V_SPACE);

    Label equipmentLabel = new Label("Equipment");
    equipmentLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final ViewBox equipmentTextField = new ViewBox("Equipment", heatChart.equipmentProperty());

    Label customerLabel = new Label("Customer");
    customerLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final ViewBox customerTextField = new ViewBox("Customer", heatChart.customerProperty());

    Label poDetailsLabel = new Label("PO Details");
    poDetailsLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final ViewBox poDetailsTextField = new ViewBox("PO Details", heatChart.poDetailsProperty());

    Label drawingLabel = new Label("Drawing No.");
    drawingLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final ViewBox drawingTextField = new ViewBox("Drawing No.", heatChart.drawingNumberProperty());

    Label suryeyorLabel = new Label("Surveyor");
    suryeyorLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final ViewBox suryeyorTextField = new ViewBox("Suryeyor", heatChart.surveyorProperty());

    Label tagNumberLabel = new Label("Tag Number");
    suryeyorLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);

    final ViewBox tagNumberTextField = new ViewBox("Tag Number", heatChart.tagNumberProperty());

    form.add(equipmentLabel, 0, 0);
    form.add(equipmentTextField, 1, 0);
    form.add(customerLabel, 2, 0);
    form.add(customerTextField, 3, 0);
    form.add(poDetailsLabel, 4, 0);
    form.add(poDetailsTextField, 5, 0);
    form.add(drawingLabel, 0, 1);
    form.add(drawingTextField, 1, 1);
    form.add(suryeyorLabel, 2, 1);
    form.add(suryeyorTextField, 3, 1);
    form.add(tagNumberLabel, 4, 1);
    form.add(tagNumberTextField, 5, 1);

    main.getChildren().addAll(form);

    final ObservableList<HeatChartSheets> data = FXCollections.observableArrayList();

    TableView<HeatChartSheets> table = TableUtil.createViewHeatChartSheetTable();

    data.setAll(heatChart.getHeatChartSheets());
    table.setItems(data);

    main.getChildren().addAll(ControlsUtil.makeScrollable(table));

    final HBox buttons = new HBox(ViewLayout.H_SPACE);
    buttons.setTranslateY(32);
    final Button printButton = new Button("Print");
    printButton.getStyleClass().add("submit-button");
    buttons.getChildren().addAll(printButton);

    main.getChildren().addAll(buttons);

    printButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent e) {

            printHeatChart.setHeatChart(heatChart);
            printHeatChart.restart();
          }
        });

    Context.getWindowBottomText()
        .textProperty()
        .bind(Bindings.format("%s", printHeatChart.stateProperty()));

    printHeatChart
        .stateProperty()
        .addListener(
            new ChangeListener<Worker.State>() {

              @Override
              public void changed(
                  ObservableValue<? extends Worker.State> observable,
                  Worker.State oldValue,
                  Worker.State newState) {

                if (newState == Worker.State.SUCCEEDED) {
                  Alert.showAlert(
                      Context.getWindowStage(),
                      "Alert",
                      "Alert",
                      "The report has been saved as " + printHeatChart.getValue());
                  Context.getHostServices().showDocument(printHeatChart.getValue());
                } else if (newState == Worker.State.FAILED) {
                  Alert.showAlert(
                      Context.getWindowStage(),
                      "Error",
                      "Error",
                      "Some error cooured. Details : " + printHeatChart.getException().getCause());
                }
              }
            });

    tab.setContent(ControlsUtil.makeScrollable(main));
    pane.getTabs().add(tab);
  }
Пример #27
0
  public EditUser() {

    Tab tab = new Tab("Edit User : Details");

    try {
      VBox main = ViewLayout.getMainVBox("Edit User", "Details");

      final TableView<UserMaster> table = TableUtil.createEditUserTable();

      main.getChildren().add(table);

      final ObservableList<UserMaster> mailboxData =
          FXCollections.observableArrayList(UserData.getUserList());

      table.setItems(mailboxData);

      EventHandler<ActionEvent> editUserEventHandler =
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {

              UserMaster user = table.getSelectionModel().getSelectedItem();
              if (user != null) {

                createEditTab(user);
              }
            }
          };

      EventHandler<ActionEvent> deleteUserEventHandler =
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {

              final UserMaster user = table.getSelectionModel().getSelectedItem();

              EventHandler<ActionEvent> delUserEvent =
                  new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent arg0) {

                      PersistUserDetails pud =
                          ServiceManager.getUserDetailsService(user, PersistType.DELETE);

                      pud.restart();

                      pud.setOnSucceeded(
                          new EventHandler<WorkerStateEvent>() {

                            @Override
                            public void handle(WorkerStateEvent e) {

                              mailboxData.remove(user);
                            }
                          });
                    }
                  };

              Confirm.showConfirm(
                  Context.getWindowStage(),
                  "Confirm",
                  "Confirm",
                  "Delete User : "******". Are you sure?",
                  delUserEvent);
            }
          };

      table.setContextMenu(
          TableContextMenu.getEditUserContextMenu(editUserEventHandler, deleteUserEventHandler));

      table.setOnMouseClicked(
          new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent mouseEvent) {

              if (mouseEvent.getClickCount() == 2) {

                UserMaster user = table.getSelectionModel().getSelectedItem();

                if (user != null) {
                  createEditTab(user);
                }
              }
            }
          });

      tab.setContent(ControlsUtil.makeScrollable(main));
      tab.setClosable(false);
      getTabs().add(tab);
      setSide(Side.TOP);
    } catch (Exception e) {
      LoggerUtil.getLogger().debug(e);
      Alert.showAlert(
          Context.getWindowStage(),
          "Error",
          "Error",
          "Some error occured. Details...\n" + e.getMessage());
    }
  }
  private void loadTabs() {
    tabPane.getTabs().clear();
    try {
      FXMLLoader customerTabLoader = new FXMLLoader(getClass().getResource("A-CustomersTab.fxml"));
      Parent custroot = (Parent) customerTabLoader.load();
      customerTabController = customerTabLoader.<ACustomerInfoTabController>getController();
      customersTab = new Tab();
      customersTab.setText("Customers");
      customersTab.setContent(custroot);

      hawkerTab = new Tab();
      FXMLLoader hawkerTabLoader = new FXMLLoader(getClass().getResource("A-HawkerInfoTab.fxml"));
      Parent hawkerroot = (Parent) hawkerTabLoader.load();
      hawkerTabController = hawkerTabLoader.<AHawkerInfoTabController>getController();
      hawkerTab.setText("Hawkers");
      hawkerTab.setContent(hawkerroot);

      hawkerTab.setOnSelectionChanged(
          new EventHandler<Event>() {

            @Override
            public void handle(Event event) {

              hawkerTabController.reloadData();
            }
          });

      lineInfoTab = new Tab();
      FXMLLoader lineInfoTabLoader = new FXMLLoader(getClass().getResource("A-LineInfoTab.fxml"));
      Parent lineinforoot = (Parent) lineInfoTabLoader.load();
      lineInfoTabController = lineInfoTabLoader.<ALineInfoTabController>getController();
      lineInfoTab.setText("Line Information");
      lineInfoTab.setContent(lineinforoot);

      lineDistTab = new Tab();
      FXMLLoader lineDistTabLoader =
          new FXMLLoader(getClass().getResource("A-LineDistributorTab.fxml"));
      Parent linedistroot = (Parent) lineDistTabLoader.load();
      lineDistTabController = lineDistTabLoader.<ALineDistributorTabController>getController();
      lineDistTab.setText("Line Distribution Boy");
      lineDistTab.setContent(linedistroot);

      additionalItemsTab = new Tab();
      FXMLLoader additionalItemsTabLoader =
          new FXMLLoader(getClass().getResource("AdditionalItems.fxml"));
      Parent additionalItemsRoot = (Parent) additionalItemsTabLoader.load();
      additionalItemsTabController =
          additionalItemsTabLoader.<AdditionalItemsController>getController();
      additionalItemsTab.setText("Additional Items");
      additionalItemsTab.setContent(additionalItemsRoot);

      productsTab = new Tab();
      FXMLLoader productsTabLoader = new FXMLLoader(getClass().getResource("AProductsTab.fxml"));
      Parent productsRoot = (Parent) productsTabLoader.load();
      productsTabController = productsTabLoader.<AProductsTabController>getController();
      productsTab.setText("Products");
      productsTab.setContent(productsRoot);

      pausedCustTab = new Tab();
      FXMLLoader pausedCustTabLoader =
          new FXMLLoader(getClass().getResource("A-PausedCustomersTab.fxml"));
      Parent pausedcustroot = (Parent) pausedCustTabLoader.load();
      pausedCustTabController = pausedCustTabLoader.<APausedCustomerTabController>getController();
      pausedCustTab.setText("Stopped Customers");
      pausedCustTab.setContent(pausedcustroot);

      stopHistoryTab = new Tab();
      FXMLLoader stopHistTabLoader = new FXMLLoader(getClass().getResource("AStopHistoryTab.fxml"));
      Parent stopHistRoot = (Parent) stopHistTabLoader.load();
      stopHistTabController = stopHistTabLoader.<AStopHistoryTabController>getController();
      stopHistoryTab.setText("Stop History");
      stopHistoryTab.setContent(stopHistRoot);

      tabPane
          .getTabs()
          .addAll(
              hawkerTab,
              lineInfoTab,
              customersTab,
              lineDistTab,
              productsTab,
              additionalItemsTab,
              pausedCustTab,
              stopHistoryTab);
    } catch (IOException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
  }
  public void createAgencyTab() {

    Tab agencyTab = new Tab("Agency");
    final AgencyProperty agency = new AgencyProperty();

    VBox main = ViewLayout.getMainVBox("Add Agency", "Details");

    GridPane agencyForm = new GridPane();
    agencyForm.setHgap(ViewLayout.H_SPACE);
    agencyForm.setVgap(ViewLayout.V_SPACE);

    Label agencyCodeLabel = new Label("Agency Code");
    agencyCodeLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);
    final ViewIntegerBox agencyCodeBox =
        new ViewIntegerBox(agency.get().getAgencyCode(), agency.get().agencyCodeProperty());

    Label agencyNameLabel = new Label("Agency Name");
    agencyNameLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);
    final AgencyComboBox agencyNameBox = new AgencyComboBox("Agency Name", agency);

    Label agencyRemarksLabel = new Label("Remarks");
    agencyRemarksLabel.setPrefWidth(ViewLayout.LABEL_WIDTH);
    final TextBox agencyRemarksTextBox = new TextBox("Remarks", agency.get().remarksProperty());

    Button agencyButton = new Button("Submit");
    agencyButton.getStyleClass().add("submit-button");
    agencyButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent e) {

            if (agencyNameBox.getText().trim().length() > 0) {
              if (agencyRemarksTextBox.getText().trim().length() == 0) {
                agency.get().setRemarks(agency.get().getAgencyName());
              }

              PersistValidationDetails pvd =
                  ServiceManager.getValidationDetailsService(
                      "Agency", agency.get(), PersistType.UPDATE);

              pvd.restart();

              pvd.setOnSucceeded(
                  new EventHandler<WorkerStateEvent>() {

                    @Override
                    public void handle(WorkerStateEvent e) {

                      agency.get().clean();
                    }
                  });
            } else {
              Alert.showAlert(
                  Context.getWindowStage(), "Error", "Error", "Please enter agency name.");
            }
          }
        });

    agencyForm.add(agencyCodeLabel, 0, 0);
    agencyForm.add(agencyCodeBox, 1, 0);
    agencyForm.add(agencyNameLabel, 0, 1);
    agencyForm.add(agencyNameBox, 1, 1);
    agencyForm.add(agencyRemarksLabel, 0, 2);
    agencyForm.add(agencyRemarksTextBox, 1, 2);
    agencyForm.add(agencyButton, 1, 3);

    main.getChildren().add(agencyForm);

    agencyTab.setContent(ControlsUtil.makeScrollable(main));
    agencyTab.setClosable(false);
    getTabs().add(agencyTab);
  }
Пример #30
-1
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX layouts samples");

    Tab hboxTab = new Tab();
    hboxTab.setText("HBox");
    hboxTab.setClosable(false);
    hboxLayout.setBackground(createBackground(Color.LIGHTGREEN));
    hboxTab.setContent(hboxLayout);

    Tab vboxTab = new Tab();
    vboxTab.setText("VBox");
    vboxTab.setClosable(false);
    vboxLayout.setBackground(createBackground(Color.ORANGE));
    vboxTab.setContent(vboxLayout);

    Tab flowPaneTab = new Tab();
    flowPaneTab.setText("FlowPane");
    flowPaneTab.setClosable(false);
    flowLayout.setBackground(createBackground(Color.LIGHTSKYBLUE));
    flowPaneTab.setContent(flowLayout);

    Tab gridPaneTab = new Tab("GridPane");
    gridPaneTab.setClosable(false);
    gridLayout.setBackground(createBackground(Color.LIGHTCORAL));
    gridLayout.setGridLinesVisible(true);
    gridPaneTab.setContent(gridLayout);

    Tab borderPaneTab = new Tab();
    borderPaneTab.setText("BorderPane");
    borderPaneTab.setClosable(false);
    borderLayout.setBackground(createBackground(Color.LIGHTYELLOW));
    borderPaneTab.setContent(borderLayout);

    Tab stackPaneTab = new Tab();
    stackPaneTab.setText("StackPane");
    stackPaneTab.setClosable(false);
    stackLayout.setBackground(createBackground(Color.YELLOW));
    stackPaneTab.setContent(stackLayout);

    Tab tilePaneTab = new Tab("TilePane");
    tilePaneTab.setClosable(false);
    tileLayout.setBackground(createBackground(Color.LIGHTGOLDENRODYELLOW));
    tilePaneTab.setContent(tileLayout);

    updateChildren(false);
    TabPane tabPane = new TabPane();
    tabPane
        .getTabs()
        .addAll(
            hboxTab, vboxTab, flowPaneTab, gridPaneTab, borderPaneTab, stackPaneTab, tilePaneTab);

    VBox optionsPanel = new VBox();
    CheckBox componentType = new CheckBox("Use Buttons instead of Rectangles");
    componentType
        .selectedProperty()
        .addListener((observable, oldValue, newValue) -> updateChildren(newValue));
    optionsPanel.getChildren().add(componentType);
    optionsPanel.setPadding(new Insets(10));

    BorderPane mainLayout = new BorderPane();
    mainLayout.setCenter(tabPane);
    mainLayout.setLeft(optionsPanel);

    // show the generated scene graph
    Scene scene = new Scene(mainLayout);
    primaryStage.setScene(scene);
    primaryStage.show();
  }