private String getCurrentDate() {
   return java.text.DateFormat.getDateInstance(DateFormat.MEDIUM, Locales.getCurrent())
       .format(new java.util.Date());
 }
예제 #2
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jLabel2 = new javax.swing.JLabel();
    lblTitulo = new javax.swing.JLabel();
    jLabel1 = new javax.swing.JLabel();
    descripcion = new javax.swing.JTextField();
    jLabel4 = new javax.swing.JLabel();
    folio = new javax.swing.JTextField();
    jScrollPane1 = new javax.swing.JScrollPane();
    tablaPrincipal = new javax.swing.JTable();
    btnNuevo = new javax.swing.JButton();
    btnImprimir = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    btnCerrar = new javax.swing.JButton();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    almacen = new javax.swing.JTextField();
    tipoMovimiento = new javax.swing.JComboBox();
    txtSumaTotal = new javax.swing.JTextField();
    jLabel8 = new javax.swing.JLabel();
    btnEliminarRenglon = new javax.swing.JButton();
    fecha = new org.jdesktop.swingx.JXDatePicker();
    jLabel3 = new javax.swing.JLabel();

    jLabel2.setText("jLabel2");

    setTitle("Movimiento de almacén");
    getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    lblTitulo.setFont(new java.awt.Font("Arial", 1, 36));
    lblTitulo.setForeground(new java.awt.Color(255, 255, 255));
    lblTitulo.setText("Movimiento de almacén");
    getContentPane()
        .add(lblTitulo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, 40));

    jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
    jLabel1.setForeground(new java.awt.Color(255, 255, 255));
    jLabel1.setText("Descripción:");
    getContentPane()
        .add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, -1, 30));
    getContentPane()
        .add(descripcion, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 90, 600, -1));

    jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12));
    jLabel4.setForeground(new java.awt.Color(255, 255, 255));
    jLabel4.setText("Folio:");
    getContentPane()
        .add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 90, -1, 30));
    getContentPane().add(folio, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 90, 80, -1));

    tablaPrincipal.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
    tablaPrincipal.setModel(
        new javax.swing.table.DefaultTableModel(
            new Object[][] {},
            new String[] {"Código artículo", "Descripción", "Costo", "Cantidad", "Total"}) {
          boolean[] canEdit = new boolean[] {true, false, true, true, false};

          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
          }
        });
    tablaPrincipal.setToolTipText("[ F1 ] catalogo de articulos");
    tablaPrincipal.setCellSelectionEnabled(true);
    tablaPrincipal.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    tablaPrincipal.setGridColor(new java.awt.Color(51, 255, 255));
    tablaPrincipal.setRowHeight(25);
    tablaPrincipal.setShowHorizontalLines(false);
    tablaPrincipal.setSurrendersFocusOnKeystroke(true);
    jScrollPane1.setViewportView(tablaPrincipal);

    getContentPane()
        .add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 820, 280));

    btnNuevo.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/64x64/page_add.png"))); // NOI18N
    btnNuevo.setText("<html><center>Agregar éste movimiento [F5]</center></html>");
    btnNuevo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnNuevoActionPerformed(evt);
          }
        });
    getContentPane()
        .add(btnNuevo, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 440, 190, 60));

    btnImprimir.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/64x64/printer.png"))); // NOI18N
    btnImprimir.setText("<html><center>Imprimir [F8]</center></html>");
    btnImprimir.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnImprimirActionPerformed(evt);
          }
        });
    getContentPane()
        .add(btnImprimir, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 440, 160, 60));

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 30, Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 30, Short.MAX_VALUE));

    getContentPane()
        .add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(810, 480, 30, 30));

    btnCerrar.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/64x64/back.png"))); // NOI18N
    btnCerrar.setText("<HTML>Regresar a almacén [Esc]</HTML>");
    btnCerrar.setRequestFocusEnabled(false);
    btnCerrar.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnCerrarActionPerformed(evt);
          }
        });
    getContentPane()
        .add(btnCerrar, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 10, 230, 40));

    jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));
    jLabel5.setForeground(new java.awt.Color(255, 255, 255));
    jLabel5.setText("Tipo de movimiento:");
    getContentPane()
        .add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 130, 30));

    jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12));
    jLabel6.setForeground(new java.awt.Color(255, 255, 255));
    jLabel6.setText("Fecha:");
    getContentPane()
        .add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(630, 60, 40, 30));

    jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12));
    jLabel7.setForeground(new java.awt.Color(255, 255, 255));
    jLabel7.setText("Almacén [F1]:");
    getContentPane()
        .add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 50, 90, 30));

    almacen.setEditable(false);
    getContentPane()
        .add(almacen, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 60, 190, -1));

    tipoMovimiento.setModel(
        new javax.swing.DefaultComboBoxModel(
            new String[] {"Entrada al almacén", "Salida del almacén", "Ajuste"}));
    getContentPane()
        .add(tipoMovimiento, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 60, 140, -1));
    getContentPane()
        .add(txtSumaTotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 410, 170, -1));

    jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12));
    jLabel8.setForeground(new java.awt.Color(255, 255, 255));
    jLabel8.setText("Total:");
    getContentPane()
        .add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 410, -1, 20));

    btnEliminarRenglon.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/16x16/remove.png"))); // NOI18N
    btnEliminarRenglon.setText("Eliminar renglón seleccionado [F12]");
    btnEliminarRenglon.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnEliminarRenglonActionPerformed(evt);
          }
        });
    getContentPane()
        .add(
            btnEliminarRenglon, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 410, -1, -1));

    fecha.setFormats(java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM));
    getContentPane()
        .add(fecha, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 60, 160, -1));

    jLabel3.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
    jLabel3.setText("[ F1 ] catalogo de articulos");
    getContentPane()
        .add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 410, 190, 20));

    pack();
  } // </editor-fold>//GEN-END:initComponents
