コード例 #1
0
  private void removeSelectedPolicyInformation() {
    int selectedRow = jtPolicyInformation.getSelectedRow();

    if (selectedRow != -1) {
      PolicyInformation policyInfo =
          (PolicyInformation) jtPolicyInformation.getValueAt(selectedRow, 0);

      policyInformation.remove(policyInfo);

      reloadPolicyInformationTable();
      selectFirstPolicyInformationInTable();
      updateButtonControls();
    }
  }
コード例 #2
0
  private void editSelectedPolicyInformation() {
    int selectedRow = jtPolicyInformation.getSelectedRow();

    if (selectedRow != -1) {
      PolicyInformation policyInfo =
          (PolicyInformation) jtPolicyInformation.getValueAt(selectedRow, 0);

      Container container = getTopLevelAncestor();

      try {
        DPolicyInformationChooser dPolicyNameChooser = null;

        if (container instanceof JDialog) {
          dPolicyNameChooser =
              new DPolicyInformationChooser((JDialog) container, title, policyInfo);
          dPolicyNameChooser.setLocationRelativeTo(container);
          dPolicyNameChooser.setVisible(true);
        } else if (container instanceof JFrame) {
          dPolicyNameChooser = new DPolicyInformationChooser((JFrame) container, title, policyInfo);
          dPolicyNameChooser.setLocationRelativeTo(container);
          dPolicyNameChooser.setVisible(true);
        }

        PolicyInformation newPolicyInfo = dPolicyNameChooser.getPolicyInformation();

        if (newPolicyInfo == null) {
          return;
        }

        policyInformation.remove(policyInfo);
        policyInformation.add(newPolicyInfo);

        populate();
        selectPolicyInformationInTable(newPolicyInfo);
      } catch (IOException ex) {
        DError dError = null;

        if (container instanceof JDialog) {
          dError = new DError((JDialog) container, ex);
        } else {
          dError = new DError((JFrame) container, ex);
        }

        dError.setLocationRelativeTo(container);
        dError.setVisible(true);
      }
    }
  }
コード例 #3
0
  private void updateButtonControls() {
    if (!enabled) {
      jbAdd.setEnabled(false);
      jbEdit.setEnabled(false);
      jbRemove.setEnabled(false);
    } else {
      jbAdd.setEnabled(true);

      int selectedRow = jtPolicyInformation.getSelectedRow();

      if (selectedRow == -1) {
        jbEdit.setEnabled(false);
        jbRemove.setEnabled(false);
      } else {
        jbEdit.setEnabled(true);
        jbRemove.setEnabled(true);
      }
    }
  }