1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 06:55:23 +02:00

Bug 153255 - enabled creation of new profiles as a side effect of this bug

This commit is contained in:
David Dykstal 2006-09-20 17:40:34 +00:00
parent abdf04eeab
commit 7d7e7cdde5
2 changed files with 325 additions and 422 deletions

View file

@ -17,8 +17,6 @@
package org.eclipse.rse.ui.actions; package org.eclipse.rse.ui.actions;
import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.IWizard;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.model.SystemStartHere;
import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
@ -66,18 +64,26 @@ public class SystemNewProfileAction extends SystemBaseWizardAction {
setEnabled(isEnabled()); setEnabled(isEnabled());
} }
/** /* (non-Javadoc)
* We disable this action if it is a new workspace and the user has yet to create * @see org.eclipse.rse.ui.actions.SystemBaseAction#isEnabled()
* their first connection, and hence rename their default profile.
* @return true if the action is enabled
*/ */
public boolean isEnabled() { public boolean isEnabled() {
// defect 43428... return true;
ISystemProfile defaultProfile = SystemStartHere.getSystemProfileManager().getDefaultPrivateSystemProfile(); /*
if (defaultProfile != null) * From the old javadoc:
return false; * We disable this action if it is a new workspace and the user has yet to create
else * their first connection, and hence rename their default profile.
return true; * @return true if the action is enabled
*
* defect 43428 was an early RSE defect whose fix prevented the creation of profiles until the first
* connection was created. However, new default profiles are created when RSE is initially activated
* so there is no need to inhibit profile creation.
*/
// ISystemProfile defaultProfile = SystemStartHere.getSystemProfileManager().getDefaultPrivateSystemProfile();
// if (defaultProfile != null)
// return false;
// else
// return true;
} }
/** /**

View file

@ -15,6 +15,7 @@
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.model; package org.eclipse.rse.internal.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
@ -34,34 +35,31 @@ import org.eclipse.rse.ui.validators.ValidatorProfileName;
* A class that manages a list of SystemProfile objects. * A class that manages a list of SystemProfile objects.
* This should be used as a singleton. * This should be used as a singleton.
*/ */
public class SystemProfileManager implements ISystemProfileManager public class SystemProfileManager implements ISystemProfileManager {
{ private List _profiles = null;
private List _profiles = null; private String[] profileNames = null;
private String[] profileNames = null; private Vector profileNamesVector = null;
private Vector profileNamesVector = null; private static ISystemProfileManager singleton = null;
private static ISystemProfileManager singleton = null;
private static final String PROFILE_FILE_NAME = "profile"; //$NON-NLS-1$ private static final String PROFILE_FILE_NAME = "profile"; //$NON-NLS-1$
/** /**
* Default constructor * Default constructor
*/ */
protected SystemProfileManager() protected SystemProfileManager() {
{
super(); super();
} }
/** /**
* Return (and create if necessary) the singleton instance of this class. * @return (and create if necessary) the singleton instance of this class.
*/ */
public static ISystemProfileManager getSystemProfileManager() public static ISystemProfileManager getSystemProfileManager() {
{ if (singleton == null) {
if (singleton == null)
{
singleton = new SystemProfileManager(); singleton = new SystemProfileManager();
RSEUIPlugin.getThePersistenceManager().restore(singleton); // restores all of RSE RSEUIPlugin.getThePersistenceManager().restore(singleton); // restores all of RSE
} }
return singleton; return singleton;
} }
/** /**
* @return the name of the default private system profile. * @return the name of the default private system profile.
*/ */
@ -78,15 +76,14 @@ public class SystemProfileManager implements ISystemProfileManager
} }
return name; return name;
} }
/** /**
* Clear the default after a team sychronization say * Clear the default after a team sychronization say
*/ */
public static void clearDefault() public static void clearDefault() {
{
singleton = null; singleton = null;
} }
/** /**
* Create a new profile with the given name, and add to the list. * Create a new profile with the given name, and add to the list.
* The name must be unique within the existing list. * The name must be unique within the existing list.
@ -96,541 +93,441 @@ public class SystemProfileManager implements ISystemProfileManager
* @param name What to name this profile * @param name What to name this profile
* @param makeActive true if this profile is to be added to the active profile list. * @param makeActive true if this profile is to be added to the active profile list.
* @return new profile, or null if name not unique. * @return new profile, or null if name not unique.
* @see ISystemProfileManager#createSystemProfile(String, boolean)
*/ */
public ISystemProfile createSystemProfile(String name, boolean makeActive) public ISystemProfile createSystemProfile(String name, boolean makeActive) {
{ // FIXME - used to use MOF
// FIXME
ISystemProfile existingProfile = getSystemProfile(name); ISystemProfile existingProfile = getSystemProfile(name);
if (existingProfile != null) if (existingProfile != null) {
{
deleteSystemProfile(existingProfile); // replace the existing one with a new profile deleteSystemProfile(existingProfile); // replace the existing one with a new profile
} }
ISystemProfile newProfile = internalCreateSystemProfileAndFolder(name); ISystemProfile newProfile = internalCreateSystemProfileAndFolder(name);
if (makeActive) if (makeActive) {
{ SystemPreferencesManager.getPreferencesManager().addActiveProfile(name);
SystemPreferencesManager.getPreferencesManager().addActiveProfile(name); ((SystemProfile) newProfile).setActive(makeActive);
((SystemProfile)newProfile).setActive(makeActive); }
}
RSEUIPlugin.getThePersistenceManager().commit(this); RSEUIPlugin.getThePersistenceManager().commit(this);
return newProfile; return newProfile;
} }
/** /* (non-Javadoc)
* Toggle an existing profile's state between active and inactive * @see org.eclipse.rse.core.model.ISystemProfileManager#makeSystemProfileActive(org.eclipse.rse.core.model.ISystemProfile, boolean)
*/ */
public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive) public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive) {
{ boolean wasActive = isSystemProfileActive(profile.getName());
boolean wasActive = isSystemProfileActive(profile.getName());
if (wasActive && !makeActive) if (wasActive && !makeActive)
SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(profile.getName()); SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(profile.getName());
else if (makeActive && !wasActive) else if (makeActive && !wasActive) SystemPreferencesManager.getPreferencesManager().addActiveProfile(profile.getName());
SystemPreferencesManager.getPreferencesManager().addActiveProfile(profile.getName()); ((SystemProfile) profile).setActive(makeActive);
((SystemProfile)profile).setActive(makeActive);
}
/*
* private version that avoids name collision check
*/
private ISystemProfile internalCreateSystemProfile(String name)
{
ISystemProfile profile = new SystemProfile();
// FIXME initMOF().createSystemProfile();
initialize(profile, name);
profile.setDefaultPrivate(name.equalsIgnoreCase(getDefaultPrivateSystemProfileName()));
//System.out.println("initializing new profile " + name + ", is default private? " + profile.isDefaultPrivate());
return profile;
} }
/* /*
* private version that avoids name collision check * private version that avoids name collision check
*/ */
private ISystemProfile internalCreateSystemProfileAndFolder(String name) private ISystemProfile internalCreateSystemProfile(String name) {
{ ISystemProfile profile = new SystemProfile();
ISystemProfile profile = internalCreateSystemProfile(name); initialize(profile, name);
// SystemResourceManager.getProfileFolder(profile); // creates proj/profileName folder DWD This is where those pesky folders get created profile.setDefaultPrivate(name.equalsIgnoreCase(getDefaultPrivateSystemProfileName()));
return profile; return profile;
} }
/*
* private version that avoids name collision check
*/
private ISystemProfile internalCreateSystemProfileAndFolder(String name) {
ISystemProfile profile = internalCreateSystemProfile(name);
// FIXME This is where the old style folders get created for profiles.
// This is no longer needed but
// SystemResourceManager.getProfileFolder(profile); // creates proj/profileName folder
return profile;
}
/* /*
* private method to initialize state for new profile * private method to initialize state for new profile
*/ */
private void initialize(ISystemProfile profile, String name) private void initialize(ISystemProfile profile, String name) {
{
profile.setName(name); profile.setName(name);
profile.setProfileManager(this); profile.setProfileManager(this);
getProfiles().add(profile); getProfiles().add(profile);
invalidateCache(); invalidateCache();
} }
/** /* (non-Javadoc)
* Get an array of all existing profiles. * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
*/ */
public ISystemProfile[] getSystemProfiles() public ISystemProfile[] getSystemProfiles() {
{
List profiles = getProfiles(); List profiles = getProfiles();
// Ensure that one Profile is the default Profile - defect 48995 NH // Ensure that one Profile is the default Profile - defect 48995 NH
boolean defaultProfileExist = false; boolean defaultProfileExist = false;
for (int idx=0; (!defaultProfileExist) && (idx<profiles.size()); idx++) for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
{ ISystemProfile profile = (ISystemProfile) profiles.get(idx);
ISystemProfile profile = (ISystemProfile)profiles.get(idx); if (profile.isDefaultPrivate()) {
if (profile.isDefaultPrivate()) defaultProfileExist = true;
{ }
defaultProfileExist = true; }
} if (!defaultProfileExist) {
} // Check if the Profile exists with name same as the LocalMachine Name - this is the default we give
if (!defaultProfileExist) // when creating connections.
{ for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
// Check if the Profile exists with name same as the LocalMachine Name - this is the default we give ISystemProfile profile = (ISystemProfile) profiles.get(idx);
// when creating connections. String initProfileName = getDefaultPrivateSystemProfileName();
for (int idx=0; (!defaultProfileExist) && (idx<profiles.size()); idx++) if (profile.getName().equalsIgnoreCase(initProfileName)) {
{ profile.setDefaultPrivate(true);
ISystemProfile profile = (ISystemProfile)profiles.get(idx); defaultProfileExist = true;
String initProfileName = getDefaultPrivateSystemProfileName(); }
if (profile.getName().equalsIgnoreCase(initProfileName)) }
{
profile.setDefaultPrivate(true); // If did not find such a profile then the first profile found besides Team is set to be the default profile
defaultProfileExist = true; if (!defaultProfileExist) {
} for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) {
} ISystemProfile profile = (ISystemProfile) profiles.get(idx);
if (!profile.getName().equalsIgnoreCase(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE)) {
// If did not find such a profile then the first profile found besides Team is set to be the default profile profile.setDefaultPrivate(true);
if (!defaultProfileExist)
{ RSEUIPlugin.getThePersistenceManager().commit(SystemStartHere.getSystemProfileManager());
for (int idx=0; (!defaultProfileExist) && (idx<profiles.size()); idx++) defaultProfileExist = true;
{ }
ISystemProfile profile = (ISystemProfile)profiles.get(idx); }
if (!profile.getName().equalsIgnoreCase(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE)) }
{ if (!defaultProfileExist) {
profile.setDefaultPrivate(true); // If Team is the only profile - then put a message in the log - do not make Team to be default
if (profiles.size() == 1 && ((ISystemProfile) profiles.get(0)).getName().equalsIgnoreCase("Team")) //$NON-NLS-1$
RSEUIPlugin.getThePersistenceManager().commit(SystemStartHere.getSystemProfileManager()); {
defaultProfileExist = true; SystemBasePlugin.logWarning("Only one Profile Team exists - there is no Default Profile");
} } else {
} // sonething must have gone wrong - it should not come here
} SystemBasePlugin.logWarning("Something went wrong and the default profile is not set");
if (!defaultProfileExist) }
{ }
// If Team is the only profile - then put a message in the log - do not make Team to be default }
if (profiles.size() == 1 && ((ISystemProfile)profiles.get(0)).getName().equalsIgnoreCase("Team")) //$NON-NLS-1$ return (ISystemProfile[]) profiles.toArray(new ISystemProfile[profiles.size()]);
{
SystemBasePlugin.logWarning("Only one Profile Team exists - there is no Default Profile");
}
else
{
// sonething must have gone wrong - it should not come here
SystemBasePlugin.logWarning("Something went wrong and the default profile is not set");
}
}
}
return (ISystemProfile[])profiles.toArray(new ISystemProfile[profiles.size()]);
} }
/** /* (non-Javadoc)
* Get an array of all existing profile names. * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNames()
*/ */
public String[] getSystemProfileNames() public String[] getSystemProfileNames() {
{ if (profileNames == null) {
if (profileNames == null) ISystemProfile[] profiles = getSystemProfiles();
{ profileNames = new String[profiles.length];
ISystemProfile[] profiles = getSystemProfiles(); for (int idx = 0; idx < profiles.length; idx++)
profileNames = new String[profiles.length]; profileNames[idx] = profiles[idx].getName();
for (int idx = 0; idx < profiles.length; idx++)
profileNames[idx] = profiles[idx].getName();
} }
return profileNames; return profileNames;
} }
/**
* Get a vector of all existing profile names. /* (non-Javadoc)
*/ * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfileNamesVector()
public Vector getSystemProfileNamesVector() */
{ public Vector getSystemProfileNamesVector() {
if (profileNamesVector == null) if (profileNamesVector == null) {
{ ISystemProfile[] profiles = getSystemProfiles();
ISystemProfile[] profiles = getSystemProfiles(); profileNamesVector = new Vector(profiles.length);
profileNamesVector = new Vector(profiles.length); for (int idx = 0; idx < profiles.length; idx++)
for (int idx = 0; idx < profiles.length; idx++) profileNamesVector.addElement(profiles[idx].getName());
profileNamesVector.addElement(profiles[idx].getName()); }
} return profileNamesVector;
return profileNamesVector;
} }
/** /**
* Something changed so invalide cache of profiles so it will be regenerated * Something changed so invalide cache of profiles so it will be regenerated
*/ */
protected void invalidateCache() protected void invalidateCache() {
{ //DY profiles = null;
//DY profiles = null;
profileNames = null; profileNames = null;
profileNamesVector = null; profileNamesVector = null;
} }
/** /* (non-Javadoc)
* Get a profile given its name. * @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfile(java.lang.String)
*/ */
public ISystemProfile getSystemProfile(String name) public ISystemProfile getSystemProfile(String name) {
{ ISystemProfile[] profiles = getSystemProfiles();
ISystemProfile[] profiles = getSystemProfiles(); if ((profiles == null) || (profiles.length == 0)) return null;
if ((profiles == null) || (profiles.length==0)) ISystemProfile match = null;
return null; for (int idx = 0; (match == null) && (idx < profiles.length); idx++)
ISystemProfile match = null; if (profiles[idx].getName().equals(name)) match = profiles[idx];
for (int idx=0; (match==null) && (idx<profiles.length); idx++) return match;
if (profiles[idx].getName().equals(name))
match = profiles[idx];
return match;
} }
/** /* (non-Javadoc)
* Rename the given profile. * @see org.eclipse.rse.core.model.ISystemProfileManager#renameSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
* This will:
* <ul>
* <li>Rename the profile in memory
* <li>Rename the underlying folder
* <li>Update the user preferences if this profile is currently active.
* </ul>
*/ */
public void renameSystemProfile(ISystemProfile profile, String newName) public void renameSystemProfile(ISystemProfile profile, String newName) {
{
boolean isActive = isSystemProfileActive(profile.getName()); boolean isActive = isSystemProfileActive(profile.getName());
String oldName = profile.getName(); String oldName = profile.getName();
profile.setName(newName); profile.setName(newName);
if (isActive) if (isActive) SystemPreferencesManager.getPreferencesManager().renameActiveProfile(oldName, newName);
SystemPreferencesManager.getPreferencesManager().renameActiveProfile(oldName, newName); invalidateCache();
invalidateCache();
// FIXME RSEUIPlugin.getThePersistenceManager().save(this); // FIXME RSEUIPlugin.getThePersistenceManager().save(this);
} }
/** /* (non-Javadoc)
* Delete the given profile * @see org.eclipse.rse.core.model.ISystemProfileManager#deleteSystemProfile(org.eclipse.rse.core.model.ISystemProfile)
* This will:
* <ul>
* <li>Delete the profile in memory
* <li>Delete the underlying folder
* <li>Update the user preferences if this profile is currently active.
* </ul>
*/ */
public void deleteSystemProfile(ISystemProfile profile) public void deleteSystemProfile(ISystemProfile profile) {
{
String oldName = profile.getName(); String oldName = profile.getName();
boolean isActive = isSystemProfileActive(oldName); boolean isActive = isSystemProfileActive(oldName);
getProfiles().remove(profile);
getProfiles().remove(profile); /* FIXME in EMF the profiles are "owned" by the Resource, and only referenced by the profile manager,
/* FIXME * so just removing it from the manager is not enough, it must also be removed from its resource.
// now in EMF, the profiles are "owned" by the Resource, and only referenced by the profile manager, * No longer needed since EMF is not in use.
// so I don't think just removing it from the manager is enough... it must also be removed from its * Resource res = profile.eResource();
// resource. Phil. * if (res != null)
Resource res = profile.eResource(); * res.getContents().remove(profile);
if (res != null) */
res.getContents().remove(profile); if (isActive) SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(oldName);
*/ invalidateCache();
if (isActive) // FIXME RSEUIPlugin.getThePersistenceManager().save(this);
SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(oldName);
invalidateCache();
//FIXME RSEUIPlugin.getThePersistenceManager().save(this);
} }
/** /* (non-Javadoc)
* Clone the given profile to a new one with the given name. * @see org.eclipse.rse.core.model.ISystemProfileManager#cloneSystemProfile(org.eclipse.rse.core.model.ISystemProfile, java.lang.String)
* Pretty useless right now, as there is no data to clone!
*/ */
public ISystemProfile cloneSystemProfile(ISystemProfile profile, String newName) public ISystemProfile cloneSystemProfile(ISystemProfile profile, String newName) {
{
ISystemProfile newProfile = createSystemProfile(newName, false); ISystemProfile newProfile = createSystemProfile(newName, false);
return newProfile; return newProfile;
} }
/** /* (non-Javadoc)
* Return true if the given profile is active. * @see org.eclipse.rse.core.model.ISystemProfileManager#isSystemProfileActive(java.lang.String)
* @see ISystemProfile#isActive()
*/
public boolean isSystemProfileActive(String profileName)
{
String[] activeProfiles = getActiveSystemProfileNames();
boolean match = false;
for (int idx=0; !match && (idx<activeProfiles.length); idx++)
{
if (activeProfiles[idx].equals(profileName))
match = true;
}
return match;
}
// ---------------------------
// RETURN SPECIFIC PROFILES...
// ---------------------------
/**
* Return the profiles currently selected by the user as his "active" profiles
*/ */
public ISystemProfile[] getActiveSystemProfiles() public boolean isSystemProfileActive(String profileName) {
{ String[] activeProfiles = getActiveSystemProfileNames();
boolean match = false;
for (int idx = 0; !match && (idx < activeProfiles.length); idx++) {
if (activeProfiles[idx].equals(profileName)) match = true;
}
return match;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfiles()
*/
public ISystemProfile[] getActiveSystemProfiles() {
String[] profileNames = getActiveSystemProfileNames(); String[] profileNames = getActiveSystemProfileNames();
ISystemProfile[] profiles = new ISystemProfile[profileNames.length]; ISystemProfile[] profiles = new ISystemProfile[profileNames.length];
for (int idx=0; idx<profileNames.length; idx++) for (int idx = 0; idx < profileNames.length; idx++) {
{ profiles[idx] = getOrCreateSystemProfile(profileNames[idx]);
profiles[idx] = getOrCreateSystemProfile(profileNames[idx]); ((SystemProfile) profiles[idx]).setActive(true);
((SystemProfile)profiles[idx]).setActive(true);
} }
return profiles; return profiles;
} }
/**
* Return the profile names currently selected by the user as his "active" profiles /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfileNames()
*/ */
public String[] getActiveSystemProfileNames() public String[] getActiveSystemProfileNames() {
{ String[] activeProfileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames();
String[] activeProfileNames =
SystemPreferencesManager.getPreferencesManager().getActiveProfileNames();
// dy: defect 48355, need to sync this with the actual profile list. If the user // dy: defect 48355, need to sync this with the actual profile list. If the user
// imports old preference settings or does a team sync and a profile is deleted then // imports old preference settings or does a team sync and a profile is deleted then
// it is possible an active profile no longer exists. // it is possible an active profile no longer exists.
//String[] systemProfileNames = getSystemProfileNames(); // String[] systemProfileNames = getSystemProfileNames();
ISystemProfile[] systemProfiles = getSystemProfiles(); ISystemProfile[] systemProfiles = getSystemProfiles();
boolean found; boolean found;
boolean found_team = false; boolean found_team = false;
boolean found_private = false; boolean found_private = false;
boolean changed = false; boolean changed = false;
String defaultProfileName = getDefaultPrivateSystemProfileName(); String defaultProfileName = getDefaultPrivateSystemProfileName();
for (int activeIdx = 0; activeIdx < activeProfileNames.length; activeIdx++) for (int activeIdx = 0; activeIdx < activeProfileNames.length; activeIdx++) {
{
// skip Team and Private profiles // skip Team and Private profiles
String activeProfileName = activeProfileNames[activeIdx]; String activeProfileName = activeProfileNames[activeIdx];
if (activeProfileName.equals(defaultProfileName)) if (activeProfileName.equals(defaultProfileName)) {
{
found_private = true; found_private = true;
} } else if (activeProfileName.equals(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE)) {
else if (activeProfileName.equals(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE))
{
found_team = true; found_team = true;
} } else {
else
{
found = false; found = false;
for (int systemIdx = 0; systemIdx < systemProfiles.length && !found; systemIdx++) for (int systemIdx = 0; systemIdx < systemProfiles.length && !found; systemIdx++) {
{ if (activeProfileNames[activeIdx].equals(systemProfiles[systemIdx].getName())) {
if (activeProfileNames[activeIdx].equals(systemProfiles[systemIdx].getName()))
{
found = true; found = true;
} }
} }
if (!found) if (!found) {
{
// The active profile no longer exists so remove it from the active list // The active profile no longer exists so remove it from the active list
SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(activeProfileNames[activeIdx]); SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(activeProfileNames[activeIdx]);
changed = true; changed = true;
} }
} }
} }
for (int systemIdx = 0; systemIdx < systemProfiles.length && !changed; systemIdx++) for (int systemIdx = 0; systemIdx < systemProfiles.length && !changed; systemIdx++) {
{ boolean matchesBoth = false;
boolean matchesBoth = false; String name = systemProfiles[systemIdx].getName();
String name = systemProfiles[systemIdx].getName();
for (int activeIdx = 0; activeIdx < activeProfileNames.length && !matchesBoth; activeIdx++) {
for (int activeIdx = 0; activeIdx < activeProfileNames.length && !matchesBoth; activeIdx++) String aname = activeProfileNames[activeIdx];
{ if (name.equals(aname)) {
String aname = activeProfileNames[activeIdx]; matchesBoth = true;
if (name.equals(aname)) }
{
matchesBoth = true; }
} if (!matchesBoth && found_private) {
if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate()) {
SystemPreferencesManager.getPreferencesManager().addActiveProfile(name);
SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(RSECorePlugin.getLocalMachineName());
activeProfileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames();
}
} }
if (!matchesBoth && found_private)
{
if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate())
{
SystemPreferencesManager.getPreferencesManager().addActiveProfile(name);
SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(RSECorePlugin.getLocalMachineName());
activeProfileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames();
}
}
} }
// the active profiles list needed to be changed because of an external update, also // the active profiles list needed to be changed because of an external update, also
// check if Default profile needs to be added back to the list // check if Default profile needs to be added back to the list
if (changed || !found_team || !found_private) if (changed || !found_team || !found_private) {
{ if (systemProfiles.length == 0) {
if (systemProfiles.length == 0) // First time user, make sure default is in the active list, the only time it wouldn't
{ // be is if the pref_store.ini was modified (because the user imported old preferences)
// First time user, make sure default is in the active list, the only time it wouldn't if (!found_team) {
// be is if the pref_store.ini was modified (because the user imported old preferences)
if (!found_team)
{
SystemPreferencesManager.getPreferencesManager().addActiveProfile(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE); SystemPreferencesManager.getPreferencesManager().addActiveProfile(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE);
changed = true; changed = true;
} }
if (!found_private) if (!found_private) {
{
SystemPreferencesManager.getPreferencesManager().addActiveProfile(RSECorePlugin.getLocalMachineName()); SystemPreferencesManager.getPreferencesManager().addActiveProfile(RSECorePlugin.getLocalMachineName());
changed = true; changed = true;
} }
} } else {
else ISystemProfile defaultProfile = getDefaultPrivateSystemProfile();
{ if (defaultProfile != null && !found_private) {
ISystemProfile defaultProfile = getDefaultPrivateSystemProfile(); SystemPreferencesManager.getPreferencesManager().addActiveProfile(defaultProfile.getName());
if (defaultProfile != null && !found_private) changed = true;
{ }
SystemPreferencesManager.getPreferencesManager().addActiveProfile(defaultProfile.getName()); }
changed = true;
}
}
if (changed) if (changed) {
{
activeProfileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames(); activeProfileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames();
} }
} }
return activeProfileNames; return activeProfileNames;
} }
/** /**
* Return the profile names currently selected by the user as his "active" profiles * @return the profile names currently selected by the user as "active" profiles
*/ */
public Vector getActiveSystemProfileNamesVector() public Vector getActiveSystemProfileNamesVector() {
{ String[] profileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames();
String[] profileNames =
SystemPreferencesManager.getPreferencesManager().getActiveProfileNames();
Vector v = new Vector(profileNames.length); Vector v = new Vector(profileNames.length);
for (int idx=0; idx<profileNames.length; idx++) for (int idx = 0; idx < profileNames.length; idx++)
v.addElement(profileNames[idx]); v.addElement(profileNames[idx]);
return v; return v;
} }
/**
* Return 0-based position of the given active profile within the list of active profiles. /* (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfilePosition(java.lang.String)
*/ */
public int getActiveSystemProfilePosition(String profileName) public int getActiveSystemProfilePosition(String profileName) {
{
String[] profiles = getActiveSystemProfileNames(); String[] profiles = getActiveSystemProfileNames();
int pos = -1; int pos = -1;
for (int idx=0; (pos<0) && (idx<profiles.length); idx++) for (int idx = 0; (pos < 0) && (idx < profiles.length); idx++) {
{ if (profiles[idx].equals(profileName)) pos = idx;
if (profiles[idx].equals(profileName))
pos = idx;
} }
return pos; return pos;
} }
/** /* (non-Javadoc)
* Return the default private profile created at first touch. * @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
* Will return null if it has been renamed!
*/ */
public ISystemProfile getDefaultPrivateSystemProfile() public ISystemProfile getDefaultPrivateSystemProfile() {
{
return getSystemProfile(getDefaultPrivateSystemProfileName()); return getSystemProfile(getDefaultPrivateSystemProfileName());
} }
/**
* Return the default team profile created at first touch. /* (non-Javadoc)
* Will return null if it has been renamed! * @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultTeamSystemProfile()
*/ */
public ISystemProfile getDefaultTeamSystemProfile() public ISystemProfile getDefaultTeamSystemProfile() {
{
return getSystemProfile(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE); return getSystemProfile(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE);
} }
/** /**
* Instantiate a user profile given its name. * Instantiate a user profile given its name.
* @param userProfileName the name of the profile to find or create
* @return the profile that was found or created.
*/ */
protected ISystemProfile getOrCreateSystemProfile(String userProfileName) protected ISystemProfile getOrCreateSystemProfile(String userProfileName) {
{
ISystemProfile userProfile = getSystemProfile(userProfileName); ISystemProfile userProfile = getSystemProfile(userProfileName);
//System.out.println("in gorcSp for "+userProfileName+". userProfile==null? "+(userProfile==null)); if (userProfile == null) {
if (userProfile == null)
{
userProfile = internalCreateSystemProfileAndFolder(userProfileName); userProfile = internalCreateSystemProfileAndFolder(userProfileName);
} }
return userProfile; return userProfile;
} }
/**
* No longer used.
* @param profileName the name of the profile from which to construct the name
* @return the unqualified save file name with the extension .xmi
*/
public static String getSaveFileName(String profileName) {
return null;
//FIXME SystemMOFHelpers.getSaveFileName(getRootSaveFileName(profileName)); no longer needed.
}
/**
* No longer used.
* @param profile the profile from which to construct the name
* @return the unqualified save file name with the extension .xmi
*/
public static String getSaveFileName(ISystemProfile profile) {
return null;
//FIXME SystemMOFHelpers.getSaveFileName(getRootSaveFileName(profile)); no longer needed.
}
/**
* No longer used.
// ------------------ * @param profile the profile from which to retrieve the root.
// UTILITY METHODS... * @return the root save file name without the extension .xmi
// ------------------ */
protected static String getRootSaveFileName(ISystemProfile profile) {
/** return getRootSaveFileName(profile.getName());
* Return the unqualified save file name with the extension .xmi }
*/
public static String getSaveFileName(String profileName)
{
return null;//FIXME SystemMOFHelpers.getSaveFileName(getRootSaveFileName(profileName));
}
/**
* Return the unqualified save file name with the extension .xmi
*/
public static String getSaveFileName(ISystemProfile profile)
{
return null;//FIXME SystemMOFHelpers.getSaveFileName(getRootSaveFileName(profile));
}
/**
* Return the root save file name without the extension .xmi
*/
protected static String getRootSaveFileName(ISystemProfile profile)
{
return getRootSaveFileName(profile.getName());
}
/**
* Return the root save file name without the extension .xmi
*/
protected static String getRootSaveFileName(String profileName)
{
//String fileName = profileName; // maybe a bad idea to include manager name in it!
String fileName = PROFILE_FILE_NAME;
return fileName;
}
/**
* No longer used.
* @param profileName the name of the profile
* @return the root save file name without the extension .xmi
*/
protected static String getRootSaveFileName(String profileName) {
//String fileName = profileName; // may be a bad idea to include manager name in it!
String fileName = PROFILE_FILE_NAME;
return fileName;
}
/** /**
* Reusable method to return a name validator for renaming a profile. * Reusable method to return a name validator for renaming a profile.
* @param profileName the current profile name on updates. Can be null for new profiles. Used * @param profileName the current profile name on updates. Can be null for new profiles. Used
* to remove from the existing name list the current connection. * to remove from the existing name list the current connection.
* @return the validator
*/ */
public ISystemValidator getProfileNameValidator(String profileName) public ISystemValidator getProfileNameValidator(String profileName) {
{ //Vector v = getActiveSystemProfileNamesVector();
//Vector v = getActiveSystemProfileNamesVector(); Vector v = getSystemProfileNamesVector();
Vector v = getSystemProfileNamesVector(); if (profileName != null) v.removeElement(profileName);
if (profileName != null) ISystemValidator nameValidator = new ValidatorProfileName(v);
v.removeElement(profileName); return nameValidator;
ISystemValidator nameValidator = new ValidatorProfileName(v); }
return nameValidator;
}
/** /**
* Reusable method to return a name validator for renaming a profile. * Reusable method to return a name validator for renaming a profile.
* @param profile the current profile object on updates. Can be null for new profiles. Used * @param profile the current profile object on updates. Can be null for new profiles. Used
* to remove from the existing name list the current connection. * to remove from the existing name list the current connection.
* @return the validator
*/ */
public ISystemValidator getProfileNameValidator(ISystemProfile profile) public ISystemValidator getProfileNameValidator(ISystemProfile profile) {
{
if (profile != null) if (profile != null)
return getProfileNameValidator(profile.getName()); return getProfileNameValidator(profile.getName());
else else
return getProfileNameValidator((String)null); return getProfileNameValidator((String) null);
} }
/** /* (non-Javadoc)
* @generated This field/method will be replaced during code generation * @see org.eclipse.rse.core.model.ISystemProfileManager#getProfiles()
*/ */
public java.util.List getProfiles() public List getProfiles() {
{ if (_profiles == null) {
if (_profiles == null)
{
ISystemProfile profile = new SystemProfile(); ISystemProfile profile = new SystemProfile();
String initProfileName = getDefaultPrivateSystemProfileName(); String initProfileName = getDefaultPrivateSystemProfileName();
profile.setName(initProfileName); profile.setName(initProfileName);