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

📄 inlineeditbox.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                        "InlineEditBox.Attach"));            attachMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,                    ActionEvent.SHIFT_MASK));            attachMI.setActionCommand(EDIT_MENU_ATT);            attachMI.addActionListener(this);            editorMenu.add(attachMI);        }        commitMI = new JMenuItem(ElanLocale.getString("InlineEditBox.Commit"));        commitMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,                Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));        commitMI.setActionCommand(EDIT_MENU_CMT);        commitMI.addActionListener(this);        editorMenu.add(commitMI);        cancelMI = new JMenuItem(ElanLocale.getString("InlineEditBox.Cancel"));        cancelMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));        cancelMI.setActionCommand(EDIT_MENU_CNL);        cancelMI.addActionListener(this);        editorMenu.add(cancelMI);        cutMI = new JMenuItem(ElanLocale.getString("InlineEditBox.Edit.Cut"));        cutMI.setActionCommand("cut");        cutMI.addActionListener(this);        editMenu.add(cutMI);        copyMI = new JMenuItem(ElanLocale.getString("InlineEditBox.Edit.Copy"));        copyMI.setActionCommand("copy");        copyMI.addActionListener(this);        editMenu.add(copyMI);        pasteMI = new JMenuItem(ElanLocale.getString("InlineEditBox.Edit.Paste"));        pasteMI.setActionCommand("paste");        pasteMI.addActionListener(this);        editMenu.add(pasteMI);        selectAllMI = new JMenuItem(ElanLocale.getString(                    "InlineEditBox.Edit.SelectAll"));        selectAllMI.setActionCommand("selectAll");        selectAllMI.addActionListener(this);        editMenu.add(selectAllMI);        JMenuItem newItem;        for (int i = 0; i < numberOfLocales; i++) {            newItem = new JMenuItem(allLocales[i].getDisplayName());            selectLanguageMenu.add(newItem);            newItem.addActionListener(this);        }        menuBar.add(editorMenu);        menuBar.add(editMenu);        menuBar.add(selectLanguageMenu);        return menuBar;    }    /**     * Returns whether or not the current annotation's value is restricted by a     * ControlledVocabulary.     *     * @return true if a CV has to be used, false otherwise     */    public boolean isUsingControlledVocabulary() {        return isUsingControlledVocabulary;    }    /**     * Overrides setVisible(boolean) in JComponent.     *     * @param vis the visibility value     */    public void setVisible(boolean vis) {        super.setVisible(vis);        if (externalDialog != null) {            externalDialog.setVisible(vis);        }        if (vis == false) {            //closeIM();            if (table == null) {                setLocation(-10, -10);            }        }    }    /**     * Overrides setSize(Dimension) in Component by performing a check to     * guarantee a minimal  size.     *     * @param d the requested size     */    public void setSize(Dimension d) {        // set useable sizes for edit region        if (d.getWidth() < 60) {            d = new Dimension(60, d.height);        }        if (d.getHeight() < 38) {            d = new Dimension(d.width, 38);        }        //AK 16/08/2002 unfortunately all those setSizes are somewhere necessary        super.setSize(d);        setPreferredSize(d);        textAreaScrollPane.setPreferredSize(d);        textAreaScrollPane.setSize(d);    }    /**     * Overrides setFont(Font) in Component by also setting the font for the     * textareas.     *     * @param font the Font to use     */    public void setFont(Font font) {        super.setFont(font);        uniFont = font;        // setFont() is used at intializing superclass - textarea not yet instantiated        if (textArea != null) {            textArea.setFont(font);        }        if (exttextArea != null) {            exttextArea.setFont(font);        }    }    /**     * Sets the annotation that is to be edited.     * When <code>forceOpenCV</code> is true an 'open' text edit box will be used     * even if the linguistic type has an associated ControlledVocabulery.     *     * @param ann the annotation to be edited     * @param forceOpenCV if true the associated CV will be ignored,     * editing will be open     */    public void setAnnotation(Annotation ann, boolean forceOpenCV) {        annotation = ann;        oldText = ann.getValue();        textArea.setText(oldText.trim());        try {            annotationLocale = ((TierImpl) annotation.getTier()).getDefaultLocale();            if (forceOpenCV) {                isUsingControlledVocabulary = false;            } else {                isUsingControlledVocabulary = ((TierImpl) annotation.getTier()).getLinguisticType()                                               .isUsingControlledVocabulary();            }        } catch (Exception e) {            LOG.warning(                "Could not establish Default Language of Tier. Using System Default instead.");            annotationLocale = Locale.getDefault();            isUsingControlledVocabulary = false;        }        if (attached) {            if (!isUsingControlledVocabulary) {                textArea.setEditable(true);                textArea.setCaretPosition(textArea.getText().length());                //textArea.requestFocus();            } else {                textArea.setEditable(false);                if (cvEntryComp == null) {                    cvEntryComp = new CVEntryComponent(JScrollPane.class);                }                cvEntryComp.setAnnotation(annotation);            }        }    }    /**     * Sets the annotation that is to be edited.     *     * @param ann the annotation to be edited     */    public void setAnnotation(Annotation ann) {        setAnnotation(ann, false);    }    /**     * Checks whether the annotation's value has been edited.     *     * @return true if the annotation's value has been edited, false otherwise     */    public boolean annotationModified() {        return attached ? (!oldText.equals(textArea.getText()))                        : (!oldText.equals(exttextArea.getText()));    }    /**     * Returns true if the internal TextArea is open     *     * @return true if the component is attached to a viewer's layout     */    public boolean isAttached() {        return attached;    }    /**     * Sets internal TextArea (resp. "this") visible(false) and opens external     * TextArea (resp. "externalDialog")     */    public void detachEditor() {        if (attachable && !attached) {            return;        }        attached = false;        position = getLocation();        createExternalDialog();        if (dialogBounds != null) {            externalDialog.setBounds(dialogBounds);        } else {            Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();            Rectangle frameDim = externalDialog.getBounds();            externalDialog.setLocation((screenDim.width - frameDim.width) / 2,                (screenDim.height - frameDim.height) / 2);        }        ImUtil.setLanguage(textArea, Locale.getDefault());        setVisible(false);        if (table != null) {            editingColumn = table.getEditingColumn();            table.editingCanceled(new ChangeEvent(this));        }        if (!isUsingControlledVocabulary) {            externalDialog.getContentPane().removeAll();            externalDialog.getContentPane().add(exttextAreaScrollPane);            exttextArea.setEditable(true);            exttextArea.setText(textArea.getText());            exttextArea.setCaretPosition(exttextArea.getText().length());            exttextArea.setFont(textArea.getFont().deriveFont(20.0f));        } else {            if (cvEntryComp == null) {                cvEntryComp = new CVEntryComponent(JScrollPane.class);                cvEntryComp.setAnnotation(annotation);            } else {                //cvEntryComp.setAnnotation(annotation);                cvEntryComp.setDelegate(JScrollPane.class);            }            exttextArea.setEditable(false);            cvEntryComp.removePopupListener();            cvEntryComp.setFont(getFont());            externalDialog.getContentPane().removeAll();            externalDialog.getContentPane().add(cvEntryComp.getEditorComponent());        }        externalDialog.setVisible(true);    }    /**     * Returns the editor the editor to the previous attached state and dispose     * the external dialog.     */    protected void attachEditor() {        attached = true;        dialogBounds = externalDialog.getBounds();        externalDialog.dispose();        externalDialog = null;        if (table == null) {            setLocation(position);            setVisible(true);        } else {            Locale tmpLocale = annotationLocale;            //The TagCellEditor will call another time the setAnnotation method            //which sets again the default Locale of the Tier            //table.editCellAt(table.getRowOfAnnotation(annotation),1);            int[] selrows = table.getSelectedRows();            //int column = table.getSelectedColumn();            table.editCellAt(selrows[0], editingColumn);            annotationLocale = tmpLocale;        }        if (!isUsingControlledVocabulary) {            textArea.setText(exttextArea.getText());            textArea.requestFocus();        } else {            cvEntryComp.addPopupListener();            if (editorComponent == this) {                removeAll();                add(cvEntryComp.getEditorComponent(), BorderLayout.CENTER);            }            startEdit();        }    }    /**     * Resets elements and cleans up without applying any changes in the  value     * of the annotation.  HB, 11 oct 01, changed from protected to public     */    public void cancelEdit() {        isEditing = false;        closeIM();        if (attached) {            setVisible(false);        } else {            if (externalDialog != null) {                dialogBounds = externalDialog.getBounds();                setVisible(false);                externalDialog.dispose();                externalDialog = null;            }            attached = true;        }        if (table != null) {            table.editingCanceled(new ChangeEvent(this));        }        //M_P        handleSubtitleViewer();    }    /**     * Checks for modifications, applies the modification if any, resets and     * cleans  up a bit.     */    public void commitEdit() {        isEditing = false;        closeIM();        if (isUsingControlledVocabulary && (cvEntryComp != null)) {            if (attached) {                textArea.setText(cvEntryComp.getSelectedEntryValue());            } else {                exttextArea.setText(cvEntryComp.getSelectedEntryValue());            }        }        String newText = "";        boolean modified = annotationModified();        if (attached) {            if (modified) {                newText = textArea.getText();            }            setVisible(false);        } else {            if (modified) {                newText = exttextArea.getText();            }            dialogBounds = externalDialog.getBounds();            setVisible(false);            externalDialog.dispose();            externalDialog = null;            attached = true;        }        if (modified) {            Command c = ELANCommandFactory.createCommand(((Transcription) annotation.getTier()                                                                                    .getParent()),                    ELANCommandFactory.MODIFY_ANNOTATION);            Object[] args = new Object[] { oldText, newText };            c.execute(annotation, args);        }        if (table != null) {            table.editingStopped(new ChangeEvent(this));        }        //M_P        handleSubtitleViewer();    }    /**     * Notification of a connected SubtitleViewer when editing has stopped.     * Pending: candidate for change     */    private void handleSubtitleViewer() {        if (subtitleViewer != null) {            subtitleViewer.putOriginalComponentBack();        }    }    /**     * Restores the default locale (because of InputMethod stuff) of the     * textareas.     */    private void closeIM() {        if (attached) {            if (!textArea.getLocale().equals(Locale.getDefault())) {                ImUtil.setLanguage(textArea, Locale.getDefault());            }        } else {            if (!exttextArea.getLocale().equals(Locale.getDefault())) {                ImUtil.setLanguage(exttextArea, Locale.getDefault());            }        }    }    /**     * Forwards the cut action to either the <code>textArea</code> or the     * <code>exttextArea</code>, depending on the attached/detached state.     */    private void doCut() {        if (attached) {            textArea.cut();        } else {            exttextArea.cut();        }    }    /**     * Forwards the copy action to either the <code>textArea</code> or the     * <code>exttextArea</code>, depending on the attached/detached state.     */    private void doCopy() {        if (attached) {            textArea.copy();        } else {            exttextArea.copy();        }    }    /**     * Forwards the paste action to either the <code>textArea</code> or the     * <code>exttextArea</code>, depending on the attached/detached state.     */    private void doPaste() {        if (attached) {            textArea.paste();        } else {            exttextArea.paste();        }    }    /**     * Forwards the select all action to either the <code>textArea</code> or the     * <code>exttextArea</code>, depending on the attached/detached state.     */

⌨️ 快捷键说明

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