⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edittierdialog2.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * File:     EditTierDialog2.java * Project:  MPI Linguistic Application * Date:     02 May 2007 * * Copyright (C) 2001-2007  Max Planck Institute for Psycholinguistics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package mpi.eudico.client.annotator.gui;import mpi.eudico.client.annotator.Constants;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.annotator.Preferences;import mpi.eudico.client.annotator.commands.Command;import mpi.eudico.client.annotator.commands.ELANCommandFactory;import mpi.eudico.client.annotator.tier.TierTableModel;import mpi.eudico.client.annotator.util.ElanFileFilter;import mpi.eudico.client.annotator.util.FileExtension;import mpi.eudico.client.im.ImUtil;import mpi.eudico.server.corpora.clom.Tier;import mpi.eudico.server.corpora.clom.Transcription;import mpi.eudico.server.corpora.clomimpl.abstr.TierImpl;import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl;import mpi.eudico.server.corpora.clomimpl.type.Constraint;import mpi.eudico.server.corpora.clomimpl.type.LinguisticType;import java.awt.Dimension;import java.awt.Frame;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.io.File;import java.util.Enumeration;import java.util.Iterator;import java.util.Locale;import java.util.Vector;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JFileChooser;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTabbedPane;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.ListSelectionModel;import javax.swing.SwingConstants;import javax.swing.border.TitledBorder;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import javax.swing.filechooser.FileFilter;/** * A dialog to create, change, delete or import tiers. This is an extended * version of EditTierDialog. An information table has been added showing info * on the current tiers. Tabs have been introduced to switch between add, * change, delete or import  mode. The import mode is also new: it enables the * import of tiers (with associated  linguistic types and cv's, but without * annotations) from an .eaf or .etf. * * @author Han Sloetjes * @version 2.0 */public class EditTierDialog2 extends ClosableDialog implements ActionListener,    ItemListener, ChangeListener, ListSelectionListener {    /** the add mode */    public static final int ADD = 0;    /** the change mode */    public static final int CHANGE = 1;    /** the delete mode */    public static final int DELETE = 2;    /** the import mode */    public static final int IMPORT = 3;    /** value for no parent */    final private String none = "none";    //private Frame frame;    private TranscriptionImpl transcription;    private TierImpl tier = null;    private TierImpl oldParentTier;    private String oldTierName;    private String oldParentTierName;    private String oldParticipant;    private String oldAnnotator;    private LinguisticType oldLingType;    private Locale oldLocale;    private Locale[] langs;    private int mode = ADD;    private boolean singleEditMode = false;    private Vector tiers;    // ui    private JLabel titleLabel;    private JPanel tablePanel;    private JTable tierTable;    private TierTableModel model;    private JTabbedPane tabPane;    // ui elements for edit panel    private JPanel editPanel;    private JLabel selectTierLabel;    private JLabel tierNameLabel;    private JComboBox currentTiersComboBox;    private JTextField tierNameTextField;    private JLabel participantLabel;    private JTextField participantTextField;    private JLabel annotatorLabel;    private JTextField annotatorTextField;    private JLabel lingTypeLabel;    private JComboBox lingTypeComboBox;    private JLabel parentLabel;    private JComboBox parentComboBox;    private JLabel languageLabel;    private JComboBox languageComboBox;    // import panel    private JPanel importPanel;    private JLabel importSourceLabel;    private JTextField importSourceTF;    private JButton importSourceButton;    private JButton changeButton;    private JButton cancelButton;    private JPanel buttonPanel;    /**     * Creates a new EditTierDialog2 instance     *     * @param parentFrame the parent ELAN frame     * @param modal the modal flag: true     * @param theTranscription the transcription to work on     * @param editMode the edit mode: ADD, CHANGE, DELETE or IMPORT     * @param tier the tier to select in the ui initially     */    public EditTierDialog2(Frame parentFrame, boolean modal,        Transcription theTranscription, int editMode, TierImpl tier) {        super(parentFrame, modal);        //frame = parentFrame;        transcription = (TranscriptionImpl) theTranscription;        if ((editMode >= ADD) && (editMode <= IMPORT)) {            mode = editMode;        }        initComponents();        extractCurrentTiers();        if (tier != null) {            this.tier = tier;            String name = tier.getName();            singleEditMode = true;            if (currentTiersComboBox != null) {                currentTiersComboBox.setSelectedItem(name);            }        }        updateLanguageComboBox();        updateLocale();        updateForMode();        updateUIForTier((String) currentTiersComboBox.getSelectedItem());        postInit();        if (editMode == ADD) {            tierNameTextField.requestFocus();        } else if (editMode == IMPORT) {            // this forces proper rendering of the import panel,             // otherwise a textfield of the editPanel is visible on top             // of the importPanel ??            editPanel.setVisible(false);            importSourceButton.requestFocus();        } else {            currentTiersComboBox.requestFocus();        }    }    /**     * Initializes the ui components.     */    private void initComponents() {        langs = ImUtil.getLanguages(this);        getContentPane().setLayout(new GridBagLayout());        Insets insets = new Insets(2, 6, 2, 6);        titleLabel = new JLabel();        titleLabel.setFont(titleLabel.getFont().deriveFont((float) 16));        titleLabel.setHorizontalAlignment(SwingConstants.CENTER);        tablePanel = new JPanel();        tablePanel.setLayout(new GridBagLayout());        model = new TierTableModel(transcription.getTiers());        tierTable = new JTable(model);        tierTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        JScrollPane tableScrollPane = new JScrollPane(tierTable);        Dimension size = new Dimension(300, 120);        tableScrollPane.setMinimumSize(size);        tableScrollPane.setPreferredSize(size);        tabPane = new JTabbedPane();        GridBagConstraints gbc = new GridBagConstraints();        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.anchor = GridBagConstraints.NORTH;        gbc.insets = new Insets(6, 6, 6, 6);        gbc.weightx = 1.0;        getContentPane().add(titleLabel, gbc);        gbc = new GridBagConstraints();        gbc.fill = GridBagConstraints.BOTH;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.insets = insets;        gbc.weightx = 1.0;        gbc.weighty = 1.0;        tablePanel.add(tableScrollPane, gbc);        gbc = new GridBagConstraints();        gbc.gridy = 1;        gbc.fill = GridBagConstraints.BOTH;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.insets = insets;        gbc.weightx = 1.0;        gbc.weighty = 1.0;        getContentPane().add(tablePanel, gbc);        gbc = new GridBagConstraints();        gbc.gridy = 2;        gbc.fill = GridBagConstraints.BOTH;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.insets = new Insets(10, 6, 6, 6);        gbc.weightx = 1.0;        //gbc.weighty = 1.0;        getContentPane().add(tabPane, gbc);        // edit panel        editPanel = new JPanel(new GridBagLayout());        selectTierLabel = new JLabel();        currentTiersComboBox = new JComboBox();        currentTiersComboBox.setMaximumRowCount(Constants.COMBOBOX_VISIBLE_ROWS);        tierNameLabel = new JLabel();        tierNameTextField = new JTextField();        participantLabel = new JLabel();        participantTextField = new JTextField();        annotatorLabel = new JLabel();        annotatorTextField = new JTextField();        lingTypeLabel = new JLabel();        lingTypeComboBox = new JComboBox();        parentLabel = new JLabel();        parentComboBox = new JComboBox();        languageLabel = new JLabel();        languageComboBox = new JComboBox();        GridBagConstraints lgbc = new GridBagConstraints();        lgbc.anchor = GridBagConstraints.NORTHWEST;        lgbc.insets = insets;        editPanel.add(selectTierLabel, lgbc);        GridBagConstraints rgbc = new GridBagConstraints();        rgbc.gridx = 1;        rgbc.fill = GridBagConstraints.HORIZONTAL;        rgbc.anchor = GridBagConstraints.NORTHWEST;        rgbc.insets = insets;        rgbc.weightx = 1.0;        editPanel.add(currentTiersComboBox, rgbc);        lgbc.gridy = 1;        editPanel.add(tierNameLabel, lgbc);        rgbc.gridy = 1;        editPanel.add(tierNameTextField, rgbc);        lgbc.gridy = 2;        editPanel.add(participantLabel, lgbc);        rgbc.gridy = 2;        editPanel.add(participantTextField, rgbc);        lgbc.gridy = 3;        editPanel.add(annotatorLabel, lgbc);        rgbc.gridy = 3;        editPanel.add(annotatorTextField, rgbc);        lgbc.gridy = 4;        editPanel.add(parentLabel, lgbc);        rgbc.gridy = 4;        editPanel.add(parentComboBox, rgbc);        lgbc.gridy = 5;        editPanel.add(lingTypeLabel, lgbc);        rgbc.gridy = 5;        editPanel.add(lingTypeComboBox, rgbc);        lgbc.gridy = 6;        editPanel.add(languageLabel, lgbc);        rgbc.gridy = 6;        editPanel.add(languageComboBox, rgbc);        // import panel        importPanel = new JPanel(new GridBagLayout());        importSourceLabel = new JLabel();        importSourceTF = new JTextField();        importSourceTF.setEditable(false);        importSourceButton = new JButton();        importSourceButton.addActionListener(this);        gbc = new GridBagConstraints();        gbc.gridwidth = 2;        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.insets = insets;        gbc.weightx = 1.0;        importPanel.add(importSourceLabel, gbc);        gbc = new GridBagConstraints();        gbc.gridy = 1;        gbc.fill = GridBagConstraints.HORIZONTAL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -