2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package org
.bgbm
.biovel
.datacleaning
.syncheck
;
8 import javax
.swing
.JCheckBox
;
10 import org
.bgbm
.biovel
.datacleaning
.utils
.syncheck
.SynCheckConstants
;
17 public class DCSynExpInputDialog
extends javax
.swing
.JDialog
{
18 List
<JCheckBox
> stdCBList
= new ArrayList
<JCheckBox
>();
19 Map
<JCheckBox
,Integer
> gbifCBIDMap
= new HashMap
<JCheckBox
,Integer
>();
24 * A return status code - returned if Cancel button has been pressed
26 public static final int RET_CANCEL
= 0;
28 * A return status code - returned if OK button has been pressed
30 public static final int RET_OK
= 1;
32 private int returnStatus
= RET_CANCEL
;
35 * Creates new form DCSynExpInputDialog
37 public DCSynExpInputDialog(java
.awt
.Frame parent
, boolean modal
,List
<String
> gbifchkdatasets
) {
40 javax
.swing
.JButton okButton
= new javax
.swing
.JButton();
41 okButton
.setText("OK");
42 okButton
.addActionListener(new java
.awt
.event
.ActionListener() {
43 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
44 okButtonActionPerformed(evt
);
50 if(gbifchkdatasets
!= null && !gbifchkdatasets
.isEmpty()) {
51 addGBIFChecklistBanks(gbifchkdatasets
);
54 java
.awt
.GridBagConstraints gridBagConstraints
= new java
.awt
.GridBagConstraints();
55 gridBagConstraints
= new java
.awt
.GridBagConstraints();
56 gridBagConstraints
.gridx
= 0;
57 gridBagConstraints
.gridy
= 3;
58 gridBagConstraints
.fill
= java
.awt
.GridBagConstraints
.BOTH
;
59 gridBagConstraints
.insets
= new java
.awt
.Insets(5, 5, 5, 5);
60 getContentPane().add(okButton
, gridBagConstraints
);
63 public void addStdChecklists() {
65 colCBox
= createJCheckBox("Catalogue of Life");
69 public void addGBIFChecklistBanks(List
<String
> gbifchkdatasets
) {
70 Iterator itr
= gbifchkdatasets
.iterator();
72 while(itr
.hasNext()) {
73 String chkdataset
= (String
)itr
.next();
74 StringTokenizer st
= new StringTokenizer(chkdataset
, SynCheckConstants
.CHECKLIST_BANK_DELIMITER
);
75 if(st
.countTokens() == 2) {
76 String chklistName
= (String
)st
.nextElement();
77 String datasetID
= (String
)st
.nextElement();
78 JCheckBox jcbox
= createJCheckBox("GBIF - " + chklistName
);
79 gbifCBIDMap
.put(jcbox
,new Integer(datasetID
));
84 private JCheckBox
createJCheckBox(String chklistName
) {
85 JCheckBox jcbox
= new JCheckBox();
86 jcbox
.setText(chklistName
);
87 java
.awt
.GridBagConstraints gridBagConstraints
= new java
.awt
.GridBagConstraints();
88 gridBagConstraints
.gridx
= 0;
89 gridBagConstraints
.gridy
= currentGridy
;
90 gridBagConstraints
.fill
= java
.awt
.GridBagConstraints
.BOTH
;
91 gridBagConstraints
.insets
= new java
.awt
.Insets(5, 5, 5, 5);
92 chkListPanel
.add(jcbox
, gridBagConstraints
);
99 public boolean isColSelected() {
100 return colCBox
.isSelected();
103 public List
<String
> getSelectedGBIFChkList() {
104 List
<String
> selGBIFStdChkList
= new ArrayList
<String
>();
105 Iterator
<Map
.Entry
<JCheckBox
, Integer
>> entries
= gbifCBIDMap
.entrySet().iterator();
106 while (entries
.hasNext()) {
107 Map
.Entry
<JCheckBox
, Integer
> entry
= entries
.next();
108 JCheckBox jcbox
= (JCheckBox
)entry
.getKey();
109 if(jcbox
.isSelected()) {
110 Integer datasetID
= (Integer
)entry
.getValue();
111 selGBIFStdChkList
.add(datasetID
.toString());
115 return selGBIFStdChkList
;
118 * This method is called from within the constructor to initialize the form.
119 * WARNING: Do NOT modify this code. The content of this method is always
120 * regenerated by the Form Editor.
122 @SuppressWarnings("unchecked")
123 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
124 private void initComponents() {
125 java
.awt
.GridBagConstraints gridBagConstraints
;
127 chkListLbl
= new javax
.swing
.JLabel();
128 chkListScrollPane
= new javax
.swing
.JScrollPane();
129 chkListPanel
= new javax
.swing
.JPanel();
131 setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
132 setMaximumSize(new java
.awt
.Dimension(600, 1000));
133 setMinimumSize(new java
.awt
.Dimension(500, 800));
134 setPreferredSize(new java
.awt
.Dimension(500, 800));
135 addWindowListener(new java
.awt
.event
.WindowAdapter() {
136 public void windowClosing(java
.awt
.event
.WindowEvent evt
) {
137 formWindowClosing(evt
);
140 getContentPane().setLayout(new java
.awt
.GridBagLayout());
142 chkListLbl
.setText("Choose Check List to target :");
143 chkListLbl
.setMaximumSize(new java
.awt
.Dimension(140, 30));
144 chkListLbl
.setMinimumSize(new java
.awt
.Dimension(140, 30));
145 chkListLbl
.setPreferredSize(new java
.awt
.Dimension(140, 30));
146 gridBagConstraints
= new java
.awt
.GridBagConstraints();
147 gridBagConstraints
.gridx
= 0;
148 gridBagConstraints
.gridy
= 0;
149 gridBagConstraints
.fill
= java
.awt
.GridBagConstraints
.BOTH
;
150 gridBagConstraints
.insets
= new java
.awt
.Insets(5, 5, 5, 5);
151 getContentPane().add(chkListLbl
, gridBagConstraints
);
153 chkListScrollPane
.setMinimumSize(new java
.awt
.Dimension(400, 600));
154 chkListScrollPane
.setPreferredSize(new java
.awt
.Dimension(400, 600));
156 chkListPanel
.setLayout(new java
.awt
.GridBagLayout());
157 chkListScrollPane
.setViewportView(chkListPanel
);
159 gridBagConstraints
= new java
.awt
.GridBagConstraints();
160 gridBagConstraints
.gridx
= 0;
161 gridBagConstraints
.gridy
= 1;
162 gridBagConstraints
.fill
= java
.awt
.GridBagConstraints
.BOTH
;
163 gridBagConstraints
.insets
= new java
.awt
.Insets(5, 5, 5, 5);
164 getContentPane().add(chkListScrollPane
, gridBagConstraints
);
167 }// </editor-fold>//GEN-END:initComponents
169 private void formWindowClosing(java
.awt
.event
.WindowEvent evt
) {//GEN-FIRST:event_formWindowClosing
171 }//GEN-LAST:event_formWindowClosing
173 private void okButtonActionPerformed(java
.awt
.event
.ActionEvent evt
) {
177 private void doClose(int retStatus
) {
178 returnStatus
= retStatus
;
183 * @param args the command line arguments
185 public static void main(String args
[]) {
187 * Set the Nimbus look and feel
189 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
191 * If Nimbus (introduced in Java SE 6) is not available, stay with the
192 * default look and feel. For details see
193 * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
196 for (javax
.swing
.UIManager
.LookAndFeelInfo info
: javax
.swing
.UIManager
.getInstalledLookAndFeels()) {
197 if ("Nimbus".equals(info
.getName())) {
198 javax
.swing
.UIManager
.setLookAndFeel(info
.getClassName());
202 } catch (ClassNotFoundException ex
) {
203 java
.util
.logging
.Logger
.getLogger(DCSynExpInputDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
204 } catch (InstantiationException ex
) {
205 java
.util
.logging
.Logger
.getLogger(DCSynExpInputDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
206 } catch (IllegalAccessException ex
) {
207 java
.util
.logging
.Logger
.getLogger(DCSynExpInputDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
208 } catch (javax
.swing
.UnsupportedLookAndFeelException ex
) {
209 java
.util
.logging
.Logger
.getLogger(DCSynExpInputDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
214 * Create and display the dialog
216 java
.awt
.EventQueue
.invokeLater(new Runnable() {
219 List
<String
> stdchecklists
= new ArrayList
<String
>();
220 stdchecklists
.add("Catalogue of Life");
221 DCSynExpInputDialog dialog
= new DCSynExpInputDialog(new javax
.swing
.JFrame(), true, null);
222 dialog
.addWindowListener(new java
.awt
.event
.WindowAdapter() {
225 public void windowClosing(java
.awt
.event
.WindowEvent e
) {
230 dialog
.setVisible(true);
236 // Variables declaration - do not modify//GEN-BEGIN:variables
237 private javax
.swing
.JLabel chkListLbl
;
238 private javax
.swing
.JPanel chkListPanel
;
239 private javax
.swing
.JScrollPane chkListScrollPane
;
240 // End of variables declaration//GEN-END:variables