1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-06 15:55:47 +02:00

bug 153253 - formatting to facilitate debug

This commit is contained in:
David Dykstal 2006-08-17 16:29:41 +00:00
parent 49f98cb4f0
commit 59801af006

View file

@ -45,8 +45,7 @@ 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;
public class RSEPersistenceManager implements IRSEPersistenceManager public class RSEPersistenceManager implements IRSEPersistenceManager {
{
public static final int STATE_NONE = 0; public static final int STATE_NONE = 0;
public static final int STATE_IMPORTING = 1; public static final int STATE_IMPORTING = 1;
public static final int STATE_EXPORTING = 2; public static final int STATE_EXPORTING = 2;
@ -58,14 +57,12 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
private RSEDOMExporter _exporter; private RSEDOMExporter _exporter;
private RSEDOMImporter _importer; private RSEDOMImporter _importer;
public RSEPersistenceManager() public RSEPersistenceManager() {
{
_exporter = RSEDOMExporter.getInstance(); _exporter = RSEDOMExporter.getInstance();
_importer = RSEDOMImporter.getInstance(); _importer = RSEDOMImporter.getInstance();
} }
public void registerRSEPersistenceProvider(String id, IRSEPersistenceProvider provider) public void registerRSEPersistenceProvider(String id, IRSEPersistenceProvider provider) {
{
loadedProviders.put(id, provider); loadedProviders.put(id, provider);
} }
@ -112,24 +109,19 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
* @return the default IRSEPersistenceProvider for this installation. * @return the default IRSEPersistenceProvider for this installation.
* TODO: need to determine what this is. Having more than one is problematic. * TODO: need to determine what this is. Having more than one is problematic.
*/ */
public IRSEPersistenceProvider getRSEPersistenceProvider() public IRSEPersistenceProvider getRSEPersistenceProvider() {
{
IRSEPersistenceProvider provider = getRSEPersistenceProvider("org.eclipse.rse.persistence.PropertyFileProvider"); IRSEPersistenceProvider provider = getRSEPersistenceProvider("org.eclipse.rse.persistence.PropertyFileProvider");
return provider; return provider;
} }
public boolean restore(ISystemProfileManager profileManager) {
public boolean restore(ISystemProfileManager profileManager)
{
return load(profileManager); return load(profileManager);
} }
/** /**
* Restore a profile of a given name from disk... * Restore a profile of a given name from disk...
*/ */
protected ISystemProfile restoreProfile(ISystemProfileManager mgr, String name) protected ISystemProfile restoreProfile(ISystemProfileManager mgr, String name) throws Exception {
throws Exception
{
/* /*
* FIXME String fileName = mgr.getRootSaveFileName(name); java.util.List * FIXME String fileName = mgr.getRootSaveFileName(name); java.util.List
* ext = null;//FIXME * ext = null;//FIXME
@ -144,22 +136,15 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
/** /**
* Save all profiles to disk * Save all profiles to disk
*/ */
public boolean commit(ISystemProfileManager profileManager) public boolean commit(ISystemProfileManager profileManager) {
{
ISystemProfile[] profiles = profileManager.getSystemProfiles(); ISystemProfile[] profiles = profileManager.getSystemProfiles();
for (int idx = 0; idx < profiles.length; idx++) for (int idx = 0; idx < profiles.length; idx++) {
{ try {
try
{
commit(profiles[idx]); commit(profiles[idx]);
} } catch (Exception exc) {
catch (Exception exc)
{
exc.printStackTrace(); exc.printStackTrace();
System.out.println("Error saving profile " + profiles[idx] System.out.println("Error saving profile " + profiles[idx] + ": " + exc.getClass().getName() + " " + exc.getMessage());
+ ": " + exc.getClass().getName() + " "
+ exc.getMessage());
return false; return false;
} }
} }
@ -167,19 +152,14 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
return true; return true;
} }
public boolean restore(ISystemHostPool connectionPool) {
public boolean restore(ISystemHostPool connectionPool)
{
return false; return false;
} }
/** /**
* Restore a connection of a given name from disk... * Restore a connection of a given name from disk...
*/ */
protected IHost restoreHost(ISystemHostPool hostPool, String connectionName) protected IHost restoreHost(ISystemHostPool hostPool, String connectionName) throws Exception {
throws Exception
{
/* /*
* FIXME //System.out.println("in SystemConnectionPoolImpl#restore for * FIXME //System.out.println("in SystemConnectionPoolImpl#restore for
* connection " + connectionName); String fileName = * connection " + connectionName); String fileName =
@ -200,10 +180,8 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
return null; return null;
} }
public boolean commit(ISystemHostPool connectionPool) public boolean commit(ISystemHostPool connectionPool) {
{ if (connectionPool.isDirty()) {
if (connectionPool.isDirty())
{
commit(connectionPool.getSystemProfile()); commit(connectionPool.getSystemProfile());
connectionPool.setDirty(false); connectionPool.setDirty(false);
} }
@ -221,36 +199,29 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
return false; // all persistence should be at profile level return false; // all persistence should be at profile level
} }
public boolean commit(ISystemFilterPoolManager filterPoolManager) public boolean commit(ISystemFilterPoolManager filterPoolManager) {
{ if (filterPoolManager.isDirty()) {
if (filterPoolManager.isDirty())
{
commit(filterPoolManager.getSystemProfile()); commit(filterPoolManager.getSystemProfile());
filterPoolManager.setDirty(false); filterPoolManager.setDirty(false);
} }
return false; return false;
} }
public boolean commit(ISystemFilterPool filterPool) public boolean commit(ISystemFilterPool filterPool) {
{ if (filterPool.isDirty()) {
if (filterPool.isDirty())
{
commit(filterPool.getSystemFilterPoolManager().getSystemProfile()); commit(filterPool.getSystemFilterPoolManager().getSystemProfile());
filterPool.setDirty(false); filterPool.setDirty(false);
} }
return false; return false;
} }
public boolean restore(ISystemFilterPool filterPool) public boolean restore(ISystemFilterPool filterPool) {
{
//System.out.println("restore filterpool"); //System.out.println("restore filterpool");
// DWD function Is this method really needed? // DWD function Is this method really needed?
return false; return false;
} }
public boolean commit(ISystemFilter filter) {
public boolean commit(ISystemFilter filter)
{
// System.out.println("commit filter"); // System.out.println("commit filter");
// DWD function Is this method really needed? // DWD function Is this method really needed?
/* /*
@ -269,28 +240,22 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
return false; return false;
} }
public ISystemFilterPool restoreFilterPool(String name) public ISystemFilterPool restoreFilterPool(String name) {
{
//System.out.println("restore filter pool "+name); //System.out.println("restore filter pool "+name);
// DWD function is this method really needed? // DWD function is this method really needed?
return null; return null;
} }
public boolean commit(ISubSystem subSystem) public boolean commit(ISubSystem subSystem) {
{
if (subSystem.isDirty()) if (subSystem.isDirty()) {
{
// System.out.println("updated " + subSystem.getName()); // System.out.println("updated " + subSystem.getName());
try try {
{
// commit everything for now // commit everything for now
ISystemProfileManager mgr = RSEUIPlugin.getTheSystemRegistry().getSystemProfileManager(); ISystemProfileManager mgr = RSEUIPlugin.getTheSystemRegistry().getSystemProfileManager();
commit(mgr); commit(mgr);
subSystem.setDirty(false); subSystem.setDirty(false);
} } catch (Exception e) {
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
return true; return true;
@ -306,7 +271,6 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
return false; return false;
} }
/** /**
* Restore the filter pools from disk. * Restore the filter pools from disk.
* @param logger The logging object to log errors to * @param logger The logging object to log errors to
@ -317,8 +281,7 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
* @return the restored manager, or null if it does not exist. If anything else went * @return the restored manager, or null if it does not exist. If anything else went
* 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
@ -329,10 +292,8 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
/** /**
* Attempt to save single profile to disk. * Attempt to save single profile to disk.
*/ */
public boolean commit(ISystemProfile profile) public boolean commit(ISystemProfile profile) {
{ if (profile != null) {
if (profile != null)
{
return save(profile, false); return save(profile, false);
} }
return false; return false;
@ -343,42 +304,30 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
* @param profileManager * @param profileManager
* @return true if the profiles are loaded * @return true if the profiles are loaded
*/ */
public boolean load(ISystemProfileManager profileManager) public boolean load(ISystemProfileManager profileManager) {
{
boolean successful = true; boolean successful = true;
if (isExporting() || isImporting()) if (isExporting() || isImporting()) {
{
successful = false; successful = false;
} } else {
else
{
_currentState = STATE_IMPORTING; _currentState = STATE_IMPORTING;
IProject project = SystemResourceManager.getRemoteSystemsProject(); IProject project = SystemResourceManager.getRemoteSystemsProject();
try try {
{ if (!project.isSynchronized(IResource.DEPTH_ONE)) project.refreshLocal(IResource.DEPTH_ONE, null);
if (!project.isSynchronized(IResource.DEPTH_ONE))
project.refreshLocal(IResource.DEPTH_ONE, null);
IRSEPersistenceProvider persistenceProvider = getRSEPersistenceProvider(); IRSEPersistenceProvider persistenceProvider = getRSEPersistenceProvider();
String profileNames[] = persistenceProvider.getSavedProfileNames(); String profileNames[] = persistenceProvider.getSavedProfileNames();
for (int i = 0; i < profileNames.length; i++) { for (int i = 0; i < profileNames.length; i++) {
String profileName = profileNames[i]; String profileName = profileNames[i];
RSEDOM dom = importRSEDOM(profileName); RSEDOM dom = importRSEDOM(profileName);
if (dom != null) if (dom != null) {
{
ISystemProfile restoredProfile = _importer.restoreProfile(profileManager, dom); ISystemProfile restoredProfile = _importer.restoreProfile(profileManager, dom);
if (restoredProfile == null) if (restoredProfile == null) {
{ successful = false;
}
} else {
successful = false; successful = false;
} }
} }
else } catch (Exception e) {
{
successful = false;
}
}
}
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
_currentState = STATE_NONE; _currentState = STATE_NONE;
@ -389,23 +338,18 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
/** /**
* Saves the RSE artifacts from this session * Saves the RSE artifacts from this session
*/ */
public boolean save(ISystemProfile profile, boolean force) public boolean save(ISystemProfile profile, boolean force) {
{
boolean result = false; boolean result = false;
if (!isImporting() && !isExporting()) if (!isImporting() && !isExporting()) {
{
RSEDOM dom = exportRSEDOM(profile, force); RSEDOM dom = exportRSEDOM(profile, force);
if (dom.needsSave() && !dom.saveScheduled()) if (dom.needsSave() && !dom.saveScheduled()) {
{
// IProject project = SystemResourceManager.getRemoteSystemsProject(); // IProject project = SystemResourceManager.getRemoteSystemsProject();
SaveRSEDOMJob job = new SaveRSEDOMJob(this, dom, getRSEPersistenceProvider()); SaveRSEDOMJob job = new SaveRSEDOMJob(this, dom, getRSEPersistenceProvider());
// job.setRule(project); // job.setRule(project);
job.schedule(0); // TODO dwd control job delay here job.schedule(0); // TODO dwd control job delay here
dom.markSaveScheduled(); dom.markSaveScheduled();
} } else {
else
{
//System.out.println("no save required"); //System.out.println("no save required");
result = true; result = true;
} }
@ -413,30 +357,25 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
return result; return result;
} }
public boolean isExporting() public boolean isExporting() {
{
return _currentState == STATE_EXPORTING; return _currentState == STATE_EXPORTING;
} }
public boolean isImporting() public boolean isImporting() {
{
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) public RSEDOM exportRSEDOM(ISystemProfile profile, boolean force) {
{
_currentState = STATE_EXPORTING; _currentState = STATE_EXPORTING;
RSEDOM dom = _exporter.createRSEDOM(profile, force); RSEDOM dom = _exporter.createRSEDOM(profile, force);
return dom; return dom;
} }
public RSEDOM importRSEDOM(String domName) public RSEDOM importRSEDOM(String domName) {
{
RSEDOM dom = null; RSEDOM dom = null;
IRSEPersistenceProvider provider = getRSEPersistenceProvider(); IRSEPersistenceProvider provider = getRSEPersistenceProvider();
if (provider != null) { if (provider != null) {
@ -448,12 +387,8 @@ public class RSEPersistenceManager implements IRSEPersistenceManager
return dom; return dom;
} }
public boolean commit(IHost host) {
public boolean commit(IHost host)
{
return commit(host.getSystemProfile()); return commit(host.getSystemProfile());
} }
} }