📄 chatexportdlg.java
字号:
/* * File: CHATExportDlg.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 *//* * Options dialog to set all parameters for CHAT Export. * * @author Hennie Brugman */package mpi.eudico.client.annotator.export;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.annotator.Preferences;import mpi.eudico.client.annotator.gui.ClosableDialog;import mpi.eudico.client.annotator.util.ElanFileFilter;import mpi.eudico.server.corpora.clom.Tier;import mpi.eudico.server.corpora.clom.Transcription;import mpi.eudico.server.corpora.clom.TranscriptionStore;import mpi.eudico.server.corpora.clomimpl.abstr.MediaDescriptor;import mpi.eudico.server.corpora.clomimpl.abstr.TierImpl;import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl;import mpi.eudico.server.corpora.clomimpl.chat.CHATEncoderInfo;import mpi.eudico.server.corpora.clomimpl.dobes.ACM24TranscriptionStore;import java.awt.BorderLayout;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.util.Vector;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComponent;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTextField;import javax.swing.SwingConstants;import javax.swing.border.TitledBorder;import javax.swing.filechooser.FileFilter;/** * DOCUMENT ME! * * @author hennie */public class CHATExportDlg extends ClosableDialog implements ActionListener { /** Holds value of property DOCUMENT ME! */ private final int NUM_OF_COLUMNS = 7; /** Holds value of property DOCUMENT ME! */ private final int NUM_OF_DEP_COLUMNS = 3; /** Holds value of property DOCUMENT ME! */ private final String MAIN_TIER = "Main Tier"; /** Holds value of property DOCUMENT ME! */ private final String DEPENDENT_TIER = "Dependent Tier"; /** Holds value of property DOCUMENT ME! */ private final String LABEL = "Label"; /** Holds value of property DOCUMENT ME! */ private final String FULL_NAME = "Full Name"; /** Holds value of property DOCUMENT ME! */ private final String ROLE = "Role"; /** Holds value of property DOCUMENT ME! */ private final String ID = "ID"; /** Holds value of property DOCUMENT ME! */ private final String LANGUAGE = "Language"; private TranscriptionImpl transcription; private ACM24TranscriptionStore acmTranscriptionStore; private Vector visibleTiers; private JLabel titleLabel; private JPanel titlePanel; private JComponent[][] mainTierTable; private JComponent[][] dependentTierTable; private JPanel mainTiersPanel; private JPanel dependentTiersPanel; private JPanel optionsPanel; private JPanel buttonPanel; private JButton exportButton; private TitledBorder mainTiersBorder; private TitledBorder dependentTiersBorder; private TitledBorder optionsBorder; private JCheckBox correctTimesCB; private JCheckBox timesOnSeparateLineCB; /** * Creates a new CHATExportDlg instance * * @param frame DOCUMENT ME! * @param modal DOCUMENT ME! * @param tr DOCUMENT ME! * @param acmTranscriptionStore DOCUMENT ME! * @param visibleTiers DOCUMENT ME! */ public CHATExportDlg(JFrame frame, boolean modal, Transcription tr, ACM24TranscriptionStore acmTranscriptionStore, Vector visibleTiers) { super(frame, modal); //this.frame = frame; transcription = (TranscriptionImpl) tr; this.acmTranscriptionStore = acmTranscriptionStore; this.visibleTiers = visibleTiers; // create main tier table (num of root tier records, NUM_OF_COLUMNS columns each) Vector topTiers = transcription.getTopTiers(); if (topTiers != null) { int numOfTiers = transcription.getTiers().size(); mainTierTable = new JComponent[NUM_OF_COLUMNS][topTiers.size() + 1]; dependentTierTable = new JComponent[NUM_OF_DEP_COLUMNS][numOfTiers - topTiers.size() + 1]; } mainTiersPanel = new JPanel(); dependentTiersPanel = new JPanel(); buttonPanel = new JPanel(); exportButton = new JButton(); mainTiersBorder = new TitledBorder("Main tiers"); dependentTiersBorder = new TitledBorder("Dependent tiers"); createDialog(); updateForLocale(); setDefaultValues(); pack(); setLocationRelativeTo(getParent()); //setResizable(false); } private void createDialog() { getContentPane().setLayout(new GridBagLayout()); Insets insets = new Insets(2, 6, 2, 6); titleLabel = new JLabel(); titlePanel = new JPanel(); titlePanel.setLayout(new BorderLayout(0, 4)); titleLabel.setFont(titleLabel.getFont().deriveFont((float) 16)); titleLabel.setHorizontalAlignment(SwingConstants.CENTER); JPanel titleLabelPanel = new JPanel(); titleLabelPanel.add(titleLabel); titlePanel.add(titleLabelPanel, BorderLayout.NORTH); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.NORTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = insets; getContentPane().add(titlePanel, gridBagConstraints); mainTiersPanel.setLayout(new GridBagLayout()); dependentTiersPanel.setLayout(new GridBagLayout()); buttonPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); // main tiers panel JComponent tableComponent = null; JPanel mtPanel = new JPanel(new GridBagLayout()); JScrollPane scrollPane = new JScrollPane(mtPanel); scrollPane.setBorder(null); mainTiersPanel.setBorder(mainTiersBorder); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.weighty = 0.0; c.insets = insets; //getContentPane().add(mainTiersPanel, c); mtPanel.add(mainTiersPanel, c); // header row c = new GridBagConstraints(); tableComponent = new JLabel(MAIN_TIER); mainTierTable[1][0] = tableComponent; c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JLabel(LABEL); mainTierTable[2][0] = tableComponent; c.gridx = 2; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JLabel(FULL_NAME); mainTierTable[3][0] = tableComponent; c.gridx = 3; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JLabel(ROLE); mainTierTable[4][0] = tableComponent; c.gridx = 4; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JLabel(ID); mainTierTable[5][0] = tableComponent; c.gridx = 5; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JLabel(LANGUAGE); mainTierTable[5][0] = tableComponent; c.gridx = 6; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); // row for each top level tier Vector topTiers = transcription.getTopTiers(); if (topTiers != null) { for (int i = 0; i < topTiers.size(); i++) { String tName = ((Tier) topTiers.elementAt(i)).getName(); tableComponent = new JCheckBox(); ((JCheckBox) tableComponent).setSelected(true); mainTierTable[0][i + 1] = tableComponent; c.gridx = 0; c.gridy = i + 1; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JLabel(tName); mainTierTable[1][i + 1] = tableComponent; c.gridx = 1; c.gridy = i + 1; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JTextField(3); String defaultName = "*"; if (tName.startsWith("*") && (tName.length() == 4)) { defaultName = tName; } ((JTextField) tableComponent).setText(defaultName); mainTierTable[2][i + 1] = tableComponent; c.gridx = 2; c.gridy = i + 1; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JTextField(12); mainTierTable[3][i + 1] = tableComponent; c.gridx = 3; c.gridy = i + 1; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JTextField(8); mainTierTable[4][i + 1] = tableComponent; c.gridx = 4; c.gridy = i + 1; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JTextField(18); mainTierTable[5][i + 1] = tableComponent; c.gridx = 5; c.gridy = i + 1; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); tableComponent = new JTextField(8); String language = ((TierImpl) topTiers.elementAt(i)).getDefaultLocale() .getLanguage(); if ((language != null) && !language.equals("")) { ((JTextField) tableComponent).setText(language); } mainTierTable[6][i + 1] = tableComponent; c.gridx = 6; c.gridy = i + 1; c.anchor = GridBagConstraints.WEST; c.insets = insets; mainTiersPanel.add(tableComponent, c); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -