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


Java CharmListCell类代码示例

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


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

示例1: updateItem

import com.gluonhq.charm.glisten.control.CharmListCell; //导入依赖的package包/类
@Override
public void updateItem(T item, boolean empty) {
    super.updateItem(item, empty); 
    if (item != null && !empty) {
        CharmListCell<T> currentCell = getCell(item.getClass().getSimpleName());
        if (currentCell == null) {
            setText(null);
            setGraphic(null);
            setStyle(null);
            getStyleClass().setAll(DEFAULT);
            changePseudoClass(null);
        } else {
            currentCell.updateItem(item, empty);
            setText(currentCell.getText());
            setGraphic(currentCell.getGraphic());
            setStyle(currentCell.getStyle());
            getStyleClass().setAll(currentCell.getStyleClass());
            changePseudoClass(currentCell.getPseudoClassStates());
        }
    } else {
        setText(null);
        setGraphic(null);
        setStyle(null);
        getStyleClass().setAll(DEFAULT);
        changePseudoClass(null);
    }
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:28,代码来源:SearchCell.java

示例2: getCell

import com.gluonhq.charm.glisten.control.CharmListCell; //导入依赖的package包/类
private CharmListCell<T> getCell(String name) {
    if (cellsCache.get(name) == null || cellsCache.get(name).get() == null) {
        cellsCache.remove(name);
        registerCell(name);
    }
    return cellsCache.get(name).get();
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:8,代码来源:SearchCell.java

示例3: TraplineListView

import com.gluonhq.charm.glisten.control.CharmListCell; //导入依赖的package包/类
public TraplineListView(TrapDataService dataService) {
      super(NAME);
      this.dataService = dataService;
      
      ReadOnlyDoubleProperty deviceWidth = this.widthProperty();
      
      //Create an alphabetically sorted view of the trapline list, so traplines appear in alphabetical order
      SortedList<Trapline> sortedList = new SortedList<>(dataService.getTraplines(), (t1, t2) -> {
      	if (t1 == null && t2 == null) {
              return 0;
          } else if (t1 == null) {
              return -1;
          } else if (t2 == null) {
              return 1;
          } else {
          	return t1.getName().compareToIgnoreCase(t2.getName());
          }
      });
      
      traplineList = new CharmListView<>(sortedList);
      traplineList.setHeadersFunction(Trapline::getRegion);
      traplineList.setConverter(new StringConverter <Region>() {
          @Override public String toString(Region r) {
              return r.getName();
          }
	@Override public Region fromString(String string) {
		throw new UnsupportedOperationException("Not supported!");
	}
      });
      traplineList.setId("trapline-list");
      traplineList.setCellFactory(list -> new CharmListCell<Trapline>() {
      	Button button = new Button();
      	Trapline trapline;
      	
      	{
      		this.setGraphic(button);
      		
      		//Prevent long trapline names from expanding the size of buttons to cause side scrolling
      		//NOTE: This assumes a total left & right padding of less than 16 for the parent cell. Higher padding values will cause the scroll bar to re-appear
      		double padding = 16;
      		button.maxWidthProperty().bind(Bindings.subtract(deviceWidth, padding));
      		
      		button.setOnAction(evt -> {
      			LOG.log(Level.INFO, "Pressed trapline: "+trapline);
      			TraplineInfoView infoView = ((NestApplication) TraplineListView.this.getApplication()).lookupView(TraplineInfoView.NAME);
      			infoView.setTrapline(trapline);
      			TraplineListView.this.getApplication().switchView(TraplineInfoView.NAME);
      		});
      	}
      	
      	@Override public void updateItem (Trapline item, boolean empty) {
      		super.updateItem(item, empty);
      		trapline = item;
      		if(item!=null && !empty){
      			button.setText(item.getName());
              } else {
              	button.setText(null);
              }
      	}
      });
		
      this.setOnShown(evt -> {
  		if (dataService.isNetworkAvailable() &&
  				(lastTraplineFetch == null || lastTraplineFetch.plusHours(REFRESH_FREQUENCY).isBefore(LocalDateTime.now()))) {
  			LOG.log(Level.INFO, "Refreshing trapline list. Last refresh: "+lastTraplineFetch);
  			refreshTraplines();//Load the traplines if (a) they haven't been loaded yet or (b) at least an hour has passed since their last load  			
  		}
      });
      
      this.setOnHidden(evt -> {

      });
      
      setCenter(traplineList);
menu = buildMenu();
      
  }
 
开发者ID:FrancisG-Massey,项目名称:Capstone2016,代码行数:78,代码来源:TraplineListView.java


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