*fixes
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java
index e0a9406..610d928 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java
@@ -34,6 +34,7 @@
import org.eclipse.dltk.core.IScriptModel;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.internal.core.ExternalProjectFragment;
import org.eclipse.dltk.internal.core.ScriptFolder;
import org.eclipse.dltk.internal.ui.StandardModelElementContentProvider;
import org.eclipse.dltk.internal.ui.scriptview.BuildPathContainer;
@@ -142,6 +143,9 @@
public Object[] getChildren(Object parentElement) {
Object[] children = NO_CHILDREN;
try {
+ if (parentElement instanceof LibrariesFragment) {
+ return ((LibrariesFragment) parentElement).elements.toArray();
+ }
if (parentElement instanceof IScriptModel)
return concatenate(
getScriptProjects((IScriptModel) parentElement),
@@ -188,7 +192,25 @@
if (!containedRoots.contains(roots[i])) {
result.add(roots[i]);
}
+ } else if (roots[i] instanceof LibrariesFragment) {
+ LibrariesFragment frag = (LibrariesFragment) roots[i];
+ LibrariesFragment nFrag = new LibrariesFragment();
+ nFrag.parent = frag.parent;
+ for (Iterator iterator = frag.elements.iterator(); iterator
+ .hasNext();) {
+ Object object = (Object) iterator.next();
+ if (!containedRoots.contains(object)) {
+ nFrag.elements.add(object);
+ }
+ }
+ if( nFrag.elements.size() > 1 ) {
+ result.add(nFrag);
+ }
+ else if( nFrag.elements.size() == 1 ) {
+ result.add(nFrag.elements.get(0));
+ }
} else {
+
result.add(roots[i]);
}
}
@@ -209,6 +231,9 @@
}
public Object getParent(Object child) {
+ if( child instanceof LibrariesFragment ) {
+ return ((LibrariesFragment) child).parent;
+ }
if (needsToDelegateGetParent(child)) {
return fScriptFolderProvider.getParent(child);
} else
@@ -249,6 +274,11 @@
return (!fIsFlatLayout && type == IModelElement.SCRIPT_FOLDER);
}
+ public static class LibrariesFragment {
+ public List elements = new ArrayList();
+ public Object parent;
+ }
+
/**
* Returns the given objects with the resources of the parent.
*/
@@ -259,15 +289,28 @@
if (existingObject != null) {
list.addAll(Arrays.asList(existingObject));
}
+ // Show all external libraris in libraries section.
+ LibrariesFragment fragment = new LibrariesFragment();
+ fragment.parent = parent;
// Add everything that is not a ScriptFolder
for (int i = 0; i < objects.length; i++) {
Object object = objects[i];
if (!(object instanceof ScriptFolder)) {
- if( !list.contains(object)) {
- list.add(object);
+ if (!list.contains(object)) {
+ if (object instanceof ExternalProjectFragment) {
+ fragment.elements.add(object);
+ } else {
+ list.add(object);
+ }
}
}
}
+ // Filter fragment
+ if (fragment.elements.size() == 1) {
+ list.add(fragment.elements.get(0));
+ } else if (fragment.elements.size() > 1) {
+ list.add(fragment);
+ }
return list.toArray();
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerLabelProvider.java
index 8fb681f..24241a3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerLabelProvider.java
@@ -12,8 +12,10 @@
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.Assert;
import org.eclipse.dltk.core.IScriptFolder;
+import org.eclipse.dltk.ui.DLTKPluginImages;
import org.eclipse.dltk.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.graphics.Image;
/**
@@ -40,8 +42,18 @@
}
+ public Image getImage(Object element) {
+ if( element instanceof ScriptExplorerContentProvider.LibrariesFragment ) {
+ return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_LIBRARY);
+ }
+ return super.getImage(element);
+ }
+
+
public String getText(Object element) {
-
+ if( element instanceof ScriptExplorerContentProvider.LibrariesFragment) {
+ return "Libraries";
+ }
if (fIsFlatLayout || !(element instanceof IScriptFolder))
return super.getText(element);