Coverage Report - org.openpermis.editor.policy.gui.ButtonFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
ButtonFactory
0%
0/17
0%
0/2
1.5
 
 1  
 /*
 2  
  * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport
 3  
  *                     (http://www.vbs.admin.ch)
 4  
  * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch)
 5  
  * All rights reserved.
 6  
  *
 7  
  * Licensed under the Open Permis License which accompanies this distribution,
 8  
  * and is available at http://www.openpermis.org/BSDlicenceKent.txt
 9  
  */
 10  
 package org.openpermis.editor.policy.gui;
 11  
 
 12  
 import java.awt.Insets;
 13  
 
 14  
 import javax.swing.Action;
 15  
 import javax.swing.ActionMap;
 16  
 import javax.swing.JButton;
 17  
 
 18  
 import org.jdesktop.application.ResourceMap;
 19  
 
 20  
 /**
 21  
  * Factory for buttons.
 22  
  * @since 0.1.0
 23  
  */
 24  
 public class ButtonFactory
 25  
         extends ComponentFactory
 26  
 {
 27  
 
 28  
         //---- Constructors
 29  
 
 30  
         /**
 31  
          * Creates a button factory that operates on the specified action and resource map.
 32  
          * @param actionMap the action map this factory operates on.
 33  
          * @param resourceMap the resource map this factory operates on.
 34  
          * @since 0.1.0
 35  
          */
 36  
         public ButtonFactory (ActionMap actionMap, ResourceMap resourceMap) {
 37  0
                 super(actionMap, resourceMap);
 38  0
         }
 39  
 
 40  
         //---- Methods
 41  
 
 42  
         /**
 43  
          * Creates a tool button suitable for use in a tool bar.
 44  
          * @param key the resource key name of the tool button to create.
 45  
          * @return the tool button created.
 46  
          * @since 0.1.0
 47  
          */
 48  
         protected JButton createToolButton (final String key) {
 49  0
                 final JButton button = new JButton();
 50  0
                 if (isPlaceholder(key)) {
 51  0
                         button.setText(key);
 52  0
                         button.setEnabled(false);
 53  
                 } else {
 54  0
                         final Action action = getAction(key);
 55  0
                         button.setAction(action);
 56  0
                         button.setText(null);
 57  0
                         button.setToolTipText((String) action.getValue(Action.NAME));
 58  0
                         button.setVerticalTextPosition(JButton.CENTER);
 59  0
                         button.setHorizontalTextPosition(JButton.RIGHT);
 60  
                 }
 61  0
                 button.setOpaque(false);
 62  0
                 button.setMargin(new Insets(2, 2, 2, 2));
 63  0
                 button.setFocusable(false);
 64  0
                 button.setRequestFocusEnabled(false);
 65  0
                 return button;
 66  
         }
 67  
 
 68  
 }