]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | |
2 | import java.awt.*; | |
3 | import java.awt.event.*; | |
4 | import javax.swing.*; | |
5 | import java.net.URL; | |
6 | import java.net.*; | |
7 | import java.io.*; | |
8 | import com.easysw.cups.*; | |
9 | ||
10 | public class GLPserver implements ActionListener | |
11 | { | |
12 | ||
13 | private JPanel serverPanel = null; | |
14 | private JPanel searchPanel = null; | |
15 | ||
16 | private GLPjobTableModel tm = null; | |
17 | private JTable table = null; | |
18 | ||
19 | protected JLabel currentLabel; | |
20 | protected JLabel currentLabelValue; | |
21 | protected JLabel actionLabel; | |
22 | protected JTextField serverTextField; | |
23 | ||
24 | protected static final String serverFieldString = "New Server Name:"; | |
25 | protected static final String applyButtonString = "Apply Changes"; | |
26 | ||
27 | ||
28 | // Constructor | |
29 | public GLPserver() | |
30 | { | |
31 | GLPvars.searchTM = new GLPjobTableModel(1,1); | |
32 | GLPvars.searchTM.setColumnName( 0, "Search Results" ); | |
33 | GLPvars.searchTM.setValueAt("No search results",0,0); | |
34 | GLPvars.searchTable = new JTable(GLPvars.searchTM); | |
35 | ||
36 | load(); | |
37 | } | |
38 | ||
39 | public void load() | |
40 | { | |
41 | GridBagLayout serverLayout; | |
42 | GridBagConstraints serverConst; | |
43 | ||
44 | // Create the main panel to contain the two sub panels. | |
45 | serverPanel = new JPanel(); | |
46 | serverLayout = new GridBagLayout(); | |
47 | serverConst = new GridBagConstraints(); | |
48 | ||
49 | serverPanel.setLayout(serverLayout); | |
50 | serverPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); | |
51 | serverPanel.setBackground(GLPcolors.backgroundColor); | |
52 | ||
53 | ||
54 | //Create a regular text field. | |
55 | serverTextField = new JTextField(32); | |
56 | serverTextField.setActionCommand(serverFieldString); | |
57 | serverTextField.addActionListener(this); | |
58 | ||
59 | //Create some labels for the fields. | |
60 | JLabel serverFieldLabel = new JLabel(serverFieldString); | |
61 | serverFieldLabel.setForeground(GLPcolors.foregroundColor); | |
62 | serverFieldLabel.setLabelFor(serverTextField); | |
63 | ||
64 | currentLabel = new JLabel("Current Server Name: "); | |
65 | currentLabel.setForeground(GLPcolors.foregroundColor); | |
66 | currentLabelValue = new JLabel(GLPvars.getServerName()); | |
67 | ||
68 | serverConst.gridwidth = GridBagConstraints.RELATIVE; | |
69 | serverConst.gridx = 0; | |
70 | serverConst.gridy = 0; | |
71 | serverConst.fill = GridBagConstraints.HORIZONTAL; | |
72 | serverConst.weightx = 0.4; | |
73 | serverConst.weighty = 0.0; | |
74 | serverConst.ipadx = 4; | |
75 | serverConst.ipady = 4; | |
76 | serverLayout.setConstraints( currentLabel, serverConst ); | |
77 | serverPanel.add(currentLabel); | |
78 | ||
79 | serverConst.gridwidth = GridBagConstraints.RELATIVE; | |
80 | serverConst.gridx = 1; | |
81 | serverConst.gridy = 0; | |
82 | serverConst.fill = GridBagConstraints.HORIZONTAL; | |
83 | serverConst.weightx = 0.4; | |
84 | serverConst.weighty = 0.0; | |
85 | serverConst.ipadx = 4; | |
86 | serverConst.ipady = 4; | |
87 | serverLayout.setConstraints( currentLabelValue, serverConst ); | |
88 | serverPanel.add(currentLabelValue); | |
89 | ||
90 | // Text | |
91 | serverConst.gridwidth = GridBagConstraints.RELATIVE; | |
92 | serverConst.gridx = 0; | |
93 | serverConst.gridy = 1; | |
94 | serverConst.fill = GridBagConstraints.HORIZONTAL; | |
95 | serverConst.weightx = 0.4; | |
96 | serverConst.weighty = 0.0; | |
97 | serverConst.ipadx = 4; | |
98 | serverConst.ipady = 4; | |
99 | serverLayout.setConstraints( serverFieldLabel, serverConst ); | |
100 | serverPanel.add(serverFieldLabel); | |
101 | ||
102 | serverConst.gridwidth = GridBagConstraints.RELATIVE; | |
103 | serverConst.gridx = 1; | |
104 | serverConst.gridy = 1; | |
105 | serverConst.fill = GridBagConstraints.HORIZONTAL; | |
106 | serverConst.weightx = 0.4; | |
107 | serverConst.weighty = 0.0; | |
108 | serverConst.ipadx = 4; | |
109 | serverConst.ipady = 4; | |
110 | serverLayout.setConstraints( serverTextField, serverConst ); | |
111 | serverPanel.add(serverTextField); | |
112 | ||
113 | JButton applyButton = new JButton(applyButtonString); | |
114 | applyButton.setBorder(BorderFactory.createCompoundBorder( | |
115 | BorderFactory.createRaisedBevelBorder(), | |
116 | BorderFactory.createEmptyBorder(5,5,5,5))); | |
117 | applyButton.setActionCommand(applyButtonString); | |
118 | applyButton.addActionListener(this); | |
119 | serverConst.gridx = 1; | |
120 | serverConst.gridy = 2; | |
121 | serverConst.fill = GridBagConstraints.NONE; | |
122 | serverLayout.setConstraints( applyButton, serverConst ); | |
123 | serverConst.weightx = 0.4; | |
124 | serverConst.weighty = 0.0; | |
125 | serverConst.ipadx = 4; | |
126 | serverConst.ipady = 4; | |
127 | serverPanel.add(applyButton); | |
128 | ||
129 | GLPsearchProgressPanel progress = new GLPsearchProgressPanel(); | |
130 | searchPanel = progress.getPanel(); | |
131 | serverConst.gridx = 1; | |
132 | serverConst.gridy = 3; | |
133 | serverConst.fill = GridBagConstraints.HORIZONTAL; | |
134 | serverConst.weightx = 0.6; | |
135 | serverConst.weighty = 0.3; | |
136 | serverConst.ipadx = 4; | |
137 | serverConst.ipady = 4; | |
138 | serverLayout.setConstraints( searchPanel, serverConst ); | |
139 | serverPanel.add(searchPanel); | |
140 | ||
141 | serverConst.gridx = 1; | |
142 | serverConst.gridy = 4; | |
143 | serverConst.fill = GridBagConstraints.HORIZONTAL; | |
144 | serverConst.weightx = 1.0; | |
145 | serverConst.weighty = 0.5; | |
146 | serverConst.ipadx = 4; | |
147 | serverConst.ipady = 4; | |
148 | serverLayout.setConstraints( GLPvars.searchTable, serverConst ); | |
149 | serverPanel.add(GLPvars.searchTable); | |
150 | ||
151 | } | |
152 | ||
153 | ||
154 | public void actionPerformed(ActionEvent e) | |
155 | { | |
156 | if (e.getActionCommand().equals(serverFieldString)) | |
157 | { | |
158 | String s = serverTextField.getText(); | |
159 | if (s.length() > 1) | |
160 | { | |
161 | GLPvars.setServerName(s); | |
162 | serverTextField.setText(""); | |
163 | currentLabelValue.setText(GLPvars.getServerName()); | |
164 | } | |
165 | } | |
166 | else if (e.getActionCommand().equals(applyButtonString)) | |
167 | { | |
168 | String s = serverTextField.getText(); | |
169 | if (s.length() > 1) | |
170 | { | |
171 | GLPvars.setServerName(s); | |
172 | serverTextField.setText(""); | |
173 | currentLabelValue.setText(GLPvars.getServerName()); | |
174 | } | |
175 | } | |
176 | } | |
177 | ||
178 | public void updateServer( String server ) | |
179 | { | |
180 | GLPvars.setServerName(server); | |
181 | load(); | |
182 | serverTextField.setText(""); | |
183 | currentLabelValue.setText(GLPvars.getServerName()); | |
184 | } | |
185 | ||
186 | ||
187 | public JPanel getPanel() | |
188 | { | |
189 | return(serverPanel); | |
190 | } | |
191 | ||
192 | } |