Author: adietish
Date: 2010-10-11 11:53:22 -0400 (Mon, 11 Oct 2010)
New Revision: 25727
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java
Log:
[JBIDE-7306] moved Remove action to its own inner class, implemented removal of several,
selected clouds
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java 2010-10-11
15:44:01 UTC (rev 25726)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java 2010-10-11
15:53:22 UTC (rev 25727)
@@ -11,6 +11,7 @@
package org.jboss.tools.deltacloud.ui.views;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -217,34 +218,7 @@
}
private void makeActions() {
- removeCloud = new Action() {
- public void run() {
- IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
- CloudViewElement element = (CloudViewElement)selection.getFirstElement();
- while (element != null && !(element instanceof CVCloudElement)) {
- element = (CloudViewElement)element.getParent();
- }
- if (element != null) {
- CVCloudElement cve = (CVCloudElement)element;
- Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
- boolean confirmed = MessageDialog.openConfirm(shell,
- CVMessages.getString(CONFIRM_CLOUD_DELETE_TITLE),
- CVMessages.getFormattedString(CONFIRM_CLOUD_DELETE_MSG, cve.getName()));
- if (confirmed) {
- DeltaCloudManager.getDefault().removeCloud((DeltaCloud)element.getElement());
- CloudViewContentProvider p =
(CloudViewContentProvider)viewer.getContentProvider();
- Object[] elements = p.getElements(getViewSite());
- int index = -1;
- for (int i = 0; i < elements.length; ++i) {
- if (elements[i] == cve)
- index = i;
- }
- if (index >= 0)
- ((TreeViewer)cve.getViewer()).remove(getViewSite(), index);
- }
- }
- }
- };
+ removeCloud = new RemoveAction();
removeCloud.setText(CVMessages.getString(REMOVE_CLOUD));
removeCloud.setToolTipText(CVMessages.getString(REMOVE_CLOUD));
removeCloud.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
@@ -537,4 +511,43 @@
return new CVPropertySheetPage();
return super.getAdapter(adapter);
}
+
+ /**
+ * A JFace action that removes the clouds that are selected in the tree viewer.
+ */
+ private class RemoveAction extends Action {
+
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ for (Iterator<?> iterator = selection.toList().iterator(); iterator.hasNext(); )
{
+ CloudViewElement element = (CloudViewElement) iterator.next();
+ remove(element);
+ }
+ }
+
+ private void remove(CloudViewElement element) {
+ while (element != null && !(element instanceof CVCloudElement)) {
+ element = (CloudViewElement)element.getParent();
+ }
+ if (element != null) {
+ CVCloudElement cve = (CVCloudElement)element;
+ Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ boolean confirmed = MessageDialog.openConfirm(shell,
+ CVMessages.getString(CONFIRM_CLOUD_DELETE_TITLE),
+ CVMessages.getFormattedString(CONFIRM_CLOUD_DELETE_MSG, cve.getName()));
+ if (confirmed) {
+ DeltaCloudManager.getDefault().removeCloud((DeltaCloud)element.getElement());
+ CloudViewContentProvider p = (CloudViewContentProvider)viewer.getContentProvider();
+ Object[] elements = p.getElements(getViewSite());
+ int index = -1;
+ for (int i = 0; i < elements.length; ++i) {
+ if (elements[i] == cve)
+ index = i;
+ }
+ if (index >= 0)
+ ((TreeViewer)cve.getViewer()).remove(getViewSite(), index);
+ }
+ }
+ }
+ }
}
\ No newline at end of file
Show replies by date