예제 #3
0
 private Object createObject(
     Node node, String name, String classPackage, String type, String value, boolean setProperty) {
   Bean parentBean = null;
   if (beansStack.size() > 0) parentBean = (Bean) beansStack.peek();
   Object object = null;
   // param is either an XSD type or a bean,
   // check if it can be converted to an XSD type
   XSDatatype dt = null;
   try {
     dt = DatatypeFactory.getTypeByName(type);
   } catch (DatatypeException dte) {
     // the type is not a valid XSD data type
   }
   // convert null value to default
   if ((dt != null) && (value == null)) {
     Class objType = dt.getJavaObjectType();
     if (objType == String.class) value = "";
     else if ((objType == java.math.BigInteger.class)
         || (objType == Long.class)
         || (objType == Integer.class)
         || (objType == Short.class)
         || (objType == Byte.class)) value = "0";
     else if ((objType == java.math.BigDecimal.class)
         || (objType == Double.class)
         || (objType == Float.class)) value = "0.0";
     else if (objType == Boolean.class) value = "false";
     else if (objType == java.util.Date.class) value = DateUtils.getCurrentDate();
     else if (objType == java.util.Calendar.class) value = DateUtils.getCurrentDateTime();
   }
   //  check whether the type was converted to an XSD datatype
   if ((dt != null) && dt.isValid(value, null)) {
     // create and return an XSD Java object (e.g. String, Integer, Boolean, etc)
     object = dt.createJavaObject(value, null);
     if (object instanceof java.util.Calendar) {
       // check that the object is truly a Calendar
       // because DatatypeFactory converts xsd:date
       // types to GregorianCalendar instead of Date.
       if (type.equals("date")) {
         java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
         try {
           object = df.parse(value);
         } catch (java.text.ParseException pe) {
           object = new java.util.Date();
         }
       }
     }
   } else {
     // Create a bean object
     if (topLevelBean == null) topLevelBean = parentBean;
     object = pushBeanOnStack(classPackage, type);
     // Check fields to see if this property is the 'value' for the object
     Field[] fields = object.getClass().getDeclaredFields();
     for (int i = 0; i < fields.length; i++) {
       if (fields[i].isAnnotationPresent(ObjectXmlAsValue.class)) {
         try {
           StringBuffer fieldName = new StringBuffer(fields[i].getName());
           char c = fieldName.charAt(0);
           if (c >= 'a' && c <= 'z') {
             c += 'A' - 'a';
           }
           fieldName.setCharAt(0, c);
           fieldName.insert(0, "set");
           Method method =
               object
                   .getClass()
                   .getMethod(fieldName.toString(), new Class[] {fields[i].getType()});
           method.invoke(object, value);
           break;
         } catch (Exception e) {
           System.err.println(e.getMessage());
         }
       }
     }
     NamedNodeMap nodeAttrs = node.getAttributes();
     // iterate attributes and set field values for property attributes
     for (int i = 0; i < nodeAttrs.getLength(); i++) {
       String nodePrefix = nodeAttrs.item(i).getPrefix();
       if (nodePrefix.equals(nsPrefix)) {
         String nodeName = nodeAttrs.item(i).getLocalName();
         String nodeValue = nodeAttrs.item(i).getNodeValue();
         try {
           Field field = object.getClass().getDeclaredField(nodeName);
           if (field.isAnnotationPresent(ObjectXmlAsAttribute.class)) {
             StringBuffer fieldName = new StringBuffer(field.getName());
             char c = fieldName.charAt(0);
             if (c >= 'a' && c <= 'z') {
               c += 'A' - 'a';
             }
             fieldName.setCharAt(0, c);
             fieldName.insert(0, "set");
             Method method =
                 object.getClass().getMethod(fieldName.toString(), new Class[] {field.getType()});
             if (field.getType() == String.class) method.invoke(object, nodeValue);
             else if (field.getType() == Boolean.TYPE)
               method.invoke(object, StringUtils.strToBool(nodeValue, "true"));
             else if (field.getType() == Byte.TYPE)
               method.invoke(object, Byte.valueOf(nodeValue).byteValue());
             else if (field.getType() == Character.TYPE)
               method.invoke(object, Character.valueOf(nodeValue.charAt(0)));
             else if (field.getType() == Double.TYPE)
               method.invoke(object, Double.valueOf(nodeValue).doubleValue());
             else if (field.getType() == Float.TYPE)
               method.invoke(object, Float.valueOf(nodeValue).floatValue());
             else if (field.getType() == Integer.TYPE)
               method.invoke(object, Integer.valueOf(nodeValue).intValue());
             else if (field.getType() == Long.TYPE)
               method.invoke(object, Long.valueOf(nodeValue).longValue());
             else if (field.getType() == Short.TYPE)
               method.invoke(object, Short.valueOf(nodeValue).shortValue());
           }
         } catch (Exception e) {
           System.err.println(e.getMessage());
         }
       }
     }
   }
   if ((parentBean != null) && (setProperty)) {
     parentBean.setProperty(name, object);
   }
   return object;
 }
