public void actionPerformed(ActionEvent e) {
   try {
     String scannedDestination = ((JTextField) e.getSource()).getText().toUpperCase();
     validateDestinationScan(scannedDestination);
     DefaultListModel listModel = (DefaultListModel) destinationsList.getModel();
     int lastPosition = listModel.getSize();
     int seedsCount = 0;
     // todo: do we have to worry about more trays than required..?
     for (int i = 0; i < seedPlates.length; i++) {
       if (seedPlates[i].getSeedPlateBarcode() != null
           && SCANNED.equals(seedPlates[i].getStatus())
           && !isContainedInList(seedPlates[i].getSeedPlateBarcode(), failedPlatesList)) {
         seedsCount++;
       }
     }
     if (lastPosition >= seedsCount) {
       throw new ChippingManagerException(DESTINATIONS_LIMIT_EXCEEDED);
     }
     addDestination(scannedDestination);
   } catch (Throwable cmException) {
     logger.error("Unable to scan destination ", cmException);
     JOptionPane.showMessageDialog(
         new JFrame(),
         cmException.getMessage(),
         TITLE_CHIPPING_MANAGER,
         JOptionPane.WARNING_MESSAGE);
   }
   scanDestination.setText(BLANK);
 }
Esempio n. 2
0
 /**
  * ** Invokes all listeners with an assciated command ** @param r a string that may specify a
  * command (possibly one ** of several) associated with the event
  */
 protected void invokeListeners(String r) {
   if (this.actionListeners != null) {
     for (Iterator i = this.actionListeners.iterator(); i.hasNext(); ) {
       ActionListener al = (ActionListener) i.next();
       ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, r);
       try {
         al.actionPerformed(ae);
       } catch (Throwable t) {
         Print.logError("Exception: " + t.getMessage());
       }
     }
   }
 }
 public void actionPerformed(ActionEvent e) {
   try {
     validateUnloadPlatesDialog();
     unloadPlates();
   } catch (Throwable cmException) {
     logger.error("error to unload to multiple destinations", cmException);
     JOptionPane.showMessageDialog(
         new JFrame(),
         cmException.getMessage(),
         TITLE_CHIPPING_MANAGER,
         JOptionPane.WARNING_MESSAGE);
   }
 }
 void printException(Throwable tr) {
   CAT.error("exception", tr);
   // StringWriter sw = new StringWriter();
   // PrintWriter pw = new PrintWriter(sw);
   // tr.p rintStackTrace(pw);
   // pw.flush();
   // sw.flush();
   log(
       getMyLoginId()
           + " reports exception:\r\n  "
           + tr.getClass().getName()
           + "\r\n  "
           + tr.getMessage()); // sw.toString());
 }
Esempio n. 5
0
  public void setData(String text) {
    if (text != null && text.length() > 0) {
      InputStream in = null;
      try {
        Object result = null;
        Drawing drawing = createDrawing();
        // Try to read the data using all known input formats.
        for (InputFormat fmt : drawing.getInputFormats()) {
          try {
            fmt.read(in, drawing);
            in = new ByteArrayInputStream(text.getBytes("UTF8"));
            result = drawing;
            break;
          } catch (IOException e) {
            result = e;
          }
        }
        if (result instanceof IOException) {
          throw (IOException) result;
        }

        setDrawing(drawing);
      } catch (Throwable e) {
        getDrawing().removeAllChildren();
        SVGTextFigure tf = new SVGTextFigure();
        tf.setText(e.getMessage());
        tf.setBounds(new Point2D.Double(10, 10), new Point2D.Double(100, 100));
        getDrawing().add(tf);
        e.printStackTrace();
      } finally {
        if (in != null) {
          try {
            in.close();
          } catch (IOException ex) {
            ex.printStackTrace();
          }
        }
      }
    }
  }
 /**
  * Default action when any uncaught exception bubbled from the mouse event handlers of the tools.
  * Subclass may override it to provide other action.
  */
 protected void handleMouseEventException(Throwable t) {
   JOptionPane.showMessageDialog(
       this, t.getClass().getName() + " - " + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
   t.printStackTrace();
 }