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

📄 multieditorpane.java

📁 本系统是用 java 语言实现的一个 Email客户端
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      ((DefaultTableModel)optionTable.getModel()).addRow(newValueVector);      firePropertyChangedEvent(newValue);      this.setChanged(true);      optionTable.getSelectionModel().setSelectionInterval(optionTable.getModel().getRowCount(), optionTable.getModel().getRowCount() -1);      editSelectedValue(container);    } catch (PropertyValueVetoException pvve) {      manager.getFactory().showError(container, "Error adding value " + newValueName + " to " + property + ":  " + pvve.getReason());    }  }  /**   * Removes the currently selected value from the edited List.   */  public void removeSelectedValue() {    int selectedRow = optionTable.getSelectedRow();    String selValue = (String) optionTable.getValueAt(selectedRow, 0);    if (selValue == null)      return;    try {      List<String> newValueList = new ArrayList<String>();      for (int i = 0; i < optionTable.getRowCount(); i++) {        if (i != selectedRow) {          newValueList.add((String) optionTable.getValueAt(i, 0));        }      }      String newValue = VariableBundle.convertToString(newValueList);      firePropertyChangingEvent(newValue) ;      ((DefaultTableModel)optionTable.getModel()).removeRow(selectedRow);      firePropertyChangedEvent(newValue);      removeValues.add(property + "." + selValue);      this.setChanged(true);    } catch (PropertyValueVetoException pvve) {      manager.getFactory().showError(this, "Error removing value " + selValue + " from " + property + ":  " + pvve.getReason());    }  }  /**   * Edits the currently selected value.   */  public void editSelectedValue() {    editSelectedValue(this.getPropertyEditorPane().getContainer());  }  /**   * Edits the currently selected value, using the given Container as an   * editor source.   */  protected void editSelectedValue(Container container) {    getLogger().fine("calling editSelectedValue().");    int selectedRow = optionTable.getSelectedRow();    if (selectedRow != -1) {      String valueToEdit = (String) optionTable.getValueAt(selectedRow, 0);      String editProperty = property + "." + valueToEdit;      getLogger().fine("editing " + editProperty);      manager.getFactory().showNewEditorWindow(manager.getProperty(editorTemplate + ".label", editProperty), manager.getFactory().createEditor(editProperty, editorTemplate + ".editableFields", editProperty, "Composite", manager), container);    } else {      getLogger().fine("editSelectedValue():  no selected value.");    }  }  /**   * Puts up a dialog to get a name for the new value.   */  public String getNewValueName() {    boolean goodValue = false;    boolean matchFound = false;    String newName = null;    newName = manager.getFactory().showInputDialog(this, manager.getProperty("MultiEditorPane.renameProperty", "Enter new name."));    while (goodValue == false) {      matchFound = false;      if (newName != null) {        for (int i = 0; i < optionTable.getRowCount() && matchFound == false; i++) {          if (((String)optionTable.getValueAt(i, 0)).equals(newName))            matchFound = true;        }        if (matchFound == false)          goodValue = true;        else          newName = manager.getFactory().showInputDialog(this, manager.getProperty("MultiEditorPane.error.duplicateName", "Name already exists:") + "  " + newName + "\n" + manager.getProperty("MultiEditorPane.renameProperty", "Enter new name."));      } else {        goodValue = true;      }    }    return newName;  }  /**   * This produces a string for the given JList.   */  public String getStringFromList(DefaultListModel dlm) {    String retVal;    if (dlm.getSize() < 1)      return "";    else      retVal = new String((String)dlm.getElementAt(0));    for (int i = 1; i < dlm.getSize(); i++) {      retVal = retVal.concat(":" + (String)dlm.getElementAt(i));    }    return retVal;  }  /**   * Sets the value for this MultiEditorPane.   */  public void setValue() throws PropertyValueVetoException {    if (isEditorEnabled()) {      if (isChanged()) {        getLogger().fine("setting property.  property is " + property + "; value is " + getCurrentValue());        manager.setProperty(property, getCurrentValue());        for (String removeProp: removeValues) {          //manager.removeProperty(removeValues.get(i));          Set<String> subProperties = manager.getPropertyNamesStartingWith(removeProp + ".");          for (String subProp: subProperties) {            manager.removeProperty(subProp);          }        }        removeValues = new ArrayList<String>();      }    }  }  /**   * Returns the current value from the table.   */  public String getCurrentValue() {    List<String> values = new ArrayList<String>();    for (int i = 0; i < optionTable.getRowCount(); i++) {      values.add((String) optionTable.getValueAt(i, 0));    }    return VariableBundle.convertToString(values);  }  /**   * Resets the default values.   */  public void resetDefaultValue() throws PropertyValueVetoException {    //FIXME    throw new UnsupportedOperationException("reset not yet implemented for MultiEditorPane.");    /*    removeValues = new Vector();    if (isChanged()) {      firePropertyChangedEvent(originalValue);    }    */  }  /**   * Returns the currently edited values as a Properties object.   */  public java.util.Properties getValue() {    java.util.Properties currentRetValue = new java.util.Properties();    currentRetValue.setProperty(property, getCurrentValue());    return currentRetValue;  }  /**   * Returns whether or not the top-level edited values of this EditorPane   * have changed.   */  public boolean isChanged() {    return changed;  }  /**   * Sets whether or not the top-level edited values of this EditorPane   * have changed.   */  public void setChanged(boolean newChanged) {    changed=newChanged;  }  /**   * Returns the entryPanel.   */  public JPanel getEntryPanel() {    return entryPanel;  }  /**   * Creates an editor.   */  public SwingPropertyEditor createEditorPane(String subProperty, String subTemplate) {    return (SwingPropertyEditor) manager.getFactory().createEditor(subProperty, subTemplate, "Composite", manager);  }  /**   * Run when the PropertyEditor may have changed enabled states.   */  protected void updateEditorEnabled() {    for (int i = 0; i < buttonList.size(); i++) {      buttonList.get(i).setEnabled(isEditorEnabled());    }  }  /**   * Removes the PropertyEditor.   */  public void remove() {    manager.removePropertyEditorListeners(getProperty());  }  /**   * Returns the actions associated with this editor.   */  public Action[] getActions() {    return mDefaultActions;  }  /**   * Returns the action for the given identifier.   */  public Action getAction(String name) {    for (Action action: mDefaultActions) {      if (action.getValue(Action.NAME) != null && action.getValue(Action.NAME).equals(name))        return action;    }    return null;  }  public class AddAction extends AbstractAction {    public AddAction() {      //super("address-add");      super("editor-add");    }    public void actionPerformed(ActionEvent e) {      /*      setBusy(true);      performAdd();      setBusy(false);      */      // check to see if we want to add a new value using a      // wizard      String newValueTemplate = manager.getProperty(editorTemplate + "._addValueTemplate", "");      if (newValueTemplate.length() > 0) {        manager.getFactory().showNewEditorWindow(manager.getProperty(newValueTemplate + ".label", newValueTemplate), manager.getFactory().createEditor(newValueTemplate, newValueTemplate, manager), getPropertyEditorPane().getContainer());      } else {        addNewValue(getNewValueName(), getPropertyEditorPane().getContainer());      }    }  }  public class EditAction extends AbstractAction {    public EditAction() {      super("editor-edit");    }    public void actionPerformed(ActionEvent e) {      /*      setBusy(true);      editSelectedValue();      setBusy(false);      */      editSelectedValue();    }  }  public class DeleteAction extends AbstractAction {    public DeleteAction() {      super("editor-delete");    }    public void actionPerformed(ActionEvent e) {      removeSelectedValue();      /*      setBusy(true);      performDelete();      setBusy(false);      */    }  }}

⌨️ 快捷键说明

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