예제 #4
0
  /**
   * over-ridden method, where we write out our data
   *
   * @param theData the data to plot
   * @param out the stream to write to
   * @throws java.io.IOException file-related troubles
   */
  protected final void plotData(MWC.GUI.Layers theData, java.io.BufferedWriter out)
      throws java.io.IOException {

    java.text.DateFormat df = new java.text.SimpleDateFormat("ddHHmm");
    df.setTimeZone(TimeZone.getTimeZone("GMT"));

    // work through the layers
    int num = _theData.size();
    for (int i = 0; i < num; i++) {
      Layer l = (Layer) _theData.elementAt(i);
      Enumeration<Editable> iter = l.elements();
      while (iter.hasMoreElements()) {
        Object oj = iter.nextElement();
        if (oj instanceof Debrief.Wrappers.FixWrapper) {
          Debrief.Wrappers.FixWrapper fw = (Debrief.Wrappers.FixWrapper) oj;
          WorldLocation pos = fw.getLocation();

          if (fw.getSymbolShowing()) {
            String lbl = fw.getName();
            writeBox(out, pos.getLong(), pos.getLat(), pos.getDepth(), fw.getColor(), lbl);
          }

          if (fw.getLabelShowing()) {
            String str = DebriefFormatDateTime.toStringHiRes(fw.getTime());
            writeText(out, pos.getLong(), pos.getLat(), pos.getDepth(), str, fw.getColor());
          }
        }
      }
    }

    // now draw the line connectors
    num = _theData.size();
    for (int i = 0; i < num; i++) {
      Layer l = (Layer) _theData.elementAt(i);
      Enumeration<Editable> iter = l.elements();
      int len = 0;
      while (iter.hasMoreElements()) {
        Object oj = iter.nextElement();

        if (oj instanceof MWC.GenericData.WatchableList) {
          // just check that we haven't got any dangling Fix lines
          // waiting to be finished
          if (len > 0) {
            // we have clearly written some fixes to the file, write the footer
            writeLineFooter(out, len);
            len = 0;
          }

          MWC.GenericData.WatchableList tw = (MWC.GenericData.WatchableList) oj;
          java.awt.Color col = tw.getColor();
          writeLineHeader(out, col);
        }

        if (oj instanceof Debrief.Wrappers.FixWrapper) {
          len++;
          Debrief.Wrappers.FixWrapper fw = (Debrief.Wrappers.FixWrapper) oj;
          WorldLocation pos = fw.getLocation();

          writeLineEntry(out, pos.getLong(), pos.getLat(), pos.getDepth());
        }
      }

      if (len > 0) {
        // we have clearly written some fixes to the file, write the footer
        writeLineFooter(out, len);
      }
    }
  }