📄 edittierdialog.java
字号:
buttonPanel.add(changeButton); buttonPanel.add(cancelButton); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { dispose(); } }); //Dependencies //Put them into the dialog getContentPane().setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTH; c.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(titleLabel, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.insets = new Insets(2, 6, 2, 6); getContentPane().add(selectTierLabel, c); currentTiersComboBox.setMaximumRowCount(Constants.COMBOBOX_VISIBLE_ROWS); c.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(currentTiersComboBox, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; getContentPane().add(tierNameLabel, c); c.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(tierNameTextField, c); c.gridwidth = 1; getContentPane().add(participantLabel, c); c.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(participantTextField, c); c.gridwidth = 1; // add(lingTypeLabel,c); // HB, 16 aug 02 change order LT and parent choices // HS 22-10-2002: the intention of the negative parameters is to get the same // vertical distances between the textFields and the choice menus (the default // height of a textField is e.g. 23 pixel, but the one of a choice menu is 21 getContentPane().add(parentLabel, c); parentChoice.setMaximumRowCount(Constants.COMBOBOX_VISIBLE_ROWS); c.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(parentChoice, c); c.gridwidth = 1; getContentPane().add(lingTypeLabel, c); lingTypeChoice.setMaximumRowCount(Constants.COMBOBOX_VISIBLE_ROWS); c.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(lingTypeChoice, c); c.gridwidth = 1; getContentPane().add(languageLabel, c); languageChoice.setMaximumRowCount(Constants.COMBOBOX_VISIBLE_ROWS); c.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(languageChoice, c); c.anchor = GridBagConstraints.SOUTH; c.fill = GridBagConstraints.NONE; getContentPane().add(buttonPanel, c); updateUIForTier((String) currentTiersComboBox.getSelectedItem()); pack(); setResizable(false); setLocationRelativeTo(frame); } /** * Empties and refills the Linguistic Type menu with types that are not * excluded by the current parent tier choice. */ private void fillLingTypeMenu() { lingTypeChoice.removeItemListener(this); lingTypeChoice.removeAllItems(); TierImpl parentTier = (TierImpl) (transcription.getTierWithId((String) parentChoice.getSelectedItem())); boolean excludeTimeSubDiv = false; Constraint parentConstraint = null; if (parentTier != null) { parentConstraint = parentTier.getLinguisticType().getConstraints(); if (parentConstraint != null) { if ((parentConstraint.getStereoType() == Constraint.SYMBOLIC_SUBDIVISION) || (parentConstraint.getStereoType() == Constraint.SYMBOLIC_ASSOCIATION)) { excludeTimeSubDiv = true; } } } Enumeration e = transcription.getLinguisticTypes().elements(); while (e.hasMoreElements()) { LinguisticType lt = (LinguisticType) e.nextElement(); String ltName = lt.getLinguisticTypeName(); if (excludeTimeSubDiv && (lt.getConstraints() != null) && ((lt.getConstraints().getStereoType() == Constraint.TIME_SUBDIVISION) || (lt.getConstraints().getStereoType() == Constraint.INCLUDED_IN))) { continue; } if (parentTier == null) { // only unconstrained types if (lt.getConstraints() != null) { continue; } } if (parentTier != null) { // only constrained types if (lt.getConstraints() == null) { continue; } } lingTypeChoice.addItem(ltName); } // set selected the current type of the selected tier String tierName = (String) currentTiersComboBox.getSelectedItem(); if (tierName != null) { TierImpl tier = (TierImpl) transcription.getTierWithId(tierName); if (tier != null) { LinguisticType type = tier.getLinguisticType(); if (type != null) { lingTypeChoice.setSelectedItem(type.getLinguisticTypeName()); } } } lingTypeChoice.addItemListener(this); if (lingTypeChoice.getModel().getSize() <= 0) { changeButton.setEnabled(false); } else { changeButton.setEnabled(true); } } /** * Fills the parent tier combobox with the potential parent tiers for the * specified tier. */ private void fillParentComboBox() { parentChoice.removeItemListener(this); parentChoice.removeAllItems(); parentChoice.addItem(none); if ((tier != null) && (mode != ADD)) { Vector candidateParents = transcription.getCandidateParentTiers(tier); Iterator pIter = candidateParents.iterator(); while (pIter.hasNext()) { parentChoice.addItem(((Tier) pIter.next()).getName()); } if (tier.hasParentTier()) { parentChoice.setSelectedItem(tier.getParentTier().getName()); } } else if (mode == ADD) { Iterator tierIt = tiers.iterator(); while (tierIt.hasNext()) { TierImpl t = (TierImpl) tierIt.next(); parentChoice.addItem(t.getName()); } parentChoice.setSelectedItem(none); } parentChoice.addItemListener(this); } /** * Gets the Locale of the currently selected tier and tries to set this * Locale as the selected item in the language combo box.<br> * If the tier has a Locale that is not in the list, add it to the list. */ private void updateLanguageChoice() { languageChoice.removeAllItems(); if (langs != null) { for (int i = 0; i < langs.length; i++) { languageChoice.addItem(langs[i].getDisplayName()); } } if (tier != null) { Locale l = tier.getDefaultLocale(); if (l != null) { /* List al = Arrays.asList(langs); if (!al.contains(l)) { languageChoice.addItem(l.getDisplayName()); } */ languageChoice.setSelectedItem(l.getDisplayName()); } else { languageChoice.setSelectedIndex(0); } } } private void updateUIForTier(String name) { if (name != null) { tier = (TierImpl) transcription.getTierWithId(name); if (tier != null) { oldParentTier = (TierImpl) tier.getParentTier(); if (oldParentTier != null) { oldParentTierName = tier.getParentTier().getName(); } else { oldParentTierName = none; } oldLingType = tier.getLinguisticType(); oldLocale = tier.getDefaultLocale(); oldTierName = tier.getName(); oldParticipant = tier.getParticipant(); if (mode != ADD) { tierNameTextField.setText(oldTierName); participantTextField.setText(oldParticipant); } } fillParentComboBox(); fillLingTypeMenu(); updateLanguageChoice(); } } //Various Listeners public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getSource() == currentTiersComboBox) { String name = (String) currentTiersComboBox.getSelectedItem(); updateUIForTier(name); } else if ((e.getSource() == lingTypeChoice) && (mode == CHANGE)) { if ((tier != null) && (tier.getNumberOfAnnotations() > 0)) { // warn if more than 0 annotations and stereotype is different String newTypeName = (String) e.getItem(); boolean stereoTypeChanged = false; int newStereoType = getStereoTypeForTypeName(newTypeName); int oldStereoType = getStereoTypeForType(oldLingType); if (newStereoType != oldStereoType) { stereoTypeChanged = true; } if (!oldLingType.getLinguisticTypeName().equals(newTypeName) && stereoTypeChanged) { StringBuffer buf = new StringBuffer(ElanLocale.getString( "EditTierDialog.Message.RecommendType")); buf.append("\n"); buf.append(ElanLocale.getString( "EditTierDialog.Message.Corrupt")); JOptionPane.showMessageDialog(this, buf.toString(), ElanLocale.getString("Message.Warning"), JOptionPane.WARNING_MESSAGE); // HS sep-04 prevent changing the lin. type when there are annotations lingTypeChoice.setSelectedItem(oldLingType.getLinguisticTypeName()); } } } else if (e.getSource() == parentChoice) { if ((mode == CHANGE) && (tier != null) && (tier.getNumberOfAnnotations() > 0)) { if (!(oldParentTierName.equals((String) e.getItem()))) { StringBuffer buf = new StringBuffer(ElanLocale.getString( "EditTierDialog.Message.RecommendParent")); buf.append("\n"); buf.append(ElanLocale.getString( "EditTierDialog.Message.Corrupt")); JOptionPane.showMessageDialog(this, buf.toString(), ElanLocale.getString("Message.Warning"), JOptionPane.WARNING_MESSAGE); // HS sep-04 prevent changing the parent when there are annotations parentChoice.setSelectedItem(oldParentTierName); } } else { // suggest the participant name from the parent... String partiName = participantTextField.getText(); if ((partiName == null) || (partiName.trim().length() == 0)) { TierImpl parent = (TierImpl) transcription.getTierWithId((String) e.getItem()); if (parent != null) { participantTextField.setText(parent.getParticipant()); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -