Coverage Report - org.jtheque.core.managers.view.impl.components.filthy.AbstractFilthyField
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFilthyField
0 %
0/22
N/A
1
 
 1  
 package org.jtheque.core.managers.view.impl.components.filthy;
 2  
 
 3  
 import org.jtheque.core.managers.Managers;
 4  
 import org.jtheque.core.managers.resource.IResourceManager;
 5  
 import org.jtheque.core.managers.view.able.IViewManager;
 6  
 import org.jtheque.core.managers.view.able.ViewDefaults;
 7  
 import org.jtheque.core.utils.ui.Borders;
 8  
 
 9  
 import javax.swing.BorderFactory;
 10  
 import javax.swing.JPanel;
 11  
 import javax.swing.border.CompoundBorder;
 12  
 import javax.swing.text.JTextComponent;
 13  
 import java.awt.BorderLayout;
 14  
 import java.awt.Color;
 15  
 import java.awt.Font;
 16  
 
 17  
 /*
 18  
  * This file is part of JTheque.
 19  
  *
 20  
  * JTheque is free software: you can redistribute it and/or modify
 21  
  * it under the terms of the GNU General Public License as published by
 22  
  * the Free Software Foundation, either version 3 of the License.
 23  
  *
 24  
  * JTheque is distributed in the hope that it will be useful,
 25  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 26  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 27  
  * GNU General Public License for more details.
 28  
  *
 29  
  * You should have received a copy of the GNU General Public License
 30  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 31  
  */
 32  
 
 33  
 /**
 34  
  * An abstract filthy field.
 35  
  *
 36  
  * @author Baptiste Wicht
 37  
  */
 38  
 public abstract class AbstractFilthyField extends JPanel {
 39  
     /**
 40  
      * Construct a new AbstractFilthyField.
 41  
      */
 42  
     public AbstractFilthyField() {
 43  0
         super();
 44  
 
 45  0
         IResourceManager resources = Managers.getManager(IResourceManager.class);
 46  
 
 47  0
         Color inputColor = resources.getColor("filthyInputColor");
 48  0
         Color inputBorderColor = resources.getColor("filthyInputBorderColor");
 49  
 
 50  0
         setLayout(new BorderLayout());
 51  0
         setBackground(inputColor);
 52  0
         setBorder(new CompoundBorder(
 53  
                 BorderFactory.createLineBorder(inputBorderColor, 2),
 54  
                 BorderFactory.createEmptyBorder(2, 2, 2, 2)));
 55  
 
 56  0
         initComponent();
 57  0
     }
 58  
 
 59  
     /**
 60  
      * Init the component.
 61  
      */
 62  
     abstract void initComponent();
 63  
 
 64  
     /**
 65  
      * Make a component filthy.
 66  
      *
 67  
      * @param field The field to make filthy.
 68  
      */
 69  
     static void makeFilthy(JTextComponent field) {
 70  0
         ViewDefaults defaults = Managers.getManager(IViewManager.class).getViewDefaults();
 71  
 
 72  0
         Font inputFont = defaults.getFilthyInputFont();
 73  
 
 74  0
         Color inputTextColor = defaults.getFilthyForegroundColor();
 75  0
         Color inputSelectionColor = defaults.getFilthyForegroundColor();
 76  0
         Color inputSelectedTextColor = defaults.getFilthyBackgroundColor();
 77  
 
 78  0
         field.setOpaque(false);
 79  0
         field.setBorder(Borders.EMPTY_BORDER);
 80  0
         field.setForeground(inputTextColor);
 81  0
         field.setSelectedTextColor(inputSelectedTextColor);
 82  0
         field.setSelectionColor(inputSelectionColor);
 83  0
         field.setCaretColor(inputSelectionColor);
 84  0
         field.setFont(inputFont);
 85  0
     }
 86  
 }