1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

bug 142743 - Problem was located in Host. It was not tagging itself as dirty for certain attribute changes. Moreover, it must also tag the containing SystemHostPool. The persistence framework has been fixed to allow changes in one object to propagate to another and Host now takes advantage of this.

This commit is contained in:
David Dykstal 2006-09-14 18:57:10 +00:00
parent d5b99ef295
commit 2e7912869b
4 changed files with 77 additions and 4 deletions

View file

@ -29,17 +29,25 @@ public abstract class RSEModelObject extends PropertySetContainer implements IRS
protected boolean _wasRestored = false;
/* (non-Javadoc)
* @see org.eclipse.rse.core.persistance.IRSEPersistableContainer#isDirty()
*/
public final boolean isDirty()
{
return _isDirty;
}
public final void setDirty(boolean flag)
/* (non-Javadoc)
* @see org.eclipse.rse.core.persistance.IRSEPersistableContainer#setDirty(boolean)
*/
public void setDirty(boolean flag)
{
_isDirty = flag;
}
public final boolean wasRestored()
{
return _wasRestored;
@ -54,4 +62,22 @@ public abstract class RSEModelObject extends PropertySetContainer implements IRS
{
return RSEModelResources.RESID_MODELOBJECTS_MODELOBJECT_DESCRIPTION;
}
/**
* Does a null-aware string comparison. Two strings that are
* <code>null</code> will compare equal. Otherwise the result is
* the same as s1.equals(s2), if s1 is not null.
* @param s1 The first string to compare
* @param s2 the second string
* @return true if the strings are equal or both null.
*/
protected boolean compareStrings(String s1, String s2) {
boolean result = false;
if (s1 == null) {
result = s1 == null;
} else {
result = s1.equals(s2);
}
return result;
}
}

View file

@ -18,11 +18,42 @@ package org.eclipse.rse.core.persistance;
public interface IRSEPersistableContainer
{
/**
* An object is dirty if a change has been made to it that requires
* it to be persisted.
* @return true if the object is dirty
*/
public boolean isDirty();
/**
* An object is dirty if a change has been made to it that requires
* it to be persisted. Objects should usually mark themselves dirty
* when a persistable change is made. However, there may be a need
* to mark related objects dirty as well.
* Setting this value to false should be done only in the persistence
* manager after the object has been written to the DOM.
* @param flag true if the object must be persisted.
*/
public void setDirty(boolean flag);
/**
* Request a persistence manager to persist this object.
* @return true if the object was persisted.
*/
public boolean commit();
/**
* An object was restored if it originated from a persistent form.
* @return true if the object was created from its persistent form,
* false if the object has never been persisted.
*/
public boolean wasRestored();
/**
* The the "restored" state of the object. Only persistence managers
* should do this.
* @param flag true if the object was restored.
*/
public void setWasRestored(boolean flag);
}

View file

@ -543,6 +543,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
*/
public void setDescription(String newDescription)
{
setDirty(!compareStrings(description, newDescription));
description = newDescription;
}
@ -559,6 +560,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
*/
public void setPromptable(boolean newPromptable)
{
setDirty(promptable != newPromptable);
promptable = newPromptable;
}
@ -583,6 +585,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
*/
public void setOffline(boolean newOffline)
{
setDirty(offline != newOffline);
offline = newOffline;
}
@ -591,6 +594,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
*/
public void setSystemTypeGen(String newSystemType)
{
setDirty(!compareStrings(systemType, newSystemType));
systemType = newSystemType;
}
@ -599,6 +603,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
*/
public void setAliasNameGen(String newAliasName)
{
setDirty(!compareStrings(aliasName, newAliasName));
aliasName = newAliasName;
}
@ -607,6 +612,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
*/
public void setHostNameGen(String newHostName)
{
setDirty(!compareStrings(hostName, newHostName));
hostName = newHostName;
}
@ -623,6 +629,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
*/
public void setDefaultUserIdGen(String newDefaultUserId)
{
setDirty(!compareStrings(defaultUserId, newDefaultUserId));
defaultUserId = newDefaultUserId;
}
@ -650,6 +657,17 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
return result.toString();
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.RSEModelObject#setDirty(boolean)
*/
public void setDirty(boolean flag) {
super.setDirty(flag);
ISystemHostPool myPool = getHostPool();
if (myPool != null && flag) {
myPool.setDirty(true);
}
};
public boolean commit()
{
return RSEUIPlugin.getThePersistenceManager().commit(this);

View file

@ -387,7 +387,6 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
public void deleteHost(IHost conn)
{
conn.deletingHost(); // let connection do any necessary cleanup
getHostList().remove(conn);
setDirty(true);
RSEUIPlugin.getThePersistenceManager().commit(conn.getSystemProfile());
@ -409,7 +408,6 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
{
conn.setAliasName(newName);
invalidateCache();
conn.setDirty(true);
commit(conn);
}