📄 editcvdialog.java
字号:
/* * File: EditCVDialog.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.commands.Command;import mpi.eudico.client.annotator.commands.ELANCommandFactory;import mpi.eudico.client.annotator.util.ElanFileFilter;import mpi.eudico.server.corpora.clom.Transcription;import mpi.eudico.server.corpora.clomimpl.abstr.ParseException;import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl;import mpi.eudico.server.corpora.clomimpl.dobes.EAFSkeletonParser;import mpi.util.ControlledVocabulary;import mpi.util.gui.AbstractEditCVDialog;import java.awt.Dimension;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemListener;import java.io.File;import java.util.ArrayList;import java.util.List;import java.util.logging.Logger;import javax.swing.Action;import javax.swing.ActionMap;import javax.swing.ComponentInputMap;import javax.swing.InputMap;import javax.swing.JButton;import javax.swing.JComponent;import javax.swing.JFileChooser;import javax.swing.JOptionPane;import javax.swing.JTextArea;import javax.swing.KeyStroke;import javax.swing.border.TitledBorder;/** * $Id: EditCVDialog.java,v 1.13 2007/02/27 09:43:07 hasloe Exp $ * * The Edit Controlled Vocabulary dialog is a dialog for defining and changing * controlled vocabularies and their entries.<br> * * @author Han Sloetjes, Alexander Klassmann * @version jun 04 * @version Aug 2005 Identity removed * @version July 2006 refactored * */public class EditCVDialog extends AbstractEditCVDialog implements ActionListener, ItemListener { /** a logger */ private static final Logger LOG = Logger.getLogger(EditCVDialog.class.getName()); private JButton importButton; private TranscriptionImpl transcription; /** Holds value of property DOCUMENT ME! */ private final int SKIP = 0; /** Holds value of property DOCUMENT ME! */ private final int REPLACE = 1; /** Holds value of property DOCUMENT ME! */ private final int RENAME = 2; /** Holds value of property DOCUMENT ME! */ private final int MERGE = 3; /** * Creates a new EditCVDialog. * * @param transcription the transcription containing the controlled * vocabularies */ public EditCVDialog(Transcription transcription) { super(ELANCommandFactory.getRootFrame(transcription), true, true, new ElanEditCVPanel()); this.transcription = (TranscriptionImpl) transcription; addCloseActions(); updateLabels(); setPosition(); updateComboBox(); cvNameTextField.requestFocus(); } /** * The button actions. * * @param actionEvent the actionEvent */ public void actionPerformed(ActionEvent actionEvent) { Object source = actionEvent.getSource(); // check source equality if (source == importButton) { importCV(); } else { super.actionPerformed(actionEvent); } } /** * DOCUMENT ME! */ public void updateLocale() { ((ElanEditCVPanel) cvEditorPanel).updateLabels(); updateLabels(); } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ protected List getCVList() { return transcription.getControlledVocabularies(); } /** * Calls command to add a CV to the transcription. Re-initializes gui afterwords. */ protected void addCV(String name) { //create a new CV and add it to the Transcription Command com = ELANCommandFactory.createCommand(transcription, ELANCommandFactory.ADD_CV); Object[] args = new Object[2]; args[0] = name; args[1] = cvDescArea.getText(); com.execute(transcription, args); updateComboBox(); cvComboBox.setSelectedIndex(cvComboBox.getItemCount() - 1); } /** * Calls command to change the CV in the transcription. */ protected void changeCV(ControlledVocabulary cv, String name, String description) { // create a change CV command Command com = ELANCommandFactory.createCommand(transcription, ELANCommandFactory.CHANGE_CV); Object[] args = new Object[4]; args[0] = oldCVName; args[1] = (description != null) ? description : oldCVDesc; args[2] = (name != null) ? name : oldCVName; args[3] = description; com.execute(transcription, args); updateComboBox(); cvComboBox.setSelectedItem(cv); } /** * If there are any tiers using this * cv, a message will ask the user for confirmation. * (Overrides condition of super class) */ protected void deleteCV() { ControlledVocabulary conVoc = (ControlledVocabulary) cvComboBox.getSelectedItem(); // warn if there are tiers using lin. types using this cv if (transcription.getTiersWithCV(conVoc.getName()).size() > 0) { String mes = ElanLocale.getString("EditCVDialog.Message.CVInUse") + "\n" + ElanLocale.getString("EditCVDialog.Message.CVConfirmDelete"); if (!showConfirmDialog(mes)) { return; } } deleteCV(conVoc); } /** * Calls command to delete CV in the transcription. Re-initializes gui afterwords. */ protected void deleteCV(ControlledVocabulary cv) { Command com = ELANCommandFactory.createCommand(transcription, ELANCommandFactory.DELETE_CV); com.execute(transcription, new Object[] { cv }); updateComboBox(); if (cvComboBox.getItemCount() == 0) { cvEditorPanel.setControlledVocabulary(null); } } /** * This method is called from within the constructor to initialize the * dialog's components. */ protected void makeLayout() { super.makeLayout(); importButton = new JButton(); importButton.addActionListener(this); cvButtonPanel.add(importButton); } /** * Shows a confirm (yes/no) dialog with the specified message string. * * @param message the messsage to display * * @return true if the user clicked OK, false otherwise */ protected boolean showConfirmDialog(String message) { int confirm = JOptionPane.showConfirmDialog(this, message, ElanLocale.getString("Message.Warning"), JOptionPane.YES_NO_OPTION); return confirm == JOptionPane.YES_OPTION; } /** * Shows a warning/error dialog with the specified message string. * * @param message the message to display */ protected void showWarningDialog(String message) { JOptionPane.showMessageDialog(this, message, ElanLocale.getString("Message.Warning"), JOptionPane.WARNING_MESSAGE); } /** * Since this dialog is meant to be moda l a Locale change while this dialog * is open is not supposed to happen. This will set the labels etc. using * the current locale strings. */ protected void updateLabels() { closeDialogButton.setText(ElanLocale.getString( "EditCVDialog.Button.Close")); deleteCVButton.setText(ElanLocale.getString("Button.Delete")); changeCVButton.setText(ElanLocale.getString("Button.Change")); addCVButton.setText(ElanLocale.getString("Button.Add")); importButton.setText(ElanLocale.getString("Button.Import")); cvDescLabel.setText(ElanLocale.getString( "EditCVDialog.Label.CVDescription")); cvNameLabel.setText(ElanLocale.getString("EditCVDialog.Label.Name")); cvPanel.setBorder(new TitledBorder(ElanLocale.getString( "EditCVDialog.Label.CV"))); currentCVLabel.setText(ElanLocale.getString( "EditCVDialog.Label.Current")); titleLabel.setText(ElanLocale.getString("EditCVDialog.Title")); setTitle(ElanLocale.getString("EditCVDialog.Title")); cvNameExistsMessage = ElanLocale.getString( "EditCVDialog.Message.CVExists"); cvInvalidNameMessage = ElanLocale.getString( "EditCVDialog.Message.CVValidName"); cvContainsEntriesMessage = ElanLocale.getString( "EditCVDialog.Message.CVInUse"); deleteQuestion = ElanLocale.getString( "EditCVDialog.Message.CVConfirmDelete"); } /** * Prompts the user to select an template import file. * * @return the template file, or null when no valid file was selected */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -