001    /*
002     *  Copyright 2012 GWT-Bootstrap
003     *
004     *  Licensed under the Apache License, Version 2.0 (the "License");
005     *  you may not use this file except in compliance with the License.
006     *  You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     *  Unless required by applicable law or agreed to in writing, software
011     *  distributed under the License is distributed on an "AS IS" BASIS,
012     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     *  See the License for the specific language governing permissions and
014     *  limitations under the License.
015     */
016    package com.github.gwtbootstrap.client.ui;
017    
018    import com.github.gwtbootstrap.client.ui.base.HasAlternateSize;
019    import com.github.gwtbootstrap.client.ui.base.HasId;
020    import com.github.gwtbootstrap.client.ui.base.HasSize;
021    import com.github.gwtbootstrap.client.ui.base.IsSearchQuery;
022    import com.github.gwtbootstrap.client.ui.base.SearchQueryStyleHelper;
023    import com.github.gwtbootstrap.client.ui.base.SizeHelper;
024    import com.github.gwtbootstrap.client.ui.base.StyleHelper;
025    import com.github.gwtbootstrap.client.ui.constants.AlternateSize;
026    import com.github.gwtbootstrap.client.ui.constants.Constants;
027    
028    
029    /**
030     * A FileInput for Bootstrap form.
031     * @since 2.0.4.0
032     * @author ohashi keisuke
033     *
034     */
035    public class FileUpload extends com.google.gwt.user.client.ui.FileUpload implements HasSize, HasAlternateSize, IsSearchQuery, HasId {
036            {
037                    setStyleName("");
038            }
039            
040            /**
041             * {@inheritDoc}
042             */
043            @Override
044            public void setAlternateSize(AlternateSize size) {
045                    StyleHelper.changeStyle(this, size, AlternateSize.class);
046            }
047    
048            /**
049             * {@inheritDoc}
050             */
051            @Override
052            public void setSize(int size) {
053                    SizeHelper.setSize(this, size);
054            }
055            
056            /**
057             * {@inheritDoc}
058             */
059            @Override
060            public void setSearchQuery(boolean searchQuery) {
061                    SearchQueryStyleHelper.setSearchQuery(this, searchQuery);
062            }
063    
064            /**
065             * {@inheritDoc}
066             */
067            @Override
068            public boolean isSearchQuery() {
069                    return SearchQueryStyleHelper.isSearchQuery(this);
070            }
071    
072            /**
073             * {@inheritDoc}
074             */
075            @Override
076            public String getId() {
077                    return getElement().getId();
078            }
079    
080            /**
081             * {@inheritDoc}
082             */
083            @Override
084            public void setId(String id) {
085                    getElement().setId(id);
086            }
087    
088            /**
089             * {@inheritDoc}
090             */
091            @Override
092            public void setEnabled(boolean enabled) {
093                    super.setEnabled(enabled);
094                    if(enabled) {
095                            removeStyleName(Constants.DISABLED);
096                    } else {
097                            addStyleName(Constants.DISABLED);
098                    }
099            }
100    }