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

📄 edittypedialog2.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * File:     EditTypeDialog2.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.type.LinguisticTypeTableModel;import mpi.eudico.client.annotator.util.ElanFileFilter;import mpi.eudico.client.annotator.util.FileExtension;import mpi.eudico.client.util.CheckBoxTableCellRenderer;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.IncludedIn;import mpi.eudico.server.corpora.clomimpl.type.LinguisticType;import mpi.eudico.server.corpora.clomimpl.type.SymbolicAssociation;import mpi.eudico.server.corpora.clomimpl.type.SymbolicSubdivision;import mpi.eudico.server.corpora.clomimpl.type.TimeSubdivision;import mpi.util.ControlledVocabulary;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.Iterator;import java.util.Vector;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JCheckBox;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 for adding, changing and removing Linguistic Types. * @version 2.0 */public class EditTypeDialog2 extends ClosableDialog implements ActionListener,    ItemListener, ChangeListener, ListSelectionListener {    /** add linguistic type mode */    public static final int ADD = 0;    /** change linguistic type mode! */    public static final int CHANGE = 1;    /** delete linguistic type mode! */    public static final int DELETE = 2;    /** import linguistic type mode */    public static final int IMPORT = 3;    /** value for no stereotype! */    public final String none = "None";    private TranscriptionImpl transcription;    private Vector types;    private String oldConstraint;    private JLabel titleLabel;    private JPanel typePanel;    private JTable typeTable;    private LinguisticTypeTableModel model;    private JTabbedPane tabPane;    private JPanel editPanel;    private JLabel currentTypesLabel;    private JLabel typeLabel;    private JLabel timeAlignableLabel;    private JLabel graphicReferencesLabel;    private JLabel constraintsLabel;    private JLabel cvLabel;    private JTextField typeTextField;    private JCheckBox timeAlignableCheckbox;    private JCheckBox graphicReferencesCheckbox;    private JComboBox constraintsComboBox;    private JComboBox currentTypesComboBox;    private JComboBox cvComboBox;    // import panel    private JPanel importPanel;    private JLabel importSourceLabel;    private JTextField importSourceTF;    private JButton importSourceButton;    private JPanel buttonPanel;    private JButton changeButton;    private JButton cancelButton;    private int mode = ADD;    /**     * A general purpose constructor for adding, changing, deleting or importing     * LinguisticTypes.<br>     *     * @param theFrame the parent frame     * @param modal whether the dialog should be modal or not     * @param theTranscription the Transcription containing the types     * @param editMode the mode to start with, ADD, CHANGE, DELETE or IMPORT     */    public EditTypeDialog2(Frame theFrame, boolean modal,        Transcription theTranscription, int editMode) {        super(theFrame, modal);        transcription = (TranscriptionImpl) theTranscription;        if ((editMode >= ADD) && (editMode <= IMPORT)) {            mode = editMode;        }        initComponents();        extractCurrentTypes();        extractControlledVocabularies();        updateUIForType((String) currentTypesComboBox.getSelectedItem());        updateLocale();        updateForMode();        postInit();        if (mode == ADD) {            typeTextField.requestFocus();        } else if (mode == IMPORT) {            importSourceButton.requestFocus();        } else {            currentTypesComboBox.requestFocus();        }    }    /**     * Initializes the ui components.     */    private void initComponents() {        titleLabel = new JLabel();        currentTypesLabel = new JLabel();        typeLabel = new JLabel();        timeAlignableLabel = new JLabel();        graphicReferencesLabel = new JLabel();        constraintsLabel = new JLabel();        cvLabel = new JLabel();        typeTextField = new JTextField(30);        changeButton = new JButton();        cancelButton = new JButton();        timeAlignableCheckbox = new JCheckBox("", true);        timeAlignableCheckbox.setEnabled(false);        graphicReferencesCheckbox = new JCheckBox("", false);        constraintsComboBox = new JComboBox();        currentTypesComboBox = new JComboBox();        currentTypesComboBox.setMaximumRowCount(Constants.COMBOBOX_VISIBLE_ROWS);        cvComboBox = new JComboBox();        buttonPanel = new JPanel(new GridLayout(1, 2, 6, 2));        // add stereotypes        constraintsComboBox.addItem(none);        //get all stereotypes and add them to the choice menu        String[] publicStereoTypes = Constraint.publicStereoTypes;        for (int i = 0; i < publicStereoTypes.length; i++) {            constraintsComboBox.addItem(publicStereoTypes[i]);        }        constraintsComboBox.addItemListener(this);        typePanel = new JPanel();        typePanel.setLayout(new GridBagLayout());        ImageIcon tickIcon = new ImageIcon(this.getClass().getResource("/mpi/eudico/client/annotator/resources/Tick16.gif"));        ImageIcon untickIcon = new ImageIcon(this.getClass().getResource("/mpi/eudico/client/annotator/resources/Untick16.gif"));        CheckBoxTableCellRenderer cbRenderer = new CheckBoxTableCellRenderer();        cbRenderer.setIcon(untickIcon);        cbRenderer.setSelectedIcon(tickIcon);        cbRenderer.setHorizontalAlignment(SwingConstants.CENTER);        String[] columns = new String[] {                LinguisticTypeTableModel.NAME,                LinguisticTypeTableModel.STEREOTYPE,                LinguisticTypeTableModel.CV_NAME,                LinguisticTypeTableModel.TIME_ALIGNABLE,                LinguisticTypeTableModel.GRAPHICS            };        model = new LinguisticTypeTableModel(transcription.getLinguisticTypes(),                columns);        typeTable = new JTable(model);        typeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        typeTable.getSelectionModel().addListSelectionListener(this);        for (int i = 0; i < typeTable.getColumnCount(); i++) {            if (typeTable.getModel().getColumnClass(i) != String.class) {                typeTable.getColumn(typeTable.getModel().getColumnName(i))                         .setPreferredWidth(35);            }            if (typeTable.getModel().getColumnClass(i) == Boolean.class) {                typeTable.getColumn(typeTable.getModel().getColumnName(i))                         .setCellRenderer(cbRenderer);            }        }        JScrollPane typeScrollPane = new JScrollPane(typeTable);        Dimension size = new Dimension(300, 120);        typeScrollPane.setMinimumSize(size);        typeScrollPane.setPreferredSize(size);        tabPane = new JTabbedPane();        getContentPane().setLayout(new GridBagLayout());        Insets insets = new Insets(2, 6, 2, 6);        GridBagConstraints gbc = new GridBagConstraints();        titleLabel.setFont(titleLabel.getFont().deriveFont((float) 16));        titleLabel.setHorizontalAlignment(SwingConstants.CENTER);        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;        typePanel.add(typeScrollPane, 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(typePanel, 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());        GridBagConstraints lgbc = new GridBagConstraints();        lgbc.anchor = GridBagConstraints.NORTHWEST;        lgbc.insets = insets;        editPanel.add(currentTypesLabel, 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(currentTypesComboBox, rgbc);        lgbc.gridy = 1;        editPanel.add(typeLabel, lgbc);        rgbc.gridy = 1;        editPanel.add(typeTextField, rgbc);        lgbc.gridy = 2;        editPanel.add(constraintsLabel, lgbc);        rgbc.gridy = 2;        editPanel.add(constraintsComboBox, rgbc);        lgbc.gridy = 3;        editPanel.add(cvLabel, lgbc);        rgbc.gridy = 3;        editPanel.add(cvComboBox, rgbc);        lgbc.gridy = 4;        editPanel.add(timeAlignableLabel, lgbc);        rgbc.gridy = 4;        editPanel.add(timeAlignableCheckbox, rgbc);        lgbc.gridy = 5;        editPanel.add(graphicReferencesLabel, lgbc);        rgbc.gridy = 5;        editPanel.add(graphicReferencesCheckbox, 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;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.insets = insets;        gbc.weightx = 1.0;        importPanel.add(importSourceTF, gbc);        gbc = new GridBagConstraints();        gbc.gridx = 1;        gbc.gridy = 1;        gbc.fill = GridBagConstraints.NONE;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.insets = insets;        importPanel.add(importSourceButton, gbc);        tabPane.addTab(ElanLocale.getString("Button.Add"), null);        tabPane.addTab(ElanLocale.getString("Button.Change"), null);        tabPane.addTab(ElanLocale.getString("Button.Delete"), null);        tabPane.addTab(ElanLocale.getString("Button.Import"), importPanel);        if (mode < IMPORT) {            tabPane.setComponentAt(mode, editPanel);        } else {            tabPane.setComponentAt(0, editPanel);        }        tabPane.setSelectedIndex(mode);        tabPane.addChangeListener(this);        // buttons        changeButton.addActionListener(this);        cancelButton.addActionListener(this);        buttonPanel.add(changeButton);        buttonPanel.add(cancelButton);        gbc = new GridBagConstraints();        gbc.gridy = 3;        gbc.anchor = GridBagConstraints.SOUTH;        gbc.insets = insets;        getContentPane().add(buttonPanel, gbc);    }    /**     * Pack, size and set location.     */    private void postInit() {        pack();        int w = 550;        int h = 400;        setSize((getSize().width < w) ? w : getSize().width,            (getSize().height < h) ? h : getSize().height);        setLocationRelativeTo(getParent());    }    private void updateLocale() {        typeLabel.setText(ElanLocale.getString("EditTypeDialog.Label.Type"));        typePanel.setBorder(new TitledBorder(ElanLocale.getString(

⌨️ 快捷键说明

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