Example #1
0
  /** Descripción de Método */
  private void loadAttachments() {
    log.config("");

    // Set Text/Description

    String sText = m_attachment.getTextMsg();

    if (sText == null) {
      text.setText("");
    } else {
      text.setText(sText);
    }

    // Set Combo

    int size = m_attachment.getEntryCount();

    for (int i = 0; i < size; i++) {
      cbContent.addItem(m_attachment.getEntryName(i));
    }

    if (size > 0) {
      cbContent.setSelectedIndex(0);
    } else {
      displayData(0);
    }
  } // loadAttachment
Example #2
0
  /** Descripción de Método */
  private void displayLocator() {
    MLocator l = (MLocator) fLocator.getSelectedItem();

    if (l == null) {
      return;
    }

    //

    m_M_Locator_ID = l.getM_Locator_ID();
    fWarehouseInfo.setText(l.getWarehouseName());
    fX.setText(l.getX());
    fY.setText(l.getY());
    fZ.setText(l.getZ());
    fValue.setText(l.getValue());
    getWarehouseInfo(l.getM_Warehouse_ID());

    // Set Warehouse

    int size = fWarehouse.getItemCount();

    for (int i = 0; i < size; i++) {
      KeyNamePair pp = (KeyNamePair) fWarehouse.getItemAt(i);

      if (pp.getKey() == l.getM_Warehouse_ID()) {
        fWarehouse.setSelectedIndex(i);

        continue;
      }
    }
  } // displayLocator
Example #3
0
  /** Descripción de Método */
  private void loadFile() {
    log.info("");

    JFileChooser chooser = new JFileChooser();

    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "AttachmentNew"));

    int returnVal = chooser.showOpenDialog(this);

    if (returnVal != JFileChooser.APPROVE_OPTION) {
      return;
    }

    //

    String fileName = chooser.getSelectedFile().getName();

    log.config(fileName);

    File file = chooser.getSelectedFile();

    if (m_attachment.addEntry(file)) {
      cbContent.addItem(fileName);
      cbContent.setSelectedIndex(cbContent.getItemCount() - 1);
      m_change = true;
    }
  } // getFileName
Example #4
0
  /**
   * Descripción de Método
   *
   * @param index
   * @return
   */
  public String getFileName(int index) {
    String fileName = null;

    if (cbContent.getItemCount() > index) {
      fileName = (String) cbContent.getItemAt(index);
    }

    return fileName;
  } // getFileName
Example #5
0
  /**
   * Descripción de Método
   *
   * @param AD_PrintFormat_ID
   */
  private void fillComboReport(int AD_PrintFormat_ID) {
    comboReport.removeActionListener(this);
    comboReport.removeAllItems();

    KeyNamePair selectValue = null;

    // fill Report Options

    String sql =
        MRole.getDefault()
            .addAccessSQL(
                "SELECT AD_PrintFormat_ID, Name, Description "
                    + "FROM AD_PrintFormat "
                    + "WHERE AD_Table_ID=? AND IsActive='Y' "
                    + "ORDER BY Name",
                "AD_PrintFormat",
                MRole.SQL_NOTQUALIFIED,
                MRole.SQL_RO);
    int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();

    try {
      PreparedStatement pstmt = DB.prepareStatement(sql);

      pstmt.setInt(1, AD_Table_ID);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));

        comboReport.addItem(pp);

        if (rs.getInt(1) == AD_PrintFormat_ID) {
          selectValue = pp;
        }
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "", e);
    }

    StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(m_ctx, "NewReport")).append(" **");
    KeyNamePair pp = new KeyNamePair(-1, sb.toString());

    // comboReport.addItem( pp );

    if (selectValue != null) {
      comboReport.setSelectedItem(selectValue);
    }

    comboReport.addActionListener(this);
  } // fillComboReport
  private final void actionPerformed0(ActionEvent e) throws Exception {
    // Select Instance
    if (e.getSource() == bSelectExistingASI) {
      cmd_select();
      return;
    }
    // New/Edit
    else if (e.getSource() == cbNewEdit) {
      cmd_newEdit();
    }
    // Select Lot from existing
    else if (e.getSource() == fieldLot) {
      final KeyNamePair pp = fieldLot.getSelectedItem();
      if (pp != null && pp.getKey() != -1) {
        fieldLotString.setText(pp.getName());
        fieldLotString.setEditable(false);
        asiTemplate.setM_Lot_ID(pp.getKey());
      } else {
        fieldLotString.setEditable(true);
        asiTemplate.setM_Lot_ID(0);
      }
    }
    // Create New Lot
    else if (e.getSource() == bLot) {
      KeyNamePair pp = asiTemplate.createLot(m_M_Product_ID);
      if (pp != null) {
        fieldLot.addItem(pp);
        fieldLot.setSelectedItem(pp);
      }
    }
    // Create New SerNo
    else if (e.getSource() == bSerNo) {
      fieldSerNo.setText(asiTemplate.getSerNo(true));
    }

    // OK
    else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
      final MAttributeSetInstance asi = saveSelection();
      final int M_Locator_ID = -1; // N/A
      setResultAndDispose(asi, M_Locator_ID);
      return;
    }
    // Cancel
    else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
      final int M_Locator_ID = -1; // N/A
      setResultAndDispose(null, M_Locator_ID);
    }
    // Zoom M_Lot
    else if (e.getSource() == mZoom) {
      cmd_zoom();
    } else {
      log.log(Level.SEVERE, "Unknown event: {0}", e);
    }
  } // actionPerformed
  /** Actualiza el combobox de repositorios */
  public void refresh() {
    // Eliminamos los items actuales y la posibilidad de que salte el evento
    locationsCombo.removeActionListener(this);
    locationsCombo.removeAllItems();

    // Añadimos los repositorios actualizados
    for (URI uri : P2.get().getRepositories()) {
      locationsCombo.addItem(uri);
    }

    locationsCombo.addActionListener(this);
  }
  void dynDepartament() {
    KeyNamePair cat = (KeyNamePair) categoryCombo.getSelectedItem();
    departmentCombo.removeActionListener(this);
    departmentCombo.removeAllItems();

    String sql = "SELECT XX_VMR_DEPARTMENT_ID, VALUE||'-'||NAME " + " FROM XX_VMR_DEPARTMENT ";

    if (cat != null && cat.getKey() != -1) {
      sql += " WHERE XX_VMR_CATEGORY_ID = " + cat.getKey();
    }
    sql += " ORDER BY VALUE||'-'||NAME ";
    sql = MRole.getDefault().addAccessSQL(sql, "", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, null);
      rs = pstmt.executeQuery();

      departmentCombo.addItem(new KeyNamePair(-1, null));
      while (rs.next()) {
        departmentCombo.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
      }
      rs.close();
      pstmt.close();

      departmentCombo.addActionListener(this);
      departmentCombo.setEnabled(true);
      departmentCombo.setEditable(true);
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
  }
Example #9
0
 private void gridOK() {
   int mode = modeCombo.getSelectedIndex();
   //	Create PO
   if (mode == MODE_PO) {
     createPO();
     modeCombo.setSelectedIndex(MODE_VIEW);
     return;
   }
   //	Update Prices
   else if (mode == MODE_PRICE) {
     updatePrices();
     modeCombo.setSelectedIndex(MODE_VIEW);
     return;
   } else if (mode == MODE_VIEW) ;
   m_frame.dispose();
 } //	gridOK
Example #10
0
 /**
  * Get BPartner Contact
  *
  * @return AD_User_ID
  */
 public int getAD_User_ID() {
   if (m_bpartner != null) {
     KeyNamePair pp = (KeyNamePair) f_user.getSelectedItem();
     if (pp != null) return pp.getKey();
   }
   return 0;
 } //	getC_BPartner_Location_ID
  /** Initial table state */
  private void loadBasicInfo() {

    comboCNotifySearch.removeActionListener(this);
    comboBPartner.removeActionListener(this);
    monthCombo.removeAllItems();
    yearField.setDisplayType(0);
    comboBPartner.setEnabled(true);

    comboBPartner.removeAllItems();
    categoryCombo.removeAllItems();
    departmentCombo.removeAllItems();
    agreementTypeCombo.removeAllItems();

    // Llenar los filtros de busquedas
    llenarcombos();
  }
Example #12
0
  /** Descripción de Método */
  private void cmd_drill() {
    m_drillDown = comboDrill.getSelectedIndex() < 1; // -1 or 0

    if (m_drillDown) {
      setCursor(Cursor.getDefaultCursor());
    } else {
      setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
  } // cmd_drill
  private void llenarcombos() {
    dynCategory();
    dynDepartament();

    // Cargar el combo box de mes
    monthCombo.addItem(null);
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_January"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_February"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_March"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_April"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_May"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_June"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_July"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_August"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_September"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_October"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_November"));
    monthCombo.addItem(Msg.translate(Env.getCtx(), "XX_December"));

    // Cargar proveedores
    String sql = "SELECT b.C_BPARTNER_ID, b.NAME FROM C_BPARTNER b WHERE isVendor='Y' ";
    sql = MRole.getDefault().addAccessSQL(sql, "b", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
    sql += " ORDER BY b.NAME";
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {
      pstmt = DB.prepareStatement(sql, null);
      rs = pstmt.executeQuery();
      loadKNP = new KeyNamePair(0, new String());
      comboBPartner.addItem(loadKNP);
      while (rs.next()) {
        loadKNP = new KeyNamePair(rs.getInt(1), rs.getString(2));
        comboBPartner.addItem(loadKNP);
        // comboBPartner.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
      }
      comboBPartner.setEditable(false);
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
  } // fin de llenar combos
Example #14
0
  /** Descripción de Método */
  private void deleteAttachmentEntry() {
    log.info("");

    int index = cbContent.getSelectedIndex();
    String fileName = getFileName(index);

    if (fileName == null) {
      return;
    }

    //

    if (ADialog.ask(m_WindowNo, this, "AttachmentDeleteEntry?", fileName)) {
      if (m_attachment.deleteEntry(index)) {
        cbContent.removeItemAt(index);
      }

      m_change = true;
    }
  } // deleteAttachment
Example #15
0
 /** Fill Combos (Location, User) */
 private void fillCombos() {
   Vector<KeyNamePair> locationVector = new Vector<KeyNamePair>();
   if (m_bpartner != null) {
     MBPartnerLocation[] locations = m_bpartner.getLocations(false);
     for (int i = 0; i < locations.length; i++)
       locationVector.add(
           new KeyNamePair(locations[i].getC_BPartner_Location_ID(), locations[i].getName()));
   }
   DefaultComboBoxModel locationModel = new DefaultComboBoxModel(locationVector);
   f_location.setModel(locationModel);
   //
   Vector<KeyNamePair> userVector = new Vector<KeyNamePair>();
   if (m_bpartner != null) {
     MUser[] users = m_bpartner.getContacts(false);
     for (int i = 0; i < users.length; i++)
       userVector.add(new KeyNamePair(users[i].getAD_User_ID(), users[i].getName()));
   }
   DefaultComboBoxModel userModel = new DefaultComboBoxModel(userVector);
   f_user.setModel(userModel);
 } //	fillCombos
  /** Load table data */
  private void load() {
    // Fill repository IU
    URI location = (URI) locationsCombo.getSelectedItem();
    repoAppsList.clear();
    // Load  Installable units
    repoAppsList.addAll(P2.get().getAllIUnit(location));

    // Fill installed apps
    installedAppsList.clear();
    installedAppsList.addAll(P2.get().getInstalledModel());
  }
Example #17
0
  /** Descripción de Método */
  private void enableNew() {
    boolean sel = fCreateNew.isSelected();

    lWarehouse.setVisible(sel);
    fWarehouse.setVisible(sel);
    lWarehouseInfo.setVisible(!sel);
    fWarehouseInfo.setVisible(!sel);
    fX.setReadWrite(sel);
    fY.setReadWrite(sel);
    fZ.setReadWrite(sel);
    fValue.setReadWrite(sel);
    pack();
  } // enableNew
  // Datos
  void dynCategory() {

    categoryCombo.removeActionListener(this);
    String sql = "SELECT XX_VMR_CATEGORY_ID, VALUE||'-'||NAME " + " FROM XX_VMR_CATEGORY ";
    sql += " ORDER BY VALUE||'-'||NAME ";
    sql = MRole.getDefault().addAccessSQL(sql, "", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, null);
      rs = pstmt.executeQuery();

      categoryCombo.addItem(new KeyNamePair(-1, null));
      while (rs.next()) {
        categoryCombo.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
      }
      categoryCombo.addActionListener(this);
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
  }
Example #19
0
  /** Descripción de Método */
  private void cmd_report() {
    KeyNamePair pp = (KeyNamePair) comboReport.getSelectedItem();

    if (pp == null) {
      return;
    }

    //

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    MPrintFormat pf = null;
    int AD_PrintFormat_ID = pp.getKey();

    // create new

    if (AD_PrintFormat_ID == -1) {
      int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID();

      if (AD_ReportView_ID != 0) {
        String name = m_reportEngine.getName();
        int index = name.lastIndexOf("_");

        if (index != -1) {
          name = name.substring(0, index);
        }

        pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name);
      } else {
        int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();

        pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID);
      }

      if (pf != null) {
        fillComboReport(pf.getID());
      } else {
        return;
      }
    } else {
      pf = MPrintFormat.get(Env.getCtx(), AD_PrintFormat_ID, true);
    }

    m_reportEngine.setPrintFormat(pf);
    revalidate();
    cmd_drill(); // setCursor
  } // cmd_report
Example #20
0
  /** Descripción de Método */
  private void createValue() {

    // Get Warehouse Info

    KeyNamePair pp = (KeyNamePair) fWarehouse.getSelectedItem();

    if (pp == null) {
      return;
    }

    getWarehouseInfo(pp.getKey());

    //

    StringBuffer buf = new StringBuffer(m_M_WarehouseValue);

    buf.append(m_Separator).append(fX.getText());
    buf.append(m_Separator).append(fY.getText());
    buf.append(m_Separator).append(fZ.getText());
    fValue.setText(buf.toString());
  } // createValue
Example #21
0
  /**
   * Descripción de Método
   *
   * @return
   */
  private boolean openAttachment() {
    int index = cbContent.getSelectedIndex();
    byte[] data = m_attachment.getEntryData(index);

    if (data == null) {
      return false;
    }

    try {
      String fileName = System.getProperty("java.io.tmpdir") + m_attachment.getEntryName(index);
      File tempFile = new File(fileName);

      m_attachment.getEntryFile(index, tempFile);

      if (isWindows()) {

        // Runtime.getRuntime().exec ("rundll32 url.dll,FileProtocolHandler " + url);

        Process p =
            Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL \"" + tempFile + "\"");

        // p.waitFor();

        return true;
      } else if (isMac()) {
        String[] cmdArray = new String[] {"open", tempFile.getAbsolutePath()};
        Process p = Runtime.getRuntime().exec(cmdArray);

        // p.waitFor();

        return true;
      } else // other OS
      {
      }
    } catch (Exception e) {
      log.log(Level.SEVERE, "openFile", e);
    }

    return false;
  } // openFile
