private void completePanel() { jlFederationLocaleNiveau.setText(profile.getConfiguration().getLangue()); if (federation == null) return; jtfFederatonSigle.setText(federation.getSigleFederation()); jtfFederatonName.setText(federation.getNomFederation()); ccbCountryFederation.setSelectedCountry(federation.getCodeCountry()); for (CompetitionLevel cl : federation.getCompetitionLevels()) { if (cl.getLang().equals(profile.getConfiguration().getLangue())) { String tmp = ""; // $NON-NLS-1$ if (!jtfFederationNiveau.getText().isEmpty()) tmp = jtfFederationNiveau.getText() + ","; // $NON-NLS-1$ tmp += cl.getLibelle(); jtfFederationNiveau.setText(tmp); } else { if (!mTraduction.containsKey(cl.getLang())) { addLocaleLevelField(cl.getLang()); jcbAvailableLocale.removeItem(new Locale(cl.getLang())); if (jcbAvailableLocale.getItemCount() == 0) { jcbAvailableLocale.setEnabled(false); jbAddLocale.setEnabled(false); } jlAddLocaleInfo.setVisible(true); } String tmp = ""; // $NON-NLS-1$ JTextField tmpTF = mTraduction.get(cl.getLang()); if (!tmpTF.getText().isEmpty()) tmp = tmpTF.getText() + ","; // $NON-NLS-1$ tmp += cl.getLibelle(); tmpTF.setText(tmp); } } }
/* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == jbValider) { if (federation == null) federation = new Federation(jtfFederatonName.getText(), jtfFederatonSigle.getText()); else { federation.setNomFederation(jtfFederatonName.getText()); federation.setSigleFederation(jtfFederatonSigle.getText()); } federation.setCodeCountry( ((Country) ccbCountryFederation.getSelectedItem()).getCode().toLowerCase()); federation.getCompetitionLevels().clear(); boolean first = true; for (String level : jtfFederationNiveau.getText().split(",")) { // $NON-NLS-1$ CompetitionLevel cl = new CompetitionLevel(); cl.setDefaut(first); first = false; cl.setLang(profile.getConfiguration().getLangue()); cl.setLibelle(level); federation.addCompetitionLevel(cl); } for (Entry<String, JTextField> le : mTraduction.entrySet()) { first = true; for (String level : le.getValue().getText().split(",")) { // $NON-NLS-1$ CompetitionLevel cl = new CompetitionLevel(); cl.setDefaut(first); first = false; cl.setLang(le.getKey()); cl.setLibelle(level); federation.addCompetitionLevel(cl); } } try { federation.save(); } catch (ObjectPersistenceException e1) { federation = null; DisplayableErrorHelper.displayException(e1); e1.printStackTrace(); } setVisible(false); } else if (e.getSource() == jbAnnuler) { setVisible(false); } else if (e.getSource() == jbAddLocale) { Locale loc = (Locale) jcbAvailableLocale.getSelectedItem(); addLocaleLevelField(loc.toString()); mTraduction.get(loc.toString()).setText(jtfFederationNiveau.getText()); jcbAvailableLocale.removeItem(loc); if (jcbAvailableLocale.getItemCount() == 0) { jcbAvailableLocale.setEnabled(false); jbAddLocale.setEnabled(false); } jlAddLocaleInfo.setVisible(true); redimDialog(); } }