package org.mustbe.consulo.unity3d.editor;

import javax.swing.Icon;

import org.jetbrains.annotations.Nullable;
import com.intellij.lang.Language;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.NavigatablePsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.light.LightElement;

/**
 * @author VISTALL
 * @since 17.01.2016
 */
public class UnitySceneFile extends LightElement implements NavigatablePsiElement
{
	private VirtualFile myVirtualFile;

	public UnitySceneFile(Project project, VirtualFile virtualFile)
	{
		super(PsiManager.getInstance(project), Language.ANY);
		myVirtualFile = virtualFile;
	}

	@Override
	public void navigate(boolean requestFocus)
	{
		if("unity".equals(myVirtualFile.getName()))
		{
			return;
		}
		UnityOpenScene p = new UnityOpenScene(myVirtualFile.getPath());
		UnityEditorCommunication.request(getProject(), p, false);
	}

	@Override
	public ItemPresentation getPresentation()
	{
		return new ItemPresentation()
		{
			@Nullable
			@Override
			public String getPresentableText()
			{
				return myVirtualFile.getName();
			}

			@Nullable
			@Override
			public String getLocationString()
			{
				return myVirtualFile.getPath();
			}

			@Nullable
			@Override
			public Icon getIcon(boolean unused)
			{
				return myVirtualFile.getFileType().getIcon();
			}
		};
	}

	@Override
	public String toString()
	{
		return "SceneFile: " + myVirtualFile;
	}
}

@@ -235,16 +235,57 @@
 roject;%0A
+import com.intellij.openapi.vfs.VfsUtil;%0A
 import c
@@ -1208,38 +1208,80 @@
 %09return 
-myVirtualFile.getName(
+VfsUtil.getRelativePath(myVirtualFile, getProject().getBaseDir()
 );%0A%09%09%09%7D%0A
@@ -1360,39 +1360,20 @@
 %09return 
-myVirtualFile.getPath()
+null
 ;%0A%09%09%09%7D%0A%0A

use relative path