Author: adietish
Date: 2011-03-31 15:44:50 -0400 (Thu, 31 Mar 2011)
New Revision: 30190
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java
Log:
[JBIDE-8659] enabled "Launch instance" in instance view even if no instance is
selected
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-03-31
19:42:37 UTC (rev 30189)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-03-31
19:44:50 UTC (rev 30190)
@@ -1,6 +1,9 @@
2011-03-31 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+ * src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java:
* plugin.xml:
+ [JBIDE-8659] enabled "Launch instance" in instance view even if no instance is
selected
+ * plugin.xml:
[JBIDE-8655] added "Launch instance" to context menu and toolbar in instance
view
2011-03-29 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2011-03-31
19:42:37 UTC (rev 30189)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2011-03-31
19:44:50 UTC (rev 30190)
@@ -250,19 +250,25 @@
class="org.jboss.tools.deltacloud.ui.commands.CreateInstanceFromAnyImageHandler"
commandId="org.jboss.tools.deltacloud.ui.createinstanceFromAnyImage">
<enabledWhen>
- <with
- variable="selection">
- <and>
- <count value="+" />
- <iterate operator="and">
- <adapt
- type="org.jboss.tools.deltacloud.core.DeltaCloud">
- <test property="org.jboss.tools.deltacloud.ui.commands.isValid"
- value="true"/>
- </adapt>
- </iterate>
- </and>
- </with>
+ <or>
+ <with
+ variable="selection">
+ <and>
+ <count value="+" />
+ <iterate operator="and">
+ <adapt
+ type="org.jboss.tools.deltacloud.core.DeltaCloud">
+ <test property="org.jboss.tools.deltacloud.ui.commands.isValid"
+ value="true"/>
+ </adapt>
+ </iterate>
+ </and>
+ </with>
+ <with
+ variable="activePart">
+ <instanceof
value="org.jboss.tools.deltacloud.ui.views.cloudelements.InstanceView" />
+ </with>
+ </or>
</enabledWhen>
</handler>
</extension>
Modified:
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java
===================================================================
---
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java 2011-03-31
19:42:37 UTC (rev 30189)
+++
branches/jbosstools-3.2.x/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java 2011-03-31
19:44:50 UTC (rev 30190)
@@ -33,16 +33,27 @@
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloud cloud = null;
+ cloud = getSelectedCloud(event, selection, cloud);
+ if (cloud != null) {
IWizard wizard = new NewInstanceWizard(cloud);
- WizardDialog dialog = new WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(),
- wizard);
+ WizardDialog dialog =
+ new WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(), wizard);
dialog.create();
dialog.open();
}
-
return Status.OK_STATUS;
}
+ private DeltaCloud getSelectedCloud(ExecutionEvent event, ISelection selection,
DeltaCloud cloud) {
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ // try selection
+ cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ }
+ if (cloud == null) {
+ // try active part
+ cloud = UIUtils.adapt(HandlerUtil.getActivePart(event), DeltaCloud.class);
+ }
+ return cloud;
+ }
}
Show replies by date