Search in sources :

Example 1 with OneFilterTableModel

use of org.omegat.filters2.master.OneFilterTableModel in project omegat by omegat-org.

the class FilterEditor method toDefaultsButtonActionPerformed.

// GEN-LAST:event_removeButtonActionPerformed
private void toDefaultsButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_toDefaultsButtonActionPerformed
    try {
        filter = FilterMaster.getDefaultSettingsFromFilter(filter.getClassName());
        instances.setModel(new OneFilterTableModel(filter));
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, OStrings.getString("FILTEREDITOR_ERROR_Reverting_To_Def") + e, OStrings.getString("ERROR_TITLE"), JOptionPane.ERROR_MESSAGE);
    }
}
Also used : OneFilterTableModel(org.omegat.filters2.master.OneFilterTableModel)

Example 2 with OneFilterTableModel

use of org.omegat.filters2.master.OneFilterTableModel in project omegat by omegat-org.

the class FilterEditor method removeButtonActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_removeButtonActionPerformed
    int row = instances.getSelectedRow();
    Files instance = filter.getFiles().get(row);
    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, StringUtil.format(OStrings.getString("FILTEREDITOR_really_delete_filter_instance"), instance.getSourceFilenameMask()), OStrings.getString("FILTEREDITOR_Confirm_deletion_TITLE"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) {
        filter.getFiles().remove(row);
        instances.setModel(new OneFilterTableModel(filter));
    }
}
Also used : OneFilterTableModel(org.omegat.filters2.master.OneFilterTableModel) Files(gen.core.filters.Files)

Example 3 with OneFilterTableModel

use of org.omegat.filters2.master.OneFilterTableModel in project omegat by omegat-org.

the class FilterEditor method addButtonActionPerformed.

// GEN-LAST:event_toDefaultsButtonActionPerformed
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_addButtonActionPerformed
    IFilter f = FilterMaster.getFilterInstance(filter.getClassName());
    if (f == null) {
        return;
    }
    InstanceEditor ie = new InstanceEditor(this, f.isSourceEncodingVariable(), f.isTargetEncodingVariable(), f.getHint());
    ie.setVisible(true);
    if (ie.getReturnStatus() == InstanceEditor.RET_OK) {
        Files ff = new Files();
        ff.setSourceEncoding(setEncodingName(ie.getSourceEncoding()));
        ff.setSourceFilenameMask(ie.getSourceFilenameMask());
        ff.setTargetEncoding(setEncodingName(ie.getTargetEncoding()));
        ff.setTargetFilenamePattern(ie.getTargetFilenamePattern());
        filter.getFiles().add(ff);
        instances.setModel(new OneFilterTableModel(filter));
    }
}
Also used : IFilter(org.omegat.filters2.IFilter) OneFilterTableModel(org.omegat.filters2.master.OneFilterTableModel) Files(gen.core.filters.Files)

Example 4 with OneFilterTableModel

use of org.omegat.filters2.master.OneFilterTableModel in project omegat by omegat-org.

the class FilterEditor method editButtonActionPerformed.

// GEN-LAST:event_addButtonActionPerformed
private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_editButtonActionPerformed
    int row = instances.getSelectedRow();
    IFilter f = FilterMaster.getFilterInstance(filter.getClassName());
    if (f == null) {
        return;
    }
    InstanceEditor ie = new InstanceEditor(this, f.isSourceEncodingVariable(), f.isTargetEncodingVariable(), f.getHint(), instances.getModel().getValueAt(row, 0).toString(), instances.getModel().getValueAt(row, 1).toString(), instances.getModel().getValueAt(row, 2).toString(), instances.getModel().getValueAt(row, 3).toString());
    ie.setVisible(true);
    if (ie.getReturnStatus() == InstanceEditor.RET_OK) {
        Files ff = new Files();
        ff.setSourceEncoding(setEncodingName(ie.getSourceEncoding()));
        ff.setSourceFilenameMask(ie.getSourceFilenameMask());
        ff.setTargetEncoding(setEncodingName(ie.getTargetEncoding()));
        ff.setTargetFilenamePattern(ie.getTargetFilenamePattern());
        filter.getFiles().set(row, ff);
        instances.setModel(new OneFilterTableModel(filter));
    }
}
Also used : IFilter(org.omegat.filters2.IFilter) OneFilterTableModel(org.omegat.filters2.master.OneFilterTableModel) Files(gen.core.filters.Files)

