/** Layots and shows the dialog content */
  private void addContentPanel() {
    int border = 5;
    double root_size[][] = {
      {border, TableLayout.PREFERRED, TableLayout.PREFERRED, border}, // Columns
      {border, TableLayout.PREFERRED, TableLayout.PREFERRED, border}
    }; // Rows
    TableLayout tl = new TableLayout(root_size);
    JPanel root = new JPanel(tl);

    double root2[][] = {
      {border, TableLayout.PREFERRED, TableLayout.PREFERRED, border}, // Columns
      {
        border,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        border
      }
    }; // Rows
    TableLayout tl1 = new TableLayout(root2);
    tl.setHGap(10);
    tl.setVGap(10);

    JPanel panel = new JPanel(tl1);

    /** Show toolbar */
    JLabel label1 =
        FormElement.getInfiniteExtLabel(Gui.lang.getString("getToolBarVisible"), Font.PLAIN, null);
    panel.add(label1, "1,1,1,1,LEFT,CENTER");

    box1 = new JCheckBox();
    if (Gui.showToolbar) box1.setSelected(true);
    else box1.setSelected(false);
    box1.setEnabled(true);
    box1.setToolTipText(Gui.lang.getString("show_toolbar"));
    panel.add(box1, "2,1,2,1,RIGHT,CENTER");

    /** Warnings are on or off */
    JLabel label2 =
        FormElement.getInfiniteExtLabel(Gui.lang.getString("getBranchWarning"), Font.PLAIN, null);
    panel.add(label2, "1,2,1,2,LEFT,CENTER");

    box2 = new JCheckBox();
    box2.setEnabled(true);
    box2.setSelected(Gui.showWarnings);
    box2.setToolTipText(Gui.lang.getString("show_warnings"));
    panel.add(box2, "2,2,2,2,RIGHT,CENTER");

    /** Choose a language */
    JLabel label3 =
        FormElement.getInfiniteExtLabel(Gui.lang.getString("Language"), Font.PLAIN, null);
    panel.add(label3, "1,6,1,6,LEFT,CENTER");

    languages = new JComboBox(lang);
    if (Gui.language.equals("german")) languages.setSelectedItem(Gui.lang.getString("german"));
    else languages.setSelectedItem(Gui.lang.getString("english"));

    languages.setEnabled(true);
    languages.setToolTipText(Gui.lang.getString("languages_change"));
    panel.add(languages, "2,6,2,6,RIGHT,CENTER");

    /** Automatic connect */
    JLabel label4 =
        FormElement.getInfiniteExtLabel(Gui.lang.getString("autom_connecten"), Font.PLAIN, null);
    panel.add(label4, "1,5,1,5,LEFT,CENTER");

    box3 = new JCheckBox();
    box3.setEnabled(true);
    box3.setSelected(Gui.connect);
    box3.setToolTipText(Gui.lang.getString("connect_to_all_server_aut"));
    panel.add(box3, "2,5,2,5,RIGHT,CENTER");

    JLabel label5 =
        FormElement.getInfiniteExtLabel(Gui.lang.getString("confirm_message"), Font.BOLD, null);
    panel.add(label5, "1,3,2,3");

    box4 = new JCheckBox();
    box4.setEnabled(true);
    box4.setSelected(Gui.showConfirmations);
    box4.setToolTipText(Gui.lang.getString("show_confirmations"));
    panel.add(box4, "2,3,2,3,RIGHT,CENTER");

    panel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEtchedBorder(BevelBorder.LOWERED), Gui.lang.getString("prefs")));

    root.add(panel, "1,1,2,1");

    JLabel label6 =
        FormElement.getInfiniteExtLabel(Gui.lang.getString("automatic_update"), Font.BOLD, null);
    panel.add(label6, "1,4,2,4");

    box5 = new JCheckBox();
    box5.setEnabled(true);
    box5.setSelected(Gui.automaticUpdate);
    box5.setToolTipText(Gui.lang.getString("automatic_update2"));
    panel.add(box5, "2,4,2,4,RIGHT,CENTER");

    panel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEtchedBorder(BevelBorder.LOWERED), Gui.lang.getString("prefs")));

    root.add(panel, "1,1,2,1");

    // OK-Button
    JButton ok_button = FormElement.getButton("ok", "images/ok.png", "save", null, true);
    ok_button.setActionCommand("ok");
    ok_button.addActionListener(this);
    root.add(ok_button, "1,2,1,2,FULL,CENTER");

    // Cancel-Button
    JButton cancel_button =
        FormElement.getButton("cancel", "images/cancel.png", "close_wnd", null, true);
    cancel_button.setActionCommand("cancel");
    cancel_button.addActionListener(this);
    root.add(cancel_button, "2,2,2,2,FULL,CENTER");

    this.getContentPane().add(root);
    this.pack();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension labelSize = this.getPreferredSize();

    this.setLocation(
        screenSize.width / 2 - (labelSize.width / 2),
        screenSize.height / 2 - (labelSize.height / 2));
    this.setVisible(true);
  }
