add visualization of repository props and any problems found during creation of repository
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@991726 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
index d2f60ea..fe3aeab 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
@@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map.Entry;
import org.apache.felix.sigil.common.model.ICompoundModelElement;
import org.apache.felix.sigil.common.model.IModelElement;
@@ -35,6 +36,7 @@
import org.apache.felix.sigil.eclipse.model.util.ModelHelper;
import org.apache.felix.sigil.eclipse.ui.SigilUI;
import org.apache.felix.sigil.eclipse.ui.actions.RefreshRepositoryAction;
+import org.apache.felix.sigil.eclipse.ui.util.DefaultTableProvider;
import org.apache.felix.sigil.eclipse.ui.util.DefaultTreeContentProvider;
import org.apache.felix.sigil.eclipse.ui.util.ModelLabelProvider;
import org.eclipse.jface.action.Action;
@@ -43,8 +45,11 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
@@ -55,6 +60,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISharedImages;
@@ -120,6 +126,7 @@
public void run()
{
treeViewer.setInput(rep);
+ tableViewer.setInput(rep);
createMenu();
}
@@ -201,6 +208,7 @@
}
private TreeViewer treeViewer;
+ private TableViewer tableViewer;
@Override
public void createPartControl(Composite parent)
@@ -247,6 +255,7 @@
if (treeViewer.getInput() == null)
{
treeViewer.setInput(rep);
+ tableViewer.setInput(rep);
}
RepositoryAction action = new RepositoryAction(rep);
@@ -258,13 +267,25 @@
{
// components
Composite control = new Composite(parent, SWT.NONE);
+ Table table = new Table(control, SWT.SINGLE);
+ table.setHeaderVisible(true);
Tree tree = new Tree(control, SWT.NONE);
// layout
control.setLayout(new GridLayout(1, false));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
- // viewer
+ // viewers
+ createPropertiesViewer(table);
+ createContentsViewer(tree);
+ }
+
+ /**
+ * @param tree
+ */
+ private void createContentsViewer(Tree tree)
+ {
treeViewer = new TreeViewer(tree);
treeViewer.setContentProvider(new DefaultTreeContentProvider()
{
@@ -303,7 +324,13 @@
public Object[] getElements(Object inputElement)
{
IBundleRepository rep = (IBundleRepository) inputElement;
- return getBundles(rep);
+ IRepositoryModel model = SigilCore.getRepositoryModel(rep);
+ if ( model.getProblem() == null ) {
+ return getBundles(rep);
+ }
+ else {
+ return new Object[] { model.getProblem() };
+ }
}
});
@@ -357,6 +384,49 @@
});
}
+ /**
+ * @param table
+ */
+ private void createPropertiesViewer(Table table)
+ {
+ tableViewer = new TableViewer(table);
+ tableViewer.setContentProvider(new DefaultTableProvider() {
+
+ public Object[] getElements(Object inputElement)
+ {
+ IBundleRepository rep = (IBundleRepository) inputElement;
+ IRepositoryModel model = SigilCore.getRepositoryModel(rep);
+ return toArray(model.getProperties().entrySet());
+ }
+ });
+
+ TableViewerColumn keyCol = new TableViewerColumn(tableViewer, SWT.NONE);
+ keyCol.getColumn().setText("Key");
+ keyCol.getColumn().setWidth(100);
+ keyCol.setLabelProvider(new ColumnLabelProvider() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public String getText(Object element)
+ {
+ Entry<String, String> entry = (Entry<String, String>) element;
+ return entry.getKey();
+ }
+ });
+
+ TableViewerColumn valCol = new TableViewerColumn(tableViewer, SWT.NONE);
+ valCol.getColumn().setText("Value");
+ valCol.getColumn().setWidth(500);
+ valCol.setLabelProvider(new ColumnLabelProvider() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public String getText(Object element)
+ {
+ Entry<String, String> entry = (Entry<String, String>) element;
+ return entry.getValue();
+ }
+ });
+ }
+
@Override
public void setFocus()
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
index 7103095..9dc0b37 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
@@ -19,6 +19,8 @@
package org.apache.felix.sigil.eclipse.ui.util;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
import java.util.Set;
import org.apache.felix.sigil.common.model.IModelElement;
@@ -38,6 +40,8 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
import org.osgi.framework.Version;
public class ModelLabelProvider extends LabelProvider
@@ -90,12 +94,16 @@
{
return findPackage();
}
- if (element instanceof IBundleRepository)
+ else if (element instanceof IBundleRepository)
{
IBundleRepository rep = (IBundleRepository) element;
IRepositoryModel config = SigilCore.getRepositoryModel(rep);
return config.getType().getIcon();
}
+ else if (element instanceof Throwable) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJS_ERROR_TSK);
+ }
return null;
}
@@ -170,6 +178,15 @@
IRepositoryModel config = SigilCore.getRepositoryModel(rep);
return config.getName();
}
+
+ if ( element instanceof Throwable ) {
+ Throwable t = (Throwable) element;
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ PrintStream print = new PrintStream(buf);
+ t.printStackTrace(print);
+ print.flush();
+ return buf.toString();
+ }
return element.toString();
}