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; 021 022import com.google.gwt.dom.client.Element; 023import com.google.gwt.user.client.DOM; 024import gwt.material.design.client.base.AbstractIconButton; 025import gwt.material.design.client.constants.ButtonType; 026import gwt.material.design.client.constants.IconType; 027 028//@formatter:off 029 030/** 031 * Using Material Link you can easily add href functionality into your app for navigation 032 * <h3>UiBinder Usage:</h3> 033 * <pre> 034 * {@code 035 * Links 036 * <m:MaterialLink href="#normal" text="Normal Link" textColor="RED" iconType="POLYMER" iconPosition="LEFT"/> 037 * 038 * <m:MaterialLink href="#material" text="Link with Href" textColor="RED" iconType="POLYMER" iconPosition="LEFT"/> 039 * 040 * <m:MaterialLink href="#design" text="Link with Different Icon color" textColor="BLACK" iconType="POLYMER" iconPosition="LEFT" iconColor="RED"/>} 041 * </pre> 042 * 043 * @author kevzlou7979 044 * @author Ben Dol 045 * @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#buttons">Material Link</a> 046 * @see <a href="https://material.io/guidelines/components/buttons.html">Material Design Specification</a> 047 */ 048//@formatter:on 049public class MaterialLink extends AbstractIconButton { 050 051 public MaterialLink(ButtonType type, String text, MaterialIcon icon) { 052 super(type, text, icon); 053 } 054 055 public MaterialLink(String text, MaterialIcon icon) { 056 super(ButtonType.LINK, text, icon); 057 } 058 059 public MaterialLink(IconType iconType) { 060 super(iconType); 061 } 062 063 public MaterialLink(String text) { 064 super(ButtonType.LINK, text); 065 } 066 067 public MaterialLink(String text, String href) { 068 this(text); 069 070 setTargetHistoryToken(href); 071 } 072 073 public MaterialLink(String text, String href, IconType icon) { 074 this(text, href); 075 076 setIconType(icon); 077 } 078 079 public MaterialLink() { 080 super(ButtonType.LINK); 081 } 082 083 @Override 084 protected Element createElement() { 085 return DOM.createAnchor(); 086 } 087}