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

📄 chatexportdlg.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }        // filler        c.gridx = 7;        c.gridy = 0;        c.fill = GridBagConstraints.HORIZONTAL;        c.weightx = 1.0;        mainTiersPanel.add(new JPanel(), c);        // dependent tiers panel        dependentTiersPanel.setBorder(dependentTiersBorder);        c.gridx = 0;        c.gridy = 1;        c.fill = GridBagConstraints.HORIZONTAL;        c.anchor = GridBagConstraints.WEST;        c.insets = insets;        c.weightx = 1.0;        //getContentPane().add(dependentTiersPanel, c);        mtPanel.add(dependentTiersPanel, c);        // header row        tableComponent = new JLabel(DEPENDENT_TIER);        dependentTierTable[1][0] = tableComponent;        c.gridx = 1;        c.gridy = 0;        c.fill = GridBagConstraints.NONE;        c.weightx = 0.0;        c.anchor = GridBagConstraints.WEST;        c.insets = insets;        dependentTiersPanel.add(tableComponent, c);        tableComponent = new JLabel(LABEL);        dependentTierTable[1][0] = tableComponent;        c.gridx = 2;        c.gridy = 0;        c.anchor = GridBagConstraints.WEST;        c.insets = insets;        dependentTiersPanel.add(tableComponent, c);        // row for each dependent tier        Vector tiers = null;        int rowIndex = 1;        tiers = transcription.getTiers();        if (tiers != null) {            for (int i = 0; i < tiers.size(); i++) {                TierImpl t = (TierImpl) tiers.elementAt(i);                if (t.hasParentTier()) {                    tableComponent = new JCheckBox();                    ((JCheckBox) tableComponent).setSelected(true);                    dependentTierTable[0][rowIndex] = tableComponent;                    c.gridx = 0;                    c.gridy = rowIndex;                    c.anchor = GridBagConstraints.WEST;                    c.insets = insets;                    dependentTiersPanel.add(tableComponent, c);                    tableComponent = new JLabel(t.getName());                    dependentTierTable[1][rowIndex] = tableComponent;                    c.gridx = 1;                    c.gridy = rowIndex;                    c.anchor = GridBagConstraints.WEST;                    c.insets = insets;                    dependentTiersPanel.add(tableComponent, c);                    String defaultName = "%";                    if (t.getName().startsWith("%")) {                        int atInd = t.getName().indexOf('@');                        if ((atInd > 1) && (atInd <= 8)) {                            defaultName = t.getName().substring(0, atInd);                        }                    }                    tableComponent = new JTextField(7);                    ((JTextField) tableComponent).setText(defaultName);                    dependentTierTable[2][rowIndex] = tableComponent;                    c.gridx = 2;                    c.gridy = rowIndex;                    c.anchor = GridBagConstraints.WEST;                    c.insets = insets;                    dependentTiersPanel.add(tableComponent, c);                    rowIndex++;                }            }        }        // filler        c.gridx = 3;        c.gridy = 0;        c.fill = GridBagConstraints.HORIZONTAL;        c.weightx = 1.0;        dependentTiersPanel.add(new JPanel(), c);        optionsPanel = new JPanel(new GridBagLayout());        optionsBorder = new TitledBorder("");        optionsPanel.setBorder(optionsBorder);        correctTimesCB = new JCheckBox();        correctTimesCB.setSelected(true);        timesOnSeparateLineCB = new JCheckBox();        c = new GridBagConstraints();        c.gridx = 0;        c.gridy = 0;        c.insets = insets;        c.fill = GridBagConstraints.HORIZONTAL;        c.anchor = GridBagConstraints.WEST;        c.weightx = 1.0;        optionsPanel.add(correctTimesCB, c);        c = new GridBagConstraints();        c.gridx = 0;        c.gridy = 1;        c.insets = insets;        c.fill = GridBagConstraints.HORIZONTAL;        c.anchor = GridBagConstraints.WEST;        c.weightx = 1.0;        optionsPanel.add(timesOnSeparateLineCB, c);        c = new GridBagConstraints();        c.gridx = 0;        c.gridy = 1;        c.insets = insets;        c.fill = GridBagConstraints.BOTH;        c.weightx = 1.0;        c.weighty = 100.0;        getContentPane().add(scrollPane, c);        c.gridx = 0;        c.gridy = 2;        c.fill = GridBagConstraints.HORIZONTAL;        c.anchor = GridBagConstraints.NORTH;        c.weightx = 1.0;        c.weighty = 0.0;        c.insets = new Insets(2, 12, 2, 12);        getContentPane().add(optionsPanel, c);        c.gridx = 0;        c.gridy = 3;        c.fill = GridBagConstraints.NONE;        c.anchor = GridBagConstraints.SOUTH;        c.weightx = 0.0;        c.weighty = 0.0;        c.insets = insets;        getContentPane().add(buttonPanel, c);        c.gridx = 0;        c.gridy = 0;        c.fill = GridBagConstraints.NONE;        c.anchor = GridBagConstraints.NORTH;        c.insets = insets;        buttonPanel.add(exportButton, c);    }    private void setDefaultValues() {        //		selectionOnlyCheckBox.setSelected(false);        //		selectionOnlyCheckBox.setEnabled(false);        //		selectionOnlyLabel.setEnabled(false);        //		showTierLabelCheckBox.setSelected(interlinearizer.isTierLabelsShown());		        //		widthTextField.setText(new Integer(initialWidth).toString());    }    /**     * Update the UI elements according to the current Locale and the current     * edit mode.     */    private void updateForLocale() {        setTitle(ElanLocale.getString("ExportCHATDialog.Title"));        titleLabel.setText(ElanLocale.getString("ExportCHATDialog.Title"));        mainTiersBorder.setTitle(ElanLocale.getString(                "ExportCHATDialog.MainTiers"));        dependentTiersBorder.setTitle(ElanLocale.getString(                "ExportCHATDialog.DependentTiers"));        optionsBorder.setTitle(ElanLocale.getString(                "ExportDialog.Label.Options"));        correctTimesCB.setText(ElanLocale.getString("ExportDialog.CorrectTimes"));        timesOnSeparateLineCB.setText(ElanLocale.getString(                "ExportCHATDialog.SeparateLine"));        exportButton.setText(ElanLocale.getString("ExportCHATDialog.Export"));        exportButton.addActionListener(this);    }    //listeners    public void actionPerformed(ActionEvent event) {        if (event.getSource() == exportButton) {            if (fieldsOK()) {                showDialogAndSave();            }        }    }    private boolean fieldsOK() {        boolean ok = true;        // main tier table: all fields have to start with * and have length 4        for (int i = 1; i < mainTierTable[2].length; i++) {            if (((JCheckBox) mainTierTable[0][i]).isSelected()) {                String text = ((JTextField) mainTierTable[2][i]).getText();                if ((text.length() != 4) || !text.startsWith("*")) {                    ok = false;                    break;                }            }        }        // dependent tier table: all fields have to start with % and have length 4        // dec 2006  HS: depending tier names can be 1 to 7 chars long        for (int i = 1; i < dependentTierTable[2].length; i++) {            if (((JCheckBox) dependentTierTable[0][i]).isSelected()) {                String text = ((JTextField) dependentTierTable[2][i]).getText();                if (((text.length() < 2) || (text.length() > 8)) ||                        !text.startsWith("%")) {                    ok = false;                    break;                }            }        }        if (!ok) { // give error message            JOptionPane.showMessageDialog(this,                ElanLocale.getString("ExportCHATDlg.Message.WrongLabel"),                ElanLocale.getString("Message.Error"), JOptionPane.ERROR_MESSAGE);        }        return ok;    }    private void showDialogAndSave() {        // prompt for new file name        String saveDir = (String) Preferences.get("LastUsedCHATDir", null);        if (saveDir == null) {            saveDir = (new File(transcription.getName())).getParent();            if (saveDir == null) {                saveDir = System.getProperty("user.dir");            }        }        // open dialog at directory of original eaf file        JFileChooser chooser = new JFileChooser(saveDir);        FileFilter filter = ElanFileFilter.createFileFilter(ElanFileFilter.CHAT_TYPE);        chooser.setFileFilter(filter);        chooser.setDialogTitle(ElanLocale.getString("ExportCHATDialog.Title"));        //	int option = chooser.showSaveDialog(ELANCommandFactory.getRootFrame(        //				tr));        int option = chooser.showSaveDialog(this);        if (option == JFileChooser.APPROVE_OPTION) {            File curDir = chooser.getCurrentDirectory();            if (curDir != null) {                Preferences.set("LastUsedCHATDir", curDir.getAbsolutePath(),                    null);            }            File f = chooser.getSelectedFile();            if (f != null) {                // make sure pathname finishes with .cha extension                String pathName = f.getAbsolutePath();                String lowerPathName = pathName.toLowerCase();                if (!lowerPathName.endsWith(".cha")) {                    pathName += ".cha";                }                if ((new File(pathName)).exists()) {                    int answer = JOptionPane.showConfirmDialog(null,                            ElanLocale.getString("Message.Overwrite"),                            ElanLocale.getString(                                "ExportCHATDialog.Message.Title"),                            JOptionPane.YES_NO_OPTION);                    if (answer == JOptionPane.NO_OPTION) {                        return;                    }                }                // collect encoder information to pass on                String[][] mainTierInfo = new String[mainTierTable.length - 1][mainTierTable[0].length -                    1];                String[][] dependentTierInfo = new String[dependentTierTable.length -                    1][dependentTierTable[0].length - 1];                int index = 0;                for (int i = 1; i < mainTierTable[1].length; i++) {                    if (((JCheckBox) mainTierTable[0][i]).isSelected()) {                        mainTierInfo[0][index] = ((JLabel) mainTierTable[1][i]).getText();                        mainTierInfo[1][index] = ((JTextField) mainTierTable[2][i]).getText();                        mainTierInfo[2][index] = ((JTextField) mainTierTable[3][i]).getText();                        mainTierInfo[3][index] = ((JTextField) mainTierTable[4][i]).getText();                        mainTierInfo[4][index] = ((JTextField) mainTierTable[5][i]).getText();                        mainTierInfo[5][index] = ((JTextField) mainTierTable[6][i]).getText();                        index++;                    }                }                index = 0;                for (int j = 1; j < dependentTierTable[1].length; j++) {                    if (((JCheckBox) dependentTierTable[0][j]).isSelected()) {                        dependentTierInfo[0][index] = ((JLabel) dependentTierTable[1][j]).getText();                        dependentTierInfo[1][index] = ((JTextField) dependentTierTable[2][j]).getText();                        index++;                    }                }                CHATEncoderInfo encoderInfo = new CHATEncoderInfo(mainTierInfo,                        dependentTierInfo);                encoderInfo.setCorrectAnnotationTimes(correctTimesCB.isSelected());                encoderInfo.setTimesOnSeparateLine(timesOnSeparateLineCB.isSelected());                if (correctTimesCB.isSelected()) {                    Vector mediaDescriptors = transcription.getMediaDescriptors();                    if (mediaDescriptors.size() > 0) {                        encoderInfo.setMediaOffset(((MediaDescriptor) mediaDescriptors.get(                                0)).timeOrigin);                    }                }                acmTranscriptionStore.storeTranscriptionIn(transcription,                    encoderInfo, visibleTiers, pathName, TranscriptionStore.CHAT);            }        }    }}

⌨️ 快捷键说明

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