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

📄 shoeboxmarkerdialog.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * File:     ShoeboxMarkerDialog.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.util.ElanFileFilter;import mpi.eudico.server.corpora.clomimpl.shoebox.MarkerRecord;import mpi.eudico.server.corpora.clomimpl.shoebox.ShoeboxTypFile;import mpi.eudico.server.corpora.clomimpl.type.Constraint;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.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileOutputStream;import java.io.FileReader;import java.io.OutputStreamWriter;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import java.util.Vector;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.JTextField;import javax.swing.border.TitledBorder;/** * The Shoebox Marker dialog is a custom dialog for defining markers used in * Shoebox files that are imported. Alternative for using a Shoebox .typ file. * * @author Hennie Brugman * @version July 2004 */public class ShoeboxMarkerDialog extends ClosableDialog    implements ActionListener, ItemListener {    /** Holds value of property DOCUMENT ME! */    public final String none = "None";    private Frame frame;    //    private String oldType=new String();    private JLabel titleLabel = new JLabel();    private JLabel currentMarkerLabel = new JLabel();    private JLabel markerLabel = new JLabel();    private JLabel parentLabel = new JLabel();    private JLabel constraintsLabel = new JLabel();    private JLabel charsetLabel = new JLabel();    private JLabel participantLabel = new JLabel();    private JLabel excludeLabel = new JLabel();    private JComboBox currentMarkers = new JComboBox();    private JTextField markerTextField = new JTextField(30);    private JComboBox parents = new JComboBox();    private JComboBox constraints = new JComboBox();    private JComboBox charsets = new JComboBox();    private JCheckBox participantMarker = new JCheckBox();    private JCheckBox excludeCheckBox = new JCheckBox();    private JButton changeButton = new JButton();    private JButton cancelButton = new JButton();    private JButton addButton = new JButton();    private JButton deleteButton = new JButton();    private JButton loadButton = new JButton();    private JButton storeButton = new JButton();    private JPanel titlePanel = new JPanel();    private JPanel markerPanel = new JPanel();    private JPanel buttonPanel1 = new JPanel(new GridLayout(3, 1, 2, 6));    private JPanel buttonPanel2 = new JPanel(new GridLayout(1, 1, 0, 2));    private JPanel buttonPanel3 = new JPanel(new GridLayout(1, 3, 6, 6));    private ArrayList markers = new ArrayList();    //    private static Vector markers = new Vector();    /**     * A general purpose constructor for adding, changing or deleting a     * LinguisticType.<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 type of dialog, ADD, CHANGE or DELETE     */    public ShoeboxMarkerDialog(Frame theFrame, boolean modal) {        super(theFrame, modal);        frame = theFrame;        //loadMarkers(); // is this convenient or annoying? and what about serialisation when prefs are stored in xml format?        createDialog();        updateForLocale();        pack();        setResizable(false);        setLocationRelativeTo(frame);    }    /**     * DOCUMENT ME!     *     * @param parent DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public static Object showDialog(Frame parent) {        ShoeboxMarkerDialog dlg = new ShoeboxMarkerDialog(parent, true);        Object o = dlg.getValue();        return o;    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public Object getValue() {        // return null;        return markers;    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public List getMarkers() {        // return ShoeboxTypFile.getMarkers();        return markers;    }    /**      * Load the markers from a preferences file.      */    private void loadMarkers() {        Object luMarkers = Preferences.get("LastUsedShoeboxMarkers", null);        if (luMarkers instanceof ArrayList) {            markers = (ArrayList) luMarkers;        }    }    /**     * Initialize UI elements with the attributes from the argument marker     *     * @param markerName the name of the shoebox marker     */    private void updateUIForMarker(String markerName) {        if (markerName != null) {            markerTextField.setText(markerName);            Iterator markerIt = getMarkers().iterator();            MarkerRecord mr = null;            while (markerIt.hasNext()) {                mr = (MarkerRecord) markerIt.next();                if (mr.getMarker().equals(markerName)) {                    currentMarkers.setSelectedItem(mr.getMarker());                    fillParentMenu();                    parents.setSelectedItem(mr.getParentMarker());                    String stereoType = mr.getStereoType();                    if (stereoType != null) {                        constraints.setSelectedItem(mr.getStereoType());                    } else {                        constraints.setSelectedItem(none);                    }                    charsets.setSelectedItem(mr.getCharsetString());                    participantMarker.setSelected(mr.getParticipantMarker());                    excludeCheckBox.setSelected(mr.isExcluded());                    break;                }            }        }    }    private void fillCurrentMarkersMenu() {        // empty parents menu        currentMarkers.removeAllItems();        // add all markers that are not the specified marker or any of it's descendants        Iterator markerIter = getMarkers().iterator();        while (markerIter.hasNext()) {            MarkerRecord mr = (MarkerRecord) markerIter.next();            currentMarkers.addItem(mr.getMarker());        }    }    private void fillParentMenu() {        // empty parents menu        parents.removeAllItems();        // add all markers that are not the specified marker or any of it's descendants        Iterator markerIter = getMarkers().iterator();        while (markerIter.hasNext()) {            MarkerRecord mr = (MarkerRecord) markerIter.next();            parents.addItem(mr.getMarker());        }        // select the first one (temporarily)        if (parents.getItemCount() > 0) {            parents.setSelectedIndex(0);        }    }    private boolean isDescendentOf(MarkerRecord record, String ofMarkerName) {        // if record equals markerName, or        // if record has markerName as parent, or        // if record is descendent of 1 of the direct children of markerName        if (record.getMarker().equals(ofMarkerName)) {            return true;        }        if ((record.getParentMarker() != null) &&                record.getParentMarker().equals(ofMarkerName)) {            return true;        }        // find children of markerName        boolean isDescendent = false;        Iterator markerIter = getMarkers().iterator();        while (markerIter.hasNext()) {            MarkerRecord mr = (MarkerRecord) markerIter.next();            if ((mr.getParentMarker() != null) &&                    mr.getParentMarker().equals(ofMarkerName)) {                if (isDescendentOf(record, mr.getMarker())) {                    isDescendent = true;                    break;                }            }        }        return isDescendent;    }    private void createDialog() {        // HB, 9-7-02, add 'None' to stereoTypes menu        constraints.addItem(none);        //get all stereotypes and add them to the choice menu        String[] publicStereoTypes = Constraint.publicStereoTypes;        for (int i = 0; i < publicStereoTypes.length; i++) {            //	if (!publicStereoTypes[i].equals("Time Subdivision")) {            constraints.addItem(publicStereoTypes[i]);            //	}        }        charsets.addItem(MarkerRecord.ISOLATINSTRING);        charsets.addItem(MarkerRecord.UNICODESTRING);        charsets.addItem(MarkerRecord.SILIPASTRING);        currentMarkers.addItemListener(this);        currentMarkers.setMaximumRowCount(Constants.COMBOBOX_VISIBLE_ROWS);        titleLabel.setFont(titleLabel.getFont().deriveFont((float) 16));        titlePanel.add(titleLabel);        constraints.addItemListener(this);        changeButton.addActionListener(this);        cancelButton.addActionListener(this);        addButton.addActionListener(this);        deleteButton.addActionListener(this);        loadButton.addActionListener(this);        storeButton.addActionListener(this);        buttonPanel1.add(addButton);        buttonPanel1.add(deleteButton);        buttonPanel1.add(changeButton);        buttonPanel2.add(loadButton);        buttonPanel2.add(storeButton);        buttonPanel3.add(cancelButton);        addWindowListener(new WindowAdapter() {                public void windowClosing(WindowEvent event) {                    close();                }            });        //add Components        getContentPane().setLayout(new GridBagLayout());        markerPanel.setLayout(new GridBagLayout());        GridBagConstraints c = new GridBagConstraints();        Insets insets = new Insets(2, 6, 2, 6);        c.gridx = 0;        c.gridy = 0;        c.fill = GridBagConstraints.HORIZONTAL;

⌨️ 快捷键说明

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