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

📄 edittypedialog.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            //oldConstraint = (String)constraints.getSelectedItem();            break;        case DELETE:            setTitle(ElanLocale.getString("EditTypeDialog.Title.Delete"));            currentTypesLabel.setText(ElanLocale.getString(                    "EditTypeDialog.DeleteType"));            changeButton.setText(ElanLocale.getString("Button.Delete"));            if (currentTypes.getModel().getSize() > 0) {                updateUIForType((String) currentTypes.getItemAt(0));                currentTypes.addItemListener(this);                //typeTextField.setText((String)currentTypes.getItemAt(0));            } else {                changeButton.setEnabled(false);            }            typeTextField.setEditable(false);            constraints.setEnabled(false);            cvComboBox.setEnabled(false);            graphicReferencesCheckbox.setEnabled(false);            break;        }        titleLabel.setText(getTitle());    }    /**     * Utility method for creating a Constraint for a given name.     *     * @param name the name of the constraint     *     * @return a Constraint or <code>null</code>     */    private Constraint getConstraintForName(String name) {        Constraint c = null;        if (name.equals(Constraint.stereoTypes[Constraint.TIME_SUBDIVISION])) {            c = new TimeSubdivision();        } else if (name.equals(                    Constraint.stereoTypes[Constraint.SYMBOLIC_SUBDIVISION])) {            c = new SymbolicSubdivision();        } else if (name.equals(                    Constraint.stereoTypes[Constraint.SYMBOLIC_ASSOCIATION])) {            c = new SymbolicAssociation();        } else if (name.equals(Constraint.stereoTypes[Constraint.INCLUDED_IN])) {            c = new IncludedIn();        }        return c;    }    private void doAdd(String name) {        // check existence        LinguisticType lt = null;        Iterator tIter = types.iterator();        while (tIter.hasNext()) {            lt = (LinguisticType) tIter.next();            if (lt.getLinguisticTypeName().equals(name)) {                String errorMessage = ElanLocale.getString(                        "EditTypeDialog.Message.Exists");                typeTextField.requestFocus();                JOptionPane.showMessageDialog(this, errorMessage,                    ElanLocale.getString("Message.Error"),                    JOptionPane.ERROR_MESSAGE);                return;            }        }        //create new type        String cons = (String) constraints.getSelectedItem();        Constraint c = getConstraintForName(cons);        boolean alignable = timeAlignableCheckbox.isSelected();        boolean graphicsRef = graphicReferencesCheckbox.isSelected();        String cvName = (String) cvComboBox.getSelectedItem();        if (cvName.equals(none)) {            cvName = null;        }        //create and execute a command        Command com = ELANCommandFactory.createCommand(transcription,                ELANCommandFactory.ADD_TYPE);        Object[] args = new Object[5];        args[0] = name;        args[1] = c;        args[2] = cvName;        args[3] = new Boolean(alignable);        args[4] = new Boolean(graphicsRef);        com.execute(transcription, args);        reextractTypes();        //dispose();    }    private void doChange(String name) {        String oldName = (String) currentTypes.getSelectedItem();        LinguisticType lt = null;        LinguisticType iterType = null;        Iterator tIter = types.iterator();        while (tIter.hasNext()) {            iterType = (LinguisticType) tIter.next();            if (iterType.getLinguisticTypeName().equals(oldName)) {                lt = iterType;            }            if (iterType.getLinguisticTypeName().equals(name) &&                    (iterType != lt)) {                // name already exists                String errorMessage = ElanLocale.getString(                        "EditTypeDialog.Message.Exists");                typeTextField.requestFocus();                JOptionPane.showMessageDialog(this, errorMessage,                    ElanLocale.getString("Message.Error"),                    JOptionPane.ERROR_MESSAGE);                return;            }        }        if (lt == null) {            // something is wrong            String errorMessage = ElanLocale.getString(                    "EditTypeDialog.Message.UnknownError");            JOptionPane.showMessageDialog(this, errorMessage,                ElanLocale.getString("Message.Error"), JOptionPane.ERROR_MESSAGE);            //dispose();            return;        }        String oldCV = null;        if (lt.isUsingControlledVocabulary()) {            oldCV = lt.getControlledVocabylaryName();        }        boolean oldGraphicsRef = lt.hasGraphicReferences();        String cons = (String) constraints.getSelectedItem();        Constraint c = getConstraintForName(cons);        String cvName = (String) cvComboBox.getSelectedItem();        if (cvName.equals(none)) {            cvName = null;        }        boolean alignable = timeAlignableCheckbox.isSelected();        boolean graphicsRef = graphicReferencesCheckbox.isSelected();        // if nothing has changed do nothing        if (name.equals(oldName) &&                (((c == null) && (lt.getConstraints() == null)) ||                (c == lt.getConstraints())) &&                (((oldCV == null) && (cvName == null)) ||                ((oldCV != null) && oldCV.equals(cvName))) &&                (lt.isTimeAlignable() == alignable) &&                (oldGraphicsRef == graphicsRef)) {            return;        }        // warn if graphic references allowed has been deselected...        if (oldGraphicsRef && !graphicsRef) {            String warning = ElanLocale.getString(                    "EditTypeDialog.Message.GraphicsLost") + "\n" +                ElanLocale.getString("EditTypeDialog.Message.Confirm");            int option = JOptionPane.showConfirmDialog(this, warning,                    ElanLocale.getString("Message.Warning"),                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);            if (option != JOptionPane.YES_OPTION) {                return;            }        }        if (graphicsRef) {            // check whether there are tiers using this type and             // whether these are the first tiers allowing graphic refs	            checkGraphics(lt);        }        //create and execute a command        Object[] args = new Object[6];        args[0] = name;        args[1] = c;        args[2] = cvName;        args[3] = new Boolean(alignable);        args[4] = new Boolean(graphicsRef);        args[5] = lt;        Command com = ELANCommandFactory.createCommand(transcription,                ELANCommandFactory.CHANGE_TYPE);        com.execute(transcription, args);        reextractTypes();        //dispose();    }    private void doDelete() {        String oldName = (String) currentTypes.getSelectedItem();        LinguisticType lt = null;        Iterator tIter = types.iterator();        while (tIter.hasNext()) {            lt = (LinguisticType) tIter.next();            if (lt.getLinguisticTypeName().equals(oldName)) {                break;            }        }        if (lt == null) {            // something is wrong            String errorMessage = ElanLocale.getString(                    "EditTypeDialog.Message.UnknownError");            JOptionPane.showMessageDialog(this, errorMessage,                ElanLocale.getString("Message.Error"), JOptionPane.ERROR_MESSAGE);            //dispose();            return;        } else {            //warn            Vector clientTiers = transcription.getTiersWithLinguisticType(oldName);            if (clientTiers.size() > 0) {                StringBuffer errorBuffer = new StringBuffer(ElanLocale.getString(                            "EditTypeDialog.Message.TypeInUse"));                errorBuffer.append(":\n");                Iterator clIter = clientTiers.iterator();                while (clIter.hasNext()) {                    errorBuffer.append("- ");                    errorBuffer.append(((Tier) clIter.next()).getName());                    errorBuffer.append("\n");                }                errorBuffer.append(ElanLocale.getString(                        "EditTypeDialog.Message.Reassign"));                JOptionPane.showMessageDialog(this, errorBuffer.toString(),                    ElanLocale.getString("Message.Warning"),                    JOptionPane.ERROR_MESSAGE);                return;            }        }        //create and execute a command        Command com = ELANCommandFactory.createCommand(transcription,                ELANCommandFactory.DELETE_TYPE);        com.execute(transcription, new Object[] { lt });        reextractTypes();        //dispose();    }    /**     * Shows a warning message when the document needs to be reopened  to view     * graphic annotations.     *     * @param type the modified linguistic type     */    private void checkGraphics(LinguisticType type) {        Vector tiersOfType = transcription.getTiersWithLinguisticType(type.getLinguisticTypeName());        boolean alreadyThere = false;        Vector allTiers = transcription.getTiers();        Iterator tierIt = allTiers.iterator();        TierImpl tier;        LinguisticType otherType;        while (tierIt.hasNext()) {            tier = (TierImpl) tierIt.next();            otherType = tier.getLinguisticType();            if ((otherType != type) && otherType.hasGraphicReferences()) {                alreadyThere = true;                break;            }        }        if (!alreadyThere && (tiersOfType.size() > 0)) {            JOptionPane.showMessageDialog(this,                ElanLocale.getString("EditTierDialog.Message.Graphics"),                ElanLocale.getString("Message.Warning"),                JOptionPane.WARNING_MESSAGE);        }    }    //listeners    public void actionPerformed(ActionEvent event) {        if (event.getSource() == changeButton) {            if (mode == DELETE) {                doDelete();            } else {                String typeName = typeTextField.getText();                typeName.replace('\n', ' ');                typeName.trim();                if (typeName.length() == 0) {                    String errorMessage = ElanLocale.getString(                            "EditTypeDialog.Message.TypeName");                    typeTextField.requestFocus();                    JOptionPane.showMessageDialog(this, errorMessage,                        ElanLocale.getString("Message.Error"),                        JOptionPane.ERROR_MESSAGE);                    return;                } else {                    switch (mode) {                    case ADD:                        doAdd(typeName);                        break;                    case CHANGE:                        doChange(typeName);                        break;                    default:                        return;                    }                }            }        } else {            dispose();        }    }    /**     * DOCUMENT ME!     *     * @param e DOCUMENT ME!     */    public void itemStateChanged(ItemEvent e) {        if ((e.getSource() == currentTypes) &&                (e.getStateChange() == ItemEvent.SELECTED)) {            String name = (String) currentTypes.getSelectedItem();            if (name != null) {                updateUIForType(name);            }        } else if ((e.getSource() == constraints) &&                (e.getStateChange() == ItemEvent.SELECTED)) {            String constraint = (String) constraints.getSelectedItem();            if ((constraint == none) || (constraint == "Time Subdivision")) {                timeAlignableCheckbox.setSelected(true);                graphicReferencesCheckbox.setEnabled(true);            } else if ((constraint == "Symbolic Subdivision") ||                    (constraint == "Symbolic Association")) {                timeAlignableCheckbox.setSelected(false);                graphicReferencesCheckbox.setSelected(false); // ??                graphicReferencesCheckbox.setEnabled(false);            }            //if ((e.getSource() == constraints) && (oldType != null)) {	// warn if tiers use the type            if ((mode == CHANGE) && (oldConstraint != constraint)) {                String typeName = (String) currentTypes.getSelectedItem();                Vector tiers = transcription.getTiersWithLinguisticType(typeName);                if (tiers.size() > 0) {                    StringBuffer mesBuf = new StringBuffer(ElanLocale.getString(                                "EditTypeDialog.Message.TypeInUse"));                    mesBuf.append("\n");                    mesBuf.append(ElanLocale.getString(                            "EditTypeDialog.Message.Corrupt"));                    JOptionPane.showMessageDialog(null, mesBuf.toString(),                        ElanLocale.getString("Message.Warning"),                        JOptionPane.WARNING_MESSAGE);                    /*                       // HB, 9 may 03, restore old stereotype                       Constraint oldC = oldType.getConstraints();                       String oldStereoType = none;                       if (oldC != null) {                           oldStereoType = Constraint.stereoTypes[oldC.getStereoType()];                       }                       constraints.setSelectedItem(oldStereoType);                     */                    updateUIForType(typeName);                }            }        }    }}

⌨️ 快捷键说明

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