Author: adietish
Date: 2010-12-08 12:48:54 -0500 (Wed, 08 Dec 2010)
New Revision: 27246
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingItem.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootItem.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java
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/adapter/CloudViewElementAdapterFactory.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceHandler2.java
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
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewLabelProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java
Log:
renamed CloudViewElement(s) to CloudViewItems
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2010-12-08 17:43:10
UTC (rev 27245)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2010-12-08 17:48:54
UTC (rev 27246)
@@ -65,7 +65,7 @@
id="org.jboss.tools.deltacloud.ui.propertySection.advanced"
tab="cloudview.advancedTab">
<input
-
type="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
+
type="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
</input>
</propertySection>
</propertySections>
@@ -116,7 +116,7 @@
variable="selection">
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
</instanceof>
</iterate>
</with>
@@ -136,7 +136,7 @@
variable="selection">
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
</instanceof>
</iterate>
</with>
@@ -158,7 +158,7 @@
<count value="+" />
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
</instanceof>
</iterate>
</and>
@@ -299,7 +299,7 @@
variable="selection">
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
</instanceof>
</iterate>
</with>
@@ -675,7 +675,7 @@
variable="selection">
<iterate>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.ImageViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.ImageItem">
</instanceof>
</iterate>
</with>
@@ -699,11 +699,11 @@
<iterate>
<and>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem">
</instanceof>
<not>
<instanceof
-
value="org.jboss.tools.deltacloud.ui.views.cloud.ImageViewElement">
+
value="org.jboss.tools.deltacloud.ui.views.cloud.ImageItem">
</instanceof>
</not>
</and>
@@ -870,7 +870,7 @@
<extension
point="org.eclipse.core.runtime.adapters">
<factory
-
adaptableType="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement"
+
adaptableType="org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem"
class="org.jboss.tools.deltacloud.ui.adapter.CloudViewElementAdapterFactory">
<adapter
type="org.jboss.tools.deltacloud.core.DeltaCloudInstance">
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/CloudViewElementAdapterFactory.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/CloudViewElementAdapterFactory.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/CloudViewElementAdapterFactory.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -16,9 +16,9 @@
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.views.cloud.ImageViewElement;
-import org.jboss.tools.deltacloud.ui.views.cloud.InstanceViewElement;
-import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.ImageItem;
+import org.jboss.tools.deltacloud.ui.views.cloud.InstanceItem;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem;
import org.jboss.tools.internal.deltacloud.ui.utils.CloudViewElementUtils;
public class CloudViewElementAdapterFactory implements IAdapterFactory {
@@ -33,8 +33,8 @@
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
- Assert.isLegal(adaptableObject instanceof DeltaCloudViewElement);
- DeltaCloudViewElement element = (DeltaCloudViewElement) adaptableObject;
+ Assert.isLegal(adaptableObject instanceof DeltaCloudViewItem);
+ DeltaCloudViewItem element = (DeltaCloudViewItem) adaptableObject;
if (adapterType == IPropertySource.class) {
return element.getPropertySource();
} else if (adapterType == DeltaCloudImage.class) {
@@ -48,16 +48,16 @@
}
}
- private DeltaCloudInstance getDeltaCloudInstance(DeltaCloudViewElement element) {
- if (element instanceof InstanceViewElement) {
+ private DeltaCloudInstance getDeltaCloudInstance(DeltaCloudViewItem element) {
+ if (element instanceof InstanceItem) {
return (DeltaCloudInstance) element.getModel();
} else {
return null;
}
}
- private DeltaCloudImage getDeltaCloudImage(DeltaCloudViewElement element) {
- if (element instanceof ImageViewElement) {
+ private DeltaCloudImage getDeltaCloudImage(DeltaCloudViewItem element) {
+ if (element instanceof ImageItem) {
return (DeltaCloudImage) element.getModel();
} else {
return null;
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceHandler2.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceHandler2.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceHandler2.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -21,8 +21,8 @@
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.CloudViewElement;
-import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
+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.NewInstanceWizard;
@@ -35,12 +35,12 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloudViewElement element = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewElement.class);
- while (element != null && !(element instanceof CloudViewElement)) {
- element = (DeltaCloudViewElement) element.getParent();
+ DeltaCloudViewItem element = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewItem.class);
+ while (element != null && !(element instanceof CloudItem)) {
+ element = (DeltaCloudViewItem) element.getParent();
}
if (element != null) {
- CloudViewElement cloudElement = (CloudViewElement) element;
+ CloudItem cloudElement = (CloudItem) element;
DeltaCloud cloud = (DeltaCloud) cloudElement.getModel();
IWizard wizard = new NewInstanceWizard(cloud);
WizardDialog dialog = new
WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(),
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-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DisconnectCloudHandler.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -38,8 +38,8 @@
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.CloudViewElement;
-import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.CloudItem;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem;
/**
* @author Andre Dietisheim
@@ -132,8 +132,8 @@
DeltaCloud deltaCloud = null;
if (selectedElements.size() > 0) {
Object object = selectedElements.get(0);
- if (object instanceof CloudViewElement) {
- Object element = ((CloudViewElement) object).getModel();
+ if (object instanceof CloudItem) {
+ Object element = ((CloudItem) object).getModel();
if (element instanceof DeltaCloud) {
deltaCloud = (DeltaCloud) element;
}
@@ -154,11 +154,11 @@
}
private DeltaCloud getDeltaCloud(Object item) {
- if (!(item instanceof DeltaCloudViewElement)) {
+ if (!(item instanceof DeltaCloudViewItem)) {
return null;
}
- DeltaCloud cloud = getDeltaCloud((DeltaCloudViewElement) item);
+ DeltaCloud cloud = getDeltaCloud((DeltaCloudViewItem) item);
if (cloud == null) {
return null;
@@ -166,7 +166,7 @@
return cloud;
}
- private DeltaCloud getDeltaCloud(DeltaCloudViewElement element) {
+ private DeltaCloud getDeltaCloud(DeltaCloudViewItem element) {
if (element == null) {
return null;
}
@@ -175,7 +175,7 @@
return (DeltaCloud) cloud;
}
- return getDeltaCloud((DeltaCloudViewElement) element.getParent());
+ return getDeltaCloud((DeltaCloudViewItem) element.getParent());
}
private void removeDeltaClouds(Object[] deltaClouds) throws DeltaCloudException {
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-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -21,8 +21,8 @@
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.CloudViewElement;
-import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
+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,12 +35,12 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloudViewElement element = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewElement.class);
- while (element != null && !(element instanceof CloudViewElement)) {
- element = (DeltaCloudViewElement) element.getParent();
+ DeltaCloudViewItem element = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewItem.class);
+ while (element != null && !(element instanceof CloudItem)) {
+ element = (DeltaCloudViewItem) element.getParent();
}
if (element != null) {
- CloudViewElement cloudElement = (CloudViewElement) element;
+ CloudItem cloudElement = (CloudItem) element;
DeltaCloud cloud = (DeltaCloud) cloudElement.getModel();
IWizard wizard = new EditCloudConnectionWizard(cloud);
WizardDialog dialog = new WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(),
wizard);
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -25,7 +25,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudMultiException;
import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
-import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem;
import org.jboss.tools.internal.deltacloud.ui.utils.CloudViewElementUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
@@ -38,14 +38,14 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloudViewElement cloudViewElement = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewElement.class);
+ DeltaCloudViewItem cloudViewElement = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudViewItem.class);
refresh(cloudViewElement);
}
return Status.OK_STATUS;
}
- private void refresh(final DeltaCloudViewElement cloudViewElement) {
+ private void refresh(final DeltaCloudViewItem cloudViewElement) {
if (cloudViewElement != null) {
final DeltaCloud cloud = CloudViewElementUtils.getCloud(cloudViewElement);
if (cloud != null) {
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public abstract class CloudElementCategoryItem<CLOUDELEMENT> extends
DeltaCloudViewItem {
+
+ protected CloudElementCategoryItem(Object model, DeltaCloudViewItem parent, TreeViewer
viewer) {
+ super(model, parent, viewer);
+ addCloudElementListener(getCloud());
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return true;
+ }
+
+ @Override
+ public Object[] getChildren() {
+ if (!initialized.get()) {
+// setLoadingIndicator();
+ asyncGetCloudElements();
+ initialized.set(true);
+ }
+ return super.getChildren();
+ }
+
+ protected void setLoadingIndicator() {
+ children.add(new LoadingItem(this, viewer));
+ }
+
+ protected abstract void asyncGetCloudElements();
+
+ protected void addChildren(Object[] modelElements) {
+ if (modelElements.length > NumericFoldingItem.FOLDING_SIZE) {
+ addFoldedChildren(modelElements);
+ } else {
+ addChildren(getElements(modelElements, 0, modelElements.length));
+ }
+ }
+
+ protected void addFoldedChildren(Object[] modelElements) {
+ int min = 0;
+ int max = NumericFoldingItem.FOLDING_SIZE;
+ int length = modelElements.length;
+ while (length > NumericFoldingItem.FOLDING_SIZE) {
+ NumericFoldingItem f = new NumericFoldingItem(min, max, this, viewer);
+ addChild(f);
+ f.addChildren(getElements(modelElements, min, max));
+ min += NumericFoldingItem.FOLDING_SIZE;
+ max += NumericFoldingItem.FOLDING_SIZE;
+ length -= NumericFoldingItem.FOLDING_SIZE;
+ }
+ if (length > 0) {
+ NumericFoldingItem f = new NumericFoldingItem(min, max, this, viewer);
+ addChild(f);
+ f.addChildren(getElements(modelElements, min, min + length));
+ }
+ }
+
+ protected void onListChanged(DeltaCloud cloud, CLOUDELEMENT[] cloudElements) throws
DeltaCloudException {
+ try {
+ clearChildren();
+ initialized.set(false);
+ final CLOUDELEMENT[] filteredElements = filter(cloudElements);
+ addChildren(filteredElements);
+ expand();
+ } finally {
+ initialized.set(true);
+ }
+ }
+
+ protected abstract CLOUDELEMENT[] filter(CLOUDELEMENT[] cloudElements) throws
DeltaCloudException;
+
+ protected abstract DeltaCloudViewItem[] getElements(Object[] modelElements, int
startIndex, int stopIndex);
+
+ @Override
+ public IPropertySource getPropertySource() {
+ // no property source for cathegories
+ return null;
+ }
+
+ protected DeltaCloud getCloud() {
+ return (DeltaCloud) getModel();
+ }
+
+ @Override
+ protected void dispose() {
+ removeCloudElementListener(getCloud());
+ }
+
+ protected abstract void addCloudElementListener(DeltaCloud cloud);
+
+ protected abstract void removeCloudElementListener(DeltaCloud cloud);
+
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudElementCategoryViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.DeltaCloudException;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public abstract class CloudElementCategoryViewElement<CLOUDELEMENT> extends
DeltaCloudViewElement {
-
- protected CloudElementCategoryViewElement(Object model, DeltaCloudViewElement parent,
TreeViewer viewer) {
- super(model, parent, viewer);
- addCloudElementListener(getCloud());
- }
-
- @Override
- public boolean hasChildren() {
- return true;
- }
-
- @Override
- public Object[] getChildren() {
- if (!initialized.get()) {
-// setLoadingIndicator();
- asyncGetCloudElements();
- initialized.set(true);
- }
- return super.getChildren();
- }
-
- protected void setLoadingIndicator() {
- children.add(new LoadingCloudElementViewElement(this, viewer));
- }
-
- protected abstract void asyncGetCloudElements();
-
- protected void addChildren(Object[] modelElements) {
- if (modelElements.length > NumericFoldingViewElement.FOLDING_SIZE) {
- addFoldedChildren(modelElements);
- } else {
- addChildren(getElements(modelElements, 0, modelElements.length));
- }
- }
-
- protected void addFoldedChildren(Object[] modelElements) {
- int min = 0;
- int max = NumericFoldingViewElement.FOLDING_SIZE;
- int length = modelElements.length;
- while (length > NumericFoldingViewElement.FOLDING_SIZE) {
- NumericFoldingViewElement f = new NumericFoldingViewElement(min, max, this, viewer);
- addChild(f);
- f.addChildren(getElements(modelElements, min, max));
- min += NumericFoldingViewElement.FOLDING_SIZE;
- max += NumericFoldingViewElement.FOLDING_SIZE;
- length -= NumericFoldingViewElement.FOLDING_SIZE;
- }
- if (length > 0) {
- NumericFoldingViewElement f = new NumericFoldingViewElement(min, max, this, viewer);
- addChild(f);
- f.addChildren(getElements(modelElements, min, min + length));
- }
- }
-
- protected void onListChanged(DeltaCloud cloud, CLOUDELEMENT[] cloudElements) throws
DeltaCloudException {
- try {
- clearChildren();
- initialized.set(false);
- final CLOUDELEMENT[] filteredElements = filter(cloudElements);
- addChildren(filteredElements);
- expand();
- } finally {
- initialized.set(true);
- }
- }
-
- protected abstract CLOUDELEMENT[] filter(CLOUDELEMENT[] cloudElements) throws
DeltaCloudException;
-
- protected abstract DeltaCloudViewElement[] getElements(Object[] modelElements, int
startIndex, int stopIndex);
-
- @Override
- public IPropertySource getPropertySource() {
- // no property source for cathegories
- return null;
- }
-
- protected DeltaCloud getCloud() {
- return (DeltaCloud) getModel();
- }
-
- @Override
- protected void dispose() {
- removeCloudElementListener(getCloud());
- }
-
- protected abstract void addCloudElementListener(DeltaCloud cloud);
-
- protected abstract void removeCloudElementListener(DeltaCloud cloud);
-
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudItem.java
(from rev 27245,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.ui.views.cloud.property.CloudPropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class CloudItem extends DeltaCloudViewItem {
+
+ private TreeViewer viewer;
+
+ protected CloudItem(Object element, DeltaCloudViewItem parent, TreeViewer viewer) {
+ super(element, parent, viewer);
+ this.viewer = viewer;
+ }
+
+ public String getName() {
+ Object element = getModel();
+ if (element instanceof DeltaCloud) {
+ return ((DeltaCloud) element).getName();
+ } else {
+ return "";
+ }
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return true;
+ }
+
+ @Override
+ public synchronized Object[] getChildren() {
+ if (!initialized.get()) {
+ DeltaCloud cloud = (DeltaCloud) getModel();
+ children.add(new InstancesCategoryItem(cloud, this, viewer));
+ children.add(new ImagesCategoryItem(cloud, this, viewer));
+ }
+ initialized.set(true);
+ return super.getChildren();
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ return new CloudPropertySource(getModel());
+ }
+
+
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.ui.views.cloud.property.CloudPropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class CloudViewElement extends DeltaCloudViewElement {
-
- private TreeViewer viewer;
-
- protected CloudViewElement(Object element, DeltaCloudViewElement parent, TreeViewer
viewer) {
- super(element, parent, viewer);
- this.viewer = viewer;
- }
-
- public String getName() {
- Object element = getModel();
- if (element instanceof DeltaCloud) {
- return ((DeltaCloud) element).getName();
- } else {
- return "";
- }
- }
-
- @Override
- public boolean hasChildren() {
- return true;
- }
-
- @Override
- public synchronized Object[] getChildren() {
- if (!initialized.get()) {
- DeltaCloud cloud = (DeltaCloud) getModel();
- children.add(new InstancesCategoryViewElement(cloud, this, viewer));
- children.add(new ImagesCategoryViewElement(cloud, this, viewer));
- }
- initialized.set(true);
- return super.getChildren();
- }
-
- @Override
- public IPropertySource getPropertySource() {
- return new CloudPropertySource(getModel());
- }
-
-
-}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -56,7 +56,7 @@
viewer.setContentProvider(new DeltaCloudViewContentProvider());
viewer.setLabelProvider(new DeltaCloudViewLabelProvider());
viewer.setUseHashlookup(true);
- viewer.setInput(new RootViewElement(viewer));
+ viewer.setInput(new RootItem(viewer));
viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
getSite().setSelectionProvider(viewer);
return viewer;
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewContentProvider.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewContentProvider.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -15,12 +15,12 @@
public class DeltaCloudViewContentProvider implements ITreeContentProvider {
- private DeltaCloudViewElement root;
+ private DeltaCloudViewItem root;
@Override
public Object[] getChildren(Object element) {
- if (element instanceof DeltaCloudViewElement) {
- return ((DeltaCloudViewElement) element).getChildren();
+ if (element instanceof DeltaCloudViewItem) {
+ return ((DeltaCloudViewItem) element).getChildren();
} else {
return null;
}
@@ -28,8 +28,8 @@
@Override
public Object getParent(Object element) {
- if (element instanceof DeltaCloudViewElement) {
- return ((DeltaCloudViewElement) element).getParent();
+ if (element instanceof DeltaCloudViewItem) {
+ return ((DeltaCloudViewItem) element).getParent();
} else {
return null;
}
@@ -37,7 +37,7 @@
@Override
public boolean hasChildren(Object element) {
- DeltaCloudViewElement e = (DeltaCloudViewElement) element;
+ DeltaCloudViewItem e = (DeltaCloudViewItem) element;
return e.hasChildren();
}
@@ -53,7 +53,7 @@
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- root = (DeltaCloudViewElement) newInput;
+ root = (DeltaCloudViewItem) newInput;
}
}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public abstract class DeltaCloudViewElement implements IAdaptable {
-
- private Object model;
- private DeltaCloudViewElement parent;
- protected List<DeltaCloudViewElement> children =
- Collections.synchronizedList(new ArrayList<DeltaCloudViewElement>());
- protected TreeViewer viewer;
- protected AtomicBoolean initialized = new AtomicBoolean();
-
- protected DeltaCloudViewElement(Object model, DeltaCloudViewElement parent, TreeViewer
viewer) {
- this.model = model;
- this.parent = parent;
- this.viewer = viewer;
- initDisposeListener(viewer);
- }
-
- public abstract String getName();
-
- public Object[] getChildren() {
- return children.toArray();
- }
-
- protected void clearChildren() {
- getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- // viewer.getTree().setRedraw(false);
- for (final DeltaCloudViewElement element : children) {
- viewer.remove(element);
- }
- // viewer.getTree().setRedraw(true);
- }
- });
- children.clear();
- }
-
- public boolean hasChildren() {
- return children.size() > 0;
- }
-
- public Object getParent() {
- return parent;
- }
-
- public void addChild(final DeltaCloudViewElement element) {
- children.add(element);
-
- getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- viewer.add(DeltaCloudViewElement.this, element);
- }
- });
- }
-
- public void addChildren(final DeltaCloudViewElement[] elements) {
- for (DeltaCloudViewElement element : elements) {
- children.add(element);
- }
-
- getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- viewer.add(DeltaCloudViewElement.this, elements);
- }
- });
- }
-
- public void removeChild(final DeltaCloudViewElement element) {
-
- getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (element != null) {
- int index = children.indexOf(element);
- viewer.remove(DeltaCloudViewElement.this, index);
- }
- }
- });
- }
-
- protected void expand() {
- getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- viewer.setExpandedState(DeltaCloudViewElement.this, true);
- }
- });
- }
-
- public Object getModel() {
- return model;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class) {
- IPropertySource p = getPropertySource();
- return p;
- }
- return null;
- }
-
- public abstract IPropertySource getPropertySource();
-
- private void initDisposeListener(Viewer viewer) {
- final Control control = viewer.getControl();
- control.getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- control.addDisposeListener(new DisposeListener() {
-
- @Override
- public void widgetDisposed(DisposeEvent e) {
- dispose();
- }
- });
- }
- });
- }
-
- protected Display getDisplay() {
- return viewer.getControl().getDisplay();
- }
-
- protected void dispose() {
- // nothing to do
- }
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public abstract class DeltaCloudViewItem implements IAdaptable {
+
+ private Object model;
+ private DeltaCloudViewItem parent;
+ protected List<DeltaCloudViewItem> children =
+ Collections.synchronizedList(new ArrayList<DeltaCloudViewItem>());
+ protected TreeViewer viewer;
+ protected AtomicBoolean initialized = new AtomicBoolean();
+
+ protected DeltaCloudViewItem(Object model, DeltaCloudViewItem parent, TreeViewer viewer)
{
+ this.model = model;
+ this.parent = parent;
+ this.viewer = viewer;
+ initDisposeListener(viewer);
+ }
+
+ public abstract String getName();
+
+ public Object[] getChildren() {
+ return children.toArray();
+ }
+
+ protected void clearChildren() {
+ getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ // viewer.getTree().setRedraw(false);
+ for (final DeltaCloudViewItem element : children) {
+ viewer.remove(element);
+ }
+ // viewer.getTree().setRedraw(true);
+ }
+ });
+ children.clear();
+ }
+
+ public boolean hasChildren() {
+ return children.size() > 0;
+ }
+
+ public Object getParent() {
+ return parent;
+ }
+
+ public void addChild(final DeltaCloudViewItem element) {
+ children.add(element);
+
+ getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ viewer.add(DeltaCloudViewItem.this, element);
+ }
+ });
+ }
+
+ public void addChildren(final DeltaCloudViewItem[] elements) {
+ for (DeltaCloudViewItem element : elements) {
+ children.add(element);
+ }
+
+ getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ viewer.add(DeltaCloudViewItem.this, elements);
+ }
+ });
+ }
+
+ public void removeChild(final DeltaCloudViewItem element) {
+
+ getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (element != null) {
+ int index = children.indexOf(element);
+ viewer.remove(DeltaCloudViewItem.this, index);
+ }
+ }
+ });
+ }
+
+ protected void expand() {
+ getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ viewer.setExpandedState(DeltaCloudViewItem.this, true);
+ }
+ });
+ }
+
+ public Object getModel() {
+ return model;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ IPropertySource p = getPropertySource();
+ return p;
+ }
+ return null;
+ }
+
+ public abstract IPropertySource getPropertySource();
+
+ private void initDisposeListener(Viewer viewer) {
+ final Control control = viewer.getControl();
+ control.getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ control.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ }
+ });
+ }
+ });
+ }
+
+ protected Display getDisplay() {
+ return viewer.getControl().getDisplay();
+ }
+
+ protected void dispose() {
+ // nothing to do
+ }
+}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewLabelProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewLabelProvider.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudViewLabelProvider.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -18,14 +18,14 @@
@Override
public Image getImage(Object element) {
- if (element instanceof CloudViewElement) {
+ if (element instanceof CloudItem) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_CLOUD);
- } else if (element instanceof CloudElementCategoryViewElement ||
- element instanceof NumericFoldingViewElement) {
+ } else if (element instanceof CloudElementCategoryItem ||
+ element instanceof NumericFoldingItem) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_FOLDER);
- } else if (element instanceof InstanceViewElement) {
+ } else if (element instanceof InstanceItem) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_INSTANCE);
- } else if (element instanceof ImageViewElement) {
+ } else if (element instanceof ImageItem) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_IMAGE);
}
return null;
@@ -33,7 +33,7 @@
@Override
public String getText(Object element) {
- DeltaCloudViewElement e = (DeltaCloudViewElement)element;
+ DeltaCloudViewItem e = (DeltaCloudViewItem)element;
return e.getName();
}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloudImage;
+import org.jboss.tools.deltacloud.ui.views.cloud.property.ImagePropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class ImageItem extends DeltaCloudViewItem {
+
+ protected ImageItem(Object model, DeltaCloudViewItem parent, TreeViewer viewer) {
+ super(model, parent, viewer);
+ }
+
+ public String getName() {
+ Object element = getModel();
+ if (element instanceof DeltaCloudImage) {
+ return ((DeltaCloudImage) element).getName();
+ } else {
+ return "";
+ }
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ return new ImagePropertySource(getModel());
+ }
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImageViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloudImage;
-import org.jboss.tools.deltacloud.ui.views.cloud.property.ImagePropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class ImageViewElement extends DeltaCloudViewElement {
-
- protected ImageViewElement(Object model, DeltaCloudViewElement parent, TreeViewer
viewer) {
- super(model, parent, viewer);
- }
-
- public String getName() {
- Object element = getModel();
- if (element instanceof DeltaCloudImage) {
- return ((DeltaCloudImage) element).getName();
- } else {
- return "";
- }
- }
-
- @Override
- public IPropertySource getPropertySource() {
- return new ImagePropertySource(getModel());
- }
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.viewers.TreeViewer;
+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.GetImagesCommand;
+import org.jboss.tools.deltacloud.core.IImageFilter;
+import org.jboss.tools.deltacloud.core.IImageListListener;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.views.CVMessages;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class ImagesCategoryItem extends CloudElementCategoryItem<DeltaCloudImage>
implements IImageListListener {
+
+ private static final String IMAGE_CATEGORY_NAME = "ImageCategoryName";
//$NON-NLS-1$
+
+ protected ImagesCategoryItem(Object model, DeltaCloudViewItem parent, TreeViewer viewer)
{
+ super(model, parent, viewer);
+ }
+
+ public String getName() {
+ return CVMessages.getString(IMAGE_CATEGORY_NAME);
+ }
+
+ @Override
+ protected void asyncGetCloudElements() {
+ setLoadingIndicator();
+ new GetImagesCommand(getCloud()){
+
+ @Override
+ protected void asyncGetImages() throws DeltaCloudException {
+ try {
+ super.asyncGetImages();
+ } catch(DeltaCloudException e) {
+ clearChildren();
+ throw e;
+ }
+ }
+
+ }.execute();
+ }
+
+ @Override
+ protected DeltaCloudViewItem[] getElements(Object[] modelElements, int startIndex, int
stopIndex) {
+ DeltaCloudViewItem[] elements = new DeltaCloudViewItem[stopIndex - startIndex];
+ for (int i = startIndex; i < stopIndex; ++i) {
+ elements[i - startIndex] = new ImageItem(modelElements[i], this, viewer);
+ }
+ return elements;
+ }
+
+ @Override
+ public synchronized void listChanged(DeltaCloud cloud, DeltaCloudImage[] newImages) {
+ try {
+ onListChanged(cloud, newImages);
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.handleError(
+ "Error",
+ MessageFormat.format("Could not get images from cloud \"{0}\"",
cloud.getName()), e,
+ viewer.getControl().getShell());
+ }
+ }
+
+ @Override
+ protected DeltaCloudImage[] filter(DeltaCloudImage[] images) throws DeltaCloudException
{
+ DeltaCloud cloud = (DeltaCloud) getModel();
+ IImageFilter f = cloud.getImageFilter();
+ return f.filter(images).toArray(new DeltaCloudImage[images.length]);
+ }
+
+ protected void addCloudElementListener(DeltaCloud cloud) {
+ if (cloud != null) {
+ cloud.addImageListListener(this);
+ }
+ }
+
+ protected void removeCloudElementListener(DeltaCloud cloud) {
+ if (cloud != null) {
+ cloud.removeImageListListener(this);
+ }
+ }
+
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/ImagesCategoryViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.text.MessageFormat;
-
-import org.eclipse.jface.viewers.TreeViewer;
-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.GetImagesCommand;
-import org.jboss.tools.deltacloud.core.IImageFilter;
-import org.jboss.tools.deltacloud.core.IImageListListener;
-import org.jboss.tools.deltacloud.ui.ErrorUtils;
-import org.jboss.tools.deltacloud.ui.views.CVMessages;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class ImagesCategoryViewElement extends
CloudElementCategoryViewElement<DeltaCloudImage> implements IImageListListener {
-
- private static final String IMAGE_CATEGORY_NAME = "ImageCategoryName";
//$NON-NLS-1$
-
- protected ImagesCategoryViewElement(Object model, DeltaCloudViewElement parent,
TreeViewer viewer) {
- super(model, parent, viewer);
- }
-
- public String getName() {
- return CVMessages.getString(IMAGE_CATEGORY_NAME);
- }
-
- @Override
- protected void asyncGetCloudElements() {
- setLoadingIndicator();
- new GetImagesCommand(getCloud()){
-
- @Override
- protected void asyncGetImages() throws DeltaCloudException {
- try {
- super.asyncGetImages();
- } catch(DeltaCloudException e) {
- clearChildren();
- throw e;
- }
- }
-
- }.execute();
- }
-
- @Override
- protected DeltaCloudViewElement[] getElements(Object[] modelElements, int startIndex,
int stopIndex) {
- DeltaCloudViewElement[] elements = new DeltaCloudViewElement[stopIndex - startIndex];
- for (int i = startIndex; i < stopIndex; ++i) {
- elements[i - startIndex] = new ImageViewElement(modelElements[i], this, viewer);
- }
- return elements;
- }
-
- @Override
- public synchronized void listChanged(DeltaCloud cloud, DeltaCloudImage[] newImages) {
- try {
- onListChanged(cloud, newImages);
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Could not get images from cloud \"{0}\"",
cloud.getName()), e,
- viewer.getControl().getShell());
- }
- }
-
- @Override
- protected DeltaCloudImage[] filter(DeltaCloudImage[] images) throws DeltaCloudException
{
- DeltaCloud cloud = (DeltaCloud) getModel();
- IImageFilter f = cloud.getImageFilter();
- return f.filter(images).toArray(new DeltaCloudImage[images.length]);
- }
-
- protected void addCloudElementListener(DeltaCloud cloud) {
- if (cloud != null) {
- cloud.addImageListListener(this);
- }
- }
-
- protected void removeCloudElementListener(DeltaCloud cloud) {
- if (cloud != null) {
- cloud.removeImageListListener(this);
- }
- }
-
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.views.cloud.property.InstancePropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class InstanceItem extends DeltaCloudViewItem {
+
+ protected InstanceItem(Object model, DeltaCloudViewItem parent, TreeViewer viewer) {
+ super(model, parent, viewer);
+ }
+
+ public String getName() {
+ Object element = getModel();
+ StringBuilder sb = new StringBuilder();
+ if (element instanceof DeltaCloudInstance) {
+ DeltaCloudInstance instance = (DeltaCloudInstance) element;
+ if (instance.getName() != null) {
+ sb.append(instance.getName());
+ }
+ if (instance.getId() != null) {
+ sb.append(" [").append(instance.getId()).append("] ");
+ }
+ }
+ return sb.toString();
+
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ return new InstancePropertySource(this, getModel());
+ }
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstanceViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.views.cloud.property.InstancePropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class InstanceViewElement extends DeltaCloudViewElement {
-
- protected InstanceViewElement(Object model, DeltaCloudViewElement parent, TreeViewer
viewer) {
- super(model, parent, viewer);
- }
-
- public String getName() {
- Object element = getModel();
- StringBuilder sb = new StringBuilder();
- if (element instanceof DeltaCloudInstance) {
- DeltaCloudInstance instance = (DeltaCloudInstance) element;
- if (instance.getName() != null) {
- sb.append(instance.getName());
- }
- if (instance.getId() != null) {
- sb.append(" [").append(instance.getId()).append("] ");
- }
- }
- return sb.toString();
-
- }
-
- @Override
- public IPropertySource getPropertySource() {
- return new InstancePropertySource(this, getModel());
- }
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * 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;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.GetInstancesCommand;
+import org.jboss.tools.deltacloud.core.IInstanceFilter;
+import org.jboss.tools.deltacloud.core.IInstanceListListener;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.views.CVMessages;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class InstancesCategoryItem extends
CloudElementCategoryItem<DeltaCloudInstance> implements IInstanceListListener {
+
+ private static final String INSTANCE_CATEGORY_NAME = "InstanceCategoryName";
//$NON-NLS-1$
+
+ protected InstancesCategoryItem(Object model, DeltaCloudViewItem parent, TreeViewer
viewer) {
+ super(model, parent, viewer);
+ }
+
+ public String getName() {
+ return CVMessages.getString(INSTANCE_CATEGORY_NAME);
+ }
+
+ @Override
+ protected void asyncGetCloudElements() {
+ setLoadingIndicator();
+ new GetInstancesCommand(getCloud()){
+
+ @Override
+ protected void asyncGetInstances() throws DeltaCloudException {
+ try {
+ super.asyncGetInstances();
+ } catch(DeltaCloudException e) {
+ clearChildren();
+ throw e;
+ }
+ }
+
+ }.execute();
+ }
+
+ @Override
+ protected DeltaCloudViewItem[] getElements(Object[] modelElements, int startIndex, int
stopIndex) {
+ DeltaCloudViewItem[] elements = new DeltaCloudViewItem[stopIndex - startIndex];
+ for (int i = startIndex; i < stopIndex; ++i) {
+ elements[i - startIndex] = new InstanceItem(modelElements[i], this, viewer);
+ }
+ return elements;
+ }
+
+ @Override
+ public void listChanged(DeltaCloud cloud, DeltaCloudInstance[] newInstances) {
+ try {
+ onListChanged(cloud, newInstances);
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.handleError(
+ "Error",
+ MessageFormat.format("Could not get instances from cloud
\"{0}\"", cloud.getName()), e,
+ viewer.getControl().getShell());
+ }
+ }
+
+ @Override
+ protected DeltaCloudInstance[] filter(DeltaCloudInstance[] instances) throws
DeltaCloudException {
+ DeltaCloud cloud = (DeltaCloud) getModel();
+ IInstanceFilter f = cloud.getInstanceFilter();
+ return f.filter(instances).toArray(new DeltaCloudInstance[instances.length]);
+ }
+
+ protected void addCloudElementListener(DeltaCloud cloud) {
+ if (cloud != null) {
+ cloud.addInstanceListListener(this);
+ }
+ }
+
+ protected void removeCloudElementListener(DeltaCloud cloud) {
+ if (cloud != null) {
+ cloud.removeInstanceListListener(this);
+ }
+ }
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/InstancesCategoryViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.text.MessageFormat;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.DeltaCloudException;
-import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.core.GetInstancesCommand;
-import org.jboss.tools.deltacloud.core.IInstanceFilter;
-import org.jboss.tools.deltacloud.core.IInstanceListListener;
-import org.jboss.tools.deltacloud.ui.ErrorUtils;
-import org.jboss.tools.deltacloud.ui.views.CVMessages;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class InstancesCategoryViewElement extends
CloudElementCategoryViewElement<DeltaCloudInstance> implements IInstanceListListener
{
-
- private static final String INSTANCE_CATEGORY_NAME = "InstanceCategoryName";
//$NON-NLS-1$
-
- protected InstancesCategoryViewElement(Object model, DeltaCloudViewElement parent,
TreeViewer viewer) {
- super(model, parent, viewer);
- }
-
- public String getName() {
- return CVMessages.getString(INSTANCE_CATEGORY_NAME);
- }
-
- @Override
- protected void asyncGetCloudElements() {
- setLoadingIndicator();
- new GetInstancesCommand(getCloud()){
-
- @Override
- protected void asyncGetInstances() throws DeltaCloudException {
- try {
- super.asyncGetInstances();
- } catch(DeltaCloudException e) {
- clearChildren();
- throw e;
- }
- }
-
- }.execute();
- }
-
- @Override
- protected DeltaCloudViewElement[] getElements(Object[] modelElements, int startIndex,
int stopIndex) {
- DeltaCloudViewElement[] elements = new DeltaCloudViewElement[stopIndex - startIndex];
- for (int i = startIndex; i < stopIndex; ++i) {
- elements[i - startIndex] = new InstanceViewElement(modelElements[i], this, viewer);
- }
- return elements;
- }
-
- @Override
- public void listChanged(DeltaCloud cloud, DeltaCloudInstance[] newInstances) {
- try {
- onListChanged(cloud, newInstances);
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Could not get instances from cloud
\"{0}\"", cloud.getName()), e,
- viewer.getControl().getShell());
- }
- }
-
- @Override
- protected DeltaCloudInstance[] filter(DeltaCloudInstance[] instances) throws
DeltaCloudException {
- DeltaCloud cloud = (DeltaCloud) getModel();
- IInstanceFilter f = cloud.getInstanceFilter();
- return f.filter(instances).toArray(new DeltaCloudInstance[instances.length]);
- }
-
- protected void addCloudElementListener(DeltaCloud cloud) {
- if (cloud != null) {
- cloud.addInstanceListListener(this);
- }
- }
-
- protected void removeCloudElementListener(DeltaCloud cloud) {
- if (cloud != null) {
- cloud.removeInstanceListListener(this);
- }
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * A tree element that shows the user that the tree is currently loading
- * elements
- */
-public class LoadingCloudElementViewElement extends DeltaCloudViewElement {
-
- protected LoadingCloudElementViewElement(DeltaCloudViewElement parent, TreeViewer
viewer) {
- super(null, parent, viewer);
- }
-
- @Override
- public IPropertySource getPropertySource() {
- // no property source for this element
- return null;
- }
-
- @Override
- public String getName() {
- // TODO: internationalize strings
- return "Loading...";
- }
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingCloudElementViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/LoadingItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * A tree element that shows the user that the tree is currently loading
+ * elements
+ */
+public class LoadingItem extends DeltaCloudViewItem {
+
+ protected LoadingItem(DeltaCloudViewItem parent, TreeViewer viewer) {
+ super(null, parent, viewer);
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ // no property source for this element
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ // TODO: internationalize strings
+ return "Loading...";
+ }
+}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class NumericFoldingItem extends DeltaCloudViewItem {
+
+ public static int FOLDING_SIZE = 50;
+ private Object min;
+ private int max;
+
+ protected NumericFoldingItem(int min, int max, DeltaCloudViewItem parent, TreeViewer
viewer) {
+ super(null, parent, viewer);
+ this.min = min;
+ this.max = max;
+ }
+
+ @Override
+ public String getName() {
+ return new StringBuilder()
+ .append("[")
+ .append(min)
+ .append("..")
+ .append(max - 1)
+ .append("]").toString();
+ }
+
+ @Override
+ public Object[] getChildren() {
+ return super.getChildren();
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return true;
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ return null;
+ }
+
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/NumericFoldingViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class NumericFoldingViewElement extends DeltaCloudViewElement {
-
- public static int FOLDING_SIZE = 50;
- private Object min;
- private int max;
-
- protected NumericFoldingViewElement(int min, int max, DeltaCloudViewElement parent,
TreeViewer viewer) {
- super(null, parent, viewer);
- this.min = min;
- this.max = max;
- }
-
- @Override
- public String getName() {
- return new StringBuilder()
- .append("[")
- .append(min)
- .append("..")
- .append(max - 1)
- .append("]").toString();
- }
-
- @Override
- public Object[] getChildren() {
- return super.getChildren();
- }
-
- @Override
- public boolean hasChildren() {
- return true;
- }
-
- @Override
- public IPropertySource getPropertySource() {
- return null;
- }
-
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootItem.java
(from rev 27210,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootItem.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootItem.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.ICloudManagerListener;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
+
+/**
+ * @author Jeff Johnston
+ * @author Andre Dietisheim
+ */
+public class RootItem extends DeltaCloudViewItem implements ICloudManagerListener {
+
+ protected RootItem(TreeViewer viewer) {
+ super(DeltaCloudManager.getDefault(), null, viewer); //$NON-NLS-1$
+ DeltaCloudManager.getDefault().addCloudManagerListener(this);
+ }
+
+ @Override
+ public String getName() {
+ return "root"; //$NON-NLS-1$
+ }
+
+ @Override
+ public IPropertySource getPropertySource() {
+ // no property source for the root element
+ return null;
+ }
+
+ @Override
+ public Object[] getChildren() {
+ if (!initialized.get()) {
+ DeltaCloudManager m = DeltaCloudManager.getDefault();
+ try {
+ addClouds(m.getClouds());
+ } catch (DeltaCloudException e) {
+ // TODO: internationalize strings
+ ErrorUtils.handleError("Error", "Could not get clouds", e,
Display.getDefault().getActiveShell());
+ } finally {
+ initialized.set(true);
+ }
+ }
+ return super.getChildren();
+ }
+
+ private void addClouds(DeltaCloud[] clouds) {
+ for (DeltaCloud cloud : clouds) {
+ addCloud(cloud);
+ }
+ }
+
+ private void addCloud(DeltaCloud cloud) {
+ CloudItem e = new CloudItem(cloud, this, viewer);
+ children.add(e);
+ }
+
+ private DeltaCloudViewItem getCloudViewElement(DeltaCloud cloudToMatch) {
+ for (DeltaCloudViewItem cloudElement : children) {
+ DeltaCloud cloud = (DeltaCloud) cloudElement.getModel();
+ if (cloudToMatch.equals(cloud)) {
+ return cloudElement;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ DeltaCloudManager.getDefault().removeCloudManagerListener(this);
+ }
+
+ public void cloudsChanged(int type, DeltaCloud cloud) {
+ switch (type) {
+ case ICloudManagerListener.ADD_EVENT:
+ addChild(new CloudItem(cloud, this, viewer));
+ break;
+ case ICloudManagerListener.REMOVE_EVENT:
+ removeChild(getCloudViewElement(cloud));
+ break;
+ case ICloudManagerListener.RENAME_EVENT:
+ DeltaCloudViewItem cloudViewElement = getCloudViewElement(cloud);
+ viewer.refresh(cloudViewElement);
+ break;
+ }
+ initialized.set(true);
+ }
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/RootViewElement.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.DeltaCloudException;
-import org.jboss.tools.deltacloud.core.DeltaCloudManager;
-import org.jboss.tools.deltacloud.core.ICloudManagerListener;
-import org.jboss.tools.deltacloud.ui.ErrorUtils;
-
-/**
- * @author Jeff Johnston
- * @author Andre Dietisheim
- */
-public class RootViewElement extends DeltaCloudViewElement implements
ICloudManagerListener {
-
- protected RootViewElement(TreeViewer viewer) {
- super(DeltaCloudManager.getDefault(), null, viewer); //$NON-NLS-1$
- DeltaCloudManager.getDefault().addCloudManagerListener(this);
- }
-
- @Override
- public String getName() {
- return "root"; //$NON-NLS-1$
- }
-
- @Override
- public IPropertySource getPropertySource() {
- // no property source for the root element
- return null;
- }
-
- @Override
- public Object[] getChildren() {
- if (!initialized.get()) {
- DeltaCloudManager m = DeltaCloudManager.getDefault();
- try {
- addClouds(m.getClouds());
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError("Error", "Could not get clouds", e,
Display.getDefault().getActiveShell());
- } finally {
- initialized.set(true);
- }
- }
- return super.getChildren();
- }
-
- private void addClouds(DeltaCloud[] clouds) {
- for (DeltaCloud cloud : clouds) {
- addCloud(cloud);
- }
- }
-
- private void addCloud(DeltaCloud cloud) {
- CloudViewElement e = new CloudViewElement(cloud, this, viewer);
- children.add(e);
- }
-
- private DeltaCloudViewElement getCloudViewElement(DeltaCloud cloudToMatch) {
- for (DeltaCloudViewElement cloudElement : children) {
- DeltaCloud cloud = (DeltaCloud) cloudElement.getModel();
- if (cloudToMatch.equals(cloud)) {
- return cloudElement;
- }
- }
- return null;
- }
-
- @Override
- public void dispose() {
- DeltaCloudManager.getDefault().removeCloudManagerListener(this);
- }
-
- public void cloudsChanged(int type, DeltaCloud cloud) {
- switch (type) {
- case ICloudManagerListener.ADD_EVENT:
- addChild(new CloudViewElement(cloud, this, viewer));
- break;
- case ICloudManagerListener.REMOVE_EVENT:
- removeChild(getCloudViewElement(cloud));
- break;
- case ICloudManagerListener.RENAME_EVENT:
- DeltaCloudViewElement cloudViewElement = getCloudViewElement(cloud);
- viewer.refresh(cloudViewElement);
- break;
- }
- initialized.set(true);
- }
-}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -21,7 +21,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.deltacloud.ui.views.cloud.InstanceViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.InstanceItem;
import org.jboss.tools.internal.deltacloud.ui.utils.CloudViewElementUtils;
public class InstancePropertySource implements IPropertySource {
@@ -49,7 +49,7 @@
private DeltaCloudInstance instance;
private DeltaCloud cloud;
- public InstancePropertySource(InstanceViewElement element, Object o) {
+ public InstancePropertySource(InstanceItem element, Object o) {
cloud = CloudViewElementUtils.getCloud(element);
instance = (DeltaCloudInstance) o;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java 2010-12-08
17:43:10 UTC (rev 27245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/CloudViewElementUtils.java 2010-12-08
17:48:54 UTC (rev 27246)
@@ -11,8 +11,8 @@
package org.jboss.tools.internal.deltacloud.ui.utils;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.ui.views.cloud.CloudViewElement;
-import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewElement;
+import org.jboss.tools.deltacloud.ui.views.cloud.CloudItem;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudViewItem;
public class CloudViewElementUtils {
@@ -21,13 +21,13 @@
*
* @param element
* the cloud view element to get the DeltaCloud for
- * @return the cloud for the given CloudViewElement
+ * @return the cloud for the given CloudItem
*
* @see DeltaCloud
- * @see DeltaCloudViewElement
+ * @see DeltaCloudViewItem
*/
- public static DeltaCloud getCloud(DeltaCloudViewElement element) {
- CloudViewElement cvCloud = getCVCloudElement(element);
+ public static DeltaCloud getCloud(DeltaCloudViewItem element) {
+ CloudItem cvCloud = getCVCloudElement(element);
if (cvCloud == null) {
return null;
}
@@ -40,17 +40,17 @@
*
* @param element
* the cloud view element to get the CVCloudElement for
- * @return the CVCloudElement for the given CloudViewElement
+ * @return the CVCloudElement for the given CloudItem
*
- * @see DeltaCloudViewElement
- * @see CloudViewElement
+ * @see DeltaCloudViewItem
+ * @see CloudItem
*/
- public static CloudViewElement getCVCloudElement(DeltaCloudViewElement element) {
- while (!(element instanceof CloudViewElement)
+ public static CloudItem getCVCloudElement(DeltaCloudViewItem element) {
+ while (!(element instanceof CloudItem)
&& element != null) {
- element = (DeltaCloudViewElement) element.getParent();
+ element = (DeltaCloudViewItem) element.getParent();
}
- return (CloudViewElement) element;
+ return (CloudItem) element;
}
}