mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
[222376][regression] NPE when starting eclipse with rse
https://bugs.eclipse.org/bugs/show_bug.cgi?id=222376
This commit is contained in:
parent
ba4ddf9e43
commit
c978a62c0e
3 changed files with 65 additions and 35 deletions
|
@ -1,5 +1,18 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* David Dykstal (IBM) - [197167] adding initializer support to startup
|
||||
* David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.internal.core;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
@ -19,18 +32,25 @@ public class RSELocalConnectionInitializer implements IRSEModelInitializer {
|
|||
*/
|
||||
public IStatus run(IProgressMonitor monitor) {
|
||||
IStatus status = Status.OK_STATUS;
|
||||
// create a local host object if one is desired and one has not yet been created in this workspace.
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
ISystemProfileManager profileManager = RSECorePlugin.getTheSystemProfileManager();
|
||||
ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile();
|
||||
String localConnectionName = RSECoreMessages.RSELocalConnectionInitializer_localConnectionName;
|
||||
IHost localHost = registry.getHost(profile, localConnectionName);
|
||||
if (localHost == null && RSEPreferencesManager.getCreateLocalConnection()) {
|
||||
// create the connection only if the local system type is enabled
|
||||
IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
|
||||
if (systemType != null && systemType.isEnabled()) {
|
||||
String userName = System.getProperty("user.name"); //$NON-NLS-1$
|
||||
registry.createLocalHost(profile, localConnectionName, userName);
|
||||
// look for the old style mark
|
||||
IPath pluginState = RSECorePlugin.getDefault().getStateLocation();
|
||||
IPath markPath = pluginState.append("localHostCreated.mark"); //$NON-NLS-1$
|
||||
File markFile = new File(markPath.toOSString());
|
||||
boolean markExists = markFile.exists();
|
||||
if (!markExists) {
|
||||
// create a local host object only if an old style mark does not exist
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
ISystemProfileManager profileManager = RSECorePlugin.getTheSystemProfileManager();
|
||||
ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile();
|
||||
String localConnectionName = RSECoreMessages.RSELocalConnectionInitializer_localConnectionName;
|
||||
IHost localHost = registry.getHost(profile, localConnectionName);
|
||||
if (localHost == null && RSEPreferencesManager.getCreateLocalConnection()) {
|
||||
// create the connection only if the local system type is enabled
|
||||
IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
|
||||
if (systemType != null && systemType.isEnabled()) {
|
||||
String userName = System.getProperty("user.name"); //$NON-NLS-1$
|
||||
registry.createLocalHost(profile, localConnectionName, userName);
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Yu-Fen Kuo (MontaVista) - [189271] [team] New Profile's are always active
|
||||
* - [189219] [team] Inactive Profiles become active after workbench restart
|
||||
* David Dykstal (IBM) - [197036] added implementation of run() for commit transaction support
|
||||
* David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.core.model;
|
||||
|
@ -45,6 +46,7 @@ public class SystemProfileManager implements ISystemProfileManager {
|
|||
private static SystemProfileManager singleton = null;
|
||||
private boolean restoring = false;
|
||||
private boolean active = true;
|
||||
private ISystemProfile defaultProfile = null;
|
||||
|
||||
/**
|
||||
* Ordinarily there should be only one instance of a SystemProfileManager
|
||||
|
@ -253,19 +255,17 @@ public class SystemProfileManager implements ISystemProfileManager {
|
|||
String oldName = profile.getName();
|
||||
boolean isActive = isSystemProfileActive(oldName);
|
||||
_profiles.remove(profile);
|
||||
/* FIXME in EMF the profiles are "owned" by the Resource, and only referenced by the profile manager,
|
||||
* so just removing it from the manager is not enough, it must also be removed from its resource.
|
||||
* No longer needed since EMF is not in use.
|
||||
* Resource res = profile.eResource();
|
||||
* if (res != null)
|
||||
* res.getContents().remove(profile);
|
||||
*/
|
||||
if (isActive) RSEPreferencesManager.deleteActiveProfile(oldName);
|
||||
// invalidateCache();
|
||||
if (isActive) {
|
||||
RSEPreferencesManager.deleteActiveProfile(oldName);
|
||||
}
|
||||
if (persist) {
|
||||
IRSEPersistenceProvider provider = profile.getPersistenceProvider();
|
||||
RSECorePlugin.getThePersistenceManager().deleteProfile(provider, oldName);
|
||||
}
|
||||
if (profile == defaultProfile) {
|
||||
defaultProfile = null;
|
||||
ensureDefaultPrivateProfile();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -420,7 +420,7 @@ public class SystemProfileManager implements ISystemProfileManager {
|
|||
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
|
||||
*/
|
||||
public ISystemProfile getDefaultPrivateSystemProfile() {
|
||||
return getSystemProfile(RSEPreferencesManager.getDefaultPrivateSystemProfileName());
|
||||
return defaultProfile;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -454,6 +454,7 @@ public class SystemProfileManager implements ISystemProfileManager {
|
|||
String initProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
|
||||
ISystemProfile profile = internalCreateSystemProfile(initProfileName);
|
||||
profile.setDefaultPrivate(true);
|
||||
defaultProfile = profile;
|
||||
}
|
||||
|
||||
private ISystemProfile internalCreateSystemProfile(String name) {
|
||||
|
@ -463,36 +464,41 @@ public class SystemProfileManager implements ISystemProfileManager {
|
|||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that one profile is always the default profile
|
||||
*/
|
||||
private void ensureDefaultPrivateProfile() {
|
||||
// Ensure that one Profile is the default Profile - defect 48995 NH
|
||||
boolean defaultProfileExists = false;
|
||||
for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
|
||||
ISystemProfile profile = (ISystemProfile) z.next();
|
||||
defaultProfileExists = profile.isDefaultPrivate();
|
||||
if (defaultProfile == null) {
|
||||
for (Iterator z = _profiles.iterator(); z.hasNext() && defaultProfile == null;) {
|
||||
ISystemProfile profile = (ISystemProfile) z.next();
|
||||
if (profile.isDefaultPrivate()) {
|
||||
defaultProfile = profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defaultProfileExists) {
|
||||
if (defaultProfile == null) {
|
||||
// find one with the right name
|
||||
String defaultPrivateProfileName = RSEPreferencesManager.getDefaultPrivateSystemProfileName();
|
||||
for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
|
||||
for (Iterator z = _profiles.iterator(); z.hasNext() && defaultProfile == null;) {
|
||||
ISystemProfile profile = (ISystemProfile) z.next();
|
||||
if (profile.getName().equals(defaultPrivateProfileName)) {
|
||||
profile.setDefaultPrivate(true);
|
||||
defaultProfileExists = true;
|
||||
defaultProfile = profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defaultProfileExists) {
|
||||
if (defaultProfile == null) {
|
||||
// Find the first profile that is not the Team profile and make it the default private profile
|
||||
String defaultTeamProfileName = RSEPreferencesManager.getDefaultTeamProfileName();
|
||||
for (Iterator z = _profiles.iterator(); z.hasNext() && !defaultProfileExists;) {
|
||||
for (Iterator z = _profiles.iterator(); z.hasNext() && defaultProfile == null;) {
|
||||
ISystemProfile profile = (ISystemProfile) z.next();
|
||||
if (!profile.getName().equals(defaultTeamProfileName)) {
|
||||
profile.setDefaultPrivate(true);
|
||||
defaultProfileExists = true;
|
||||
defaultProfile = profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defaultProfileExists) {
|
||||
if (defaultProfile == null) {
|
||||
// If Team is the only profile - then put a message in the log and create the default private profile
|
||||
Logger logger = RSECorePlugin.getDefault().getLogger();
|
||||
logger.logWarning("Only one Profile Team exists - there is no Default Profile"); //$NON-NLS-1$
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
* David McKnight (IBM) - [199424] api to create tree items after query complete
|
||||
* David McKnight (IBM) - [187711] expandTo to handle filters specially
|
||||
* Martin Oberhuber (Wind River) - [218524][api] Remove deprecated ISystemViewInputProvider#getShell()
|
||||
* David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.ui.view;
|
||||
|
@ -3436,7 +3437,10 @@ public class SystemView extends SafeTreeViewer
|
|||
while (i.hasNext()) {
|
||||
Object element = i.next();
|
||||
if (parentElement == null) {
|
||||
parentItem = getParentItem((Item) findItem(element));
|
||||
Item item = (Item) findItem(element);
|
||||
if (item != null) {
|
||||
parentItem = getParentItem(item);
|
||||
}
|
||||
if ((parentItem != null) && (parentItem instanceof Item)) parentElement = ((Item) parentItem).getData();
|
||||
}
|
||||
if (getViewAdapter(element) != null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue