1 6 7 package com.jaspersoft.jasperserver.irplugin.gui; 8 9 import com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ListItem; 10 import com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor; 11 import com.jaspersoft.jasperserver.irplugin.RepositoryFolder; 12 import com.jaspersoft.jasperserver.irplugin.gui.explorer.ResourceChooser; 13 import it.businesslogic.ireport.IReportConnection; 14 import it.businesslogic.ireport.connection.JDBCConnection; 15 import it.businesslogic.ireport.gui.MainFrame; 16 import it.businesslogic.ireport.gui.sheet.Tag; 17 import it.businesslogic.ireport.util.Misc; 18 import java.io.File ; 19 import java.math.BigDecimal ; 20 import java.util.List ; 21 import java.util.regex.Pattern ; 22 import javax.swing.DefaultListModel ; 23 import javax.swing.DefaultListSelectionModel ; 24 import javax.swing.JOptionPane ; 25 import com.jaspersoft.jasperserver.irplugin.JServer; 26 import javax.swing.event.ListSelectionEvent ; 27 import javax.swing.event.ListSelectionListener ; 28 import javax.swing.table.DefaultTableModel ; 29 30 34 public class InputControlDialog extends javax.swing.JDialog { 35 36 private int dialogResult = JOptionPane.CANCEL_OPTION; 37 38 private JServer server = null; 39 private String parentFolder = null; 40 private RepositoryFolder resource = null; 41 private String reportUnitUri = null; 42 43 private ResourceDescriptor newResourceDescriptor = null; 44 45 private ResourceDescriptor lovResourceDescriptor = null; 46 private ResourceDescriptor dataTypeResourceDescriptor = null; 47 private ResourceDescriptor queryResourceDescriptor = null; 48 49 50 53 public InputControlDialog(java.awt.Frame parent, boolean modal) { 54 super(parent, modal); 55 initComponents(); 56 57 it.businesslogic.ireport.util.Misc.centerFrame(this); 58 javax.swing.event.DocumentListener changesListener = new javax.swing.event.DocumentListener () { 59 public void changedUpdate(javax.swing.event.DocumentEvent evt) { 60 updateSaveButton(); 61 } 62 public void insertUpdate(javax.swing.event.DocumentEvent evt) { 63 updateSaveButton(); 64 } 65 public void removeUpdate(javax.swing.event.DocumentEvent evt) { 66 updateSaveButton(); 67 } 68 }; 69 70 jComboBoxType.addItem( new it.businesslogic.ireport.gui.sheet.Tag("1","Boolean") ); 71 jComboBoxType.addItem( new it.businesslogic.ireport.gui.sheet.Tag("2","Single Value") ); 72 jComboBoxType.addItem( new it.businesslogic.ireport.gui.sheet.Tag("3","Single Select List of Values") ); 73 jComboBoxType.addItem( new it.businesslogic.ireport.gui.sheet.Tag("4","Single Select Query") ); 74 75 jComboBoxType.setSelectedIndex(0); 76 77 this.jTextFieldLabel.getDocument().addDocumentListener(changesListener); 78 this.jTextFieldName.getDocument().addDocumentListener(changesListener); 79 jTextFieldName.requestFocusInWindow(); 80 81 jListColumns.addListSelectionListener( new ListSelectionListener () { 82 public void valueChanged(ListSelectionEvent e) { 83 boolean b = jListColumns.getSelectedIndex()>=0; 84 jButtonModColumn.setEnabled(b); 85 jButtonRemColumn.setEnabled(b); 86 } 87 }); 88 89 jListColumns.setModel( new DefaultListModel ()); 90 91 } 92 93 94 95 96 private void updateSaveButton() 97 { 98 if (jTextFieldLabel.getText().length() > 0 && 99 jTextFieldName.getText().length() > 0) 100 { 101 jButtonSave.setEnabled(true); 102 } 103 else 104 { 105 jButtonSave.setEnabled(false); 106 } 107 } 108 109 114 private void initComponents() { 116 java.awt.GridBagConstraints gridBagConstraints; 117 118 buttonGroup1 = new javax.swing.ButtonGroup (); 119 buttonGroup2 = new javax.swing.ButtonGroup (); 120 jPanel1 = new javax.swing.JPanel (); 121 jLabel1 = new javax.swing.JLabel (); 122 jSeparator1 = new javax.swing.JSeparator (); 123 jTabbedPane1 = new javax.swing.JTabbedPane (); 124 jPanel2 = new javax.swing.JPanel (); 125 jLabelUriString = new javax.swing.JLabel (); 126 jTextFieldUriString = new javax.swing.JTextField (); 127 jLabelName = new javax.swing.JLabel (); 128 jTextFieldName = new javax.swing.JTextField (); 129 jSeparator2 = new javax.swing.JSeparator (); 130 jLabelLabel = new javax.swing.JLabel (); 131 jTextFieldLabel = new javax.swing.JTextField (); 132 jScrollPane1 = new javax.swing.JScrollPane (); 133 jEditorPaneDescription = new javax.swing.JEditorPane (); 134 jLabelDescription = new javax.swing.JLabel (); 135 jPanel3 = new javax.swing.JPanel (); 136 jLabelType = new javax.swing.JLabel (); 137 jComboBoxType = new javax.swing.JComboBox (); 138 jLabelMandatory = new javax.swing.JLabel (); 139 jCheckBoxMandatory = new javax.swing.JCheckBox (); 140 jLabelReadOnly = new javax.swing.JLabel (); 141 jCheckBoxReadOnly = new javax.swing.JCheckBox (); 142 jSeparator4 = new javax.swing.JSeparator (); 143 jPanel5 = new javax.swing.JPanel (); 144 jPanelLocate = new javax.swing.JPanel (); 145 jLabelLocate = new javax.swing.JLabel (); 146 jRadioButtonRepo = new javax.swing.JRadioButton (); 147 jTextFieldResource = new javax.swing.JTextField (); 148 jButtonPickResource = new javax.swing.JButton (); 149 jRadioButtonLocal = new javax.swing.JRadioButton (); 150 jButtonEditLocalResource = new javax.swing.JButton (); 151 jPanel6 = new javax.swing.JPanel (); 152 jPanelQuery = new javax.swing.JPanel (); 153 jTabbedPane2 = new javax.swing.JTabbedPane (); 154 jPanelLocateQuery = new javax.swing.JPanel (); 155 jLabelLocate1 = new javax.swing.JLabel (); 156 jRadioButtonRepo1 = new javax.swing.JRadioButton (); 157 jTextFieldResource1 = new javax.swing.JTextField (); 158 jButtonPickResource1 = new javax.swing.JButton (); 159 jRadioButtonLocal1 = new javax.swing.JRadioButton (); 160 jButtonEditLocalResource1 = new javax.swing.JButton (); 161 jPanel7 = new javax.swing.JPanel (); 162 jPanelFields = new javax.swing.JPanel (); 163 jLabelLocate2 = new javax.swing.JLabel (); 164 jTextFieldValueColumn = new javax.swing.JTextField (); 165 jPanelVisibleColumns = new javax.swing.JPanel (); 166 jLabelLocate3 = new javax.swing.JLabel (); 167 jScrollPane2 = new javax.swing.JScrollPane (); 168 jListColumns = new javax.swing.JList (); 169 jPanel8 = new javax.swing.JPanel (); 170 jButtonAddColumn = new javax.swing.JButton (); 171 jButtonModColumn = new javax.swing.JButton (); 172 jButtonRemColumn = new javax.swing.JButton (); 173 jPanel4 = new javax.swing.JPanel (); 174 jButtonSave = new javax.swing.JButton (); 175 jButtonClose = new javax.swing.JButton (); 176 177 getContentPane().setLayout(new java.awt.GridBagLayout ()); 178 179 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 180 setTitle("Data Type"); 181 jPanel1.setLayout(new java.awt.GridBagLayout ()); 182 183 jPanel1.setBackground(new java.awt.Color (255, 255, 255)); 184 jLabel1.setFont(new java.awt.Font ("Tahoma", 1, 12)); 185 jLabel1.setIcon(new javax.swing.ImageIcon (getClass().getResource("/com/jaspersoft/jasperserver/irplugin/res/datasource_new.png"))); 186 jLabel1.setText("Input Control"); 187 jLabel1.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); 188 jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); 189 gridBagConstraints = new java.awt.GridBagConstraints (); 190 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 191 gridBagConstraints.weightx = 1.0; 192 gridBagConstraints.weighty = 1.0; 193 jPanel1.add(jLabel1, gridBagConstraints); 194 195 gridBagConstraints = new java.awt.GridBagConstraints (); 196 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 197 getContentPane().add(jPanel1, gridBagConstraints); 198 199 jSeparator1.setMinimumSize(new java.awt.Dimension (2, 2)); 200 jSeparator1.setPreferredSize(new java.awt.Dimension (2, 2)); 201 gridBagConstraints = new java.awt.GridBagConstraints (); 202 gridBagConstraints.gridx = 0; 203 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 204 gridBagConstraints.weightx = 1.0; 205 getContentPane().add(jSeparator1, gridBagConstraints); 206 207 jPanel2.setLayout(new java.awt.GridBagLayout ()); 208 209 jPanel2.setPreferredSize(new java.awt.Dimension (400, 185)); 210 jLabelUriString.setText("Parent folder"); 211 gridBagConstraints = new java.awt.GridBagConstraints (); 212 gridBagConstraints.gridx = 0; 213 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 214 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 215 jPanel2.add(jLabelUriString, gridBagConstraints); 216 217 jTextFieldUriString.setEditable(false); 218 jTextFieldUriString.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 219 jTextFieldUriString.setOpaque(false); 220 gridBagConstraints = new java.awt.GridBagConstraints (); 221 gridBagConstraints.gridx = 1; 222 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 223 gridBagConstraints.weightx = 1.0; 224 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 225 jPanel2.add(jTextFieldUriString, gridBagConstraints); 226 227 jLabelName.setText("Name"); 228 gridBagConstraints = new java.awt.GridBagConstraints (); 229 gridBagConstraints.gridx = 0; 230 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 231 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 4); 232 jPanel2.add(jLabelName, gridBagConstraints); 233 234 gridBagConstraints = new java.awt.GridBagConstraints (); 235 gridBagConstraints.gridx = 1; 236 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 237 gridBagConstraints.weightx = 1.0; 238 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 4); 239 jPanel2.add(jTextFieldName, gridBagConstraints); 240 241 jSeparator2.setMinimumSize(new java.awt.Dimension (0, 2)); 242 gridBagConstraints = new java.awt.GridBagConstraints (); 243 gridBagConstraints.gridx = 0; 244 gridBagConstraints.gridwidth = 2; 245 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 246 gridBagConstraints.weightx = 1.0; 247 gridBagConstraints.insets = new java.awt.Insets (4, 4, 6, 4); 248 jPanel2.add(jSeparator2, gridBagConstraints); 249 250 jLabelLabel.setText("Label"); 251 gridBagConstraints = new java.awt.GridBagConstraints (); 252 gridBagConstraints.gridx = 0; 253 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 254 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 4); 255 jPanel2.add(jLabelLabel, gridBagConstraints); 256 257 gridBagConstraints = new java.awt.GridBagConstraints (); 258 gridBagConstraints.gridx = 1; 259 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 260 gridBagConstraints.weightx = 1.0; 261 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 262 jPanel2.add(jTextFieldLabel, gridBagConstraints); 263 264 jScrollPane1.setViewportView(jEditorPaneDescription); 265 266 gridBagConstraints = new java.awt.GridBagConstraints (); 267 gridBagConstraints.gridx = 1; 268 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 269 gridBagConstraints.weightx = 1.0; 270 gridBagConstraints.weighty = 1.0; 271 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 4); 272 jPanel2.add(jScrollPane1, gridBagConstraints); 273 274 jLabelDescription.setText("Description"); 275 gridBagConstraints = new java.awt.GridBagConstraints (); 276 gridBagConstraints.gridx = 0; 277 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 278 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 279 gridBagConstraints.insets = new java.awt.Insets (4, 4, 0, 4); 280 jPanel2.add(jLabelDescription, gridBagConstraints); 281 282 jTabbedPane1.addTab("General", jPanel2); 283 284 jPanel3.setLayout(new java.awt.GridBagLayout ()); 285 286 jLabelType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); 287 jLabelType.setText("Type"); 288 gridBagConstraints = new java.awt.GridBagConstraints (); 289 gridBagConstraints.gridx = 0; 290 gridBagConstraints.gridy = 1; 291 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 292 gridBagConstraints.insets = new java.awt.Insets (8, 20, 4, 0); 293 jPanel3.add(jLabelType, gridBagConstraints); 294 295 jComboBoxType.setMinimumSize(new java.awt.Dimension (23, 22)); 296 jComboBoxType.addActionListener(new java.awt.event.ActionListener () { 297 public void actionPerformed(java.awt.event.ActionEvent evt) { 298 jComboBoxTypeActionPerformed(evt); 299 } 300 }); 301 302 gridBagConstraints = new java.awt.GridBagConstraints (); 303 gridBagConstraints.gridy = 1; 304 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 305 gridBagConstraints.weightx = 1.0; 306 gridBagConstraints.insets = new java.awt.Insets (8, 4, 4, 20); 307 jPanel3.add(jComboBoxType, gridBagConstraints); 308 309 jLabelMandatory.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); 310 jLabelMandatory.setText("Mandatory"); 311 gridBagConstraints = new java.awt.GridBagConstraints (); 312 gridBagConstraints.gridx = 0; 313 gridBagConstraints.gridy = 4; 314 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 315 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 0); 316 jPanel3.add(jLabelMandatory, gridBagConstraints); 317 318 jCheckBoxMandatory.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 319 gridBagConstraints = new java.awt.GridBagConstraints (); 320 gridBagConstraints.gridx = 1; 321 gridBagConstraints.gridy = 4; 322 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 323 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 20); 324 jPanel3.add(jCheckBoxMandatory, gridBagConstraints); 325 326 jLabelReadOnly.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); 327 jLabelReadOnly.setText("Read Only"); 328 gridBagConstraints = new java.awt.GridBagConstraints (); 329 gridBagConstraints.gridx = 0; 330 gridBagConstraints.gridy = 6; 331 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 332 gridBagConstraints.insets = new java.awt.Insets (0, 4, 8, 0); 333 jPanel3.add(jLabelReadOnly, gridBagConstraints); 334 335 jCheckBoxReadOnly.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 336 gridBagConstraints = new java.awt.GridBagConstraints (); 337 gridBagConstraints.gridx = 1; 338 gridBagConstraints.gridy = 6; 339 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 340 gridBagConstraints.insets = new java.awt.Insets (0, 4, 8, 20); 341 jPanel3.add(jCheckBoxReadOnly, gridBagConstraints); 342 343 jSeparator4.setMinimumSize(new java.awt.Dimension (2, 2)); 344 jSeparator4.setPreferredSize(new java.awt.Dimension (2, 2)); 345 gridBagConstraints = new java.awt.GridBagConstraints (); 346 gridBagConstraints.gridx = 0; 347 gridBagConstraints.gridwidth = 2; 348 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 349 gridBagConstraints.weightx = 1.0; 350 gridBagConstraints.insets = new java.awt.Insets (0, 8, 0, 8); 351 jPanel3.add(jSeparator4, gridBagConstraints); 352 353 jPanel5.setLayout(new java.awt.GridBagLayout ()); 354 355 jPanelLocate.setLayout(new java.awt.GridBagLayout ()); 356 357 jLabelLocate.setText("Locate List of Values"); 358 gridBagConstraints = new java.awt.GridBagConstraints (); 359 gridBagConstraints.gridx = 0; 360 gridBagConstraints.gridwidth = 2; 361 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 362 gridBagConstraints.insets = new java.awt.Insets (4, 8, 8, 8); 363 jPanelLocate.add(jLabelLocate, gridBagConstraints); 364 365 buttonGroup1.add(jRadioButtonRepo); 366 jRadioButtonRepo.setText("From the repository"); 367 jRadioButtonRepo.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 368 jRadioButtonRepo.setMargin(new java.awt.Insets (0, 0, 0, 0)); 369 jRadioButtonRepo.addActionListener(new java.awt.event.ActionListener () { 370 public void actionPerformed(java.awt.event.ActionEvent evt) { 371 jRadioButtonRepoActionPerformed(evt); 372 } 373 }); 374 375 gridBagConstraints = new java.awt.GridBagConstraints (); 376 gridBagConstraints.gridx = 0; 377 gridBagConstraints.gridwidth = 2; 378 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 379 gridBagConstraints.weightx = 1.0; 380 gridBagConstraints.insets = new java.awt.Insets (8, 8, 4, 4); 381 jPanelLocate.add(jRadioButtonRepo, gridBagConstraints); 382 383 jTextFieldResource.setEnabled(false); 384 gridBagConstraints = new java.awt.GridBagConstraints (); 385 gridBagConstraints.gridx = 0; 386 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 387 gridBagConstraints.weightx = 1.0; 388 gridBagConstraints.insets = new java.awt.Insets (0, 30, 4, 0); 389 jPanelLocate.add(jTextFieldResource, gridBagConstraints); 390 391 jButtonPickResource.setText("Browse"); 392 jButtonPickResource.setEnabled(false); 393 jButtonPickResource.addActionListener(new java.awt.event.ActionListener () { 394 public void actionPerformed(java.awt.event.ActionEvent evt) { 395 jButtonPickResourceActionPerformed(evt); 396 } 397 }); 398 399 gridBagConstraints = new java.awt.GridBagConstraints (); 400 gridBagConstraints.gridx = 1; 401 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 402 gridBagConstraints.insets = new java.awt.Insets (0, 0, 4, 8); 403 jPanelLocate.add(jButtonPickResource, gridBagConstraints); 404 405 buttonGroup1.add(jRadioButtonLocal); 406 jRadioButtonLocal.setSelected(true); 407 jRadioButtonLocal.setText("Locally Defined"); 408 jRadioButtonLocal.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 409 jRadioButtonLocal.setMargin(new java.awt.Insets (0, 0, 0, 0)); 410 jRadioButtonLocal.addActionListener(new java.awt.event.ActionListener () { 411 public void actionPerformed(java.awt.event.ActionEvent evt) { 412 jRadioButtonLocalActionPerformed(evt); 413 } 414 }); 415 416 gridBagConstraints = new java.awt.GridBagConstraints (); 417 gridBagConstraints.gridx = 0; 418 gridBagConstraints.gridwidth = 2; 419 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 420 gridBagConstraints.weightx = 1.0; 421 gridBagConstraints.insets = new java.awt.Insets (8, 8, 4, 4); 422 jPanelLocate.add(jRadioButtonLocal, gridBagConstraints); 423 424 jButtonEditLocalResource.setText("Edit local resource"); 425 jButtonEditLocalResource.addActionListener(new java.awt.event.ActionListener () { 426 public void actionPerformed(java.awt.event.ActionEvent evt) { 427 jButtonEditLocalResourceActionPerformed(evt); 428 } 429 }); 430 431 gridBagConstraints = new java.awt.GridBagConstraints (); 432 gridBagConstraints.gridx = 0; 433 gridBagConstraints.gridwidth = 2; 434 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 435 gridBagConstraints.insets = new java.awt.Insets (0, 30, 0, 0); 436 jPanelLocate.add(jButtonEditLocalResource, gridBagConstraints); 437 438 gridBagConstraints = new java.awt.GridBagConstraints (); 439 gridBagConstraints.gridx = 0; 440 gridBagConstraints.weighty = 1.0; 441 jPanelLocate.add(jPanel6, gridBagConstraints); 442 443 gridBagConstraints = new java.awt.GridBagConstraints (); 444 gridBagConstraints.gridx = 0; 445 gridBagConstraints.gridy = 0; 446 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 447 gridBagConstraints.weightx = 1.0; 448 gridBagConstraints.weighty = 1.0; 449 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 4); 450 jPanel5.add(jPanelLocate, gridBagConstraints); 451 452 jPanelQuery.setLayout(new java.awt.GridBagLayout ()); 453 454 jPanelLocateQuery.setLayout(new java.awt.GridBagLayout ()); 455 456 jLabelLocate1.setText("Locate query"); 457 gridBagConstraints = new java.awt.GridBagConstraints (); 458 gridBagConstraints.gridx = 0; 459 gridBagConstraints.gridwidth = 2; 460 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 461 gridBagConstraints.insets = new java.awt.Insets (4, 8, 8, 8); 462 jPanelLocateQuery.add(jLabelLocate1, gridBagConstraints); 463 464 buttonGroup2.add(jRadioButtonRepo1); 465 jRadioButtonRepo1.setText("From the repository"); 466 jRadioButtonRepo1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 467 jRadioButtonRepo1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 468 jRadioButtonRepo1.addActionListener(new java.awt.event.ActionListener () { 469 public void actionPerformed(java.awt.event.ActionEvent evt) { 470 jRadioButtonRepoActionPerformed1(evt); 471 } 472 }); 473 474 gridBagConstraints = new java.awt.GridBagConstraints (); 475 gridBagConstraints.gridx = 0; 476 gridBagConstraints.gridwidth = 2; 477 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 478 gridBagConstraints.weightx = 1.0; 479 gridBagConstraints.insets = new java.awt.Insets (8, 8, 4, 4); 480 jPanelLocateQuery.add(jRadioButtonRepo1, gridBagConstraints); 481 482 jTextFieldResource1.setEnabled(false); 483 gridBagConstraints = new java.awt.GridBagConstraints (); 484 gridBagConstraints.gridx = 0; 485 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 486 gridBagConstraints.weightx = 1.0; 487 gridBagConstraints.insets = new java.awt.Insets (0, 30, 4, 0); 488 jPanelLocateQuery.add(jTextFieldResource1, gridBagConstraints); 489 490 jButtonPickResource1.setText("Browse"); 491 jButtonPickResource1.setEnabled(false); 492 jButtonPickResource1.addActionListener(new java.awt.event.ActionListener () { 493 public void actionPerformed(java.awt.event.ActionEvent evt) { 494 jButtonPickResourceActionPerformed1(evt); 495 } 496 }); 497 498 gridBagConstraints = new java.awt.GridBagConstraints (); 499 gridBagConstraints.gridx = 1; 500 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 501 gridBagConstraints.insets = new java.awt.Insets (0, 0, 4, 8); 502 jPanelLocateQuery.add(jButtonPickResource1, gridBagConstraints); 503 504 buttonGroup2.add(jRadioButtonLocal1); 505 jRadioButtonLocal1.setSelected(true); 506 jRadioButtonLocal1.setText("Locally Defined"); 507 jRadioButtonLocal1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 508 jRadioButtonLocal1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 509 jRadioButtonLocal1.addActionListener(new java.awt.event.ActionListener () { 510 public void actionPerformed(java.awt.event.ActionEvent evt) { 511 jRadioButtonLocalActionPerformed1(evt); 512 } 513 }); 514 515 gridBagConstraints = new java.awt.GridBagConstraints (); 516 gridBagConstraints.gridx = 0; 517 gridBagConstraints.gridwidth = 2; 518 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 519 gridBagConstraints.weightx = 1.0; 520 gridBagConstraints.insets = new java.awt.Insets (8, 8, 4, 4); 521 jPanelLocateQuery.add(jRadioButtonLocal1, gridBagConstraints); 522 523 jButtonEditLocalResource1.setText("Edit local resource"); 524 jButtonEditLocalResource1.setActionCommand("Edit local query resource"); 525 jButtonEditLocalResource1.addActionListener(new java.awt.event.ActionListener () { 526 public void actionPerformed(java.awt.event.ActionEvent evt) { 527 jButtonEditLocalResourceActionPerformed1(evt); 528 } 529 }); 530 531 gridBagConstraints = new java.awt.GridBagConstraints (); 532 gridBagConstraints.gridx = 0; 533 gridBagConstraints.gridwidth = 2; 534 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 535 gridBagConstraints.insets = new java.awt.Insets (0, 30, 0, 0); 536 jPanelLocateQuery.add(jButtonEditLocalResource1, gridBagConstraints); 537 538 gridBagConstraints = new java.awt.GridBagConstraints (); 539 gridBagConstraints.gridx = 0; 540 gridBagConstraints.weighty = 1.0; 541 jPanelLocateQuery.add(jPanel7, gridBagConstraints); 542 543 jTabbedPane2.addTab("Query resource", jPanelLocateQuery); 544 545 jPanelFields.setLayout(new java.awt.GridBagLayout ()); 546 547 jLabelLocate2.setText("Value column"); 548 gridBagConstraints = new java.awt.GridBagConstraints (); 549 gridBagConstraints.gridx = 0; 550 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 551 gridBagConstraints.insets = new java.awt.Insets (4, 8, 8, 8); 552 jPanelFields.add(jLabelLocate2, gridBagConstraints); 553 554 gridBagConstraints = new java.awt.GridBagConstraints (); 555 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 556 gridBagConstraints.weightx = 1.0; 557 gridBagConstraints.insets = new java.awt.Insets (4, 0, 8, 8); 558 jPanelFields.add(jTextFieldValueColumn, gridBagConstraints); 559 560 jPanelVisibleColumns.setLayout(new java.awt.GridBagLayout ()); 561 562 jLabelLocate3.setText("Visible query columns"); 563 gridBagConstraints = new java.awt.GridBagConstraints (); 564 gridBagConstraints.gridx = 0; 565 gridBagConstraints.gridwidth = 2; 566 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 567 gridBagConstraints.weightx = 1.0; 568 jPanelVisibleColumns.add(jLabelLocate3, gridBagConstraints); 569 570 jListColumns.addMouseListener(new java.awt.event.MouseAdapter () { 571 public void mouseClicked(java.awt.event.MouseEvent evt) { 572 jListColumnsMouseClicked(evt); 573 } 574 }); 575 576 jScrollPane2.setViewportView(jListColumns); 577 578 gridBagConstraints = new java.awt.GridBagConstraints (); 579 gridBagConstraints.gridx = 0; 580 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 581 gridBagConstraints.weightx = 1.0; 582 gridBagConstraints.weighty = 1.0; 583 jPanelVisibleColumns.add(jScrollPane2, gridBagConstraints); 584 585 jPanel8.setLayout(new java.awt.GridBagLayout ()); 586 587 jButtonAddColumn.setText("Add"); 588 jButtonAddColumn.addActionListener(new java.awt.event.ActionListener () { 589 public void actionPerformed(java.awt.event.ActionEvent evt) { 590 jButtonAddColumnActionPerformed(evt); 591 } 592 }); 593 594 gridBagConstraints = new java.awt.GridBagConstraints (); 595 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 596 gridBagConstraints.weightx = 1.0; 597 gridBagConstraints.insets = new java.awt.Insets (0, 0, 4, 0); 598 jPanel8.add(jButtonAddColumn, gridBagConstraints); 599 600 jButtonModColumn.setText("Modify"); 601 jButtonModColumn.addActionListener(new java.awt.event.ActionListener () { 602 public void actionPerformed(java.awt.event.ActionEvent evt) { 603 jButtonModColumnActionPerformed(evt); 604 } 605 }); 606 607 gridBagConstraints = new java.awt.GridBagConstraints (); 608 gridBagConstraints.gridx = 0; 609 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 610 gridBagConstraints.weightx = 1.0; 611 gridBagConstraints.insets = new java.awt.Insets (0, 0, 4, 0); 612 jPanel8.add(jButtonModColumn, gridBagConstraints); 613 614 jButtonRemColumn.setText("Remove"); 615 jButtonRemColumn.addActionListener(new java.awt.event.ActionListener () { 616 public void actionPerformed(java.awt.event.ActionEvent evt) { 617 jButtonRemColumnActionPerformed(evt); 618 } 619 }); 620 621 gridBagConstraints = new java.awt.GridBagConstraints (); 622 gridBagConstraints.gridx = 0; 623 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 624 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 625 gridBagConstraints.weightx = 1.0; 626 gridBagConstraints.weighty = 1.0; 627 gridBagConstraints.insets = new java.awt.Insets (0, 0, 4, 0); 628 jPanel8.add(jButtonRemColumn, gridBagConstraints); 629 630 gridBagConstraints = new java.awt.GridBagConstraints (); 631 gridBagConstraints.gridx = 1; 632 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 633 gridBagConstraints.weighty = 1.0; 634 gridBagConstraints.insets = new java.awt.Insets (0, 4, 0, 4); 635 jPanelVisibleColumns.add(jPanel8, gridBagConstraints); 636 637 gridBagConstraints = new java.awt.GridBagConstraints (); 638 gridBagConstraints.gridx = 0; 639 gridBagConstraints.gridwidth = 2; 640 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 641 gridBagConstraints.weightx = 1.0; 642 gridBagConstraints.weighty = 1.0; 643 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 644 jPanelFields.add(jPanelVisibleColumns, gridBagConstraints); 645 646 jTabbedPane2.addTab("Value and visible columns", jPanelFields); 647 648 gridBagConstraints = new java.awt.GridBagConstraints (); 649 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 650 gridBagConstraints.weightx = 1.0; 651 gridBagConstraints.weighty = 1.0; 652 jPanelQuery.add(jTabbedPane2, gridBagConstraints); 653 654 gridBagConstraints = new java.awt.GridBagConstraints (); 655 gridBagConstraints.gridx = 0; 656 gridBagConstraints.gridy = 0; 657 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 658 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 659 gridBagConstraints.weightx = 1.0; 660 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 4); 661 jPanel5.add(jPanelQuery, gridBagConstraints); 662 663 gridBagConstraints = new java.awt.GridBagConstraints (); 664 gridBagConstraints.gridx = 0; 665 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 666 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 667 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 668 gridBagConstraints.weightx = 1.0; 669 gridBagConstraints.weighty = 1.0; 670 jPanel3.add(jPanel5, gridBagConstraints); 671 672 jTabbedPane1.addTab("Input Control details", jPanel3); 673 674 gridBagConstraints = new java.awt.GridBagConstraints (); 675 gridBagConstraints.gridx = 0; 676 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 677 gridBagConstraints.weightx = 1.0; 678 gridBagConstraints.weighty = 1.0; 679 getContentPane().add(jTabbedPane1, gridBagConstraints); 680 681 jPanel4.setLayout(new java.awt.GridBagLayout ()); 682 683 jPanel4.setMinimumSize(new java.awt.Dimension (10, 30)); 684 jPanel4.setPreferredSize(new java.awt.Dimension (10, 30)); 685 jButtonSave.setText("Save"); 686 jButtonSave.setEnabled(false); 687 jButtonSave.addActionListener(new java.awt.event.ActionListener () { 688 public void actionPerformed(java.awt.event.ActionEvent evt) { 689 jButtonSaveActionPerformed(evt); 690 } 691 }); 692 693 gridBagConstraints = new java.awt.GridBagConstraints (); 694 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 695 gridBagConstraints.weightx = 1.0; 696 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 4); 697 jPanel4.add(jButtonSave, gridBagConstraints); 698 699 jButtonClose.setText("Cancel"); 700 jButtonClose.addActionListener(new java.awt.event.ActionListener () { 701 public void actionPerformed(java.awt.event.ActionEvent evt) { 702 jButtonCloseActionPerformed(evt); 703 } 704 }); 705 706 jPanel4.add(jButtonClose, new java.awt.GridBagConstraints ()); 707 708 gridBagConstraints = new java.awt.GridBagConstraints (); 709 gridBagConstraints.gridx = 0; 710 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 711 gridBagConstraints.insets = new java.awt.Insets (0, 4, 0, 4); 712 getContentPane().add(jPanel4, gridBagConstraints); 713 714 pack(); 715 } 717 private void jButtonRemColumnActionPerformed(java.awt.event.ActionEvent evt) { 719 int keys[] = jListColumns.getSelectedIndices(); 720 DefaultListModel dlm = (DefaultListModel )jListColumns.getModel(); 721 for (int i = keys.length-1; i>=0; --i) 722 { 723 dlm.remove(keys[i]); 724 } 725 726 727 } 729 private void jButtonAddColumnActionPerformed(java.awt.event.ActionEvent evt) { 731 String s = JOptionPane.showInputDialog(MainFrame.getMainInstance(),"Column name"); 732 if (s != null && s.trim().length()>0) 733 { 734 ((DefaultListModel )jListColumns.getModel()).addElement(s); 735 } 736 737 } 739 private void jButtonModColumnActionPerformed(java.awt.event.ActionEvent evt) { 741 int i = jListColumns.getSelectedIndex(); 742 if (i < 0) return; 743 String s = ""+jListColumns.getSelectedValue(); 744 s = JOptionPane.showInputDialog(MainFrame.getMainInstance(),"Column name",s); 745 if (s != null && s.trim().length()>0) 746 { 747 ((DefaultListModel )jListColumns.getModel()).setElementAt(s,i); 748 } 749 750 } 752 private void jListColumnsMouseClicked(java.awt.event.MouseEvent evt) { 754 if (evt.getClickCount() == 2 && 755 evt.getButton() == evt.BUTTON1 && 756 jListColumns.getSelectedIndex() >=0 ) 757 { 758 jButtonModColumnActionPerformed(null); 759 } 760 } 762 private void jButtonEditLocalResourceActionPerformed1(java.awt.event.ActionEvent evt) { 764 765 jButtonEditLocalResourceActionPerformed(evt); 766 767 } 769 private void jRadioButtonLocalActionPerformed1(java.awt.event.ActionEvent evt) { updateQueryResourceFromType(); 771 } 773 private void jButtonPickResourceActionPerformed1(java.awt.event.ActionEvent evt) { ResourceChooser rc = new ResourceChooser(); 775 rc.setServer( getServer() ); 776 if (rc.showDialog(this, null) == JOptionPane.OK_OPTION) 777 { 778 ResourceDescriptor rd = rc.getSelectedDescriptor(); 779 if (rd == null || rd.getUriString() == null) 780 { 781 jTextFieldResource1.setText(""); 782 } 783 else 784 { 785 jTextFieldResource1.setText( rd.getUriString() ); 786 } 787 updateSaveButton(); 788 } 789 } 791 private void jRadioButtonRepoActionPerformed1(java.awt.event.ActionEvent evt) { updateQueryResourceFromType(); 793 } 795 private void jButtonEditLocalResourceActionPerformed(java.awt.event.ActionEvent evt) { 797 byte b = Byte.parseByte( ((Tag)jComboBoxType.getSelectedItem()).getValue()+""); 798 799 if (b == ResourceDescriptor.IC_TYPE_SINGLE_VALUE) 800 { 801 DataTypeDialog dtd = new DataTypeDialog(MainFrame.getMainInstance(),true); 802 dtd.setServer(this.getServer()); 803 dtd.setParentFolder( this.getParentFolder() + "/<inputControl>"); 804 dtd.setDoNotStore(true); 805 if (dataTypeResourceDescriptor != null) 806 { 807 dtd.setResource(dataTypeResourceDescriptor); 808 } 809 810 dtd.setVisible(true); 811 812 if (dtd.getDialogResult() == JOptionPane.OK_OPTION) 813 { 814 dataTypeResourceDescriptor = dtd.getNewResourceDescriptor(); 815 } 816 } 817 else if (b == ResourceDescriptor.IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES) 818 { 819 ListOfValuesDialog dtd = new ListOfValuesDialog(MainFrame.getMainInstance(),true); 820 dtd.setServer(this.getServer()); 821 dtd.setParentFolder( this.getParentFolder() + "/<inputControl>"); 822 dtd.setDoNotStore(true); 823 if (lovResourceDescriptor != null) 824 { 825 dtd.setResource(lovResourceDescriptor); 826 } 827 828 dtd.setVisible(true); 829 830 if (dtd.getDialogResult() == JOptionPane.OK_OPTION) 831 { 832 lovResourceDescriptor = dtd.getNewResourceDescriptor(); 833 } 834 } 835 else if (b == ResourceDescriptor.IC_TYPE_SINGLE_SELECT_QUERY) 836 { 837 QueryDialog dtd = new QueryDialog(MainFrame.getMainInstance(),true); 838 dtd.setServer(this.getServer()); 839 dtd.setParentFolder( this.getParentFolder() + "/<inputControl>"); 840 dtd.setDoNotStore(true); 841 if (queryResourceDescriptor != null) 842 { 843 dtd.setResource(queryResourceDescriptor); 844 } 845 846 dtd.setVisible(true); 847 848 if (dtd.getDialogResult() == JOptionPane.OK_OPTION) 849 { 850 queryResourceDescriptor = dtd.getNewResourceDescriptor(); 851 } 852 } 853 } 855 private void jButtonPickResourceActionPerformed(java.awt.event.ActionEvent evt) { 857 858 ResourceChooser rc = new ResourceChooser(); 859 rc.setServer( getServer() ); 860 if (rc.showDialog(this, null) == JOptionPane.OK_OPTION) 861 { 862 ResourceDescriptor rd = rc.getSelectedDescriptor(); 863 if (rd == null || rd.getUriString() == null) 864 { 865 jTextFieldResource.setText(""); 866 } 867 else 868 { 869 jTextFieldResource.setText( rd.getUriString() ); 870 } 871 updateSaveButton(); 872 } 873 874 } 876 private void jComboBoxTypeActionPerformed(java.awt.event.ActionEvent evt) { 878 String value = ((Tag)jComboBoxType.getSelectedItem()).getValue()+""; 879 880 if (value.equals("1")) 881 { 882 jPanelLocate.setVisible(false); 883 jPanelQuery.setVisible(false); 884 } 885 else if (value.equals("2")) 886 { 887 jPanelLocate.setVisible(true); 888 jLabelLocate.setText("Locate Data Type"); 889 jButtonEditLocalResource.setText("Edit local resource (Data Type)"); 890 jPanelQuery.setVisible(false); 891 } 892 else if (value.equals("3")) 893 { 894 jPanelLocate.setVisible(true); 895 jLabelLocate.setText("Locate List of Values"); 896 jButtonEditLocalResource.setText("Edit local resource (List of Values)"); 897 jPanelQuery.setVisible(false); 898 } 899 else if (value.equals("4")) 900 { 901 jPanelLocate.setVisible(false); 902 jPanelQuery.setVisible(true); 903 } 904 905 } 907 private void jRadioButtonLocalActionPerformed(java.awt.event.ActionEvent evt) { updateResourceFromType(); 909 } 911 private void jRadioButtonRepoActionPerformed(java.awt.event.ActionEvent evt) { updateResourceFromType(); 913 } 915 private void jButtonCloseActionPerformed(java.awt.event.ActionEvent evt) { 917 this.setVisible(false); 918 this.dispose(); 919 } 921 private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) { 923 924 ResourceDescriptor rd = new ResourceDescriptor(); 925 926 rd.setDescription( jEditorPaneDescription.getText().trim() ); rd.setName( jTextFieldName.getText() ); 928 String uri = getParentFolder(); 929 if (!uri.endsWith("/")) uri = uri + "/"; 930 uri += jTextFieldName.getText(); 931 rd.setUriString( uri ); 932 rd.setLabel(jTextFieldLabel.getText().trim() ); rd.setParentFolder( getParentFolder() ); 934 rd.setIsNew(resource == null); 935 936 rd.setWsType( ResourceDescriptor.TYPE_INPUT_CONTROL); 937 938 rd.setMandatory( jCheckBoxMandatory.isSelected() ); 939 rd.setReadOnly( jCheckBoxReadOnly.isSelected() ); 940 rd.setControlType( Byte.parseByte( ((Tag)jComboBoxType.getSelectedItem()).getValue()+"")); 941 942 if (rd.getControlType() == rd.IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES && 943 jRadioButtonLocal.isSelected()) 944 { 945 if (lovResourceDescriptor == null || !lovResourceDescriptor.getWsType().equals( ResourceDescriptor.TYPE_LOV)) 946 { 947 JOptionPane.showMessageDialog(this,"The local list of values defined is not valid.\nPress the button \"Edit local resource\" to fix the problem."); 948 return; 949 } 950 } 951 else if (rd.getControlType() == rd.IC_TYPE_SINGLE_VALUE && 952 jRadioButtonLocal.isSelected()) 953 { 954 if (dataTypeResourceDescriptor == null || !dataTypeResourceDescriptor.getWsType().equals( ResourceDescriptor.TYPE_DATA_TYPE)) 955 { 956 JOptionPane.showMessageDialog(this,"The local data type defined is not valid.\nPress the button \"Edit local resource\" to fix the problem."); 957 return; 958 } 959 } 960 else if (rd.getControlType() == rd.IC_TYPE_SINGLE_SELECT_QUERY) 961 { 962 if (jRadioButtonLocal1.isSelected()) 963 { 964 if (queryResourceDescriptor == null || !queryResourceDescriptor.getWsType().equals( ResourceDescriptor.TYPE_QUERY)) 965 { 966 JOptionPane.showMessageDialog(this,"The local query defined is not valid.\nPress the button \"Edit local resource\" to fix the problem."); 967 return; 968 } 969 } 970 971 if (jRadioButtonRepo1.isSelected() && jTextFieldResource1.getText().trim().length() == 0) 972 { 973 JOptionPane.showMessageDialog(this,"Please set a valid reference to a Query object in the Repository."); 974 jTextFieldResource1.requestFocusInWindow(); 975 return; 976 } 977 978 if (jTextFieldValueColumn.getText().trim().length() == 0) 979 { 980 JOptionPane.showMessageDialog(this,"Please set the value column."); 981 return; 982 } 983 984 if (jListColumns.getModel().getSize() == 0) 985 { 986 JOptionPane.showMessageDialog(this,"Please set at least one visible column in the visible columns list."); 987 return; 988 } 989 990 rd.setQueryValueColumn( jTextFieldValueColumn.getText() ); 991 int count = jListColumns.getModel().getSize(); 992 String [] visibleColumns = new String [count]; 993 994 for (int i=0; i<count; ++i) 995 { 996 visibleColumns[i] = jListColumns.getModel().getElementAt(i) + ""; 997 } 998 rd.setQueryVisibleColumns( visibleColumns ); 999 1000 } 1001 1002 1003 if ( (rd.getControlType() == rd.IC_TYPE_SINGLE_VALUE || rd.getControlType() == rd.IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES) 1004 && jRadioButtonRepo.isSelected() 1005 && jTextFieldResource.getText().trim().length() == 0) 1006 { 1007 JOptionPane.showMessageDialog(this,"Please set a valid reference to a resource in the Repository."); 1008 jTextFieldResource.requestFocusInWindow(); 1009 return; 1010 } 1011 1012 try { 1013 1014 validate(rd); 1015 1016 if (rd.getControlType() != rd.IC_TYPE_BOOLEAN) 1017 { 1018 ResourceDescriptor rdChild = null; 1019 1020 if (rd.getControlType() == rd.IC_TYPE_SINGLE_SELECT_QUERY && 1021 jRadioButtonRepo1.isSelected()) 1022 { 1023 rdChild = new ResourceDescriptor(); 1025 rdChild.setWsType( ResourceDescriptor.TYPE_REFERENCE); 1026 rdChild.setReferenceUri( jTextFieldResource1.getText().trim() ); 1027 } 1028 else if ( (rd.getControlType() == rd.IC_TYPE_SINGLE_VALUE || 1029 rd.getControlType() == rd.IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES) 1030 && jRadioButtonRepo.isSelected() ) 1031 { 1032 rdChild = new ResourceDescriptor(); 1034 rdChild.setWsType( ResourceDescriptor.TYPE_REFERENCE); 1035 rdChild.setReferenceUri( jTextFieldResource.getText().trim() ); 1036 } 1037 else { 1039 if (rd.getControlType() == rd.IC_TYPE_SINGLE_VALUE) 1040 { 1041 rdChild = dataTypeResourceDescriptor; 1042 } 1043 else if (rd.getControlType() == rd.IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES) 1044 { 1045 rdChild = lovResourceDescriptor; 1046 } 1047 else if (rd.getControlType() == rd.IC_TYPE_SINGLE_SELECT_QUERY) 1048 { 1049 rdChild = queryResourceDescriptor; 1050 } 1051 } 1052 1053 if (rdChild != null) 1054 { 1055 if (rd.getChildren() == null) rd.setChildren(new java.util.ArrayList ()); 1056 rd.getChildren().add(rdChild); 1057 } 1058 } 1059 1060 newResourceDescriptor = getServer().getWSClient().modifyReportUnitResource(getReportUnitUri(), rd, null); 1061 setDialogResult(JOptionPane.OK_OPTION); 1062 1063 if (resource != null) 1064 { 1065 resource.setDescriptor(newResourceDescriptor); 1066 } 1067 1068 this.setVisible(false); 1069 this.dispose(); 1070 1071 } catch (Exception ex) { 1072 JOptionPane.showMessageDialog(this,"Error: " + ex.getMessage()); 1073 ex.printStackTrace(); 1074 return; 1075 } 1076 } 1078 1079 public int getDialogResult() { 1080 return dialogResult; 1081 } 1082 1083 public void setDialogResult(int dialogResult) { 1084 this.dialogResult = dialogResult; 1085 } 1086 1087 1088 public JServer getServer() { 1089 return server; 1090 } 1091 1092 public void setServer(JServer server) { 1093 this.server = server; 1094 } 1095 1096 public String getParentFolder() { 1097 return parentFolder; 1098 } 1099 1100 public void setParentFolder(String parentFolder) { 1101 this.parentFolder = parentFolder; 1102 this.jTextFieldUriString.setText(parentFolder); 1103 } 1104 1105 public ResourceDescriptor getNewResourceDescriptor() { 1106 return newResourceDescriptor; 1107 } 1108 1109 1112 public void setResource(RepositoryFolder resource) 1113 { 1114 1115 this.resource = resource; 1116 1117 if (resource != null) 1118 { 1119 setResource(resource.getDescriptor()); 1120 } 1121 jTextFieldName.setEditable(false); 1122 jTextFieldName.setOpaque(false); 1123 } 1124 1125 1128 public void setResource(ResourceDescriptor descriptor) 1129 { 1130 if (descriptor == null) return; 1131 jTextFieldName.setText( descriptor.getName()); 1132 jTextFieldLabel.setText( descriptor.getLabel()); 1133 jEditorPaneDescription.setText( descriptor.getDescription()); 1134 1135 System.out.println("Mandatory: " + descriptor.isMandatory() ); 1136 System.out.println("ReadOnly: " + descriptor.isReadOnly() ); 1137 1138 jCheckBoxMandatory.setSelected( descriptor.isMandatory()); 1139 jCheckBoxReadOnly.setSelected( descriptor.isReadOnly()); 1140 1141 Misc.setComboboxSelectedTagValue(jComboBoxType, ""+ descriptor.getControlType()); 1142 1143 if (descriptor.getQueryValueColumn() != null) 1144 { 1145 jTextFieldValueColumn.setText( descriptor.getQueryValueColumn() ); 1146 } 1147 1148 if (descriptor.getQueryVisibleColumns() != null) 1149 { 1150 String [] visibleColumns = descriptor.getQueryVisibleColumns(); 1151 DefaultListModel dlm = (DefaultListModel )jListColumns.getModel(); 1152 for (int i=0; i<visibleColumns.length; ++i) 1153 { 1154 dlm.addElement( visibleColumns[i] ); 1155 } 1156 } 1157 1158 if (descriptor.getChildren().size() > 0) 1159 { 1160 ResourceDescriptor rd = (ResourceDescriptor)descriptor.getChildren().get(0); 1161 1162 if (rd.getWsType().equals(ResourceDescriptor.TYPE_REFERENCE)) 1163 { 1164 if (descriptor.getControlType() == ResourceDescriptor.IC_TYPE_SINGLE_SELECT_QUERY) 1165 { 1166 jTextFieldResource1.setText( rd.getReferenceUri() ); 1167 jRadioButtonRepo1.setSelected(true); 1168 } 1169 else 1170 { 1171 jTextFieldResource.setText( rd.getReferenceUri() ); 1172 jRadioButtonRepo.setSelected(true); 1173 } 1174 } 1175 else 1176 { 1177 jRadioButtonLocal.setSelected(true); 1178 if (rd.getWsType().equals(ResourceDescriptor.TYPE_DATA_TYPE)) 1179 { 1180 dataTypeResourceDescriptor = rd; 1181 } 1182 else if (rd.getWsType().equals(ResourceDescriptor.TYPE_LOV)) 1183 { 1184 lovResourceDescriptor = rd; 1185 } 1186 else if (rd.getWsType().equals(ResourceDescriptor.TYPE_QUERY)) 1187 { 1188 queryResourceDescriptor = rd; 1189 } 1190 } 1191 1192 if (descriptor.getControlType() == ResourceDescriptor.IC_TYPE_SINGLE_SELECT_QUERY) 1193 { 1194 updateQueryResourceFromType(); 1195 } 1196 else 1197 { 1198 updateResourceFromType(); 1199 } 1200 } 1201 } 1202 1203 private javax.swing.ButtonGroup buttonGroup1; 1205 private javax.swing.ButtonGroup buttonGroup2; 1206 private javax.swing.JButton jButtonAddColumn; 1207 private javax.swing.JButton jButtonClose; 1208 private javax.swing.JButton jButtonEditLocalResource; 1209 private javax.swing.JButton jButtonEditLocalResource1; 1210 private javax.swing.JButton jButtonModColumn; 1211 private javax.swing.JButton jButtonPickResource; 1212 private javax.swing.JButton jButtonPickResource1; 1213 private javax.swing.JButton jButtonRemColumn; 1214 private javax.swing.JButton jButtonSave; 1215 private javax.swing.JCheckBox jCheckBoxMandatory; 1216 private javax.swing.JCheckBox jCheckBoxReadOnly; 1217 private javax.swing.JComboBox jComboBoxType; 1218 private javax.swing.JEditorPane jEditorPaneDescription; 1219 private javax.swing.JLabel jLabel1; 1220 private javax.swing.JLabel jLabelDescription; 1221 private javax.swing.JLabel jLabelLabel; 1222 private javax.swing.JLabel jLabelLocate; 1223 private javax.swing.JLabel jLabelLocate1; 1224 private javax.swing.JLabel jLabelLocate2; 1225 private javax.swing.JLabel jLabelLocate3; 1226 private javax.swing.JLabel jLabelMandatory; 1227 private javax.swing.JLabel jLabelName; 1228 private javax.swing.JLabel jLabelReadOnly; 1229 private javax.swing.JLabel jLabelType; 1230 private javax.swing.JLabel jLabelUriString; 1231 private javax.swing.JList jListColumns; 1232 private javax.swing.JPanel jPanel1; 1233 private javax.swing.JPanel jPanel2; 1234 private javax.swing.JPanel jPanel3; 1235 private javax.swing.JPanel jPanel4; 1236 private javax.swing.JPanel jPanel5; 1237 private javax.swing.JPanel jPanel6; 1238 private javax.swing.JPanel jPanel7; 1239 private javax.swing.JPanel jPanel8; 1240 private javax.swing.JPanel jPanelFields; 1241 private javax.swing.JPanel jPanelLocate; 1242 private javax.swing.JPanel jPanelLocateQuery; 1243 private javax.swing.JPanel jPanelQuery; 1244 private javax.swing.JPanel jPanelVisibleColumns; 1245 private javax.swing.JRadioButton jRadioButtonLocal; 1246 private javax.swing.JRadioButton jRadioButtonLocal1; 1247 private javax.swing.JRadioButton jRadioButtonRepo; 1248 private javax.swing.JRadioButton jRadioButtonRepo1; 1249 private javax.swing.JScrollPane jScrollPane1; 1250 private javax.swing.JScrollPane jScrollPane2; 1251 private javax.swing.JSeparator jSeparator1; 1252 private javax.swing.JSeparator jSeparator2; 1253 private javax.swing.JSeparator jSeparator4; 1254 private javax.swing.JTabbedPane jTabbedPane1; 1255 private javax.swing.JTabbedPane jTabbedPane2; 1256 private javax.swing.JTextField jTextFieldLabel; 1257 private javax.swing.JTextField jTextFieldName; 1258 private javax.swing.JTextField jTextFieldResource; 1259 private javax.swing.JTextField jTextFieldResource1; 1260 private javax.swing.JTextField jTextFieldUriString; 1261 private javax.swing.JTextField jTextFieldValueColumn; 1262 1264 1265 1266 1270 public void validate(ResourceDescriptor dataType) throws Exception 1271 { 1272 1273 } 1274 1275 public void updateResourceFromType() 1276 { 1277 jTextFieldResource.setEnabled( jRadioButtonRepo.isSelected() ); 1278 jButtonPickResource.setEnabled( jRadioButtonRepo.isSelected() ); 1279 1280 jButtonEditLocalResource.setEnabled( jRadioButtonLocal.isSelected() ); 1281 } 1282 1283 public void updateQueryResourceFromType() 1284 { 1285 jTextFieldResource1.setEnabled( jRadioButtonRepo1.isSelected() ); 1286 jButtonPickResource1.setEnabled( jRadioButtonRepo1.isSelected() ); 1287 1288 jButtonEditLocalResource1.setEnabled( jRadioButtonLocal1.isSelected() ); 1289 } 1290 1291 public String getReportUnitUri() { 1292 return reportUnitUri; 1293 } 1294 1295 public void setReportUnitUri(String reportUnitUri) { 1296 this.reportUnitUri = reportUnitUri; 1297 } 1298} 1299 | Popular Tags |