org.fxmisc.richtext.InlineCssTextArea Java Examples

The following examples show how to use org.fxmisc.richtext.InlineCssTextArea. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LyricsTextArea.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
public LyricsTextArea() {
    textArea = new InlineCssTextArea();
    ContextMenu contextMenu = new ContextMenu();
    Clipboard systemClipboard = Clipboard.getSystemClipboard();
    MenuItem paste = new MenuItem(LabelGrabber.INSTANCE.getLabel("paste.label"));
    contextMenu.setOnShown(e -> {
        paste.setDisable(!systemClipboard.hasContent(DataFormat.PLAIN_TEXT));
    });

    paste.setOnAction(e -> {
        String clipboardText = systemClipboard.getString();
        textArea.insertText(textArea.getCaretPosition(), clipboardText);
    });

    contextMenu.getItems().add(paste);
    textArea.setContextMenu(contextMenu);
    textArea.textProperty().addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
        Platform.runLater(this::refreshStyle);
    });

    textArea.setStyle("-fx-font-family: monospace; -fx-font-size: 10pt;");
    textArea.setUndoManager(UndoManagerFactory.zeroHistorySingleChangeUM(textArea.richChanges()));
    getChildren().add(new VirtualizedScrollPane<>(textArea));
    textArea.getStyleClass().add("text-area");
}
 
Example #2
Source File: MultiCaretAndSelectionDemo.java    From RichTextFX with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    // initialize area with some lines of text
    String alphabet = "abcdefghijklmnopqrstuvwxyz";
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 10; i++) {
        sb.append(i).append(" :").append(alphabet).append("\n");
    }
    area = new InlineCssTextArea(sb.toString());

    setupRTFXSpecificCSSShapes();

    addExtraCaret();

    addExtraSelection();

    // select some other range with the regular caret/selection before showing area
    area.selectRange(2, 0, 2, 4);

    primaryStage.setScene(new Scene(area, 400, 400));
    primaryStage.show();

    // request focus so carets blink
    area.requestFocus();
}
 
Example #3
Source File: FormattedAppender.java    From MSPaintIDE with MIT License 6 votes vote down vote up
public static void activate(InlineCssTextArea output, VirtualizedScrollPane virtualScrollPane) {
    FormattedAppender.output = output;
    FormattedAppender.virtualScrollPane = virtualScrollPane;
    output.getStyleClass().add("output-theme");

    PRE_STYLES.forEach((level, style) -> STYLE_MAP.put(level, style + "-fx-font-family: Monospace;"));

    Platform.runLater(() -> {
        var instance = getInstance();
        if (instance == null) return;

        synchronized (eventBuffer) {
            eventBuffer.forEach(instance::processEvent);
            eventBuffer.clear();
        }

        virtualScrollPane.scrollYBy(10000);
    });
}
 
Example #4
Source File: RFXInlineCSSTextAreaTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void selectWithUtf8Chars() throws InterruptedException {
    final InlineCssTextArea inlineCssTextAreaNode = (InlineCssTextArea) getPrimaryStage().getScene().getRoot()
            .lookup(".styled-text-area");
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            inlineCssTextAreaNode.appendText("å∫ç∂´ƒ©˙ˆ∆");
        }
    });
    LoggingRecorder lr = new LoggingRecorder();
    RFXComponent rTextField = new RFXGenericStyledArea(inlineCssTextAreaNode, null, null, lr);
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            rTextField.focusLost(null);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", select.getCall());
    AssertJUnit.assertEquals("å∫ç∂´ƒ©˙ˆ∆", select.getParameters()[0]);
}
 
Example #5
Source File: RFXInlineCSSTextAreaTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void selectWithSpecialChars() throws InterruptedException {
    final InlineCssTextArea inlineCssTextAreaNode = (InlineCssTextArea) getPrimaryStage().getScene().getRoot()
            .lookup(".styled-text-area");
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            inlineCssTextAreaNode.appendText("Hello\n World'\"");
        }
    });
    LoggingRecorder lr = new LoggingRecorder();
    RFXComponent rTextField = new RFXGenericStyledArea(inlineCssTextAreaNode, null, null, lr);
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            rTextField.focusLost(null);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", select.getCall());
    AssertJUnit.assertEquals("Hello\n World'\"", select.getParameters()[0]);
}
 
