List of usage examples for javax.swing JTextField getText
public String getText()
TextComponent
. From source file:org.languagetool.gui.ConfigurationDialog.java
private void createOfficeElements(GridBagConstraints cons, JPanel portPanel) { int numParaCheck = config.getNumParasToCheck(); JRadioButton[] radioButtons = new JRadioButton[3]; ButtonGroup numParaGroup = new ButtonGroup(); radioButtons[0] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckOnlyParagraph"))); radioButtons[0].setActionCommand("ParagraphCheck"); radioButtons[1] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckFullText"))); radioButtons[1].setActionCommand("FullTextCheck"); radioButtons[2] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckNumParagraphs"))); radioButtons[2].setActionCommand("NParagraphCheck"); radioButtons[2].setSelected(true);//ww w . j a v a2s . co m JTextField numParaField = new JTextField(Integer.toString(5), 2); numParaField.setEnabled(radioButtons[2].isSelected()); numParaField.setMinimumSize(new Dimension(30, 25)); for (int i = 0; i < 3; i++) { numParaGroup.add(radioButtons[i]); } if (numParaCheck == 0) { radioButtons[0].setSelected(true); numParaField.setEnabled(false); } else if (numParaCheck < 0) { radioButtons[1].setSelected(true); numParaField.setEnabled(false); } else { radioButtons[2].setSelected(true); numParaField.setText(Integer.toString(numParaCheck)); numParaField.setEnabled(true); } radioButtons[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { numParaField.setEnabled(false); config.setNumParasToCheck(0); } }); radioButtons[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { numParaField.setEnabled(false); config.setNumParasToCheck(-1); } }); radioButtons[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int numParaCheck = Integer.parseInt(numParaField.getText()); if (numParaCheck < 1) numParaCheck = 1; else if (numParaCheck > 99) numParaCheck = 99; config.setNumParasToCheck(numParaCheck); numParaField.setForeground(Color.BLACK); numParaField.setText(Integer.toString(numParaCheck)); numParaField.setEnabled(true); } }); numParaField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void removeUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { try { int numParaCheck = Integer.parseInt(numParaField.getText()); if (numParaCheck > 0 && numParaCheck < 99) { numParaField.setForeground(Color.BLACK); config.setNumParasToCheck(numParaCheck); } else { numParaField.setForeground(Color.RED); } } catch (NumberFormatException ex) { numParaField.setForeground(Color.RED); } } }); JLabel textChangedLabel = new JLabel(Tools.getLabel(messages.getString("guiTextChangeLabel"))); cons.gridy++; portPanel.add(textChangedLabel, cons); cons.gridy++; cons.insets = new Insets(0, 30, 0, 0); for (int i = 0; i < 3; i++) { portPanel.add(radioButtons[i], cons); if (i < 2) cons.gridy++; } cons.gridx = 1; portPanel.add(numParaField, cons); JCheckBox noMultiResetbox = new JCheckBox(Tools.getLabel(messages.getString("guiNoMultiReset"))); noMultiResetbox.setSelected(config.isNoMultiReset()); noMultiResetbox.setEnabled(config.isResetCheck()); noMultiResetbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setNoMultiReset(noMultiResetbox.isSelected()); } }); JCheckBox resetCheckbox = new JCheckBox(Tools.getLabel(messages.getString("guiDoResetCheck"))); resetCheckbox.setSelected(config.isResetCheck()); resetCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setDoResetCheck(resetCheckbox.isSelected()); noMultiResetbox.setEnabled(resetCheckbox.isSelected()); } }); cons.insets = new Insets(0, 4, 0, 0); cons.gridx = 0; // JLabel dummyLabel = new JLabel(" "); // cons.gridy++; // portPanel.add(dummyLabel, cons); cons.gridy++; portPanel.add(resetCheckbox, cons); cons.insets = new Insets(0, 30, 0, 0); cons.gridx = 0; cons.gridy++; portPanel.add(noMultiResetbox, cons); JCheckBox fullTextCheckAtFirstBox = new JCheckBox( Tools.getLabel(messages.getString("guiCheckFullTextAtFirst"))); fullTextCheckAtFirstBox.setSelected(config.doFullCheckAtFirst()); fullTextCheckAtFirstBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setFullCheckAtFirst(fullTextCheckAtFirstBox.isSelected()); } }); cons.insets = new Insets(0, 4, 0, 0); cons.gridx = 0; // cons.gridy++; // JLabel dummyLabel2 = new JLabel(" "); // portPanel.add(dummyLabel2, cons); cons.gridy++; portPanel.add(fullTextCheckAtFirstBox, cons); JCheckBox isMultiThreadBox = new JCheckBox(Tools.getLabel(messages.getString("guiIsMultiThread"))); isMultiThreadBox.setSelected(config.isMultiThread()); isMultiThreadBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setMultiThreadLO(isMultiThreadBox.isSelected()); } }); cons.gridy++; JLabel dummyLabel3 = new JLabel(" "); portPanel.add(dummyLabel3, cons); cons.gridy++; portPanel.add(isMultiThreadBox, cons); }
From source file:org.languagetool.gui.ConfigurationDialog.java
private JPanel getSpecialRuleValuePanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints cons = new GridBagConstraints(); cons.gridx = 0;/* w w w . j av a 2s.c om*/ cons.gridy = 0; cons.weightx = 0.0f; cons.anchor = GridBagConstraints.WEST; List<JCheckBox> ruleCheckboxes = new ArrayList<JCheckBox>(); List<JLabel> ruleLabels = new ArrayList<JLabel>(); List<JTextField> ruleValueFields = new ArrayList<JTextField>(); for (int i = 0; i < configurableRules.size(); i++) { Rule rule = configurableRules.get(i); JCheckBox ruleCheckbox = new JCheckBox(rule.getDescription()); ruleCheckboxes.add(ruleCheckbox); ruleCheckbox.setSelected(getEnabledState(rule)); cons.insets = new Insets(3, 0, 0, 0); panel.add(ruleCheckbox, cons); cons.insets = new Insets(0, 24, 0, 0); cons.gridy++; JLabel ruleLabel = new JLabel(rule.getConfigureText()); ruleLabels.add(ruleLabel); ruleLabel.setEnabled(ruleCheckbox.isSelected()); panel.add(ruleLabel, cons); cons.gridx++; int value = config.getConfigurableValue(rule.getId()); if (config.getConfigurableValue(rule.getId()) < 0) { value = rule.getDefaultValue(); } JTextField ruleValueField = new JTextField(Integer.toString(value), 2); ruleValueFields.add(ruleValueField); ruleValueField.setEnabled(ruleCheckbox.isSelected()); ruleValueField.setMinimumSize(new Dimension(35, 25)); // without this the box is just a few pixels small, but why? panel.add(ruleValueField, cons); ruleCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { ruleValueField.setEnabled(ruleCheckbox.isSelected()); ruleLabel.setEnabled(ruleCheckbox.isSelected()); if (ruleCheckbox.isSelected()) { config.getEnabledRuleIds().add(rule.getId()); config.getDisabledRuleIds().remove(rule.getId()); } else { config.getEnabledRuleIds().remove(rule.getId()); config.getDisabledRuleIds().add(rule.getId()); } } }); ruleValueField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void removeUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { try { int num = Integer.parseInt(ruleValueField.getText()); if (num < rule.getMinConfigurableValue()) { num = rule.getMinConfigurableValue(); ruleValueField.setForeground(Color.RED); } else if (num > rule.getMaxConfigurableValue()) { num = rule.getMaxConfigurableValue(); ruleValueField.setForeground(Color.RED); } else { ruleValueField.setForeground(null); } config.setConfigurableValue(rule.getId(), num); } catch (Exception ex) { ruleValueField.setForeground(Color.RED); } } }); cons.gridx = 0; cons.gridy++; } return panel; }
From source file:org.metawidget.swing.widgetprocessor.binding.beanutils.BeanUtilsBindingProcessorTest.java
public void testScalaBinding() throws Exception { // Model//from w w w .ja va2s.com Date dateFirst = new GregorianCalendar(1975, Calendar.APRIL, 9).getTime(); ScalaFoo scalaFoo = new ScalaFoo(); scalaFoo.bar_$eq(dateFirst); ScalaFoo scalaFoo2 = new ScalaFoo(); scalaFoo.nestedFoo = scalaFoo2; ScalaFoo scalaFoo3 = new ScalaFoo(); scalaFoo2.nestedFoo = scalaFoo3; scalaFoo3.bar_$eq(new GregorianCalendar(1976, Calendar.MAY, 16).getTime()); // BeanUtilsBinding ConvertUtils.register(new DateConverter(DATE_FORMAT), Date.class); // Inspect SwingMetawidget metawidget = new SwingMetawidget(); metawidget.addWidgetProcessor(new BeanUtilsBindingProcessor( new BeanUtilsBindingProcessorConfig().setPropertyStyle(new ScalaPropertyStyle()))); BaseObjectInspectorConfig config = new BaseObjectInspectorConfig() .setPropertyStyle(new ScalaPropertyStyle()); metawidget.setInspector(new PropertyTypeInspector(config)); metawidget.setToInspect(scalaFoo); // Loading JTextField textField = (JTextField) metawidget.getComponent(1); DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); assertEquals(dateFormat.format(dateFirst), textField.getText()); JLabel label = (JLabel) metawidget.getComponent(5); assertEquals("Not settable", label.getText()); JTextField nestedTextField = (JTextField) ((SwingMetawidget) metawidget.getComponent(3)).getComponent(1); assertEquals("", nestedTextField.getText()); JTextField nestedNestedTextField = (JTextField) ((SwingMetawidget) ((SwingMetawidget) metawidget .getComponent(3)).getComponent(3)).getComponent(1); assertEquals(dateFormat.format(scalaFoo3.bar()), nestedNestedTextField.getText()); // Saving Date dateSecond = new GregorianCalendar(1976, Calendar.MAY, 10).getTime(); textField.setText(dateFormat.format(dateSecond)); nestedNestedTextField.setText(dateFormat.format(new GregorianCalendar(1977, Calendar.JUNE, 17).getTime())); metawidget.getWidgetProcessor(BeanUtilsBindingProcessor.class).save(metawidget); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(scalaFoo.bar()); assertEquals(1976, calendar.get(Calendar.YEAR)); assertEquals(null, scalaFoo2.bar()); calendar.setTime(scalaFoo3.bar()); assertEquals(1977, calendar.get(Calendar.YEAR)); // Rebinding textField = (JTextField) metawidget.getComponent(1); assertEquals(dateFormat.format(dateSecond), textField.getText()); scalaFoo.bar_$eq(dateFirst); metawidget.getWidgetProcessor(BeanUtilsBindingProcessor.class).rebind(scalaFoo, metawidget); textField = (JTextField) metawidget.getComponent(1); assertEquals(dateFormat.format(dateFirst), textField.getText()); }
From source file:org.olivier.ihm.FramePUMLCleanerControler.java
/** * Slectionner un fichier PUML/* www. j a v a2 s . c o m*/ * * @param jTextFieldFichier le composant contenant le nom du fichier PUML en * cours d'utilisation */ public void selectInputFile(JTextField jTextFieldFichier) { final File fichier = new File(jTextFieldFichier.getText()); if (fichier.exists()) { fileChooser.setCurrentDirectory(fichier.getParentFile()); } fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileFilter(pumlFilter); fileChooser.addChoosableFileFilter(pumlFilter); fileChooser.setDialogTitle("Choisir un fichier PUML ..."); final int returnVal = fileChooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { final File file = fileChooser.getSelectedFile(); if (file.exists()) { jTextFieldFichier.setText(file.getPath()); myProperties.setProperty(nomFichierPropertie, jTextFieldFichier.getText()); } } }
From source file:org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private Icon iconWarning = ImageIconWarning.getInstance(); public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); Set<Class<? extends SQLElement>> s = map.keySet(); final ArrayList<Class<? extends SQLElement>> list = new ArrayList<Class<? extends SQLElement>>(s); Collections.sort(list, new Comparator<Class<? extends SQLElement>>() { public int compare(Class<? extends SQLElement> o1, Class<? extends SQLElement> o2) { return o1.getSimpleName().toString().compareTo(o2.getSimpleName().toString()); };/*from www . j a va 2 s.c om*/ }); List<String> added = new ArrayList<String>(); for (Class<? extends SQLElement> class1 : list) { String prefix = map.get(class1); if (!added.contains(prefix)) { c.gridy++; c.gridx = 0; c.weightx = 0; added.add(prefix); SQLElement elt = Configuration.getInstance().getDirectory().getElement(class1); if (elt == null) { throw new IllegalArgumentException("Element null for class " + class1); } // Avoir JLabel labelAvoirFormat = new JLabel( StringUtils.firstUp(elt.getPluralName()) + " " + getLabelFor(prefix + FORMAT), SwingConstants.RIGHT); this.add(labelAvoirFormat, c); c.gridx++; c.weightx = 1; final JTextField fieldFormat = new JTextField(); this.add(fieldFormat, c); final JLabel labelAvoirStart = new JLabel(getLabelFor(prefix + START)); c.gridx++; c.weightx = 0; this.add(labelAvoirStart, c); c.gridx++; c.weightx = 1; final JTextField fieldStart = new JTextField(); this.add(fieldStart, c); final JLabel labelResult = new JLabel(); c.gridx++; c.weightx = 0; this.add(labelResult, c); if (getTable().getFieldsName().contains(prefix + AUTO_MONTH)) { final JCheckBox boxAuto = new JCheckBox(getLabelFor(prefix + AUTO_MONTH)); c.gridx++; c.weightx = 0; this.add(boxAuto, c); this.addSQLObject(boxAuto, prefix + AUTO_MONTH); } // Affichage dynamique du rsultat SimpleDocumentListener listener = new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { updateLabel(fieldStart, fieldFormat, labelResult); } }; fieldFormat.getDocument().addDocumentListener(listener); fieldStart.getDocument().addDocumentListener(listener); this.addRequiredSQLObject(fieldFormat, prefix + FORMAT); this.addRequiredSQLObject(fieldStart, prefix + START); } } // JLabel labelCodeLettrage = new JLabel(getLabelFor("CODE_LETTRAGE")); // c.gridy++; // c.gridx = 0; // c.weightx = 0; // this.add(labelCodeLettrage, c); // c.gridx++; // c.weightx = 1; // this.add(this.textCodeLettrage, c); // // c.gridx++; // c.weightx = 0; // labelNextCodeLettrage = new JLabel(); // this.add(labelNextCodeLettrage, c); JLabel labelExemple = new JLabel("Exemple de format : 'Fact'yyyy0000"); c.gridy++; c.gridx = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 1; c.anchor = GridBagConstraints.NORTHWEST; this.add(labelExemple, c); // this.textCodeLettrage.getDocument().addDocumentListener(this.listenText); } // private void updateLabelNextCode() { // String s = getNextCodeLetrrage(this.textCodeLettrage.getText()); // this.labelNextCodeLettrage.setText(donne + " " + s); // } private void updateLabel(JTextField textStart, JTextField textFormat, JLabel label) { if (textStart.getText().trim().length() > 0) { try { String numProposition = getNextNumero(textFormat.getText(), Integer.parseInt(textStart.getText()), new Date()); if (numProposition != null) { label.setText(" --> " + numProposition); label.setIcon(null); } else { label.setIcon(this.iconWarning); label.setText(""); } } catch (IllegalArgumentException e) { JOptionPane.showMessageDialog(null, "Le format " + textFormat.getText() + " n'est pas valide!"); } } else { label.setIcon(this.iconWarning); label.setText(""); } } }; }
From source file:org.openconcerto.erp.core.common.ui.DeviseField.java
public static void addFilteringKeyListener(final JTextField textField) { textField.addKeyListener(new KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent keyEvent) { final char keychar = keyEvent.getKeyChar(); if (keychar == KeyEvent.VK_BACK_SPACE) { return; }//from w w w. j ava 2 s . co m // pas plus de 2 chiffres apres la virgule int pointPosition = textField.getText().indexOf('.'); if (Character.isDigit(keychar)) { if (pointPosition > -1) { // System.err.println("Text Selected :: " + textField.getSelectedText()); if (textField.getSelectedText() == null) { if (textField.getCaretPosition() <= pointPosition) { return; } else { if (textField.getText().substring(pointPosition).length() <= 2) { return; } } } else { return; } } else { return; } } if (keychar == KeyEvent.VK_PERIOD && textField.getText().indexOf('.') < 0) return; // if (keychar == KeyEvent.VK_MINUS && (textField.getText().indexOf('-') < 0) && // textField.getCaretPosition() == 0) // return; keyEvent.consume(); } }); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.ClotureMensuellePayePanel.java
public ClotureMensuellePayePanel() { super();/*www. j a v a2 s . c o m*/ this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(2, 2, 1, 2); c.weightx = 0; c.weighty = 0; c.gridheight = 1; c.gridwidth = 1; c.gridx = 0; c.gridy = 0; JLabel labelMois = new JLabel("Cloture du mois de "); this.add(labelMois, c); final ElementComboBox selMois = new ElementComboBox(true, 25); selMois.init(((ComptaPropsConfiguration) Configuration.getInstance()).getDirectory() .getElement(MoisSQLElement.class)); selMois.setButtonsVisible(false); c.gridx++; this.add(selMois, c); JLabel labelAnnee = new JLabel("Anne"); c.gridx++; this.add(labelAnnee, c); final JTextField textAnnee = new JTextField(5); c.gridx++; this.add(textAnnee, c); DateFormat format = new SimpleDateFormat("yyyy"); textAnnee.setText(format.format(new Date())); c.gridy++; c.gridx = 0; final JCheckBox boxValid = new JCheckBox("Valider toutes les payes du mois"); final JCheckBox boxCompta = new JCheckBox("Gnrer les critures comptables associes"); c.gridwidth = GridBagConstraints.REMAINDER; this.add(boxValid, c); boxValid.setSelected(true); c.gridy++; this.add(boxCompta, c); JButton buttonClot = new JButton("Clturer"); JButton buttonFermer = new JButton("Fermer"); JPanel panelButton = new JPanel(); panelButton.add(buttonClot); panelButton.add(buttonFermer); c.anchor = GridBagConstraints.SOUTHEAST; c.fill = GridBagConstraints.NONE; c.weighty = 1; c.gridy++; this.add(panelButton, c); buttonFermer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(ClotureMensuellePayePanel.this)).dispose(); } }); buttonClot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Valider les fiches non valids des salaris actifs if (boxValid.isSelected()) { SQLSelect selFiche = new SQLSelect(); SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE"); SQLTable tableSalarie = ClotureMensuellePayePanel.this.base.getTable("SALARIE"); SQLTable tableInfosSal = ClotureMensuellePayePanel.this.base.getTable("INFOS_SALARIE_PAYE"); selFiche.addSelect(tableFiche.getField("ID")); selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.FALSE)); selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId())); selFiche.andWhere( new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText()))); selFiche.andWhere( new Where(tableSalarie.getField("ID"), "=", tableFiche.getField("ID_SALARIE"))); selFiche.andWhere(new Where(tableInfosSal.getField("ID"), "=", tableSalarie.getField("ID_INFOS_SALARIE_PAYE"))); // FIXME ne pas valider les fiches d'un employ renvoy // Where w2 = new Where(tableInfosSal.getField("DATE_SORTIE"), "IS", // "NULL"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DATE, 1); cal.set(Calendar.MONTH, selMois.getSelectedId() - 2); cal.set(Calendar.YEAR, Integer.parseInt(textAnnee.getText())); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Where w = new Where(tableInfosSal.getField("DATE_SORTIE"), "<=", cal.getTime()); w = w.or(new Where(tableInfosSal.getField("DATE_SORTIE"), "=", (Object) null)); selFiche.andWhere(w); String req = selFiche.asString(); System.err.println(req); List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req, new ArrayListHandler()); for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); SQLRow rowFicheTmp = tableFiche.getRow(Integer.parseInt(tmp[0].toString())); System.err.println(rowFicheTmp); FichePayeSQLElement.validationFiche(rowFicheTmp.getID()); } } // cloture du mois et generation compta SQLSelect selFiche = new SQLSelect(ClotureMensuellePayePanel.this.base); SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE"); SQLTable tableMois = ClotureMensuellePayePanel.this.base.getTable("MOIS"); selFiche.addSelect(tableFiche.getField("ID")); selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.TRUE)); selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId())); selFiche.andWhere( new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText()))); String req = selFiche.asString(); List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req, new ArrayListHandler()); if (l != null && l.size() > 0) { int[] idS = new int[l.size()]; SQLRow rowMois = tableMois.getRow(selMois.getSelectedId()); for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); idS[i] = Integer.parseInt(tmp[0].toString()); SQLRow rowFiche = tableFiche.getRow(idS[i]); FichePayeSQLElement.clotureMensuelle(selMois.getSelectedId(), Integer.parseInt(textAnnee.getText()), rowFiche.getInt("ID_SALARIE")); } if (boxCompta.isSelected()) { new GenerationMvtFichePaye(idS, rowMois.getString("NOM"), textAnnee.getText()); } } System.err.println( "ClotureMensuellePayePanel.ClotureMensuellePayePanel().new ActionListener() {...}.actionPerformed()"); JOptionPane.showMessageDialog(null, "Clture termine"); } catch (Exception ex) { ExceptionHandler.handle("Unable to complete operation", ex); } } }); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java
/** * Returns <code>true</code> if data to save, <code>false</code> * otherwise.// ww w.j ava 2 s. co m * * @return See above. */ boolean hasDataToSave() { saveButton.setEnabled(false); String text = loginArea.getText(); if (StringUtils.isBlank(text)) return false; text = text.trim(); ExperimenterData original = (ExperimenterData) model.getRefObject(); if (!text.equals(original.getUserName())) { saveButton.setEnabled(true); return true; } //if (selectedIndex != originalIndex) return true; if (details == null) return false; Entry<String, String> entry; Iterator<Entry<String, String>> i = details.entrySet().iterator(); String key; String value; JTextField field; String v; if (items.size() > 0) { i = details.entrySet().iterator(); while (i.hasNext()) { entry = i.next(); key = entry.getKey(); field = items.get(key); if (field != null) { v = field.getText(); if (StringUtils.isBlank(v)) { if (EditorUtil.FIRST_NAME.equals(key) || EditorUtil.LAST_NAME.equals(key)) { return false; } } } } i = details.entrySet().iterator(); while (i.hasNext()) { entry = i.next(); key = entry.getKey(); field = items.get(key); if (field != null) { v = field.getText(); if (v != null) { v = v.trim(); value = (String) entry.getValue(); if (value == null) value = ""; if (!v.equals(value)) { saveButton.setEnabled(true); return true; } } } } } Boolean b = ownerBox.isSelected(); if (b.compareTo(groupOwner) != 0) { saveButton.setEnabled(true); return true; } if (adminBox.isVisible()) { b = adminBox.isSelected(); if (b.compareTo(admin) != 0) { saveButton.setEnabled(true); return true; } } if (activeBox.isVisible()) { b = activeBox.isSelected(); if (b.compareTo(active) != 0) { saveButton.setEnabled(true); return true; } } return false; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java
/** * Returns the experimenter to save./* w w w . j a v a 2s .c om*/ * * @return See above. */ Object getExperimenterToSave() { ExperimenterData original = (ExperimenterData) model.getRefObject(); //Required fields first String v = loginArea.getText(); if (v == null || v.trim().length() == 0) showRequiredField(); JTextField f = items.get(EditorUtil.EMAIL); v = f.getText(); if (v == null || v.trim().length() == 0) v = ""; original.setEmail(v); f = items.get(EditorUtil.INSTITUTION); v = f.getText(); if (v == null) v = ""; original.setInstitution(v.trim()); f = items.get(EditorUtil.LAST_NAME); v = f.getText(); if (v == null) v = ""; original.setLastName(v.trim()); f = items.get(EditorUtil.FIRST_NAME); v = f.getText(); if (v == null) v = ""; original.setFirstName(v.trim()); f = items.get(EditorUtil.MIDDLE_NAME); v = f.getText(); if (v == null) v = ""; original.setMiddleName(v.trim()); //set the groups GroupData g = null; String value = loginArea.getText().trim(); UserCredentials uc = new UserCredentials(value, ""); Boolean b = ownerBox.isSelected(); boolean a = false; if (b.compareTo(groupOwner) != 0) { a = true; uc.setOwner(b); Object parent = model.getParentRootObject(); if (parent instanceof GroupData) { Map<GroupData, Boolean> map = new HashMap<GroupData, Boolean>(); map.put((GroupData) parent, b); uc.setGroupsOwner(map); } } if (adminBox.isVisible()) { b = adminBox.isSelected(); if (b.compareTo(admin) != 0) { a = true; uc.setAdministrator(b); } } if (activeBox.isVisible()) { b = activeBox.isSelected(); if (b.compareTo(active) != 0) { a = true; uc.setActive(b); } } if (!original.getUserName().equals(value)) a = true; //if admin if (MetadataViewerAgent.isAdministrator()) a = true; if (a) { Map<ExperimenterData, UserCredentials> m = new HashMap<ExperimenterData, UserCredentials>(); m.put(original, uc); AdminObject object = new AdminObject(g, m, AdminObject.UPDATE_EXPERIMENTER); return object; } return original;//newOne; }
From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptComponent.java
/** * Helper method. Returns the value associated to a script. * /* w w w . j a v a 2 s . c o m*/ * @param c The component to handle. * @return See above. */ static Object getComponentValue(JComponent c) { if (c == null) return null; if (c instanceof JCheckBox) { JCheckBox box = (JCheckBox) c; return box.isSelected(); } else if (c instanceof NumericalTextField) { return ((NumericalTextField) c).getValueAsNumber(); } else if (c instanceof JTextField) { JTextField field = (JTextField) c; String value = field.getText(); if (StringUtils.isBlank(value)) return null; return value; } else if (c instanceof JComboBox) { JComboBox box = (JComboBox) c; return box.getSelectedItem(); } else if (c instanceof ComplexParamPane) { return ((ComplexParamPane) c).getValue(); } else if (c instanceof IdentifierParamPane) { return ((IdentifierParamPane) c).isReady(); } return null; }