MERGED: Fix for packages displayed in browsing perspective
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml b/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml
index e9ef47e..85e5395 100644
--- a/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml
+++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/plugin.xml
@@ -477,23 +477,13 @@
point="org.eclipse.dltk.ui.scriptCompletionProposalComputer"
id="TclScriptNoTypeCompletionProposalComputer">
<scriptCompletionProposalComputer
- categoryId="org.eclipse.dltk.ui.scriptNoTypeProposalCategory"
- class="org.eclipse.dltk.tcl.internal.ui.text.completion.TclNoTypeCompletionProposalComputer"
+ categoryId="org.eclipse.dltk.ui.scriptTypeProposalCategory"
+ class="org.eclipse.dltk.tcl.internal.ui.text.completion.TclTypeCompletionProposalComputer"
toolkitId="org.eclipse.dltk.tcl.core.nature">
<partition type="__dftl_partition_content_type"/>
<partition type="__tcl_string"/>
</scriptCompletionProposalComputer>
</extension>
- <extension
- point="org.eclipse.dltk.ui.scriptCompletionProposalComputer"
- id="TclScriptTypeCompletionProposalComputer">
- <scriptCompletionProposalComputer
- class="org.eclipse.dltk.tcl.internal.ui.text.completion.TclTypeCompletionProposalComputer"
- categoryId="org.eclipse.dltk.ui.scriptTypeProposalCategory"
- toolkitId="org.eclipse.dltk.tcl.core.nature">
- <partition type="__dftl_partition_content_type"/>
- </scriptCompletionProposalComputer>
- </extension>
<extension
point="org.eclipse.dltk.ui.scriptDocumentationProviders">
<provider
@@ -610,7 +600,7 @@
point="org.eclipse.ui.views">
<view
category="org.eclipse.dltk.tcl.ui"
- class="org.eclipse.dltk.ui.browsing.ProjectsView:org.eclipse.dltk.tcl.core.nature"
+ class="org.eclipse.dltk.tcl.internal.ui.browsing.TclProjectsView:org.eclipse.dltk.tcl.core.nature"
icon="icons/eview16/tcl_persp.gif"
id="org.eclipse.dltk.tcl.ui.Projects"
name="%TclProjectsView.name">
@@ -673,13 +663,14 @@
language="org.eclipse.dltk.tcl.core.nature">
</modelCompareProvider>
</extension>
-<!--extension
+<extension
point="org.eclipse.dltk.ui.editorTextHovers">
<hover
activate="false"
class="org.eclipse.dltk.tcl.internal.ui.PackagesSourcesHover"
id="org.eclipse.dltk.tcl.ui.source_package_hover"
+ nature="org.eclipse.dltk.tcl.core.nature"
label="Tcl Source/Package information hover">
</hover>
-</extension-->
+</extension>
</plugin>
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclDecoratingModelLabelProvider.java b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclDecoratingModelLabelProvider.java
new file mode 100644
index 0000000..9be6547
--- /dev/null
+++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclDecoratingModelLabelProvider.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2009 xored software, 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:
+ * xored software, Inc. - initial API and Implementation (Alex Panchenko)
+ *******************************************************************************/
+package org.eclipse.dltk.tcl.internal.ui.browsing;
+
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.tcl.internal.core.packages.TclPackageFragment;
+import org.eclipse.dltk.ui.viewsupport.DecoratingModelLabelProvider;
+import org.eclipse.dltk.ui.viewsupport.ScriptUILabelProvider;
+
+public class TclDecoratingModelLabelProvider extends
+ DecoratingModelLabelProvider {
+
+ /**
+ * @param labelProvider
+ */
+ public TclDecoratingModelLabelProvider(ScriptUILabelProvider labelProvider) {
+ super(labelProvider);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof TclPackageFragment) {
+ final TclPackageFragment fragment = (TclPackageFragment) element;
+ try {
+ final IModelElement[] children = fragment.getChildren();
+ if (children.length == 1) {
+ return super.getText(children[0]);
+ }
+ } catch (ModelException e) {
+ // ignore
+ }
+ return fragment.getPackageName();
+ }
+ return super.getText(element);
+ }
+}
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclProjectAndSourceFolderContentProvider.java b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclProjectAndSourceFolderContentProvider.java
new file mode 100644
index 0000000..8b513db
--- /dev/null
+++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclProjectAndSourceFolderContentProvider.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2009 xored software, 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:
+ * xored software, Inc. - initial API and Implementation (Alex Panchenko)
+ *******************************************************************************/
+package org.eclipse.dltk.tcl.internal.ui.browsing;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.dltk.core.IDLTKLanguageToolkit;
+import org.eclipse.dltk.core.IProjectFragment;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.tcl.internal.core.sources.TclSourcesFragment;
+import org.eclipse.dltk.ui.browsing.ProjectAndSourceFolderContentProvider;
+import org.eclipse.dltk.ui.browsing.ScriptBrowsingPart;
+
+public class TclProjectAndSourceFolderContentProvider extends
+ ProjectAndSourceFolderContentProvider {
+
+ public TclProjectAndSourceFolderContentProvider(
+ ScriptBrowsingPart browsingPart,
+ IDLTKLanguageToolkit languageToolkit) {
+ super(browsingPart, languageToolkit);
+ }
+
+ @Override
+ protected Object[] getProjectFragments(IScriptProject project)
+ throws ModelException {
+ if (!project.getProject().isOpen())
+ return NO_CHILDREN;
+ IProjectFragment[] roots = project.getProjectFragments();
+ final List list = new ArrayList(roots.length);
+ // filter out package fragments that correspond to projects and
+ // replace them with the package fragments directly
+ for (int i = 0; i < roots.length; i++) {
+ IProjectFragment root = roots[i];
+ if (!isProjectProjectFragment(root)) {
+ if (!(root instanceof TclSourcesFragment)) {
+ // FIXME Exclude "Sources" element for now
+ list.add(root);
+ }
+ }
+ }
+ return list.toArray();
+ }
+
+}
diff --git a/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclProjectsView.java b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclProjectsView.java
new file mode 100644
index 0000000..7bf05f9
--- /dev/null
+++ b/tcl/plugins/org.eclipse.dltk.tcl.ui/src/org/eclipse/dltk/tcl/internal/ui/browsing/TclProjectsView.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 xored software, 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:
+ * xored software, Inc. - initial API and Implementation (Alex Panchenko)
+ *******************************************************************************/
+package org.eclipse.dltk.tcl.internal.ui.browsing;
+
+import org.eclipse.dltk.ui.browsing.ProjectsView;
+import org.eclipse.dltk.ui.viewsupport.DecoratingModelLabelProvider;
+import org.eclipse.dltk.ui.viewsupport.ScriptUILabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+
+public class TclProjectsView extends ProjectsView {
+
+ @Override
+ protected DecoratingModelLabelProvider createDecoratingLabelProvider(
+ ScriptUILabelProvider provider) {
+ return new TclDecoratingModelLabelProvider(provider);
+ }
+
+ @Override
+ protected IContentProvider createContentProvider() {
+ return new TclProjectAndSourceFolderContentProvider(this, getToolkit());
+ }
+
+}