View Javadoc

1   /*
2    * @(#)$Id: ComponentFactory.java 758 2009-08-25 16:45:01Z bsigner $
3    *
4    * Author		:	Ueli Kurmann, igesture@uelikurmann.ch
5    *                  
6    *
7    * Purpose		: 
8    *
9    * -----------------------------------------------------------------------
10   *
11   * Revision Information:
12   *
13   * Date				Who			Reason
14   *
15   * 04.05.2008			ukurmann	Initial Release
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  package org.ximtec.igesture.tool.util;
27  
28  import java.awt.BorderLayout;
29  import java.awt.Color;
30  import java.awt.GridBagLayout;
31  
32  import javax.swing.Action;
33  import javax.swing.JButton;
34  import javax.swing.JLabel;
35  import javax.swing.JMenuItem;
36  import javax.swing.JPanel;
37  import javax.swing.JPopupMenu;
38  import javax.swing.JTextArea;
39  import javax.swing.JTextField;
40  
41  import org.sigtec.graphix.GuiBundle;
42  import org.sigtec.graphix.widget.BasicButton;
43  import org.sigtec.graphix.widget.BasicLabel;
44  import org.sigtec.graphix.widget.BasicTextField;
45  import org.sigtec.util.Constant;
46  import org.ximtec.igesture.tool.locator.Service;
47  import org.ximtec.igesture.tool.service.GuiBundleService;
48  
49  /**
50   * Comment
51   * 
52   * @version 1.0 04.05.2008
53   * @author Ueli Kurmann
54   */
55  public class ComponentFactory implements Service {
56  
57  	
58  
59  	private GuiBundleService guiBundleService;
60  
61    public ComponentFactory(GuiBundleService guiBundleService) {
62  		this.guiBundleService = guiBundleService;
63  	}
64  
65  	public JLabel createLabel(String key) {
66  		return new BasicLabel(key, getGuiBundle(), Constant.COLON);
67  	}
68  
69  	public JButton createButton(String key, Action action) {
70  		return new BasicButton(action, key, getGuiBundle());
71  	}
72  
73  	public JTextField createTextField(String key) {
74  		return new BasicTextField(key, getGuiBundle());
75  	}
76  
77  	public JTextArea createTextArea(String key) {
78  		return new JTextArea();
79  	}
80  
81  	public GuiBundle getGuiBundle() {
82  	  return guiBundleService;
83  	}
84  
85  	public JPopupMenu createPopupMenu(Action action) {
86  		JPopupMenu menu = new JPopupMenu();
87  		JMenuItem item = new JMenuItem();
88  		item.setAction(action);
89  		menu.add(item);
90  		return menu;
91  	}
92  	
93  	public static JPanel createBorderLayoutPanel(){
94  	  JPanel panel = new JPanel();
95      panel.setLayout(new BorderLayout());
96      panel.setOpaque(false);
97      panel.setBackground(Color.white);
98      return panel;
99  	}
100 	
101 	public static JPanel createGridBagLayoutPanel(){
102 	  JPanel panel = new JPanel();
103     panel.setLayout(new GridBagLayout());
104     panel.setOpaque(true);
105     panel.setBackground(Color.white);
106 
107     return panel;
108 	}
109 
110 	@Override
111 	public String getIdentifier() {
112 		return ComponentFactory.class.getName();
113 	}
114 
115 }