Example 5 with OneFilterTableModel

use of org.omegat.filters2.master.OneFilterTableModel in project omegat by omegat-org.

the class FilterEditor method initComponents.

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;
    buttonPanel = new javax.swing.JPanel();
    toDefaultsButton = new javax.swing.JButton();
    jLabel1 = new javax.swing.JLabel();
    okButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    fileFormatLabel = new javax.swing.JLabel();
    fileFormatTextField = new javax.swing.JTextField();
    descTextArea = new javax.swing.JTextArea();
    jPanel3 = new javax.swing.JPanel();
    instancesScrollPane = new javax.swing.JScrollPane();
    instances = new javax.swing.JTable();
    removeButton = new javax.swing.JButton();
    editButton = new javax.swing.JButton();
    addButton = new javax.swing.JButton();
    hintTextArea = new javax.swing.JTextArea();
    // NOI18N
    setTitle(OStrings.getString("FILTEREDITOR_Edit_a_single_file_filter"));
    addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog(evt);
        }
    });
    getContentPane().setLayout(new java.awt.GridBagLayout());
    buttonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
    // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(toDefaultsButton, OStrings.getString("BUTTON_TO_DEFAULTS"));
    toDefaultsButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            toDefaultsButtonActionPerformed(evt);
        }
    });
    buttonPanel.add(toDefaultsButton);
    jLabel1.setPreferredSize(new java.awt.Dimension(20, 0));
    buttonPanel.add(jLabel1);
    // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(okButton, OStrings.getString("BUTTON_OK"));
    okButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            okButtonActionPerformed(evt);
        }
    });
    buttonPanel.add(okButton);
    // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(cancelButton, OStrings.getString("BUTTON_CANCEL"));
    cancelButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelButtonActionPerformed(evt);
        }
    });
    buttonPanel.add(cancelButton);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
    getContentPane().add(buttonPanel, gridBagConstraints);
    // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(fileFormatLabel, OStrings.getString("FILTEREDITOR_File_Format"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
    getContentPane().add(fileFormatLabel, gridBagConstraints);
    fileFormatTextField.setEditable(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
    getContentPane().add(fileFormatTextField, gridBagConstraints);
    descTextArea.setEditable(false);
    descTextArea.setFont(fileFormatLabel.getFont());
    descTextArea.setLineWrap(true);
    // NOI18N
    descTextArea.setText(OStrings.getString("FILTEREDITOR_DESC"));
    descTextArea.setWrapStyleWord(true);
    descTextArea.setDragEnabled(false);
    descTextArea.setOpaque(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
    getContentPane().add(descTextArea, gridBagConstraints);
    jPanel3.setLayout(new java.awt.GridBagLayout());
    instances.setModel(new OneFilterTableModel(filter));
    instances.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    instancesScrollPane.setViewportView(instances);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    jPanel3.add(instancesScrollPane, gridBagConstraints);
    // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(removeButton, OStrings.getString("BUTTON_REMOVE"));
    removeButton.setEnabled(false);
    removeButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            removeButtonActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    jPanel3.add(removeButton, gridBagConstraints);
    // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(editButton, OStrings.getString("BUTTON_EDIT"));
    editButton.setEnabled(false);
    editButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            editButtonActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    jPanel3.add(editButton, gridBagConstraints);
    // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(addButton, OStrings.getString("BUTTON_ADD"));
    addButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            addButtonActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    jPanel3.add(addButton, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
    getContentPane().add(jPanel3, gridBagConstraints);
    hintTextArea.setEditable(false);
    hintTextArea.setFont(new JLabel().getFont());
    hintTextArea.setLineWrap(true);
    hintTextArea.setWrapStyleWord(true);
    hintTextArea.setOpaque(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
    getContentPane().add(hintTextArea, gridBagConstraints);
}
Also used : JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) OneFilterTableModel(org.omegat.filters2.master.OneFilterTableModel) JLabel(javax.swing.JLabel)

Aggregations

OneFilterTableModel (org.omegat.filters2.master.OneFilterTableModel)5 Files (gen.core.filters.Files)3 IFilter (org.omegat.filters2.IFilter)2 Dimension (java.awt.Dimension)1 JLabel (javax.swing.JLabel)1