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

📄 importpraattgstep1.java

📁 编辑视频文件
💻 JAVA
字号:
/* * File:     ImportPraatTGStep1.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.imports.praat;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.annotator.Preferences;import mpi.eudico.client.annotator.gui.multistep.MultiStepPane;import mpi.eudico.client.annotator.gui.multistep.StepPane;import mpi.eudico.client.annotator.util.ElanFileFilter;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 javax.swing.JButton;import javax.swing.JFileChooser;import javax.swing.JOptionPane;import javax.swing.JTextField;import javax.swing.border.EmptyBorder;/** * First step of an import Praat TextGrid process. */public class ImportPraatTGStep1 extends StepPane implements ActionListener {    private JTextField sourceField;    private JButton browseButton;    /**     * Creates a new instance of the first step of the wizard.     *     * @param multiPane the parent pane     */    public ImportPraatTGStep1(MultiStepPane multiPane) {        super(multiPane);        initComponents();    }    /**     * Initializes ui components.     */    public void initComponents() {        setLayout(new GridBagLayout());        setBorder(new EmptyBorder(12, 12, 12, 12));        sourceField = new JTextField();        sourceField.setEditable(false);        browseButton = new JButton(ElanLocale.getString("Button.Browse"));        Insets insets = new Insets(4, 6, 4, 6);        GridBagConstraints gbc = new GridBagConstraints();        gbc.gridx = 0;        gbc.gridy = 0;        gbc.anchor = GridBagConstraints.WEST;        gbc.insets = insets;        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.weightx = 1.0;        add(sourceField, gbc);        gbc.gridx = 1;        gbc.fill = GridBagConstraints.NONE;        gbc.weightx = 0.0;        add(browseButton, gbc);        browseButton.addActionListener(this);    }    /**     * @see mpi.eudico.client.annotator.gui.multistep.Step#getStepTitle()     */    public String getStepTitle() {        return ElanLocale.getString("ImportDialog.Praat.Title1");    }    /**     * @see mpi.eudico.client.annotator.gui.multistep.Step#enterStepBackward()     */    public void enterStepBackward() {        multiPane.setButtonEnabled(MultiStepPane.NEXT_BUTTON, true);        multiPane.setButtonEnabled(MultiStepPane.CANCEL_BUTTON, true);    }    /**     * @see mpi.eudico.client.annotator.gui.multistep.Step#leaveStepForward()     */    public boolean leaveStepForward() {        multiPane.putStepProperty("Source", sourceField.getText());        return true;    }    /**     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)     */    public void actionPerformed(ActionEvent e) {        File file = getFileName();        if (file != null) {            sourceField.setText(file.getAbsolutePath());            multiPane.setButtonEnabled(MultiStepPane.NEXT_BUTTON, true);        }    }    private File getFileName() {        JFileChooser chooser = new JFileChooser();        chooser.setFileFilter(ElanFileFilter.createFileFilter(                ElanFileFilter.PRAAT_TEXTGRID_TYPE));        chooser.setDialogTitle(ElanLocale.getString("ImportDialog.Title.Select"));        String dirPath = (String) Preferences.get("LastUsedPraatDir", null);        if (dirPath == null) {            // user.dir is probably a better choice than home.dir?            dirPath = System.getProperty("user.dir");        }        chooser.setCurrentDirectory(new File(dirPath));        int returnVal = chooser.showOpenDialog(null);        if (returnVal == JFileChooser.APPROVE_OPTION) {            String fullPath = chooser.getSelectedFile().getAbsolutePath();            File fileTemp = new File(fullPath);            //check if file exists and is a file            if (!fileTemp.exists() || fileTemp.isDirectory()) {                String strMessage = ElanLocale.getString("Menu.Dialog.Message1");                strMessage += fullPath;                strMessage += ElanLocale.getString("Menu.Dialog.Message2");                String strError = ElanLocale.getString("Message.Error");                JOptionPane.showMessageDialog(null, strMessage, strError,                    JOptionPane.ERROR_MESSAGE);                return null;            }            // check the file extension??            Preferences.set("LastUsedPraatDir", fileTemp.getParent(), null);            return fileTemp;        }        return null;    }}

⌨️ 快捷键说明

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