Example #22
0
  /** Descripción de Método */
  private void saveAttachmentToFile() {
    int index = cbContent.getSelectedIndex();

    log.info("index=" + index);

    if (m_attachment.getEntryCount() < index) {
      return;
    }

    String fileName = getFileName(index);
    String ext = fileName.substring(fileName.lastIndexOf("."));

    log.config("Ext=" + ext);

    JFileChooser chooser = new JFileChooser();

    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "AttachmentSave"));

    File f = new File(fileName);

    chooser.setSelectedFile(f);

    // Show dialog

    int returnVal = chooser.showSaveDialog(this);

    if (returnVal != JFileChooser.APPROVE_OPTION) {
      return;
    }

    File saveFile = chooser.getSelectedFile();

    if (saveFile == null) {
      return;
    }

    log.config("Save to " + saveFile.getAbsolutePath());
    m_attachment.getEntryFile(index, saveFile);
  } // saveAttachmentToFile
  /** Update which fields status (read-only/read-write) based on New ASI/Edit ASI checkbox. */
  private final void cmd_newEdit() {
    final boolean rw = cbNewEdit.isSelected();
    log.config("R/W=" + rw + " " + asiTemplate);

    // Lot
    final boolean isNewLot = asiTemplate == null || asiTemplate.getM_Lot_ID() <= 0;
    fieldLotString.setEditable(rw && isNewLot);
    if (fieldLot != null) {
      fieldLot.setReadWrite(rw);
    }
    bLot.setReadWrite(rw);

    // Serial No
    fieldSerNo.setReadWrite(rw);
    bSerNo.setReadWrite(rw);

    // Guarantee Date
    fieldGuaranteeDate.setReadWrite(rw);

    // Attribute Editors
    for (final CEditor editor : attributeId2editor.values()) {
      editor.setReadWrite(rw);
    }
  } // cmd_newEdit
 /** Zoom M_Lot */
 private void cmd_zoom() {
   int M_Lot_ID = 0;
   KeyNamePair pp = fieldLot.getSelectedItem();
   if (pp != null) M_Lot_ID = pp.getKey();
   MQuery zoomQuery = new MQuery("M_Lot");
   zoomQuery.addRestriction("M_Lot_ID", MQuery.EQUAL, M_Lot_ID);
   log.info(zoomQuery.toString());
   //
   setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   //
   int AD_Window_ID = 257; // Lot
   AWindow frame = new AWindow();
   if (frame.initWindow(AD_Window_ID, zoomQuery)) {
     this.setVisible(false);
     this.setModal(false); // otherwise blocked
     this.setVisible(true);
     AEnv.addToWindowManager(frame);
     AEnv.showScreen(frame, SwingConstants.EAST);
   }
   // async window - not able to get feedback
   frame = null;
   //
   setCursor(Cursor.getDefaultCursor());
 } // cmd_zoom
