public void afterInit() { // this.setSize(620, 320); this.pack(); // Open in center... it.businesslogic.ireport.util.Misc.centerFrame(this); this.jComboBoxWhenResourceMissingType.addItem( new Tag( "Null", it.businesslogic.ireport.util.I18n.getString("whenResourceMissingType.Null", "Null"))); this.jComboBoxWhenResourceMissingType.addItem( new Tag( "Empty", it.businesslogic.ireport.util.I18n.getString( "whenResourceMissingType.Empty", "Empty"))); this.jComboBoxWhenResourceMissingType.addItem( new Tag( "Key", it.businesslogic.ireport.util.I18n.getString("whenResourceMissingType.Key", "Key"))); this.jComboBoxWhenResourceMissingType.addItem( new Tag( "Error", it.businesslogic.ireport.util.I18n.getString( "whenResourceMissingType.Error", "Error"))); applyI18n(); it.businesslogic.ireport.util.Misc.setComboboxSelectedTagValue( jComboBoxWhenResourceMissingType, "Null"); boolean found = true; for (int i = 1; found; ++i) { found = false; Enumeration e = it.businesslogic.ireport.gui.MainFrame.getMainInstance() .getActiveReportFrame() .getReport() .getSubDatasets() .elements(); while (e.hasMoreElements() && !found) { SubDataset dataset = (SubDataset) e.nextElement(); if (dataset.getName().equals("SubDataset" + i)) { found = true; } } if (!found) { jTextFieldName.setText("SubDataset" + i); } } jTextFieldResourceBoundle.setText( it.businesslogic.ireport.gui.MainFrame.getMainInstance() .getActiveReportFrame() .getReport() .getResourceBundleBaseName()); }
public void setSubDataset(SubDataset subDataset) { this.subDataset = subDataset; this.jTextFieldName.setText(subDataset.getName()); this.jTextFieldScriptletClass.setText(subDataset.getScriptletClass()); this.jTextFieldResourceBoundle.setText(subDataset.getResourceBundleBaseName()); this.jRTextExpressionAreaFilterExpression.setText(subDataset.getFilterExpression()); if (subDataset != null) { jRTextExpressionAreaFilterExpression.setSubDataset(subDataset); } Misc.setComboboxSelectedTagValue( jComboBoxWhenResourceMissingType, subDataset.getWhenResourceMissingType()); jButtonFields.setEnabled(true); jButtonVariables.setEnabled(true); jButtonParameters.setEnabled(true); jButtonQuery.setEnabled(true); jButtonGroups.setEnabled(true); jButtonProperties.setEnabled(true); this.jButtonOk.setText(I18n.getString("subDatasetDialog.buttonOk", "Ok")); }
private void jButtonOkActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonOkActionPerformed if (this.jTextFieldName.getText().trim().length() <= 0) { javax.swing.JOptionPane.showMessageDialog( this, I18n.getString( "messages.subDatasetDialog.notValidName", "Please insert a valid SubDataset name!"), I18n.getString("messages.subDatasetDialog.notValidNameCaption", "Invalid name!"), javax.swing.JOptionPane.WARNING_MESSAGE); return; } String newName = this.jTextFieldName.getText().trim(); // check for duplicate name.... Enumeration e = it.businesslogic.ireport.gui.MainFrame.getMainInstance() .getActiveReportFrame() .getReport() .getSubDatasets() .elements(); while (e.hasMoreElements()) { SubDataset dataset = (SubDataset) e.nextElement(); if (dataset.getName().equals(newName) && dataset != getSubDataset()) { javax.swing.JOptionPane.showMessageDialog( this, I18n.getFormattedString( "messages.subDatasetDialog.nameAlreadyInUse", "The name \"{0}\" is already in use!\nPlease change it.", new Object[] {newName}), I18n.getString("messages.subDatasetDialog.notValidNameCaption", "Invalid name!"), javax.swing.JOptionPane.WARNING_MESSAGE); return; } } if (getSubDataset() == null) { this.subDataset = new SubDataset(); } SubDataset subdataset = getSubDataset(); subdataset.setName(jTextFieldName.getText()); subdataset.setScriptletClass(jTextFieldScriptletClass.getText()); subdataset.setResourceBundleBaseName(jTextFieldResourceBoundle.getText()); subdataset.setFilterExpression(jRTextExpressionAreaFilterExpression.getText()); if (jComboBoxWhenResourceMissingType.getSelectedItem() != null) { Tag val = (Tag) jComboBoxWhenResourceMissingType.getSelectedItem(); subdataset.setWhenResourceMissingType(val.getValue() + ""); } if (this.jButtonOk .getText() .equals(I18n.getString("subDatasetDialog.buttonCreate", "Create"))) { if (this.getParent() instanceof SubDatasetsDialog) { ((SubDatasetsDialog) this.getParent()).addSubDataset(this.getSubDataset()); } this.setSubDataset(subdataset); MainFrame.getMainInstance().getActiveReportFrame().getReport().addSubDataset(subdataset); return; } else { MainFrame.getMainInstance() .getActiveReportFrame() .getReport() .fireReportSubDatasetChangedListenerReportSubDatasetChanged( new ReportSubDatasetChangedEvent( MainFrame.getMainInstance().getActiveReportFrame().getReport(), getSubDataset(), ReportSubDatasetChangedEvent.CHANGED, ReportSubDatasetChangedEvent.OBJECT_SUBDATASET)); } MainFrame.getMainInstance().getActiveReportFrame().getReport().incrementReportChanges(); this.setDialogResult(javax.swing.JOptionPane.OK_OPTION); setVisible(false); dispose(); } // GEN-LAST:event_jButtonOkActionPerformed