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 */
016package com.github.gwtbootstrap.client.ui.constants;
017
018import com.github.gwtbootstrap.client.ui.base.Style;
019
020/**
021 * The way a responsive widget is shown.
022 * 
023 * @since 2.0.4.0
024 * 
025 * @author Dominik Mayer
026 */
027public enum ResponsiveStyle implements Style {
028
029        /**
030         * The widget is only shown on {@link Device#PHONE phones.}
031         */
032        VISIBLE_PHONE(true, Device.PHONE),
033
034        /**
035         * The widget is hidden on {@link Device#PHONE phones}.
036         */
037        HIDDEN_PHONE(false, Device.PHONE),
038
039        /**
040         * The widget is only shown on {@link Device#TABLET tablets.}
041         */
042        VISIBLE_TABLET(true, Device.TABLET),
043
044        /**
045         * The widget is hidden on {@link Device#TABLET tablets}.
046         */
047        HIDDEN_TABLET(false, Device.TABLET),
048
049        /**
050         * The widget is only shown on {@link Device#DESKTOP desktop computers.}
051         */
052        VISIBLE_DESKTOP(true, Device.DESKTOP),
053
054        /**
055         * The widget is hidden on {@link Device#DESKTOP desktop computers}.
056         */
057        HIDDEN_DESKTOP(false, Device.DESKTOP);
058
059        private static final String VISBILE_PREFIX = "visible-";
060
061        private static final String HIDDEN_PREFIX = "hidden-";
062
063        private boolean visible;
064
065        private Device device;
066
067        private ResponsiveStyle(boolean visible, Device device) {
068                this.visible = visible;
069                this.device = device;
070        }
071
072        /**
073         * {@inheritDoc}
074         */
075        public String get() {
076                String className;
077                if (visible)
078                        className = VISBILE_PREFIX;
079                else
080                        className = HIDDEN_PREFIX;
081
082                return className + device.get();
083        }
084}