📄 importshoeboxwac.java
字号:
/* * File: ImportShoeboxWAC.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.ElanLocale;import mpi.eudico.client.annotator.Preferences;import mpi.eudico.client.annotator.util.*;import mpi.eudico.server.corpora.clomimpl.shoebox.ShoeboxPreferences;import mpi.eudico.server.corpora.clomimpl.shoebox.ToolboxDecoderInfo;import java.awt.BorderLayout;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.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.io.File;import java.util.List;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComponent;import javax.swing.JDialog;import javax.swing.JFileChooser;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.JTextField;import javax.swing.border.TitledBorder;/** * Displays a dialog to either import a WAC file or a Shoebox file. Uses a * JOptionPane style mechanism to display a JDialog and return an Object as a * user value.<br> * <b>Note: </b>localization of the file choosers is not implemented (yet). * * @author Han Sloetjes */public class ImportShoeboxWAC extends JComponent implements ActionListener, ItemListener { /** Holds value of property DOCUMENT ME! */ public static final int SHOEBOX = 0; /** Holds value of property DOCUMENT ME! */ public static final int WAC = 1; private static int importType; /** Holds value of property DOCUMENT ME! */ public static final String VALUE_PROPERTY = "value"; /** Holds value of property DOCUMENT ME! */ public static final String TEXT_KEY = "TextFile"; /** Holds value of property DOCUMENT ME! */ public static final String TYPE_KEY = "TypeFile"; /** Holds value of property DOCUMENT ME! */ // public static final String MEDIA_KEY = "MediaFile"; private JTextField sbxField = new JTextField("", 23); private JTextField typField = new JTextField("", 23); // private JTextField auField = new JTextField("", 23); private GridBagLayout gridbag = new GridBagLayout(); private JButton txtButton; private JButton typButton; // private JButton medButton; private JButton fieldSpecButton; private JButton okButton; private JButton cancelButton; private JRadioButton typeRB; private JRadioButton specRB; private JLabel typeLabel; private JLabel intervalLabel; private JTextField intervalField; private JCheckBox timeInRefMarker; private JCheckBox allUnicodeCB; /** Holds value of property DOCUMENT ME! */ private final String INTERVAL_PREF = "ShoeboxChatBlockDuration"; // private File lastUsedDir;//used for elan properties file /** Used for the storage of the filenames and media files */ //private Hashtable fileNames = new Hashtable(); private List markers = null; // private Vector mediaFileNames; private Object value; /** * Creates a new ImportShoeboxWAC instance * * @param type either <code>WAC</code> or <code>SHOEBOX</code> */ private ImportShoeboxWAC(int type) { if (type == WAC) { importType = WAC; } else { importType = SHOEBOX; } createPane(); } private void createPane() { setLayout(gridbag); Insets insets = new Insets(2, 6, 2, 6); GridBagConstraints gbc = new GridBagConstraints(); int y = 0; if (importType == SHOEBOX) { ButtonGroup buttonGroup = new ButtonGroup(); typeRB = new JRadioButton(); typeRB.setSelected(true); specRB = new JRadioButton(); buttonGroup.add(typeRB); buttonGroup.add(specRB); gbc.gridx = 1; gbc.gridy = y; gbc.weightx = 0.0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = insets; add(new JLabel(ElanLocale.getString("ImportDialog.Label.Shoebox")), gbc); gbc.gridx = 2; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; add(sbxField, gbc); txtButton = new JButton("..."); txtButton.addActionListener(this); gbc.gridx = 3; gbc.weightx = 0.0; gbc.fill = GridBagConstraints.NONE; add(txtButton, gbc); y++; gbc.gridx = 0; gbc.gridy = y; add(typeRB, gbc); typeLabel = new JLabel(ElanLocale.getString( "ImportDialog.Label.Type")); gbc.gridx = 1; add(typeLabel, gbc); gbc.gridx = 2; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; add(typField, gbc); typButton = new JButton("..."); typButton.addActionListener(this); gbc.gridx = 3; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; add(typButton, gbc); y++; allUnicodeCB = new JCheckBox(ElanLocale.getString( "ImportDialog.Label.AllUnicode")); gbc.gridx = 1; gbc.gridy = y; gbc.gridwidth = 2; add(allUnicodeCB, gbc); y++; gbc.gridx = 0; gbc.gridy = y; add(specRB, gbc); fieldSpecButton = new JButton(ElanLocale.getString( "ImportDialog.Button.FieldSpec")); fieldSpecButton.addActionListener(this); fieldSpecButton.setEnabled(false); gbc.gridx = 1; add(fieldSpecButton, gbc); y++; JPanel optionsPanel = new JPanel(new GridBagLayout()); optionsPanel.setBorder(new TitledBorder(ElanLocale.getString( "ImportDialog.Label.Options"))); intervalLabel = new JLabel(ElanLocale.getString( "ImportDialog.Label.BlockDuration")); intervalField = new JTextField(); if (Preferences.get(INTERVAL_PREF, null) != null) { Integer val = (Integer) Preferences.get(INTERVAL_PREF, null); intervalField.setText("" + val.intValue()); } else { intervalField.setText("" + ShoeboxPreferences.DEFAULT_BLOCK_DURATION); } GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.insets = gbc.insets; gridBagConstraints.anchor = GridBagConstraints.WEST; optionsPanel.add(intervalLabel, gridBagConstraints); gridBagConstraints.gridx = 1; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; optionsPanel.add(intervalField, gridBagConstraints); timeInRefMarker = new JCheckBox(ElanLocale.getString( "ImportDialog.Label.TimeInRefMarker")); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; optionsPanel.add(timeInRefMarker, gridBagConstraints); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = y; gridBagConstraints.gridwidth = 4; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; add(optionsPanel, gridBagConstraints); setShoeboxMarkerRB(); typeRB.addItemListener(this); specRB.addItemListener(this); y++; } else { gbc.gridx = 0; gbc.gridy = y; gbc.weightx = 0.0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = insets; add(new JLabel(ElanLocale.getString("ImportDialog.Label.WAC")), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; add(sbxField, gbc); txtButton = new JButton("..."); txtButton.addActionListener(this); gbc.gridx = 2; gbc.weightx = 0.0; gbc.fill = GridBagConstraints.NONE; add(txtButton, gbc); y++; typeLabel = new JLabel(ElanLocale.getString( "ImportDialog.Label.Type")); gbc.gridx = 0; gbc.gridy = y; add(typeLabel, gbc); gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; add(typField, gbc); typButton = new JButton("..."); typButton.addActionListener(this); gbc.gridx = 2; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; add(typButton, gbc); y++; } // ok - cancel buttons // JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 6, 2)); okButton = new JButton(ElanLocale.getString("Button.OK")); okButton.addActionListener(this); cancelButton = new JButton(ElanLocale.getString("Button.Cancel")); cancelButton.addActionListener(this); buttonPanel.add(okButton); buttonPanel.add(cancelButton); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = GridBagConstraints.SOUTH; gbc.fill = GridBagConstraints.NONE; gbc.gridx = 0; gbc.gridy = y; ; add(buttonPanel, gbc); } private void setShoeboxMarkerRB() { Object useTyp = Preferences.get("LastUsedShoeboxImportWithType", null); if (useTyp instanceof Boolean && !((Boolean) useTyp).booleanValue()) { specRB.setSelected(true); typButton.setEnabled(false); fieldSpecButton.setEnabled(true); allUnicodeCB.setEnabled(false); } else { typeRB.setSelected(true); Object luTypFile = Preferences.get("LastUsedShoeboxTypFile", null); if (luTypFile instanceof String) { typField.setText((String) luTypFile); } typButton.setEnabled(true); allUnicodeCB.setEnabled(true); } } /** * DOCUMENT ME! * * @return DOCUMENT ME!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -