예제 #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);
      }
    }
  }
예제 #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();
    }
  }
  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   *  Invoked when an action occurs.
   */
  public void actionPerformed(ActionEvent e) {
    String actionCmd = e.getActionCommand();
    myConnections =
        Gui.dispatcher.sortConnections(Gui.dispatcher.getAllConnections(), Gui.myLib).toArray();

    if (actionCmd.equals("cancel")) {
      this.dispose();
    }

    if (actionCmd.equals("ok")) {

      if (languages.getSelectedItem().toString() == Gui.lang.getString("german")) {
        // System.out.println(languages.getSelectedItem().toString()+"deustch");

        Configurator.setProperty("language", "german", "gui-options");
        Gui.language = "german";

        // Gui.lang = Gui.dispatcher.initLanguage(Locale.GERMAN);

      } else {
        // System.out.println(languages.getSelectedItem().toString()+"english");

        Configurator.setProperty("language", "english", "gui-options");
        Gui.language = "english";
      }

      if (box1.isSelected()) {
        Configurator.setProperty("toolbar", Integer.toString(1), "gui-options");
        Gui.toolbar.setVisible(true);
        Gui.modalParent.update(Gui.modalParent.getGraphics());
        Gui.showToolbar = true;
      } else {

        Configurator.setProperty("toolbar", "0", "gui-options");

        Gui.toolbar.setVisible(false);
        Gui.modalParent.update(Gui.modalParent.getGraphics());
        Gui.showToolbar = false;
      }
      if (box2.isSelected()) {
        Configurator.setProperty("warnings", "1", "gui-options");
        Gui.showWarnings = true;
      } else {
        Configurator.setProperty("warnings", "0", "gui-options");
        Gui.showWarnings = false;
      }
      if (box4.isSelected()) {
        Configurator.setProperty("confirmations", "1", "gui-options");
        Gui.showConfirmations = true;
      } else {
        Configurator.setProperty("confirmations", "0", "gui-options");
        Gui.showConfirmations = false;
      }
      if (box3.isSelected()) {
        Configurator.setProperty("connect", "1", "gui-options");
        Gui.connect = true;
        ToolBar.connectButton.setSelected(true);
        Menu.connect.setSelected(true);
        ArrayList connectedLibs = new ArrayList();
        for (int i = 0; i < this.myConnections.length; i++) {
          System.out.println("Connect");
          Connection conn = (Connection) myConnections[i];
          connectedLibs.add(Gui.dispatcher.connect(conn));
        }

        ToolBar.connectButton.setToolTipText(Gui.lang.getString("connected"));
      } else {
        Configurator.setProperty("connect", "0", "gui-options");
        Gui.connect = false;
        ToolBar.connectButton.setSelected(false);
        Menu.connect.setSelected(false);
        ToolBar.connectButton.setToolTipText(Gui.lang.getString("not_connected"));
        Gui.dispatcher.disconnectFromAllConnectedLibraries();
      }

      if (box5.isSelected()) {
        Configurator.setProperty("update", "1", "gui-options");
        Gui.automaticUpdate = true;
      } else {
        Configurator.setProperty("update", "0", "gui-options");
        Gui.automaticUpdate = false;
      }

      Configurator.store();
      this.dispose();
    }
  }