package fr.adrienbrault.idea.symfony2plugin.navigation;

import com.intellij.ide.util.PsiNavigationSupport;
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.NavigationItem;
import com.intellij.pom.Navigatable;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

class NavigationItemEx implements NavigationItem {

    private PsiElement psiElement;
    private String name;
    private Icon icon;
    private String locationString;

    public NavigationItemEx(PsiElement psiElement, final String name, final Icon icon, final String locationString) {
        this.psiElement = psiElement;
        this.name = name;
        this.icon = icon;
        this.locationString = locationString;
    }

    @Nullable
    @Override
    public String getName() {
        return this.name;
    }

    @Nullable
    @Override
    public ItemPresentation getPresentation() {

        return new ItemPresentation() {
            @Nullable
            @Override
            public String getPresentableText() {
                return name;
            }

            @Nullable
            @Override
            public String getLocationString() {
                return locationString;
            }

            @Nullable
            @Override
            public Icon getIcon(boolean b) {
                return icon;
            }
        };
    }

    @Override
    public void navigate(boolean requestFocus) {
        final Navigatable descriptor = PsiNavigationSupport.getInstance().getDescriptor(this.psiElement);
        if (descriptor != null) {
            descriptor.navigate(requestFocus);
        }
    }

    @Override
    public boolean canNavigate() {
        return PsiNavigationSupport.getInstance().canNavigate(this.psiElement);
    }

    @Override
    public boolean canNavigateToSource() {
        return canNavigate();
    }

    @Override
    public String toString() {
        return this.name;
    }
}


@@ -50,16 +50,70 @@
 ation;%0A%0A
+import com.intellij.ide.projectView.PresentationData;%0A
 import c
@@ -990,17 +990,16 @@
 ion() %7B%0A
-%0A
         
@@ -1009,20 +1009,16 @@
 urn new 
-Item
 Presenta
@@ -1025,437 +1025,61 @@
 tion
-() %7B%0A            @Nullable%0A            @Override%0A            public String getPresentableText() %7B%0A                return name;%0A            %7D%0A%0A            @Nullable%0A            @Override%0A            public String getLocationString() %7B%0A                return locationString;%0A            %7D%0A%0A            @Nullable%0A            @Override%0A            public Icon getIcon(boolean b) %7B%0A                return icon;%0A            %7D%0A        %7D
+Data(this.name, this.locationString, this.icon, null)
 ;%0A  

use some core ItemPresentation #189