Bug 574743 - Fixed item provider of: Cache, HwConnection
diff --git a/plugins/org.eclipse.app4mc.amalthea.model.edit.extended/src/org/eclipse/app4mc/amalthea/model/edit/hw/extended/ExtendedCacheIP.java b/plugins/org.eclipse.app4mc.amalthea.model.edit.extended/src/org/eclipse/app4mc/amalthea/model/edit/hw/extended/ExtendedCacheIP.java
index 3bc1c5d..d495cc6 100644
--- a/plugins/org.eclipse.app4mc.amalthea.model.edit.extended/src/org/eclipse/app4mc/amalthea/model/edit/hw/extended/ExtendedCacheIP.java
+++ b/plugins/org.eclipse.app4mc.amalthea.model.edit.extended/src/org/eclipse/app4mc/amalthea/model/edit/hw/extended/ExtendedCacheIP.java
@@ -1,6 +1,6 @@
/**
********************************************************************************
- * Copyright (c) 2015-2018 Robert Bosch GmbH and others.
+ * Copyright (c) 2015-2021 Robert Bosch GmbH and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -28,10 +28,17 @@
*/
@Override
public Object getParent(final Object object) {
- final Object hwStructure = super.getParent(object);
- final ExtendedHwStructureIP hwStructureItemProvider = (ExtendedHwStructureIP) this.adapterFactory
- .adapt(hwStructure, ITreeItemContentProvider.class);
- return hwStructureItemProvider != null ? hwStructureItemProvider.getModulesContainerIP((HwStructure) hwStructure) : null;
+ final Object parent = super.getParent(object);
+
+ // if parent is HwStructure then adapt to modules container
+ if (parent instanceof HwStructure) {
+ final Object parentIP = this.adapterFactory.adapt(parent, ITreeItemContentProvider.class);
+ if (parentIP instanceof ExtendedHwStructureIP) {
+ return ((ExtendedHwStructureIP) parentIP).getModulesContainerIP((HwStructure) parent);
+ }
+ }
+
+ return parent;
}
}
diff --git a/plugins/org.eclipse.app4mc.amalthea.model.edit.extended/src/org/eclipse/app4mc/amalthea/model/edit/hw/extended/ExtendedHwConnectionIP.java b/plugins/org.eclipse.app4mc.amalthea.model.edit.extended/src/org/eclipse/app4mc/amalthea/model/edit/hw/extended/ExtendedHwConnectionIP.java
index 6f8978c..3d591ad 100644
--- a/plugins/org.eclipse.app4mc.amalthea.model.edit.extended/src/org/eclipse/app4mc/amalthea/model/edit/hw/extended/ExtendedHwConnectionIP.java
+++ b/plugins/org.eclipse.app4mc.amalthea.model.edit.extended/src/org/eclipse/app4mc/amalthea/model/edit/hw/extended/ExtendedHwConnectionIP.java
@@ -1,6 +1,6 @@
/**
********************************************************************************
- * Copyright (c) 2015-2018 Robert Bosch GmbH and others.
+ * Copyright (c) 2015-2021 Robert Bosch GmbH and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -28,10 +28,17 @@
*/
@Override
public Object getParent(final Object object) {
- final Object hwStructure = super.getParent(object);
- final ExtendedHwStructureIP hwStructureItemProvider = (ExtendedHwStructureIP) this.adapterFactory
- .adapt(hwStructure, ITreeItemContentProvider.class);
- return hwStructureItemProvider != null ? hwStructureItemProvider.getConnectionsContainerIP((HwStructure) hwStructure) : null;
+ final Object parent = super.getParent(object);
+
+ // if parent is HwStructure then adapt to modules container
+ if (parent instanceof HwStructure) {
+ final Object parentIP = this.adapterFactory.adapt(parent, ITreeItemContentProvider.class);
+ if (parentIP instanceof ExtendedHwStructureIP) {
+ return ((ExtendedHwStructureIP) parentIP).getModulesContainerIP((HwStructure) parent);
+ }
+ }
+
+ return parent;
}
}