Author: adietish
Date: 2012-01-27 13:16:53 -0500 (Fri, 27 Jan 2012)
New Revision: 38246
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyCellLabelProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyTableContentProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/ContainerElement.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/IProperty.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/LinkElement.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyNameCellLabelProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/StringElement.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/TreeUtils.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsContentProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java
Log:
[JBIDE-10724] extracted property table to its own packge (for later reuse). Used
TreeEditor to put a link on top of the url to be able to handle clicks on the web url
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyCellLabelProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyCellLabelProvider.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyCellLabelProvider.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.propertytable;
+
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ViewerCell;
+
+/**
+ * @author Xavier Coulon
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractPropertyCellLabelProvider extends CellLabelProvider {
+
+ @Override
+ public void update(ViewerCell cell) {
+ if (cell.getElement() instanceof IProperty) {
+ update((IProperty) cell.getElement(), cell);
+ }
+ }
+
+ abstract protected void update(IProperty property, ViewerCell cell);
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyCellLabelProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyTableContentProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyTableContentProvider.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyTableContentProvider.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package org.jboss.tools.openshift.express.internal.ui.propertytable;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * @author Xavier Coulon
+ * @author Andre Dietisheim
+ *
+ */
+public abstract class AbstractPropertyTableContentProvider implements
ITreeContentProvider {
+
+ @Override
+ public abstract Object[] getElements(Object inputElement);
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (!hasChildren(parentElement)) {
+ return new Object[0];
+ }
+ return ((IProperty) parentElement).getChildren();
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof IProperty) {
+ return ((IProperty) element).getParent();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ return element instanceof IProperty
+ && ((IProperty) element).hasChildren();
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/AbstractPropertyTableContentProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/ContainerElement.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/ContainerElement.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/ContainerElement.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.propertytable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ContainerElement implements IProperty {
+
+ private final String property;
+ private final List<Object> children;
+ private final ContainerElement parent;
+
+ public ContainerElement(String property, ContainerElement parent) {
+ this.property = property;
+ this.children = new ArrayList<Object>();
+ this.parent = parent;
+ }
+
+ public final String getProperty() {
+ return property;
+ }
+
+ public final void add(StringElement child) {
+ children.add(child);
+ }
+
+ public final void add(ContainerElement child) {
+ children.add(child);
+ }
+
+ public final Object[] getChildren() {
+ return children.toArray();
+ }
+
+ public boolean hasChildren() {
+ return !children.isEmpty();
+ }
+
+ public final ContainerElement getParent() {
+ return parent;
+ }
+
+ public boolean isLink() {
+ return false;
+ }
+
+ @Override
+ public String getName() {
+ return property;
+ }
+
+ @Override
+ public String getValue() {
+ return null;
+ }
+ }
\ No newline at end of file
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/ContainerElement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/IProperty.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/IProperty.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/IProperty.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.propertytable;
+
+public interface IProperty {
+
+ public String getName();
+
+ public String getValue();
+
+ public ContainerElement getParent();
+
+ public boolean isLink();
+
+ public boolean hasChildren();
+
+ public Object[] getChildren();
+}
\ No newline at end of file
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/IProperty.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/LinkElement.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/LinkElement.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/LinkElement.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.propertytable;
+
+class LinkElement extends StringElement {
+
+ public LinkElement(String property, String value, ContainerElement parent) {
+ super(property, value, true, parent);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/LinkElement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyNameCellLabelProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyNameCellLabelProvider.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyNameCellLabelProvider.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.propertytable;
+
+import org.eclipse.jface.viewers.ViewerCell;
+
+/**
+ * @author Xavier Coulon
+ * @author Andre Dietisheim
+ */
+public class PropertyNameCellLabelProvider extends AbstractPropertyCellLabelProvider {
+
+ protected void update(IProperty property, ViewerCell cell) {
+ cell.setText(property.getName());
+ }
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyNameCellLabelProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.propertytable;
+
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Tree;
+import org.jboss.tools.openshift.express.internal.ui.utils.TreeUtils;
+
+/**
+ * @author Xavier Coulon
+ * @author Andre Dietisheim
+ */
+public class PropertyValueCellLabelProvider extends AbstractPropertyCellLabelProvider {
+
+ protected void update(IProperty property, ViewerCell cell) {
+ if (property.isLink()) {
+ createLink(property, cell);
+ } else {
+ cell.setText(property.getValue());
+ }
+ }
+
+ private void createLink(IProperty property, final ViewerCell cell) {
+ Link link = new Link((Tree) cell.getControl(), SWT.NONE);
+ link.setText("<a>" + property.getValue() +"</a>");
+ link.setBackground(cell.getBackground());
+ TreeUtils.createTreeEditor(link, property.getValue(), cell);
+ }
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/StringElement.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/StringElement.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/StringElement.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.propertytable;
+
+public class StringElement extends ContainerElement {
+
+ private final String value;
+ private final boolean isLink;
+
+ public StringElement(String property, String value, ContainerElement parent) {
+ this(property, value, false, parent);
+ }
+
+ public StringElement(String property, String value, boolean isLink, ContainerElement
parent) {
+ super(property, parent);
+ this.value = value;
+ this.isLink = isLink;
+ }
+
+ public final String getValue() {
+ return value;
+ }
+
+ public boolean isLink() {
+ return isLink;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/StringElement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/TreeUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/TreeUtils.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/TreeUtils.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.utils;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * @author André Dietisheim
+ */
+public class TreeUtils {
+
+ /**
+ * Creates a tree editor for the given cell with the given control.
+ * <p>
+ * A tree editor puts a control over a given cell in a tree. Furthermore it puts text
into the cell so that the
+ * column's large enough so that the control has enough room to overlay itself over
it
+ *
+ * @param cell the cell to put the control to
+ * @param control the control to put to the given cell
+ * @param cellText the text that's put into the table cell (overlayed by the
editor), that only enlarges the
+ * column to have enough room for the editor
+ *
+ * @return the tree editor
+ *
+ * @see ViewerCell
+ * @see TreeEditor
+ */
+ public static TreeEditor createTreeEditor( Control control, String cellText, ViewerCell
cell )
+ {
+ Assert.isTrue(cell.getControl() instanceof Tree);
+
+ Tree tree = ( Tree ) cell.getControl();
+ TreeEditor treeEditor = new TreeEditor( tree );
+ initializeTreeEditor( treeEditor, control, cellText, cell );
+ return treeEditor;
+ }
+
+ /**
+ * Initializes a given table editor for a given viewer cell with a given
(editor-)control.
+ *
+ * @param treeEditor the table editor
+ * @param control the control
+ * @param cellText the cell text
+ * @param cell the cell
+ *
+ * @see TableEditor
+ * @see ViewerCell
+ */
+ public static void initializeTreeEditor( TreeEditor treeEditor, Control control, String
cellText, ViewerCell cell )
+ {
+ treeEditor.grabHorizontal = true;
+ treeEditor.grabVertical = true;
+ treeEditor.horizontalAlignment = SWT.CENTER;
+ treeEditor.verticalAlignment = SWT.CENTER;
+ TreeItem treeItem = ( TreeItem ) cell.getItem();
+ treeEditor.setEditor( control, treeItem, cell.getColumnIndex() );
+ // ensure cell is as large as space needed for link
+ cell.setText( " " + cellText + " ");
+ }
+
+ /**
+ * Sets the height of the rows in a given table. The height might only be increased
(compared to the standard
+ * height). Decreasing it below the default height has no effect.
+ *
+ * @param height the height in pixels
+ * @param table the table
+ */
+ public static void setRowHeight( final int height, Tree tree )
+ {
+ tree.addListener( SWT.MeasureItem, new Listener()
+ {
+ public void handleEvent( Event event )
+ {
+ event.height = height;
+ }
+ } );
+ }
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/TreeUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsContentProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsContentProvider.java 2012-01-27
17:30:19 UTC (rev 38245)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsContentProvider.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -4,11 +4,10 @@
package org.jboss.tools.openshift.express.internal.ui.wizard;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
+import
org.jboss.tools.openshift.express.internal.ui.propertytable.AbstractPropertyTableContentProvider;
+import org.jboss.tools.openshift.express.internal.ui.propertytable.ContainerElement;
+import org.jboss.tools.openshift.express.internal.ui.propertytable.StringElement;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import com.openshift.express.client.IApplication;
@@ -17,170 +16,44 @@
/**
* @author Xavier Coulon
+ * @author Andre Dietisheim
*
*/
-public class ApplicationDetailsContentProvider implements ITreeContentProvider {
+public class ApplicationDetailsContentProvider extends
AbstractPropertyTableContentProvider {
- private IApplication application;
-
@Override
public Object[] getElements(Object inputElement) {
+ Object[] elements = null;
if (inputElement instanceof IApplication) {
try {
- final SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd 'at'
HH:mm:ss");
+ IApplication application = (IApplication) inputElement;
final ContainerElement infoContainer = new ContainerElement("info", null);
- infoContainer.add(new SimpleElement("Name", application.getName(),
infoContainer));
- infoContainer.add(new SimpleElement("Public URL",
application.getApplicationUrl().toString(), true,
+ infoContainer.add(new StringElement("Name", application.getName(),
infoContainer));
+ infoContainer.add(new StringElement("Public URL",
application.getApplicationUrl().toString(), true,
infoContainer));
- infoContainer.add(new SimpleElement("Type",
application.getCartridge().getName(), infoContainer));
- infoContainer.add(new SimpleElement("Created on",
format.format(application.getCreationTime()),
- infoContainer));
- infoContainer.add(new SimpleElement("UUID", application.getUUID(),
infoContainer));
- infoContainer.add(new SimpleElement("Git URL", application.getGitUri(),
infoContainer));
- final ContainerElement cartridgesContainer = new
ContainerElement("Cartridges", infoContainer);
- infoContainer.add(cartridgesContainer);
- for (IEmbeddableCartridge cartridge : application.getEmbeddedCartridges()) {
- cartridgesContainer.add(new SimpleElement(cartridge.getName(),
cartridge.getUrl().toString(), true,
- cartridgesContainer));
- }
- return new Object[] { infoContainer };
- } catch (OpenShiftException e) {
+ infoContainer.add(new StringElement("Type",
application.getCartridge().getName(), infoContainer));
+ final SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd 'at'
HH:mm:ss");
+ infoContainer.add(
+ new StringElement("Created on",
format.format(application.getCreationTime()), infoContainer));
+ infoContainer.add(new StringElement("UUID", application.getUUID(),
infoContainer));
+ infoContainer.add(new StringElement("Git URL", application.getGitUri(),
infoContainer));
+ infoContainer.add(createCartridges(application, infoContainer));
+ elements = new Object[] { infoContainer };
+ } catch (Exception e) {
Logger.error("Failed to display details for OpenShift application", e);
}
}
- return null;
+ return elements;
}
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof ContainerElement) {
- return ((ContainerElement) parentElement).getChildren();
+ private ContainerElement createCartridges(IApplication application, ContainerElement
infoContainer)
+ throws OpenShiftException {
+ ContainerElement cartridgesContainer = new ContainerElement("Cartridges",
infoContainer);
+ for (IEmbeddableCartridge cartridge : application.getEmbeddedCartridges()) {
+ cartridgesContainer.add(
+ new StringElement(cartridge.getName(), cartridge.getUrl().toString(), true,
+ cartridgesContainer));
}
- return new Object[0];
+ return cartridgesContainer;
}
-
- @Override
- public Object getParent(Object element) {
- if (element instanceof SimpleElement) {
- return ((SimpleElement) element).getParent();
- } else if (element instanceof ContainerElement) {
- return ((ContainerElement) element).getParent();
- }
- return null;
- }
-
- @Override
- public boolean hasChildren(Object element) {
- return (element instanceof ContainerElement);
- }
-
- @Override
- public void dispose() {
-
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof IApplication) {
- this.application = (IApplication) newInput;
- } else {
- this.application = null;
- }
-
- }
-
- static class SimpleElement {
-
- private final String property;
- private final String value;
- private final ContainerElement parent;
- private final boolean isLink;
-
- public SimpleElement(String property, String value, ContainerElement parent) {
- super();
- this.property = property;
- this.value = value;
- this.parent = parent;
- this.isLink = false;
- }
-
- public SimpleElement(String property, String value, boolean isLink, ContainerElement
parent) {
- super();
- this.property = property;
- this.value = value;
- this.parent = parent;
- this.isLink = isLink;
- }
-
- /**
- * @return the property
- */
- public final String getProperty() {
- return property;
- }
-
- /**
- * @return the value
- */
- public final String getValue() {
- return value;
- }
-
- /**
- * @return the parent container
- */
- public final ContainerElement getParent() {
- return parent;
- }
-
- /**
- * @return the isLink
- */
- public boolean isLink() {
- return isLink;
- }
- }
-
- static class ContainerElement {
-
- private final String property;
- private final List<Object> children;
- private final ContainerElement parent;
-
- public ContainerElement(String property, ContainerElement parent) {
- this.property = property;
- this.children = new ArrayList<Object>();
- this.parent = parent;
- }
-
- /**
- * @return the property
- */
- public final String getProperty() {
- return property;
- }
-
- public final void add(SimpleElement child) {
- children.add(child);
- }
-
- public final void add(ContainerElement child) {
- children.add(child);
- }
-
- /**
- * @return the value
- */
- public final Object[] getChildren() {
- return children.toArray();
- }
-
- /**
- * @return the parent container
- */
- public final ContainerElement getParent() {
- return parent;
- }
- }
-
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java 2012-01-27
17:30:19 UTC (rev 38245)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java 2012-01-27
18:16:53 UTC (rev 38246)
@@ -10,9 +10,6 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.util.concurrent.Callable;
-
-import org.eclipse.core.runtime.ILog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.layout.GridDataFactory;
@@ -20,33 +17,24 @@
import org.eclipse.jface.layout.TreeColumnLayout;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.StyledCellLabelProvider;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
-import org.jboss.tools.common.ui.BrowserUtil;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftImages;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import
org.jboss.tools.openshift.express.internal.ui.propertytable.PropertyNameCellLabelProvider;
+import
org.jboss.tools.openshift.express.internal.ui.propertytable.PropertyValueCellLabelProvider;
import com.openshift.express.client.IApplication;
/**
- * @author Andr� Dietisheim
+ * @author Andre Dietisheim
* @author Xavier Coulon
*/
public class ApplicationDetailsDialog extends TitleAreaDialog {
@@ -74,80 +62,18 @@
Composite dialogArea = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(dialogArea);
- GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(dialogArea);
+ GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(dialogArea);
TreeViewer viewer = createApplicationDetailsTable(dialogArea);
fillApplicationDetailsTable(viewer);
-
+
Label buttonsSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(buttonsSeparator);
- // createDetails("Name:", application.getName(), treeTableContainer);
- // createDetails("Type:", application.getCartridge().getName(),
- // treeTableContainer);
- // createDetails("Embedded Cartridges:", new
- // ErrorMessageCallable<String>("Embedded Cartridges") {
- //
- // @Override
- // public String call() throws Exception {
- // return StringUtils.toString(application.getEmbeddedCartridges(),
- // new StringUtils.ToStringConverter<IEmbeddableCartridge>() {
- //
- // @Override
- // public String toString(IEmbeddableCartridge cartridge) {
- // return cartridge.getName();
- // }
- // });
- // }
- //
- // }.get(), treeTableContainer);
- // createDetails("Creation Time:", new
- // ErrorMessageCallable<String>("Creation Time") {
- //
- // @Override
- // public String call() throws Exception {
- // return RFC822DateUtils.getString(application.getCreationTime());
- // }
- // }.get(), treeTableContainer);
- // createDetails("UUIDxx:", new
ErrorMessageCallable<String>("UUID") {
- //
- // @Override
- // public String call() throws Exception {
- // return application.getUUID();
- // }
- // }.get(), treeTableContainer);
- // createDetails("Git URL:", new ErrorMessageCallable<String>("Git
URL")
- // {
- //
- // @Override
- // public String call() throws Exception {
- // return application.getGitUri();
- // }
- // }.get(), treeTableContainer);
- //
- // Label publicUrlLabel = new Label(treeTableContainer, SWT.NONE);
- // publicUrlLabel.setText("Public URL:");
- // GridDataFactory.fillDefaults().align(SWT.LEFT,
- // SWT.CENTER).applyTo(publicUrlLabel);
- // Link publicUrlLink = new Link(treeTableContainer, SWT.WRAP);
- // String applicationUrl = new
- // ErrorMessageCallable<String>("Public URL") {
- //
- // @Override
- // public String call() throws Exception {
- // return application.getApplicationUrl();
- // }
- // }.get();
- // publicUrlLink.setText("<a>" + applicationUrl +
"</a>");
- // GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
- // false).applyTo(publicUrlLink);
- // publicUrlLink.addSelectionListener(onPublicUrl(applicationUrl));
-
return dialogArea;
}
private void fillApplicationDetailsTable(final TreeViewer viewer) {
- viewer.setContentProvider(new ApplicationDetailsContentProvider());
viewer.setInput(application);
viewer.expandToLevel(2);
}
@@ -156,57 +82,19 @@
Composite tableContainer = new Composite(parent, SWT.NONE);
TreeColumnLayout treeLayout = new TreeColumnLayout();
tableContainer.setLayout(treeLayout);
-
+
Tree tree = new Tree(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL |
SWT.H_SCROLL);
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
-// GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(500,
tree.getItemHeight() * 10).applyTo(tableContainer);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(500,
300).applyTo(tableContainer);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).hint(500, 300).applyTo(tableContainer);
- TreeViewer viewer = new TreeViewer(tree);
- createTreeColumn("Property", 1, new CellLabelProvider() {
- @Override
- public void update(ViewerCell cell) {
- if (cell.getElement() instanceof ApplicationDetailsContentProvider.SimpleElement) {
- ApplicationDetailsContentProvider.SimpleElement element =
(ApplicationDetailsContentProvider.SimpleElement) cell
- .getElement();
- cell.setText(element.getProperty());
- } else if (cell.getElement() instanceof
ApplicationDetailsContentProvider.ContainerElement) {
- ApplicationDetailsContentProvider.ContainerElement element =
(ApplicationDetailsContentProvider.ContainerElement) cell
- .getElement();
- cell.setText(element.getProperty());
- }
- }
- }, viewer, treeLayout);
+ final TreeViewer viewer = new TreeViewer(tree);
+ viewer.setContentProvider(new ApplicationDetailsContentProvider());
+ createTreeColumn("Property", 1, new PropertyNameCellLabelProvider(), viewer,
treeLayout);
+ createTreeColumn("Value", 3, new PropertyValueCellLabelProvider(), viewer,
treeLayout);
- createTreeColumn("Value", 3, new StyledCellLabelProvider() {
- @Override
- public void update(ViewerCell cell) {
- if (cell.getElement() instanceof ApplicationDetailsContentProvider.SimpleElement) {
- ApplicationDetailsContentProvider.SimpleElement element =
(ApplicationDetailsContentProvider.SimpleElement) cell
- .getElement();
- cell.setText(element.getValue());
- if (element.isLink()) {
- Styler style = new Styler() {
- @Override
- public void applyStyles(TextStyle textStyle) {
- textStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
- textStyle.underline = true;
- }
-
- };
- StyledString styledString = new StyledString(cell.getText(), style);
- cell.setStyleRanges(styledString.getStyleRanges());
- cell.setText(styledString.getString());
- // cell.setCursor(new Cursor(Display.getCurrent(),
- // SWT.CURSOR_HAND));
- }
- }
- }
- }, viewer, treeLayout);
-
return viewer;
-
}
private void createTreeColumn(String name, int weight, CellLabelProvider
cellLabelProvider, TreeViewer treeViewer,
@@ -230,47 +118,4 @@
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
}
-
- private SelectionAdapter onPublicUrl(final String applicationUrl) {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- ILog log = OpenShiftUIActivator.getDefault().getLog();
- BrowserUtil.checkedCreateExternalBrowser(applicationUrl,
OpenShiftUIActivator.PLUGIN_ID, log);
- }
- };
- }
-
- private void createDetails(String name, String value, Composite container) {
- Label label = new Label(container, SWT.None);
- label.setText(name);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(label);
- Text text = new Text(container, SWT.NONE);
- text.setEditable(false);
- text.setBackground(container.getBackground());
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(text);
- text.setText(value);
- }
-
- private abstract class ErrorMessageCallable<T> implements Callable<T> {
-
- private String fieldName;
-
- public ErrorMessageCallable(String fieldName) {
- this.fieldName = fieldName;
- }
-
- public T get() {
- try {
- return call();
- } catch (Exception e) {
- setErrorMessage(NLS.bind("Could not get {0}: {1}", fieldName,
e.getMessage()));
- return null;
- }
- }
-
- @Override
- public abstract T call() throws Exception;
- }
}