java类javafx.stage.PopupWindow的实例源码

AutoCompletionCodeAreaBind.java 文件源码 项目:CSS-Editor-FX 阅读 29 收藏 0 点赞 0 评论 0
public void showPopup() {
  Collection<String> suggestions = suggestionProvider.apply(codeArea.getText(), codeArea.getCaretPosition());
  if (suggestions.isEmpty()) {
    hidePopup();
  } else {
    PopupWindow popupWindow = codeArea.getPopupWindow();
    if (popupWindow != popup) {
      popupWindow.hide();
      codeArea.setPopupWindow(popup);
    }
    popup.getSuggestions().setAll(suggestions);
    selectFirstSuggestion(popup);
    if (popup.isShowing() == false) {
      popup.show(codeArea.getScene().getWindow());
    }
  }
}
BasicEntityEditor.java 文件源码 项目:myWMS 阅读 24 收藏 0 点赞 0 评论 0
protected PopupWindow createPopup() {
    ListView<BODTO<T>> listView = new ListView<>();
    listView.getStyleClass().addAll("combo-box-popup");
    listView.setItems(completionItems);
    listView.cellFactoryProperty().bind(control.cellFactoryProperty());
    listView.setOnKeyReleased(e -> { 
        if (e.getCode() == KeyCode.ENTER ) { select(listView); e.consume(); }
        if (e.getCode() == KeyCode.ESCAPE ) { hidePopup(); e.consume(); }
    });

    listView.setOnMouseClicked(e -> { if (e.getClickCount() == 1) select(listView); e.consume();});

    Popup popup = new Popup();
    control.showPopup.bind(popup.showingProperty());
    popup.getContent().add(listView);
    textInput.updateValue("");
    return popup;
}
ChoiceTest.java 文件源码 项目:openjfx-8u-dev-tests 阅读 28 收藏 0 点赞 0 评论 0
@Smoke
@Test(timeout = 300000)
public void converter() throws InterruptedException {
    choice.as(Selectable.class).selector().select("1");
    converter.mouse().click();
    final LookupCriteria marker = new ByText("Converted", StringComparePolicy.SUBSTRING);
    final Parent choiceAsParent = choice.as(Parent.class, Node.class);
    choiceAsParent.lookup(marker).wait(1);
    choice.mouse().click();
    final Lookup<? extends Scene> popupLookup = Root.ROOT.lookup(new ByWindowType(PopupWindow.class)).lookup(Scene.class);
    popupLookup.wrap().as(Parent.class, Node.class).lookup(marker).wait(3);
    removeConverter.mouse().click();
    choice.waitState(new State<Integer>() {
        public Integer reached() {
            return choiceAsParent.lookup(marker).size();
        }
    }, 0);
    choice.mouse().click();
    choice.waitState(new State<Integer>() {
        public Integer reached() {
            return popupLookup.wrap().as(Parent.class, Node.class).lookup(marker).size();
        }
    }, 0);
}
ScrollEventTest.java 文件源码 项目:openjfx-8u-dev-tests 阅读 19 收藏 0 点赞 0 评论 0
/**
 * This test checks that context menu appears
 * but there are no other popup windows
 *
 * Input: each control gets right mouse click
 * Expected output: only one new window appears on the stage
 *
 */
@Smoke
@Test(timeout=300000)
public void contextMenuPopupTest() {
    enableContextMenuTest();

    for (Object nf : nodeChooser.as(Selectable.class).getStates()) {
        nodeChooser.as(Selectable.class).selector().select(nf);

        targetControl = parent.lookup(Node.class, new ByID<Node>(ID_TARGET_NODE)).wrap();
        targetControl.mouse().click(1, targetControl.getClickPoint(), Mouse.MouseButtons.BUTTON3);

        Lookup<Scene> popUpLookup = Root.ROOT.lookup(new ByWindowType(PopupWindow.class)).lookup(Scene.class);
        assertEquals("There must be only one popup window for control <" + nf + ">", 1, popUpLookup.size());
    }
}
ChoiceBoxWrap.java 文件源码 项目:openjfx-8u-dev-tests 阅读 24 收藏 0 点赞 0 评论 0
public void select(final Object state) {
    if (!isShowing()) {
        mouse().click();
    }
    Parent<Node> popupContainer =
            Root.ROOT.lookup(new ByWindowType<>(PopupWindow.class)).as(Parent.class, Node.class);

    // TODO: figure out what to do with duplicate strings
    popupContainer.lookup(Node.class, cntrl -> {
        MenuItem item = (MenuItem) cntrl.getProperties().get(MenuItem.class);
        if (item == null) {
            return false;
        }
        ;
        if (!item.getText().contentEquals(state.toString())) {
            return false;
        }
        return true;
    }).wrap().mouse().click();
}
FXSceneTreeBuilder.java 文件源码 项目:openjfx-8u-dev-tests 阅读 23 收藏 0 点赞 0 评论 0
public static ArrayList<TreeNode<FXSimpleNodeDescription>> build(final Wrap<? extends Parent> wrap) {
    return new GetAction<ArrayList<TreeNode<FXSimpleNodeDescription>>>() {
        @Override
        public void run(Object... os) throws Exception {
            ArrayList<TreeNode<FXSimpleNodeDescription>> list = new ArrayList<TreeNode<FXSimpleNodeDescription>>();
            list.add(build(wrap.getControl()));
            final Lookup<Scene> lookup = Root.ROOT.lookup(new ByWindowType(PopupWindow.class));
            for (int  i = 0; i < lookup.size(); i++) {
                Wrap<? extends Scene> popup = lookup.wrap(i);
                if (wrap.getScreenBounds().intersects(popup.getScreenBounds())) {
                    list.add(build(popup.getControl().getRoot(), wrap.getControl()));
                }
            }
            setResult(list);
        }
    }.dispatch(wrap.getEnvironment());
}
AutoCompletionCodeAreaBind.java 文件源码 项目:CSS-Editor-FX 阅读 29 收藏 0 点赞 0 评论 0
public void showPopup() {
  Collection<String> suggestions = suggestionProvider.apply(codeArea.getText(), codeArea.getCaretPosition());
  if (suggestions.isEmpty()) {
    hidePopup();
  } else {
    PopupWindow popupWindow = codeArea.getPopupWindow();
    if (popupWindow != popup) {
      popupWindow.hide();
      codeArea.setPopupWindow(popup);
    }
    popup.getSuggestions().setAll(suggestions);
    selectFirstSuggestion(popup);
    if (popup.isShowing() == false) {
      popup.show(codeArea.getScene().getWindow());
    }
  }
}
NotificationController.java 文件源码 项目:Elegit 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Updates the notification alert
 * @param notification new alert
 * @return new PopOver
 */
