java类javafx.scene.control.ListCell的实例源码

HostController.java 文件源码 项目:phone-simulator 阅读 38 收藏 0 点赞 0 评论 0
/**
 * Initializes the controller class.
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
    UssdClient.impl.showData(cboChanel, cboRole, txtLocalHost, txtLocalPort, txtRemoteHost, txtRemotePort, txtPhone);
    cboChanel.setCellFactory((ListView<EnumeratedBase> param) -> new ListCell<EnumeratedBase>() {
        @Override
        protected void updateItem(EnumeratedBase item, boolean empty) {
            super.updateItem(item, empty);
            if (item == null || empty) {
                setText(null);
            } else {
                setText(item.toString());
            }
        }

    });
}
ListCellFactory.java 文件源码 项目:Matcher 阅读 35 收藏 0 点赞 0 评论 0
@Override
public ListCell<T> call(ListView<T> list) {
    return new ListCell<T>() {
        @Override
        protected void updateItem(T item, boolean empty) {
            super.updateItem(item, empty);

            if (empty || item == null) {
                setText(null);
                setStyle("");
            } else {
                setText(ListCellFactory.this.getText(item));
                setStyle(ListCellFactory.this.getStyle(item));
            }
        }
    };
}
ListViewCellFactorySample.java 文件源码 项目:marathonv5 阅读 37 收藏 0 点赞 0 评论 0
public ListViewCellFactorySample() {
    final ListView<Number> listView = new ListView<Number>();
    listView.setItems(FXCollections.<Number>observableArrayList(
            100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
            430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
            15.00, 47.50, 12.11

    ));

    listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
        @Override public ListCell<Number> call(ListView<java.lang.Number> list) {
            return new MoneyFormatCell();
        }
    });        

    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getChildren().add(listView);
}
MarathonFileChooser.java 文件源码 项目:marathonv5 阅读 44 收藏 0 点赞 0 评论 0
private void initListView() {
    if (!doesAllowChildren) {
        fillUpChildren(fileChooserInfo.getRoot());
    }
    childrenListView.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
        @Override public ListCell<File> call(ListView<File> param) {
            return new ChildrenFileCell();
        }
    });
    childrenListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (fileChooserInfo.isFileCreation()) {
            return;
        }
        File selectedItem = childrenListView.getSelectionModel().getSelectedItem();
        if (selectedItem == null) {
            fileNameBox.clear();
        }
    });
}
RunHistoryStage.java 文件源码 项目:marathonv5 阅读 44 收藏 0 点赞 0 评论 0
private void initComponents() {
    VBox.setVgrow(historyView, Priority.ALWAYS);
    historyView.setItems(FXCollections.observableArrayList(runHistoryInfo.getTests()));
    historyView.setCellFactory(new Callback<ListView<JSONObject>, ListCell<JSONObject>>() {
        @Override public ListCell<JSONObject> call(ListView<JSONObject> param) {
            return new HistoryStateCell();
        }
    });

    VBox historyBox = new VBox(5);
    HBox.setHgrow(historyBox, Priority.ALWAYS);

    countField.setText(getRemeberedCount());
    if (countNeeded) {
        form.addFormField("Max count of remembered runs: ", countField);
    }
    historyBox.getChildren().addAll(new Label("Select test", FXUIUtils.getIcon("params")), historyView, form);

    verticalButtonBar.setId("vertical-buttonbar");
    historyPane.setId("history-pane");
    historyPane.getChildren().addAll(historyBox, verticalButtonBar);

    doneButton.setOnAction((e) -> onOK());
    buttonBar.setButtonMinWidth(Region.USE_PREF_SIZE);
    buttonBar.getButtons().addAll(doneButton);
}
CompositeLayout.java 文件源码 项目:marathonv5 阅读 46 收藏 0 点赞 0 评论 0
private void initComponents() {
    optionBox.setItems(model);
    optionBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        if (newValue != null) {
            updateTabPane();
        }
    });
    optionBox.setCellFactory(new Callback<ListView<PlugInModelInfo>, ListCell<PlugInModelInfo>>() {
        @Override public ListCell<PlugInModelInfo> call(ListView<PlugInModelInfo> param) {
            return new LauncherCell();
        }
    });
    optionTabpane.setId("CompositeTabPane");
    optionTabpane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
    optionTabpane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);
    VBox.setVgrow(optionTabpane, Priority.ALWAYS);
}
JavaFXElementPropertyAccessor.java 文件源码 项目:marathonv5 阅读 37 收藏 0 点赞 0 评论 0
protected int getIndexAt(ListView<?> listView, Point2D point) {
    if (point == null) {
        return listView.getSelectionModel().getSelectedIndex();
    }
    point = listView.localToScene(point);
    Set<Node> lookupAll = getListCells(listView);
    ListCell<?> selected = null;
    for (Node cellNode : lookupAll) {
        Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
        if (boundsInScene.contains(point)) {
            selected = (ListCell<?>) cellNode;
            break;
        }
    }
    if (selected == null) {
        return -1;
    }
    return selected.getIndex();
}
ListViewCellFactorySample.java 文件源码 项目:marathonv5 阅读 34 收藏 0 点赞 0 评论 0
public ListViewCellFactorySample() {
    final ListView<Number> listView = new ListView<Number>();
    listView.setItems(FXCollections.<Number>observableArrayList(
            100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
            430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
            15.00, 47.50, 12.11

    ));

    listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
        @Override public ListCell<Number> call(ListView<java.lang.Number> list) {
            return new MoneyFormatCell();
        }
    });        

    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getChildren().add(listView);
}
SimpleListViewScrollSample.java 文件源码 项目:marathonv5 阅读 48 收藏 0 点赞 0 评论 0
@Override public void start(Stage primaryStage) throws Exception {
    final ListView<String> listView = new ListView<String>();
    listView.setItems(FXCollections.observableArrayList("Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6", "Row 7",
            "Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13", "Row 14", "Row 15", "Row 16", "Row 17", "Row 18",
            "Row 19", "Row 20", "Row 21", "Row 22", "Row 23", "Row 24", "Row 25"));
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    Button button = new Button("Debug");
    button.setOnAction((e) -> {
        ObservableList<Integer> selectedIndices = listView.getSelectionModel().getSelectedIndices();
        for (Integer index : selectedIndices) {
            ListCell cellAt = getCellAt(listView, index);
            System.out.println("SimpleListViewScrollSample.SimpleListViewScrollSampleApp.start(" + cellAt + ")");
        }
    });
    VBox root = new VBox(listView, button);
    primaryStage.setScene(new Scene(root, 300, 400));
    primaryStage.show();
}
SiderBarView.java 文件源码 项目:javafx-qiniu-tinypng-client 阅读 31 收藏 0 点赞 0 评论 0
void initView() {
    listview.setCellFactory(param -> new ListCell<String>() {
        @Override
        protected void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            if (!empty) {
                BucketItemView view = new BucketItemView();
                view.setBucketName(item);
                setGraphic(view);
            } else {
                setGraphic(null);
            }
        }
    });
    listview.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (StringUtils.isNotEmpty(newValue)) {
            if (this.itemSelectListener != null) {
                this.itemSelectListener.onItemSelected(newValue);
            }
        }
    });
}
PatientHistoryController.java 文件源码 项目:Dr-Assistant 阅读 41 收藏 0 点赞 0 评论 0
private void loadPatientHistory() {
    prescriptions = prescriptionGetway.patientPrescriptions(patient);
    prescriptionList.getItems().addAll(prescriptions);
    prescriptionList.getSelectionModel().select(0);

    prescriptionList.setCellFactory(param -> new ListCell<Prescription>() {
        @Override
        protected void updateItem(Prescription item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null || item.getDate() == null) {
                setText(null);
            } else {
                setText(item.getDate());
            }
        }
    });

    showPrescription();
}
ExercisePresenter.java 文件源码 项目:ABC-List 阅读 33 收藏 0 点赞 0 评论 0
private void initializeComboBoxTimeChooser() {
    LoggerFacade.getDefault().info(this.getClass(), "Initialize [ComboBox] [TimeChooser]"); // NOI18N

    cbTimeChooser.setCellFactory((ListView<ETime> listview) -> new ListCell<ETime>() {
        @Override
        public void updateItem(ETime time, boolean empty) {
            super.updateItem(time, empty);
            this.setGraphic(null);
            this.setText(!empty ? time.toString() : null);
        }
    });

    final ObservableList<ETime> observableListTimes = FXCollections.observableArrayList();
    observableListTimes.addAll(ETime.values());
    cbTimeChooser.getItems().addAll(observableListTimes);
    cbTimeChooser.getSelectionModel().selectFirst();
}
PathSetter.java 文件源码 项目:voogasalad-ltub 阅读 39 收藏 0 点赞 0 评论 0
public PathSetter(ObservableList<Path> paths, String variableName){
    super(Path.class,variableName);
    this.myPaths=paths;     

    pathChoices= new ComboBox<>(myPaths);

    pathChoices.setCellFactory(new Callback<ListView<Path>, ListCell<Path>>(){
        @Override
        public ListCell<Path> call(ListView<Path> list){
            return new PathCell();
        }
    });
    pathChoices.setButtonCell(new PathButtonCell());

    this.getChildren().add(pathChoices);

}
ComponentSelectorPane.java 文件源码 项目:voogasalad-ltub 阅读 37 收藏 0 点赞 0 评论 0
public ComponentSelectorPane(String listTitle, ObservableList<Class<? extends Component>> displayedData, SpriteDataPane infoPane) {
    this.infoPane=infoPane;
    this.setPrefWidth(PREF_WIDTH);
    ListView<Class<? extends Component>> componentDisplay = new ListView<>();
    componentDisplay.setItems(displayedData);

    componentDisplay.setCellFactory(
            new Callback<ListView<Class<? extends Component>>, ListCell<Class<? extends Component>>>() {
                @Override
                public ListCell<Class<? extends Component>> call(ListView<Class<? extends Component>> list) {
                    return new ComponentCustomizerOption();
                }
            });

    Label title = new Label(listTitle);
    this.getChildren().addAll(title, componentDisplay);
}
CloudNoticeManagerController.java 文件源码 项目:Java-9-Programming-Blueprints 阅读 31 收藏 0 点赞 0 评论 0
@Override
public void initialize(URL url, ResourceBundle rb) {
    recips.setAll(dao.getRecipients());
    topics.setAll(sns.getTopics());

    type.setItems(types);
    recipList.setItems(recips);
    topicCombo.setItems(topics);

    recipList.setCellFactory(p -> new ListCell<Recipient>() {
        @Override
        public void updateItem(Recipient recip, boolean empty) {
            super.updateItem(recip, empty);
            if (!empty) {
                setText(String.format("%s - %s", recip.getType(), recip.getAddress()));
            } else {
                setText(null);
            }
        }
    });
    recipList.getSelectionModel().selectedItemProperty().addListener((obs, oldRecipient, newRecipient) -> {
        type.valueProperty().setValue(newRecipient != null ? newRecipient.getType() : "");
        address.setText(newRecipient != null ? newRecipient.getAddress() : "");
    });
}
DailySectionChooserDialogPresenter.java 文件源码 项目:Incubator 阅读 34 收藏 0 点赞 0 评论 0
private void initializeCombBox() {
    LoggerFacade.INSTANCE.info(this.getClass(), "Initialize ComboBox"); // NOI18N

    // Define rendering of the list of values in ComboBox drop down. 
    lvDailySections.setCellFactory(listView -> new ListCell<DailySectionModel>() {
        @Override
        public void updateItem(DailySectionModel item, boolean empty) {
            super.updateItem(item, empty);

            if (
                    item == null
                    || empty
            ) {
                super.setText(null);
            } else {
                super.setText(item.getDailyDate());
            }
        }
    });
}
DebugComponentsPresenter.java 文件源码 项目:Incubator 阅读 32 收藏 0 点赞 0 评论 0
private void initializeSimulateGameLevel() {
    DebugConsole.getDefault().info(this.getClass(), "Initialize simulate GameLevel"); // NOI18N

    cbSimulateGameLevel.getItems().addAll(EGameLevel.values());
    cbSimulateGameLevel.setCellFactory(new Callback<ListView<EGameLevel>, ListCell<EGameLevel>>() {
        @Override
        public ListCell<EGameLevel> call(ListView<EGameLevel> listView) {
            return new ListCell<EGameLevel>() {
                @Override
                protected void updateItem(EGameLevel item, boolean empty) {
                    super.updateItem(item, empty);

                    if (item == null || empty) {
                        setText(null);
                    } else {
                        setText(item.toString());
                    }
                }
            };
        }
    });
    cbSimulateGameLevel.getSelectionModel().selectFirst();
}
DebugComponentsPresenter.java 文件源码 项目:Incubator 阅读 35 收藏 0 点赞 0 评论 0
private void initializeSimulateGameMode() {
    DebugConsole.getDefault().info(this.getClass(), "Initialize simulate GameMode"); // NOI18N

    cbSimulateGameMode.getItems().addAll(EGameMode.values());
    cbSimulateGameMode.setCellFactory(new Callback<ListView<EGameMode>, ListCell<EGameMode>>() {
        @Override
        public ListCell<EGameMode> call(ListView<EGameMode> listView) {
            return new ListCell<EGameMode>() {
                @Override
                protected void updateItem(EGameMode item, boolean empty) {
                    super.updateItem(item, empty);

                    if (item == null || empty) {
                        setText(null);
                    } else {
                        setText(item.toString());
                    }
                }
            };
        }
    });
    cbSimulateGameMode.getSelectionModel().selectFirst();
}
ListViewFileCellFactory.java 文件源码 项目:Gargoyle 阅读 38 收藏 0 点赞 0 评论 0
@Override
public ListCell<File> call(ListView<File> param) {
    return new ListCell<File>() {

        @Override
        protected void updateItem(File item, boolean empty) {
            super.updateItem(item, empty);

            if (!empty) {
                setText(String.format("%s       ( %,d KB )", item.getName(), (item.length() / 1024)));
            } else {
                setText("");
            }
        }

    };
}
KeyTestingController.java 文件源码 项目:chvote-1-0 阅读 39 收藏 0 点赞 0 评论 0
private void customizeCipherTextCellFactory() {
    cipherTextList.setCellFactory(new Callback<ListView<AuthenticatedBallot>, ListCell<AuthenticatedBallot>>() {
        @Override
        public ListCell<AuthenticatedBallot> call(ListView<AuthenticatedBallot> param) {
            return new ListCell<AuthenticatedBallot>() {
                @Override
                protected void updateItem(AuthenticatedBallot item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        setText(DatatypeConverter.printHexBinary(item.getAuthenticatedEncryptedBallot()));
                    }
                }
            };
        }
    });
}
HListViewAddRemoveTest.java 文件源码 项目:openjfx-8u-dev-tests 阅读 41 收藏 0 点赞 0 评论 0
protected void extraTestingForLongItem() {
    list.as(Selectable.class).selector().select("string");
    //check that right side of the long item is within the listview
    final Wrap<? extends ListCell> longCell = list.as(Parent.class, Node.class).
            lookup(ListCell.class, new LookupCriteria<ListCell>() {

        public boolean check(ListCell cntrl) {
            return cntrl.getItem() != null &&
                    cntrl.getItem().toString().contains(ListViewApp.createLongItem(0));
        }
    }).wrap();
    longCell.waitState(new State() {

        public Object reached() {
            Rectangle bounds = longCell.getScreenBounds();
            Rectangle listBounds = list.getScreenBounds();
            return ((bounds.x + bounds.width) >= listBounds.x) &&
                    ((bounds.x + bounds.width) <= (listBounds.x+ listBounds.width)) ?
                        true : null;
        }
    });
}
ListViewCellFactoryAccessor.java 文件源码 项目:reduxfx 阅读 32 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
@Override
protected void updateItem(Object data, boolean empty) {
    super.updateItem(data, empty);

    if (empty || data == null) {
        setText(null);
        setGraphic(null);
    } else {
        final Object item = mapping.apply(data);
        if (item instanceof VNode) {
            final VNode newVNode = VScenegraphFactory.customNode(ListCell.class).child("graphic", (VNode) item);
            final Option<VNode> oldVNode = Option.of(getGraphic()).flatMap(node -> Option.of((VNode) node.getUserData()));
            final Map<Phase, Vector<Patch>> patches = Differ.diff(oldVNode, Option.of(newVNode));
            Patcher.patch(dispatcher, this, oldVNode, patches);
            Option.of(getGraphic()).forEach(node -> node.setUserData(newVNode));
        } else {
            this.setText(String.valueOf(item));
            this.setGraphic(null);
        }
    }
}
PlaylistListCellFactoryTest.java 文件源码 项目:rpmjukebox 阅读 43 收藏 0 点赞 0 评论 0
@Test
public void shouldOpenContextMenuOnReservedPlaylist() {
    ListView<Playlist> listView = getListView();
    ListCell<Playlist> listCell = cellFactory.call(listView);

    listCell.updateListView(listView);
    listCell.updateIndex(0);

    listCell.onContextMenuRequestedProperty().get().handle(getContextMenuEvent(listCell));

    MenuItem newPlaylistItem = listCell.getContextMenu().getItems().get(0);
    MenuItem deletePlaylistItem = listCell.getContextMenu().getItems().get(1);

    assertThat("New playlist item should be disabled", newPlaylistItem.isDisable(), equalTo(true));
    assertThat("Delete playlist item should be disabled", deletePlaylistItem.isDisable(), equalTo(true));
}
PlaylistListCellFactoryTest.java 文件源码 项目:rpmjukebox 阅读 35 收藏 0 点赞 0 评论 0
@Test
public void shouldOpenContextMenuOnUserPlaylist() {
    ListView<Playlist> listView = getListView();
    ListCell<Playlist> listCell = cellFactory.call(listView);

    listCell.updateListView(listView);
    listCell.updateIndex(2);

    listCell.onContextMenuRequestedProperty().get().handle(getContextMenuEvent(listCell));

    MenuItem newPlaylistItem = listCell.getContextMenu().getItems().get(0);
    MenuItem deletePlaylistItem = listCell.getContextMenu().getItems().get(1);

    assertThat("New playlist item should be disabled", newPlaylistItem.isDisable(), equalTo(true));
    assertThat("Delete playlist item should not be disabled", deletePlaylistItem.isDisable(), equalTo(false));
}
PlaylistListCellFactoryTest.java 文件源码 项目:rpmjukebox 阅读 45 收藏 0 点赞 0 评论 0
@Test
public void shouldOpenContextMenuBelowPlaylists() {
    ListView<Playlist> listView = getListView();
    ListCell<Playlist> listCell = cellFactory.call(listView);

    listCell.updateListView(listView);
    listCell.updateIndex(10);

    listCell.onContextMenuRequestedProperty().get().handle(getContextMenuEvent(listCell));

    MenuItem newPlaylistItem = listCell.getContextMenu().getItems().get(0);
    MenuItem deletePlaylistItem = listCell.getContextMenu().getItems().get(1);

    assertThat("New playlist item should not be disabled", newPlaylistItem.isDisable(), equalTo(false));
    assertThat("Delete playlist item should be disabled", deletePlaylistItem.isDisable(), equalTo(true));
}
PlaylistListCellFactoryTest.java 文件源码 项目:rpmjukebox 阅读 45 收藏 0 点赞 0 评论 0
@Test
public void shouldTriggerDragEntered() {
    ListCell<Playlist> listCell = cellFactory.call(getListView());
    listCell.setItem(new Playlist(1, "Playlist", 10));
    listCell.setStyle(null);

    Dragboard mockDragboard = mock(Dragboard.class);
    when(mockDragboard.hasContent(DND_TRACK_DATA_FORMAT)).thenReturn(true);

    DragEvent spyDragEvent = spy(getDragEvent(DragEvent.DRAG_OVER, mockDragboard, TransferMode.COPY, new Object()));

    listCell.onDragEnteredProperty().get().handle(spyDragEvent);

    assertThat("List cell style should not be empty", listCell.getStyle(), not(isEmptyString()));
    verify(spyDragEvent, times(1)).consume();
}
PlaylistListCellFactoryTest.java 文件源码 项目:rpmjukebox 阅读 88 收藏 0 点赞 0 评论 0
@Test
public void shouldNotTriggerDragEnterdWithSameSource() {
    ListCell<Playlist> listCell = cellFactory.call(getListView());
    listCell.setItem(new Playlist(1, "Playlist", 10));
    listCell.setStyle(null);

    Dragboard mockDragboard = mock(Dragboard.class);
    when(mockDragboard.hasContent(DND_TRACK_DATA_FORMAT)).thenReturn(true);

    DragEvent spyDragEvent = spy(getDragEvent(DragEvent.DRAG_OVER, mockDragboard, TransferMode.COPY, listCell));

    listCell.onDragEnteredProperty().get().handle(spyDragEvent);

    assertThat("List cell style should be empty", listCell.getStyle(), isEmptyString());
    verify(spyDragEvent, times(1)).consume();
}
PlaylistListCellFactoryTest.java 文件源码 项目:rpmjukebox 阅读 43 收藏 0 点赞 0 评论 0
@Test
public void shouldNotTriggerDragEnteredWithNoContent() {
    ListCell<Playlist> listCell = cellFactory.call(getListView());
    listCell.setItem(new Playlist(1, "Playlist", 10));
    listCell.setStyle(null);

    Dragboard mockDragboard = mock(Dragboard.class);
    when(mockDragboard.hasContent(DND_TRACK_DATA_FORMAT)).thenReturn(false);

    DragEvent spyDragEvent = spy(getDragEvent(DragEvent.DRAG_OVER, mockDragboard, TransferMode.COPY, new Object()));

    listCell.onDragEnteredProperty().get().handle(spyDragEvent);

    assertThat("List cell style should be empty", listCell.getStyle(), isEmptyString());
    verify(spyDragEvent, times(1)).consume();
}
PlaylistListCellFactoryTest.java 文件源码 项目:rpmjukebox 阅读 39 收藏 0 点赞 0 评论 0
@Test
public void shouldNotTriggerDragEnteredWithNoPlaylist() {
    ListCell<Playlist> listCell = cellFactory.call(getListView());
    listCell.setItem(null);
    listCell.setStyle(null);

    Dragboard mockDragboard = mock(Dragboard.class);
    when(mockDragboard.hasContent(DND_TRACK_DATA_FORMAT)).thenReturn(true);

    DragEvent spyDragEvent = spy(getDragEvent(DragEvent.DRAG_OVER, mockDragboard, TransferMode.COPY, new Object()));

    listCell.onDragEnteredProperty().get().handle(spyDragEvent);

    assertThat("List cell style should be empty", listCell.getStyle(), isEmptyString());
    verify(spyDragEvent, times(1)).consume();
}
PlaylistListCellFactoryTest.java 文件源码 项目:rpmjukebox 阅读 39 收藏 0 点赞 0 评论 0
@Test
public void shouldNotTriggerDragEnteredWithReservedPlaylist() {
    ListCell<Playlist> listCell = cellFactory.call(getListView());
    listCell.setItem(new Playlist(PLAYLIST_ID_FAVOURITES, "Favourites", 10));
    listCell.setStyle(null);

    Dragboard mockDragboard = mock(Dragboard.class);
    when(mockDragboard.hasContent(DND_TRACK_DATA_FORMAT)).thenReturn(true);

    DragEvent spyDragEvent = spy(getDragEvent(DragEvent.DRAG_OVER, mockDragboard, TransferMode.COPY, new Object()));

    listCell.onDragEnteredProperty().get().handle(spyDragEvent);

    assertThat("List cell style should be empty", listCell.getStyle(), isEmptyString());
    verify(spyDragEvent, times(1)).consume();
}


问题


面经


文章

微信
公众号

扫码关注公众号