Index: src/org/openide/loaders/DataObject.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/DataObject.java,v --- src/org/openide/loaders/DataObject.java 30 Oct 2001 20:45:57 -0000 1.63 +++ src/org/openide/loaders/DataObject.java 27 Nov 2001 10:42:50 -0000 @@ -119,6 +119,9 @@ private PrimaryFileListener primaryFileListener; private static final Object syncObject = new Object(); + + /** private lock used at delete and rename methods. */ + private final String privateLock = "DataObject.privateLock"; /** Create new data object. * @param pf primary file object for this data object @@ -511,20 +514,20 @@ *

Events are fired and atomicity is implemented. * @exception IOException if an error occures */ - public final synchronized void delete () throws IOException { - // the object is ready to be closed - FileSystem fs = getPrimaryFile ().getFileSystem (); - fs.runAtomicAction (new FileSystem.AtomicAction () { - public void run () throws IOException { - handleDelete (); - item.deregister(false); - item.setDataObject(null); - } - }); - firePropertyChange (PROP_VALID, Boolean.TRUE, Boolean.FALSE); - fireOperationEvent ( - new OperationEvent (this), OperationEvent.DELETE - ); + public final void delete () throws IOException { + synchronized ( privateLock ) { + // the object is ready to be closed + FileSystem fs = getPrimaryFile ().getFileSystem (); + fs.runAtomicAction (new FileSystem.AtomicAction () { + public void run () throws IOException { + handleDelete (); + item.deregister(false); + item.setDataObject(null); + } + }); + firePropertyChange (PROP_VALID, Boolean.TRUE, Boolean.FALSE); + fireOperationEvent (new OperationEvent (this), OperationEvent.DELETE); + } } /** Delete this object (implemented by subclasses). @@ -540,29 +543,29 @@ * * @exception IOException if an error occurs */ - public final synchronized void rename (final String name) throws IOException { - String oldName = getName (); - - if (oldName.equals (name)) return; // the new name is the same as the old one + public final void rename (final String name) throws IOException { + synchronized ( privateLock ) { + String oldName = getName (); + + if (oldName.equals (name)) return; // the new name is the same as the old one + + FileObject old = getPrimaryFile (); + + // executes atomic action with renaming + FileSystem fs = old.getFileSystem (); + fs.runAtomicAction (new FileSystem.AtomicAction () { + public void run () throws IOException { + FileObject mf = handleRename (name); + item.changePrimaryFile (mf); + } + }); - FileObject old = getPrimaryFile (); + firePropertyChange (PROP_PRIMARY_FILE, old, getPrimaryFile ()); + fireOperationEvent (new OperationEvent.Rename (this, oldName), OperationEvent.RENAME); - // executes atomic action with renaming - FileSystem fs = old.getFileSystem (); - fs.runAtomicAction (new FileSystem.AtomicAction () { - public void run () throws IOException { - FileObject mf = handleRename (name); - item.changePrimaryFile (mf); - } - }); - - firePropertyChange (PROP_PRIMARY_FILE, old, getPrimaryFile ()); - fireOperationEvent ( - new OperationEvent.Rename (this, oldName), OperationEvent.RENAME - ); - - // rename succeed - firePropertyChange(DataObject.PROP_NAME, oldName, getName ()); + // rename succeed + firePropertyChange(DataObject.PROP_NAME, oldName, getName ()); + } } /** Rename this object (implemented in subclasses).