Ejemplo n.º 1
0
  /**
   * Constructor
   *
   * @param frame parent
   * @param title title (field name)
   * @param location Model Location
   */
  public VLocationDialog(Frame frame, String title, MLocation location) {
    super(frame, title, true);
    try {
      jbInit();
    } catch (Exception ex) {
      log.log(Level.SEVERE, ex.getMessage());
    }
    m_location = location;
    if (m_location == null) {
      m_location = m_tempLocation;
    }

    //	Overwrite title
    if (m_location.getC_Location_ID() == 0) setTitle(Msg.getMsg(Env.getCtx(), "LocationNew"));
    else setTitle(Msg.getMsg(Env.getCtx(), "LocationUpdate"));

    //	Current Country
    // MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx()));
    fCountry = new CComboBox(MCountry.getCountries(Env.getCtx()));
    fCountry.setSelectedItem(m_location.getCountry());
    m_origCountry_ID = m_location.getC_Country_ID();
    //	Current Region
    fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), m_origCountry_ID));
    if (m_location.getCountry().isHasRegion())
      lRegion.setText(m_location.getCountry().getRegionName()); // 	name for region
    fRegion.setSelectedItem(m_location.getRegion());

    // Kenos - Faire
    //	Current City
    if (m_location.getC_Region_ID() != 0) {
      fCity = new CComboBox(getCCity());
      fCity.setSelectedItem(new MCity(Env.getCtx(), m_location.getC_City_ID(), null));
    } else fCity = new CComboBox();

    //
    initLocation();
    fCountry.addActionListener(this);
    // Kenos
    fRegion.addActionListener(this);
    //
    AEnv.positionCenterWindow(frame, this);
  } //	VLocationDialog
Ejemplo n.º 2
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