Bug 385586 - Remove,Delete, Update Action (ContextMenu,
ButtonPad etc.)
Change-Id: I5a70ab23286434debb22f5ce5f15e657dd485107
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/DeleteAction.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/DeleteAction.java
index 67a3788..e25809b 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/DeleteAction.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/DeleteAction.java
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * cbrand - Bug 385586 - Remove,Delete, Update Action (ContextMenu, ButtonPad etc.)
*
* </copyright>
*
@@ -55,7 +56,7 @@
for (int i = 0; i < pe.length; i++) {
IDeleteContext context = new DeleteContext(pe[i]);
IDeleteFeature deleteFeature = getFeatureProvider().getDeleteFeature(context);
- if (deleteFeature == null) {
+ if (deleteFeature == null || !deleteFeature.isAvailable(context)) {
return false;
}
}
@@ -76,7 +77,7 @@
return false;
}
IDeleteFeature deleteFeature = featureProvider.getDeleteFeature(context);
- if (deleteFeature != null && !deleteFeature.canDelete(context)) {
+ if (deleteFeature != null && (!deleteFeature.isAvailable(context) || !deleteFeature.canDelete(context))) {
return false;
}
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/RemoveAction.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/RemoveAction.java
index 506e7b1..1d5bdb9 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/RemoveAction.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/RemoveAction.java
@@ -10,6 +10,7 @@
* Contributors:
* SAP AG - initial API, implementation and documentation
* jpasch - Bug 323025 ActionBarContributor clean up
+ * cbrand - Bug 385586 - Remove,Delete, Update Action (ContextMenu, ButtonPad etc.)
*
* </copyright>
*
@@ -55,7 +56,7 @@
for (int i = 0; i < pe.length; i++) {
IRemoveContext context = new RemoveContext(pe[i]);
IRemoveFeature removeFeature = getFeatureProvider().getRemoveFeature(context);
- if (removeFeature == null) {
+ if (removeFeature == null || !removeFeature.isAvailable(context)) {
return false;
}
}
@@ -76,7 +77,7 @@
IRemoveContext context = new RemoveContext(pe[i]);
IRemoveFeature removeFeature = featureProvider.getRemoveFeature(context);
- if (removeFeature == null)
+ if (removeFeature == null || !removeFeature.isAvailable(context))
return false;
if (!removeFeature.canRemove(context)) {
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/UpdateAction.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/UpdateAction.java
index cb41340..5f2e477 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/UpdateAction.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/action/UpdateAction.java
@@ -10,6 +10,7 @@
* Contributors:
* SAP AG - initial API, implementation and documentation
* jpasch - Bug 323025 ActionBarContributor clean up
+ * cbrand - Bug 385586 - Remove,Delete, Update Action (ContextMenu, ButtonPad etc.)
*
* </copyright>
*
@@ -56,7 +57,7 @@
for (int i = 0; i < pe.length; i++) {
IUpdateContext context = new UpdateContext(pe[i]);
IUpdateFeature updateFeature = getFeatureProvider().getUpdateFeature(context);
- if (updateFeature == null) {
+ if (updateFeature == null || !updateFeature.isAvailable(context)) {
return false;
}
}
@@ -72,7 +73,7 @@
IFeatureProvider featureProvider = getFeatureProvider();
if (featureProvider != null) {
IUpdateFeature updateFeature = featureProvider.getUpdateFeature(context);
- if (updateFeature != null && updateFeature.canExecute(context)) {
+ if (updateFeature != null && updateFeature.isAvailable(context) && updateFeature.canExecute(context)) {
if (pe.length == 1 && pe[0] instanceof Diagram) {
return true;
} else if (updateFeature.updateNeeded(context).toBoolean()) {
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/ContextEntryHelper.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/ContextEntryHelper.java
index 4441015..26e6f57 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/ContextEntryHelper.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/ContextEntryHelper.java
@@ -10,6 +10,7 @@
* Contributors:
* SAP AG - initial API, implementation and documentation
* mgorning - Bug 376572 - Generic context buttons name changeable via getName() method
+ * cbrand - Bug 385586 - Remove,Delete, Update Action (ContextMenu, ButtonPad etc.)
*
* </copyright>
*
@@ -52,7 +53,7 @@
final IUpdateContext updateContext = new UpdateContext(pe);
final IUpdateFeature updateFeature = featureProvider.getUpdateFeature(updateContext);
IContextButtonEntry ret = null;
- if (updateFeature != null) {
+ if (checkFeatureAvalability(updateFeature, updateContext)) {
ret = new ContextButtonEntry(updateFeature, updateContext) {
@Override
public boolean canExecute() {
@@ -78,7 +79,7 @@
IRemoveContext removeContext = new RemoveContext(pe);
IRemoveFeature removeFeature = featureProvider.getRemoveFeature(removeContext);
IContextButtonEntry ret = null;
- if (removeFeature != null) {
+ if (checkFeatureAvalability(removeFeature, removeContext)) {
ret = new ContextButtonEntry(removeFeature, removeContext);
markAsRemoveContextEntry(ret);
}
@@ -99,7 +100,7 @@
IDeleteContext deleteContext = new DeleteContext(pe);
IDeleteFeature deleteFeature = featureProvider.getDeleteFeature(deleteContext);
IContextButtonEntry ret = null;
- if (deleteFeature != null) {
+ if (checkFeatureAvalability(deleteFeature, deleteContext)) {
ret = new ContextButtonEntry(deleteFeature, deleteContext);
markAsDeleteContextEntry(ret);
}
@@ -213,4 +214,9 @@
entry.setText(entryText);
entry.setDescription(entryDescription);
}
+
+ private static boolean checkFeatureAvalability(IFeature feature, IContext context) {
+ return feature != null && feature.isAvailable(context);
+ }
+
}