예제 #1
0
  /** Creates new form ValuesDialog */
  public StylesDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    applyI18n();
    this.setSize(490, 250);
    // DefaultTableColumnModel dtcm = (DefaultTableColumnModel)jTableParameters.getColumnModel();
    // DefaultTableCellRenderer tcr =
    // (DefaultTableCellRenderer)dtcm.getColumn(0).getHeaderRenderer();

    // new DefaultTableCellRenderer();
    // tcr.setFont(jTableParameters.getFont());
    // tcr.setBackground(this.getBackground());
    // tcr.setBorder( new javax.swing.border.BevelBorder( javax.swing.border.BevelBorder.RAISED));
    // dtcm.getColumn(0).setHeaderRenderer(tcr);

    DefaultListSelectionModel dlsm =
        (DefaultListSelectionModel) this.jTableParameters.getSelectionModel();
    dlsm.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            jTableParametersListSelectionValueChanged(e);
          }
        });

    // Open in center...
    it.businesslogic.ireport.util.Misc.centerFrame(this);

    DefaultTableModel dtm = (DefaultTableModel) jTableParameters.getModel();

    it.businesslogic.ireport.gui.MainFrame.getMainInstance()
        .getActiveReportFrame()
        .getReport()
        .addStyleChangedListener(this);
    Enumeration e =
        it.businesslogic.ireport.gui.MainFrame.getMainInstance()
            .getActiveReportFrame()
            .getReport()
            .getStyles()
            .elements();
    while (e.hasMoreElements()) {
      Style style = (Style) e.nextElement();
      addStyle(style);
    }

    DefaultTableColumnModel dtcm = (DefaultTableColumnModel) jTableParameters.getColumnModel();
    dtcm.getColumn(0).setPreferredWidth(350);
    dtcm.getColumn(1).setPreferredWidth(100);

    javax.swing.KeyStroke escape =
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
    javax.swing.Action escapeAction =
        new javax.swing.AbstractAction() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            setVisible(false);
          }
        };

    getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
  }
예제 #2
0
 /** Used to show the main window and bring the iReport window on top... */
 public boolean setVisible(boolean b) {
   MainFrame.getMainInstance().setVisible(b);
   if (MainFrame.getMainInstance().getState() == java.awt.Frame.ICONIFIED) {
     MainFrame.getMainInstance().setState(java.awt.Frame.NORMAL);
   }
   return MainFrame.getMainInstance().requestFocusInWindow();
 }
예제 #3
0
  private void jButtonDefaultActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonDefaultActionPerformed

    if (jTableParameters.getSelectedRow() < 0) return;
    Style irc = null;
    try {
      irc = (Style) jTableParameters.getModel().getValueAt(jTableParameters.getSelectedRow(), 0);
    } catch (Exception ex) {
      return;
    }

    if (irc == null) return;

    irc.getAttributes().put(irc.ATTRIBUTE_isDefault, "true");
    jTableParameters.setValueAt("Yes", jTableParameters.getSelectedRow(), 1);

    for (int i = 0; i < jTableParameters.getRowCount(); ++i) {
      if (i != jTableParameters.getSelectedRow()) {
        Style s = (Style) jTableParameters.getModel().getValueAt(i, 0);
        if (s != null) s.getAttributes().remove(s.ATTRIBUTE_isDefault);
        jTableParameters.setValueAt("", i, 1);
      }
    }

    MainFrame.getMainInstance()
        .getActiveReportFrame()
        .getReport()
        .fireStyleChangedListenerStyleChanged(
            new StyleChangedEvent(
                MainFrame.getMainInstance().getActiveReportFrame().getReport(),
                StyleChangedEvent.CHANGED,
                irc,
                irc));
  } // GEN-LAST:event_jButtonDefaultActionPerformed
예제 #4
0
  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());
  }
예제 #5
0
 /** Closes the dialog */
 private void closeDialog(java.awt.event.WindowEvent evt) { // GEN-FIRST:event_closeDialog
   it.businesslogic.ireport.gui.MainFrame.getMainInstance()
       .getActiveReportFrame()
       .getReport()
       .removeStyleChangedListener(this);
   setVisible(false);
 } // GEN-LAST:event_closeDialog
예제 #6
0
  private void jButtonModifyActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonModifyActionPerformed

    if (jList1.getSelectedIndex() >= 0) {
      CategorySeries cs = (CategorySeries) jList1.getSelectedValue();
      CategorySeriesDialog csd =
          new CategorySeriesDialog(it.businesslogic.ireport.gui.MainFrame.getMainInstance(), true);

      csd.setSeriesExpression(cs.getSeriesExpression());
      csd.setCategoryExpression(cs.getCategoryExpression());
      csd.setValueExpression(cs.getValueExpression());
      csd.setLabelExpression(cs.getLabelExpression());
      csd.setSectionItemHyperlink(cs.getSectionItemHyperlink());
      csd.setSubDataset(this.getSubDataset());
      if (newInfo != null) {
        csd.setFocusedExpression(newInfo);
      }
      csd.setVisible(true);

      if (csd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
        cs.setSeriesExpression(csd.getSeriesExpression());
        cs.setCategoryExpression(csd.getCategoryExpression());
        cs.setValueExpression(csd.getValueExpression());
        cs.setLabelExpression(csd.getLabelExpression());
        cs.setSectionItemHyperlink(csd.getSectionItemHyperlink());

        jList1.updateUI();
      }
    }
  } // GEN-LAST:event_jButtonModifyActionPerformed
예제 #7
0
  private void jButtonDeleteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonDeleteActionPerformed
    // Get the selected connection...
    if (jTableParameters.getSelectedRowCount() > 0) {
      Style irc = null;
      try {
        irc = (Style) jTableParameters.getModel().getValueAt(jTableParameters.getSelectedRow(), 0);
      } catch (Exception ex) {
        return;
      }

      if (javax.swing.JOptionPane.showConfirmDialog(
              this,
              I18n.getString(
                  "messages.stylesDialog.removingStyle", "Do you want really remove this style?"),
              "",
              javax.swing.JOptionPane.YES_NO_CANCEL_OPTION,
              javax.swing.JOptionPane.QUESTION_MESSAGE)
          == javax.swing.JOptionPane.YES_OPTION) {
        MainFrame.getMainInstance().getActiveReportFrame().getReport().removeStyle(irc);

        ((DefaultTableModel) jTableParameters.getModel())
            .removeRow(jTableParameters.getSelectedRow());
        jTableParameters.updateUI();
      }
    }
  } // GEN-LAST:event_jButtonDeleteActionPerformed
예제 #8
0
  private void jButtonQueryActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonQueryActionPerformed

    ReportQueryDialog rqd = new ReportQueryDialog(MainFrame.getMainInstance(), true);
    rqd.setSubDataset(this.getSubDataset());
    rqd.setVisible(true);
    jRTextExpressionAreaFilterExpression.setText(rqd.getSubDataset().getFilterExpression());
  } // GEN-LAST:event_jButtonQueryActionPerformed
예제 #9
0
  private void jList1MouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jList1MouseClicked

    if (evt.getClickCount() == 1 && evt.getButton() == evt.BUTTON3) {
      jMenuItemCopy.setEnabled(jList1.getSelectedIndex() >= 0);
      jMenuItemPaste.setEnabled(
          it.businesslogic.ireport.gui.MainFrame.getMainInstance().getChartSeriesClipBoard() != null
              && it.businesslogic.ireport.gui.MainFrame.getMainInstance()
                      .getChartSeriesClipBoard()
                      .size()
                  > 0);

      jPopupMenuCategorySeries.show(jList1, evt.getPoint().x, evt.getPoint().y);
    } else if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1) {
      jButtonModifyActionPerformed(null);
    }
  } // GEN-LAST:event_jList1MouseClicked
예제 #10
0
  private void jMenuItemCopyActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemCopyActionPerformed

    Object[] values = jList1.getSelectedValues();
    Vector copy_c = new Vector();
    for (int i = 0; i < values.length; ++i) copy_c.add(((CategorySeries) values[i]).cloneMe());
    it.businesslogic.ireport.gui.MainFrame.getMainInstance().setChartSeriesClipBoard(copy_c);
  } // GEN-LAST:event_jMenuItemCopyActionPerformed
예제 #11
0
  public void queryChanged(String newQuery) {

    lastExecution++;
    int thisExecution = lastExecution;
    // Execute a thread to perform the query change...

    String error_msg = "";
    lastExecution++;

    int in = lastExecution;

    if (getReportQueryDialog() == null) return;

    getReportQueryDialog().getJLabelStatusSQL().setText("Executing HQL query....");
    /////////////////////////////

    try {
      Thread.currentThread()
          .setContextClassLoader(MainFrame.getMainInstance().getReportClassLoader());
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    if (in < lastExecution) return; // Abort, new execution requested

    HQLFieldsReader hqlFR =
        new HQLFieldsReader(newQuery, getReportQueryDialog().getSubDataset().getParameters());

    if (in < lastExecution) return; // Abort, new execution requested

    try {
      Vector fields = hqlFR.readFields();

      List columns = new ArrayList();
      for (int i = 0; i < fields.size(); ++i) {
        JRField field = (JRField) fields.elementAt(i);
        columns.add(new Object[] {field, field.getClassType(), field.getDescription()});
      }

      Vector v = hqlFR.getNotScalars();

      if (v.size() == 0) v = null;

      if (in < lastExecution) return; // Abort, new execution requested
      setBeanExplorerFromWorker(v, true, true);

      if (in < lastExecution) return; // Abort, new execution requested
      setColumnsFromWorker(columns);

    } catch (Exception ex) {
      ex.printStackTrace();
      setBeanExplorerFromWorker(null, true, true);
      setColumnErrorFromWork("Error: " + ex.getMessage());
    }

    getReportQueryDialog().getJLabelStatusSQL().setText("Ready");
  }
예제 #12
0
 /** Creates a new instance of ReportElementSheetPanel */
 public ReportObjectSheetPanel() {
   super();
   this.setBackground(Color.BLUE);
   initSheetProperties();
   // We have to register for element changes...
   MainFrame mf = MainFrame.getMainInstance();
   mf.addReportListener(this);
   mf.addReportFrameActivatedListener(this);
   I18n.addOnLanguageChangedListener(this);
 }
예제 #13
0
 /** Open the file passed as parameter... */
 public boolean openFile(String file) {
   setVisible(true);
   try {
     JReportFrame jrf = MainFrame.getMainInstance().openFile(file);
     jrf.setSelected(true);
     return true;
   } catch (Exception ex) {
     return false;
   }
 }
예제 #14
0
  private void jButton2ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed

    // Get all selected paths...
    if (MainFrame.getMainInstance().getActiveReportFrame() == null || getJTableFields() == null) {
      return;
    }

    DefaultTableModel dtm = (DefaultTableModel) getJTableFields().getModel();

    TreePath[] paths = jTree1.getSelectionPaths();
    if (paths == null) return;
    for (int i = 0; i < paths.length; ++i) {
      boolean valid = true;
      TreePath tp = paths[i];

      TreeJRField tjrf =
          (TreeJRField) ((DefaultMutableTreeNode) tp.getLastPathComponent()).getUserObject();
      String returnType = Misc.getJRFieldType(tjrf.getObj().getName());
      it.businesslogic.ireport.JRField field =
          new it.businesslogic.ireport.JRField(tjrf.getField().getName(), returnType);
      field.setDescription(tjrf.getField().getDescription());
      Vector row = new Vector();
      row.addElement(field);
      row.addElement(field.getClassType());
      row.addElement(field.getDescription());

      if (isComboVisible() && jComboBox1.getSelectedItem() instanceof FieldClassWrapper) {
        FieldClassWrapper cw = (FieldClassWrapper) jComboBox1.getSelectedItem();
        field.setName(cw.getFieldName() + "." + field.getDescription());
        field.setDescription(field.getName());
      }

      // Check for duplicates fields...
      boolean found = fieldAlreadyExists(field);
      String baseName = field.getName();
      for (int j = 1; isPathOnDescription() && found; ++j) {
        field.setName(baseName + "_" + j);
        found = fieldAlreadyExists(field);
      }

      if (!found) {
        dtm.addRow(row);
        getJTableFields()
            .getSelectionModel()
            .addSelectionInterval(
                getJTableFields().getRowCount() - 1, getJTableFields().getRowCount() - 1);
      }
    }
  } // GEN-LAST:event_jButton2ActionPerformed
예제 #15
0
  private void jMenuItemPasteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemPasteActionPerformed

    Vector v = it.businesslogic.ireport.gui.MainFrame.getMainInstance().getChartSeriesClipBoard();

    if (v != null && v.size() > 0) {
      for (int i = 0; i < v.size(); ++i) {
        if (v.elementAt(i) instanceof CategorySeries) {
          CategorySeries cs = (CategorySeries) v.elementAt(i);
          cs = cs.cloneMe();
          categoryDataset.getCategorySeries().addElement(cs);
          ((javax.swing.DefaultListModel) jList1.getModel()).addElement(cs);
        }
      }
    }
  } // GEN-LAST:event_jMenuItemPasteActionPerformed
예제 #16
0
  private void jButtonAddActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonAddActionPerformed

    CategorySeriesDialog csd =
        new CategorySeriesDialog(it.businesslogic.ireport.gui.MainFrame.getMainInstance(), true);
    csd.setSubDataset(this.getSubDataset());
    csd.setVisible(true);
    if (csd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
      CategorySeries cs = new CategorySeries();
      cs.setSeriesExpression(csd.getSeriesExpression());
      cs.setCategoryExpression(csd.getCategoryExpression());
      cs.setValueExpression(csd.getValueExpression());
      cs.setLabelExpression(csd.getLabelExpression());
      cs.setSectionItemHyperlink(csd.getSectionItemHyperlink());

      categoryDataset.getCategorySeries().addElement(cs);
      ((javax.swing.DefaultListModel) jList1.getModel()).addElement(cs);
    }
  } // GEN-LAST:event_jButtonAddActionPerformed
예제 #17
0
  public boolean runWizard(String destFile) {
    MainFrame mainFrame = MainFrame.getMainInstance();

    if (mainFrame == null) return false;

    mainFrame.logOnConsole("Invocato wizard");
    mainFrame.logOnConsole(
        "Pronto ad invocare la nuova finestra..." + Thread.currentThread().getName());

    try {
      // TODO
      // Set the project directory as current directory;

      WizardDialog wd = new WizardDialog(mainFrame, true);

      mainFrame.logOnConsole("Lancio wizard");
      wd.setVisible(true);
      wd.requestFocus();

      Report report = null;
      if (wd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
        report = wd.getReport();
        if (report == null) {
          report = createBlankReport();
        }
      } else {
        report = createBlankReport();
      }

      if (report != null) {
        mainFrame.openNewReportWindow(report);
        report.setFilename(destFile);
        report.saveXMLFile();
        setVisible(true);
      }

    } catch (Exception ex) {
      System.out.println(ex.getMessage());
      ex.printStackTrace();
    }

    return true;
  }
