@Override
 public void load() {
   desktop.setWaitCursor();
   clear();
   Vector<ScheduleRangeObject> v = null;
   try {
     v =
         memberService.findFollowUp(
             personFile.getId(), new DateRange(dates.getStartFr(), dates.getEndFr()));
   } catch (SQLException ex) {
     GemLogger.logException(ex);
   }
   int min = 0;
   if (v != null) {
     for (int i = 0; i < v.size(); i++) {
       ScheduleRangeObject r = v.elementAt(i);
       Hour hd = r.getStart();
       Hour hf = r.getEnd();
       min += hd.getLength(hf);
       tableModel.addItem(r);
     }
     totalTime.setText(Hour.format(min));
   }
   loaded = true;
   desktop.setDefaultCursor();
 }
  private void print() {
    desktop.setWaitCursor();
    hideCatchingRooms();
    printDlg.setVisible(true);
    try {
      List<Module> modules =
          memberService.findModuleOrders(personFile.getId(), dates.getStart(), dates.getEnd());
      StringBuilder sb = new StringBuilder(personFile.getContact().getFirstnameName());

      if (modules != null && !modules.isEmpty()) {
        sb.append(" : ");
        sb.append(modules.get(0).getTitle());
        if (modules.size() > 1) {
          sb.append("..."); // do not display next modules
        }
      }

      MessageFormat header = new MessageFormat(sb.toString());
      MessageFormat footer = new MessageFormat("Page {0}");
      PrintRequestAttributeSet prs = new HashPrintRequestAttributeSet();
      prs.add(MediaSizeName.ISO_A4);
      prs.add(Sides.TWO_SIDED_LONG_EDGE);
      prs.add(OrientationRequested.PORTRAIT);
      prs.add(
          new JobName(
              BundleUtil.getLabel("Follow.up.label") + "-" + personFile.getId(),
              Locale.getDefault()));
      // 210 x 297 mm | 8.3 x 11.7 in 1 inch = 25.4 mm

      MediaPrintableArea printableArea =
          new MediaPrintableArea(10f, 10f, 190f, 277f, MediaPrintableArea.MM);
      prs.add(printableArea);
      printTable.print(JTable.PrintMode.FIT_WIDTH, header, footer, true, prs, true);
    } catch (PrinterException ex) {
      GemLogger.logException(ex);
    } finally {
      printDlg.setVisible(false);
      desktop.setDefaultCursor();
    }
  }
  public MemberFollowUpEditor(GemDesktop desktop, PersonFile pf) {
    super(desktop);
    memberService = new MemberService(DataCache.getDataConnection());
    personFile = pf;

    tableModel = new ScheduleRangeTableModel(dataCache);
    table = new JTable(tableModel);
    table.setAutoCreateRowSorter(true);

    table.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (table.getSelectedRow() < 0) {
              return;
            }
            int n = table.convertRowIndexToModel(table.getSelectedRow());
            if (e.getClickCount() == 2) {
              try {
                modification(n);
              } catch (SQLException sqe) {
                GemLogger.log(sqe.getMessage());
              } catch (PlanningException pe) {
                GemLogger.log(pe.getMessage());
              }
            }
          }
        });
    roomFilter =
        new RowFilter<Object, Object>() {

          @Override
          public boolean include(Entry<? extends Object, ? extends Object> entry) {
            String r = (String) entry.getValue(4);
            return !r.matches(Room.CATCHING_UP_REGEX);
          }
        };
    TableColumnModel cm = table.getColumnModel();
    cm.getColumn(0).setPreferredWidth(50);
    cm.getColumn(1).setPreferredWidth(15);
    cm.getColumn(2).setPreferredWidth(15);
    cm.getColumn(3).setPreferredWidth(100);
    cm.getColumn(4).setPreferredWidth(40);
    cm.getColumn(5).setPreferredWidth(60);
    cm.getColumn(6).setPreferredWidth(15);
    cm.getColumn(7).setPreferredWidth(160);
    cm.getColumn(8).setPreferredWidth(150);

    JScrollPane scroll = new JScrollPane(table);
    initPrintTable();
    initPrintDialog();

    btModify = new GemButton(GemCommand.VIEW_EDIT_CMD); // consulter/modifier
    btDelete = new GemButton(GemCommand.DELETE_CMD);
    btLoad = new GemButton(GemCommand.LOAD_CMD);
    btPrint = new GemButton(GemCommand.PRINT_CMD);
    btModify.addActionListener(this);
    btDelete.addActionListener(this);
    btLoad.addActionListener(this);
    btPrint.addActionListener(this);

    GemPanel datesPanel = new GemPanel();
    dates = new DateRangePanel();
    dates.setStart(dataCache.getStartOfYear());
    dates.setEnd(new Date()); // now by default
    totalTime = new GemLabel();
    GemPanel timePanel = new GemPanel();

    datesPanel.add(new GemLabel(BundleUtil.getLabel("Total.label") + " :"));
    datesPanel.add(totalTime);
    datesPanel.add(dates);
    datesPanel.add(btLoad);
    datesPanel.add(btPrint);

    GemPanel pDates = new GemPanel(new BorderLayout());
    pDates.add(datesPanel, BorderLayout.CENTER);
    pDates.add(timePanel, BorderLayout.SOUTH);

    GemPanel mainPanel = new GemPanel(new BorderLayout());
    mainPanel.add(scroll, BorderLayout.CENTER);
    mainPanel.add(pDates, BorderLayout.SOUTH);

    GemPanel buttons = new GemPanel(new GridLayout(1, 2));
    buttons.add(btModify);
    buttons.add(btDelete);

    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
    add(buttons, BorderLayout.SOUTH);
  }
Example #4
0
 DateFr getDate() {
   return datePanel.get();
 }
Example #5
0
 void clear() {
   datePanel.setDate(new Date());
   hourPanel.clear();
   roomChoice.setSelectedIndex(0);
 }