public boolean checkFields() throws FieldValueException {
    FieldsChecking.checkAllRequiredFields(this);

    Date validFrom = validFromField.getDate();

    Date validTo = validToField.getDateAcceptEmpty();
    if (validTo != null) {
      if (validFrom.after(validTo)) {
        throw new FieldValueException(
            "<USER>'Valid From' should not be later than 'Valid To'</USER>");
      }
    }

    FacilityValue seaport = (FacilityValue) seaportCombo.getSelectedItem();

    Seaport2FixpointValue seaport2Fixpoint = (Seaport2FixpointValue) getModel();
    seaport2Fixpoint.setSeaportId(seaport.getId().longValue());
    seaport2Fixpoint.setValidityStart(validFrom);
    seaport2Fixpoint.setValidityEnd(validTo);

    Object selectedFixpoint = fixpointCombo.getSelectedItem();
    if (selectedFixpoint instanceof FacilityValue) {
      FacilityValue fixpoint = (FacilityValue) selectedFixpoint;
      seaport2Fixpoint.setFixpointId(fixpoint.getId());
      seaport2Fixpoint.setActive(true);
    } else {
      seaport2Fixpoint.setFixpointId(null);
      seaport2Fixpoint.setActive(false);
    }

    // Nicht verwendet.
    return true;
  }
 protected void generateReport() {
   log.debug("Generating");
   MainFrame.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   CurrencyValue currency = currencyBox.getSelectedCurrency();
   String[] platformRefs = null;
   boolean imp = false;
   boolean exp = false;
   Date from = fromField.getDateOrNull();
   Date to = toField.getDateOrNull();
   Object[] cs = platformChooser.getSelectedPlatforms().toArray(new String[0]);
   if (cs.length > 0) platformRefs = new String[cs.length];
   for (int i = 0, n = cs.length; i < n; i++) {
     platformRefs[i] = (String) cs[i];
     // platformRefs[i] = ((FacilityValue)cs[i]).getReference();
   }
   imp = this.importBox.isSelected();
   exp = this.exportBox.isSelected();
   try {
     // @war-pp
     if (typeBox.getSelectedItem().equals("ICC Manual Tracing Report")) {
       byte[] pdfStream =
           ReportService.getInstance()
               .getICCManualTracingReport(platformRefs, typeBox.getSelectedItem().toString());
       if (pdfStream != null) ReportFrame.openIccManualReport(pdfStream, "ICCManualTracingReport");
       else showInformationMessage("No data found "); // @war
     } else {
       byte[] pdfStream =
           ReportService.getInstance()
               .getCCReport(
                   from,
                   to,
                   currency,
                   platformRefs,
                   imp,
                   exp,
                   typeBox.getSelectedItem().toString());
       ReportFrame.openReport(
           pdfStream,
           typeBox.getSelectedItem().equals("Activity Report")
               ? "ActivityReport"
               : "PreliminaryReport");
     }
   } catch (Exception e) {
     log.error(this, e);
     MainFrame.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     MainFrame.handleException("Could not create " + typeBox.getSelectedItem(), e);
   }
   MainFrame.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 }
  public CCReportPane() {
    super(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    fromField = new DateJTextField((TextFieldChangeListener) null);
    fromField.setColumns(6);
    fromField.setMinimumSize(fromField.getPreferredSize());

    JLabel fromLabel = new JLabel("From");
    fromLabel.setLabelFor(fromField);
    fromLabel.setDisplayedMnemonic('F');

    toField = new DateJTextField((TextFieldChangeListener) null);
    toField.setColumns(6);
    toField.setMinimumSize(toField.getPreferredSize());

    JLabel toLabel = new JLabel("To");
    toLabel.setLabelFor(toField);
    toLabel.setDisplayedMnemonic('T');

    platformChooser = new CcPlatformChooser();

    JLabel ccLabel = new JLabel("CC");
    ccLabel.setLabelFor(platformChooser.getCcComboBox());
    ccLabel.setDisplayedMnemonic('C');

    JLabel platformLabel = new JLabel("Platforms");
    platformLabel.setLabelFor(platformChooser.getPlatformList());
    platformLabel.setDisplayedMnemonic('P');

    DefaultComboBoxModel boxModel = new DefaultComboBoxModel();
    boxModel.addElement("Activity Report");

    // boxModel.addElement("Preliminary Report");
    boxModel.addElement("ICC Manual Tracing Report"); // @war-pp
    typeBox = new ContextJComboBox(boxModel);

    JLabel typeLabel = new JLabel("Report Type");
    typeLabel.setLabelFor(typeBox);
    typeLabel.setDisplayedMnemonic('R');

    importBox = new JCheckBox();

    JLabel importLabel = new JLabel("Import");
    importLabel.setLabelFor(importBox);
    importLabel.setDisplayedMnemonic('I');

    exportBox = new JCheckBox();

    JLabel exportLabel = new JLabel("Export");
    exportLabel.setLabelFor(exportBox);
    exportLabel.setDisplayedMnemonic('E');

    currencyBox = new CurrencyBox();
    currencyBox.setToolTipText("The currency for reported amounts of money");

    JLabel currencyLabel = new JLabel("Currency");
    currencyLabel.setToolTipText("The currency for reported amounts of money");
    currencyLabel.setLabelFor(currencyBox);
    currencyLabel.setDisplayedMnemonic('U');

    // @war-pp
    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (typeBox.getSelectedItem().equals("ICC Manual Tracing Report")) {
              toField.setEnabled(false);
              fromField.setEnabled(false);
              importBox.setEnabled(false);
              // System.out.println("ANWAR     ---------"+importBox.isEnabled());
              exportBox.setEnabled(false);
              currencyBox.setEnabled(false);

            } else {
              toField.setEnabled(true);
              fromField.setEnabled(true);
              importBox.setEnabled(true);
              exportBox.setEnabled(true);
              currencyBox.setEnabled(true);
            }
          }
        };

    // @war-pp
    typeBox.addActionListener(actionListener); // @war-pp

    generateReportButton = new JButton("Get Report");
    generateReportButton.setToolTipText("Creates the report and opens it");
    generateReportButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            generateReport();
          }
        });

    Insets insets = new Insets(5, 0, 0, 0);

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(fromLabel, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(fromField, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(toLabel, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(toField, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(ccLabel, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(platformChooser.getCcComboBox(), constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.insets = insets;
    add(platformLabel, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.insets = insets;
    add(new MetaScrollPane(platformChooser.getPlatformList()), constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(typeLabel, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 4;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(typeBox, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(importLabel, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 5;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(importBox, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 6;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(exportLabel, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 6;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(exportBox, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 7;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(currencyLabel, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 7;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = insets;
    add(currencyBox, constraints);

    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 8;
    constraints.gridwidth = 2;
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.insets = new Insets(15, 0, 0, 0);
    add(generateReportButton, constraints);
  }
 public void comboBoxChanged(ContextJComboBox c) {
   if (c.equals(currency)) {
     model.setCurrencyId(((CurrencyValue) currency.getSelectedItem()).getId().longValue());
     notifyModel();
   }
 }
  private void initComponents(Seaport2FixpointValue seaport2Fixpoint) {
    seaportCombo = new ContextJComboBox(this, true);
    seaportCombo.setName("Seaport");
    mandatoryFields.add(seaportCombo);
    try {
      String regionID =
          ParameterService.getInstance()
              .getParameterValue(Constants.PARAM_SEAPORT_REGION_FOR_FIXPOINT_MAPPING);

      List seaports = new ArrayList();
      if (seaport2Fixpoint.getClientValueObjectProxy().isNew()) {
        // Die Leer-auswahl nur beim Einfuegen anzeigen.
        seaports.add("-- Select --");
      }
      seaports.addAll(
          FacilityService.getInstance()
              .findFacilitiesByTypeAndRegion(
                  Constants.FACILITY_TYPE_SEAPORT, Long.parseLong(regionID)));
      seaportCombo.setModel(new DefaultComboBoxModel(seaports.toArray()));
    } catch (Exception x) {
      log.error(
          "Exception while retrieving seaport list for seaport2fixpoint table.\n "
              + "Parameter '"
              + Constants.PARAM_SEAPORT_REGION_FOR_FIXPOINT_MAPPING
              + "' not set?",
          x);
    }
    setSelectedItem(seaportCombo, seaport2Fixpoint.getSeaportId());

    JLabel seaportLabel = new JLabel(seaportCombo.getName());
    seaportLabel.setLabelFor(seaportCombo);
    seaportLabel.setDisplayedMnemonic('S');

    fixpointCombo = new ContextJComboBox(this);
    fixpointCombo.setName("Fixpoint");
    mandatoryFields.add(fixpointCombo);
    try {
      List fixpoints = new ArrayList();
      fixpoints.add("-- n/a --");
      fixpoints.addAll(
          FacilityService.getInstance().findFacilitiesByType(Constants.FACILITY_TYPE_FIXPOINT));
      fixpointCombo.setModel(new DefaultComboBoxModel(fixpoints.toArray()));
    } catch (Exception e) {
      log.error("Exception while retrieving fixpoint list: ", e);
    }
    if (seaport2Fixpoint.getFixpointId() != null) {
      // D.h. seaport2Fixpoint.isActive().
      setSelectedItem(fixpointCombo, seaport2Fixpoint.getFixpointId().longValue());
    }

    JLabel fixpointLabel = new JLabel(fixpointCombo.getName());
    fixpointLabel.setLabelFor(fixpointCombo);
    fixpointLabel.setDisplayedMnemonic('F');

    validFromField = new DateJTextField(this);
    validFromField.setName("Valid From");
    validFromField.setDate(seaport2Fixpoint.getValidityStart());
    validFromField.setRequired(true);
    mandatoryFields.add(validFromField);

    JLabel validFromLabel = new JLabel(validFromField.getName());
    validFromLabel.setLabelFor(validFromField);
    validFromLabel.setDisplayedMnemonic('F');

    validToField = new DateJTextField(this);
    validToField.setName("Valid To");
    validToField.setDate(seaport2Fixpoint.getValidityEnd());
    // VERSION_TOGGLE ValidityModification.enabled Start ----------
    if (!ResourceUtil.getBoolean("ValidityModification.enabled")) {
      validToField.setRequired(true);
      mandatoryFields.add(validToField);
    }
    // VERSION_TOGGLE ValidityModification.enabled End ----------

    JLabel validToLabel = new JLabel(validToField.getName());
    validToLabel.setLabelFor(validToField);
    validToLabel.setDisplayedMnemonic('T');

    // Durch die Vorbelgung soll das Objekt noch nicht speicherbar sein.
    seaport2Fixpoint.getClientValueObjectProxy().setChanged(false);

    setTitle("Fixpoints");
    setMaximizable(false);

    getContentPane().setLayout(new GridBagLayout());
    ((JComponent) getContentPane()).setBorder(BorderFactory.createEmptyBorder(15, 15, 10, 15));

    GridBagConstraints constraints = new GridBagConstraints();

    // Spalte 1.

    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 0, 5, 0);
    getContentPane().add(seaportLabel, constraints);

    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.anchor = GridBagConstraints.WEST;
    getContentPane().add(validFromLabel, constraints);

    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.anchor = GridBagConstraints.WEST;
    getContentPane().add(validToLabel, constraints);

    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.anchor = GridBagConstraints.WEST;
    getContentPane().add(fixpointLabel, constraints);

    // Spalte 2.

    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    getContentPane().add(seaportCombo, constraints);

    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    getContentPane().add(validFromField, constraints);

    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    getContentPane().add(validToField, constraints);

    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    getContentPane().add(fixpointCombo, constraints);

    pack();
  }