📄 elanframe2.java
字号:
/* * File: ElanFrame2.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;import mpi.eudico.client.annotator.commands.BackupCA;import mpi.eudico.client.annotator.commands.Command;import mpi.eudico.client.annotator.commands.CommandAction;import mpi.eudico.client.annotator.commands.ELANCommandFactory;import mpi.eudico.client.annotator.commands.StoreCommand;import mpi.eudico.client.annotator.commands.global.*;import mpi.eudico.client.annotator.grid.GridViewer;import mpi.eudico.client.annotator.gui.ElanMenuItem;import mpi.eudico.client.annotator.linkedmedia.LinkedFileDescriptorUtil;import mpi.eudico.client.annotator.linkedmedia.MediaDescriptorUtil;import mpi.eudico.client.annotator.player.JMFGraphicMediaPlayer;import mpi.eudico.client.annotator.svg.SVGPrefs;import mpi.eudico.client.annotator.util.ElanFileFilter;import mpi.eudico.client.annotator.util.FileUtility;import mpi.eudico.client.annotator.util.FrameConstants;import mpi.eudico.client.annotator.viewer.InterlinearViewer;import mpi.eudico.client.annotator.viewer.SubtitleViewer;import mpi.eudico.client.annotator.viewer.TextViewer;import mpi.eudico.client.annotator.viewer.TimeLineViewer;import mpi.eudico.client.annotator.viewer.TimeSeriesViewer;import mpi.eudico.client.mac.MacApplicationListener;import mpi.eudico.p2p.*;import mpi.eudico.server.corpora.clom.DecoderInfo;import mpi.eudico.server.corpora.clom.Tier;import mpi.eudico.server.corpora.clom.Transcription;import mpi.eudico.server.corpora.clomimpl.abstr.MediaDescriptor;import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl;import mpi.eudico.server.corpora.clomimpl.dobes.ACM24TranscriptionStore;import java.awt.Dimension;import java.awt.Point;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.KeyEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.File;import java.util.ArrayList;import java.util.Enumeration;import java.util.HashMap;import java.util.Hashtable;import java.util.Iterator;import java.util.Locale;import java.util.Vector;import javax.swing.AbstractAction;import javax.swing.Action;import javax.swing.ActionMap;import javax.swing.ButtonGroup;import javax.swing.ComponentInputMap;import javax.swing.ImageIcon;import javax.swing.InputMap;import javax.swing.JCheckBoxMenuItem;import javax.swing.JComponent;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.JPopupMenu;import javax.swing.JRadioButtonMenuItem;import javax.swing.JTextField;import javax.swing.KeyStroke;import javax.swing.SwingUtilities;import javax.swing.UIManager;import javax.swing.filechooser.FileFilter;import javax.swing.text.DefaultEditorKit;import javax.swing.text.JTextComponent;import javax.swing.text.Keymap;/** * DOCUMENT ME! $Id: ElanFrame2.java,v 1.44 2007/04/16 15:41:39 hasloe Exp $ * * @author $Author: hasloe $ * @version $Revision: 1.44 $ */public class ElanFrame2 extends JFrame implements ActionListener, ElanLocaleListener, MacApplicationListener, FrameConstants { // load some keybindings for the Mac static { if (System.getProperty("os.name").indexOf("Mac") > -1) { JTextComponent.KeyBinding[] bind = new JTextComponent.KeyBinding[] { new JTextComponent.KeyBinding(KeyStroke.getKeyStroke( KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), DefaultEditorKit.copyAction), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke( KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), DefaultEditorKit.cutAction), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke( KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), DefaultEditorKit.pasteAction), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke( KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), DefaultEditorKit.selectAllAction) }; JTextComponent comp = new JTextField(); Keymap map = JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP); JTextComponent.loadKeymap(map, bind, comp.getActions()); } } /** a list of actions for menu containers and a few transcription independent * actions */ private ArrayList menuActions = new ArrayList(20); /** a map for actions that are added to the menubar's action map * this storage is needed for detaching and re-attaching actions to the menu bar */ private HashMap registeredActions = new HashMap(); private Transcription transcriptionForThisFrame; private JMenuBar menuBar; private JMenu menuFile; private JMenuItem menuItemFileNew; private JMenuItem menuItemFileOpen; private JMenu menuRecentFiles; private JMenuItem menuItemFileExit; private JMenu menuBackup; private JMenu menuImport; private JMenu menuExport; private JMenuItem menuItemShoeboxImport; private JMenuItem menuItemCHATImport; private JMenuItem menuItemTranscriberImport; private JMenuItem menuItemDiscoverDoc; private JMenuItem menuItemPublishDoc; private JMenu menuEdit; private JMenu menuAnnotation; private JMenu menuTier; private JMenu menuType; private JMenu menuWindow; private ButtonGroup windowsGroup; private JMenu menuSearch; private JMenu menuView; private JMenu menuOptions; private JCheckBoxMenuItem menuItemNativeMedia; private JCheckBoxMenuItem menuItemPermanentDetached; private JCheckBoxMenuItem menuMacNativeLF; private JRadioButtonMenuItem menuItemAnnoMode; private JRadioButtonMenuItem menuItemSyncMode; private JCheckBoxMenuItem menuItemKioskMode; private JMenuItem menuItemPlayAround; private JMenuItem menuItemRateVol; private JMenu menuP2P; private JMenu menuHelp; private JMenu menuFrameLength; private JMenu menuAppLanguage; private ButtonGroup languageBG; private JMenu menuChangeTimePropMode; private JMenuItem menuItemOptionsEnglish; private JMenuItem menuItemOptionsDutch; private ElanLayoutManager layoutManager; private ViewerManager2 viewerManager; private ElanP2P elanP2P; /** * The no arg constructor creates an empty elan frame containing a menubar * with a limited set of menu items. */ public ElanFrame2() { /* disabled for the time being String p2p = System.getProperty("P2P"); if ((p2p != null) && p2p.equals("true")) { elanP2P = new ElanP2P(this); } */ // set the initial title setTitle("Elan"); ImageIcon icon = new ImageIcon(this.getClass().getResource("/mpi/eudico/client/annotator/resources/ELAN16.png")); if (icon != null) { setIconImage(icon.getImage()); } else { setIconImage(null); } initFrame(); } /** * Constructor that accepts the path to an .eaf file. This first creates an * empty frame and then calls openEAF to open the specified .eaf file. * * @param path the location of the eaf file * * @see #openEAF(String) */ public ElanFrame2(final String path) { this(); if (path != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { openEAF(path); } }); } } /** * Creates a new ElanFrame2 instance * * @param eafPath DOCUMENT ME! * @param mediaFiles DOCUMENT ME! */ public ElanFrame2(final String eafPath, final Vector mediaFiles) { this(); if (eafPath != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { openEAF(eafPath, mediaFiles); } }); } } /** * Constructor that accepts a Transcription object to use for the current * ElanFrame. * * @param transcription the trancription */ public ElanFrame2(Transcription transcription) { this(); transcriptionForThisFrame = transcription; // fill the frame if transcription != null if (transcriptionForThisFrame != null) { try { //new InitThread(transcriptionForThisFrame.getName()).start(); initElan(); } catch (Exception e) { e.printStackTrace(); } } } /** * Open an .eaf file defined by a full path string * Nov 2006: changed access from private to package * @param fullPath * @param mediaFiles a vector containing associated media files */ void openEAF(String fullPath, Vector mediaFiles) { 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(this, strMessage, strError, JOptionPane.ERROR_MESSAGE); return; } //check if file is a '.eaf' file if (fileTemp.toString().toLowerCase().endsWith(".eaf") == false) { String strMessage = ElanLocale.getString("Menu.Dialog.Message1"); strMessage += fullPath; strMessage += ElanLocale.getString("Menu.Dialog.Message3"); String strError = ElanLocale.getString("Message.Error");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -