1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package com.mindtree.techworks.insight.gui.preferences;
25
26 import java.awt.GridLayout;
27 import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29 import java.util.Enumeration;
30
31 import javax.swing.BorderFactory;
32 import javax.swing.ButtonGroup;
33 import javax.swing.JCheckBox;
34 import javax.swing.JLabel;
35 import javax.swing.JPanel;
36 import javax.swing.JRadioButton;
37
38 import com.mindtree.techworks.insight.InsightConstants;
39 import com.mindtree.techworks.insight.download.Fileset;
40
41
42
43
44
45
46
47
48
49
50
51
52 public class FilesetsUIPanel extends AbstractPreferencesUIPanel implements ActionListener {
53
54
55
56
57 private static final long serialVersionUID = -46917056193251251L;
58
59
60
61
62 private static final String SHOW_FILE_SETS = "showFilesetsOnLoad";
63 private static final String FILE_SET_TYPE = "filesetType";
64 private static final String TAIL_OPTION = "tailOption";
65
66
67
68
69 private static final String TRUE = "true";
70 private static final String FALSE = "false";
71
72
73
74
75 private JCheckBox tailopt;
76 private JCheckBox showFileset;
77 private JRadioButton localButton;
78 private JRadioButton ftpButton;
79 private JRadioButton sftpButton;
80 private JRadioButton httpButton;
81 private ButtonGroup bg;
82
83
84
85
86 public FilesetsUIPanel() {
87 }
88
89
90
91
92
93 public void actionPerformed(ActionEvent e) {
94 checkEnable();
95 }
96
97
98
99
100
101 protected void initializeDisplay() {
102
103 this.tailopt = new JCheckBox(InsightConstants.getLiteral("ENABLE_TAILING"));
104 tailopt.addActionListener(this);
105 this.addComponent(tailopt,0,0,0,0,1,1);
106
107 this.showFileset = new JCheckBox(InsightConstants.getLiteral("SHOW_FILESETS"));
108 showFileset.addActionListener(this);
109 addComponent(showFileset,0,1,0,0,1,1);
110
111 JPanel panel = new JPanel();
112 panel.setLayout(new GridLayout(3,1));
113 panel.setBorder(BorderFactory.createTitledBorder(InsightConstants.getLiteral("FILESET_TYPE")));
114
115 bg = new ButtonGroup();
116 this.localButton = new JRadioButton(InsightConstants.getLiteral("LOCAL_FILESETS"));
117 localButton.setActionCommand(String.valueOf(Fileset.LOCAL_FILESET));
118 bg.add(localButton);
119 panel.add(localButton);
120
121 this.ftpButton = new JRadioButton(InsightConstants.getLiteral("FTP_FILESETS"));
122 ftpButton.setActionCommand(String.valueOf(Fileset.FTP_FILESET));
123 bg.add(ftpButton);
124 panel.add(ftpButton);
125
126 this.sftpButton = new JRadioButton(InsightConstants.getLiteral("SFTP_FILESETS"));
127 sftpButton.setActionCommand(String.valueOf(Fileset.SFTP_FILESET));
128 bg.add(sftpButton);
129 panel.add(sftpButton);
130
131 this.httpButton = new JRadioButton(InsightConstants.getLiteral("HTTP_FILESETS"));
132 httpButton.setActionCommand(String.valueOf(Fileset.HTTP_FILESET));
133 bg.add(httpButton);
134 panel.add(httpButton);
135
136 addComponent(panel,0,2,1,0,1,1);
137
138 addComponent(new JLabel(),0,3,1,1,1,1);
139
140
141 this.tailopt.setSelected(this.preference.getPreferenceAttributeById(TAIL_OPTION).getValue().equalsIgnoreCase(TRUE));
142 this.showFileset.setSelected(this.preference.getPreferenceAttributeById(SHOW_FILE_SETS).getValue().equals(TRUE));
143 checkEnable();
144 }
145
146
147
148
149
150 protected void setPreferenceValues() {
151 this.preference.getPreferenceAttributeById(SHOW_FILE_SETS).setValue(this.showFileset.isSelected() ? TRUE: FALSE);
152 this.preference.getPreferenceAttributeById(TAIL_OPTION).setValue(this.tailopt.isSelected()?TRUE:FALSE);
153 Enumeration buttons = bg.getElements();
154 while(buttons.hasMoreElements()) {
155 JRadioButton button = (JRadioButton)buttons.nextElement();
156 if (button.isSelected()) {
157 this.preference.getPreferenceAttributeById(FILE_SET_TYPE).setValue(button.getActionCommand());
158 break;
159 }
160 }
161 }
162
163
164
165
166 private void checkEnable() {
167 this.localButton.setEnabled(this.showFileset.isSelected());
168 this.ftpButton.setEnabled(this.showFileset.isSelected());
169 this.sftpButton.setEnabled(this.showFileset.isSelected());
170 this.httpButton.setEnabled(this.showFileset.isSelected());
171
172 int type = Integer.parseInt(this.preference.getPreferenceAttributeById(FILE_SET_TYPE).getValue());
173 this.localButton.setSelected(type == Fileset.LOCAL_FILESET);
174 this.ftpButton.setSelected(type == Fileset.FTP_FILESET);
175 this.sftpButton.setSelected(type == Fileset.SFTP_FILESET);
176 this.httpButton.setSelected(type == Fileset.HTTP_FILESET);
177 }
178
179 }