mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46: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:
parent
d5b99ef295
commit
2e7912869b
4 changed files with 77 additions and 4 deletions
|
@ -29,15 +29,23 @@ 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()
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -323,7 +323,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
|
|||
newId = newId.toUpperCase();
|
||||
|
||||
if ((newId == null) || (newId.length()==0)) // a "clear" request?
|
||||
{
|
||||
{
|
||||
clearLocalDefaultUserId();
|
||||
}
|
||||
else
|
||||
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue