1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-16 13:35:22 +02:00

[225911]Exception received after deleting a profile containing a connection

https://bugs.eclipse.org/bugs/show_bug.cgi?id=225911
This commit is contained in:
David Dykstal 2008-04-24 20:38:13 +00:00
parent f014e30211
commit f3aa90026a
3 changed files with 95 additions and 84 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. * Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -21,6 +21,7 @@
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty() * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* Kevin Doyle (IBM) - [203365] Profile should not be saved as a result of file transfer * Kevin Doyle (IBM) - [203365] Profile should not be saved as a result of file transfer
* David Dykstal (IBM) - [225911] Exception received after deleting a profile containing a connection
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.core.model; package org.eclipse.rse.core.model;
@ -181,14 +182,16 @@ public class Host extends RSEModelObject implements IHost {
* @see org.eclipse.rse.core.model.IHost#getSystemProfileName() * @see org.eclipse.rse.core.model.IHost#getSystemProfileName()
*/ */
public String getSystemProfileName() { public String getSystemProfileName() {
if (pool == null) String result = null;
return null; if (_profile != null) {
else { result = _profile.getName();
} else if (pool != null) {
ISystemProfile profile = pool.getSystemProfile(); ISystemProfile profile = pool.getSystemProfile();
if (profile != null) if (profile != null) {
return profile.getName(); result = profile.getName();
else return null; }
} }
return result;
} }
/** /**

View file

@ -1,70 +1,73 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2007, 2008 IBM Corporation and others. All rights reserved. * Copyright (c) 2007, 2008 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* Kevin Doyle (IBM) - [195537] Move ElementComparer From SystemView to Separate File * Kevin Doyle (IBM) - [195537] Move ElementComparer From SystemView to Separate File
* Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
********************************************************************************/ * David Dykstal (IBM) - [225911] Exception received after deleting a profile containing a connection
********************************************************************************/
package org.eclipse.rse.internal.ui.view; package org.eclipse.rse.internal.ui.view;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.IElementComparer; import org.eclipse.jface.viewers.IElementComparer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.core.model.SystemRegistry; import org.eclipse.rse.internal.core.model.SystemRegistry;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter; import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
public class ElementComparer implements IElementComparer /**
{ * An implememtation of an element comparer for the system view.
*/
public boolean equals(Object a, Object b) public class ElementComparer implements IElementComparer {
{
public boolean equals(Object a, Object b) {
boolean result = false;
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
if (registry instanceof SystemRegistry) if (registry instanceof SystemRegistry) {
{ result = ((SystemRegistry) registry).isSameObjectByAbsoluteName(a, null, b, null);
return ((SystemRegistry) registry).isSameObjectByAbsoluteName(a, null, b, null);
} }
return false; return result;
} }
public int hashCode(Object element) public int hashCode(Object element) {
{ /*
ISystemViewElementAdapter ident=null; * Hashcodes should be invariant across the lifetime of the object.
if(element instanceof IAdaptable) { * Since one adapter is typically used for many elements in RSE,
ident = (ISystemViewElementAdapter) * performance would be better if the original Element's hashCode
((IAdaptable)element).getAdapter(ISystemViewElementAdapter.class); * were used rather than the adapter's hashCode. The problem with
if(ident!=null) { * this is, that if the remote object changes, it cannot be
String absName = ident.getAbsoluteName(element); * identified any more.
if(absName!=null) return absName.hashCode(); * Note that currently the hashCode of the object can change
//Since one adapter is typically used for many elements in RSE, * over time if properties are modified (this is probably a bug).
//performance would be better if the original Element's hashCode * Therefore, if there is no absolute name, play it safe and return the adapter's hashCode which won't ever change.
//were used rather than the adapter's hashCode. The problem with */
//this is, that if the remote object changes, it cannot be int result = 0;
//identified any more. ISystemViewElementAdapter ident = null;
//Note that even if the SAME object is modified during refresh if (element instanceof IAdaptable) {
//(so object a==b), the hashCode of the object can change ident = (ISystemViewElementAdapter) ((IAdaptable) element).getAdapter(ISystemViewElementAdapter.class);
//over time if properties are modified. Therefore, play it Assert.isNotNull(ident, NLS.bind("no adapter found for element {0}", element)); //$NON-NLS-1$
//safe and return the adapter's hashCode which won't ever change. String absName = ident.getAbsoluteName(element);
return ident.hashCode(); if (absName != null) {
} result = absName.hashCode();
} } else {
if (element != null) { // adding check because I hit a null exception here once at startup result = ident.hashCode();
return element.hashCode(); }
} else { } else if (element != null) {
//System.out.println("null element"); result = element.hashCode();
return 0; }
} return result;
} }
} }

View file

@ -51,6 +51,7 @@
* David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile * David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile
* David McKnight (IBM) - [224380] system view should only fire property sheet update event when in focus * David McKnight (IBM) - [224380] system view should only fire property sheet update event when in focus
* David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
* David Dykstal (IBM) - [225911] Exception received after deleting a profile containing a connection
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.ui.view; package org.eclipse.rse.internal.ui.view;
@ -1951,40 +1952,49 @@ public class SystemView extends SafeTreeViewer
break; break;
case ISystemResourceChangeEvents.EVENT_DELETE_MANY: case ISystemResourceChangeEvents.EVENT_DELETE_MANY:
if (debug) logDebugMsg("SV event: EVENT_DELETE_MANY "); //$NON-NLS-1$ if (debug) {
logDebugMsg("SV event: EVENT_DELETE_MANY "); //$NON-NLS-1$
}
multiSource = _event.getMultiSource(); multiSource = _event.getMultiSource();
// are we a secondary perspective, and our input or parent of our input was deleted? // are we a secondary perspective, and our input or parent of our input was deleted?
if (affectsInput(multiSource)) { if (affectsInput(multiSource)) {
close(); close();
return Status.OK_STATUS; return Status.OK_STATUS;
} }
if (parent != null) if (parent != null) {
parentItem = findItem(parent); parentItem = findItem(parent);
else { } else {
// find first parentItem for source // find first parentItem for source
if (multiSource != null && multiSource.length > 0){ if (multiSource != null && multiSource.length > 0) {
Widget sitem = findItem(multiSource[0]); Widget sitem = findItem(multiSource[0]);
if (sitem instanceof TreeItem) if (sitem instanceof TreeItem) {
{
parentItem = ((TreeItem)sitem).getParentItem(); parentItem = ((TreeItem)sitem).getParentItem();
if (parentItem == null) if (parentItem == null) {
{
parentItem = ((TreeItem)sitem).getParent(); parentItem = ((TreeItem)sitem).getParent();
} }
} }
} }
} }
if (parentItem == null) {
if (parentItem == null) return Status.OK_STATUS; return Status.OK_STATUS;
if ((parentItem instanceof Item) && !getExpanded((Item) parentItem)) }
if ((parentItem instanceof Item) && !getExpanded((Item) parentItem)) {
refresh(parent); // flush memory refresh(parent); // flush memory
else if (parentItem instanceof Tree) { } else if (parentItem instanceof Tree) {
if (_originatingViewer != null) _originatingViewer.remove(multiSource); if (_originatingViewer != null) {
_originatingViewer.remove(multiSource);
}
} else { } else {
wasSelected = isSelectedOrChildSelected(multiSource); wasSelected = isSelectedOrChildSelected(multiSource);
if (wasSelected) clearSelection(); if (wasSelected) {
if (_originatingViewer != null) _originatingViewer.remove(multiSource); clearSelection();
if (wasSelected) setSelection(parent != null ? new StructuredSelection(parent) : null, true); }
if (_originatingViewer != null) {
_originatingViewer.remove(multiSource);
}
if (wasSelected) {
setSelection(parent != null ? new StructuredSelection(parent) : null, true);
}
} }
break; break;
/* Now done below in systemRemoteResourceChanged /* Now done below in systemRemoteResourceChanged
@ -5704,12 +5714,7 @@ public class SystemView extends SafeTreeViewer
ISystemViewElementAdapter adapter = getViewAdapter(parentObject); ISystemViewElementAdapter adapter = getViewAdapter(parentObject);
ISystemViewElementAdapter targetAdapter = getViewAdapter(remoteObject); ISystemViewElementAdapter targetAdapter = getViewAdapter(remoteObject);
Assert.isNotNull(adapter, "adapter is null for " + parentObject); //$NON-NLS-1$
if (adapter == null)
{
System.out.println("adapter is null for "+parentObject);
return;
}
ISubSystem ss = adapter.getSubSystem(parentObject); ISubSystem ss = adapter.getSubSystem(parentObject);
String parentName = adapter.getAbsoluteName(parentObject); String parentName = adapter.getAbsoluteName(parentObject);
String remoteObjectName = targetAdapter.getAbsoluteName(remoteObject); String remoteObjectName = targetAdapter.getAbsoluteName(remoteObject);