private PopOver updateNotificationBubble(String notification) {
    Text notifcationText = new Text(notification);
    notifcationText.setWrappingWidth(230);
    notifcationText.setStyle("-fx-font-weight: bold");

    HBox hBox = new HBox(notifcationText);
    hBox.setPadding(new Insets(0, 5, 0, 5));
    hBox.setOnMouseClicked(event -> showNotificationList());

    PopOver popOver = new PopOver(hBox);
    popOver.setTitle("New Notification");
    popOver.setArrowLocation(PopOver.ArrowLocation.BOTTOM_RIGHT);
    popOver.setAnchorLocation(PopupWindow.AnchorLocation.CONTENT_BOTTOM_RIGHT);

    return popOver;
}
ContextMenuHandler.java 文件源码 项目:marathonv5 阅读 24 收藏 0 点赞 0 评论 0
public ContextMenuHandler(IJSONRecorder recorder, RFXComponentFactory finder) {
    popup = new PopupWindow() {
    };
    root = new AssertionPanel(popup, recorder, finder);
    root.setPrefWidth(300.0);
    popup.getScene().setRoot(root);
    popup.sizeToScene();
}
RFXComponent.java 文件源码 项目:marathonv5 阅读 23 收藏 0 点赞 0 评论 0
private Stage getStage(Window window) {
    if (window instanceof Stage) {
        return (Stage) window;
    }
    if (window instanceof PopupWindow) {
        Node ownerNode = ((PopupWindow) window).getOwnerNode();
        ownerNode.getScene().getWindow();
        return getStage(ownerNode.getScene().getWindow());
    }
    return null;
}
PreviewCodeAreaBind.java 文件源码 项目:CSS-Editor-FX 阅读 31 收藏 0 点赞 0 评论 0
public void showPopup() {
  PopupWindow popupWindow = codeArea.getPopupWindow();
  if (popupWindow != popup) {
    popupWindow.hide();
    codeArea.setPopupWindow(popup);
  }
  popup.show(codeArea.getScene().getWindow());
}
ComboButton.java 文件源码 项目:fx-animation-editor 阅读 21 收藏 0 点赞 0 评论 0
private void createUi() {
    setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
    setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);

    popupContent.getStyleClass().add(POPUP_CONTENT_STYLE_CLASS);
    popupContent.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> popup.hide());

    popup.setAutoHide(true);
    popup.getContent().add(popupContent);
    popup.showingProperty().addListener((v, o, n) -> pseudoClassStateChanged(SHOWING_PSEUDO_CLASS, n));
    popup.setAnchorLocation(PopupWindow.AnchorLocation.CONTENT_TOP_LEFT);
}
ApplicationInteractionFunctions.java 文件源码 项目:openjfx-8u-dev-tests 阅读 23 收藏 0 点赞 0 评论 0
protected void checkPopup() throws Exception {
    Lookup<Scene> lookup = Root.ROOT.lookup(new ByWindowType(PopupWindow.class))
                                     .lookup(Scene.class);
    if (lookup.size() != 1) {
        throw new Exception("Popup is expected to appear.");
    }
}
TooltipTest.java 文件源码 项目:openjfx-8u-dev-tests 阅读 23 收藏 0 点赞 0 评论 0
protected void checkVisibleState(boolean check) {
    isVisible.waitProperty(TextControlWrap.SELECTED_PROP_NAME, check ? CheckBoxWrap.State.CHECKED : CheckBoxWrap.State.UNCHECKED);
    if (check) {
        isActivated.waitProperty(TextControlWrap.SELECTED_PROP_NAME, CheckBoxWrap.State.UNCHECKED);
        activatedPropVal.waitProperty(TextControlWrap.SELECTED_PROP_NAME, CheckBoxWrap.State.UNCHECKED);
    }
    assertEquals(check ? 1 : 0, Root.ROOT.lookup(new ByWindowType(PopupWindow.class)).lookup(Scene.class).size());
}
ChoiceTest.java 文件源码 项目:openjfx-8u-dev-tests 阅读 26 收藏 0 点赞 0 评论 0
@Smoke
@Test(timeout = 300000)
public void keyboardCapture() throws InterruptedException { //RT-12597
    choice.mouse().click();
    Wrap<? extends Scene> popupScene = Root.ROOT.lookup(new ByWindowType(PopupWindow.class)).lookup(Scene.class).wrap(0);
    Node focused = getFocused();
    popupScene.keyboard().pushKey(KeyboardButtons.UP);
    assertEquals(focused, getFocused());
}
RichTextEditorTest.java 文件源码 项目:openjfx-8u-dev-tests 阅读 23 收藏 0 点赞 0 评论 0
private Wrap<? extends Scene> getPopupWrap() throws InterruptedException {
    Wrap<? extends Scene> temp;
    try {
        temp = Root.ROOT.lookup(new ByWindowType(PopupWindow.class)).lookup(Scene.class).wrap(0);
    } catch (Exception e) {
        return null;
    }
    return temp;
}
TestBase.java 文件源码 项目:openjfx-8u-dev-tests 阅读 34 收藏 0 点赞 0 评论 0
protected Wrap<? extends Scene> getPopupWrap() {
    Wrap<? extends Scene> temp;
    try {
        temp = Root.ROOT.lookup(new ByWindowType(PopupWindow.class)).lookup(Scene.class).wrap(0);
    } catch (Exception e) {
        return null;
    }
    return temp;
}
PreviewCodeAreaBind.java 文件源码 项目:CSS-Editor-FX 阅读 26 收藏 0 点赞 0 评论 0
public void showPopup() {
  PopupWindow popupWindow = codeArea.getPopupWindow();
  if (popupWindow != popup) {
    popupWindow.hide();
    codeArea.setPopupWindow(popup);
  }
  popup.show(codeArea.getScene().getWindow());
}
PopupTest.java 文件源码 项目:openjfx-8u-dev-tests 阅读 23 收藏 0 点赞 0 评论 0
private void pressEscOnPopup() {
    Wrap<? extends Scene> popupScene = Root.ROOT.lookup(new ByWindowType(PopupWindow.class)).lookup(Scene.class).wrap(0);
    popupScene.keyboard().pushKey(KeyboardButtons.ESCAPE);
}
SceneBuilderTest.java 文件源码 项目:openjfx-8u-dev-tests 阅读 20 收藏 0 点赞 0 评论 0
@Test
public void testPrototype() {
    //find Scene Builder scene
    final SceneDock sceneBuilder = new SceneDock(new ByTitleSceneLookup<>("Scene Builder", StringComparePolicy.SUBSTRING));
    //find library panel  by node ID using Scene Builder's scene as Parent
    ListViewDock library = new ListViewDock(sceneBuilder.asParent(), ID_LIBRARY_PANEL_LIST_VIEW);

    //find button in library
    ListItemDock button = new ListItemDock(library.asList(), new ByID("Button"));

    //show list item with button by scrolling listview
    button.shower().show();

    //find design surface by node ID "Anchor Pane".
    NodeDock designSurface = new NodeDock(sceneBuilder.asParent(), "AnchorPane");

    //drag list item with button and drop in center of design surface
    button.drag().dnd(designSurface.wrap(), designSurface.wrap().getClickPoint());

    //find properties panel by node ID
    TitledPaneDock titledPaneDock = new TitledPaneDock(sceneBuilder.asParent(), "Properties");

    //find text field for property "Text"
    TextInputControlDock textField = new TextInputControlDock(new NodeDock(titledPaneDock.asParent(), "TextValue").asParent());
    //clear and type text
    textField.clear();
    textField.type("Submit");
    //push enter to complete
    textField.keyboard().pushKey(Keyboard.KeyboardButtons.ENTER);

    //Add text field/////////////////////////////////////////////////////////////////////////////////////////////////////

    //find text field in library
    ListItemDock textFieldControl = new ListItemDock(library.asList(), new ByID("Text Field"));

    //show list item with text field by scrolling listview
    textFieldControl.shower().show();

    //drag list item with text field and drop on design surface near button
    textFieldControl.drag().dnd(designSurface.wrap(), designSurface.wrap().getClickPoint().translate(70, 50));

    //find text field on design surface and double click to invoke inline editing
    new TextInputControlDock(designSurface.asParent()).mouse().click(2);

    //find inline text field and type text "Name".
    TextInputControlDock inline = new TextInputControlDock(sceneBuilder.asParent(), ID_TEXT_INLINE_EDITING);
    inline.clear();
    inline.type("Name");
    inline.keyboard().pushKey(Keyboard.KeyboardButtons.ENTER);


    //show preview
    //find menu bar by ID then push "Preview" menu. Finally push "Show preview" menu item. All menu item have id's that help to find them.
    new MenuBarDock(sceneBuilder.asParent(), ID_MENU_BAR).menu().push(new ByIdMenuItem(ID_PREVIEW_MENU), new ByIdMenuItem(ID_PREVIEW_MENU_ITEM));

    //find preview scene. Criteria: scene is not existing scene builder scene and scene.getWindow is not PopupWindow
    SceneDock previewScene = new SceneDock(new LookupCriteria<Scene>() {
        @Override
        public boolean check(Scene cntrl) {
            return (cntrl != sceneBuilder.wrap().getControl() && !(cntrl.getWindow() instanceof PopupWindow));
        }
    });

    //find Button with text "Submit" on preview scene
    new LabeledDock(previewScene.asParent(), Button.class, new ByText<Button>("Submit"));
    //find TextField with text "Name" on preview scene
    new TextInputControlDock(previewScene.asParent(), TextField.class, new ByText<TextField>("Name"));


    try {
        Thread.sleep(5000);
    } catch (InterruptedException ex) {
        Logger.getLogger(SceneBuilderTest.class.getName()).log(Level.SEVERE, null, ex);
    }


}


问题


面经


文章

微信
公众号

扫码关注公众号