예제 #18
0
  public void run() {
    // set the security manager
    try {
      int port = 2100;
      try {
        port =
            Integer.parseInt(
                MainFrame.getMainInstance().getProperties().getProperty("RMIServerPort", "2100"));
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      Registry reg = LocateRegistry.createRegistry(port);

      // put the local instance in the registry
      // Naming.rebind("iReportServer" , Server);
      reg.bind("iReportServer", this);
      System.out.println("RMI iReportServer waiting on port " + port + ".....");
    } catch (java.rmi.AlreadyBoundException abe) {
      System.out.println("Service already bound! Is another iReport instance running?");
    } catch (RemoteException re) {
      System.out.println("Remote exception: " + re.toString());
    }
  }
예제 #19
0
 public void updateSelection() {
   JReportFrame newJrf = MainFrame.getMainInstance().getActiveReportFrame();
   updateSelection(newJrf);
 }
예제 #20
0
  public void reportFrameActivated(ReportFrameActivatedEvent evt) {

    if (MainFrame.getMainInstance().getActiveReportFrame() == this.getJrf()) return;
    updateSelection(MainFrame.getMainInstance().getActiveReportFrame());
  }
예제 #21
0
  public void run() {
    try {
      // Thread.currentThread().setContextClassLoader(it.businesslogic.ireport.gui.MainFrame.getMainInstance().getReportClassLoader() );

      java.util.Properties props =
          it.businesslogic.ireport.gui.MainFrame.getMainInstance().getProperties();

      if (props.getProperty("update.useProxy", "false").equals("true")) {
        System.getProperties().put("proxySet", "true");

        String urlProxy = props.getProperty("update.proxyUrl", "");
        String port = "8080";
        String server = urlProxy;
        if (urlProxy.indexOf(":") > 0) {
          port = urlProxy.substring(urlProxy.indexOf(":") + 1);
          server = urlProxy.substring(0, urlProxy.indexOf(":"));
        }

        System.getProperties().put("proxyHost", server);
        System.getProperties().put("proxyPort", port);

        MainFrame.getMainInstance().logOnConsole("Using proxy: " + urlProxy);
      }

      java.net.URL url = new java.net.URL("http://ireport.sf.net/lastversion.php");

      byte[] webBuffer = new byte[100];
      URLConnection uConn = url.openConnection();

      if (props.getProperty("update.useProxy", "false").equals("true")
          && props.getProperty("update.useAuth", "false").equals("true")) {
        String password =
            props.getProperty("update.username", "")
                + ":"
                + props.getProperty("update.password", "");

        org.w3c.tools.codec.Base64Encoder b = new org.w3c.tools.codec.Base64Encoder(password);
        String encodedPassword = b.processString();
        uConn.setRequestProperty("Proxy-Authorization", encodedPassword);
      }

      // uConn.setReadTimeout(1000);
      java.io.InputStream is = uConn.getInputStream();
      int readed = is.read(webBuffer);
      String version = new String(webBuffer, 0, readed);
      if (version.toLowerCase().startsWith("ireport")) {
        if (version.compareTo(it.businesslogic.ireport.gui.MainFrame.constTitle) > 0) {

          final String fversion = version;
          javax.swing.SwingUtilities.invokeLater(
              new Runnable() {
                public void run() {
                  javax.swing.JOptionPane.showMessageDialog(
                      it.businesslogic.ireport.gui.MainFrame.getMainInstance(),
                      I18n.getFormattedString(
                          "messages.upgradeSearch.newVersion",
                          "{0} is available on http://ireport.sf.net!",
                          new Object[] {fversion}));
                }
              });
        }
      }
    } catch (Throwable ex) {
      ex.printStackTrace();
    }

    if (win != null) win.setVisible(false);
  }
예제 #22
0
  /** Creates new form ModifyTemplate */
  public ModifyTemplate(java.awt.Component parent, boolean modal, String tname, TemplatesPanel tp) {
    super(MainFrame.getMainInstance(), modal);
    fatherFrame = (JDialog) parent;
    tpp = tp;
    mName = tname;
    initComponents();
    jButton4.setEnabled(false);
    jComboBox1.setEnabled(false);
    ItemListener itemListener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Object obj = e.getItem();

            if (obj.equals(jCheckBox3)) {
              if (jCheckBox3.isSelected()) {
                jCheckBox1.setSelected(false);
                jCheckBox2.setSelected(false);
                jComboBox1.setEnabled(false);
                jTextField5.setEnabled(false);
                jButton4.setEnabled(false);
                jPanel7.setBackground(new Color(204, 204, 204));
                jTextField5.setBackground(new Color(204, 204, 204));
              }
            } else if (obj.equals(jCheckBox1)) {
              if (jCheckBox1.isSelected()) {
                jCheckBox2.setSelected(false);
                jCheckBox3.setSelected(false);
                jTextField5.setEnabled(false);
                jButton4.setEnabled(false);
                jComboBox1.setEnabled(true);
                jPanel7.setBackground(new Color(244, 244, 244));
                jTextField5.setBackground(new Color(204, 204, 204));
              }
            } else if (obj.equals(jCheckBox2)) {
              if (jCheckBox2.isSelected()) {
                jCheckBox1.setSelected(false);
                jCheckBox3.setSelected(false);
                jComboBox1.setEnabled(false);
                jTextField5.setEnabled(true);
                jButton4.setEnabled(true);
                jPanel7.setBackground(new Color(244, 244, 244));
                jTextField5.setBackground(Color.WHITE);
              }
            }
          }
        };

    jCheckBox1.addItemListener(itemListener);
    jCheckBox2.addItemListener(itemListener);
    jCheckBox3.addItemListener(itemListener);

    jCheckBox1.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            JCheckBox jc = (JCheckBox) e.getSource();
            if (!jc.isSelected()) {
              jc.setSelected(true);
              return;
            }
          }
        });
    jCheckBox2.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            JCheckBox jc = (JCheckBox) e.getSource();
            if (!jc.isSelected()) {
              jc.setSelected(true);
              return;
            }
          }
        });
    jCheckBox3.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            JCheckBox jc = (JCheckBox) e.getSource();
            if (!jc.isSelected()) {
              jc.setSelected(true);
              return;
            }
          }
        });
  }
예제 #23
0
  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