void printButton_actionPerformed(ActionEvent e) {
    if (controlFromDate.getValue() == null || controlToDate.getValue() == null) {
      JOptionPane.showMessageDialog(
          ClientUtils.getParentFrame(this),
          ClientSettings.getInstance().getResources().getResource("please set a from/to date"),
          ClientSettings.getInstance().getResources().getResource("Attention"),
          JOptionPane.WARNING_MESSAGE);
      return;
    }
    if (controlCompaniesCombo.getValue() == null) {
      JOptionPane.showMessageDialog(
          ClientUtils.getParentFrame(this),
          ClientSettings.getInstance().getResources().getResource("please select a company"),
          ClientSettings.getInstance().getResources().getResource("Attention"),
          JOptionPane.WARNING_MESSAGE);
      return;
    }

    HashMap params = new HashMap();
    params.put("COMPANY_CODE", controlCompaniesCombo.getValue());
    params.put("START_DATE", controlFromDate.getValue());
    params.put("END_DATE", controlToDate.getValue());
    if (controlFromItemNr.getValue() != null)
      params.put(
          "FROM_PROGRESSIVE",
          " and ACC05_JOURNAL_HEADER.PROGRESSIVE>=" + controlFromItemNr.getValue());
    else params.remove("FROM_PROGRESSIVE");

    HashMap map = new HashMap();
    map.put(ApplicationConsts.COMPANY_CODE_SYS01, controlCompaniesCombo.getValue());
    map.put(ApplicationConsts.FUNCTION_CODE_SYS06, "ACC05");
    map.put(ApplicationConsts.EXPORT_PARAMS, params);
    Response res = ClientUtils.getData("getJasperReport", map);
    if (!res.isError()) {
      JasperPrint print = (JasperPrint) ((VOResponse) res).getVo();
      JRViewer viewer = new JRViewer(print);
      JFrame frame = new JFrame();
      frame.setSize(MDIFrame.getInstance().getSize());
      frame.setContentPane(viewer);
      frame.setTitle(this.getTitle());
      frame.setIconImage(MDIFrame.getInstance().getIconImage());
      frame.setVisible(true);
    } else
      JOptionPane.showMessageDialog(
          ClientUtils.getParentFrame(this),
          res.getErrorMessage(),
          ClientSettings.getInstance().getResources().getResource("print journal"),
          JOptionPane.ERROR_MESSAGE);
  }
  private void jbInit() throws Exception {
    printButton.setToolTipText(
        ClientSettings.getInstance().getResources().getResource("print journal"));
    printButton.addActionListener(new JournalFilterFrame_printButton_actionAdapter(this));
    controlCompaniesCombo.setAttributeName("companyCodeSys01WAR01");

    this.setTitle(ClientSettings.getInstance().getResources().getResource("print journal"));
    buttonsPanel.setBorder(BorderFactory.createEtchedBorder());
    mainPanel.setLayout(gridBagLayout1);
    labelFromDate.setText("from date");
    labelToDate.setText("to date");
    labelFromItemNr.setText("from item number");
    labelCompanyCode.setText("companyCodeSys01WAR01");
    this.getContentPane().add(mainPanel, BorderLayout.CENTER);
    this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
    buttonsPanel.add(printButton, null);
    mainPanel.add(
        labelCompanyCode,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        labelFromDate,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        labelToDate,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        labelFromItemNr,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        controlCompaniesCombo,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        controlFromDate,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        controlToDate,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    mainPanel.add(
        controlFromItemNr,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    Calendar cal = Calendar.getInstance();
    cal.set(cal.DAY_OF_MONTH, 1);
    cal.set(cal.MONTH, 0);
    controlFromDate.setValue(cal.getTime());
    controlToDate.setValue(new Date());
  }
Exemplo n.º 3
0
  /** Load data from server and construct panel content. */
  public final void reloadData(DocumentsFrame frame) {
    try {
      // remove all panel content...
      clearData();
      frame.getGrid().getOtherGridParams().put(ApplicationConsts.PROPERTIES_FILTER, filters);

      // retrieve customized input controls list...
      GridParams gridParams = new GridParams();
      DefaultMutableTreeNode node = frame.getHierarTreePanel().getSelectedNode();
      if (node != null) {
        HierarchyLevelVO vo = (HierarchyLevelVO) node.getUserObject();
        HierarchyLevelVO root =
            (HierarchyLevelVO) ((DefaultMutableTreeNode) node.getRoot()).getUserObject();
        gridParams
            .getOtherGridParams()
            .put(ApplicationConsts.PROGRESSIVE_HIE01, vo.getProgressiveHIE01());
        gridParams
            .getOtherGridParams()
            .put(ApplicationConsts.ROOT_PROGRESSIVE_HIE01, root.getProgressiveHIE01());
      } else gridParams.getOtherGridParams().remove(ApplicationConsts.PROGRESSIVE_HIE01);
      gridParams
          .getOtherGridParams()
          .put(
              ApplicationConsts.PROGRESSIVE_HIE02,
              frame.getHierarTreePanel().getProgressiveHIE02());
      gridParams.getOtherGridParams().put(ApplicationConsts.LOAD_ANCIENTS, Boolean.TRUE);
      Response res = ClientUtils.getData("loadLevelProperties", gridParams);
      if (res.isError()) {
        JOptionPane.showMessageDialog(
            ClientUtils.getParentFrame(this),
            ClientSettings.getInstance().getResources().getResource("Error while loading data")
                + ":\n"
                + res.getErrorMessage(),
            ClientSettings.getInstance().getResources().getResource("Loading Data Error"),
            JOptionPane.ERROR_MESSAGE);
        return;
      }
      ArrayList rows = ((VOListResponse) res).getRows();
      if (rows.size() > 0) {
        // adding customized input controls...
        LevelPropertyVO inputControlInfo = null;
        int row = 0;
        int col = 0;
        LabelControl labelControl = null;
        TextControl textControl = null;
        DateControl dateControl = null;
        NumericControl numericControl = null;
        for (int i = 0; i < rows.size(); i++) {
          inputControlInfo = (LevelPropertyVO) rows.get(i);
          labelControl = new LabelControl();
          labelControl.setText(inputControlInfo.getDescriptionSYS10());
          innerPanel.add(
              labelControl,
              new GridBagConstraints(
                  col++,
                  row,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.WEST,
                  GridBagConstraints.NONE,
                  new Insets(5, 5, 5, 5),
                  0,
                  0));

          if (inputControlInfo.getPropertyTypeDOC21().equals(ApplicationConsts.TYPE_TEXT)) {
            textControl = new TextControl();
            textControl.setMaxCharacters(255);
            textControl.setLinkLabel(labelControl);
            innerPanel.add(
                textControl,
                new GridBagConstraints(
                    col,
                    row,
                    1,
                    1,
                    1.0,
                    0.0,
                    GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL,
                    new Insets(5, 5, 5, 15),
                    0,
                    0));
            textControl.addFocusListener(new ControlFocusListener(inputControlInfo, textControl));
          } else if (inputControlInfo.getPropertyTypeDOC21().equals(ApplicationConsts.TYPE_DATE)) {
            dateControl = new DateControl();
            dateControl.setLinkLabel(labelControl);
            innerPanel.add(
                dateControl,
                new GridBagConstraints(
                    col,
                    row,
                    1,
                    1,
                    1.0,
                    0.0,
                    GridBagConstraints.WEST,
                    GridBagConstraints.NONE,
                    new Insets(5, 5, 5, 15),
                    0,
                    0));
            dateControl.addFocusListener(new ControlFocusListener(inputControlInfo, dateControl));
          } else if (inputControlInfo.getPropertyTypeDOC21().equals(ApplicationConsts.TYPE_NUM)) {
            numericControl = new NumericControl();
            numericControl.setDecimals(5);
            numericControl.setLinkLabel(labelControl);
            innerPanel.add(
                numericControl,
                new GridBagConstraints(
                    col,
                    row,
                    1,
                    1,
                    1.0,
                    0.0,
                    GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL,
                    new Insets(5, 5, 5, 15),
                    0,
                    0));
            numericControl.addFocusListener(
                new ControlFocusListener(inputControlInfo, numericControl));
          }

          col++;
          if (col >= 2) {
            innerPanel.add(
                new JPanel(),
                new GridBagConstraints(
                    col,
                    row,
                    1,
                    1,
                    1.0,
                    0.0,
                    GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL,
                    new Insets(5, 5, 5, 5),
                    0,
                    0));
            row++;
            col = 0;
          }
        }
        row++;
        innerPanel.add(
            new JPanel(),
            new GridBagConstraints(
                col,
                row,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.WEST,
                GridBagConstraints.NONE,
                new Insets(5, 5, 5, 5),
                0,
                0));

        innerPanel.add(
            new JPanel(),
            new GridBagConstraints(
                0,
                row,
                1,
                1,
                0.0,
                1.0,
                GridBagConstraints.WEST,
                GridBagConstraints.VERTICAL,
                new Insets(5, 5, 5, 5),
                0,
                0));
        this.revalidate();
        this.repaint();
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
  private void jbInit() throws Exception {
    controlDofRef.setAttributeName("docRefNumberDOC01");
    titledBorder1 = new TitledBorder("");
    titledBorder2 = new TitledBorder("");
    labelDocNum.setText("docNumber");
    titledBorder1.setTitle(
        ClientSettings.getInstance().getResources().getResource("document identification"));
    titledBorder1.setTitleColor(Color.blue);
    this.setBorder(titledBorder1);
    this.setLayout(gridBagLayout1);
    labelDocYear.setText("docYear");
    labelDocRif.setText("docRif");
    controlDocRifLookup.setCanCopy(true);
    controlDocRifLookup.setAllowOnlyNumbers(true);
    controlDocRifLookup.setLinkLabel(labelDocRif);
    controlDocRifLookup.setMaxCharacters(20);
    controlDocRifLookup.setEnabledOnEdit(false);
    controlDocRifLookup.setAttributeName("docSequenceDoc01DOC01");
    labelDocDate.setText("docDate");
    labelDocState.setText("docState");

    ClientApplet applet =
        ((ApplicationClientFacade) MDIFrame.getInstance().getClientFacade()).getMainClass();
    ApplicationParametersVO appVO = applet.getAuthorizations();
    if (!appVO.getManualDocNumInSaleDocs().booleanValue()) {
      controlDocNumber.setEnabledOnInsert(false);
      controlDocNumber.setEnabledOnEdit(false);
    }

    controlDocNumber.setLinkLabel(labelDocNum);
    controlDocNumber.setMaxCharacters(255);
    controlDocNumber.setRequired(false);
    controlDocNumber.setAttributeName("docSequenceDOC01");
    controlDocYear.setLinkLabel(labelDocYear);
    controlDocYear.setEnabledOnInsert(false);
    controlDocYear.setEnabledOnEdit(false);
    controlDocYear.setAttributeName("docYearDOC01");
    controlDocTypeRef.setCanCopy(true);
    controlDocTypeRef.setAttributeName("docTypeDoc01DOC01");
    controlDocTypeRef.setLinkLabel(labelDocRif);
    controlDocTypeRef.setEnabledOnInsert(true);
    controlDocTypeRef.setEnabledOnEdit(false);
    controlDocTypeRef.setDomainId("SALE_DOC_TYPE");
    controlDocYearRef.setEnabledOnInsert(false);
    controlDocYearRef.setEnabledOnEdit(false);
    controlDocYearRef.setAttributeName("docYearDoc01DOC01");
    controlDocDate.setCanCopy(true);
    controlDocDate.setLinkLabel(labelDocDate);
    controlDocDate.setRequired(true);
    controlDocDate.setEnabledOnEdit(false);
    controlDocDate.setAttributeName("docDateDOC01");
    controlDocState.setCanCopy(false);
    controlDocState.setLinkLabel(labelDocDate);
    controlDocState.setRequired(true);
    controlDocState.setEnabledOnInsert(false);
    controlDocState.setEnabledOnEdit(false);
    controlDocState.setAttributeName("docStateDOC01");
    controlDocState.setDomainId("DOC01_STATES");
    labelDocRefNr.setText("docRef");
    controlSectional.setAttributeName("sectionalDOC01");
    controlSectional.setEnabledOnInsert(false);
    controlSectional.setEnabledOnEdit(false);
    controlSectional.setTextAlignment(SwingConstants.RIGHT);
    this.add(
        labelDocNum,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    this.add(
        controlDocNumber,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 0, 5, 5),
            0,
            0));

    if (showDocRefLookup) {
      this.add(
          labelDocRif,
          new GridBagConstraints(
              0,
              1,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.WEST,
              GridBagConstraints.NONE,
              new Insets(5, 5, 5, 5),
              0,
              0));
      this.add(
          controlDocTypeRef,
          new GridBagConstraints(
              1,
              1,
              2,
              1,
              0.0,
              0.0,
              GridBagConstraints.WEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(5, 0, 5, 5),
              0,
              0));
      this.add(
          controlDocRifLookup,
          new GridBagConstraints(
              3,
              1,
              2,
              1,
              0.0,
              0.0,
              GridBagConstraints.WEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(5, 0, 5, 5),
              0,
              0));
      this.add(
          controlDocYearRef,
          new GridBagConstraints(
              5,
              1,
              3,
              1,
              1.0,
              0.0,
              GridBagConstraints.WEST,
              GridBagConstraints.NONE,
              new Insets(5, 0, 5, 5),
              40,
              0));
      this.add(
          new JPanel(),
          new GridBagConstraints(
              9,
              0,
              1,
              1,
              1.0,
              0.0,
              GridBagConstraints.WEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(0, 0, 0, 0),
              0,
              0));
    } else {
      this.add(
          labelDocRefNr,
          new GridBagConstraints(
              0,
              1,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.WEST,
              GridBagConstraints.NONE,
              new Insets(5, 5, 5, 5),
              0,
              0));
      this.add(
          controlDofRef,
          new GridBagConstraints(
              1,
              1,
              2,
              1,
              0.0,
              0.0,
              GridBagConstraints.WEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(5, 0, 5, 5),
              0,
              0));
    }

    this.add(
        controlDocYear,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 0, 5, 5),
            0,
            0));
    this.add(
        labelDocYear,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));

    this.add(
        labelDocDate,
        new GridBagConstraints(
            5,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    this.add(
        controlDocDate,
        new GridBagConstraints(
            6,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            60,
            0));
    this.add(
        labelDocState,
        new GridBagConstraints(
            7,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    this.add(
        controlDocState,
        new GridBagConstraints(
            8,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    if (showSectional)
      this.add(
          controlSectional,
          new GridBagConstraints(
              1,
              0,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.CENTER,
              GridBagConstraints.NONE,
              new Insets(0, 0, 0, 0),
              0,
              0));
  }