Author: adietish
Date: 2010-12-03 15:05:27 -0500 (Fri, 03 Dec 2010)
New Revision: 27174
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudElementViewLabelAndContentProvider.java
Log:
[JBIDE-7688] cleanup
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudElementViewLabelAndContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudElementViewLabelAndContentProvider.java 2010-12-03
19:41:10 UTC (rev 27173)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/AbstractCloudElementViewLabelAndContentProvider.java 2010-12-03
20:05:27 UTC (rev 27174)
@@ -12,15 +12,12 @@
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.BaseLabelProvider;
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.ICloudElementFilter;
import org.jboss.tools.deltacloud.core.IDeltaCloudElement;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
@@ -35,48 +32,36 @@
public abstract class AbstractCloudElementViewLabelAndContentProvider<CLOUDELEMENT
extends IDeltaCloudElement> extends
BaseLabelProvider implements ITableContentAndLabelProvider {
- private DeltaCloud cloud;
- private Collection<CLOUDELEMENT> cloudElements;
private ICloudElementFilter<CLOUDELEMENT> localFilter;
@Override
- public Object[] getElements(Object inputElement) {
- if (cloudElements == null) {
- return new DeltaCloudImage[] {};
- }
- return cloudElements.toArray();
- }
-
- public void setFilter(ICloudElementFilter<CLOUDELEMENT> filter) {
- this.localFilter = filter;
- }
-
- @Override
- public void dispose() {
- this.cloud = null;
- this.cloudElements = null;
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput != null) {
+ public Object[] getElements(Object input) {
+ Object[] elements = new Object[] {};
+ if (input instanceof DeltaCloud) {
+ DeltaCloud cloud = (DeltaCloud) input;
try {
- Assert.isLegal(newInput instanceof DeltaCloud);
- this.cloud = (DeltaCloud) newInput;
CLOUDELEMENT[] cloudElements = getCloudElements(cloud);
ICloudElementFilter<CLOUDELEMENT> filter = getCloudFilter(cloud);
- this.cloudElements = filter(filter, cloudElements);
+ elements = filter(filter, cloudElements).toArray();
} catch (DeltaCloudException e) {
- this.cloudElements = Collections.emptyList();
// TODO: internationalize strings
ErrorUtils.handleError(
"Error",
"Could not display elements for cloud " + cloud.getName(),
- e, viewer.getControl().getShell());
+ e, Display.getDefault().getActiveShell());
}
}
+ return elements;
}
+ public void setFilter(ICloudElementFilter<CLOUDELEMENT> filter) {
+ this.localFilter = filter;
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
protected Collection<CLOUDELEMENT> filter(ICloudElementFilter<CLOUDELEMENT>
filter, CLOUDELEMENT[] cloudElements)
throws DeltaCloudException {
if (filter == null && cloudElements != null) {