001 // This file is part of AceWiki. 002 // Copyright 2008-2012, AceWiki developers. 003 // 004 // AceWiki is free software: you can redistribute it and/or modify it under the terms of the GNU 005 // Lesser General Public License as published by the Free Software Foundation, either version 3 of 006 // the License, or (at your option) any later version. 007 // 008 // AceWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 010 // Lesser General Public License for more details. 011 // 012 // You should have received a copy of the GNU Lesser General Public License along with AceWiki. If 013 // not, see http://www.gnu.org/licenses/. 014 015 package ch.uzh.ifi.attempto.echocomp; 016 017 import nextapp.echo.app.Extent; 018 import nextapp.echo.app.Font; 019 import nextapp.echo.app.ImageReference; 020 import nextapp.echo.app.ResourceImageReference; 021 022 /** 023 * This class represents a check box in blue style. 024 * 025 * @author Tobias Kuhn 026 */ 027 public class CheckBox extends nextapp.echo.app.CheckBox { 028 029 private static final long serialVersionUID = -8160475963811004744L; 030 031 private static final String iconPath = "ch/uzh/ifi/attempto/echocomp/style/"; 032 033 /** 034 * Creates a new check box having a text and an icon. 035 * 036 * @param text The text. 037 * @param icon The icon. 038 */ 039 public CheckBox(String text, ImageReference icon) { 040 super(text, icon); 041 setStateIcon(Style.getImage(iconPath + "notchecked.png")); 042 setSelectedStateIcon(Style.getImage(iconPath + "checked.png")); 043 setFont(new Font(Style.fontTypeface, Font.PLAIN, new Extent(13))); 044 } 045 046 /** 047 * Creates a new check box having only a text. 048 * 049 * @param text The text. 050 */ 051 public CheckBox(String text) { 052 this(text, null); 053 } 054 055 /** 056 * Creates a new check box having only an icon. 057 * 058 * @param icon The icon. 059 */ 060 public CheckBox(ImageReference icon) { 061 this(null, icon); 062 } 063 064 /** 065 * Creates a new check box having neither a text nor an icon. 066 */ 067 public CheckBox() { 068 this(null, null); 069 } 070 071 public void setEnabled(boolean enabled) { 072 super.setEnabled(enabled); 073 if (enabled) { 074 setStateIcon(new ResourceImageReference(iconPath + "notchecked.png")); 075 setSelectedStateIcon(new ResourceImageReference(iconPath + "checked.png")); 076 } else { 077 setStateIcon(new ResourceImageReference(iconPath + "notcheckedi.png")); 078 setSelectedStateIcon(new ResourceImageReference(iconPath + "checkedi.png")); 079 } 080 } 081 082 }