Example usage for javax.swing JTextField setText

List of usage examples for javax.swing JTextField setText

Introduction

In this page you can find the example usage for javax.swing JTextField setText.

Prototype

@BeanProperty(bound = false, description = "the text of this component")
public void setText(String t) 

Source Link

Document

Sets the text of this TextComponent to the specified text.

Usage

From source file:org.olivier.ihm.FramePUMLCleanerControler.java

/**
 * Slectionner un fichier PUML/*w w  w.j a  v  a2 s  . co 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.finance.accounting.ui.ClotureMensuellePayePanel.java

public ClotureMensuellePayePanel() {

    super();//  ww  w.j av 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.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Numero du commande
    c.gridx = 0;//from   ww  w  . ja  v a  2s .c  o  m
    this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);

    this.numeroUniqueCommande = new JUniqueTextField(16);
    c.fill = GridBagConstraints.NONE;
    c.gridx++;
    c.weightx = 1;
    this.add(this.numeroUniqueCommande, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    this.add(labelDate, c);

    JDate dateCommande = new JDate(true);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    this.add(dateCommande, c);

    // Champ Module
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();

    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    this.comboDevis = new ElementComboBox();

    // Reference
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel labelObjet = new JLabel(getLabelFor("NOM"));
    labelObjet.setHorizontalAlignment(SwingConstants.RIGHT);
    c.weightx = 0;
    this.add(labelObjet, c);

    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.textObjet, c);

    String field;
    field = "ID_COMMERCIAL";
    c.fill = GridBagConstraints.HORIZONTAL;
    // Commercial
    JLabel labelCommercial = new JLabel(getLabelFor(field));
    labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);

    c.gridx++;
    c.weightx = 0;
    this.add(labelCommercial, c);

    this.comboCommercial = new ElementComboBox(false, 25);
    this.comboCommercial.setListIconVisible(false);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 1;
    this.add(this.comboCommercial, c);
    addRequiredSQLObject(this.comboCommercial, field);

    // Ligne 3: Client
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);

    this.comboClient = new ElementComboBox();
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 3;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboClient, c);
    final ElementComboBox boxTarif = new ElementComboBox();
    this.comboClient.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!isFilling() && comboClient.getValue() != null) {
                Integer id = comboClient.getValue();

                if (id > 1) {

                    SQLRow row = comboClient.getElement().getTable().getRow(id);
                    if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {

                        SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                        if (!foreignRow.isUndefined()
                                && (boxTarif.getSelectedRow() == null
                                        || boxTarif.getSelectedId() != foreignRow.getID())
                                && JOptionPane.showConfirmDialog(null,
                                        "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) {
                            boxTarif.setValue(foreignRow.getID());
                            // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
                            // true);
                        } else {
                            boxTarif.setValue(foreignRow.getID());
                        }
                        // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                        // if (foreignRow.isUndefined() &&
                        // !row.getForeignRow("ID_DEVISE").isUndefined()) {
                        // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
                        // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
                        // foreignRow = rowValsD;
                        //
                        // }
                        // table.setTarif(foreignRow, true);
                    }
                }
            }

        }
    });
    // tarif
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
        // TARIF
        c.gridy++;
        c.gridx = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        this.add(new JLabel("Tarif  appliquer"), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;

        c.weightx = 1;
        this.add(boxTarif, c);
        this.addView(boxTarif, "ID_TARIF");
        boxTarif.addModelListener("wantedID", new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
                table.setTarif(selectedRow, false);
            }
        });
    }

    // Table d'lment
    this.table = new CommandeClientItemTable();
    c.fill = GridBagConstraints.BOTH;
    c.gridy++;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(this.table, c);

    DeviseField textPortHT = new DeviseField();
    DeviseField textRemiseHT = new DeviseField();

    // INfos
    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.weighty = 0;
    c.weightx = 1;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 2;
    this.add(new TitledSeparator(getLabelFor("INFOS")), c);

    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    final JScrollPane scrollPane = new JScrollPane(this.infos);
    scrollPane.setBorder(null);
    this.add(scrollPane, c);

    // Poids
    c.gridwidth = 1;

    DefaultProps props = DefaultNXProps.getInstance();
    Boolean b = props.getBooleanValue("ArticleShowPoids");
    final JTextField textPoidsTotal = new JTextField(8);
    if (b) {
        JPanel panel = new JPanel();

        panel.add(new JLabel(getLabelFor("T_POIDS")), c);

        textPoidsTotal.setEnabled(false);
        textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
        textPoidsTotal.setDisabledTextColor(Color.BLACK);
        panel.add(textPoidsTotal, c);

        panel.setOpaque(false);
        DefaultGridBagConstraints.lockMinimumSize(panel);

        c.gridx = 2;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        c.fill = GridBagConstraints.NONE;
        c.anchor = GridBagConstraints.NORTHEAST;
        this.add(panel, c);
    }

    // Total
    DeviseField fieldHT = new DeviseField();
    DeviseField fieldTVA = new DeviseField();
    DeviseField fieldTTC = new DeviseField();
    DeviseField fieldDevise = new DeviseField();
    DeviseField fieldService = new DeviseField();
    DeviseField fieldHA = new DeviseField();
    fieldHT.setOpaque(false);
    fieldHA.setOpaque(false);
    fieldTVA.setOpaque(false);
    fieldTTC.setOpaque(false);
    fieldService.setOpaque(false);
    addSQLObject(fieldDevise, "T_DEVISE");
    addRequiredSQLObject(fieldHT, "T_HT");
    addRequiredSQLObject(fieldTVA, "T_TVA");
    addRequiredSQLObject(fieldTTC, "T_TTC");
    addRequiredSQLObject(fieldService, "T_SERVICE");
    if (getTable().contains("PREBILAN")) {
        addSQLObject(fieldHA, "PREBILAN");
    } else if (getTable().contains("T_HA")) {
        addSQLObject(fieldHA, "T_HA");
    }

    JTextField poids = new JTextField();
    // addSQLObject(poids, "T_POIDS");
    final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT,
            textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null);

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridy--;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.fill = GridBagConstraints.NONE;
    c.weighty = 0;

    this.add(totalTTC, c);

    this.panelOO = new PanelOOSQLComponent(this);
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    c.gridx = 0;
    c.gridy += 3;
    c.weightx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(this.panelOO, c);

    textPortHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    addRequiredSQLObject(this.comboClient, "ID_CLIENT");
    addSQLObject(this.textObjet, "NOM");
    addSQLObject(textPoidsTotal, "T_POIDS");
    addRequiredSQLObject(dateCommande, "DATE");
    // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
    addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
    addSQLObject(this.infos, "INFOS");
    addSQLObject(this.comboDevis, "ID_DEVIS");

    this.numeroUniqueCommande
            .setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));

    this.table.getModel().addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal()));
        }
    });
    DefaultGridBagConstraints.lockMinimumSize(comboClient);
    DefaultGridBagConstraints.lockMinimumSize(comboCommercial);
    DefaultGridBagConstraints.lockMinimumSize(comboDevis);
    DefaultGridBagConstraints.lockMinimumSize(totalTTC);
    DefaultGridBagConstraints.lockMaximumSize(totalTTC);
    DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);

}

From source file:org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent.java

private JPanel getBottomPanel() {
    final JPanel panel = new JPanel(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Colonne 1 : Infos
    c.gridx = 0;//w ww  .  j  av  a  2  s . c o m
    c.weightx = 1;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;

    panel.add(new TitledSeparator(getLabelFor("INFOS")), c);

    c.gridy++;
    c.weighty = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    final JScrollPane scrollPane = new JScrollPane(this.infos);
    scrollPane.setBorder(null);
    panel.add(scrollPane, c);

    // Colonne 2 : Poids & autres
    DefaultProps props = DefaultNXProps.getInstance();
    Boolean b = props.getBooleanValue("ArticleShowPoids");
    final JTextField textPoidsTotal = new JTextField(8);
    JTextField poids = new JTextField();
    if (b) {
        final JPanel panelPoids = new JPanel();

        panelPoids.add(new JLabel(getLabelFor("T_POIDS")), c);

        textPoidsTotal.setEnabled(false);
        textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
        textPoidsTotal.setDisabledTextColor(Color.BLACK);

        panelPoids.add(textPoidsTotal, c);

        c.gridx++;
        c.gridy = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        c.gridheight = 2;
        c.fill = GridBagConstraints.NONE;
        c.anchor = GridBagConstraints.NORTHEAST;
        panel.add(panelPoids, c);
        DefaultGridBagConstraints.lockMinimumSize(panelPoids);
        addSQLObject(textPoidsTotal, "T_POIDS");
    } else {
        addSQLObject(poids, "T_POIDS");
    }

    DeviseField textPortHT = new DeviseField();
    ElementComboBox comboTaxePort = new ElementComboBox();

    if (getTable().contains("PORT_HT")) {
        addRequiredSQLObject(textPortHT, "PORT_HT");
        final JPanel panelPoids = new JPanel(new GridBagLayout());
        GridBagConstraints cPort = new DefaultGridBagConstraints();
        cPort.gridx = 0;
        cPort.weightx = 0;
        panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort);
        textPortHT.setHorizontalAlignment(JTextField.RIGHT);
        cPort.gridx++;
        cPort.weightx = 1;
        panelPoids.add(textPortHT, cPort);

        cPort.gridy++;
        cPort.gridx = 0;
        cPort.weightx = 0;
        addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT");
        panelPoids.add(new JLabel(getLabelFor("ID_TAXE_PORT")), cPort);
        cPort.gridx++;
        cPort.weightx = 0;
        panelPoids.add(comboTaxePort, cPort);

        c.gridx++;
        c.gridy = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        c.gridheight = 2;
        c.fill = GridBagConstraints.NONE;
        c.anchor = GridBagConstraints.NORTHEAST;
        panel.add(panelPoids, c);
        DefaultGridBagConstraints.lockMinimumSize(panelPoids);
    }
    // Total

    DeviseField textRemiseHT = new DeviseField();
    DeviseField fieldHT = new DeviseField();
    DeviseField fieldTVA = new DeviseField();
    DeviseField fieldTTC = new DeviseField();
    DeviseField fieldDevise = new DeviseField();
    DeviseField fieldService = new DeviseField();
    fieldHT.setOpaque(false);
    fieldTVA.setOpaque(false);
    fieldTTC.setOpaque(false);
    fieldService.setOpaque(false);
    addRequiredSQLObject(fieldDevise, "T_DEVISE");
    addRequiredSQLObject(fieldHT, "T_HT");
    addRequiredSQLObject(fieldTVA, "T_TVA");

    addRequiredSQLObject(fieldTTC, "T_TTC");
    addRequiredSQLObject(fieldService, "T_SERVICE");
    final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT,
            textRemiseHT, fieldService, null, fieldDevise, null, null,
            (getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null));

    c.gridx++;
    c.gridy--;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.fill = GridBagConstraints.BOTH;
    c.weighty = 0;
    DefaultGridBagConstraints.lockMinimumSize(totalTTC);

    panel.add(totalTTC, c);

    c.gridy += 3;
    c.gridheight = 2;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    panel.add(getModuleTotalPanel(), c);

    table.getModel().addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            textPoidsTotal.setText(String.valueOf(table.getPoidsTotal()));
        }
    });

    textPortHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    comboTaxePort.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            // TODO Raccord de mthode auto-gnr
            totalTTC.updateTotal();
        }
    });

    textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });
    return panel;
}

From source file:org.openmicroscopy.shoola.agents.util.SelectionWizard.java

/**
 * Sets the default text for the specified field.
 *
 * @param field The field to handle.//from   w ww . java 2 s . c  o  m
 * @param text The text to display.
 */
private void setTextFieldDefault(JTextField field, String text) {
    field.getDocument().removeDocumentListener(this);
    if (text == null) {
        field.setText("");
        field.setForeground(originalColor);
    } else {
        field.setText(text);
        field.setForeground(Color.LIGHT_GRAY);
    }
    field.getDocument().addDocumentListener(this);
    setControls();
}

From source file:org.pdfsam.guiclient.business.listeners.AbstractRunButtonActionListener.java

/**
 * Check if there is a text in the TextField and it has a pdf extension, if
 * not it adds the extension.// w  w  w.  j a v a2s. co  m
 * 
 * @param field
 */
public static void ensurePdfExtensionOnTextField(JTextField field) {
    String stringWithExtension = FileExtensionUtility.ensureExtension(field.getText(),
            FileExtensionUtility.PDF_EXTENSION);
    if (!StringUtils.equalsIgnoreCase(stringWithExtension, field.getText())) {
        field.setText(stringWithExtension);
    }
}

From source file:org.simmi.GeneSetHead.java

License:asdf

public void blastn(boolean show) {
    String dbname = null;/*from w w w  .j a v a 2  s  . c om*/

    final JTextArea ta = new JTextArea();
    JScrollPane sp = new JScrollPane(ta);
    Dimension dim = new Dimension(400, 300);
    sp.setSize(dim);
    sp.setPreferredSize(dim);
    JTextField tf = new JTextField();
    tf.setText("0.00001");
    Object[] objs = new Object[] { sp, tf };
    JOptionPane.showMessageDialog(GeneSetHead.this, objs);

    doBlastn(ta.getText(), tf.getText(), false, null, show);
}

From source file:org.simmi.GeneSetHead.java

License:asdf

public void blast(boolean x) {
    //String dbname = null;

    /*try {//from  ww w  .  ja  v  a  2 s  .  c  om
       Map<String,String> env = new HashMap<String,String>();
       Path path = zipfile.toPath();
       String uristr = "jar:" + path.toUri();
       geneset.zipuri = URI.create( uristr /*.replace("file://", "file:")* );
       geneset.zipfilesystem = FileSystems.newFileSystem( geneset.zipuri, env );
               
       final PathMatcher pm = geneset.zipfilesystem.getPathMatcher("*.p??");
       for( Path p : zipfilesystem.getRootDirectories() ) {
    Files.walkFileTree( p, new SimpleFileVisitor<Path>() {
       @Override
       public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
          if( pm.matches( file ) ) {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             byte[] bb = new byte[1024];
             int r = zipm.read( bb );
             while( r > 0 ) {
                baos.write(bb, 0, r);
                r = zipm.read( bb );
             }
             Files.write( new File("c:/"+file.getFileName().).toPath(), baos.toByteArray(), StandardOpenOption.CREATE);
             //unresolvedmap = loadunresolvedmap( new InputStreamReader( zipm ) );
                     
             dbname = zname.substring(0, zname.length()-4);
          }
          return null;*
       }
    });
       }*/
    //Path nf = zipfilesystem.getPath("/unresolved.blastout");
    //unresolvedmap = loadunresolvedmap( new InputStreamReader( Files.newInputStream(nf, StandardOpenOption.READ) ) );

    /*ZipInputStream zipm = new ZipInputStream( new ByteArrayInputStream( zipf ) );
    ZipEntry ze = zipm.getNextEntry();
    while( ze != null ) {
    String zname = ze.getName();
    if( zname.endsWith(".phr") || zname.endsWith(".pin") || zname.endsWith(".psq") ) {
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       byte[] bb = new byte[1024];
       int r = zipm.read( bb );
       while( r > 0 ) {
          baos.write(bb, 0, r);
          r = zipm.read( bb );
       }
       Files.write( new File("c:/"+zname).toPath(), baos.toByteArray(), StandardOpenOption.CREATE);
       //unresolvedmap = loadunresolvedmap( new InputStreamReader( zipm ) );
               
       dbname = zname.substring(0, zname.length()-4);
    }
    ze = zipm.getNextEntry();
    }*
    } catch (IOException e1) {
    e1.printStackTrace();
    }*/

    final JTextArea ta = new JTextArea();
    JScrollPane sp = new JScrollPane(ta);
    Dimension dim = new Dimension(400, 300);
    sp.setSize(dim);
    sp.setPreferredSize(dim);
    JTextField tf = new JTextField();
    tf.setText("0.00001");
    Object[] objs = new Object[] { sp, tf };
    JOptionPane.showMessageDialog(GeneSetHead.this, objs);

    doBlast(ta.getText(), tf.getText(), true, null, x);
}

