001    package org.apache.myfaces.tobago.taglib.component;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  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     */
019    
020    import org.apache.commons.logging.Log;
021    import org.apache.commons.logging.LogFactory;
022    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
023    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
024    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TARGET;
025    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
026    import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_BUTTON;
027    import org.apache.myfaces.tobago.component.ComponentUtil;
028    import org.apache.myfaces.tobago.util.Deprecation;
029    
030    import javax.faces.component.UIComponent;
031    
032    
033    public class ToolBarCommandTag extends AbstractCommandTag
034        implements ToolBarCommandTagDeclaration {
035    
036      private static final Log LOG = LogFactory.getLog(ToolBarCommandTag.class);
037    
038      private String label;
039      private String image;
040      private String tip;
041      private String target;
042    
043      protected void setProperties(UIComponent component) {
044        super.setProperties(component);
045        component.setRendererType(RENDERER_TYPE_BUTTON);
046        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
047        ComponentUtil.setStringProperty(component, ATTR_IMAGE, image);
048        ComponentUtil.setStringProperty(component, ATTR_TIP, tip);
049        ComponentUtil.setStringProperty(component, ATTR_TARGET, target);
050      }
051    
052      public void release() {
053        super.release();
054        label = null;
055        image = null;
056        tip = null;
057        target = null;
058      }
059    
060      public String getImage() {
061        return image;
062      }
063    
064      public void setImage(String image) {
065        this.image = image;
066      }
067    
068      public String getLabel() {
069        return label;
070      }
071    
072      public void setLabel(String label) {
073        this.label = label;
074      }
075    
076      public void setTip(String tip) {
077        this.tip = tip;
078      }
079    
080      public String getTarget() {
081        return target;
082      }
083    
084      public void setTarget(String target) {
085        this.target = target;
086      }
087    
088      public String getAccessKey() {
089        return null;
090      }
091    
092      public void setAccessKey(String accessKey) {
093        if (Deprecation.LOG.isErrorEnabled()) {
094          Deprecation.LOG.error("Attribute 'accessKey' doesn't work any longer "
095              + "and will removed soon! Please use special syntax of 'label' instead.");
096        }
097      }
098    
099      public String getLabelWithAccessKey() {
100        return null;
101      }
102    
103      public void setLabelWithAccessKey(String labelWithAccessKey) {
104        if (Deprecation.LOG.isWarnEnabled()) {
105          Deprecation.LOG.warn("Attribute 'labelWithAccessKey' is deprecated, "
106              + "and will removed soon! Please use 'label' instead.");
107        }
108        setLabel(labelWithAccessKey);
109      }
110    }
111