JBoss Tools SVN: r27247 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-08 13:11:44 -0500 (Wed, 08 Dec 2010)
New Revision: 27247
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java
Log:
[JBIDE-7847] corrected instance view listening to selection changes in itself.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java 2010-12-08 17:48:54 UTC (rev 27246)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java 2010-12-08 18:11:44 UTC (rev 27247)
@@ -49,6 +49,7 @@
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
+import org.jboss.tools.deltacloud.ui.views.cloud.DeltaCloudView;
import org.jboss.tools.internal.deltacloud.ui.preferences.TextPreferenceValue;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
@@ -87,8 +88,6 @@
return;
}
-// removeListener(currentCloud);
-
AbstractCloudElementTableView.this.currentCloud = getCurrentCloud(index, getClouds());
if (currentCloud != null) {
lastSelectedCloudPref.store(currentCloud.getName());
@@ -97,7 +96,6 @@
@Override
public void run() {
setViewerInput(currentCloud);
-// addListener(currentCloud);
}
});
}
@@ -108,22 +106,16 @@
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
- if (cloud != null) {
- currentCloudSelector.select(getCloudIndex(cloud, getClouds()));
+ if (DeltaCloudView.class.equals(part.getClass())) {
+ // we want to listen to selection changes in the deltacloud view only
+ DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ if (cloud != null) {
+ currentCloudSelector.select(getCloudIndex(cloud, getClouds()));
+ }
}
}
};
-// private Job viewerInputJob = new Job("") {
-//
-// @Override
-// protected IStatus run(IProgressMonitor monitor) {
-//
-// return Status.OK_STATUS;
-// }
-// };
-
public AbstractCloudElementTableView() {
lastSelectedCloudPref = new TextPreferenceValue(getSelectedCloudPrefsKey(), Activator.getDefault());
}
@@ -181,7 +173,6 @@
currentCloud = getCurrentCloud(currentCloudSelector.getSelectionIndex(), clouds);
-// addListener(currentCloud);
setViewerInput(currentCloud);
setFilterLabelVisible(currentCloud, filterLabel);
14 years
JBoss Tools SVN: r27246 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/adapter and 4 other directories.
by jbosstools-commits@lists.jboss.org
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;
}
}
14 years
JBoss Tools SVN: r27245 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-08 12:43:10 -0500 (Wed, 08 Dec 2010)
New Revision: 27245
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/CloudViewElement.java
Log:
corrected warnings
Modified: 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:08:06 UTC (rev 27244)
+++ 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)
@@ -46,19 +46,13 @@
public synchronized Object[] getChildren() {
if (!initialized.get()) {
DeltaCloud cloud = (DeltaCloud) getModel();
- CloudElementCategoryViewElement instances = new InstancesCategoryViewElement(cloud, this, viewer);
- addCategory(instances);
- CloudElementCategoryViewElement images = new ImagesCategoryViewElement(cloud, this, viewer);
- addCategory(images);
+ children.add(new InstancesCategoryViewElement(cloud, this, viewer));
+ children.add(new ImagesCategoryViewElement(cloud, this, viewer));
}
initialized.set(true);
return super.getChildren();
}
- private void addCategory(CloudElementCategoryViewElement categoryElement) {
- children.add(categoryElement);
- }
-
@Override
public IPropertySource getPropertySource() {
return new CloudPropertySource(getModel());
14 years
JBoss Tools SVN: r27244 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-08 12:08:06 -0500 (Wed, 08 Dec 2010)
New Revision: 27244
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/RefreshImagesHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
Log:
[JBIDE-7594] started scheduling rules. need further refinement.
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:07:45 UTC (rev 27243)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-12-08 17:08:06 UTC (rev 27244)
@@ -20,10 +20,10 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.jboss.tools.deltacloud.core.AbstractCloudJob;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
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.internal.deltacloud.ui.utils.CloudViewElementUtils;
@@ -50,7 +50,7 @@
final DeltaCloud cloud = CloudViewElementUtils.getCloud(cloudViewElement);
if (cloud != null) {
// TODO: internationalize strings
- new AbstractCloudJob("Refreshing images and instances on " + cloud.getName()) {
+ new AbstractCloudJob("Refreshing images and instances on " + cloud.getName(), cloud) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java 2010-12-08 17:07:45 UTC (rev 27243)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java 2010-12-08 17:08:06 UTC (rev 27244)
@@ -20,10 +20,10 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.jboss.tools.deltacloud.core.AbstractCloudJob;
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.job.AbstractCloudJob;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
@@ -47,7 +47,7 @@
final DeltaCloud cloud = deltaCloudImage.getDeltaCloud();
if (cloud != null) {
// TODO: internationalize strings
- new AbstractCloudJob("Refreshing images on cloud " + cloud.getName()) {
+ new AbstractCloudJob("Refreshing images on cloud " + cloud.getName(), cloud) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-12-08 17:07:45 UTC (rev 27243)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-12-08 17:08:06 UTC (rev 27244)
@@ -20,10 +20,10 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.jboss.tools.deltacloud.core.AbstractCloudJob;
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.job.AbstractCloudJob;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
@@ -47,7 +47,7 @@
final DeltaCloud cloud = deltaCloudInstance.getDeltaCloud();
if (cloud != null) {
// TODO: internationalize strings
- new AbstractCloudJob("Refreshing instances on cloud " + cloud.getName()) {
+ new AbstractCloudJob("Refreshing instances on cloud " + cloud.getName(), cloud) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
14 years
JBoss Tools SVN: r27243 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core: META-INF and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-08 12:07:45 -0500 (Wed, 08 Dec 2010)
New Revision: 27243
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudJob.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java
Log:
[JBIDE-7594] started scheduling rules. need further refinement.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-08 17:00:00 UTC (rev 27242)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-08 17:07:45 UTC (rev 27243)
@@ -1,5 +1,10 @@
2010-12-08 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java:
+ * src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java:
+ * src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java:
+ * src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java:
+ [JBIDE-7594] started scheduling rules. need further refinement.
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getImage):
[JBIDE-7834] implemented #getLastImage(id) that queries the local cache and the server (fallback),
removed #getImage(String id), #loadImage(String imageId), removed #findInstanceById
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF 2010-12-08 17:00:00 UTC (rev 27242)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF 2010-12-08 17:07:45 UTC (rev 27243)
@@ -13,7 +13,8 @@
Export-Package: org.apache.http.client.methods;x-friends:="org.jboss.tools.deltacloud.test",
org.jboss.tools.deltacloud.core;x-friends:="org.jboss.tools.deltacloud.ui,org.jboss.tools.deltacloud.test",
org.jboss.tools.deltacloud.core.client;x-friends:="org.jboss.tools.deltacloud.test,org.jboss.tools.deltacloud.ui",
- org.jboss.tools.deltacloud.core.client.request;x-friends:="org.jboss.tools.deltacloud.test"
+ org.jboss.tools.deltacloud.core.client.request;x-friends:="org.jboss.tools.deltacloud.test",
+ org.jboss.tools.deltacloud.core.job
Bundle-ClassPath: .,
lib/apache-mime4j-0.6.jar,
lib/commons-codec-1.3.jar,
Deleted: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudJob.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudJob.java 2010-12-08 17:00:00 UTC (rev 27242)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudJob.java 2010-12-08 17:07:45 UTC (rev 27243)
@@ -1,45 +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.core;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.Job;
-import org.jboss.tools.common.log.StatusFactory;
-
-/**
- * @author André Dietisheim
- */
-public abstract class AbstractCloudJob extends Job {
-
- public AbstractCloudJob(String name) {
- super(name);
- // setUser(true);
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
- monitor.worked(1);
- try {
- return doRun(monitor);
- } catch (Exception e) {
- // TODO: internationalize strings
- return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
- MessageFormat.format("Could not {0}", getName()));
- }
- }
-
- protected abstract IStatus doRun(IProgressMonitor monitor) throws Exception;
-
-}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java 2010-12-08 17:00:00 UTC (rev 27242)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetImagesCommand.java 2010-12-08 17:07:45 UTC (rev 27243)
@@ -15,6 +15,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
/**
* @author Andre Dietisheim
@@ -28,7 +29,7 @@
public void execute() {
// TODO: internationalize strings
new AbstractCloudJob(
- MessageFormat.format("Get images from cloud {0}", getCloud().getName())) {
+ MessageFormat.format("Get images from cloud {0}", getCloud().getName()), getCloud()) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java 2010-12-08 17:00:00 UTC (rev 27242)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/GetInstancesCommand.java 2010-12-08 17:07:45 UTC (rev 27243)
@@ -15,6 +15,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
/**
* @author Andre Dietisheim
@@ -28,7 +29,7 @@
public void execute() {
// TODO: internationalize strings
new AbstractCloudJob(
- MessageFormat.format("Get instances from cloud {0}", getCloud().getName())) {
+ MessageFormat.format("Get instances from cloud {0}", getCloud().getName()), getCloud()) {
@Override
protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java 2010-12-08 17:07:45 UTC (rev 27243)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.core.job;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractCloudElementJob extends AbstractCloudJob {
+
+ public static enum CLOUDELEMENT {
+ IMAGES, INSTANCES
+ }
+
+ private CLOUDELEMENT cloudElement;
+
+ public AbstractCloudElementJob(String name, DeltaCloud cloud, CLOUDELEMENT cloudElement) {
+ super(name, cloud);
+ this.cloudElement = cloudElement;
+ // setUser(true);
+ }
+
+ protected abstract IStatus doRun(IProgressMonitor monitor) throws Exception;
+
+ @Override
+ protected ISchedulingRule getSchedulingRule() {
+ return new CloudElementSchedulingRule(getCloud(), cloudElement);
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java (from rev 27205, trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AbstractCloudJob.java)
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java 2010-12-08 17:07:45 UTC (rev 27243)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.core.job;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.jboss.tools.common.log.StatusFactory;
+import org.jboss.tools.deltacloud.core.Activator;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractCloudJob extends Job {
+
+ private DeltaCloud cloud;
+
+ public AbstractCloudJob(String name, DeltaCloud cloud) {
+ super(name);
+ this.cloud = cloud;
+ // setUser(true);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ ISchedulingRule rule = getSchedulingRule();
+ Job.getJobManager().beginRule(rule, monitor);
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+ monitor.worked(1);
+ try {
+ return doRun(monitor);
+ } catch (Exception e) {
+ // TODO: internationalize strings
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not {0}", getName()));
+ } finally {
+ Job.getJobManager().endRule(rule);
+ }
+ }
+
+ protected DeltaCloud getCloud() {
+ return cloud;
+ }
+
+ protected abstract IStatus doRun(IProgressMonitor monitor) throws Exception;
+
+ protected ISchedulingRule getSchedulingRule() {
+ return new CloudSchedulingRule(cloud);
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java 2010-12-08 17:07:45 UTC (rev 27243)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.core.job;
+
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
+
+/**
+ * A scheduling rule for jobs that prevents 2 jobs from running on the same
+ * cloud instance.
+ *
+ * @author André Dietisheim
+ */
+public class CloudElementSchedulingRule extends CloudSchedulingRule {
+
+ private CLOUDELEMENT element;
+
+ public CloudElementSchedulingRule(DeltaCloud cloud, CLOUDELEMENT element) {
+ super(cloud);
+ this.element = element;
+ }
+
+ @Override
+ public boolean contains(ISchedulingRule rule) {
+ return rule == this;
+ }
+
+ @Override
+ public boolean isConflicting(ISchedulingRule rule) {
+ return super.isConflicting(rule)
+ && isOnSameElement(rule);
+ }
+
+ private boolean isOnSameElement(ISchedulingRule rule) {
+ return rule.getClass().isAssignableFrom(CloudElementSchedulingRule.class)
+ && ((CloudElementSchedulingRule) rule).getCloudElement().equals(element);
+ }
+
+ private CLOUDELEMENT getCloudElement() {
+ return element;
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java 2010-12-08 17:07:45 UTC (rev 27243)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.core.job;
+
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+
+/**
+ * A scheduling rule for jobs that prevents 2 jobs from running on the same
+ * cloud instance.
+ *
+ * @author André Dietisheim
+ */
+public class CloudSchedulingRule implements ISchedulingRule {
+
+ private DeltaCloud cloud;
+
+ public CloudSchedulingRule(DeltaCloud cloud) {
+ this.cloud = cloud;
+ }
+
+ @Override
+ public boolean contains(ISchedulingRule rule) {
+ return rule == this;
+ }
+
+ @Override
+ public boolean isConflicting(ISchedulingRule rule) {
+ return isOnSameCloud(rule);
+ }
+
+ private boolean isOnSameCloud(ISchedulingRule rule) {
+ if (isCloudRule(rule)) {
+ CloudSchedulingRule cloudRule = (CloudSchedulingRule) rule;
+ return cloud.equals(cloudRule.getCloud());
+ } else {
+ return false;
+ }
+ }
+
+ private boolean isCloudRule(ISchedulingRule rule) {
+ return rule.getClass().isAssignableFrom(CloudSchedulingRule.class);
+ }
+
+ private DeltaCloud getCloud() {
+ return cloud;
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years
JBoss Tools SVN: r27242 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-08 12:00:00 -0500 (Wed, 08 Dec 2010)
New Revision: 27242
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
Log:
[JBIDE-7834] simplified binding, fixed find image by id (moved implementation to DeltaCloud)
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-08 16:50:08 UTC (rev 27241)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-08 17:00:00 UTC (rev 27242)
@@ -476,18 +476,30 @@
}
private IObservableValue bindImage(Text imageText, DataBindingContext dbc) {
- UpdateValueStrategy imageUpdateStrategy = new UpdateValueStrategy();
+ UpdateValueStrategy widgetToModelUpdateStrategy = new UpdateValueStrategy();
ImageConverter imageConverter = new ImageConverter();
- imageUpdateStrategy.setConverter(imageConverter);
- imageUpdateStrategy.setAfterGetValidator(
+ widgetToModelUpdateStrategy.setConverter(imageConverter);
+ widgetToModelUpdateStrategy.setAfterGetValidator(
new MandatoryStringValidator(WizardMessages.getString(MUST_ENTER_IMAGE_ID)));
- imageUpdateStrategy.setAfterConvertValidator(new ImageValidator());
+ widgetToModelUpdateStrategy.setAfterConvertValidator(new ImageValidator());
+ UpdateValueStrategy modelToTextUpdateStrategy = new UpdateValueStrategy();
+ modelToTextUpdateStrategy.setConverter(new Converter(DeltaCloudImage.class, String.class) {
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject instanceof DeltaCloudImage) {
+ return ((DeltaCloudImage) fromObject).getName();
+ } else {
+ return "";
+ }
+ }
+ });
+
Binding imageBinding = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observeDelayed(IMAGE_CHECK_DELAY, imageText),
BeanProperties.value(NewInstanceModel.class, NewInstanceModel.PROPERTY_IMAGE).observe(model),
- imageUpdateStrategy,
- null);
+ widgetToModelUpdateStrategy,
+ modelToTextUpdateStrategy);
ControlDecorationSupport.create(imageBinding, SWT.LEFT | SWT.TOP);
return imageConverter.getImageObservable();
}
14 years
JBoss Tools SVN: r27241 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-08 11:50:08 -0500 (Wed, 08 Dec 2010)
New Revision: 27241
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllImageFilter.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java
Log:
[JBIDE-7834] simplified binding, fixed find image by id (moved implementation to DeltaCloud)
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllImageFilter.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllImageFilter.java 2010-12-08 16:44:54 UTC (rev 27240)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllImageFilter.java 2010-12-08 16:50:08 UTC (rev 27241)
@@ -36,12 +36,17 @@
public void setRules(String ruleString) {
// ignore, never set the rules for this filter
}
-
+
@Override
- public String toString() {
- return ALL_STRING;
+ public IFieldMatcher getNameRule() {
+ return matcher;
}
+ @Override
+ public IFieldMatcher getIdRule() {
+ return matcher;
+ }
+
public IFieldMatcher getArchRule() {
return matcher;
}
@@ -50,4 +55,8 @@
return matcher;
}
+ @Override
+ public String toString() {
+ return ALL_STRING;
+ }
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java 2010-12-08 16:44:54 UTC (rev 27240)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java 2010-12-08 16:50:08 UTC (rev 27241)
@@ -27,12 +27,18 @@
// ignore, never set the rules for this filter
}
+
@Override
- public String toString() {
- return ALL_STRING;
+ public IFieldMatcher getNameRule() {
+ return matcher;
}
@Override
+ public IFieldMatcher getIdRule() {
+ return matcher;
+ }
+
+ @Override
public IFieldMatcher getImageIdRule() {
return matcher;
}
@@ -56,4 +62,9 @@
public IFieldMatcher getRealmRule() {
return matcher;
}
+
+ @Override
+ public String toString() {
+ return ALL_STRING;
+ }
}
14 years
JBoss Tools SVN: r27240 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/internal/deltacloud/ui/wizards and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-08 11:44:54 -0500 (Wed, 08 Dec 2010)
New Revision: 27240
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceModel.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
[JBIDE-7834] simplified binding, fixed find image by id (moved implementation to DeltaCloud)
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-08 16:43:42 UTC (rev 27239)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-08 16:44:54 UTC (rev 27240)
@@ -1,5 +1,8 @@
2010-12-08 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
+ (bindWidgets):
+ [JBIDE-7834] simplified binding, fixed find image by id (moved implementation to DeltaCloud)
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java (createWidgets):
[JBIDE-7836] corrected tab order (bad widget creation order)
* src/org/jboss/tools/internal/deltacloud/ui/wizards/FindImageWizard.java:
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceModel.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceModel.java 2010-12-08 16:43:42 UTC (rev 27239)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceModel.java 2010-12-08 16:44:54 UTC (rev 27240)
@@ -10,12 +10,6 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import org.eclipse.core.databinding.conversion.Converter;
-import org.eclipse.core.databinding.validation.IValidator;
-import org.eclipse.core.databinding.validation.ValidationStatus;
-import org.eclipse.core.runtime.IStatus;
-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.internal.deltacloud.ui.common.databinding.ObservablePojo;
@@ -26,88 +20,21 @@
public static final String PROPERTY_URL = "url"; //$NON-NLS-1$
public static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
- public static final String PROPERTY_IMAGE_ID = "imageId"; //$NON-NLS-1$
+ public static final String PROPERTY_IMAGE = "image"; //$NON-NLS-1$
public static final String PROPERTY_ARCH = "arch"; //$NON-NLS-1$
public static final String PROPERTY_REALM = "realm"; //$NON-NLS-1$
public static final String PROPERTY_KEYNAME = "keyname"; //$NON-NLS-1$
public static final String PROPERTY_PROFILE = "profile"; //$NON-NLS-1$
- private static final String IMAGE_ID_NOT_FOUND = "ErrorImageIdNotFound.text"; //$NON-NLS-1$
-
private String name;
- private String imageId;
+ private DeltaCloudImage image;
private String arch;
private String realm;
private String keyname;
private String profile;
- public static class ImageContainer {
- private DeltaCloudImage image;
-
- public DeltaCloudImage getImage() {
- return image;
- }
-
- public void setImage(DeltaCloudImage image) {
- this.image = image;
- }
- }
-
- public static class ArchConverter extends Converter {
-
- private DeltaCloud cloud;
- private ImageContainer imageContainer;
-
- public ArchConverter(DeltaCloud cloud, ImageContainer imageContainer,
- Object fromType, Object toType) {
- super(fromType, toType);
- this.cloud = cloud;
- this.imageContainer = imageContainer;
- }
-
- @Override
- public Object convert(final Object fromObject) {
- try {
- return getArch((String) fromObject);
- } catch (DeltaCloudException e) {
- return ValidationStatus.error("Could find image on the server", e);
- }
- }
-
- private String getArch(String imageId) throws DeltaCloudException {
- String arch = "";
- if (imageId != null && imageId.length() > 0) {
- DeltaCloudImage image = cloud.getImage(imageId);
- if (image != null) {
- imageContainer.setImage(image);
- arch = image.getArchitecture();
- }
- }
- return arch;
- }
- }
-
- public static class ArchValidator implements IValidator {
-
- @Override
- public IStatus validate(Object value) {
- if (value instanceof String
- && ((String) value).length() > 0) {
- return ValidationStatus.ok();
- } else {
- return ValidationStatus.error(WizardMessages.getString(IMAGE_ID_NOT_FOUND));
- }
- }
- }
-
- public NewInstanceModel(String name, String imageId, String arch, String realm,
- String keyname, String profile) {
- this.name = name;
- this.imageId = imageId;
- this.realm = realm;
+ protected NewInstanceModel(String keyname) {
this.keyname = keyname;
- this.profile = profile;
- this.arch = arch;
}
public String getName() {
@@ -118,12 +45,12 @@
getPropertyChangeSupport().firePropertyChange(PROPERTY_NAME, this.name, this.name = name);
}
- public String getImageId() {
- return imageId;
+ public DeltaCloudImage getImage() {
+ return image;
}
- public void setImageId(String imageId) {
- getPropertyChangeSupport().firePropertyChange(PROPERTY_IMAGE_ID, this.imageId, this.imageId = imageId);
+ public void setImage(DeltaCloudImage image) {
+ getPropertyChangeSupport().firePropertyChange(PROPERTY_IMAGE, this.image, this.image = image);
}
public String getRealm() {
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-08 16:43:42 UTC (rev 27239)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-08 16:44:54 UTC (rev 27240)
@@ -21,9 +21,14 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.WidgetProperties;
@@ -85,6 +90,7 @@
private static final String MUST_ENTER_IMAGE_ID = "ErrorMustProvideImageId.text"; //$NON-NLS-1$
private static final String NONE_RESPONSE = "None.response"; //$NON-NLS-1$
private static final String LOADING_VALUE = "Loading.value"; //$NON-NLS-1$
+ private static final String IMAGE_ID_NOT_FOUND = "ErrorImageIdNotFound.text"; //$NON-NLS-1$
private NewInstanceModel model;
@@ -134,18 +140,18 @@
};
- private SelectionListener findListener = new SelectionAdapter() {
+ private SelectionListener findImageButtonListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
Shell shell = getShell();
FindImageWizard wizard = new FindImageWizard(cloud);
- WizardDialog dialog = new CustomWizardDialog(shell, wizard,
- IDialogConstants.OK_LABEL);
+ WizardDialog dialog = new CustomWizardDialog(shell, wizard, IDialogConstants.OK_LABEL);
dialog.create();
dialog.open();
String imageId = wizard.getImageId();
- if (imageId != null)
+ if (imageId != null) {
imageText.setText(imageId);
+ }
}
};
@@ -154,11 +160,7 @@
super(WizardMessages.getString(NAME));
this.cloud = cloud;
String defaultKeyname = cloud.getLastKeyname();
- model = new NewInstanceModel("", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- defaultKeyname, ""); //$NON-NLS-1$
+ model = new NewInstanceModel(defaultKeyname); //$NON-NLS-1$
setDescription(WizardMessages.getString(DESCRIPTION));
setTitle(WizardMessages.getString(TITLE));
setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
@@ -261,51 +263,30 @@
public void createControl(Composite parent) {
DataBindingContext dbc = new DataBindingContext();
WizardPageSupport.create(this, dbc);
- Composite container = createWidgets(parent);
+ Composite control = createWidgets(parent);
bindWidgets(dbc);
launchFetchRealms();
launchFetchProfiles();
- // We have to set the image id here instead of in the constructor
- // of the model because the image id triggers other items to fill
- // in their values such as the architecture and hardware profiles.
- String defaultImage = cloud.getLastImageId();
- model.setImageId(defaultImage);
- setControl(container);
+ // We have to set the imageObservable id here instead of in the
+ // constructor of the model because the imageObservable id triggers
+ // other items to fill in their values such as the architecture
+ // and hardware profiles.
+ try {
+ model.setImage(cloud.getLastImage());
+ } catch (DeltaCloudException e) {
+ // ignore
+ }
+ setControl(control);
- // lastly, if there's already an image set, use it
+ // lastly, if there's already an imageObservable set, use it
if (image != null) {
imageText.setText(image.getId());
filterProfiles();
}
}
- private void bindWidgets(DataBindingContext dbc) {
- bindText(dbc, nameText, NewInstanceModel.PROPERTY_NAME, MUST_ENTER_A_NAME);
- dbc.bindValue(
- WidgetProperties.text(SWT.Modify).observeDelayed(IMAGE_CHECK_DELAY, imageText),
- BeanProperties.value(NewInstanceModel.class, NewInstanceModel.PROPERTY_IMAGE_ID)
- .observe(model),
- new UpdateValueStrategy().setAfterGetValidator(new MandatoryStringValidator(
- WizardMessages.getString(MUST_ENTER_IMAGE_ID))),
- null);
- bindArchLabel(dbc, imageText, arch, this);
-
- IObservableValue realmObservable = WidgetProperties.text().observe(realmCombo);
- dbc.bindValue(
- realmObservable,
- BeanProperties.value(NewInstanceModel.class, NewInstanceModel.PROPERTY_REALM).observe(
- model));
-
- IObservableValue hardwareObservable = WidgetProperties.text().observe(hardware);
- dbc.bindValue(
- hardwareObservable,
- BeanProperties.value(NewInstanceModel.class, NewInstanceModel.PROPERTY_PROFILE).observe(
- model));
- bindText(dbc, keyText, NewInstanceModel.PROPERTY_KEYNAME, MUST_ENTER_A_KEYNAME);
- }
-
private Composite createWidgets(Composite parent) {
final Composite container = new Composite(parent, SWT.NULL);
FormLayout layout = new FormLayout();
@@ -324,7 +305,7 @@
imageText = new Text(container, SWT.BORDER | SWT.SINGLE);
Button findImageButton = new Button(container, SWT.NULL);
findImageButton.setText(WizardMessages.getString(FIND_BUTTON_LABEL));
- findImageButton.addSelectionListener(findListener);
+ findImageButton.addSelectionListener(findImageButtonListener);
Label archLabel = new Label(container, SWT.NULL);
archLabel.setText(WizardMessages.getString(ARCH_LABEL));
@@ -448,6 +429,112 @@
groupContainer.layout();
}
+ private void bindWidgets(DataBindingContext dbc) {
+
+ bindText(nameText, NewInstanceModel.PROPERTY_NAME, WizardMessages.getString(MUST_ENTER_A_NAME), dbc);
+ IObservableValue imageObservable = bindImage(imageText, dbc);
+
+ // arch label
+ imageObservable.addValueChangeListener(new IValueChangeListener() {
+ @Override
+ public void handleValueChange(ValueChangeEvent event) {
+ DeltaCloudImage image = (DeltaCloudImage) event.diff.getNewValue();
+ if (image != null) {
+ arch.setText(image.getArchitecture());
+ } else {
+ arch.setText("");
+ }
+ }
+ });
+
+ // realms
+ IObservableValue realmObservable = WidgetProperties.text().observe(realmCombo);
+ dbc.bindValue(
+ realmObservable,
+ BeanProperties.value(
+ NewInstanceModel.class, NewInstanceModel.PROPERTY_REALM).observe(model));
+
+ // hardware
+ IObservableValue hardwareObservable = WidgetProperties.text().observe(hardware);
+ dbc.bindValue(
+ hardwareObservable,
+ BeanProperties.value(
+ NewInstanceModel.class, NewInstanceModel.PROPERTY_PROFILE).observe(model));
+
+ // key
+ bindText(keyText, NewInstanceModel.PROPERTY_KEYNAME, WizardMessages.getString(MUST_ENTER_A_KEYNAME), dbc);
+ }
+
+ private void bindText(Text text, String property, String errorMessage, DataBindingContext dbc) {
+ Binding textBinding = dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(text),
+ BeanProperties.value(NewInstanceModel.class, property).observe(model),
+ new UpdateValueStrategy().setBeforeSetValidator(
+ new MandatoryStringValidator(errorMessage)),
+ null);
+ ControlDecorationSupport.create(textBinding, SWT.LEFT | SWT.TOP);
+ }
+
+ private IObservableValue bindImage(Text imageText, DataBindingContext dbc) {
+ UpdateValueStrategy imageUpdateStrategy = new UpdateValueStrategy();
+ ImageConverter imageConverter = new ImageConverter();
+ imageUpdateStrategy.setConverter(imageConverter);
+ imageUpdateStrategy.setAfterGetValidator(
+ new MandatoryStringValidator(WizardMessages.getString(MUST_ENTER_IMAGE_ID)));
+ imageUpdateStrategy.setAfterConvertValidator(new ImageValidator());
+
+ Binding imageBinding = dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observeDelayed(IMAGE_CHECK_DELAY, imageText),
+ BeanProperties.value(NewInstanceModel.class, NewInstanceModel.PROPERTY_IMAGE).observe(model),
+ imageUpdateStrategy,
+ null);
+ ControlDecorationSupport.create(imageBinding, SWT.LEFT | SWT.TOP);
+ return imageConverter.getImageObservable();
+ }
+
+ private class ImageValidator implements IValidator {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (value instanceof DeltaCloudImage) {
+ return ValidationStatus.ok();
+ } else {
+ return ValidationStatus.error(WizardMessages.getFormattedString(
+ IMAGE_ID_NOT_FOUND, imageText.getText()));
+ }
+ }
+ }
+
+ private class ImageConverter extends Converter {
+
+ private WritableValue imageObservable = new WritableValue();
+
+ public ImageConverter() {
+ super(String.class, DeltaCloudImage.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ Assert.isLegal(fromObject instanceof String);
+ String id = (String) fromObject;
+ DeltaCloudImage image = getImage(id);
+ imageObservable.setValue(image);
+ return image;
+ }
+
+ private DeltaCloudImage getImage(String id) {
+ try {
+ return cloud.getImage(id);
+ } catch (DeltaCloudException e) {
+ return null;
+ }
+ }
+
+ public IObservableValue getImageObservable() {
+ return imageObservable;
+ }
+ }
+
private void launchFetchRealms() {
Thread t = new Thread() {
public void run() {
@@ -481,92 +568,6 @@
t.start();
}
- /**
- * Displays the arch in the given label if the given binding is valid.
- *
- * @param archLabel
- * the arch label
- * @return the value change listener
- */
- private class ArchAdapter implements IValueChangeListener {
-
- private Label archLabel;
- private NewInstanceModel.ImageContainer container;
- private NewInstancePage page;
-
- public ArchAdapter(Label archLabel,
- NewInstanceModel.ImageContainer container,
- NewInstancePage page) {
- this.archLabel = archLabel;
- this.page = page;
- this.container = container;
- }
-
- @Override
- public void handleValueChange(ValueChangeEvent event) {
- IStatus status = (IStatus) event.diff.getNewValue();
- if (status.isOK()) {
- archLabel.setText(model.getArch());
- page.setImage(container.getImage());
- page.filterProfiles();
- } else {
- archLabel.setText("");
- page.clearProfiles();
- }
- }
- }
-
- /**
- * Binds the architecture label to the given image id text widget. Attaches
- * a listener to the image id text widget Adds a validity decorator to the
- * image text widget.
- *
- * @param dbc
- * the databinding context to use
- * @param imageText
- * the image id text widget
- * @param archLabel
- * the label to display the image architecture in
- * @return
- * @return the binding that was created
- */
- private Binding bindArchLabel(DataBindingContext dbc, Text imageText, final Label archLabel,
- final NewInstancePage page) {
- UpdateValueStrategy updateStrategy = new UpdateValueStrategy();
- NewInstanceModel.ImageContainer c = new NewInstanceModel.ImageContainer();
- updateStrategy.setConverter(new NewInstanceModel.ArchConverter(cloud, c, String.class, String.class));
- updateStrategy.setBeforeSetValidator(new NewInstanceModel.ArchValidator());
-
- Binding binding = dbc.bindValue(
- WidgetProperties.text(SWT.Modify).observeDelayed(100, imageText),
- BeanProperties.value(NewInstanceModel.PROPERTY_ARCH).observe(model),
- updateStrategy,
- new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
- binding.getValidationStatus().addValueChangeListener(new ArchAdapter(archLabel, c, page));
- ControlDecorationSupport.create(binding, SWT.LEFT | SWT.TOP);
- return binding;
- }
-
- /**
- * Bind the given text widget to the cloud connection model. Attaches
- * validator to the binding that enforce a non-empty input.
- *
- * @param dbc
- * the databinding context to use
- * @param text
- * the name text widget to bind
- */
- private void bindText(DataBindingContext dbc, final Text text, String property, String errMsgId) {
- Binding nameTextBinding = dbc.bindValue(
- WidgetProperties.text(SWT.Modify).observe(text),
- BeanProperties.value(NewInstanceModel.class, property)
- .observe(model),
- new UpdateValueStrategy().setBeforeSetValidator(new MandatoryStringValidator(WizardMessages
- .getString(errMsgId))),
- null);
- ControlDecorationSupport.create(nameTextBinding, SWT.LEFT | SWT.TOP);
- }
-
private List<String> getRealmNames(List<DeltaCloudRealm> realms) {
List<String> realmNames = new ArrayList<String>();
for (DeltaCloudRealm realm : realms) {
@@ -586,6 +587,7 @@
try {
realms = Arrays.asList(cloud.getRealms());
} catch (DeltaCloudException e) {
+ // TODO: internationalize strings
ErrorUtils.handleErrorAsync("Error",
MessageFormat.format("Could not get realms from cloud {0}", cloud.getName()), e, getShell());
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-12-08 16:43:42 UTC (rev 27239)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2010-12-08 16:44:54 UTC (rev 27240)
@@ -79,7 +79,7 @@
ErrorInvalidURL.text=URL specified is invalid
ErrorNonCloudURL.text=URL specified is not a valid Delta-cloud address
ErrorInvalidPem.text=File specified is not a valid existing key
-ErrorImageIdNotFound.text = No existing image with specified id can be found
+ErrorImageIdNotFound.text = Could not find image with id \"{0}\"
ErrorMustProvideName.text=A name must be specified
ErrorMustProvideKeyName.text=A key name must be specified
ErrorMustProvideImageId.text=An image id must be specified
14 years
JBoss Tools SVN: r27239 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core: src/org/jboss/tools/deltacloud/core and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-08 11:43:42 -0500 (Wed, 08 Dec 2010)
New Revision: 27239
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
Log:
[JBIDE-7834] implemented #getLastImage(id) that queries the local cache and the server (fallback), removed #getImage(String id), #loadImage(String imageId), removed #findInstanceById
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-08 16:26:00 UTC (rev 27238)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-08 16:43:42 UTC (rev 27239)
@@ -1,3 +1,9 @@
+2010-12-08 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getImage):
+ [JBIDE-7834] implemented #getLastImage(id) that queries the local cache and the server (fallback),
+ removed #getImage(String id), #loadImage(String imageId), removed #findInstanceById
+
2010-12-06 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/InstanceFilter.java (InstanceFilter):
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-08 16:26:00 UTC (rev 27238)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-08 16:43:42 UTC (rev 27239)
@@ -138,6 +138,10 @@
return lastImageId;
}
+ public DeltaCloudImage getLastImage() throws DeltaCloudException {
+ return getImage(lastImageId);
+ }
+
public void setLastImageId(String lastImageId) {
this.lastImageId = lastImageId;
}
@@ -310,7 +314,7 @@
public DeltaCloudInstance waitForState(String instanceId, IInstanceStateMatcher stateMatcher, IProgressMonitor pm)
throws InterruptedException, DeltaCloudException {
- DeltaCloudInstance instance = findInstanceById(instanceId);
+ DeltaCloudInstance instance = instances.getById(instanceId);
if (instance != null) {
while (!pm.isCanceled()) {
if (stateMatcher.matchesState(instance, instance.getState())
@@ -399,15 +403,27 @@
notifyImageListListeners(getImagesRepository().get());
}
+ /**
+ * Gets an image for the given image id. In a first step, the local cache is
+ * queried and if no image is found, the server is queried.
+ *
+ * @param id
+ * the image id to match
+ * @return the image that has the given id
+ * @throws DeltaCloudException
+ */
public DeltaCloudImage getImage(String id) throws DeltaCloudException {
- DeltaCloudImage matchingImage = null;
- for (DeltaCloudImage image : getImagesRepository().get()) {
- if (id.equals(image.getId())) {
- matchingImage = image;
- break;
+ DeltaCloudImage deltaCloudImage = getImagesRepository().getById(id);
+ if (deltaCloudImage == null) {
+ try {
+ Image image = client.listImages(id);
+ deltaCloudImage = images.add(image, this);
+ } catch (DeltaCloudClientException e) {
+ throw new DeltaCloudException(MessageFormat.format("Cloud not find image with id \"{0}\"", id), e);
}
}
- return matchingImage;
+
+ return deltaCloudImage;
}
public void createKey(String keyname, String keystoreLocation) throws DeltaCloudException {
@@ -436,7 +452,7 @@
public void replaceInstance(DeltaCloudInstance instance) {
String instanceId = instance.getId();
if (instance != null) {
- DeltaCloudInstance instanceToReplace = findInstanceById(instanceId);
+ DeltaCloudInstance instanceToReplace = instances.getById(instanceId);
replaceInstance(instance, instanceToReplace);
// TODO: remove notification with all instances, replace by
// notifying the changed instance
@@ -444,17 +460,13 @@
}
}
- private DeltaCloudInstance findInstanceById(String instanceId) {
- return getInstancesRepository().getById(instanceId);
- }
-
// TODO: remove duplicate code with #replaceInstance
public DeltaCloudInstance refreshInstance(String instanceId) throws DeltaCloudException {
DeltaCloudInstance deltaCloudInstance = null;
try {
Instance instance = client.listInstances(instanceId);
deltaCloudInstance = new DeltaCloudInstance(this, instance);
- DeltaCloudInstance currentInstance = findInstanceById(instanceId);
+ DeltaCloudInstance currentInstance = instances.getById(instanceId);
// FIXME: remove BOGUS state when server fixes state
// problems
if (!(deltaCloudInstance.getState().equals(DeltaCloudInstance.BOGUS))
@@ -476,7 +488,7 @@
}
public boolean performInstanceAction(String instanceId, String actionId) throws DeltaCloudException {
- return performInstanceAction(findInstanceById(instanceId), actionId);
+ return performInstanceAction(instances.getById(instanceId), actionId);
}
protected boolean performInstanceAction(DeltaCloudInstance instance, String actionId) throws DeltaCloudException {
@@ -533,15 +545,6 @@
}
- public DeltaCloudImage loadImage(String imageId) throws DeltaCloudException {
- try {
- Image image = client.listImages(imageId);
- return getImagesRepository().add(image, this);
- } catch (DeltaCloudClientException e) {
- throw new DeltaCloudException(e);
- }
- }
-
public boolean testConnection() throws DeltaCloudException {
String instanceId = "nonexistingInstance"; //$NON-NLS-1$
try {
14 years
JBoss Tools SVN: r27238 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-08 11:26:00 -0500 (Wed, 08 Dec 2010)
New Revision: 27238
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
Log:
JBIDE-7844
https://jira.jboss.org/browse/JBIDE-7844
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-12-08 16:15:32 UTC (rev 27237)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-12-08 16:26:00 UTC (rev 27238)
@@ -125,6 +125,17 @@
}
public void setSuperClassBean(ClassBean bean) {
+ HashSet<ClassBean> beans = new HashSet<ClassBean>();
+ beans.add(this);
+ ClassBean b = bean;
+ while(b != null) {
+ if(beans.contains(b)) {
+ bean = null;
+ break;
+ }
+ b = b.getSuperClassBean();
+ }
+
superClassBean = bean;
if(superClassBean != null && isSpecializing()) {
superClassBean.addSpecializingClassBean(this);
14 years