1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
51
52
53
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 }