Example #25
0
  /** OK - check for changes (save them) & Exit */
  private void action_OK() {
    m_location.setAddress1(fAddress1.getText());
    m_location.setAddress2(fAddress2.getText());
    m_location.setAddress3(fAddress3.getText());
    m_location.setAddress4(fAddress4.getText());
    // m_location.setCity(fCity.getText()); Kenos (linha comentada)
    m_location.setPostal(fPostal.getText());
    m_location.setPostal_Add(fPostalAdd.getText());
    //  Country/Region
    MCountry c = (MCountry) fCountry.getSelectedItem();
    m_location.setCountry(c);
    if (m_location.getCountry().isHasRegion()) {
      MRegion r = (MRegion) fRegion.getSelectedItem();
      m_location.setRegion(r);
      m_location.setRegionName(r.getName());
    } else {
      m_location.setC_Region_ID(0);
      m_location.setRegionName(null);
    }

    // BEGIN fernandom @ faire.com.br
    // SET C_City_ID
    if (fCity.getSelectedItem() != null) {
      Object oo = fCity.getSelectedItem();
      if (oo instanceof MCity) {
        MCity city = (MCity) fCity.getSelectedItem();
        m_location.setC_City_ID(city.getC_City_ID());
        m_location.setCity(city.getName());
      } else {
        m_location.setCity((String) fCity.getSelectedItem()); // Kenos
        m_location.setC_City_ID(0);
      }
    }
    // END

    //	Save changes
    m_location.set_TrxName(null);
    m_location.save();
  } //	actionOK
Example #26
0
  /** Descripción de Método */
  private void initLocator() {
    log.fine("");

    // Load Warehouse

    String sql = "SELECT M_Warehouse_ID, Name FROM M_Warehouse";

    if (m_only_Warehouse_ID != 0) {
      sql += " WHERE M_Warehouse_ID=" + m_only_Warehouse_ID;
    }

    String SQL =
        MRole.getDefault().addAccessSQL(sql, "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO)
            + " ORDER BY 2";

    try {
      PreparedStatement pstmt = DB.prepareStatement(SQL);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        fWarehouse.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "warehouse", e);
    }

    log.fine("Warehouses=" + fWarehouse.getItemCount());

    // Load existing Locators

    m_mLocator.fillComboBox(m_mandatory, true, true, false);
    log.fine(m_mLocator.toString());
    fLocator.setModel(m_mLocator);
    fLocator.setValue(m_M_Locator_ID);
    fLocator.addActionListener(this);
    displayLocator();

    //

    fCreateNew.setSelected(false);
    fCreateNew.addActionListener(this);
    enableNew();

    //

    fWarehouse.addActionListener(this);
    fX.addKeyListener(this);
    fY.addKeyListener(this);
    fZ.addKeyListener(this);

    // Guarda el ID de la ubicación con la cual se invocó el constructor
    // de este diálogo. Este ID se utiliza en caso de cancelar el diálogo
    // para recuperar el valor que tenía previamente el ID de ubicación.
    m_OriginalLocatorID = m_M_Locator_ID;

    // Update UI

    pack();
  } // initLocator
