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

📄 edittierdialog.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * File:     EditTierDialog.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.commands.Command;import mpi.eudico.client.annotator.commands.ELANCommandFactory;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.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.awt.event.WindowAdapter;import java.awt.event.WindowEvent;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.JDialog;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;/** * The DefineTierDialog is a custom dialog for adding an Tier resp. changing * the attributes of a Tier. * * @author Alexander Klassmann * @version 2.0 nov 03 * @version Aug 2005 Identity removed */public class EditTierDialog extends JDialog implements ActionListener,    ItemListener {    /** Holds value of property DOCUMENT ME! */    public static final int ADD = 0;    /** Holds value of property DOCUMENT ME! */    public static final int CHANGE = 1;    /** Holds value of property DOCUMENT ME! */    public static final int DELETE = 2;    private TierImpl tier = null;    private TierImpl oldParentTier;    private TranscriptionImpl transcription;    private String oldTierName;    private String oldParentTierName;    private String oldParticipant;    private LinguisticType oldLingType;    private Locale oldLocale;    private Locale[] langs;    /** Holds value of property DOCUMENT ME! */    final private String none = "none";    private int mode = CHANGE;    private boolean singleEditMode = false;    private Vector tiers;    //Components    /** Holds value of property DOCUMENT ME! */    final private JLabel titleLabel = new JLabel();    /** Holds value of property DOCUMENT ME! */    final private JLabel selectTierLabel = new JLabel();    /** Holds value of property DOCUMENT ME! */    final private JLabel tierNameLabel = new JLabel();    /** Holds value of property DOCUMENT ME! */    final private JLabel participantLabel = new JLabel();    /** Holds value of property DOCUMENT ME! */    final private JLabel lingTypeLabel = new JLabel();    /** Holds value of property DOCUMENT ME! */    final private JLabel parentLabel = new JLabel();    /** Holds value of property DOCUMENT ME! */    final private JLabel languageLabel = new JLabel();    /** Holds value of property DOCUMENT ME! */    final private JTextField tierNameTextField = new JTextField(30);    /** Holds value of property DOCUMENT ME! */    final private JTextField participantTextField = new JTextField(30);    /** Holds value of property DOCUMENT ME! */    final private JComboBox lingTypeChoice = new JComboBox();    /** Holds value of property DOCUMENT ME! */    final private JComboBox languageChoice = new JComboBox();    /** Holds value of property DOCUMENT ME! */    final private JComboBox parentChoice = new JComboBox();    /** Holds value of property DOCUMENT ME! */    final private JComboBox currentTiersComboBox = new JComboBox();    /** Holds value of property DOCUMENT ME! */    final private JButton changeButton = new JButton();    /** Holds value of property DOCUMENT ME! */    final private JButton cancelButton = new JButton();    /** Holds value of property DOCUMENT ME! */    final private JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 6, 2));    /** Holds value of property DOCUMENT ME! */    final private Frame frame;    /**     * A modal dialog for creating, changing or deleting a tier.     *     * @param parentFrame the parent or root frame     * @param modal whether the dialog should be modal or not     * @param theTranscription the Transcription containing the tiers     * @param editMode the type of dialog, ADD, CHANGE or DELETE     * @param tier the tier to initialise the dialog for     */    public EditTierDialog(Frame parentFrame, boolean modal,        Transcription theTranscription, int editMode, TierImpl tier) {        super(parentFrame, modal);        frame = parentFrame;        transcription = (TranscriptionImpl) theTranscription;        if ((editMode == ADD) || (editMode == CHANGE) || (editMode == DELETE)) {            mode = editMode;        }        extractCurrentTiers();        createDialog();        updateForModeAndLocale();        if (tier != null) {            this.tier = tier;            String name = tier.getName();            singleEditMode = true;            if (currentTiersComboBox != null) {                currentTiersComboBox.setSelectedItem(name);            }        }        pack();        setResizable(false);        setLocationRelativeTo(frame);        if (editMode == ADD) {            tierNameTextField.requestFocus();        }    }    /**     * Fill the tiers combobox with the currently present tiers.     */    private void extractCurrentTiers() {        currentTiersComboBox.removeItemListener(this);        currentTiersComboBox.removeAllItems();        tiers = transcription.getTiers();        if (tiers == null) {            tiers = new Vector();            return;        }        Iterator tierIt = tiers.iterator();        while (tierIt.hasNext()) {            TierImpl t = (TierImpl) tierIt.next();            currentTiersComboBox.addItem(t.getName());        }        if (currentTiersComboBox.getItemCount() > 0) {            currentTiersComboBox.setSelectedIndex(0);            tier = (TierImpl) tiers.get(0);        }        currentTiersComboBox.addItemListener(this);    }    /**     * Again extract the tiers from the transcription after an add,  change or     * delete operation.     */    private void reextractTiers() {        extractCurrentTiers();        if (currentTiersComboBox.getItemCount() > 0) {            currentTiersComboBox.setSelectedIndex(0);        } else {            tierNameTextField.setText("");            participantTextField.setText("");        }        if (mode == ADD) {            tierNameTextField.setText("");            participantTextField.setText("");        }    }    /**     * Update the UI elements according to the current Locale and the current     * edit mode.     */    private void updateForModeAndLocale() {        tierNameLabel.setText(ElanLocale.getString(                "EditTierDialog.Label.TierName"));        participantLabel.setText(ElanLocale.getString(                "EditTierDialog.Label.Participant"));        lingTypeLabel.setText(ElanLocale.getString(                "EditTierDialog.Label.LinguisticType"));        parentLabel.setText(ElanLocale.getString("EditTierDialog.Label.Parent"));        languageLabel.setText(ElanLocale.getString(                "EditTierDialog.Label.Language"));        cancelButton.setText(ElanLocale.getString("Button.Close"));        switch (mode) {        case ADD:            setTitle(ElanLocale.getString("EditTierDialog.Title.Add"));            selectTierLabel.setText(ElanLocale.getString(                    "EditTierDialog.Label.CurrentTiers"));            changeButton.setText(ElanLocale.getString("Button.Add"));            break;        case CHANGE:            setTitle(ElanLocale.getString("EditTierDialog.Title.Change"));            selectTierLabel.setText(ElanLocale.getString(                    "EditTierDialog.Label.ChangeTier"));            changeButton.setText(ElanLocale.getString("Button.Change"));            parentChoice.setEnabled(false);            break;        case DELETE:            setTitle(ElanLocale.getString("EditTierDialog.Title.Delete"));            selectTierLabel.setText(ElanLocale.getString(                    "EditTierDialog.Label.DeleteTier"));            changeButton.setText(ElanLocale.getString("Button.Delete"));            tierNameTextField.setEditable(false);            participantTextField.setEditable(false);            parentChoice.setEnabled(false);            lingTypeChoice.setEnabled(false);            languageChoice.setEnabled(false);            break;        }        titleLabel.setText(getTitle());    }    private void createDialog() {        //Initialisation of the Components        titleLabel.setFont(titleLabel.getFont().deriveFont((float) 16));        currentTiersComboBox.addItemListener(this);        fillParentComboBox();        fillLingTypeMenu();        langs = ImUtil.getLanguages(this);        updateLanguageChoice();        changeButton.addActionListener(this);        cancelButton.addActionListener(this);

⌨️ 快捷键说明

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