private void makeGUIReadOnly() {
   for (Component c : options_.getComponents()) c.setEnabled(false);
   occurred_.setEnabled(false);
   description_.setEditable(false);
   if (line_item_form_ != null) line_item_form_.setReadOnly(true);
   setBottomComponent(new JLabel("<html><i>Select an entry to view details</i></html>"));
   this.setDividerLocation();
 }
Exemplo n.º 2
0
  private void updateDescriptionPanel(final Task t) {

    try {
      System.err.println("Looking at ID: " + t.getID());
      /* Unlock old object */
      if (task_form_ != null) {
        System.err.println("Last ID: " + task_form_.getDatabaseObject().getID());
        task_form_.cancel();
      }

      task_form_ = t.getFormPanel("Task Details", null, false);

      JButton commit = new JButton("Save");
      commit.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                OfficeProjectManager.instance().getCurrentProject().getOffice().lock();
                task_form_.commit();
                OfficeProjectManager.instance().getCurrentProject().getOffice().commit();
                OfficeProjectManager.instance().getCurrentProject().getOffice().unlock();
              } catch (Exception e1) {
                e1.printStackTrace();
              }
            }
          });

      JPanel controls = new JPanel();
      controls.add(commit);
      task_form_.add(controls, BorderLayout.SOUTH);

      this.setBottomComponent(task_form_);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void updateDescriptionPanel(JournalEntryLineItem line_item) {

    try {
      /*if (this.line_item_form_ != null) {
      	try {
      		line_item_form_.cancel();
      	} catch (NotPersistedException e) {
      	}
      }*/
      JPanel controls = new JPanel();

      /*adding a new line item*/
      if (line_item == null) {
        JournalEntryLineItem default_entry =
            new JournalEntryLineItem(null, new AcctAmount(0, TransactionType.CREDIT), null, null);
        this.line_item_form_ =
            new JournalEntryLineItemFormPanel("New Line Item", default_entry, null, false);
        JButton add = new JButton("Add");
        add.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                try {
                  JournalEntryTableModel m = (JournalEntryTableModel) entry_table_.getModel();
                  line_item_form_.retrieveForm();
                  m.addLineItem(line_item_form_.getDatabaseObject());
                  /*line_item_form_.setDatabaseObject(new JournalEntryLineItem(null, new AcctAmount(0,
                  TransactionType.CREDIT), null, null));*/
                  /*TODO close the line_item_form_ panel*/
                  setDefaultBottom();
                  // line_item_form_.updateForm();
                } catch (Exception e1) {
                  e1.printStackTrace();
                }
              }
            });
        controls.add(add);
      } else {
        this.line_item_form_ = line_item.getFormPanel("Line Item Details", null, this.isReadOnly());
        JButton update = new JButton("Update");
        update.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                try {
                  line_item_form_.retrieveForm();
                  JournalEntryTableModel m = (JournalEntryTableModel) entry_table_.getModel();
                  m.fireTableDataChanged();
                } catch (Exception e1) {
                  e1.printStackTrace();
                }
              }
            });
        controls.add(update);
      }

      if (!this.isReadOnly()) line_item_form_.add(controls, BorderLayout.SOUTH);

      // line_item_form_.setPreferredSize(new Dimension(-1, this.getHeight() / 2));
      this.setDividerLocation();
      JScrollPane form_scroller =
          new JScrollPane(
              line_item_form_,
              JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
              JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      this.setBottomComponent(form_scroller);

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }