Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
  private void updateTabTitle() {
    final HBox title = new HBox();
    title.setAlignment(Pos.CENTER);

    if (isAutoRefresh()) {
      final ProgressIndicator progressIndicator = new ProgressIndicator();
      progressIndicator.setMaxSize(15, 15);
      title.getChildren().add(progressIndicator);
      title.getChildren().add(new Label(" "));
    }

    // If the search value is too long, show only a substring
    final String searchValue =
        searchField.getText().length() > MAX_SEARCH_VALUE_CHARACTERS
            ? searchField.getText().substring(0, MAX_SEARCH_VALUE_CHARACTERS) + "..."
            : searchField.getText();

    title
        .getChildren()
        .add(
            new Label(
                "Search: \""
                    + searchValue
                    + "\""
                    + " ["
                    + foundMessages.size()
                    + " found / "
                    + seachedCount
                    + " searched]"));

    tab.setText(null);
    tab.setGraphic(title);
  }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
  public void setTabTitles() {

    for (Tab t : myTabPane.getTabs()) {

      t.setText("Work Space " + String.valueOf(numTabs + 1));

      numTabs++;
    }
  }
  @FXML
  public void HandleSaveButtonAction(ActionEvent event) {
    extract.setMarkdown(SourceText.getText());
    extract.save();
    tab.setText(extract.getTitle());
    this.isSaved = true;

    SourceText.requestFocus();
  }
Exemplo n.º 6
0
  @Override
  public void setModified(EditorPane pane, boolean isModified) {
    for (Tab tab : tabPane.getTabs()) {
      EditorPane currentPane = (EditorPane) tab.getContent();

      if (currentPane == pane) {
        String tabText = tab.getText();

        if (isModified) {
          if (!tabText.endsWith(S_ASTERISK)) {
            tab.setText(tabText + S_ASTERISK);
          }
        } else {
          if (tabText.endsWith(S_ASTERISK)) {
            tab.setText(tabText.substring(0, tabText.length() - 1));
          }
        }
      }
    }
  }
Exemplo n.º 7
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();
  }
Exemplo n.º 8
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();
  }
  public void createScene() {

    // BorderPane borderPane = new BorderPane();

    // Placement of TabPane.
    setSide(Side.TOP);

    /*
     * To disable closing of tabs.
     * tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
     */

    final Tab newtab = new Tab();
    newtab.setText("+");
    newtab.setClosable(false);

    // Addition of New Tab to the tabpane.
    getTabs().addAll(newtab);

    Platform.runLater(
        () -> {
          Tab t = new Tab();
          try {
            t = new ScriptingGistTab("Tutorial", getHomeUrl(), true);
          } catch (IOException | InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
          Tab tab = t;
          final ObservableList<Tab> tabs = getTabs();
          ConnectionManager.getConnectionManager().setClosable(false);
          int index = tabs.size() - 1;
          // new RuntimeException().printStackTrace();
          tabs.add(index, ConnectionManager.getConnectionManager());
          setSelectedTab(ConnectionManager.getConnectionManager());

          tab.setClosable(false);
          index = tabs.size() - 1;
          // new RuntimeException().printStackTrace();
          tabs.add(index, tab);
          setSelectedTab(tab);
        });

    // Function to add and display new tabs with default URL display.
    getSelectionModel()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<Tab>() {
              @Override
              public void changed(
                  ObservableValue<? extends Tab> observable,
                  Tab oldSelectedTab,
                  Tab newSelectedTab) {
                if (newSelectedTab == newtab) {

                  try {
                    addTab(createTab(), true);

                  } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }
                }
              }
            });
  }