Example #6
Source File: RichTextFXInlineCssTextAreaElementTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void clear() {
    InlineCssTextArea inlineCssTextAreaNode = (InlineCssTextArea) getPrimaryStage().getScene().getRoot()
            .lookup(".styled-text-area");
    Platform.runLater(() -> {
        inlineCssTextArea.marathon_select("Hello World");
    });
    new Wait("Waiting for the text area value to be set") {
        @Override
        public boolean until() {
            return "Hello World".equals(inlineCssTextAreaNode.getText());
        }
    };
    inlineCssTextArea.clear();
    new Wait("Waiting for the text area value to be cleared") {
        @Override
        public boolean until() {
            return "".equals(inlineCssTextAreaNode.getText());
        }
    };
}
 
Example #7
Source File: RichTextFXInlineCssTextAreaElementTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void getText() {
    InlineCssTextArea inlineCssTextAreaNode = (InlineCssTextArea) getPrimaryStage().getScene().getRoot()
            .lookup(".styled-text-area");
    AssertJUnit.assertEquals("", inlineCssTextArea.getText());
    Platform.runLater(() -> {
        inlineCssTextArea.marathon_select("Hello World");
    });
    new Wait("Waiting for the text area value to be set") {
        @Override
        public boolean until() {
            return "Hello World".equals(inlineCssTextAreaNode.getText());
        }
    };
    AssertJUnit.assertEquals("Hello World", inlineCssTextArea.getText());
}
 
Example #8
Source File: RFXInlineCSSTextAreaTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void getText() {
    final InlineCssTextArea textArea = (InlineCssTextArea) getPrimaryStage().getScene().getRoot().lookup(".styled-text-area");
    LoggingRecorder lr = new LoggingRecorder();
    List<Object> text = new ArrayList<>();
    Platform.runLater(() -> {
        RFXComponent rca = new RFXGenericStyledArea(textArea, null, null, lr);
        textArea.appendText("Hello World");
        rca.focusLost(null);
        text.add(rca.getAttribute("text"));
    });
    new Wait("Waiting for text area text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Hello World", text.get(0));
}
 
Example #9
Source File: MultipleCaretSelectionTests.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void attempting_to_add_selection_associated_with_different_area_fails() {
    InlineCssTextArea area2 = new InlineCssTextArea();
    Selection<String, String, String> selection = new SelectionImpl<>("test selection", area2);
    interact(() -> {
        try {
            area.addSelection(selection);
            fail();
        } catch (IllegalArgumentException e) {
            // cannot add a selection associated with a different area
        }
    });
}
 
Example #10
Source File: MultipleCaretSelectionTests.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void attempting_to_add_caret_associated_with_different_area_fails() {
    InlineCssTextArea area2 = new InlineCssTextArea();
    CaretNode caret = new CaretNode("test caret", area2);
    interact(() -> {
        try {
            area.addCaret(caret);
            fail();
        } catch (IllegalArgumentException e) {
            // cannot add a caret associated with a different area
        }
    });
}
 
Example #11
Source File: ShowLineDemo.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    StringBuilder sb = new StringBuilder();
    int max = 100;
    for (int i = 0; i < max; i++) {
        sb.append("Line Index: ").append(i).append("\n");
    }
    sb.append("Line Index: ").append(max);
    InlineCssTextArea area = new InlineCssTextArea(sb.toString());
    VirtualizedScrollPane<InlineCssTextArea> vsPane = new VirtualizedScrollPane<>(area);

    Function<Integer, Integer> clamp = i -> Math.max(0, Math.min(i, area.getLength() - 1));
    Button showInViewportButton = createButton("Show line somewhere in Viewport", ae -> {
        area.showParagraphInViewport(clamp.apply(field.getTextAsInt()));
    });
    Button showAtViewportTopButton = createButton("Show line at top of viewport", ae -> {
        area.showParagraphAtTop(clamp.apply(field.getTextAsInt()));
    });
    Button showAtViewportBottomButton = createButton("Show line at bottom of viewport", ae -> {
        area.showParagraphAtBottom(clamp.apply(field.getTextAsInt()));
    });

    VBox vbox = new VBox(field, showInViewportButton, showAtViewportTopButton, showAtViewportBottomButton);
    vbox.setAlignment(Pos.CENTER);

    BorderPane root = new BorderPane();
    root.setCenter(vsPane);
    root.setBottom(vbox);

    Scene scene = new Scene(root, 700, 500);
    primaryStage.setScene(scene);
    primaryStage.show();

}
 
Example #12
Source File: RichTextFXInlineCssTextAreaElementTest.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Test
public void marathon_select() {
    InlineCssTextArea inlineCssTextAreaNode = (InlineCssTextArea) getPrimaryStage().getScene().getRoot()
            .lookup(".styled-text-area");
    Platform.runLater(() -> {
        inlineCssTextArea.marathon_select("Hello World");
    });
    new Wait("Waiting for the text area value to be set") {
        @Override
        public boolean until() {
            return "Hello World".equals(inlineCssTextAreaNode.getText());
        }
    };
}
 
Example #13
Source File: InlineCSSTextAreaSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public InlineCSSTextAreaSample() {
    InlineCssTextArea area = new InlineCssTextArea();
    area.setId("inlineCssTextArea");
    area.setMaxSize(250, 250);
    VBox root = new VBox();
    root.getChildren().addAll(area, new Button("Click Me!!"));
    getChildren().add(root);
}
 
Example #14
Source File: GUIConsoleInput.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new GUI console input.
 *
 * @param area GUI text area
 */
public GUIConsoleInput(InlineCssTextArea area) {
  this.area = area;
  initialPos = -1;
  inputText = null;
  area.setEditable(false);
  queue = new ArrayBlockingQueue<>(1);
  listener = new EventHandler<KeyEvent>() {
    @Override
    public void handle(KeyEvent e) {
      switch (e.getCode()) {
        case UP:
        case KP_UP:
        case PAGE_UP:
          area.moveTo(initialPos);
          e.consume();
          break;
        case DOWN:
        case KP_DOWN:
        case PAGE_DOWN:
          area.moveTo(area.getLength());
          e.consume();
          break;
        // ensure always that caret position is >= initialPos
        case LEFT:
        case KP_LEFT:
        case BACK_SPACE:
          if (area.getCaretPosition() == initialPos)
            e.consume();
          break;
        // return user response
        case ENTER:
          // after user release enter key return response
          if (e.getEventType() == KeyEvent.KEY_RELEASED)
            returnResponse();
          break;
        // nothing
        default:
          // change area input color
          if (initialPos < area.getLength()) {
            area.setStyle(initialPos, area.getLength(), "-fx-fill: #4a148c;");
          }
          break;
      }
    }
  };
  mouseListener = new EventHandler<MouseEvent>() {
    @Override
    public void handle(MouseEvent e) {
      EventType<? extends MouseEvent> type = e.getEventType();
      // disable mouse selection
      if (type == MouseEvent.DRAG_DETECTED || type == MouseEvent.MOUSE_DRAGGED)
        e.consume();
      // control caret position
      if (type == MouseEvent.MOUSE_CLICKED || type == MouseEvent.MOUSE_RELEASED || type == MouseEvent.MOUSE_PRESSED) {
        if (e.getButton() == MouseButton.PRIMARY) {
          if (area.getCaretPosition() < initialPos) {
            area.setDisable(true);
            area.moveTo(initialPos);
            area.setDisable(false);
          }
        } else {
          e.consume();
        }
      }
    }
  };
  stopListener = new ChangeListener<Boolean>() {
    @Override
    public void changed(ObservableValue obs, Boolean oldValue, Boolean newValue) {
      if (!newValue) {
        returnResponse();
      }
    }
  };
}
 
Example #15
Source File: ThemePanel.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create and initialise the theme panel.
 * <p>
 * @param wordsArea the text area to use for words. If null, sample lyrics
 * will be used.
 */
public ThemePanel(InlineCssTextArea wordsArea, Button confirmButton, boolean showThemeCopyPanel) {
    this.confirmButton = confirmButton;
    positionSelector = new DisplayPositionSelector(this);
    positionSelector.prefWidthProperty().bind(widthProperty());
    positionSelector.prefHeightProperty().bind(heightProperty());
    DisplayCanvas canvas = new DisplayCanvas(false, false, false, new DisplayCanvas.CanvasUpdater() {
        @Override
        public void updateCallback() {
            updateTheme(true);
        }
    }, Priority.LOW);
    preview = new DisplayPreview(canvas);
    VBox centrePane = new VBox();
    Label label = new Label("      " + LabelGrabber.INSTANCE.getLabel("hover.for.position.label") + ":");
    if (!QueleaProperties.get().getUseDarkTheme()) {
        label.setStyle("-fx-text-fill:#666666;");
        centrePane.setStyle("-fx-background-color:#dddddd;");
    }
    centrePane.getChildren().add(label);
    StackPane themePreviewPane = new StackPane();
    themePreviewPane.getStyleClass().add("text-area");
    themePreviewPane.getChildren().add(preview);
    themePreviewPane.getChildren().add(positionSelector);
    centrePane.getChildren().add(themePreviewPane);
    setCenter(centrePane);
    final WordDrawer drawer;
    if (canvas.isStageView()) {
        drawer = new StageDrawer();
    } else {
        drawer = new LyricDrawer();
    }
    drawer.setCanvas(canvas);
    text = SAMPLE_LYRICS;
    if (wordsArea != null) {
        ChangeListener<String> cl = (ov, t, newText) -> {
            SongDisplayable dummy = new SongDisplayable("", "");
            dummy.setLyrics(newText);
            TextSection[] sections = dummy.getSections();
            if (sections.length > 0 && sections[0].getText(false, false).length > 0) {
                text = sections[0].getText(false, false);
            } else {
                text = SAMPLE_LYRICS;
            }
            if (isEmpty(text)) {
                text = SAMPLE_LYRICS;
            }
            updateTheme(false);
        };
        wordsArea.textProperty().addListener(cl);
        cl.changed(null, null, wordsArea.getText());
    }

    VBox northBox = new VBox();
    HBox themeSelectPanel = new HBox();
    themeSelectPanel.setPadding(new Insets(5));
    Label themeSelectLabel = new Label(LabelGrabber.INSTANCE.getLabel("theme.copy.label") + ": ");
    themeSelectLabel.setPadding(new Insets(3,0,0,0));
    themeCombo = new ComboBox<>();
    themeCombo.setItems(ThemeUtils.getThemes());

    Button copyButton = new Button(LabelGrabber.INSTANCE.getLabel("copy"));
    copyButton.setOnAction(event -> {
        setTheme(themeCombo.getValue());
    });
    themeSelectPanel.setSpacing(5);
    themeSelectPanel.getChildren().addAll(themeSelectLabel, themeCombo, copyButton);

    themeToolbar = new ThemeToolbar(this);
    if(showThemeCopyPanel) {
        northBox.getChildren().add(themeSelectPanel);
    }
    northBox.getChildren().add(themeToolbar);

    setTop(northBox);
    updateTheme(false);
    setMaxSize(800, 600);
}
 
Example #16
Source File: ThemePanel.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
public ThemePanel(InlineCssTextArea wordsArea, Button confirmButton) {
    this(wordsArea, confirmButton, false);
}
 
