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

📄 edittierdialog.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    }                }                fillLingTypeMenu();            }        }    }    /**     * Adds a new tier to the transcription.     *     * @param tierName the name of the new tier     * @param parentTier DOCUMENT ME!     * @param lingType DOCUMENT ME!     * @param participant DOCUMENT ME!     * @param locale DOCUMENT ME!     */    private void doAdd(String tierName, Tier parentTier, String lingType,        String participant, Locale locale) {        Command c = ELANCommandFactory.createCommand(transcription,                ELANCommandFactory.ADD_TIER);        Object receiver = transcription;        Object[] args = new Object[5];        args[0] = tierName;        args[1] = parentTier;        args[2] = lingType;        args[3] = participant;        args[4] = locale;        c.execute(receiver, args);        // update the dialog ui        reextractTiers();        // warn if this is the first tier with a linguistic type         // allowing graphic refs.        TierImpl tt = (TierImpl) transcription.getTierWithId(tierName);        if ((tt != null) && tt.getLinguisticType().hasGraphicReferences()) {            checkGraphics(tt);        }    }    /**     * Changes properties of a tier.     *     * @param tierName new name of the tier     * @param parentTier the parent tier     * @param lingType the linguistic type     * @param participant the participant     * @param locale the locale     */    private void doChange(String tierName, Tier parentTier, String lingType,        String participant, Locale locale) {        // double check on parent and type        if (tier.getAnnotations().size() > 0) {            if (((parentTier != null) && (oldParentTier == null)) ||                    ((parentTier == null) && (oldParentTier != null)) ||                    (parentTier != oldParentTier)) {                parentTier = oldParentTier;            }            if (getStereoTypeForTypeName(lingType) != getStereoTypeForType(                        oldLingType)) {                lingType = oldLingType.getLinguisticTypeName();            }        }        // check whether something has changed        if (!tierName.equals(oldTierName) ||                ((parentTier != null) && (oldParentTier != null) &&                (parentTier != oldParentTier)) ||                !lingType.equals(oldLingType.getLinguisticTypeName()) ||                !participant.equals(oldParticipant) ||                ((locale != null) && (locale != oldLocale))) {            Command c = ELANCommandFactory.createCommand(transcription,                    ELANCommandFactory.CHANGE_TIER);            Object receiver = tier;            Object[] args = new Object[5];            args[0] = tierName;            args[1] = parentTier;            args[2] = lingType;            args[3] = participant;            args[4] = locale;            c.execute(receiver, args);            // notify if this is the first tier allowing graphic references            if (tier.getLinguisticType().hasGraphicReferences() &&                    !lingType.equals(oldLingType.getLinguisticTypeName())) {                checkGraphics(tier);            }            if (singleEditMode) {                // dispose                dispose();            } else {                // update the dialog ui                reextractTiers();            }        } else {            //System.out.println("no change");        }    }    /**     * Actually deletes the tier.     */    private void doDelete() {        if (tier != null) {            Vector depTiers = tier.getDependentTiers();            StringBuffer mesBuf = new StringBuffer();            mesBuf.append(ElanLocale.getString(                    "EditTierDialog.Message.ConfirmDelete"));            mesBuf.append("  ");            mesBuf.append(oldTierName);            mesBuf.append(" ?\n");            if ((depTiers != null) && (depTiers.size() > 0)) {                mesBuf.append(ElanLocale.getString(                        "EditTierDialog.Message.AlsoDeleted"));                Iterator depIt = depTiers.iterator();                while (depIt.hasNext()) {                    Tier t = (Tier) depIt.next();                    mesBuf.append("\n-   ");                    mesBuf.append(t.getName());                }            }            int option = JOptionPane.showConfirmDialog(this, mesBuf.toString(),                    ElanLocale.getString("Message.Warning"),                    JOptionPane.YES_NO_OPTION);            if (option == JOptionPane.YES_OPTION) {                Object[] args = new Object[] { tier };                Command c = ELANCommandFactory.createCommand(transcription,                        ELANCommandFactory.DELETE_TIER);                c.execute(transcription, args);                if (singleEditMode) {                    // dispose                    dispose();                } else {                    // update the dialog ui                    reextractTiers();                }            }        }    }    /**     * Checks whether this is the first tier with a linguistic type that allows     * graphic annotations. Shows a warning message if so.     *     * @param ti the changed or new tier     */    private void checkGraphics(TierImpl ti) {        int numGraphicTiers = 1;        Vector tiers = transcription.getTiers();        Iterator tierIt = tiers.iterator();        TierImpl t;        while (tierIt.hasNext()) {            t = (TierImpl) tierIt.next();            if ((t != ti) && t.getLinguisticType().hasGraphicReferences()) {                numGraphicTiers++;            }        }        if ((numGraphicTiers == 1) &&                ((transcription.getSVGFile() == null) ||                (transcription.getSVGFile().length() == 0))) {            JOptionPane.showMessageDialog(this,                ElanLocale.getString("EditTierDialog.Message.Graphics"),                ElanLocale.getString("Message.Warning"),                JOptionPane.WARNING_MESSAGE);        }    }    /**     * DOCUMENT ME!     *     * @param event DOCUMENT ME!     */    public void actionPerformed(ActionEvent event) {        if (event.getSource() == changeButton) {            if (mode == DELETE) {                doDelete();                return;            } else {                String tierName = tierNameTextField.getText();                tierName.replace('\n', ' ');                tierName.trim();                if (tierName.length() == 0) {                    tierNameTextField.requestFocus();                    JOptionPane.showMessageDialog(this,                        ElanLocale.getString("EditTierDialog.Message.TierName"),                        ElanLocale.getString("Message.Error"),                        JOptionPane.ERROR_MESSAGE);                    return;                }                if (transcription.getTierWithId(tierName) != null) {                    if ((mode == ADD) ||                            ((mode == CHANGE) && !tierName.equals(oldTierName))) {                        tierNameTextField.requestFocus();                        JOptionPane.showMessageDialog(this,                            ElanLocale.getString(                                "EditTierDialog.Message.Exists"),                            ElanLocale.getString("Message.Error"),                            JOptionPane.ERROR_MESSAGE);                        return;                    }                }                String participant = participantTextField.getText();                String lingType = (String) lingTypeChoice.getSelectedItem();                Tier parentTier = transcription.getTierWithId((String) parentChoice.getSelectedItem());                String localeName = (String) languageChoice.getSelectedItem();                Locale locale = null;                if (langs != null) {                    for (int i = 0; i < langs.length; i++) {                        if (langs[i].getDisplayName().equals(localeName)) {                            locale = langs[i];                            break;                        }                    }                }                if (locale == null) {                    locale = oldLocale;                }                switch (mode) {                case ADD:                    doAdd(tierName, parentTier, lingType, participant, locale);                    break;                case CHANGE:                    doChange(tierName, parentTier, lingType, participant, locale);                    break;                }            }            //dispose();        } else {            dispose();        }    }    /**     * Returns the stereotype for a linguistic type. When the linguistic type     * has no constraints -1 is returned.     *     * @param name type name     *     * @return the stereotype or -1     */    private int getStereoTypeForTypeName(String name) {        LinguisticType type = null;        Vector types = transcription.getLinguisticTypes();        LinguisticType tempType = null;        for (int i = 0; i < types.size(); i++) {            tempType = (LinguisticType) types.get(i);            if (tempType.getLinguisticTypeName().equals(name)) {                type = tempType;                break;            }        }        return getStereoTypeForType(type);    }    /**     * Returns the stereotype for a linguistic type. When the linguistic type     * has no constraints -1 is returned.     *     * @param type type     *     * @return the stereotype or -1     */    private int getStereoTypeForType(LinguisticType type) {        if ((type == null) || (type.getConstraints() == null)) {            return -1;        } else {            return type.getConstraints().getStereoType();        }    }}

⌨️ 快捷键说明

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