コード例 #1
0
 /**
  * modificar un cliente
  *
  * <p>Devuelve el cliente que se va a modificar
  *
  * <p>Si el cliente pasado es null, intenta crear un nuevo cliente
  */
 public Cliente editCliente(Cliente cliente, Component parent) {
   Assert.notNull(dataService);
   Cliente eCliente = cliente;
   if (eCliente == null) {
     eCliente = new Cliente();
     String s = getMessage("ui.ClienteUIService.DefaultName", null, "New customer");
     eCliente.setNombre(s);
   }
   boolean error = false;
   Throwable excep = null;
   if (eCliente.getId() != null) {
     try {
       eCliente = dataService.getById(eCliente.getId());
     } catch (DataAccessException e) {
       excep = e;
       error = true;
     } catch (Throwable t) {
       excep = t;
       error = true;
     }
     if (error) {
       logger.error("Error retrieving customer from persistence service", excep);
       String t =
           getMessage(
               "ui.ClienteUIService.ErrorLoadClienteTitle", null, "Error retrieving customer");
       String m =
           getMessage(
               "ui.ClienteUIService.ErrorLoadClienteMessage",
               null,
               "Error retrieving customer data");
       ErrorInfo err = new ErrorInfo(t, m, excep.getMessage(), null, excep, null, null);
       JXErrorPane.showDialog(parent == null ? getParentWindow() : parent, err);
       return null;
     }
     // Si el cliente es null, no se ha encontrado
     // Podría haber sido borrado
     if (eCliente == null) {
       logger.error("Error retrieving customer from persistence service. Not found.");
       String t =
           getMessage(
               "ui.ClienteUIService.ErrorNotExistClienteTitle", null, "Error retrieving customer");
       String m =
           getMessage(
               "ui.ClienteUIService.ErrorNotExistClienteMessage",
               null,
               "Customer not found. Please, refresh data");
       ErrorInfo err = new ErrorInfo(t, m, m, null, null, null, null);
       JXErrorPane.showDialog(getParentWindow(), err);
       return null;
     }
   }
   ClienteEditDialog dialog =
       new ClienteEditDialog(parent == null ? getParentWindow() : parent, eCliente, this);
   dialog.setDataService(dataService);
   dialog.setModalityType(ModalityType.MODELESS);
   dialog.pack();
   dialog.setLocationRelativeTo(dialog.getOwner());
   dialog.setVisible(true);
   return eCliente;
 }
 @Override
 public void dispatchEvent(AWTEvent event) {
   try {
     super.dispatchEvent(event);
   } catch (RuntimeException e) {
     JXErrorPane.showDialog(
         null,
         new ErrorInfo(
             "Event Queue Exception!", //$NON-NLS-1$
             e.toString(),
             null,
             null,
             e,
             Level.SEVERE,
             null));
     e.printStackTrace();
   }
 }
コード例 #3
0
 /**
  * Elimina un cliente
  *
  * <p>Devuelve el cliente eliminado o null si no se elimino
  *
  * <p>Pide confirmación si así se requiere
  */
 public Cliente removeCliente(Cliente cliente, boolean askConfirmation, Component parent) {
   Assert.notNull(dataService);
   if (askConfirmation) {
     String ti = getMessage("ui.ClienteUIService.ConfirmDeleteTitle", null, "Remove Customer");
     String me =
         getMessage(
             "ui.ClienteUIService.ConfirmDeleteQuestion",
             new String[] {cliente.getNombre()},
             "Do you want to remove customer {0}?");
     int code =
         JOptionPane.showConfirmDialog(
             parent == null ? getParentWindow() : parent, me, ti, JOptionPane.YES_NO_OPTION);
     if (code != JOptionPane.YES_OPTION) return null;
   }
   boolean error = false;
   Throwable excep = null;
   try {
     dataService.remove(cliente);
   } catch (DataAccessException e) {
     excep = e;
     error = true;
   } catch (Throwable t) {
     excep = t;
     error = true;
   }
   if (error) {
     logger.error("Error deleting customer in persistence service", excep);
     String t =
         getMessage(
             "ui.ClienteUIService.ErrorDeleteClienteTitle", null, "Error deleting customer");
     String m =
         getMessage(
             "ui.ClienteUIService.ErrorDeleteClienteMessage",
             null,
             "Error trying to delete customer data");
     ErrorInfo err = new ErrorInfo(t, m, excep.getMessage(), null, excep, null, null);
     JXErrorPane.showDialog(parent == null ? getParentWindow() : parent, err);
     return null;
   }
   return cliente;
 }
コード例 #4
0
ファイル: ActionsFactory.java プロジェクト: maleadt/stockplay
  public Collection<Action> getSecuritiesActions() {

    if (securitiesActions == null) {

      securitiesActions = new ArrayList<Action>();
      Action firstTitle =
          new ShowSecuritiesAction(
              translations.getString("EXCHANGESMENUITEM"), createImageIcon("money.png"), true);
      firstTitle.putValue(Layout.LEAVE_SPACE, false);
      securitiesActions.add(firstTitle);
      Collection<Exchange> exchanges = null;
      try {
        exchanges = financeFactory.getAllExchanges();

        for (Exchange exch : exchanges) {

          securitiesActions.add(
              new ShowSecuritiesByExchangeAction(
                  exch.getName(), createImageIcon("money_euro.png"), exch));
        }
      } catch (StockPlayException ex) {
        JXErrorPane.showDialog(
            MainFrame.getInstance(),
            new ErrorInfo(
                translations.getString("ERROR_COMMUNICATION"),
                translations.getString("ERROR_FETCH_EXCHANGES"),
                null,
                null,
                ex,
                null,
                null));
      }

      securitiesActions.add(
          new ShowSecuritiesAction(
              translations.getString("INDEXESMENUITEM"), createImageIcon("money.png"), true));
      Collection<Index> indexes = null;
      try {
        indexes = financeFactory.getAllIndexes();

        for (Index index : indexes) {

          securitiesActions.add(
              new ShowSecuritiesByIndexAction(
                  index.getName(), createImageIcon("money_euro.png"), index));
        }
      } catch (StockPlayException ex) {
        JXErrorPane.showDialog(
            MainFrame.getInstance(),
            new ErrorInfo(
                translations.getString("ERROR_COMMUNICATION"),
                translations.getString("ERROR_FETCH_EXCHANGES"),
                null,
                null,
                ex,
                null,
                null));
      }
    }

    return securitiesActions;
  }