diff options
author | Michael Koch <konqueror@gmx.de> | 2003-03-31 06:30:01 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2003-03-31 06:30:01 +0000 |
commit | 2ce0d0b097225538935a0ac9e1b713c024183547 (patch) | |
tree | 14b48288634510a2d92d2fedc668b585e82853f6 /libjava/javax/swing/undo/UndoableEditSupport.java | |
parent | 98d3d336205c751fcf2f6a31a5b5553994556060 (diff) | |
download | gcc-2ce0d0b097225538935a0ac9e1b713c024183547.zip gcc-2ce0d0b097225538935a0ac9e1b713c024183547.tar.gz gcc-2ce0d0b097225538935a0ac9e1b713c024183547.tar.bz2 |
AbstractCellEditor.java, [...]: Merges from classpath.
2003-03-31 Michael Koch <konqueror@gmx.de>
* javax/swing/AbstractCellEditor.java,
javax/swing/AbstractListModel.java,
javax/swing/ActionMap.java,
javax/swing/BorderFactory.java,
javax/swing/ButtonGroup.java,
javax/swing/DefaultBoundedRangeModel.java,
javax/swing/DefaultButtonModel.java,
javax/swing/DefaultCellEditor.java,
javax/swing/DefaultComboBoxModel.java,
javax/swing/DefaultDesktopManager.java,
javax/swing/DefaultListCellRenderer.java,
javax/swing/DefaultSingleSelectionModel.java,
javax/swing/InputMap.java,
javax/swing/JComponent.java,
javax/swing/JMenu.java,
javax/swing/JSlider.java,
javax/swing/KeyStroke.java,
javax/swing/OverlayLayout.java,
javax/swing/ScrollPaneLayout.java,
javax/swing/SizeRequirements.java,
javax/swing/UIManager.java,
javax/swing/ViewportLayout.java,
javax/swing/border/AbstractBorder.java,
javax/swing/colorchooser/DefaultColorSelectionModel.java,
javax/swing/event/EventListenerList.java,
javax/swing/table/AbstractTableModel.java,
javax/swing/table/DefaultTableCellRenderer.java,
javax/swing/table/DefaultTableColumnModel.java,
javax/swing/table/DefaultTableModel.java,
javax/swing/table/TableColumn.java,
javax/swing/text/StyledEditorKit.java,
javax/swing/tree/DefaultMutableTreeNode.java,
javax/swing/tree/DefaultTreeModel.java,
javax/swing/tree/DefaultTreeSelectionModel.java,
javax/swing/tree/TreePath.java,
javax/swing/undo/AbstractUndoableEdit.java,
javax/swing/undo/StateEdit.java,
javax/swing/undo/StateEditable.java,
javax/swing/undo/UndoableEditSupport.java:
Merges from classpath.
From-SVN: r65077
Diffstat (limited to 'libjava/javax/swing/undo/UndoableEditSupport.java')
-rw-r--r-- | libjava/javax/swing/undo/UndoableEditSupport.java | 293 |
1 files changed, 168 insertions, 125 deletions
diff --git a/libjava/javax/swing/undo/UndoableEditSupport.java b/libjava/javax/swing/undo/UndoableEditSupport.java index 6f87398..f09f3ff 100644 --- a/libjava/javax/swing/undo/UndoableEditSupport.java +++ b/libjava/javax/swing/undo/UndoableEditSupport.java @@ -1,5 +1,5 @@ -/* AbstractTableModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. +/* UndoableEditSupport.java -- + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,126 +45,169 @@ import javax.swing.event.*; * UndoableEditSupport * @author Andrew Selkirk */ -public class UndoableEditSupport { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * updateLevel - */ - protected int updateLevel; - - /** - * compoundEdit - */ - protected CompoundEdit compoundEdit; - - /** - * listeners - */ - protected Vector listeners = new Vector(); - - /** - * realSource - */ - protected Object realSource; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor UndoableEditSupport - */ - public UndoableEditSupport() { - // TODO - } // UndoableEditSupport() - - /** - * Constructor UndoableEditSupport - * @param object TODO - */ - public UndoableEditSupport(Object object) { - realSource = object; - } // UndoableEditSupport() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * toString - * @returns String - */ - public String toString() { - return null; // TODO - } // toString() - - /** - * addUndoableEditListener - * @param value0 TODO - */ - public synchronized void addUndoableEditListener(UndoableEditListener value0) { - // TODO - } // addUndoableEditListener() - - /** - * removeUndoableEditListener - * @param value0 TODO - */ - public synchronized void removeUndoableEditListener(UndoableEditListener value0) { - // TODO - } // removeUndoableEditListener() - - /** - * _postEdit - * @param value0 TODO - */ - protected void _postEdit(UndoableEdit value0) { - // TODO - } // _postEdit() - - /** - * postEdit - * @param value0 TODO - */ - public synchronized void postEdit(UndoableEdit value0) { - // TODO - } // postEdit() - - /** - * getUpdateLevel - * @returns int - */ - public int getUpdateLevel() { - return 0; // TODO - } // getUpdateLevel() - - /** - * beginUpdate - */ - public synchronized void beginUpdate() { - // TODO - } // beginUpdate() - - /** - * createCompoundEdit - * @returns CompoundEdit - */ - protected CompoundEdit createCompoundEdit() { - return null; // TODO - } // createCompoundEdit() - - /** - * endUpdate - */ - public synchronized void endUpdate() { - // TODO - } // endUpdate() - - -} // UndoableEditSupport +public class UndoableEditSupport +{ + + //------------------------------------------------------------- + // Variables -------------------------------------------------- + //------------------------------------------------------------- + + /** + * updateLevel + */ + protected int updateLevel; + + /** + * compoundEdit + */ + protected CompoundEdit compoundEdit; + + /** + * listeners + */ + protected Vector listeners = new Vector(); + + /** + * realSource + */ + protected Object realSource; + + + //------------------------------------------------------------- + // Initialization --------------------------------------------- + //------------------------------------------------------------- + + /** + * Constructor UndoableEditSupport + */ + public UndoableEditSupport() + { + } + + /** + * Constructor UndoableEditSupport + * @param object TODO + */ + public UndoableEditSupport(Object object) + { + realSource = object; + } + + + //------------------------------------------------------------- + // Methods ---------------------------------------------------- + //------------------------------------------------------------- + + /** + * toString + * @returns String + */ + public String toString() + { + return (super.toString() + " realSource: " + realSource + + " updateLevel: " + updateLevel); + } + + /** + * Add a listener. + * @param val the listener + */ + public synchronized void addUndoableEditListener(UndoableEditListener val) + { + listeners.add(val); + } + + /** + * Remove a listener. + * @param val the listener + */ + public synchronized void removeUndoableEditListener(UndoableEditListener val) + { + listeners.removeElement(val); + } + + /** + * Return an array of all listeners. + * @returns all the listeners + */ + public synchronized UndoableEditListener[] getUndoableEditListeners() + { + UndoableEditListener[] result = new UndoableEditListener[listeners.size()]; + return (UndoableEditListener[]) listeners.toArray(result); + } + + /** + * _postEdit + * @param value0 TODO + */ + protected void _postEdit(UndoableEdit edit) + { + UndoableEditEvent event = new UndoableEditEvent(realSource, edit); + int max = listeners.size(); + for (int i = 0; i < max; ++i) + { + UndoableEditListener l + = (UndoableEditListener) (listeners.elementAt(i)); + l.undoableEditHappened(event); + } + } + + /** + * postEdit + * @param value0 TODO + */ + public synchronized void postEdit(UndoableEdit edit) + { + if (compoundEdit == null) + compoundEdit.addEdit(edit); + else + _postEdit(edit); + } + + /** + * getUpdateLevel + * @returns int + */ + public int getUpdateLevel() + { + return updateLevel; + } + + /** + * beginUpdate + */ + public synchronized void beginUpdate() + { + if (compoundEdit != null) + { + // FIXME: what? We can't push a new one. This isn't even + // documented anyway. + endUpdate(); + } + + compoundEdit = createCompoundEdit(); + ++updateLevel; + } + + /** + * createCompoundEdit + * @returns CompoundEdit + */ + protected CompoundEdit createCompoundEdit() + { + return new CompoundEdit(); + } + + /** + * endUpdate + */ + public synchronized void endUpdate() + { + // FIXME: assert updateLevel == 1; + compoundEdit.end(); + CompoundEdit c = compoundEdit; + compoundEdit = null; + --updateLevel; + _postEdit(c); + } +} |