当前位置: 首页>>代码示例>>Java>>正文


Java Nodes类代码示例

本文整理汇总了Java中org.fxmisc.wellbehaved.event.Nodes的典型用法代码示例。如果您正苦于以下问题:Java Nodes类的具体用法?Java Nodes怎么用?Java Nodes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Nodes类属于org.fxmisc.wellbehaved.event包,在下文中一共展示了Nodes类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
@Override
public <T extends LayoutCell<?>> void apply(VirtualFlow<T> list,
                                            Relation relation) {

    Nodes.addInputMap(list, InputMap.consume(DOUBLE_SELECT, e -> {
        Route route = back.peek()
                          .getRoute(relation);
        if (route == null) {
            return;
        }
        JsonNode item = list.getSelectionModel()
                            .getSelectedItem();
        if (item == null) {
            return;
        }
        try {
            push(extract(route, item));
        } catch (QueryException ex) {
            log.error("Unable to push page: %s", route.getPath(), ex);
        }
    }));
}
 
开发者ID:ChiralBehaviors,项目名称:Kramer,代码行数:23,代码来源:SinglePageApp.java

示例2: initKeyMapping

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
public void initKeyMapping(StyleClassedTextArea sourceText) {
    Platform.runLater(() -> {
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.S, SHORTCUT_DOWN), e -> handleSaveButtonAction())));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.G, SHORTCUT_DOWN), e -> handleBoldButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.I, SHORTCUT_DOWN), e -> handleItalicButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.B, SHORTCUT_DOWN), e -> handleBarredButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.K, SHORTCUT_DOWN), e -> handleTouchButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.PLUS, SHORTCUT_DOWN), e -> handleExpButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.EQUALS, SHORTCUT_DOWN), e -> handleIndButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.E, SHORTCUT_DOWN), e -> handleCenterButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.D, SHIFT_DOWN, SHORTCUT_DOWN), e -> handleRightButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.SPACE, SHORTCUT_DOWN), e -> handleUnbreakableAction())));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.L, SHORTCUT_DOWN), e -> handleGoToLineAction())));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.F, SHORTCUT_DOWN), e -> handleFindReplaceDialog())));
        if (FunctionTreeFactory.isMacOs()) {
            Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.Q, SHORTCUT_DOWN), e -> currentSourceText.selectAll())));
        }
        if (MainApp.getConfig().isEditorSmart()) {
            //Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.TAB), e -> handleSmartTab())));
            //Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.ENTER), e -> handleSmartEnter())));
        }
    });
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:24,代码来源:MdTextController.java

示例3: canCloseEditor

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
boolean canCloseEditor(FileEditor fileEditor) {
	if (!fileEditor.isModified())
		return true;

	Alert alert = mainWindow.createAlert(AlertType.CONFIRMATION,
		Messages.get("FileEditorTabPane.closeAlert.title"),
		Messages.get("FileEditorTabPane.closeAlert.message"), fileEditor.getTab().getText());
	alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);

	// register first characters of Yes and No buttons as keys to close the alert
	for (ButtonType buttonType : Arrays.asList(ButtonType.YES, ButtonType.NO)) {
		Nodes.addInputMap(alert.getDialogPane(),
			consume(keyPressed(KeyCode.getKeyCode(buttonType.getText().substring(0, 1).toUpperCase())), e -> {
				if (!e.isConsumed()) {
					alert.setResult(buttonType);
					alert.close();
				}
			}));
	}

	ButtonType result = alert.showAndWait().get();
	if (result != ButtonType.YES)
		return (result == ButtonType.NO);

	return saveEditor(fileEditor);
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:27,代码来源:FileEditorTabPane.java

示例4: SmartEdit

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
SmartEdit(MarkdownEditorPane editor, MarkdownTextArea textArea) {
		this.editor = editor;
		this.textArea = textArea;
		this.smartFormat = new SmartFormat(editor, textArea);

		Nodes.addInputMap(textArea, sequence(
			consume(keyPressed(ENTER),							this::enterPressed),
			consume(keyPressed(TAB),							this::tabPressed),
			consume(keyPressed(TAB, SHIFT_DOWN),				this::shiftTabPressed),
			consume(keyPressed(BACK_SPACE),						this::backspacePressed),
			consume(keyPressed(D, SHORTCUT_DOWN),				this::deleteLine),
			consume(keyPressed(UP, ALT_DOWN),					this::moveLinesUp),
			consume(keyPressed(DOWN, ALT_DOWN),					this::moveLinesDown),
			consume(keyPressed(UP, SHORTCUT_DOWN, ALT_DOWN),	this::duplicateLinesUp),
			consume(keyPressed(DOWN, SHORTCUT_DOWN, ALT_DOWN),	this::duplicateLinesDown),

			consume(keyPressed(F, SHORTCUT_DOWN, SHIFT_DOWN),	smartFormat::format)
		));

//		textArea.selectionProperty().addListener((ob, o, n) ->
//			System.out.println(findNodes(n.getStart(), n.getEnd(), (s, e, node) -> true, true)));

		editor.markdownASTProperty().addListener((ob, o, n) -> updateStateProperties());
		textArea.selectionProperty().addListener((ob, o, n) -> updateStateProperties());
	}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:26,代码来源:SmartEdit.java

示例5: CustomCodeArea

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
public CustomCodeArea(String text, Highlight highlight, Syntax syntax, String name) {
    executor = Executors.newSingleThreadExecutor();
    this.highlight = highlight;
    this.syntax = syntax;
    this.lastText = "";
    this.name = name;

    InputMap<Event> prevent = InputMap.consume(
            anyOf(
                    keyPressed(TAB, SHORTCUT_ANY, SHIFT_ANY)
            )
    );
    Nodes.addInputMap(this, prevent);

    this.setOnKeyPressed(event -> {
        if (event.getCode() == KeyCode.TAB) {
            this.insertText(this.getCaretPosition(), "    ");
        }
    });
    caretPosition = CaretPosition.create();
    this.caretPositionProperty().addListener(listener -> caretPosition.compute(this));
    this.setParagraphGraphicFactory(LineNumberFactory.get(this));
    this.richChanges()
            .filter(this::isChangeable)
            .successionEnds(Duration.ofMillis(20))
            .supplyTask(this::computeHighlightingAsync)
            .awaitLatest(this.richChanges())
            .filterMap(this::getOptional)
            .subscribe(this::applyHighlighting);
    this.replaceText(0, 0, text);
}
 
开发者ID:MrChebik,项目名称:Coconut-IDE,代码行数:32,代码来源:CustomCodeArea.java

示例6: start

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
    Layout model = new Layout() {
        @Override
        public <T extends LayoutCell<?>> void apply(VirtualFlow<T> list,
                                                    Relation relation) {
            Nodes.addInputMap(list,
                              InputMap.consume(DOUBLE_SELECT,
                                               e -> System.out.println("event: "
                                                                       + list.getSelectionModel()
                                                                             .getSelectedItem())));
        }
    };
    AutoLayout layout = new AutoLayout(Util.build(), model);
    URL url = getClass().getResource("/bootstrap3.css");
    if (url != null) {
        layout.getStylesheets()
              .add(url.toExternalForm());
    }
    AnchorPane.setTopAnchor(layout, 0.0);
    AnchorPane.setLeftAnchor(layout, 0.0);
    AnchorPane.setBottomAnchor(layout, 0.0);
    AnchorPane.setRightAnchor(layout, 0.0);
    AnchorPane root = new AnchorPane();
    root.getChildren()
        .add(layout);
    primaryStage.setScene(new Scene(root, 800, 800));
    primaryStage.show();

    JsonNode data = Util.testData();
    layout.measure(data);
    layout.updateItem(data);
    layout.autoLayout();
}
 
开发者ID:ChiralBehaviors,项目名称:Kramer,代码行数:35,代码来源:Smoke.java

示例7: test

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
@Test
public void test() {
    StringProperty res = new SimpleStringProperty();

    InputMapTemplate<Node, KeyEvent> imt1 = consume(keyPressed(A), (s, e) -> res.set("A"));
    InputMapTemplate<Node, KeyEvent> imt2 = consume(keyPressed(B), (s, e) -> res.set("B"));
    InputMapTemplate<Node, KeyEvent> imt = imt1.orElse(imt2);
    InputMap<KeyEvent> ignA = InputMap.ignore(keyPressed(A));

    Node node1 = new Region();
    Node node2 = new Region();

    Nodes.addInputMap(node1, ignA);
    InputMapTemplate.installFallback(imt, node1);
    InputMapTemplate.installFallback(imt, node2);

    KeyEvent aPressed = new KeyEvent(KEY_PRESSED, "", "", A, false, false, false, false);
    KeyEvent bPressed = new KeyEvent(KEY_PRESSED, "", "", B, false, false, false, false);

    InputMapTest.dispatch(aPressed, node1);
    assertNull(res.get());
    assertFalse(aPressed.isConsumed());

    InputMapTest.dispatch(aPressed, node2);
    assertEquals("A", res.get());
    assertTrue(aPressed.isConsumed());

    InputMapTest.dispatch(bPressed, node1);
    assertEquals("B", res.get());
    assertTrue(bPressed.isConsumed());
}
 
开发者ID:FXMisc,项目名称:WellBehavedFX,代码行数:32,代码来源:InputMapTemplateTest.java

示例8: apply

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
@Override
public <T extends LayoutCell<?>> void apply(VirtualFlow<T> list,
                                            Relation relation) {
    Nodes.addInputMap(list, InputMap.consume(DOUBLE_SELECT, e -> {
        doubleClick(list.getSelectionModel()
                        .getSelectedItem(),
                    relation);
    }));
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:10,代码来源:UniversalApplication.java

示例9: getNode

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
Node getNode() {
	if (pane != null)
		return pane;

	initComponents();

	pane.getStyleClass().add("find-replace");
	findField.getStyleClass().add("find");
	previousButton.getStyleClass().addAll("previous", "flat-button");
	nextButton.getStyleClass().addAll("next", "flat-button");
	matchCaseButton.getStyleClass().add("flat-button");
	regexButton.getStyleClass().add("flat-button");
	closeButton.getStyleClass().addAll("close", "flat-button");
	findInfoLabel.getStyleClass().add("info");
	replaceInfoLabel.getStyleClass().add("info");

	previousButton.setGraphic(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.CHEVRON_UP));
	nextButton.setGraphic(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.CHEVRON_DOWN));
	closeButton.setGraphic(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.CLOSE));

	previousButton.setTooltip(new Tooltip(Messages.get("FindReplacePane.previousButton.tooltip")));
	nextButton.setTooltip(new Tooltip(Messages.get("FindReplacePane.nextButton.tooltip")));
	matchCaseButton.setTooltip(new Tooltip(Messages.get("FindReplacePane.matchCaseButton.tooltip")));
	regexButton.setTooltip(new Tooltip(Messages.get("FindReplacePane.regexButton.tooltip")));
	closeButton.setTooltip(new Tooltip(Messages.get("FindReplacePane.closeButton.tooltip")));

	findField.setLeft(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.SEARCH));
	findField.setRight(nOfHitCountLabel);
	findField.textProperty().addListener((ov, o, n) -> findAll(true));
	Nodes.addInputMap(findField, sequence(
			// don't know why, but Ctrl+H (set in menubar) does not work if findField has focus
			consume(keyPressed(H, SHORTCUT_DOWN), e -> show(true, false)),
			// don't know why, but F3 (set in menubar) does not work if findField has focus
			consume(keyPressed(F3),		e -> findNext()),

			consume(keyPressed(UP),		e -> findPrevious()),
			consume(keyPressed(DOWN),	e -> findNext()),
			consume(keyPressed(ENTER),	e -> findNext()),
			consume(keyPressed(ESCAPE),	e -> hide())));
	previousButton.setOnAction(e -> findPrevious());
	nextButton.setOnAction(e -> findNext());
	closeButton.setOnAction(e -> hide());

	matchCaseButton.setOnAction(e -> {
		findAll(true);
		matchCase.set(matchCaseButton.isSelected());
	} );
	regexButton.setOnAction(e -> {
		findAll(true);
		regex.set(regexButton.isSelected());
	});
	matchCaseButton.setSelected(matchCase.get());
	regexButton.setSelected(regex.get());

	nOfCountFormat = nOfHitCountLabel.getText();


	replacePane.setVisible(false);

	replaceField.setLeft(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.RETWEET));
	Nodes.addInputMap(replaceField, sequence(
			// don't know why, but F3 (set in menubar) does not work if replaceField has focus
			consume(keyPressed(F3),		e -> findNext()),

			consume(keyPressed(UP),		e -> findPrevious()),
			consume(keyPressed(DOWN),	e -> findNext()),
			consume(keyPressed(ENTER),	e -> replace()),
			consume(keyPressed(ENTER, SHORTCUT_DOWN), e -> replaceAll()),
			consume(keyPressed(ESCAPE),	e -> hide())));
	replaceButton.setOnAction(e -> replace());
	replaceAllButton.setOnAction(e -> replaceAll());

	update();

	return pane;
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:77,代码来源:FindReplacePane.java

示例10: installOverride

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
/**
 * Instantiates the input map and installs it into the node via {@link Nodes#addInputMap(Node, InputMap)}
 */
public static <S extends Node, E extends Event> void installOverride(InputMapTemplate<S, E> imt, S node) {
    Nodes.addInputMap(node, imt.instantiate(node));
}
 
开发者ID:FXMisc,项目名称:WellBehavedFX,代码行数:7,代码来源:InputMapTemplate.java

示例11: installFallback

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
/**
 * Instantiates the input map and installs it into the node via {@link Nodes#addFallbackInputMap(Node, InputMap)}
 */
public static <S extends Node, E extends Event> void installFallback(InputMapTemplate<S, E> imt, S node) {
    Nodes.addFallbackInputMap(node, imt.instantiate(node));
}
 
开发者ID:FXMisc,项目名称:WellBehavedFX,代码行数:7,代码来源:InputMapTemplate.java

示例12: uninstall

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
/**
 * Removes the input map template's instance from the given node.
 */
public static <S extends Node, E extends Event> void uninstall(InputMapTemplate<S, E> imt, S node) {
    Nodes.removeInputMap(node, imt.instantiate(node));
}
 
开发者ID:FXMisc,项目名称:WellBehavedFX,代码行数:7,代码来源:InputMapTemplate.java

示例13: start

import org.fxmisc.wellbehaved.event.Nodes; //导入依赖的package包/类
@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!");
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:64,代码来源:OverrideBehaviorDemo.java


注:本文中的org.fxmisc.wellbehaved.event.Nodes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。