Author: jjohnstn
Date: 2010-07-27 16:06:22 -0400 (Tue, 27 Jul 2010)
New Revision: 23752
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewContentProvider.java
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/InstancePropertySource.java
Log:
2010-07-27 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/views/CloudViewContentProvider.java (createElements):
Add
viewer argument and use this when creating a CVCloudElement.
(inputChanged): Pass the viewer to createElements.
* src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java: Remove unused import.
* src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java (getViewer): New method.
(CVCloudElement): Pass in the viewer for possible property refreshing.
* src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java (getPropertySource):
* src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java (handleSelection): New
method.
(createPartControl): Add call to hookSelection method.
(.selectionChanged): New method to allow us to do proper context menus.
(hookSelection): New method.
* src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
(InstancePropertySource):
Pass in the CVInstanceElement this belongs to.
(getPropertyValue):
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-07-27 19:50:41
UTC (rev 23751)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-07-27 20:06:22
UTC (rev 23752)
@@ -1,3 +1,20 @@
+2010-07-27 Jeff Johnston <jjohnstn(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/ui/views/CloudViewContentProvider.java
(createElements): Add
+ viewer argument and use this when creating a CVCloudElement.
+ (inputChanged): Pass the viewer to createElements.
+ * src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java: Remove unused import.
+ * src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java (getViewer): New method.
+ (CVCloudElement): Pass in the viewer for possible property refreshing.
+ * src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java (getPropertySource):
+ * src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java (handleSelection): New
method.
+ (createPartControl): Add call to hookSelection method.
+ (.selectionChanged): New method to allow us to do proper context menus.
+ (hookSelection): New method.
+ * src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
(InstancePropertySource):
+ Pass in the CVInstanceElement this belongs to.
+ (getPropertyValue):
+
2010-07-26 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add support for
hardware
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java 2010-07-27
19:50:41 UTC (rev 23751)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCategoryElement.java 2010-07-27
20:06:22 UTC (rev 23752)
@@ -1,7 +1,5 @@
package org.jboss.tools.deltacloud.ui.views;
-import java.util.ArrayList;
-
import org.eclipse.ui.views.properties.IPropertySource;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java 2010-07-27
19:50:41 UTC (rev 23751)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVCloudElement.java 2010-07-27
20:06:22 UTC (rev 23752)
@@ -1,13 +1,21 @@
package org.jboss.tools.deltacloud.ui.views;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.views.properties.IPropertySource;
public class CVCloudElement extends CloudViewElement {
- public CVCloudElement(Object element, String name) {
+ private Viewer viewer;
+
+ public CVCloudElement(Object element, String name, Viewer viewer) {
super(element, name);
+ this.viewer = viewer;
}
+ public Viewer getViewer() {
+ return viewer;
+ }
+
@Override
public IPropertySource getPropertySource() {
return new CloudPropertySource(getElement());
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java 2010-07-27
19:50:41 UTC (rev 23751)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstanceElement.java 2010-07-27
20:06:22 UTC (rev 23752)
@@ -10,7 +10,7 @@
@Override
public IPropertySource getPropertySource() {
- return new InstancePropertySource(getElement());
+ return new InstancePropertySource(this, getElement());
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewContentProvider.java 2010-07-27
19:50:41 UTC (rev 23751)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewContentProvider.java 2010-07-27
20:06:22 UTC (rev 23752)
@@ -45,13 +45,13 @@
}
- private void createElements() {
+ private void createElements(Viewer viewer) {
ArrayList<CloudViewElement> list = new ArrayList<CloudViewElement>();
DeltaCloudManager m = DeltaCloudManager.getDefault();
DeltaCloud[] clouds = m.getClouds();
for (int i = 0; i < clouds.length; ++i) {
DeltaCloud cloud = clouds[i];
- CVCloudElement e = new CVCloudElement(cloud, cloud.getName());
+ CVCloudElement e = new CVCloudElement(cloud, cloud.getName(), viewer);
CVCategoryElement c1 = new CVCategoryElement(cloud,
CVMessages.getString(INSTANCE_CATEGORY_NAME),
CVCategoryElement.INSTANCES);
CVCategoryElement c2 = new CVCategoryElement(cloud,
CVMessages.getString(IMAGE_CATEGORY_NAME),
@@ -65,7 +65,7 @@
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- createElements();
+ createElements(viewer);
}
}
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-07-27
19:50:41 UTC (rev 23751)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/DeltaCloudView.java 2010-07-27
20:06:22 UTC (rev 23752)
@@ -11,7 +11,9 @@
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -64,9 +66,19 @@
makeActions();
hookContextMenu();
hookDoubleClickAction();
+ hookSelection();
contributeToActionBars();
}
+ private void hookSelection() {
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleSelection();
+ }
+ });
+ }
+
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
@@ -86,6 +98,12 @@
fillLocalToolBar(bars.getToolBarManager());
}
+ private void handleSelection() {
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ CloudViewElement element = (CloudViewElement)selection.getFirstElement();
+ // FIXME: add context menus here based on element type
+ }
+
private void fillLocalPullDown(IMenuManager manager) {
manager.add(action1);
manager.add(new Separator());
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java 2010-07-27
19:50:41 UTC (rev 23751)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstancePropertySource.java 2010-07-27
20:06:22 UTC (rev 23752)
@@ -11,7 +11,7 @@
private static final String PROPERTY_NAME = "deltacloud.views.instance.name";
//$NON-NLS-1$
private static final String PROPERTY_ID = "deltacloud.views.instance.id";
//$NON-NLS-1$
- private static final String PROPERTY_STATE =
"deltacloud.views.instance.state"; //$NON-NLS-1$
+ public static final String PROPERTY_STATE =
"deltacloud.views.instance.state"; //$NON-NLS-1$
private static final String PROPERTY_HOSTNAME =
"deltacloud.views.instance.hostname"; //$NON-NLS-1$
private static final String PROPERTY_PROFILEID =
"deltacloud.views.instance.profileid"; //$NON-NLS-1$
private static final String PROPERTY_REALMID =
"deltacloud.views.instance.realmid"; //$NON-NLS-1$
@@ -26,9 +26,11 @@
private IPropertyDescriptor[] propertyDescriptors;
private DeltaCloudInstance instance;
+ private CVInstanceElement element;
- public InstancePropertySource(Object o) {
+ public InstancePropertySource(CVInstanceElement element, Object o) {
instance = (DeltaCloudInstance)o;
+ this.element = element;
}
@Override
@@ -80,8 +82,9 @@
return instance.getRealmId();
if (id.equals(PROPERTY_IMAGEID))
return instance.getImageId();
- if (id.equals(PROPERTY_STATE))
+ if (id.equals(PROPERTY_STATE)) {
return instance.getState();
+ }
if (id.equals(PROPERTY_HOSTNAME)) {
List<String> hostnames = instance.getHostNames();
if (hostnames.size() >= 1)
Show replies by date