本文整理汇总了Java中ensemble.search.DocumentType类的典型用法代码示例。如果您正苦于以下问题:Java DocumentType类的具体用法?Java DocumentType怎么用?Java DocumentType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentType类属于ensemble.search包,在下文中一共展示了DocumentType类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateMenu
import ensemble.search.DocumentType; //导入依赖的package包/类
private void populateMenu(Map<DocumentType, List<SearchResult>> results) {
contextMenu.getItems().clear();
for (Map.Entry<DocumentType, List<SearchResult>> entry : results.entrySet()) {
boolean first = true;
for(SearchResult result: entry.getValue()) {
final SearchResult sr = result;
final HBox hBox = new HBox();
hBox.setFillHeight(true);
Label itemLabel = new Label(result.getName());
itemLabel.getStyleClass().add("item-label");
if (first) {
first = false;
Label groupLabel = new Label(result.getDocumentType().getPluralDisplayName());
groupLabel.getStyleClass().add("group-label");
groupLabel.setAlignment(Pos.CENTER_RIGHT);
groupLabel.setMinWidth(USE_PREF_SIZE);
groupLabel.setPrefWidth(70);
hBox.getChildren().addAll(groupLabel,itemLabel);
} else {
Region spacer = new Region();
spacer.setMinWidth(USE_PREF_SIZE);
spacer.setPrefWidth(70);
hBox.getChildren().addAll(spacer,itemLabel);
}
// create a special node for hiding/showing popup content
final Region popRegion = new Region();
popRegion.getStyleClass().add("search-menu-item-popup-region");
popRegion.setPrefSize(10, 10);
hBox.getChildren().add(popRegion);
final String name = (result.getDocumentType() == DocumentType.SAMPLE) ? result.getName() :
result.getPackageName()+
((result.getClassName() != null) ? "."+result.getClassName() : "") +
((result.getName() != null) ? "."+result.getName() : "");
final String shortDescription = (result.getShortDescription().length() == 160) ? result.getShortDescription() +"..." : result.getShortDescription();
popRegion.opacityProperty().addListener(new ChangeListener<Number>() {
@Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
Platform.runLater( new Runnable() { // TODO runLater used here as a workaround for RT-14396
@Override public void run() {
if (popRegion.getOpacity() == 1) {
infoName.setText(name);
infoDescription.setText(shortDescription);
Point2D hBoxPos = hBox.localToScene(0, 0);
extraInfoPopup.show(getScene().getWindow(),
hBoxPos.getX() + contextMenu.getScene().getX() + contextMenu.getX() - infoBox.getPrefWidth() - 10,
hBoxPos.getY() + contextMenu.getScene().getY() + contextMenu.getY() - 27
);
}
}
});
}
});
// create menu item
CustomMenuItem menuItem = new CustomMenuItem(hBox, true);
menuItem.getStyleClass().add("search-menu-item");
contextMenu.getItems().add(menuItem);
// handle item selection
menuItem.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
///System.out.println("SearchBox.handle menuItem.setOnAction");
Ensemble2.getEnsemble2().goToPage(sr.getEnsemblePath(),true);
}
});
}
}
}