Exemplo n.º 1
0
  /**
   * List all metadata items of the selected entries
   *
   * @param selected Is TRUE if some check boxes are checked
   * @param selectedRow Selected row of the table, is used only if selected = FALSE
   */
  private void listItems(boolean selected, int selectedRow) {
    TableModel model = branchTable.getModel();
    Collection searchResult = new HashSet();
    if (selected) // some items are checked, delete them
    {
      // int [] selectedIndices = branches.getSelectedIndices();
      for (int i = 0; i < myBranches.length; i++) {
        Boolean checked = (Boolean) model.getValueAt(i, 0);
        if (Boolean.TRUE.equals(checked)) {
          WaitDialog.showDialog();
          String branchToBrowse = ((Branch) myBranches[i]).getAbbreviation();
          Collection branchResult = Gui.dispatcher.getAllLibItemsFromBranch(branchToBrowse);
          searchResult.addAll(branchResult);
          WaitDialog.closeDialog();
        }
      }
    } else // no checked items, delete only selected row
    {
      if (selectedRow >= 0) {
        WaitDialog.showDialog();
        String branchToBrowse = ((Branch) myBranches[selectedRow]).getAbbreviation();
        searchResult = Gui.dispatcher.getAllLibItemsFromBranch(branchToBrowse);
        WaitDialog.closeDialog();
      }
    }

    if (searchResult.isEmpty()) // Result ist empty, show Warning
    {
      showNoResultMessage();
    } else // Result is not empty, call BrowseMetadataResults
    {
      // Result-Frame ist allready opened, ask to overwrite
      int index = Configurator.getIntProperty("searchMetadataResult", 0, "gui-forms");
      if (Gui.my_forms[index] != null && !Gui.my_forms[index].isClosed()) {
        int switch_frame = getNewSearchDialog();
        if (switch_frame == JOptionPane.NO_OPTION) {
          Gui.my_forms[index].pack();
          try {
            Gui.my_forms[index].setSelected(true);
          } catch (java.beans.PropertyVetoException ev) {
          }
        } else {
          Point location = Gui.my_forms[index].getLocation();
          Gui.my_forms[index].dispose();
          BrowseMetadataResults mdSearchResult =
              new BrowseMetadataResults(
                  index, Gui.lang.getString("selected_branch_entries"), searchResult, location);
        }
      } else {
        // GEH�RT HIER NICHT REIN // Point location = Gui.my_forms[index].getLocation();
        BrowseMetadataResults mdSearchResult =
            new BrowseMetadataResults(
                index, Gui.lang.getString("selected_branch_entries"), searchResult, null);
      }
    }
  }
Exemplo n.º 2
0
  /** Invoked when an action occurs. */
  public void actionPerformed(ActionEvent e) {
    String actionCmd = e.getActionCommand();

    if (actionCmd.equals("cancel")) {
      closeForm();
    }

    if (actionCmd.equals("new_branch")) {
      int index = Configurator.getIntProperty("newBranch", 0, "gui-forms");
      DefaultForm form = Gui.getForm(index);
      if (form != null && !form.isClosed()) {
        form.pack();
        try {
          form.setSelected(true);
        } catch (java.beans.PropertyVetoException ev) {
        }
      } else {
        BranchForm branchForm = new BranchForm(index, null);
      }
    }

    if (actionCmd.equals("checkout")) {
      boolean selected = false;
      for (int i = 0; i < myBranches.length; i++) {
        TableModel model = branchTable.getModel();
        Boolean checked = (Boolean) model.getValueAt(i, 0);
        if (Boolean.TRUE.equals(checked)) selected = true;
      }
      int selectedRow = branchTable.getSelectedRow();
      if (selected || (!selected && selectedRow >= 0)) checkoutItems(selected, selectedRow);
      else {
        showNoSectionMessage();
      }
    }

    if (actionCmd.equals("edit")) {
      Point formLocation = null;
      int selectedRow = branchTable.getSelectedRow();
      if (selectedRow >= 0) {
        Branch branchToEdit = (Branch) myBranches[selectedRow];
        int editBranchIndex = Configurator.getIntProperty("editBranch", 0, "gui-forms");
        JInternalFrame form = Gui.getForm(editBranchIndex);
        if (form != null && !form.isClosed()) {
          int switch_frame = getEditOpenedDialog();
          if (switch_frame == JOptionPane.YES_OPTION) {
            formLocation = form.getLocation();
            form.dispose();
            BranchForm editBranch =
                new BranchForm(editBranchIndex, branchToEdit, selectedRow, formLocation);
          } else {
            try {
              form.setSelected(true);
            } catch (java.beans.PropertyVetoException ev) {
            }
          }
        } else {
          BranchForm editBranch =
              new BranchForm(editBranchIndex, branchToEdit, selectedRow, formLocation);
        }
      } // if(selectedRow>=0)
      else {
        showNoEditSelectionMessage();
      }
    }

    if (actionCmd.equals("delete")) {
      boolean selected = false;
      for (int i = 0; i < myBranches.length; i++) {
        TableModel model = branchTable.getModel();
        Boolean checked = (Boolean) model.getValueAt(i, 0);
        if (Boolean.TRUE.equals(checked)) selected = true;
      }
      int selectedRow = branchTable.getSelectedRow();
      if (selected || (!selected && selectedRow >= 0)) deleteItems(selected, selectedRow);
      else {
        showNoDeleteSelectionMessage();
      }
    }

    if (actionCmd.equals("branch_content")) {
      boolean selected = false;
      for (int i = 0; i < myBranches.length; i++) {
        TableModel model = branchTable.getModel();
        Boolean checked = (Boolean) model.getValueAt(i, 0);
        if (Boolean.TRUE.equals(checked)) selected = true;
      }
      int selectedRow = branchTable.getSelectedRow();
      if (selected || (!selected && selectedRow >= 0)) listItems(selected, selectedRow);
      else {
        showNoListcontentSection();
      }
    }

    if (actionCmd.equals("select_all")) {
      selectAll();
    }

    if (actionCmd.equals("select_all_pop")) {
      selectAllPop();
    }
  }