Example #27
0
  /**
   * ActionListener
   *
   * @param e ActionEvent
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
      if (fAddress1.isMandatory() && ((((String) fAddress1.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fAddress2.isMandatory() && ((((String) fAddress2.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fAddress3.isMandatory() && ((((String) fAddress3.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else if (fPostal.isMandatory() && ((((String) fPostal.getValue()).trim()).isEmpty()))
        JOptionPane.showMessageDialog(null, "Preencha todos os campos corretamente");
      else {
        action_OK();
        m_change = true;
        dispose();
      }
    } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
      m_change = false;
      dispose();
    } else if (e.getSource() == fCountry) {
      //	Country Changed - display in new Format
      //	Modifier for Mouse selection is 16  - for any key selection 0
      MCountry c = (MCountry) fCountry.getSelectedItem();
      m_location.setCountry(c);
      //	refrseh
      mainPanel.removeAll();
      initLocation();
      fCountry.requestFocus(); // 	allows to use Keybord selection
    }
    // Kenos
    else if (e.getSource() == fRegion) {
      //	Modifier for Mouse selection is 16  - for any key selection 0
      MRegion r = (MRegion) fRegion.getSelectedItem();
      m_location.setRegion(r);
      //	refrseh
      mainPanel.removeAll();
      initLocation();
      fRegion.requestFocus(); // 	allows to use Keybord selection
    }
    // Kenos
    else if (e.getSource() == toLink) {
      String urlString = GOOGLE_MAPS_URL_PREFIX + getGoogleMapsLocation(m_location);
      String message = null;

      try {
        new URL(urlString);
        Env.startBrowser(urlString);
      } catch (Exception ex) {
        message = ex.getMessage();
        ADialog.warn(0, this, "URLnotValid", message);
      }
    } else if (e.getSource() == toRoute) {
      int AD_Org_ID = Env.getAD_Org_ID(Env.getCtx());
      if (AD_Org_ID != 0) {
        MOrgInfo orgInfo = MOrgInfo.get(Env.getCtx(), AD_Org_ID, null);
        MLocation orgLocation = new MLocation(Env.getCtx(), orgInfo.getC_Location_ID(), null);

        String urlString =
            GOOGLE_MAPS_ROUTE_PREFIX
                + GOOGLE_SOURCE_ADDRESS
                + getGoogleMapsLocation(orgLocation)
                + // org
                GOOGLE_DESTINATION_ADDRESS
                + getGoogleMapsLocation(m_location); // partner
        String message = null;
        try {
          new URL(urlString);
          Env.startBrowser(urlString);
        } catch (Exception ex) {
          message = ex.getMessage();
          ADialog.warn(0, this, "URLnotValid", message);
        }
      }
    } else if (e.getSource() == getAddress) {
      if (fPostal != null && !fPostal.getText().equals("")) {
        if (!fAddress1.getText().equals("")
            || !fAddress2.getText().equals("")
            || !fAddress3.getText().equals("")
            || !fAddress4.getText().equals("")
            || fCity.getSelectedIndex() > 0) {
          String warningMsg = "O endereço atual será substituido. Deseja continuar?";
          String warningTitle = "Aviso";
          int response =
              JOptionPane.showConfirmDialog(
                  null, warningMsg, warningTitle, JOptionPane.YES_NO_OPTION);
          if (response == JOptionPane.NO_OPTION) return;
        }

        WebServiceCep cep = WebServiceCep.searchCep(fPostal.getText());
        if (cep.wasSuccessful()) {
          MRegion[] regions = MRegion.getRegions(Env.getCtx(), 139);
          for (MRegion r : regions)
            if (r.getName() != null && r.getName().equals(cep.getUf())) {
              fRegion.setSelectedItem(r);
              break;
            }
          fCity.setSelectedItem(cep.getCidade());
          fAddress1.setText(cep.getLogradouroType() + " " + cep.getLogradouro());
          fAddress3.setText(cep.getBairro());
          if (cep.getCep().length() == 8)
            fPostal.setText(cep.getCep().substring(0, 5) + "-" + cep.getCep().substring(5));
          else fPostal.setText(cep.getCep());
        } else if (cep.getResulCode() == 0)
          JOptionPane.showMessageDialog(null, "CEP não encontrado na base de dados.");
        else if (cep.getResulCode() == 14)
          JOptionPane.showMessageDialog(
              null, "Não foi possível fazer a busca. (Possível problema com a Internet).");
        else JOptionPane.showMessageDialog(null, "Erro ao fazer a busca.");
      } else JOptionPane.showMessageDialog(null, "Preencha o CEP.");
    }
  } //	actionPerformed
Example #28
0
  /** Dynanmic Init & fill fields - Called when Country changes! */
  private void initLocation() {
    // Kenos
    fCity.setPreferredSize(new Dimension(225, 25));
    fCountry.setPreferredSize(new Dimension(225, 25));
    //

    MCountry country = m_location.getCountry();
    log.fine(
        country.getName()
            + ", Region="
            + country.isHasRegion()
            + " "
            + country.getDisplaySequence()
            + ", C_Location_ID="
            + m_location.getC_Location_ID());
    //	new Region
    if (m_location.getC_Country_ID() != s_oldCountry_ID && country.isHasRegion()) {
      fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID()));
      if (m_location.getRegion() != null) fRegion.setSelectedItem(m_location.getRegion());
      /*else
      	if(m_location.getCountry().getC_Country_ID() == 139 && m_location.getAD_Org_ID() != 0){
      		int C_Location_ID = MOrgInfo.get(Env.getCtx(),m_location.getAD_Org_ID()).getC_Location_ID();
      		if (C_Location_ID != 0)
      		{
      			MLocation location =
      				new MLocation(Env.getCtx(), C_Location_ID, null);
      			MRegion region = new MRegion(Env.getCtx(), location.getC_Region_ID(), null);
      			fRegion.setSelectedItem(region);
      			m_location.setRegion(region);
      			//	refrseh
      			fRegion.requestFocus();	//	allows to use Keybord selection
      		}
      	}
      */
      // Kenos
      fRegion.addActionListener(this);
      //
      lRegion.setText(country.getRegionName());
      s_oldCountry_ID = m_location.getC_Country_ID();
    }
    // Kenos// Faire
    if (m_location.getCountry().isHasRegion()
        && m_location.getRegion() != null
        && m_location.getCountry().getC_Country_ID() == 139) // 139 = Brasil
    {
      fCity.setEditable(false);
      fCity.removeAllItems();
      fCity = new CComboBox(getCCity());
      if (m_location.getC_City_ID() != 0)
        fCity.setSelectedItem(new MCity(Env.getCtx(), m_location.getC_City_ID(), null));
    } else {
      fCity.removeAllItems();
      fCity.setEditable(true);
      fCity.setSelectedItem(m_location.getCity());
    }
    // Kenos

    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.gridy = 0; // 	line
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.insets = fieldInsets;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0;
    gbc.weighty = 0;

    mainPanel.add(Box.createVerticalStrut(5), gbc); // 	top gap

    int line = 1;
    addLine(line++, lAddress1, fAddress1);
    addLine(line++, lAddress2, fAddress2);
    addLine(line++, lAddress3, fAddress3);
    addLine(line++, lAddress4, fAddress4);

    //  sequence of City Postal Region - @P@ @C@ - @C@, @R@ @P@
    String ds = country.getDisplaySequence();
    if (ds == null || ds.length() == 0) {
      log.log(Level.SEVERE, "DisplaySequence empty - " + country);
      ds = ""; // 	@C@,  @P@
    }
    StringTokenizer st = new StringTokenizer(ds, "@", false);
    while (st.hasMoreTokens()) {
      String s = st.nextToken();
      if (s.startsWith("C")) addLine(line++, lCity, fCity);
      else if (s.startsWith("P")) addLine(line++, lPostal, fPostal);
      else if (s.startsWith("A")) addLine(line++, lPostalAdd, fPostalAdd);
      else if (s.startsWith("R") && m_location.getCountry().isHasRegion())
        addLine(line++, lRegion, fRegion);
    }
    //  Country Last
    addLine(line++, lCountry, fCountry);

    //	Fill it
    if (m_location.getC_Location_ID() != 0) {
      fAddress1.setText(m_location.getAddress1());
      fAddress2.setText(m_location.getAddress2());
      fAddress3.setText(m_location.getAddress3());
      fAddress4.setText(m_location.getAddress4());
      // fCity.setText(m_location.getCity()); - Kenos (linha comentada)
      fPostal.setText(m_location.getPostal());
      fPostalAdd.setText(m_location.getPostal_Add());
      if (m_location.getCountry().isHasRegion()) {
        lRegion.setText(m_location.getCountry().getRegionName());
        fRegion.setSelectedItem(m_location.getRegion());
      }
      fCountry.setSelectedItem(country);
    }

    //	Update UI
    pack();
  } //	initLocation
Example #29
0
  /** Descripción de Método */
  private void actionOK() {
    if (fCreateNew.isSelected()) {

      // Get Warehouse Info

      KeyNamePair pp = (KeyNamePair) fWarehouse.getSelectedItem();

      if (pp != null) {
        getWarehouseInfo(pp.getKey());
      }

      // Check mandatory values

      String mandatoryFields = "";

      if (m_M_Warehouse_ID == 0) {
        mandatoryFields += lWarehouse.getText() + " - ";
      }

      if (fValue.getText().length() == 0) {
        mandatoryFields += lValue.getText() + " - ";
      }

      if (fX.getText().length() == 0) {
        mandatoryFields += lX.getText() + " - ";
      }

      if (fY.getText().length() == 0) {
        mandatoryFields += lY.getText() + " - ";
      }

      if (fZ.getText().length() == 0) {
        mandatoryFields += lZ.getText() + " - ";
      }

      if (mandatoryFields.length() != 0) {
        ADialog.error(
            m_WindowNo,
            this,
            "FillMandatory",
            mandatoryFields.substring(0, mandatoryFields.length() - 3));

        return;
      }

      MLocator loc =
          MLocator.get(
              Env.getCtx(),
              m_M_Warehouse_ID,
              fValue.getText(),
              fX.getText(),
              fY.getText(),
              fZ.getText());

      m_M_Locator_ID = loc.getM_Locator_ID();
      fLocator.addItem(loc);
      fLocator.setSelectedItem(loc);
    } // createNew

    //

    log.config("M_Locator_ID=" + m_M_Locator_ID);
  } // actionOK
Example #30
0
  /**
   * Descripción de Método
   *
   * @param e
   */
  public void actionPerformed(ActionEvent e) {

    // log.config( "Attachment.actionPerformed - " + e.getActionCommand());
    // Save and Close

    if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
      String newText = text.getText();

      if (newText == null) {
        newText = "";
      }

      String oldText = m_attachment.getTextMsg();

      if (oldText == null) {
        oldText = "";
      }

      if (!m_change) {
        m_change = !newText.equals(oldText);
      }

      if ((newText.length() > 0) || (m_attachment.getEntryCount() > 0)) {
        if (m_change) {
          // m_attachment.setTextMsg( text.getText());
          log.fine("Justo antes de guardar el registro, D_file_id=" + d_file_id);
          //	m_attachment.setD_File_Archive_ID(d_file_archive_id);
          m_attachment.setUploadedBy(Env.getContextAsInt(Env.getCtx(), "UploadedBy"));
          //	m_attachment.setD_File_ID(d_file_id);
          m_attachment.save();
        }
      } else {
        m_attachment.delete(true);
      }

      dispose();
    }

    // Cancel

    else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
      dispose();
    }

    // Delete Attachment

    else if (e.getSource() == bDeleteAll) {
      deleteAttachment();
      dispose();
    }

    // Delete individual entry and Return

    else if (e.getSource() == bDelete) {
      deleteAttachmentEntry();

      // Show Data

    } else if (e.getSource() == cbContent) {
      displayData(cbContent.getSelectedIndex());

      // Load Attachment

    } else if (e.getSource() == bLoad) {
      loadFile();

      // Open Attachment

    } else if (e.getSource() == bSave) {
      saveAttachmentToFile();

      // Open Attachment

    } else if (e.getSource() == bOpen) {
      if (!openAttachment()) {
        saveAttachmentToFile();
      }
    }
  } // actionPerformed