Пример #2
0
  /** Implemetation of inherited method. Returns the layouted content panel of the form */
  public JPanel showFormContent() {
    JPanel root = getRootPanel(); // inherited

    if (myBranches.length == 0) {
      Gui.my_forms[index].setPreferredSize(new Dimension(300, 200));
      JPanel noresultPanel =
          getNoResultPanel(
              Gui.lang.getString("no_branches_avail"),
              Gui.lang.getString("list_branches")); // inherited
      root.add(noresultPanel, "1,1,3,1,FULL,FULL");
    } else {
      int border = 3;
      double size[][] = {
        {
          border,
          TableLayout.PREFERRED,
          TableLayout.PREFERRED,
          TableLayout.PREFERRED,
          TableLayout.PREFERRED,
          border
        }, // Columns
        {
          border,
          TableLayout.PREFERRED,
          TableLayout.PREFERRED,
          TableLayout.PREFERRED,
          TableLayout.PREFERRED,
          TableLayout.PREFERRED,
          border
        }
      }; // Rows

      TableLayout tl = new TableLayout(size);
      tl.setHGap(border);
      tl.setVGap(border);
      JPanel panel = new JPanel(tl);
      panel.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createEtchedBorder(BevelBorder.LOWERED),
              Gui.lang.getString("list_branches")));

      Object[][] tableData = new Object[myBranches.length][3];

      for (int i = 0; i < myBranches.length; i++) {
        tableData[i][0] = new Boolean(false);
        tableData[i][1] = ((Branch) myBranches[i]).getDescription();
        tableData[i][2] = ((Branch) myBranches[i]).getAbbreviation();
      }

      // Show Statistics
      int displayed;
      if (myBranches.length < 100) displayed = myBranches.length;
      else displayed = 100;

      String stat_string = (Gui.lang.getString("results") + " : " + myBranches.length);
      JLabel stats = FormElement.getInfiniteLabel(stat_string, Font.PLAIN, null);
      panel.add(stats, "1,1,4,1,LEFT,CENTER");

      branchTable = new JTable(new ResultTableModel(tableData));
      branchTable.setColumnModel(getColumnModel());
      branchTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      branchTable.addMouseListener(this);

      JPanel sroot = new JPanel(new BorderLayout());
      JScrollPane sp = new JScrollPane(branchTable);
      sp.setPreferredSize(new Dimension(300, 300));
      sroot.add(sp, BorderLayout.CENTER);
      panel.add(sroot, "1,2,4,2,FULL,TOP");

      selectAll = new JCheckBox(Gui.lang.getString("select_all"));
      selectAll.setToolTipText(Gui.lang.getString("select_all"));
      selectAll.setActionCommand("select_all");
      selectAll.addActionListener(this);
      panel.add(selectAll, "1,3,1,3,LEFT,CENTER");

      JButton new_button = FormElement.getButton("new", "images/branch2.png", null, null, true);
      new_button.setActionCommand("new_branch");
      new_button.addActionListener(this);
      new_button.addKeyListener(
          new KeyAdapter() {
            public void keyPressed(KeyEvent event) {
              if (event.getKeyCode() == KeyEvent.VK_ESCAPE)
                actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "cancel"));
              if (event.getKeyCode() == KeyEvent.VK_ENTER)
                actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "new_branch"));
            }
          });
      panel.add(new_button, "3,3,3,3,FULL,CENTER");

      JButton content_button =
          FormElement.getButton("content", "images/content.png", "branch_content", null, true);
      content_button.setActionCommand("branch_content");
      content_button.addActionListener(this);
      content_button.addKeyListener(
          new KeyAdapter() {
            public void keyPressed(KeyEvent event) {
              if (event.getKeyCode() == KeyEvent.VK_ESCAPE)
                actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "cancel"));
              if (event.getKeyCode() == KeyEvent.VK_ENTER)
                actionPerformed(
                    new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "branch_content"));
            }
          });
      panel.add(content_button, "4,3,4,3,FULL,CENTER");

      JButton checkout_button =
          FormElement.getButton("checkout", "images/checkout2.png", null, null, true);
      checkout_button.setActionCommand("checkout");
      checkout_button.addKeyListener(
          new KeyAdapter() {
            public void keyPressed(KeyEvent event) {
              if (event.getKeyCode() == KeyEvent.VK_ESCAPE)
                actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "cancel"));
              if (event.getKeyCode() == KeyEvent.VK_ENTER)
                actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "checkout"));
            }
          });
      checkout_button.addActionListener(this);
      panel.add(checkout_button, "3,4,3,4,FULL,CENTER");

      JButton edit_button =
          FormElement.getButton("edit", "images/searchedit.png", null, null, true);
      edit_button.setActionCommand("edit");
      edit_button.addKeyListener(
          new KeyAdapter() {
            public void keyPressed(KeyEvent event) {
              if (event.getKeyCode() == KeyEvent.VK_ESCAPE)
                actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "cancel"));
              if (event.getKeyCode() == KeyEvent.VK_ENTER)
                actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "edit"));
            }
          });
      edit_button.addActionListener(this);
      panel.add(edit_button, "4,4,4,4,FULL,CENTER");

      /*
      JButton delete_button = FormElement.getButton("delete", "images/delete.png", null, null, true);
      delete_button.setActionCommand("delete");
      delete_button.addActionListener(this);
      delete_button.addKeyListener(new KeyAdapter()
      		{
      			public void keyPressed(KeyEvent event)
      			{
      				if (event.getKeyCode() == KeyEvent.VK_ESCAPE )
      					actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"cancel"));
      				if (event.getKeyCode() == KeyEvent.VK_ENTER)
      					actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"delete"));
      			}
      		});
      panel.add(delete_button, "4,5,4,5,FULL,CENTER");

      */

      root.add(panel, "1,1,3,1,CENTER,CENTER");
    }
    // Ok-Button
    JButton ok_button = FormElement.getButton("close", "images/ok.png", null, null, true);
    ok_button.setActionCommand("cancel");
    ok_button.addActionListener(this);
    ok_button.addKeyListener(this);
    root.add(ok_button, "1,2,3,2,CENTER,CENTER");

    return root;
  }
Пример #3
0
  /** Implemetation of inherited method. Returns the layouted content panel of the form */
  public JPanel showFormContent() {
    JPanel root = getRootPanel(); // inherited

    int setSize = printedSet.length;
    String outputText =
        "<html><h2>"
            + Gui.lang.getString("selected_sets")
            + ": "
            + setSize
            + "</h2><p font size=\"1\">";
    for (int i = 0; i < setSize; i++) {
      String type = printedSet[i].getDc_type();
      if (type.equals(""))
        type = "book"; // TODO: book muss bei Auslieferung definiert werden ind der DB	
      ArrayList items =
          Gui.dispatcher.getMediaTypeItems(Gui.myLib, type); // Form elements for desired Media-type
      if (items == null) {
        try {
          items = TextItem.getGenericMediaTypeItems();
        } catch (ServiceNotAvailableException error) {
          Gui.statusBar.setReceiverMessage("No generic media type defined!(" + error + ")");
        }
      }
      outputText = outputText.concat("<b>Typ: " + type + "</b><br><br>");

      for (int j = 0; j < items.size(); j++) {
        switch (((TextItem) items.get(j)).getDCid()) {
          case 0:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_creator()
                        + "<br>");
            break;
          case 1:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_title()
                        + "<br>");
            break;
          case 2:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_publisher()
                        + "<br>");
            break;
          case 3:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + MetaData.convertDate(printedSet[i].getDc_date())
                        + "<br>");
            break;
          case 4:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_relation()
                        + "<br>");
            break;
          case 5:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_source()
                        + "<br>");
            break;
          case 6:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_coverage()
                        + "<br>");
            break;
          case 7:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_language()
                        + "<br>");
            break;
          case 8:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_description()
                        + "<br>");
            break;
          case 9:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_subject()
                        + "<br>");
            break;
          case 10:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_identifier()
                        + "<br>");
            break;
          case 11:
            break;
          case 12:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_format()
                        + "<br>");
            break;
          case 13:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_contributors()
                        + "<br>");
            break;
          case 14:
            outputText =
                outputText.concat(
                    "<font color=\"#112255\"><b>"
                        + ((TextItem) items.get(j)).getLocalizedName()
                        + ":</b></font>&nbsp;&nbsp;"
                        + printedSet[i].getDc_rights()
                        + "<br>");
            break;
        }
      }
      outputText = outputText.concat("<hr><br>");
    }
    outputText = outputText.concat("</p></html>");
    output.setText(outputText);
    output.addHyperlinkListener(this);

    JScrollPane scrollPane = new JScrollPane(output);

    scrollPane.setPreferredSize(new Dimension(400, 500));
    root.add(scrollPane, "1,1,3,1");

    // OK-Button
    JButton ok_button = FormElement.getButton("print", "images/print.png", "print", null, true);
    ok_button.setActionCommand("ok");
    ok_button.addActionListener(this);
    root.add(ok_button, "1,2,1,2,RIGHT,CENTER");

    // Cancel-Button
    JButton cancel_button =
        FormElement.getButton("cancel", "images/cancel.png", "close_wnd", null, true);
    cancel_button.setActionCommand("cancel");
    cancel_button.addActionListener(this);

    root.add(cancel_button, "3,2,3,2 ,LEFT,CENTER");

    return root;
  }