001/* 002 * #%L 003 * GwtMaterial 004 * %% 005 * Copyright (C) 2015 - 2017 GwtMaterialDesign 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package gwt.material.design.client.ui.pager; 021 022import com.google.gwt.dom.client.Document; 023import gwt.material.design.client.base.MaterialWidget; 024import gwt.material.design.client.base.constants.TableCssName; 025import gwt.material.design.client.constants.IconType; 026import gwt.material.design.client.constants.WavesType; 027import gwt.material.design.client.ui.MaterialIcon; 028import gwt.material.design.client.ui.html.Span; 029 030/** 031 * Widget for building the action panel - contains a page detail including the arrow next / previous icons. 032 * 033 * @author kevzlou7979 034 */ 035public class PageActionsPanel extends MaterialWidget { 036 037 private final MaterialDataPager pager; 038 protected Span actionLabel = new Span(); 039 protected MaterialIcon iconNext = new MaterialIcon(IconType.KEYBOARD_ARROW_RIGHT); 040 protected MaterialIcon iconPrev = new MaterialIcon(IconType.KEYBOARD_ARROW_LEFT); 041 042 public PageActionsPanel(MaterialDataPager pager) { 043 super(Document.get().createDivElement(), TableCssName.ACTION_PAGE_PANEL); 044 setGrid("s12 m4 l3"); 045 this.pager = pager; 046 } 047 048 @Override 049 protected void onLoad() { 050 super.onLoad(); 051 052 // Add the next button 053 iconNext.setWaves(WavesType.DEFAULT); 054 iconNext.setCircle(true); 055 add(iconNext); 056 057 // Add the action label 058 add(actionLabel); 059 060 // Add the previous button 061 iconPrev.setWaves(WavesType.DEFAULT); 062 iconPrev.setCircle(true); 063 add(iconPrev); 064 065 // Register the handlers 066 registerHandler(iconNext.addClickHandler(clickEvent -> pager.next())); 067 registerHandler(iconPrev.addClickHandler(clickEvent -> pager.previous())); 068 } 069 070 public Span getActionLabel() { 071 return actionLabel; 072 } 073 074 public MaterialIcon getIconNext() { 075 return iconNext; 076 } 077 078 public MaterialIcon getIconPrev() { 079 return iconPrev; 080 } 081}