Author: scabanovich
Date: 2007-07-11 10:06:35 -0400 (Wed, 11 Jul 2007)
New Revision: 2386
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/RootContentProvider.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamLabelProvider.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
Log:
EXIN-218 Seam Components View implemented with common navigator framework.
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-07-11 14:04:27
UTC (rev 2385)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-07-11 14:06:35
UTC (rev 2386)
@@ -9,6 +9,7 @@
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.ui.ide,
+ org.eclipse.ui.navigator,
org.eclipse.jst.servlet.ui,
org.eclipse.wst.web.ui,
org.eclipse.wst.common.project.facet.ui,
@@ -28,6 +29,7 @@
org.eclipse.jst.j2ee.web
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.seam.ui,
+ org.jboss.tools.seam.ui.views,
org.jboss.tools.seam.ui.internal.project.facet;x-internal:=true,
org.jboss.tools.seam.ui.widget.editor,
org.jboss.tools.seam.ui.widget.field,
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2007-07-11 14:04:27 UTC (rev
2385)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2007-07-11 14:06:35 UTC (rev
2386)
@@ -94,6 +94,13 @@
id="org.jboss.tools.seam.ui.views.SeamComponentsView"
name="Seam Components">
</view>
+ <view
+ category="org.jboss.tools.seam.ui"
+ class="org.eclipse.ui.navigator.CommonNavigator"
+ icon="icons/sample.gif"
+ id="org.jboss.tools.seam.ui.views.SeamComponentsNavigator"
+ name="Seam Components Navigator">
+ </view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
@@ -108,4 +115,37 @@
</perspectiveExtension>
</extension>
+<extension point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding
viewerId="org.jboss.tools.seam.ui.views.SeamComponentsNavigator">
+ <includes>
+ <contentExtension pattern="org.jboss.tools.seam.ui.views.rootContent"
/>
+ </includes>
+ </viewerContentBinding>
+</extension>
+
+<extension point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ name="Seam Root Content Provider"
+ priority="highest"
+ icon="icons/sample.gif"
+ activeByDefault="true"
+
contentProvider="org.jboss.tools.seam.ui.views.RootContentProvider"
+ labelProvider="org.jboss.tools.seam.ui.views.SeamLabelProvider"
+ id="org.jboss.tools.seam.ui.views.rootContent">
+ <triggerPoints>
+ <or>
+ <instanceof
+ value="org.eclipse.core.resources.IWorkspaceRoot" />
+ <instanceof
+ value="org.jboss.tools.seam.core.ISeamElement" />
+ </or>
+ </triggerPoints>
+ <possibleChildren>
+ <or>
+ <instanceof value="org.jboss.tools.seam.core.ISeamElement" />
+ </or>
+ </possibleChildren>
+ </navigatorContent>
+</extension>
+
</plugin>
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/RootContentProvider.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/RootContentProvider.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/RootContentProvider.java 2007-07-11
14:06:35 UTC (rev 2386)
@@ -0,0 +1,109 @@
+package org.jboss.tools.seam.ui.views;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamElement;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.ISeamScope;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
+import org.jboss.tools.seam.core.event.SeamProjectChangeEvent;
+
+public class RootContentProvider implements ITreeContentProvider,
ISeamProjectChangeListener {
+ protected Viewer viewer;
+ IWorkspaceRoot root;
+
+ Set<ISeamProject> processed = new HashSet<ISeamProject>();
+
+ public Object[] getChildren(Object parentElement) {
+ if(parentElement instanceof IWorkspaceRoot) {
+ IWorkspaceRoot root = (IWorkspaceRoot)parentElement;
+ IProject[] ps = root.getProjects();
+ List<ISeamProject> children = new ArrayList<ISeamProject>();
+ for (int i = 0; i < ps.length; i++) {
+ ISeamProject p = SeamCorePlugin.getSeamProject(ps[i]);
+ if(p != null) {
+ if(!processed.contains(p)) {
+ processed.add(p);
+ p.addSeamProjectListener(this);
+ }
+ children.add(p);
+ }
+ }
+ return children.toArray(new ISeamProject[0]);
+ } else if(parentElement instanceof ISeamProject) {
+ return ((ISeamProject)parentElement).getScopes();
+ } else if(parentElement instanceof ISeamScope) {
+ return ((ISeamScope)parentElement).getComponents().toArray(new Object[0]);
+ } else if(parentElement instanceof ISeamComponent) {
+ return ((ISeamComponent)parentElement).getAllDeclarations().toArray(new Object[0]);
+ }
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ if(element instanceof ISeamProject) {
+ return root;
+ } else if(element instanceof ISeamElement) {
+ return ((ISeamElement)element).getParent();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return true;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ root = null;
+ viewer = null;
+ if(processed != null) {
+ for (ISeamProject p : processed) p.removeSeamProjectListener(this);
+ processed.clear();
+ }
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = viewer;
+ if(newInput instanceof IWorkspaceRoot || newInput == null) {
+ root = (IWorkspaceRoot)newInput;
+ }
+ }
+
+ public void projectChanged(SeamProjectChangeEvent event) {
+ if(viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed())
return;
+ Object o = event.getSource();
+ if(o instanceof ISeamElement) {
+ refresh(o);
+ } else {
+ System.out.println("event without source");
+ }
+ }
+
+ void refresh(final Object o) {
+ if(viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed())
return;
+ if(!(viewer instanceof StructuredViewer)) return;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ ((StructuredViewer)viewer).refresh(o);
+ }
+ });
+
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamLabelProvider.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamLabelProvider.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/SeamLabelProvider.java 2007-07-11
14:06:35 UTC (rev 2386)
@@ -0,0 +1,43 @@
+package org.jboss.tools.seam.ui.views;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.ISeamScope;
+
+public class SeamLabelProvider extends LabelProvider {
+
+ public String getText(Object element) {
+ if(element instanceof ISeamProject) {
+ return ((ISeamProject)element).getProject().getName();
+ } else if(element instanceof ISeamScope) {
+ return ((ISeamScope)element).getType().toString();
+ } else if(element instanceof ISeamComponent) {
+ return "" + ((ISeamComponent)element).getName();
+ } else if(element instanceof ISeamComponentDeclaration) {
+ IResource r = ((ISeamComponentDeclaration)element).getResource();
+ return r == null ? "???" : r.getName();
+ }
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+
+ public Image getImage(Object obj) {
+ String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
+ if (obj instanceof ISeamProject) {
+ imageKey = org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT;
+ } else if(obj instanceof ISeamScope) {
+ imageKey = ISharedImages.IMG_OBJ_FOLDER;
+ } else if(obj instanceof ISeamComponent) {
+ imageKey = ISharedImages.IMG_OBJ_ELEMENT;
+ } else if(obj instanceof ISeamComponentDeclaration) {
+ imageKey = ISharedImages.IMG_OBJ_FILE;
+ }
+ return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
+ }
+
+}
Show replies by date