Example #17
Source File: OverrideBehaviorDemo.java    From RichTextFX with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    InlineCssTextArea area = new InlineCssTextArea();

    InputMap<Event> preventSelectionOrRightArrowNavigation = InputMap.consume(
            anyOf(
                    // prevent selection via (CTRL + ) SHIFT + [LEFT, UP, DOWN]
                    keyPressed(LEFT,    SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(KP_LEFT, SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(UP,    SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(KP_UP, SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(DOWN,    SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(KP_DOWN, SHIFT_DOWN, SHORTCUT_ANY),

                    // prevent selection via mouse events
                    eventType(MouseEvent.MOUSE_DRAGGED),
                    eventType(MouseEvent.DRAG_DETECTED),
                    mousePressed().unless(e -> e.getClickCount() == 1 && !e.isShiftDown()),

                    // prevent any right arrow movement, regardless of modifiers
                    keyPressed(RIGHT,     SHORTCUT_ANY, SHIFT_ANY),
                    keyPressed(KP_RIGHT,  SHORTCUT_ANY, SHIFT_ANY)
            )
    );
    Nodes.addInputMap(area, preventSelectionOrRightArrowNavigation);

    area.replaceText(String.join("\n",
            "You can't move the caret to the right via the RIGHT arrow key in this area.",
            "Additionally, you cannot select anything either",
            "",
            ":-p"
    ));
    area.moveTo(0);

    CheckBox addExtraEnterHandlerCheckBox = new CheckBox("Temporarily add an EventHandler to area's `onKeyPressedProperty`?");
    addExtraEnterHandlerCheckBox.setStyle("-fx-font-weight: bold;");

    Label checkBoxExplanation = new Label(String.join("\n",
            "The added handler will insert a newline character at the caret's position when [Enter] is pressed.",
            "If checked, the default behavior and added handler will both occur: ",
            "\tthus, two newline characters should be inserted when user presses [Enter].",
            "When unchecked, the handler will be removed."
    ));
    checkBoxExplanation.setWrapText(true);

    EventHandler<KeyEvent> insertNewlineChar = e -> {
        if (e.getCode().equals(ENTER)) {
            area.insertText(area.getCaretPosition(), "\n");
            e.consume();
        }
    };
    addExtraEnterHandlerCheckBox.selectedProperty().addListener(
            (obs, ov, isSelected) -> area.setOnKeyPressed( isSelected ? insertNewlineChar : null)
    );

    VBox vbox = new VBox(area, addExtraEnterHandlerCheckBox, checkBoxExplanation);
    vbox.setSpacing(10);
    vbox.setPadding(new Insets(10));

    primaryStage.setScene(new Scene(vbox, 700, 350));
    primaryStage.show();
    primaryStage.setTitle("An area whose behavior has been overridden permanently and temporarily!");
}
 
Example #18
Source File: CloneDemo.java    From RichTextFX with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    String selectedText = "selection";
    String text = "Edit the top area (original)\nand watch the (clone) bottom area's displayed text change and its " +
            "selected text [" + selectedText + "] update itself accordingly.";
    InlineCssTextArea area = new InlineCssTextArea(text);
    InlineCssTextArea clone = new InlineCssTextArea(area.getContent());

    VBox vbox = new VBox(area, clone);
    vbox.setSpacing(10);

    // set up labels displaying caret position
    String caret = "Caret: ";
    Label areaCaret = new Label(caret);
    area.caretPositionProperty().addListener((observable, oldValue, newValue) -> areaCaret.setText(caret + String.valueOf(newValue)));
    Label cloneCaret = new Label(caret);
    clone.caretPositionProperty().addListener((observable, oldValue, newValue) -> cloneCaret.setText(caret + String.valueOf(newValue)));

    // set up label's displaying selection position
    String selection = "Selected Text: ";
    Label areaSelection = new Label(selection);
    area.selectedTextProperty().addListener(((observable, oldValue, newValue) -> areaSelection.setText(selection + newValue)));
    Label cloneSelection = new Label(selection);
    clone.selectedTextProperty().addListener(((observable, oldValue, newValue) -> cloneSelection.setText(selection + newValue)));

    // now that listeners are set up update the selection for clone
    int selectionStart = text.indexOf(selectedText);
    int selectionEnd   = selectionStart +  selectedText.length();
    clone.selectRange(selectionStart, selectionEnd);

    // set up Label's distinguishing which labels belong to which area.
    Label areaLabel = new Label("Original Area: ");
    Label cloneLabel = new Label("Cloned Area: ");

    // set up Buttons that programmatically change area but not clone
    Button deleteLastThreeChars = new Button("Click to Delete the previous 3 chars.");
    deleteLastThreeChars.setOnAction((ae) -> {
        for (int i = 0; i <= 2; i++) {
            area.deletePreviousChar();
        }
    });

    // finish GUI
    GridPane grid = new GridPane();
    // add area content to first row
    grid.add(areaLabel, 0, 0);
    grid.add(areaCaret, 1, 0);
    grid.add(areaSelection, 2, 0);

    // add clone content to second row
    grid.add(cloneLabel, 0, 1);
    grid.add(cloneCaret, 1, 1);
    grid.add(cloneSelection, 2, 1);

    grid.setHgap(10);
    grid.setVgap(4);

    BorderPane pane = new BorderPane();
    pane.setCenter(vbox);
    pane.setTop(grid);
    pane.setBottom(deleteLastThreeChars);

    Scene scene = new Scene(pane, 800, 500);
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #19
Source File: EditThemeScheduleActionHandler.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Edit the theme of the currently selected item in the schedule.
 *
 * @param t the action event.
 */
@Override
public void handle(ActionEvent t) {
    TextDisplayable firstSelected = selectedDisplayable;
    if (selectedDisplayable == null) {
        firstSelected = (TextDisplayable) QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList().getSelectionModel().getSelectedItem();
    }
    InlineCssTextArea wordsArea = new InlineCssTextArea();
    wordsArea.replaceText(firstSelected.getSections()[0].toString().trim());
    Button confirmButton = new Button(LabelGrabber.INSTANCE.getLabel("ok.button"), new ImageView(new Image("file:icons/tick.png")));
    Button cancelButton = new Button(LabelGrabber.INSTANCE.getLabel("cancel.button"), new ImageView(new Image("file:icons/cross.png")));
    final Stage s = new Stage();
    s.initModality(Modality.APPLICATION_MODAL);
    s.initOwner(QueleaApp.get().getMainWindow());
    s.resizableProperty().setValue(false);
    final BorderPane bp = new BorderPane();
    final ThemePanel tp = new ThemePanel(wordsArea, confirmButton, true);
    tp.setPrefSize(500, 500);
    if (firstSelected.getSections().length > 0) {
        tp.setTheme(firstSelected.getSections()[0].getTheme());
    }
    confirmButton.setOnAction(e -> {
        if (tp.getTheme() != null) {
            ScheduleList sl = QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList();
            tp.updateTheme(false);
            List<Displayable> displayableList;
            if (selectedDisplayable == null) {
                displayableList = sl.getSelectionModel().getSelectedItems();
            } else {
                displayableList = new ArrayList<>();
                displayableList.add(selectedDisplayable);
            }
            for (Displayable eachDisplayable : displayableList) {
                if (eachDisplayable instanceof TextDisplayable) {
                    ((TextDisplayable) eachDisplayable).setTheme(tp.getTheme());
                    for (TextSection ts : ((TextDisplayable) eachDisplayable).getSections()) {
                        ts.setTheme(tp.getTheme());
                    }
                    if (eachDisplayable instanceof SongDisplayable) {
                        Utils.updateSongInBackground((SongDisplayable) eachDisplayable, true, false);
                    }
                }
            }
            QueleaApp.get().getMainWindow().getMainPanel().getPreviewPanel().refresh();
        }
        s.hide();
    });
    cancelButton.setOnAction(e -> {
        s.hide();
    });
    bp.setCenter(tp);

    HBox hb = new HBox(10);
    hb.setPadding(new Insets(10));
    BorderPane.setAlignment(hb, Pos.CENTER);
    hb.setAlignment(Pos.CENTER);
    hb.getChildren().addAll(confirmButton, cancelButton);
    bp.setBottom(hb);

    Scene scene = new Scene(bp);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    s.setScene(scene);
    s.setMinHeight(600);
    s.setMinWidth(250);
    s.showAndWait();
}
 
Example #20
Source File: LyricsTextArea.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
public InlineCssTextArea getTextArea() {
    return textArea;
}
 
Example #21
Source File: GUIConsoleOutput.java    From Jupiter with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new GUI console output.
 *
 * @param area GUI text area
 */
public GUIConsoleOutput(InlineCssTextArea area) {
  this.area = area;
}
 
Example #22
Source File: InputMethodRequestsObject.java    From Quelea with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create a InputMethodRequest as a workaround for non-latin characters.
 *
 * @param textArea the InlineCssTextArea the object will be used on.
 */
public InputMethodRequestsObject(InlineCssTextArea textArea) {
    this.textArea = textArea;
}