Author: rob.stryker(a)jboss.com
Date: 2011-01-25 19:04:15 -0500 (Tue, 25 Jan 2011)
New Revision: 28606
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudLabelProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudNavigator.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionUtil.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/ClouldSorter1.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/SWTImagesFactory.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstanceDialog.java
Log:
JBIDE-8224 - initial commit for CNF based CloudView
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF 2011-01-26
00:03:09 UTC (rev 28605)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF 2011-01-26
00:04:15 UTC (rev 28606)
@@ -21,7 +21,8 @@
org.eclipse.core.expressions;bundle-version="[3.4.200,4.0.0)",
org.eclipse.equinox.security;bundle-version="[1.0.100,2.0.0)",
org.eclipse.equinox.security.ui;bundle-version="1.0.200",
- org.eclipse.jsch.core;bundle-version="1.1.200"
+ org.eclipse.jsch.core;bundle-version="1.1.200",
+ org.eclipse.ui.navigator;bundle-version="3.5.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.deltacloud.ui,
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2011-01-26 00:03:09
UTC (rev 28605)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2011-01-26 00:04:15
UTC (rev 28606)
@@ -16,7 +16,15 @@
id="org.jboss.tools.deltacloud.ui.views.CloudView">
</view>
<view
+ name="CloudViewerName2"
+ icon="icons/delta.gif"
category="org.jboss.tools.deltacloud.ui"
+
class="org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudNavigator"
+ id="org.jboss.tools.deltacloud.ui.views.CloudView2">
+ </view>
+
+ <view
+ category="org.jboss.tools.deltacloud.ui"
class="org.jboss.tools.deltacloud.ui.views.cloudelements.InstanceView"
icon="icons/delta.gif"
id="org.jboss.tools.deltacloud.ui.views.InstanceView"
@@ -843,5 +851,65 @@
</adapter>
</factory>
</extension>
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ activeByDefault="true"
+
contentProvider="org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudContentProvider"
+ icon="icons/delta.gif"
+ id="org.jboss.tools.deltacloud.ui.cloudContentRoot"
+
labelProvider="org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudLabelProvider"
+ name="DeltaClouds"
+ priority="higher">
+ <triggerPoints>
+ <or>
+ <instanceof
+ value="java.lang.Object">
+ </instanceof>
+ </or>
+ </triggerPoints>
+ <possibleChildren>
+ <or>
+ <instanceof
+ value="java.lang.Object">
+ </instanceof>
+ </or></possibleChildren>
+ </navigatorContent>
+ <actionProvider
+
class="org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudViewActionProvider"
+
id="org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudViewActionProvider"
+ priority="higher">
+ <enablement>
+ <or>
+ <instanceof
+ value="java.lang.Object">
+ </instanceof>
+ </or>
+ </enablement>
+ </actionProvider>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <viewer
+ viewerId="org.jboss.tools.deltacloud.ui.views.CloudView2">
+ </viewer>
+ <viewerContentBinding
+ viewerId="org.jboss.tools.deltacloud.ui.views.CloudView2">
+ <includes>
+ <contentExtension
+ isRoot="true"
+ pattern="org.jboss.tools.deltacloud.ui.cloudContentRoot">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ <viewerActionBinding
+ viewerId="org.jboss.tools.deltacloud.ui.views.CloudView2">
+ <includes>
+ <actionExtension
+
pattern="org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudViewActionProvider">
+ </actionExtension>
+ </includes>
+ </viewerActionBinding>
+ </extension>
</plugin>
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/SWTImagesFactory.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/SWTImagesFactory.java 2011-01-26
00:03:09 UTC (rev 28605)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/SWTImagesFactory.java 2011-01-26
00:04:15 UTC (rev 28606)
@@ -35,20 +35,25 @@
private static final String NAME_PREFIX= Activator.PLUGIN_ID + '.';
private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
public static final String IMG_CLOUD= NAME_PREFIX + "cloud.gif";
//$NON-NLS-1$
- public static final String IMG_FOLDER= NAME_PREFIX + "folder.gif";
//$NON-NLS-1$
- public static final String IMG_INSTANCE= NAME_PREFIX + "instance.gif";
//$NON-NLS-1$
- public static final String IMG_IMAGE= NAME_PREFIX + "image.gif";
//$NON-NLS-1$
public static final String IMG_COLLAPSE_ALL= NAME_PREFIX + "collapseall.gif";
//$NON-NLS-1$
public static final String IMG_DELTA= NAME_PREFIX + "delta.gif";
//$NON-NLS-1$
public static final String IMG_DELTA_LARGE= NAME_PREFIX + "delta-large.gif";
//$NON-NLS-1$
+ public static final String IMG_DESTROY = NAME_PREFIX + "destroy.gif";
//$NON-NLS-1$
+ public static final String IMG_DESTROY_D = NAME_PREFIX + "destroyd.gif";
//$NON-NLS-1$
+ public static final String IMG_FOLDER= NAME_PREFIX + "folder.gif";
//$NON-NLS-1$
+ public static final String IMG_IMAGE= NAME_PREFIX + "image.gif";
//$NON-NLS-1$
+ public static final String IMG_INSTANCE= NAME_PREFIX + "instance.gif";
//$NON-NLS-1$
+ public static final String IMG_NEW_DELTA= NAME_PREFIX + "newdelta.gif";
//$NON-NLS-1$
+ public static final String IMG_REBOOT = NAME_PREFIX + "reboot.gif";
//$NON-NLS-1$
+ public static final String IMG_REBOOTD = NAME_PREFIX + "rebootd.gif";
//$NON-NLS-1$
public static final String IMG_START= NAME_PREFIX + "run.gif"; //$NON-NLS-1$
public static final String IMG_STARTD = NAME_PREFIX + "rund.gif";
//$NON-NLS-1$
+ public static final String IMG_RUNNING= NAME_PREFIX + "running.gif";
//$NON-NLS-1$
public static final String IMG_STOP = NAME_PREFIX + "stop.gif"; //$NON-NLS-1$
public static final String IMG_STOPD = NAME_PREFIX + "stopd.gif";
//$NON-NLS-1$
public static final String IMG_STOPPED = NAME_PREFIX + "stopped.gif";
//$NON-NLS-1$
- public static final String IMG_REBOOT = NAME_PREFIX + "reboot.gif";
//$NON-NLS-1$
- public static final String IMG_REBOOTD = NAME_PREFIX + "rebootd.gif";
//$NON-NLS-1$
- public static final String IMG_RUNNING= NAME_PREFIX + "running.gif";
//$NON-NLS-1$
+ public static final String SYSTEM_VIEW = NAME_PREFIX + "system_view.gif";
//$NON-NLS-1$
+ public static final String SYSTEM_VIEWD = NAME_PREFIX + "system_viewd.gif";
//$NON-NLS-1$
public static final ImageDescriptor DESC_CLOUD= createManaged("", IMG_CLOUD);
public static final ImageDescriptor DESC_FOLDER= createManaged("",
IMG_FOLDER);
public static final ImageDescriptor DESC_INSTANCE= createManaged("",
IMG_INSTANCE);
@@ -56,6 +61,9 @@
public static final ImageDescriptor DESC_COLLAPSE_ALL= createManaged("",
IMG_COLLAPSE_ALL);
public static final ImageDescriptor DESC_DELTA= createManaged("", IMG_DELTA);
public static final ImageDescriptor DESC_DELTA_LARGE= createManaged("",
IMG_DELTA_LARGE);
+ public static final ImageDescriptor DESC_NEW_DELTA= createManaged("",
IMG_NEW_DELTA);
+ public static final ImageDescriptor DESC_DESTROY = createManaged("",
IMG_DESTROY);
+ public static final ImageDescriptor DESC_DESTROYD= createManaged("",
IMG_DESTROY_D);
public static final ImageDescriptor DESC_START= createManaged("", IMG_START);
public static final ImageDescriptor DESC_STARTD= createManaged("",
IMG_STARTD);
public static final ImageDescriptor DESC_RUNNING= createManaged("",
IMG_RUNNING);
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstanceDialog.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstanceDialog.java 2011-01-26
00:03:09 UTC (rev 28605)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstanceDialog.java 2011-01-26
00:04:15 UTC (rev 28606)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.deltacloud.ui.commands;
+import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.jface.viewers.ArrayContentProvider;
@@ -45,4 +46,13 @@
, message);
setTitle(title);
}
+
+ public DeltaCloudInstance[] getResult2() {
+ ArrayList<DeltaCloudInstance> result = new
ArrayList<DeltaCloudInstance>();
+ Object[] supArr = super.getResult();
+ for( int i = 0; i < supArr.length; i++ ) {
+ result.add((DeltaCloudInstance)supArr[i]);
+ }
+ return result.toArray(new DeltaCloudInstance[result.size()]);
+ }
}
\ No newline at end of file
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudContentProvider.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudContentProvider.java 2011-01-26
00:04:15 UTC (rev 28606)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud.cnf;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.DeltaCloudImage;
+import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.job.LoadCloudImagesJob;
+import org.jboss.tools.deltacloud.core.job.LoadCloudInstancesJob;
+import org.jboss.tools.deltacloud.ui.Activator;
+
+public class CloudContentProvider implements ITreeContentProvider {
+ private TreeViewer viewer;
+ public CloudContentProvider() {
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = (TreeViewer)viewer;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ DeltaCloudManager m = DeltaCloudManager.getDefault();
+ DeltaCloud[] clouds = new DeltaCloud[]{};
+ try {
+ clouds = m.getClouds();
+ } catch( DeltaCloudException dce) {}
+ return clouds;
+ }
+
+ public abstract static class CategoryContent implements IAdaptable{
+ protected String name;
+ protected DeltaCloud cloud;
+ public CategoryContent(String name, DeltaCloud cloud) {
+ this.name = name;
+ this.cloud = cloud;
+ }
+ public DeltaCloud getCloud(){ return cloud; }
+ public String getName(){ return name;}
+ public abstract Job getFetchChildrenJob(TreeViewer viewer);
+ public abstract Object[] getChildren() throws Exception ;
+ public Object getAdapter(Class adapter) {
+ if( adapter == DeltaCloud.class )
+ return cloud;
+ return null;
+ }
+ }
+
+ public static class InstancesCategory extends CategoryContent {
+ public InstancesCategory(String name, DeltaCloud cloud) {
+ super(name, cloud);
+ }
+ public Job getFetchChildrenJob(TreeViewer viewer) {
+ return new LoadCloudInstancesJob(cloud,refreshParentRunnable(viewer, this) );
+ }
+ public Object[] getChildren() throws Exception {
+ return cloud.instancesLoaded() ? cloud.getInstances() : null;
+ }
+ }
+
+ public static class ImagesCategory extends CategoryContent {
+ public ImagesCategory(String name, DeltaCloud cloud) {
+ super(name, cloud);
+ }
+ public Job getFetchChildrenJob(TreeViewer viewer) {
+ return new LoadCloudImagesJob(cloud,refreshParentRunnable(viewer, this) );
+ }
+ public Object[] getChildren() throws Exception {
+ if( !cloud.imagesLoaded() )
+ return null;
+ DeltaCloudImage[] images = cloud.getImages();
+ int numPages = images.length / ImagesPager.PER_PAGE;
+ if( images.length != 0 &&
+ images.length % ImagesPager.PER_PAGE != 0)
+ numPages++;
+ ImagesPager[] pages = new ImagesPager[numPages];
+ for( int i = 0; i < numPages; i++ ) {
+ pages[i] = new ImagesPager(cloud, i);
+ }
+ return pages;
+ }
+ }
+
+ public static class ImagesPager {
+ public static final int PER_PAGE = 50;
+ private DeltaCloud cloud;
+ private int page;
+ private int start, end;
+ private ArrayList<DeltaCloudImage> myImages = null;
+ public ImagesPager(DeltaCloud cloud, int page) {
+ this.cloud = cloud;
+ this.page = page;
+ try {
+ DeltaCloudImage[] images = cloud.getImages();
+ start = page * PER_PAGE;
+ end = ((page+1) * PER_PAGE);
+ end = end > images.length ? images.length : end;
+ } catch(DeltaCloudException dce){}
+ }
+ public Object[] getChildren() throws Exception {
+ if( myImages == null ) {
+ DeltaCloudImage[] images = cloud.getImages();
+ myImages = new ArrayList<DeltaCloudImage>();
+ for( int i = start; i < end; i++) {
+ myImages.add(images[i]);
+ }
+ }
+ return (DeltaCloudImage[]) myImages.toArray(new DeltaCloudImage[myImages.size()]);
+ }
+ public int getPage() { return page; }
+ public String toString() {
+ return start + "..." + end;
+ }
+ }
+
+ public static class DelayObject {
+ public Object parent;
+ public DelayObject(Object parent) {
+ this.parent = parent;
+ }
+ }
+
+ private static Runnable refreshParentRunnable(final TreeViewer v, final Object parent)
{
+ return new Runnable() {
+ public void run() {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ v.refresh(parent);
+ }
+ });
+ }
+ };
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ try {
+ if( parentElement instanceof DeltaCloud) {
+ return new CategoryContent[] {
+ new InstancesCategory("Instances", (DeltaCloud)parentElement),
+ new ImagesCategory("Images", (DeltaCloud)parentElement)
+ };
+ }
+
+ if( parentElement instanceof CategoryContent ) {
+ CategoryContent cc = (CategoryContent)parentElement;
+ Object[] vals = cc.getChildren();
+ if( vals == null ) {
+ Job j = cc.getFetchChildrenJob(viewer);
+ j.schedule();
+ return new Object[]{new DelayObject(this)};
+ }
+ return vals;
+ }
+
+ if( parentElement instanceof ImagesPager ) {
+ return ((ImagesPager)parentElement).getChildren();
+ }
+ } catch( Exception e ) {
+ // log? show? idk
+ Activator.getDefault().getLog().log(new Status(
+ IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
+ }
+ return new Object[]{};
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+ public boolean hasChildren(Object element) {
+ if( element instanceof DelayObject )
+ return false;
+ return true;
+ }
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudLabelProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudLabelProvider.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudLabelProvider.java 2011-01-26
00:04:15 UTC (rev 28606)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud.cnf;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudImage;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+import org.jboss.tools.deltacloud.ui.views.cloud.ImageItem;
+import
org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudContentProvider.CategoryContent;
+import org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudContentProvider.DelayObject;
+import org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudContentProvider.ImagesPager;
+
+public class CloudLabelProvider extends LabelProvider {
+ public Image getImage(Object element) {
+ if (element instanceof DeltaCloud) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_CLOUD);
+ } else if (element instanceof CategoryContent ) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_FOLDER);
+ } else if (element instanceof DeltaCloudInstance) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_INSTANCE);
+ } else if (element instanceof DeltaCloudImage) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_IMAGE);
+ } else if (element instanceof ImagesPager ) {
+ return SWTImagesFactory.get(SWTImagesFactory.IMG_FOLDER);
+ }
+ return null;
+ }
+
+ public String getText(Object element) {
+ if( element instanceof DelayObject )
+ return "Loading...";
+
+ if( element instanceof DeltaCloud)
+ return ((DeltaCloud)element).getName();
+
+ if( element instanceof CategoryContent)
+ return ((CategoryContent)element).getName();
+
+ if( element instanceof DeltaCloudImage)
+ return getImageText((DeltaCloudImage)element);
+
+ if( element instanceof DeltaCloudInstance)
+ return getInstanceText((DeltaCloudInstance)element);
+
+ return (element == null ? "" : element.toString());//$NON-NLS-1$
+ }
+
+ private String getInstanceText(DeltaCloudInstance instance) {
+ String result = instance.getAlias() != null
+ ? instance.getAlias()
+ : instance.getName() != null
+ ? instance.getName()
+ : "";
+
+ if (instance.getId() != null)
+ result += " [" + instance.getId() + "]";
+
+ return result.trim();
+ }
+
+ private String getImageText(DeltaCloudImage image) {
+ StringBuilder builder = new StringBuilder();
+ if (image.getName() != null)
+ builder.append(image.getName()).append(' ');
+ if (image.getId() != null)
+ builder.append('[').append(image.getId()).append(']');
+ return builder.toString();
+ }
+
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudNavigator.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudNavigator.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudNavigator.java 2011-01-26
00:04:15 UTC (rev 28606)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.deltacloud.ui.views.cloud.cnf;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.IDeltaCloudManagerListener;
+
+public class CloudNavigator extends CommonNavigator implements IDeltaCloudManagerListener
{
+ protected Object getInitialInput() {
+ return this;
+ }
+ public void createPartControl(Composite aParent) {
+ super.createPartControl(aParent);
+ getCommonViewer().setSorter(null);
+ DeltaCloudManager.getDefault().addCloudManagerListener(this);
+ }
+ public void cloudsChanged(int type, DeltaCloud cloud) {
+ if( getCommonViewer() != null && !getCommonViewer().getTree().isDisposed())
+ getCommonViewer().refresh();
+ }
+ public void dispose() {
+ super.dispose();
+ DeltaCloudManager.getDefault().removeCloudManagerListener(this);
+ }
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionProvider.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionProvider.java 2011-01-26
00:04:15 UTC (rev 28606)
@@ -0,0 +1,247 @@
+package org.jboss.tools.deltacloud.ui.views.cloud.cnf;
+
+import java.io.ObjectInputStream.GetField;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.wizards.EditCloudConnectionWizard;
+import org.jboss.tools.internal.deltacloud.ui.wizards.ImageFilterWizard;
+import org.jboss.tools.internal.deltacloud.ui.wizards.InstanceFilterWizard;
+import org.jboss.tools.internal.deltacloud.ui.wizards.NewCloudConnectionWizard;
+
+public class CloudViewActionProvider extends CommonActionProvider {
+
+ private ICommonActionExtensionSite actionSite;
+ private CommonViewer cv;
+
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ this.actionSite = aSite;
+ ICommonViewerSite site = aSite.getViewSite();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ StructuredViewer v = aSite.getStructuredViewer();
+ if( v instanceof CommonViewer ) {
+ cv = (CommonViewer)v;
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ createActions(cv, wsSite.getSelectionProvider());
+ addDoubleClickHandler(cv);
+ }
+ }
+ }
+
+ public void dispose() {
+ super.dispose();
+ removeDoubleClickHandler();
+ }
+
+ private IDoubleClickListener doubleClickListener;
+ protected void addDoubleClickHandler(CommonViewer cv) {
+ doubleClickListener = new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ Object o = getSelection();
+ }
+ };
+ cv.addDoubleClickListener(doubleClickListener);
+ }
+
+ protected void removeDoubleClickHandler() {
+ cv.removeDoubleClickListener(doubleClickListener);
+ }
+
+ private Action newConnectionAction, editConnectionAction,
+ deleteCloudAction, refreshCloudAction, launchInstanceAction,
+ startAction, stopAction, rebootAction, destroyAction,
+ filterImageAction, filterInstanceAction;
+
+ protected IStructuredSelection getSelection() {
+ ICommonViewerSite site = actionSite.getViewSite();
+ if (site instanceof ICommonViewerWorkbenchSite) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite) site;
+ return (IStructuredSelection)wsSite.getSelectionProvider().getSelection();
+ }
+ return null;
+ }
+
+ protected Object getSelectedItem() {
+ IStructuredSelection selection = getSelection();
+ if( selection != null )
+ return selection.getFirstElement();
+ return null;
+ }
+
+ private void addGM(String id, boolean visible, IMenuManager manager) {
+ GroupMarker gm = new GroupMarker(id);
+ manager.add(gm);
+ Separator s = new Separator();
+ s.setVisible(true);
+ manager.add(s);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ createActions(cv, null);
+ Object first = getSelectedItem();
+ addGM("BEGIN_CLOUD", false, menu);
+ menu.insertAfter("BEGIN_CLOUD", newConnectionAction);
+ if (first == null)
+ return;
+
+ addGM("END_CLOUD", true, menu);
+ menu.insertBefore("END_CLOUD", editConnectionAction);
+ menu.insertBefore("END_CLOUD", deleteCloudAction);
+ menu.insertBefore("END_CLOUD", refreshCloudAction);
+ addGM("INSTANCE_ACTIONS_BEGIN", false, menu);
+ addGM("INSTANCE_ACTIONS_END", true, menu);
+ menu.insertBefore("INSTANCE_ACTIONS_END", launchInstanceAction);
+ if( (first instanceof DeltaCloudInstance)) {
+ DeltaCloudInstance i = (DeltaCloudInstance)first;
+ menu.insertBefore("INSTANCE_ACTIONS_END", startAction);
+ menu.insertBefore("INSTANCE_ACTIONS_END", stopAction);
+ menu.insertBefore("INSTANCE_ACTIONS_END", rebootAction);
+ menu.insertBefore("INSTANCE_ACTIONS_END", destroyAction);
+ startAction.setEnabled(i.canStart());
+ stopAction.setEnabled(i.canStop());
+ rebootAction.setEnabled(i.canReboot());
+ destroyAction.setEnabled(i.canDestroy());
+ }
+ addGM("FILTERS_BEGIN", false, menu);
+ addGM("FILTERS_END", true, menu);
+ menu.insertBefore("FILTERS_END", filterImageAction);
+ menu.insertBefore("FILTERS_END", filterInstanceAction);
+ }
+
+ public void createActions(CommonViewer tableViewer, ISelectionProvider provider) {
+ final Shell shell = tableViewer.getTree().getShell();
+ newConnectionAction = new Action() {
+ public void run() {
+ NewCloudConnectionWizard wizard = new NewCloudConnectionWizard();
+ wizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.open();
+ }
+ };
+ newConnectionAction.setText("New Connection");
+ newConnectionAction.setImageDescriptor(SWTImagesFactory.DESC_NEW_DELTA);
+
+ editConnectionAction = new Action() {
+ public void run() {
+ DeltaCloud cloud = UIUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
+ if (cloud != null) {
+ IWizard wizard = new EditCloudConnectionWizard(cloud);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.open();
+ }
+ }
+ };
+ editConnectionAction.setText("Edit Connection");
+
+ deleteCloudAction = new Action() {
+ public void run() {
+ CloudViewActionUtil.deleteDeltaClouds(shell, getSelection());
+ }
+ };
+ deleteCloudAction.setText("Delete Cloud");
+ deleteCloudAction.setImageDescriptor(SWTImagesFactory.DESC_DESTROY);
+ deleteCloudAction.setDisabledImageDescriptor(SWTImagesFactory.DESC_DESTROYD);
+
+ refreshCloudAction = new Action() {
+ public void run() {
+ CloudViewActionUtil.refreshDeltaClouds(shell, getSelection());
+ }
+ };
+ refreshCloudAction.setText("Refresh Cloud");
+
+ launchInstanceAction = new Action() {
+ public void run() {
+ CloudViewActionUtil.showCreateInstanceWizard(shell, getSelection());
+ }
+ };
+ launchInstanceAction.setText("Launch Instance");
+ launchInstanceAction.setImageDescriptor(SWTImagesFactory.DESC_INSTANCE);
+
+ startAction = new Action() {
+ public void run() {
+ CloudViewActionUtil.startInstances(getSelection());
+ }
+ };
+ startAction.setText("Start");
+ startAction.setImageDescriptor(SWTImagesFactory.DESC_START);
+ startAction.setDisabledImageDescriptor(SWTImagesFactory.DESC_STARTD);
+
+ stopAction = new Action() {
+ public void run() {
+ CloudViewActionUtil.stopInstances(getSelection());
+ }
+ };
+ stopAction.setText("Stop");
+ stopAction.setImageDescriptor(SWTImagesFactory.DESC_STOP);
+ stopAction.setDisabledImageDescriptor(SWTImagesFactory.DESC_STOPD);
+
+ rebootAction = new Action() {
+ public void run() {
+ CloudViewActionUtil.rebootInstances(getSelection());
+ }
+ };
+ rebootAction.setText("Reboot");
+ rebootAction.setImageDescriptor(SWTImagesFactory.DESC_REBOOT);
+ rebootAction.setDisabledImageDescriptor(SWTImagesFactory.DESC_REBOOTD);
+
+ destroyAction = new Action() {
+ public void run() {
+ CloudViewActionUtil.destroyInstances(getSelection());
+ }
+ };
+ destroyAction.setText("Destroy");
+ destroyAction.setImageDescriptor(SWTImagesFactory.DESC_DESTROY);
+ destroyAction.setDisabledImageDescriptor(SWTImagesFactory.DESC_DESTROYD);
+
+ filterImageAction = new Action() {
+ public void run() {
+ DeltaCloud cloud = UIUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
+ if( cloud != null ) {
+ IWizard wizard = new ImageFilterWizard(cloud);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.open();
+ }
+ }
+ };
+ filterImageAction.setText("Filter Images");
+
+
+ filterInstanceAction = new Action() {
+ public void run() {
+ DeltaCloud cloud = UIUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
+ if( cloud != null ) {
+ IWizard wizard = new InstanceFilterWizard(cloud);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.open();
+ }
+ }
+ };
+ filterInstanceAction.setText("Filter Instances");
+ }
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionUtil.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionUtil.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionUtil.java 2011-01-26
00:04:15 UTC (rev 28606)
@@ -0,0 +1,207 @@
+package org.jboss.tools.deltacloud.ui.views.cloud.cnf;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.DeltaCloudImage;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.job.InstanceActionJob;
+import org.jboss.tools.deltacloud.core.job.RefreshCloudJob;
+import org.jboss.tools.deltacloud.ui.commands.DeleteCloudHandler.DeleteCloudsDialog;
+import org.jboss.tools.deltacloud.ui.commands.DeltaCloudInstanceDialog;
+import org.jboss.tools.deltacloud.ui.views.CVMessages;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.wizards.NewInstanceWizard;
+
+public class CloudViewActionUtil {
+ private final static String STARTING_INSTANCE_MSG_KEY =
"StartingInstance.msg"; //$NON-NLS-1$
+ private final static String START_INSTANCES_DIALOG_TITLE_VAL =
CVMessages.getString("StartInstancesDialog.title"); //$NON-NLS-1$
+ private final static String START_INSTANCES_DIALOG_MSG_VAL =
CVMessages.getString("StartInstancesDialog.msg"); //$NON-NLS-1$
+
+ private final static String STOPPING_INSTANCE_MSG_KEY =
"StoppingInstance.msg"; //$NON-NLS-1$
+ private final static String STOP_INSTANCES_DIALOG_TITLE_VAL =
CVMessages.getString("StopInstancesDialog.title"); //$NON-NLS-1$
+ private final static String STOP_INSTANCES_DIALOG_MSG_VAL =
CVMessages.getString("StopInstancesDialog.msg"); //$NON-NLS-1$
+
+ private final static String REBOOTING_INSTANCE_MSG_KEY =
"RebootingInstance.msg"; //$NON-NLS-1$
+ private final static String REBOOT_INSTANCE_TITLE_VAL =
CVMessages.getString("RebootInstancesDialog.title"); //$NON-NLS-1$
+ private final static String REBOOT_INSTANCE_MSG_VAL =
CVMessages.getString("RebootInstancesDialog.msg"); //$NON-NLS-1$
+
+ private final static String DESTROYING_INSTANCE_MSG_KEY =
"DestroyingInstance.msg"; //$NON-NLS-1$
+ private final static String DESTROY_INSTANCE_TITLE_VAL =
CVMessages.getString("DestroyInstancesDialog.title"); //$NON-NLS-1$
+ private final static String DESTROY_INSTANCE_MSG_VAL =
CVMessages.getString("DestroyInstancesDialog.msg"); //$NON-NLS-1$
+
+ public static void startInstances(ISelection selection) {
+ DeltaCloudInstance[] instances =
getStoppedInstancesToLaunch(getCloudInstances(selection));
+ handleInstanceAction(
+ instances,
+ START_INSTANCES_DIALOG_TITLE_VAL, START_INSTANCES_DIALOG_MSG_VAL,
+ DeltaCloudInstance.Action.START, DeltaCloudInstance.State.RUNNING,
+ STARTING_INSTANCE_MSG_KEY);
+ }
+
+ public static void stopInstances(ISelection selection) {
+ DeltaCloudInstance[] instances = getStoppableInstances(getCloudInstances(selection));
+ handleInstanceAction(
+ instances,
+ STOP_INSTANCES_DIALOG_TITLE_VAL, STOP_INSTANCES_DIALOG_MSG_VAL,
+ DeltaCloudInstance.Action.STOP, DeltaCloudInstance.State.STOPPED,
+ STOPPING_INSTANCE_MSG_KEY);
+ }
+
+ public static void rebootInstances(ISelection selection) {
+ DeltaCloudInstance[] instances = getRebootableInstances(getCloudInstances(selection));
+ handleInstanceAction(
+ instances,
+ REBOOT_INSTANCE_TITLE_VAL, REBOOT_INSTANCE_MSG_VAL,
+ DeltaCloudInstance.Action.REBOOT, DeltaCloudInstance.State.RUNNING,
+ REBOOTING_INSTANCE_MSG_KEY);
+ }
+ public static void destroyInstances(ISelection selection) {
+ DeltaCloudInstance[] instances =
getDestroyableInstances(getCloudInstances(selection));
+ handleInstanceAction(
+ instances,
+ DESTROY_INSTANCE_TITLE_VAL, DESTROY_INSTANCE_MSG_VAL,
+ DeltaCloudInstance.Action.DESTROY, DeltaCloudInstance.State.TERMINATED,
+ DESTROYING_INSTANCE_MSG_KEY);
+ }
+
+ protected static void handleInstanceAction(DeltaCloudInstance[] instances,
+ String dialogTitle, String dialogMsg, DeltaCloudInstance.Action action,
+ DeltaCloudInstance.State expectedState, String unformattedJobName) {
+ if(instances.length > 1 ) {
+ List<DeltaCloudInstance> list = Arrays.asList(instances);
+ DeltaCloudInstanceDialog dialog = new DeltaCloudInstanceDialog(
+ UIUtils.getActiveShell(), list,
+ dialogTitle, dialogMsg);
+ dialog.setInitialElementSelections(list);
+ if (Dialog.OK == dialog.open()) {
+ instances = dialog.getResult2();
+ } else {
+ instances = new DeltaCloudInstance[]{};
+ }
+ }
+
+ for( int i = 0; i < instances.length; i++ ) {
+ executeInstanceAction( instances[i], action, expectedState,
+ CVMessages.getFormattedString(unformattedJobName,
+ new String[] { instances[i].getName() }));
+ }
+
+ }
+
+ protected static void executeInstanceAction(DeltaCloudInstance instance,
DeltaCloudInstance.Action action,
+ DeltaCloudInstance.State expectedState, String jobName) {
+ if (instance != null) {
+ new InstanceActionJob(jobName, instance, action, expectedState).schedule();
+ }
+ }
+
+ private static DeltaCloudInstance[]
getStoppedInstancesToLaunch(List<DeltaCloudInstance> instances) {
+ Iterator<DeltaCloudInstance> i = instances.iterator();
+ while(i.hasNext())
+ if(!i.next().isStopped())
+ i.remove();
+ return instances.toArray(new DeltaCloudInstance[instances.size()]);
+ }
+
+ private static DeltaCloudInstance[] getStoppableInstances(List<DeltaCloudInstance>
instances) {
+ ArrayList<DeltaCloudInstance> stoppedInstances = new
ArrayList<DeltaCloudInstance>();
+ for (DeltaCloudInstance instance : instances)
+ if (instance.canStop())
+ stoppedInstances.add(instance);
+ return stoppedInstances.toArray(new DeltaCloudInstance[stoppedInstances.size()]);
+ }
+
+ private static DeltaCloudInstance[]
getRebootableInstances(List<DeltaCloudInstance> deltaCloudInstances) {
+ ArrayList<DeltaCloudInstance> rebootable = new
ArrayList<DeltaCloudInstance>();
+ for (DeltaCloudInstance instance : deltaCloudInstances) {
+ if (instance.canReboot()) {
+ rebootable.add(instance);
+ }
+ }
+ return rebootable.toArray(new DeltaCloudInstance[rebootable.size()]);
+ }
+
+ private static DeltaCloudInstance[]
getDestroyableInstances(List<DeltaCloudInstance> deltaCloudInstances) {
+ ArrayList<DeltaCloudInstance> destroyable = new
ArrayList<DeltaCloudInstance>();
+ for (DeltaCloudInstance instance : deltaCloudInstances) {
+ if (instance.canDestroy()) {
+ destroyable.add(instance);
+ }
+ }
+ return destroyable.toArray(new DeltaCloudInstance[destroyable.size()]);
+ }
+
+ public static List<DeltaCloudInstance> getCloudInstances(ISelection selection) {
+ if( selection instanceof DeltaCloudInstance ) {
+ IStructuredSelection s2 = (IStructuredSelection)selection;
+ List<DeltaCloudInstance> instances =
UIUtils.adapt(s2.toList(),DeltaCloudInstance.class);
+ return instances;
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ public static void showCreateInstanceWizard(Shell shell, ISelection selection) {
+ DeltaCloudImage deltaCloudImage = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudImage.class);
+ DeltaCloud deltaCloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ IWizard wizard = new NewInstanceWizard(deltaCloud, deltaCloudImage);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.open();
+ }
+
+ public static void refreshDeltaClouds(Shell shell, ISelection selection) {
+ Collection<DeltaCloud> clouds = getSelectedClouds(selection);
+ for (DeltaCloud cloud : clouds) {
+ new RefreshCloudJob(cloud).schedule();
+ }
+ }
+
+ public static void deleteDeltaClouds(Shell shell, ISelection selection) {
+ Collection<DeltaCloud> clouds = getSelectedClouds(selection);
+ DeleteCloudsDialog dialog =
+ new DeleteCloudsDialog(shell, clouds);
+ dialog.setInitialSelections(clouds.toArray());
+ if (Dialog.OK == dialog.open()) {
+ ArrayList<IStatus> children = new ArrayList<IStatus>();
+ for (Object deltaCloud : clouds) {
+ try {
+ DeltaCloudManager.getDefault().removeCloud((DeltaCloud) deltaCloud);
+ } catch( DeltaCloudException dce) {
+ // TODO create status
+ }
+ }
+ if( children.size() > 0 ) {
+ // TODO create multistatus and log
+ }
+ }
+ }
+
+ public static Collection<DeltaCloud> getSelectedClouds(ISelection selection) {
+ List<?> selectedElements = ((IStructuredSelection) selection).toList();
+ Set<DeltaCloud> selectedClouds = new HashSet<DeltaCloud>();
+ for (Object element : selectedElements) {
+ DeltaCloud deltaCloud = UIUtils.adapt(element, DeltaCloud.class);
+ if (deltaCloud != null) {
+ selectedClouds.add(deltaCloud);
+ }
+ }
+ return selectedClouds;
+ }
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/ClouldSorter1.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/ClouldSorter1.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/ClouldSorter1.java 2011-01-26
00:04:15 UTC (rev 28606)
@@ -0,0 +1,36 @@
+package org.jboss.tools.deltacloud.ui.views.cloud.cnf;
+
+import java.text.Collator;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import
org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudContentProvider.CategoryContent;
+import org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudContentProvider.ImagesPager;
+import
org.jboss.tools.deltacloud.ui.views.cloud.cnf.CloudContentProvider.InstancesCategory;
+
+public class ClouldSorter1 extends ViewerSorter {
+
+ public ClouldSorter1() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public ClouldSorter1(Collator collator) {
+ super(collator);
+ // TODO Auto-generated constructor stub
+ }
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
java.lang.Object, java.lang.Object)
+ */
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if( e1 instanceof CategoryContent && e1 instanceof CategoryContent ) {
+ if( e1 instanceof InstancesCategory)
+ return -1;
+ return 1;
+ }
+
+ if( e1 instanceof ImagesPager && e2 instanceof ImagesPager)
+ return ((ImagesPager)e1).getPage() - ((ImagesPager)e2).getPage();
+ return super.compare(viewer, e1, e2);
+ }
+}