Exemplo n.º 10
0
  public MasterGUI(Stage stage) {
    parentStage = stage;

    // JsonHelpExtractor ujextractor = new JsonHelpExtractor();
    // HashMap<String,String> dataSetTab_tooltipHelp =
    // ujextractor.extractToolTipFile("TestJson.json");
    // HashMap<String, ExtensiveHelp> dataSetTab_extensiveHelp =
    // ujextractor.extractExtensiveHelpFile("DataSetExtensiveHelp.json");
    // final HelpDataStore dataSetTab_HelpStore = new
    // HelpDataStore("DataSetTab",dataSetTab_tooltipHelp,dataSetTab_extensiveHelp);

    // ujextractor.writeExtensiveHelpFile("C:\\Users\\user\\Desktop\\ExtensiveSectionTest.json");

    experiment = new Experiment();

    tabPane = new TabPane();
    final Tab tab1 = new DataSetTab(parentStage, experiment);
    tab1.setText("Dataset");

    final Tab tab2 = new PreprocessingTab(parentStage, experiment);
    tab2.setText("Preprocessing");

    final Tab tab3 = new FeatureSelectionTab(parentStage, experiment);
    tab3.setText("Feature Selection");

    final Tab tab4 = new AlgorithmTab(parentStage, experiment);
    tab4.setText("Preference Learning Methods");

    tabPane.tabClosingPolicyProperty().set(TabPane.TabClosingPolicy.UNAVAILABLE);
    tabPane.getTabs().addAll(tab1, tab2, tab3, tab4);

    BorderPane bottomPane = new BorderPane();

    final Button btnBack = new Button();
    btnBack.setPrefSize(200, 20);
    btnBack.setVisible(false);
    Label lblBackBtn = new Label("BACK");
    ImageView imgViewBkBtn =
        new ImageView(new Image(DataSetTab.class.getResourceAsStream("bkButton.png")));
    BorderPane backBtnInnerBPane = new BorderPane();
    backBtnInnerBPane.setLeft(imgViewBkBtn);
    backBtnInnerBPane.setCenter(lblBackBtn);
    btnBack.setGraphic(backBtnInnerBPane);

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

          @Override
          public void handle(ActionEvent t) {

            if (tabPane.getSelectionModel().getSelectedIndex() > 0) {
              tabPane
                  .selectionModelProperty()
                  .get()
                  .select(tabPane.selectionModelProperty().get().getSelectedIndex() - 1);
            }
          }
        });

    final Button btnNext = new Button();
    btnNext.setPrefSize(200, 20);
    Label lblNextBtn = new Label("NEXT");
    ImageView imgViewNextBtn =
        new ImageView(new Image(DataSetTab.class.getResourceAsStream("nxtButton.png")));
    BorderPane nextBtnInnerBPane = new BorderPane();
    nextBtnInnerBPane.setCenter(lblNextBtn);
    nextBtnInnerBPane.setRight(imgViewNextBtn);
    btnNext.setGraphic(nextBtnInnerBPane);

    btnNext.disableProperty().bind(this.experiment.isReadyToUseDataSetProperty().not());

    tabPane.selectionModelProperty();

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

          @Override
          public void handle(ActionEvent t) {

            if (!tab4.selectedProperty().get()) {
              tabPane
                  .selectionModelProperty()
                  .get()
                  .select(tabPane.selectionModelProperty().get().getSelectedIndex() + 1);
            } else if (tab4.selectedProperty().get()) {
              // Perform safety checks.
              boolean allClear = true;

              int numOfIgnoredFeatures = 0;
              boolean[] tmpIgArr = experiment.ignoredFeaturesProperty().get();
              for (int i = 0; i < tmpIgArr.length; i++) {
                if (tmpIgArr[i]) {
                  numOfIgnoredFeatures++;
                }
              }

              if (numOfIgnoredFeatures
                  == experiment.dataSetProperty().get().getNumberOfFeatures()) {
                // You must include at least one feature.

                ModalPopup notification = new ModalPopup();
                notification.show(
                    new Label("ERROR: You must include at least one feature from the dataset."),
                    parentStage.getScene().getRoot(),
                    null,
                    new Button("OK"),
                    200,
                    550,
                    false);

                allClear = false;
              } else if (experiment.featureSelectionProperty().get() != null) {
                if (experiment.featureSelectionProperty().get() instanceof NBest) {
                  NBest castNBest = (NBest) experiment.featureSelectionProperty().get();

                  int numOfUserIncludedFeatures =
                      (experiment.dataSetProperty().get().getNumberOfFeatures()
                          - numOfIgnoredFeatures);

                  if (castNBest.getN() > numOfUserIncludedFeatures) {
                    // N val should always be less than or equal to the number of user included
                    // features.

                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "ERROR: N-Best N value cannot be greater than the number of included features. \n Current N Value = "
                                + castNBest.getN()
                                + " \n Current Num of Included Features = "
                                + numOfUserIncludedFeatures),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        600,
                        false);

                    allClear = false;
                  }
                }

                if (experiment.algorithmForFeatureSelectionProperty().get() == null) {
                  // You cannot select a feature selection type without stating an algorithm.

                  ModalPopup notification = new ModalPopup();
                  notification.show(
                      new Label(
                          "ERROR: You must state an algorithm to work with "
                              + experiment.featureSelectionProperty().get().getFSelName()
                              + "."),
                      parentStage.getScene().getRoot(),
                      null,
                      new Button("OK"),
                      200,
                      550,
                      false);

                  allClear = false;
                }
              }

              if (experiment.algorithmForFeatureSelectionProperty().get() != null) {
                if (experiment.algorithmForFeatureSelectionProperty().get()
                    instanceof PLNeuroEvolution) {
                  PLNeuroEvolution castPLNE =
                      (PLNeuroEvolution) experiment.algorithmForFeatureSelectionProperty().get();
                  PLNeuroEvolutionConfigurator neConfig = castPLNE.getConfigurator();
                  GeneticAlgorithmConfigurator gaConfig =
                      neConfig.getGeneticAlgorithmConfigurator();

                  if (gaConfig.getNumberOfParents() > gaConfig.getPopulationSize()) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "GA ERROR: The number of parents is greater than the GA population size."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }

                  if (gaConfig.getElitSize() > gaConfig.getPopulationSize()) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "GA ERROR: The elitism size is greater than the GA population size."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }
                }

                if (experiment.algorithmProperty().get() instanceof PLRankSvm) {
                  PLRankSvm castPLRS = (PLRankSvm) experiment.algorithmProperty().get();
                  PLRankSvmConfigurator svmConfig = castPLRS.getConfigurator();

                  if ((svmConfig.gammaRequired()) && (svmConfig.getGamma() == 0)) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label("SVM ERROR: Gamma cannot be set to 0."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }

                  if (svmConfig.degreeRequired()) {
                    try {
                      Integer.parseInt(svmConfig.getDegreeTextboxContents());
                    } catch (Exception NumberFormatException) {
                      ModalPopup notification = new ModalPopup();
                      notification.show(
                          new Label(
                              "SVM ERROR: Invalid Degree value \\"
                                  + svmConfig.getDegreeTextboxContents()
                                  + "\\"
                                  + "."),
                          parentStage.getScene().getRoot(),
                          null,
                          new Button("OK"),
                          200,
                          550,
                          false);

                      allClear = false;
                    }
                  }

                  if (svmConfig.betaRequired()) {
                    try {
                      Integer.parseInt(svmConfig.getBetaTextboxContents());
                    } catch (Exception NumberFormatException) {
                      ModalPopup notification = new ModalPopup();
                      notification.show(
                          new Label(
                              "SVM ERROR: Invalid Beta value \\"
                                  + svmConfig.getBetaTextboxContents()
                                  + "\\"
                                  + "."),
                          parentStage.getScene().getRoot(),
                          null,
                          new Button("OK"),
                          200,
                          550,
                          false);

                      allClear = false;
                    }
                  }
                }
              }

              if (experiment.algorithmProperty().get() instanceof PLNeuroEvolution) {
                PLNeuroEvolution castPLNE = (PLNeuroEvolution) experiment.algorithmProperty().get();
                PLNeuroEvolutionConfigurator neConfig = castPLNE.getConfigurator();
                GeneticAlgorithmConfigurator gaConfig = neConfig.getGeneticAlgorithmConfigurator();

                int numParents = gaConfig.getNumberOfParents();
                int popSize = gaConfig.getPopulationSize();
                if (numParents > popSize) {
                  ModalPopup notification = new ModalPopup();
                  notification.show(
                      new Label(
                          "GA ERROR: The number of parents is greater than the GA population size."),
                      parentStage.getScene().getRoot(),
                      null,
                      new Button("OK"),
                      200,
                      550,
                      false);

                  allClear = false;
                }

                if (gaConfig.getElitSize() > gaConfig.getPopulationSize()) {
                  ModalPopup notification = new ModalPopup();
                  notification.show(
                      new Label(
                          "GA ERROR: The elitism size is greater than the GA population size."),
                      parentStage.getScene().getRoot(),
                      null,
                      new Button("OK"),
                      200,
                      550,
                      false);

                  allClear = false;
                }
              }

              if (experiment.algorithmProperty().get() instanceof PLRankSvm) {
                PLRankSvm castPLRS = (PLRankSvm) experiment.algorithmProperty().get();
                PLRankSvmConfigurator svmConfig = castPLRS.getConfigurator();

                if ((svmConfig.gammaRequired()) && (svmConfig.getGamma() == 0)) {
                  ModalPopup notification = new ModalPopup();
                  notification.show(
                      new Label("SVM ERROR: Gamma cannot be set to 0."),
                      parentStage.getScene().getRoot(),
                      null,
                      new Button("OK"),
                      200,
                      550,
                      false);

                  allClear = false;
                }

                if (svmConfig.degreeRequired()) {
                  try {
                    Integer.parseInt(svmConfig.getDegreeTextboxContents());
                  } catch (Exception NumberFormatException) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "SVM ERROR: Invalid Degree value \\"
                                + svmConfig.getDegreeTextboxContents()
                                + "\\"
                                + "."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }
                }

                if (svmConfig.betaRequired()) {
                  try {
                    Integer.parseInt(svmConfig.getBetaTextboxContents());
                  } catch (Exception NumberFormatException) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "SVM ERROR: Invalid Beta value \\"
                                + svmConfig.getBetaTextboxContents()
                                + "\\"
                                + "."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }
                }
              }

              if (allClear) {
                Execution e = new Execution(experiment);
                e.show(parentStage);
              }
            }
          }
        });

    tab4.selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                if (t1) {

                  Label lblNextBtn = new Label("RUN EXPERIMENT");
                  ImageView imgViewNextBtn =
                      new ImageView(
                          new Image(
                              DataSetTab.class.getResourceAsStream("runExperimentButton.png")));
                  BorderPane nextBtnInnerBPane = new BorderPane();
                  nextBtnInnerBPane.setCenter(lblNextBtn);
                  nextBtnInnerBPane.setRight(imgViewNextBtn);
                  btnNext.setGraphic(nextBtnInnerBPane);
                } else {
                  Label lblNextBtn = new Label("NEXT");
                  ImageView imgViewNextBtn =
                      new ImageView(
                          new Image(DataSetTab.class.getResourceAsStream("nxtButton.png")));
                  BorderPane nextBtnInnerBPane = new BorderPane();
                  nextBtnInnerBPane.setCenter(lblNextBtn);
                  nextBtnInnerBPane.setRight(imgViewNextBtn);
                  btnNext.setGraphic(nextBtnInnerBPane);
                }
              }
            });

    tab1.selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {

                if (t1) {
                  btnBack.setVisible(false);
                  btnNext.setVisible(true);
                } else {
                  btnBack.setVisible(true);
                }
              }
            });

    Button helpButton = new Button();
    helpButton.setVisible(true);
    helpButton.setGraphic(
        new ImageView(new Image(DataSetTab.class.getResourceAsStream("helpButton.png"))));
    helpButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent t) {
            if (tab1.selectedProperty().get()) {
              Tab1Help h = new Tab1Help();
              h.show(parentStage.getScene().getRoot(), null);
            } else if (tab2.selectedProperty().get()) {
              Tab2Help h = new Tab2Help();
              h.show(parentStage.getScene().getRoot(), null);
            } else if (tab3.selectedProperty().get()) {
              Tab3Help h = new Tab3Help();
              h.show(parentStage.getScene().getRoot(), null);
            } else if (tab4.selectedProperty().get()) {
              Tab4Help h = new Tab4Help();
              h.show(parentStage.getScene().getRoot(), null);
            }
          }
        });

    /*helpButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            if (tab1.selectedProperty().get()) {
                ArrayList<String> itemsToInclude = new ArrayList<String>();
                itemsToInclude.add("Loading a dataset");
                itemsToInclude.add("Button: Import Object File");
                itemsToInclude.add("Button: Import Ranking File");

                String reqHTML = dataSetTab_HelpStore.constructHtml(itemsToInclude);
                HelpPopup hPopup = new HelpPopup(reqHTML);
                hPopup.show(parentStage.getScene().getRoot(), null);

                //Tab1Help h = new Tab1Help();
                //h.show(parentStage.getScene().getRoot(), null);
            }

            if (tab2.selectedProperty().get()) {
                Tab2Help h = new Tab2Help();
                h.show(parentStage.getScene().getRoot(), null);
            }

        }
    });*/

    // helpButton.visibleProperty().bind(tab1.selectedProperty().or(tab2.selectedProperty()));

    HBox navBtnBox = new HBox(10);
    navBtnBox.getChildren().addAll(btnBack, btnNext);

    bottomPane.setPadding(new Insets(10, 10, 10, 10));
    bottomPane.setStyle("-fx-background-color: #336699;");
    bottomPane.setLeft(helpButton);
    bottomPane.setRight(navBtnBox);

    this.setCenter(tabPane);
    this.setBottom(bottomPane);

    disableTabs(new ArrayList<Integer>(Arrays.asList(1, 2, 3)));
  }
Exemplo n.º 11
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();
  }
  public void setMdBox(MdTextController mdBox, Textual extract, Tab tab) throws IOException {
    this.mainApp = mdBox.getMainApp();
    this.config = mainApp.getConfig();
    this.mdBox = mdBox;
    this.tab = tab;
    this.extract = extract;

    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(MainApp.class.getResource("fxml/Editor.fxml"));
    loader.load();

    if (mainApp.getConfig().getEditorToolbarView().equals("no")) {
      BoxEditor.setTop(null);
      BoxRender.setTop(null);
    }

    SourceText.setFont(new Font(config.getEditorFont(), config.getEditorFontsize()));
    SourceText.setStyle("-fx-font-family: \"" + config.getEditorFont() + "\";");
    SourceText.replaceText(extract.getMarkdown());
    SourceText.textProperty()
        .addListener(
            (observableValue, s, s2) -> {
              tab.setText("! " + extract.getTitle());
              this.isSaved = false;
              SourceText.getUndoManager().mark();
              updateRender();
            });
    updateRender();
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(S, SHORTCUT_DOWN), () -> HandleSaveButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(G, SHORTCUT_DOWN), () -> HandleBoldButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(I, SHORTCUT_DOWN), () -> HandleItalicButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(B, SHORTCUT_DOWN), () -> HandleBarredButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(K, SHORTCUT_DOWN), () -> HandleTouchButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(PLUS, SHORTCUT_DOWN), () -> HandleExpButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(EQUALS, SHORTCUT_DOWN), () -> HandleIndButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(E, SHORTCUT_DOWN), () -> HandleCenterButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(
            new KeyCodeCombination(D, SHORTCUT_DOWN, SHIFT_DOWN),
            () -> HandleRightButtonAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(SPACE, SHORTCUT_DOWN), () -> HandleUnbreakableAction(null));
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(L, SHORTCUT_DOWN), this::HandleGoToLineAction);
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(F, SHORTCUT_DOWN), this::HandleFindReplaceDialog);
    tab.getContent()
        .getScene()
        .getAccelerators()
        .put(new KeyCodeCombination(A, SHORTCUT_DOWN), () -> SourceText.selectAll());

    SourceText.requestFocus();
  }
Exemplo n.º 13
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);
              });
    }
  }
  /*
   * 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);
  }
  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();
    }
  }
Exemplo n.º 16
0
 @Override
 public void setModified() {
   String s = tab.getText();
   tab.setText("* " + s);
 }
Exemplo n.º 17
-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();
  }