From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java

/**
 * Validates that the selected folder exists, and sets the passed-in
 * textField to empty if it does not exist. Then checks if the sanitized
 * folder is readable and writable with the current user's credentials,
 * returning True if so and False if not. This has the desirable effect that
 * a folder can show up in the text box (as chosen by the user while
 * browsing), and still return false if the permissions are incorrect. This
 * way the user can see the folder chosen and take appropriate action to fix
 * the permissions. Use this only for files chosen by the file chooser.
 *
 * @param fileChooser The fileChooser we want to use.
 * @param textField   The text field to store the sanitized value in.
 *
 * Throws FolderDidNotValidateException//from ww  w.  j a  v  a  2 s  .co  m
 */
private void validateAndSanitizeBrowsedDirectory(JFileChooser fileChooser, JTextField textField)
        throws FolderDidNotValidateException {
    File selectedFile = fileChooser.getSelectedFile();
    if (selectedFile == null || !selectedFile.exists()) {
        textField.setText(""); //NON-NLS

        throw new FolderDidNotValidateException(NbBundle.getMessage(FileExporterSettingsPanel.class,
                "FileExporterSettingsPanel.UnableToFindDirectory"));

    } else {
        textField.setText(selectedFile.toString());
        File file = new File(selectedFile.toString());
        fileChooser.setCurrentDirectory(file);

        if (!FileUtil.hasReadWriteAccess(file.toPath())) {
            throw new FolderDidNotValidateException(NbBundle.getMessage(FileExporterSettingsPanel.class,
                    "FileExporterSettingsPanel.PermissionsInvalid"));
        }
    }
}

From source file:org.thelq.stackexchange.dbimport.gui.GUI.java

/**
 * Update the list of locations/*from  w ww .  j a  v  a  2  s.  com*/
 */
protected void updateLocations() {
    locationsBuilder.getPanel().removeAll();
    for (final DumpContainer curContainer : controller.getDumpContainers()) {
        //Initialize components
        if (curContainer.getGuiHeader() == null) {
            String longLocation = Utils.getLongLocation(curContainer);
            JLabel headerLabel = new JLabel(longLocation);
            headerLabel.setToolTipText(longLocation);
            headerLabel.setIcon(UIManager.getIcon("Tree.collapsedIcon"));
            JPopupMenu popupMenu = new JPopupMenu();
            JMenuItem deleteItem = new JMenuItem("Delete");
            deleteItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    log.info("Removing " + curContainer.getType() + " " + curContainer.getLocation());
                    controller.getDumpContainers().remove(curContainer);
                    updateLocations();
                }
            });
            popupMenu.add(deleteItem);
            headerLabel.setComponentPopupMenu(popupMenu);
            curContainer.setGuiHeader(headerLabel);
            //Handlers
            headerLabel.addMouseListener(new MouseAdapter() {
                boolean visible = true;

                @Override
                public void mouseClicked(MouseEvent e) {
                    //Update labels
                    visible = !visible;
                    for (DumpEntry curEntry : curContainer.getEntries()) {
                        curEntry.getGuiName().setVisible(visible);
                        curEntry.getGuiSize().setVisible(visible);
                        curEntry.getGuiLog().setVisible(visible);
                        if (curEntry.getGuiSeparator() != null)
                            curEntry.getGuiSeparator().setVisible(visible);
                    }

                    //Change icon
                    if (visible)
                        curContainer.getGuiHeader().setIcon(UIManager.getIcon("Tree.expandedIcon"));
                    else
                        curContainer.getGuiHeader().setIcon(UIManager.getIcon("Tree.collapsedIcon"));
                    locationsPane.revalidate();
                }
            });
        }
        if (curContainer.getGuiTablePrefix() == null) {
            JTextField headerPrefix = new JTextField(6);
            curContainer.setGuiTablePrefix(headerPrefix);
            headerPrefix.setText(Utils.genTablePrefix(curContainer.getName()));
            if (StringUtils.isBlank(headerPrefix.getText()))
                log.warn("Unable to generate a table prefix for {}", curContainer.getLocation());
        }

        //Start adding to panel
        locationsBuilder.leadingColumnOffset(0);
        locationsBuilder.append(curContainer.getGuiHeader(), 7);
        locationsBuilder.append(curContainer.getGuiTablePrefix());
        locationsBuilder.nextLine();
        locationsBuilder.leadingColumnOffset(2);

        Iterator<DumpEntry> entriesItr = curContainer.getEntries().iterator();
        while (entriesItr.hasNext()) {
            DumpEntry curEntry = entriesItr.next();
            if (curEntry.getGuiName() == null)
                curEntry.setGuiName(new JLabel(curEntry.getName()));
            locationsBuilder.append(curEntry.getGuiName());
            if (curEntry.getGuiSize() == null)
                curEntry.setGuiSize(new JLabel(sizeInMegabytes(curEntry.getSizeBytes())));
            locationsBuilder.append(curEntry.getGuiSize());
            if (curEntry.getGuiLog() == null)
                curEntry.setGuiLog(new JLabel("Waiting..."));
            locationsBuilder.append(curEntry.getGuiLog(), 3);
            locationsBuilder.nextLine();
            if (entriesItr.hasNext()) {
                if (curEntry.getGuiSeparator() == null)
                    curEntry.setGuiSeparator(new JSeparator());
                locationsBuilder.append(curEntry.getGuiSeparator(), 7);
                locationsBuilder.nextLine();
            }
        }
    }

    locationsPane.validate();
}