Author: adietish
Date: 2010-12-15 16:03:11 -0500 (Wed, 15 Dec 2010)
New Revision: 27526
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java
Log:
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2010-12-15 20:31:23
UTC (rev 27525)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2010-12-15 21:03:11
UTC (rev 27526)
@@ -113,65 +113,48 @@
<handler
class="org.jboss.tools.deltacloud.ui.commands.EditConnectionHandler"
commandId="org.jboss.tools.deltacloud.ui.editconnection">
- <activeWhen>
- <with
- variable="selection">
- <iterate>
- <instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
<enabledWhen>
<with
variable="selection">
- <count value="+" />
+ <and>
+ <count value="1" />
+ <iterate operator="and">
+ <adapt
+ type="org.jboss.tools.deltacloud.core.DeltaCloud" />
+ </iterate>
+ </and>
</with>
</enabledWhen>
</handler>
<handler
class="org.jboss.tools.deltacloud.ui.commands.DisconnectCloudHandler"
commandId="org.eclipse.ui.edit.delete">
- <activeWhen>
- <with
- variable="selection">
- <iterate>
- <instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
- </instanceof>
- </iterate>
- </with>
- </activeWhen>
- <enabledWhen>
- <with
- variable="selection">
+ <enabledWhen>
+ <with
+ variable="selection">
+ <and>
<count value="+" />
- </with>
- </enabledWhen>
+ <iterate operator="and">
+ <adapt
+ type="org.jboss.tools.deltacloud.core.DeltaCloud" />
+ </iterate>
+ </and>
+ </with>
+ </enabledWhen>
</handler>
<handler
class="org.jboss.tools.deltacloud.ui.commands.RefreshCloudHandler"
commandId="org.eclipse.ui.file.refresh">
- <activeWhen>
- <with
- variable="selection">
- <and>
- <count value="+" />
- <iterate>
- <instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
- </instanceof>
- </iterate>
- </and>
- </with>
- </activeWhen>
- <enabledWhen>
+ <enabledWhen>
<with
variable="selection">
- <count value="+" />
+ <and>
+ <count value="1" />
+ <adapt
+ type="org.jboss.tools.deltacloud.core.DeltaCloud" />
+ </and>
</with>
- </enabledWhen>
+ </enabledWhen>
</handler>
<handler
class="org.jboss.tools.deltacloud.ui.commands.RefreshInstancesHandler"
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java 2010-12-15
20:31:23 UTC (rev 27525)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java 2010-12-15
21:03:11 UTC (rev 27526)
@@ -38,8 +38,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.deltacloud.ui.views.cloud.CloudItem;
-import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Andre Dietisheim
@@ -109,8 +108,15 @@
}
} catch (DeltaCloudException e) {
// TODO internationalize strings
+ String message = "";
+ if (deltaCloud != null) {
+ message = MessageFormat.format("Could not disconnect cloud {0}",
deltaCloud.getName());
+ } else {
+ // TODO: internationalize strings
+ message = "Could not disconnect cloud";
+ }
ErrorUtils.handleError("Error",
- MessageFormat.format("Could not disconnect cloud {0}",
deltaCloud.getName()), e, shell);
+ message, e, shell);
}
}
@@ -132,12 +138,7 @@
DeltaCloud deltaCloud = null;
if (selectedElements.size() > 0) {
Object object = selectedElements.get(0);
- if (object instanceof CloudItem) {
- Object element = ((CloudItem) object).getModel();
- if (element instanceof DeltaCloud) {
- deltaCloud = (DeltaCloud) element;
- }
- }
+ deltaCloud = UIUtils.adapt(object, DeltaCloud.class);
}
return deltaCloud;
}
@@ -145,7 +146,7 @@
private Collection<DeltaCloud> getSelectedClouds(List<?> selectedElements)
{
Set<DeltaCloud> selectedClouds = new HashSet<DeltaCloud>();
for (Object element : selectedElements) {
- DeltaCloud deltaCloud = getDeltaCloud(element);
+ DeltaCloud deltaCloud = UIUtils.adapt(element, DeltaCloud.class);
if (deltaCloud != null) {
selectedClouds.add(deltaCloud);
}
@@ -153,31 +154,6 @@
return selectedClouds;
}
- private DeltaCloud getDeltaCloud(Object item) {
- if (!(item instanceof DeltaCloudViewItem)) {
- return null;
- }
-
- DeltaCloud cloud = getDeltaCloud((DeltaCloudViewItem<?>) item);
-
- if (cloud == null) {
- return null;
- }
- return cloud;
- }
-
- private DeltaCloud getDeltaCloud(DeltaCloudViewItem<?> element) {
- if (element == null) {
- return null;
- }
- Object cloud = element.getModel();
- if (cloud instanceof DeltaCloud) {
- return (DeltaCloud) cloud;
- }
-
- return getDeltaCloud((DeltaCloudViewItem<?>) element.getParent());
- }
-
private void removeDeltaClouds(Object[] deltaClouds) throws DeltaCloudException {
for (Object deltaCloud : deltaClouds) {
removeDeltaCloud((DeltaCloud) deltaCloud);
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java 2010-12-15
20:31:23 UTC (rev 27525)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java 2010-12-15
21:03:11 UTC (rev 27526)
@@ -21,8 +21,6 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.ui.views.cloud.CloudItem;
-import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.EditCloudConnectionWizard;
@@ -35,13 +33,8 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloudViewItem<?> element = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewItem.class);
- while (element != null && !(element instanceof CloudItem)) {
- element = (DeltaCloudViewItem<?>) element.getParent();
- }
- if (element != null) {
- CloudItem cloudElement = (CloudItem) element;
- DeltaCloud cloud = (DeltaCloud) cloudElement.getModel();
+ DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ if (cloud != null) {
IWizard wizard = new EditCloudConnectionWizard(cloud);
WizardDialog dialog = new WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(),
wizard);
dialog.create();
Show replies by date