1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-19 14:15:50 +02:00

bug 153253 - Fixed the synchronization between the DOM writing job and the export to the DOM. Made the PropertyFileProvider a bit more resilient when reading the persistent form. Fixed the SystemFilterPool to mark itself dirty when changed. Minor formatting changes to SystemNewFilterWizard and SubSystem.

This commit is contained in:
David Dykstal 2006-08-17 22:40:47 +00:00
parent 8f323d4661
commit 80fc326d06
14 changed files with 249 additions and 293 deletions

View file

@ -1113,8 +1113,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
} }
/** /**
* Returns the persistence manager used for persisting RSE profiles * @return the persistence manager used for persisting RSE profiles
* @return
*/ */
public IRSEPersistenceManager getPersistenceManager() public IRSEPersistenceManager getPersistenceManager()
{ {

View file

@ -460,114 +460,85 @@ public class SystemNewFilterWizard
* *
* @return whether the wizard finished successfully * @return whether the wizard finished successfully
*/ */
public boolean performFinish() public boolean performFinish() {
{ boolean ok = false;
//System.out.println("inside performFinish(): mainPage.performFinish() = " + mainPage.performFinish()); newFilter = null;
boolean ok = false;
newFilter = null;
setOutputObject(null); setOutputObject(null);
if (!mainPage.performFinish()) if (!mainPage.performFinish()) {
setPageError(mainPage); setPageError(mainPage);
else if (!namePage.performFinish()) } else if (!namePage.performFinish()) {
setPageError(namePage); setPageError(namePage);
else } else {
{ Vector filterStrings = mainPage.getFilterStrings();
Vector filterStrings = mainPage.getFilterStrings(); String filterName = null;
String filterName = null; if (showNamePrompt) {
if (showNamePrompt) filterName = namePage.getFilterName();
{ // Get the filter parent, i.e. the filter pool for this new filter
filterName = namePage.getFilterName(); ISystemFilterContainer filterParent = null;
ISystemFilterContainer filterParent = null; if ((poolsToSelectFrom != null) || (poolWrapperInformation != null)) {
if ((poolsToSelectFrom!=null) || (poolWrapperInformation != null)) filterParent = namePage.getParentSystemFilterPool();
{ if (namePage.getUniqueToThisConnection()) {
filterParent = namePage.getParentSystemFilterPool(); /*
if (namePage.getUniqueToThisConnection()) * this means the user selected to create this filter in the filter pool that is unique to this connection. So now we
{ * must find, or create, that filter pool.
// this means the user selected to create this filter in the */
// filter pool that is unique to this connection. So now we
// must find, or create, that filter pool:
filterParent = provider.getUniqueOwningSystemFilterPool(true); // true -> create if not found filterParent = provider.getUniqueOwningSystemFilterPool(true); // true -> create if not found
} } else
else
filterParent = namePage.getParentSystemFilterPool(); filterParent = namePage.getParentSystemFilterPool();
} else
filterParent = getFilterContainer();
// Create the filter and possibly a filter pool reference.
String type = mainPage.getType();
try {
newFilter = createNewFilter(getShell(), filterParent, filterName, filterStrings, type);
if (newFilter == null) return false;
/*
* We allow users to select a profile to create their filter in. From this we
* select the default filter pool for the particular subsystem in that profile.
* It is possible for the user to pick a profile that this subsystem does not yet reference.
* To solve this we need to add a reference for them. This is only a possibility when called
* from a subsystem's New Filter action, versus that action on a directly on a filter pool.
*/
if ((provider != null) && (filterParent instanceof ISystemFilterPool)) {
ISystemFilterPool parentPool = (ISystemFilterPool) filterParent;
if (provider.getSystemFilterPoolReferenceManager().getReferenceToSystemFilterPool(parentPool) == null) {
provider.getSystemFilterPoolReferenceManager().addReferenceToSystemFilterPool(parentPool);
}
}
} catch (Exception exc) {
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_OCCURRED);
msg.makeSubstitution(exc);
SystemMessageDialog msgDlg = new SystemMessageDialog(getShell(), msg);
msgDlg.openWithDetails();
return false;
} }
else setOutputObject(newFilter);
filterParent = getFilterContainer(); // special handling to expand the currently selected parent node and reveal the new filter
if ((newFilter != null) && (getInputObject() != null)) {
String type = mainPage.getType(); // query just in case it is changable by user Object selectedObject = getInputObject();
try if ((selectedObject instanceof ISystemFilterPoolReference) || (selectedObject instanceof ISystemFilterPoolReferenceManagerProvider)) {
{ ISystemFilterPoolReferenceManagerProvider provider = null;
newFilter = createNewFilter(getShell(), filterParent, filterName, filterStrings, type); if (selectedObject instanceof ISystemFilterPoolReference) {
if (newFilter == null) ISystemFilterPoolReferenceManager sfprm = ((ISystemFilterPoolReference) selectedObject).getFilterPoolReferenceManager();
return false; if (sfprm != null) provider = sfprm.getProvider();
// Because we allow new users to select a profile to create their filter in, from } else
// which we choose the profile's default filter pool, it is possible the user provider = (ISystemFilterPoolReferenceManagerProvider) selectedObject;
// will choose a filter pool that this subsystem does not yet reference. To solve if (provider != null) provider.filterEventFilterCreated(selectedObject, newFilter);
// this we need to add a reference for them. This is only a possibility when called } else if (selectedObject instanceof ISystemFilterReference) {
// from the subsystem New Filter action, versus from a filter pool say. ISystemFilterReference ref = (ISystemFilterReference) selectedObject;
if ((provider != null) && (filterParent instanceof ISystemFilterPool)) ISystemFilterPoolReferenceManagerProvider provider = ref.getProvider();
{ provider.filterEventFilterCreated(selectedObject, newFilter);
ISystemFilterPool parentPool = (ISystemFilterPool)filterParent; }
if (provider.getSystemFilterPoolReferenceManager().getReferenceToSystemFilterPool(parentPool) == null) }
{ ok = (newFilter != null);
provider.getSystemFilterPoolReferenceManager().addReferenceToSystemFilterPool(parentPool); } // end if showNamePrompt
} else {
} ok = true;
setOutputObject(filterStrings);
/* Hmm, after much thought I have decided to leave this up to the }
* caller. They can do this themselves by overriding createNewFilter in return ok;
* their own wizard. }
if (!showFilterStrings && (newFilter!=null)) return false;
{
newFilter.setNonChangable(true);
newFilter.setStringsNonChangable(true);
}
*/
} catch (Exception exc)
{
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_OCCURRED);
msg.makeSubstitution(exc);
SystemMessageDialog msgDlg = new SystemMessageDialog(getShell(), msg);
msgDlg.openWithDetails();
return false;
}
setOutputObject(newFilter);
// special handling to expand the currently selected parent node and reveal the new filter
if ((newFilter != null) && (getInputObject()!=null))
{
Object selectedObject = getInputObject();
if ((selectedObject instanceof ISystemFilterPoolReference) ||
(selectedObject instanceof ISystemFilterPoolReferenceManagerProvider))
{
ISystemFilterPoolReferenceManagerProvider provider = null;
if (selectedObject instanceof ISystemFilterPoolReference)
{
ISystemFilterPoolReferenceManager sfprm = ((ISystemFilterPoolReference)selectedObject).getFilterPoolReferenceManager();
if (sfprm != null)
provider = sfprm.getProvider();
}
else
provider = (ISystemFilterPoolReferenceManagerProvider)selectedObject;
if (provider != null)
provider.filterEventFilterCreated(selectedObject, newFilter);
}
else if (selectedObject instanceof ISystemFilterReference)
{
ISystemFilterReference ref = (ISystemFilterReference)selectedObject;
ISystemFilterPoolReferenceManagerProvider provider = ref.getProvider();
provider.filterEventFilterCreated(selectedObject, newFilter);
}
}
ok = (newFilter != null);
} // end if showNamePrompt
else
{
ok = true;
setOutputObject(filterStrings);
}
return ok;
}
return false;
} }
/** /**
@ -642,24 +613,21 @@ public class SystemNewFilterWizard
* Extendable point for child classes. * Extendable point for child classes.
* Override to create unique SystemFilter object. * Override to create unique SystemFilter object.
* By default calls createSystemFilter in subsystem factory. * By default calls createSystemFilter in subsystem factory.
* @param shell the shell that hosts this wizard.
* @param filterParent the parent of this filter - usually a filter pool
* @param aliasName the name of the filter itself
* @param filterStrings a Vector of string that contain the specification of this filter
* @param type the type of the filter used when interpreting the filter, usually supplied by a subsystem
* @return the ISystemFilter that was created
* @throws Exception if an error occurs
*/ */
public ISystemFilter createNewFilter(Shell shell, ISystemFilterContainer filterParent, String aliasName, Vector filterStrings, String type) public ISystemFilter createNewFilter(Shell shell, ISystemFilterContainer filterParent, String aliasName, Vector filterStrings, String type) throws Exception {
throws Exception
{
ISystemFilter newFilter = null; ISystemFilter newFilter = null;
ISystemFilterPoolManager fpMgr = filterParent.getSystemFilterPoolManager(); ISystemFilterPoolManager fpMgr = filterParent.getSystemFilterPoolManager();
//try { if (type == null)
// create filter newFilter = fpMgr.createSystemFilter(filterParent, aliasName, filterStrings);
if (type == null) else
newFilter = fpMgr.createSystemFilter(filterParent,aliasName,filterStrings); newFilter = fpMgr.createSystemFilter(filterParent, aliasName, filterStrings, type);
else
newFilter = fpMgr.createSystemFilter(filterParent,aliasName,filterStrings,type);
//} catch (Exception exc)
//{
//RSEUIPlugin.logError("Exception in createNewFilter in SystemFilterAbstractNewFilterWizard. ",);
//System.out.println("Exception in createNewFilter in SystemFilterAbstractNewFilterWizard: "+exc.getMessage());
//exc.printStackTrace();
//}
return newFilter; return newFilter;
} }

View file

@ -200,10 +200,16 @@ public class SystemViewFilterPoolReferenceAdapter
/** /**
* Return true if this object has children * Return true if this object has children
*/ */
public boolean hasChildren(Object element) public boolean hasChildren(Object element) {
{ int count = 0;
ISystemFilterPoolReference fpRef = getFilterPoolReference(element); ISystemFilterPoolReference fpRef = getFilterPoolReference(element);
return (fpRef.getReferencedFilterPool().getSystemFilterCount() > 0); if (fpRef != null) {
ISystemFilterPool filterPool = fpRef.getReferencedFilterPool();
if (filterPool != null) {
count = filterPool.getSystemFilterCount();
}
}
return count > 0;
} }
// Property sheet descriptors defining all the properties we expose in the Property Sheet // Property sheet descriptors defining all the properties we expose in the Property Sheet

View file

@ -77,19 +77,13 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
private int savePolicy; private int savePolicy;
private IRSEFilterNamingPolicy namingPolicy = null; private IRSEFilterNamingPolicy namingPolicy = null;
private ISystemFilterPoolManager mgr; private ISystemFilterPoolManager mgr;
//private Vector filters = new Vector();
private SystemFilterContainerCommonMethods helpers = null; private SystemFilterContainerCommonMethods helpers = null;
private Object filterPoolData = null; private Object filterPoolData = null;
private boolean initialized = false; private boolean initialized = false;
//private boolean isSharable = false;
protected boolean specialCaseNoDataRestored = false; protected boolean specialCaseNoDataRestored = false;
private boolean debug = false; private boolean debug = false;
protected static final String DELIMITER = SystemFilterPoolReference.DELIMITER; protected static final String DELIMITER = SystemFilterPoolReference.DELIMITER;
// persistence
// protected boolean _isDirty = true; FIXME
// protected boolean _wasRestored = false; FIXME
/** /**
* @generated This field/method will be replaced during code generation. * @generated This field/method will be replaced during code generation.
*/ */
@ -473,6 +467,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public void setSupportsDuplicateFilterStringsGen(boolean newSupportsDuplicateFilterStrings) public void setSupportsDuplicateFilterStringsGen(boolean newSupportsDuplicateFilterStrings)
{ {
supportsDuplicateFilterStrings = newSupportsDuplicateFilterStrings; supportsDuplicateFilterStrings = newSupportsDuplicateFilterStrings;
setDirty(true);
} }
/** /**
@ -486,6 +481,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
if (filters != null) if (filters != null)
for (int idx=0; idx<filters.length; idx++) for (int idx=0; idx<filters.length; idx++)
filters[idx].setStringsCaseSensitive(supports); filters[idx].setStringsCaseSensitive(supports);
setDirty(true);
} }
/** /**
* <!-- begin-user-doc --> * <!-- begin-user-doc -->
@ -496,6 +492,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
{ {
stringsCaseSensitive = newStringsCaseSensitive; stringsCaseSensitive = newStringsCaseSensitive;
stringsCaseSensitiveESet = true; stringsCaseSensitiveESet = true;
setDirty(true);
} }
/** /**
@ -599,6 +596,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public void setDeletable(boolean newDeletable) public void setDeletable(boolean newDeletable)
{ {
deletable = newDeletable; deletable = newDeletable;
setDirty(true);
} }
/** /**
@ -807,7 +805,9 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
*/ */
public boolean addSystemFilter(ISystemFilter filter) public boolean addSystemFilter(ISystemFilter filter)
{ {
return helpers.addSystemFilter(internalGetFilters(),filter); boolean result = helpers.addSystemFilter(internalGetFilters(),filter);
if (result) setDirty(true);
return result;
} }
/** /**
* Removes a given filter from the list. * Removes a given filter from the list.
@ -816,6 +816,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public void deleteSystemFilter(ISystemFilter filter) public void deleteSystemFilter(ISystemFilter filter)
{ {
helpers.deleteSystemFilter(internalGetFilters(),filter); helpers.deleteSystemFilter(internalGetFilters(),filter);
setDirty(true);
} }
/** /**
@ -825,6 +826,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public void renameSystemFilter(ISystemFilter filter, String newName) public void renameSystemFilter(ISystemFilter filter, String newName)
{ {
helpers.renameSystemFilter(internalGetFilters(),filter, newName); helpers.renameSystemFilter(internalGetFilters(),filter, newName);
setDirty(true);
} }
/** /**
@ -836,6 +838,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public void updateSystemFilter(ISystemFilter filter, String newName, String[] newStrings) public void updateSystemFilter(ISystemFilter filter, String newName, String[] newStrings)
{ {
helpers.updateSystemFilter(internalGetFilters(), filter, newName, newStrings); helpers.updateSystemFilter(internalGetFilters(), filter, newName, newStrings);
setDirty(true);
} }
/** /**
@ -845,7 +848,9 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
*/ */
public ISystemFilter cloneSystemFilter(ISystemFilter filter, String aliasName) public ISystemFilter cloneSystemFilter(ISystemFilter filter, String aliasName)
{ {
return helpers.cloneSystemFilter(internalGetFilters(), filter, aliasName); ISystemFilter result = helpers.cloneSystemFilter(internalGetFilters(), filter, aliasName);
setDirty(true);
return result;
} }
/** /**
@ -862,6 +867,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public void moveSystemFilter(int pos, ISystemFilter filter) public void moveSystemFilter(int pos, ISystemFilter filter)
{ {
helpers.moveSystemFilter(internalGetFilters(),pos,filter); helpers.moveSystemFilter(internalGetFilters(),pos,filter);
setDirty(true);
} }
/** /**
@ -1140,6 +1146,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public void setType(String newType) public void setType(String newType)
{ {
type = newType; type = newType;
setDirty(true);
} }
/** /**
@ -1157,7 +1164,8 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
{ {
stringsCaseSensitive = STRINGS_CASE_SENSITIVE_EDEFAULT; stringsCaseSensitive = STRINGS_CASE_SENSITIVE_EDEFAULT;
stringsCaseSensitiveESet = false; stringsCaseSensitiveESet = false;
} setDirty(true);
}
/** /**
* @generated This field/method will be replaced during code generation. * @generated This field/method will be replaced during code generation.
@ -1204,6 +1212,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
public void setRelease(int newRelease) public void setRelease(int newRelease)
{ {
release = newRelease; release = newRelease;
setDirty(true);
} }
/** /**
@ -1236,6 +1245,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
{ {
singleFilterStringOnly = newSingleFilterStringOnly; singleFilterStringOnly = newSingleFilterStringOnly;
singleFilterStringOnlyESet = true; singleFilterStringOnlyESet = true;
setDirty(true);
} }
/** /**
@ -1247,6 +1257,7 @@ public class SystemFilterPool extends SystemPersistableReferencedObject
{ {
singleFilterStringOnly = SINGLE_FILTER_STRING_ONLY_EDEFAULT; singleFilterStringOnly = SINGLE_FILTER_STRING_ONLY_EDEFAULT;
singleFilterStringOnlyESet = false; singleFilterStringOnlyESet = false;
setDirty(true);
} }
/** /**

View file

@ -157,7 +157,11 @@ public class SystemFilterPoolReference extends SystemPersistableReferencingObjec
if (filterPool == null) { if (filterPool == null) {
String filterPoolName = getReferencedFilterPoolName(); String filterPoolName = getReferencedFilterPoolName();
filterPool = filterPoolManager.getSystemFilterPool(filterPoolName); filterPool = filterPoolManager.getSystemFilterPool(filterPoolName);
setReferenceToFilterPool(filterPool); if (filterPool != null) {
setReferenceToFilterPool(filterPool);
} else {
this.setReferenceBroken(true);
}
} }
return filterPool; return filterPool;
} }

View file

@ -655,7 +655,7 @@ public class Host extends RSEModelObject implements IHost, IAdaptable
public boolean commit() public boolean commit()
{ {
return RSEUIPlugin.getThePersistenceManager().commit(this.getSystemProfile()); return RSEUIPlugin.getThePersistenceManager().commit(this);
} }
} }

View file

@ -27,6 +27,7 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector; import java.util.Vector;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -111,9 +112,9 @@ public class PropertyFileProvider implements IRSEPersistenceProvider {
* @see org.eclipse.rse.persistence.IRSEPersistenceProvider#saveRSEDOM(org.eclipse.rse.persistence.dom.RSEDOM, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.rse.persistence.IRSEPersistenceProvider#saveRSEDOM(org.eclipse.rse.persistence.dom.RSEDOM, org.eclipse.core.runtime.IProgressMonitor)
*/ */
public boolean saveRSEDOM(RSEDOM dom, IProgressMonitor monitor) { public boolean saveRSEDOM(RSEDOM dom, IProgressMonitor monitor) {
String profileName = dom.getName();
IFolder providerFolder = getProviderFolder(); IFolder providerFolder = getProviderFolder();
//System.out.println("saving profile " + profileName + " to " + providerFolder.getFullPath().toString() + "..."); // DWD debugging // String profileName = dom.getName();
// System.out.println("saving profile " + profileName + " to " + providerFolder.getFullPath().toString() + "...");
try { try {
int n = countNodes(dom); int n = countNodes(dom);
if (monitor != null) monitor.beginTask("Saving DOM", n); if (monitor != null) monitor.beginTask("Saving DOM", n);
@ -441,7 +442,7 @@ public class PropertyFileProvider implements IRSEPersistenceProvider {
RSEDOM dom = null; RSEDOM dom = null;
IFolder profileFolder = getProfileFolder(profileName); IFolder profileFolder = getProfileFolder(profileName);
if (profileFolder.exists()) { if (profileFolder.exists()) {
//System.out.println("loading from " + profileFolder.getFullPath().toString() + "..."); // DWD debugging //System.out.println("loading from " + profileFolder.getFullPath().toString() + "...");
int n = countPropertiesFiles(profileFolder); int n = countPropertiesFiles(profileFolder);
if (monitor != null) monitor.beginTask("Loading DOM", n); if (monitor != null) monitor.beginTask("Loading DOM", n);
dom = (RSEDOM) loadNode(null, profileFolder, monitor); dom = (RSEDOM) loadNode(null, profileFolder, monitor);
@ -547,11 +548,11 @@ public class PropertyFileProvider implements IRSEPersistenceProvider {
RSEDOMNode node = (parent == null) ? new RSEDOM(nodeName) : new RSEDOMNode(parent, nodeType, nodeName); RSEDOMNode node = (parent == null) ? new RSEDOM(nodeName) : new RSEDOMNode(parent, nodeType, nodeName);
node.setRestoring(true); node.setRestoring(true);
Set keys = properties.keySet(); Set keys = properties.keySet();
int nReferences = 0;
int nChildren = 0;
Map attributes = new HashMap(); Map attributes = new HashMap();
Map attributeTypes = new HashMap(); Map attributeTypes = new HashMap();
Map childPropertiesMap = new HashMap(); Map childPropertiesMap = new HashMap();
Set childNames = new TreeSet(); // child names are 5 digit strings, a tree set is used to maintain ordering
Set referenceNames = new TreeSet(); // ditto for reference names
for (Iterator z = keys.iterator(); z.hasNext();) { for (Iterator z = keys.iterator(); z.hasNext();) {
String key = (String) z.next(); String key = (String) z.next();
String[] words = split(key, 2); String[] words = split(key, 2);
@ -563,16 +564,15 @@ public class PropertyFileProvider implements IRSEPersistenceProvider {
String type = properties.getProperty(key); String type = properties.getProperty(key);
attributeTypes.put(words[1], type); attributeTypes.put(words[1], type);
} else if (metatype.equals(MT_REFERENCE)) { } else if (metatype.equals(MT_REFERENCE)) {
int n = Integer.parseInt(words[1]) + 1; String referenceName = words[1];
if (nReferences < n) nReferences = n; referenceNames.add(referenceName);
} else if (metatype.equals(MT_CHILD)) { } else if (metatype.equals(MT_CHILD)) {
String value = properties.getProperty(key); String value = properties.getProperty(key);
words = split(words[1], 2); words = split(words[1], 2);
String indexString = words[0]; String childName = words[0];
childNames.add(childName);
String newKey = words[1]; String newKey = words[1];
int n = Integer.parseInt(indexString) + 1; Properties p = getProperties(childPropertiesMap, childName);
if (nChildren < n) nChildren = n;
Properties p = getProperties(childPropertiesMap, indexString);
p.put(newKey, value); p.put(newKey, value);
} }
} }
@ -584,14 +584,14 @@ public class PropertyFileProvider implements IRSEPersistenceProvider {
String attributeType = (String) attributeTypes.get(attributeName); String attributeType = (String) attributeTypes.get(attributeName);
node.addAttribute(attributeName, attributeValue, attributeType); node.addAttribute(attributeName, attributeValue, attributeType);
} }
for (int i = 0; i < nChildren; i++) { for (Iterator z = childNames.iterator(); z.hasNext();) {
String selector = getIndexString(i); String childName = (String) z.next();
Properties p = getProperties(childPropertiesMap, selector); Properties p = getProperties(childPropertiesMap, childName);
makeNode(node, nodeFolder, p, monitor); makeNode(node, nodeFolder, p, monitor);
} }
for (int i = 0; i < nReferences; i++) { for (Iterator z = referenceNames.iterator(); z.hasNext();) {
String selector = getIndexString(i); String referenceName = (String) z.next();
String key = combine(MT_REFERENCE, selector); String key = combine(MT_REFERENCE, referenceName);
String childFolderName = properties.getProperty(key); String childFolderName = properties.getProperty(key);
IFolder childFolder = getFolder(nodeFolder, childFolderName); IFolder childFolder = getFolder(nodeFolder, childFolderName);
loadNode(node, childFolder, monitor); loadNode(node, childFolder, monitor);

View file

@ -25,6 +25,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceManager; import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
@ -45,15 +46,20 @@ import org.eclipse.rse.persistence.IRSEPersistenceProvider;
import org.eclipse.rse.persistence.dom.RSEDOM; import org.eclipse.rse.persistence.dom.RSEDOM;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
/**
* The persistence manager controls all aspects of persisting the RSE data model. It will both
* save and restore this model. There should be only persistence manager in existence. This instance
* can be retrieved using RSEUIPlugin.getThePersistenceManager.
* @see RSEUIPlugin#getThePersistenceManager()
*/
public class RSEPersistenceManager implements IRSEPersistenceManager { public class RSEPersistenceManager implements IRSEPersistenceManager {
public static final int STATE_NONE = 0;
public static final int STATE_IMPORTING = 1; private static final int STATE_NONE = 0;
public static final int STATE_EXPORTING = 2; private static final int STATE_IMPORTING = 1;
private static final int STATE_EXPORTING = 2;
private Map loadedProviders = new HashMap(10); private Map loadedProviders = new HashMap(10);
private int _currentState = STATE_NONE; private int _currentState = STATE_NONE;
private RSEDOMExporter _exporter; private RSEDOMExporter _exporter;
private RSEDOMImporter _importer; private RSEDOMImporter _importer;
@ -282,7 +288,6 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
* wrong, an exception is thrown. * wrong, an exception is thrown.
*/ */
public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name) { public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name) {
ISystemFilterPoolManager mgr = SystemFilterPoolManager.createManager(profile); ISystemFilterPoolManager mgr = SystemFilterPoolManager.createManager(profile);
((SystemFilterPoolManager) mgr).initialize(logger, caller, name); // core data ((SystemFilterPoolManager) mgr).initialize(logger, caller, name); // core data
mgr.setWasRestored(false); // DWD let's try this mgr.setWasRestored(false); // DWD let's try this
@ -299,12 +304,16 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
return false; return false;
} }
public boolean commit(IHost host) {
return commit(host.getSystemProfile());
}
/** /**
* Loads and restores RSE artifacts from the last session * Loads and restores RSE artifacts from the last session
* @param profileManager * @param profileManager
* @return true if the profiles are loaded * @return true if the profiles are loaded
*/ */
public boolean load(ISystemProfileManager profileManager) { private boolean load(ISystemProfileManager profileManager) {
boolean successful = true; boolean successful = true;
if (isExporting() || isImporting()) { if (isExporting() || isImporting()) {
successful = false; successful = false;
@ -336,22 +345,25 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
} }
/** /**
* Saves the RSE artifacts from this session * Writes the RSE model to a DOM and schedules writing of that DOM to disk.
* May, in fact, update an existing DOM instead of creating a new one.
* If in the process of importing, skip writing.
* @return true if the profile is written to a DOM
*/ */
public boolean save(ISystemProfile profile, boolean force) { private boolean save(ISystemProfile profile, boolean force) {
boolean result = false; boolean result = false;
if (!isImporting() && !isExporting()) { if (!isImporting()) {
_currentState = STATE_EXPORTING;
RSEDOM dom = exportRSEDOM(profile, force); RSEDOM dom = exportRSEDOM(profile, true); // DWD should do merge, but does not handle deletes properly yet
if (dom.needsSave() && !dom.saveScheduled()) { _currentState = STATE_NONE;
// IProject project = SystemResourceManager.getRemoteSystemsProject(); result = true;
SaveRSEDOMJob job = new SaveRSEDOMJob(this, dom, getRSEPersistenceProvider()); if (dom.needsSave()) {
// job.setRule(project); Job job = dom.getSaveJob();
job.schedule(0); // TODO dwd control job delay here if (job == null) {
dom.markSaveScheduled(); job = new SaveRSEDOMJob(dom, getRSEPersistenceProvider());
} else { dom.setSaveJob(job);
//System.out.println("no save required"); }
result = true; job.schedule(3000); // five second delay
} }
} }
return result; return result;
@ -365,17 +377,16 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
return _currentState == STATE_IMPORTING; return _currentState == STATE_IMPORTING;
} }
public void setState(int state) { // public void setState(int state) {
_currentState = state; // _currentState = state;
} // }
public RSEDOM exportRSEDOM(ISystemProfile profile, boolean force) { private RSEDOM exportRSEDOM(ISystemProfile profile, boolean force) {
_currentState = STATE_EXPORTING;
RSEDOM dom = _exporter.createRSEDOM(profile, force); RSEDOM dom = _exporter.createRSEDOM(profile, force);
return dom; return dom;
} }
public RSEDOM importRSEDOM(String domName) { private RSEDOM importRSEDOM(String domName) {
RSEDOM dom = null; RSEDOM dom = null;
IRSEPersistenceProvider provider = getRSEPersistenceProvider(); IRSEPersistenceProvider provider = getRSEPersistenceProvider();
if (provider != null) { if (provider != null) {
@ -387,8 +398,4 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
return dom; return dom;
} }
public boolean commit(IHost host) {
return commit(host.getSystemProfile());
}
} }

View file

@ -23,35 +23,28 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.persistence.IRSEPersistenceProvider; import org.eclipse.rse.persistence.IRSEPersistenceProvider;
import org.eclipse.rse.persistence.dom.RSEDOM; import org.eclipse.rse.persistence.dom.RSEDOM;
public class SaveRSEDOMJob extends Job {
public class SaveRSEDOMJob extends Job
{
private RSEPersistenceManager _mgr;
private RSEDOM _dom; private RSEDOM _dom;
private IRSEPersistenceProvider _provider; private IRSEPersistenceProvider _provider;
public SaveRSEDOMJob(RSEPersistenceManager mgr, RSEDOM dom, IRSEPersistenceProvider provider) public SaveRSEDOMJob(RSEDOM dom, IRSEPersistenceProvider provider) {
{
super("Saving RSE Profile: " + dom.getName()); super("Saving RSE Profile: " + dom.getName());
_dom = dom; _dom = dom;
_mgr = mgr;
_provider = provider; _provider = provider;
} }
protected IStatus run(IProgressMonitor monitor) protected IStatus run(IProgressMonitor monitor) {
{ IStatus result = Status.OK_STATUS;
if (_dom.needsSave()) synchronized (_dom) { // synchronize on the DOM to prevent its update while writing
{ if (_dom.needsSave()) {
_provider.saveRSEDOM(_dom, monitor); _provider.saveRSEDOM(_dom, monitor);
_dom.markUpdated(); _dom.markUpdated();
_mgr.setState(RSEPersistenceManager.STATE_NONE); } else {
return Status.OK_STATUS; result = Status.CANCEL_STATUS;
} }
else
{
return Status.CANCEL_STATUS;
} }
return result;
} }
} }

View file

@ -67,7 +67,8 @@ public class RSEDOMExporter implements IRSEDOMExporter {
} }
/** /**
* Creates the RSE DOM for this profile * Creates the RSE DOM for this profile. After it has found the DOM it will
* synchronize on the DOM to ensure its integrity while it is being updated.
* @param profile the profile for which to create the DOM * @param profile the profile for which to create the DOM
* @param clean indicates whether to create from scratch or merge with existing DOM * @param clean indicates whether to create from scratch or merge with existing DOM
* @return The DOM for this profile * @return The DOM for this profile
@ -79,7 +80,9 @@ public class RSEDOMExporter implements IRSEDOMExporter {
_domMap.put(profile, dom); _domMap.put(profile, dom);
clean = true; clean = true;
} }
populateRSEDOM(dom, profile, clean); synchronized (dom) {
populateRSEDOM(dom, profile, clean);
}
return dom; return dom;
} }

View file

@ -114,14 +114,6 @@ public interface IRSEPersistenceManager
public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name); public ISystemFilterPoolManager restoreFilterPoolManager(ISystemProfile profile, Logger logger, ISystemFilterPoolManagerProvider caller, String name);
/**
* Save the profile externally
* @param profile
* @param clean indicates whether to create from scratch or merger
* @return
*/
public boolean save(ISystemProfile profile, boolean clean);
public boolean isExporting(); public boolean isExporting();
public boolean isImporting(); public boolean isImporting();
} }

View file

@ -16,6 +16,8 @@
package org.eclipse.rse.persistence.dom; package org.eclipse.rse.persistence.dom;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.internal.persistence.SaveRSEDOMJob;
import org.eclipse.rse.model.ISystemProfile; import org.eclipse.rse.model.ISystemProfile;
/** /**
@ -28,7 +30,7 @@ public class RSEDOM extends RSEDOMNode {
* Recommended for serializable objects. This should be updated if there is a schema change. * Recommended for serializable objects. This should be updated if there is a schema change.
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private boolean _saveScheduled = false; private Job saveJob = null;
private transient ISystemProfile _profile; private transient ISystemProfile _profile;
public RSEDOM(ISystemProfile profile) { public RSEDOM(ISystemProfile profile) {
@ -54,33 +56,6 @@ public class RSEDOM extends RSEDOMNode {
} }
} }
/**
* Indicate that this DOM has been saved
*/
public void markUpdated() {
if (_needsSave) {
_needsSave = false;
_saveScheduled = false;
super.markUpdated();
}
}
/**
* @return true if this DOM is scheduled to be saved
*/
public boolean saveScheduled() {
return _saveScheduled;
}
/**
* Indicate that this DOM is scheduled to be saved
*/
public void markSaveScheduled() {
if (!_saveScheduled) {
_saveScheduled = true;
}
}
/** /**
* @return true if this DOM has the DOM changed since last saved or restored. * @return true if this DOM has the DOM changed since last saved or restored.
*/ */
@ -114,4 +89,12 @@ public class RSEDOM extends RSEDOMNode {
System.out.println(indent + "}"); System.out.println(indent + "}");
} }
public Job getSaveJob() {
return saveJob;
}
public void setSaveJob(Job saveJob) {
this.saveJob = saveJob;
}
} }

View file

@ -23,8 +23,8 @@ import java.util.List;
public class RSEDOMNode implements IRSEDOMConstants, Serializable public class RSEDOMNode implements IRSEDOMConstants, Serializable
{ {
/** /*
* * Recommended for serializable objects. This should be updated if there is a schema change.
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected String _type; protected String _type;

View file

@ -616,73 +616,63 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
{ {
return getConnectionPrivateFilterPool(createIfNotFound); return getConnectionPrivateFilterPool(createIfNotFound);
} }
/** /**
* Find or create a new filter pool, unique to this subsystem's connection. This will be * Find or create a new filter pool, unique to this subsystem's connection. This will be
* in the same profile as the connection, and it will follow a naming convention that ties * in the same profile as the connection and it will follow a naming convention that ties
* it to the connection: Filter Pool for xxx, where xxx is the connection name. * it to the connection.
* @param createIfNotFound - true to create the pool if it doesn't exist * @param createIfNotFound - true to create the pool if it doesn't exist
* @return the filter pool that was found or created
*/ */
public ISystemFilterPool getConnectionPrivateFilterPool(boolean createIfNotFound) public ISystemFilterPool getConnectionPrivateFilterPool(boolean createIfNotFound) {
{
ISystemFilterPool pool = null; ISystemFilterPool pool = null;
ISystemFilterPool[] allPoolsInProfile = getSubSystemConfiguration().getFilterPoolManager(getSystemProfile()).getSystemFilterPools(); ISubSystemConfiguration config = getSubSystemConfiguration();
if (allPoolsInProfile!=null) ISystemProfile profile = getSystemProfile();
{ ISystemFilterPoolManager fpm = config.getFilterPoolManager(profile);
for (int idx=0; idx<allPoolsInProfile.length; idx++) ISystemFilterPool[] allPoolsInProfile = fpm.getSystemFilterPools();
{ IHost host = getHost();
String hostName = host.getAliasName();
if (allPoolsInProfile != null) {
for (int idx = 0; idx < allPoolsInProfile.length; idx++) {
String poolOwnerName = allPoolsInProfile[idx].getOwningParentName(); String poolOwnerName = allPoolsInProfile[idx].getOwningParentName();
if ((poolOwnerName!=null) && (poolOwnerName.equals(getHost().getAliasName()))) if ((poolOwnerName != null) && (poolOwnerName.equals(hostName))) {
{
pool = allPoolsInProfile[idx]; pool = allPoolsInProfile[idx];
} }
} }
} }
if ((pool == null) && createIfNotFound) // not found? Create it I guess if ((pool == null) && createIfNotFound) {
{
try { try {
// ----------------------------------------------------- String profileName = profile.getName();
// create a pool named to incorporate connection name pool = fpm.createSystemFilterPool(getConnectionOwnedFilterPoolName(profileName, hostName), true); // true=>is deletable by user
// ----------------------------------------------------- if (pool != null) {
ISystemFilterPoolManager mgr = getSubSystemConfiguration().getFilterPoolManager(getSystemProfile()); pool.setNonRenamable(true);
pool = mgr.createSystemFilterPool(getConnectionOwnedFilterPoolName(getSystemProfileName(), getHostAliasName()), true); // true=>is deletable by user pool.setOwningParentName(hostName);
pool.setNonRenamable(true); // don't allow users to rename this pool pool.commit();
//pool.setNonDeletable(true); hmm, should we or not? ISystemFilterPoolReferenceManager fprm = getSystemFilterPoolReferenceManager();
pool.setOwningParentName(getHostAliasName()); if (fprm.getReferenceToSystemFilterPool(pool) == null) {
// now it is time to reference this pool in this subsystem fprm.addReferenceToSystemFilterPool(pool);
if (getSystemFilterPoolReferenceManager().getReferenceToSystemFilterPool(pool) == null) }
{ }
getSystemFilterPoolReferenceManager().addReferenceToSystemFilterPool(pool); } catch (Exception exc) {
} SystemBasePlugin.logError("Error creating connection-private filter pool for connection: " + hostName, exc);
} catch (Exception exc)
{
SystemBasePlugin.logError("Error creating connection-private filter pool for connection: "+getHostAliasName(),exc);
} }
} }
return pool; return pool;
} }
/**
* Return the name for the connection-owned filter pool.
*/
public String getConnectionOwnedFilterPoolName(String profileName, String connectionName)
{
// Similar to SubSystemConfigurationImpl#getDefaultFilterPoolName(String)...
// System.out.println("ProfileName: " + profileName);
// System.out.println("ConnectionName: " + connectionName);
// String name = SystemResources.RESID_PERCONNECTION_FILTERPOOL; /**
// * Constructs the name of a connection specific filter pool from its parts.
// StringBuffer profileNameBuffer = new StringBuffer(profileName.toLowerCase()); * @param profileName the name of the profile that contains this filter pool.
// profileNameBuffer.setCharAt(0, Character.toUpperCase(profileNameBuffer.charAt(0))); * @param connectionName the name of the connection the "owns" this filter pool.
// * @return the name for the connection-owned filter pool.
// name = SystemMessage.sub(name, "%1", profileNameBuffer.toString()); */
// name = SystemMessage.sub(name, "%2", connectionName); public String getConnectionOwnedFilterPoolName(String profileName, String connectionName) {
/* /*
* DWD - Need to keep this name short and not translatable * Need to keep this name short and not translatable
* since it names a team sharable resource. Not qualified by the profile * since it names a team sharable resource. Not qualified by the profile
* name since that is implicit by being in a profile. * name since that is implicit by being in a profile.
*/ */
// DWD - does not appear to be used. String name = "CN-" + connectionName; // $NON-NLS-1$
String name = "CN-" + connectionName;
return name; return name;
} }