IDEA-76142: Gradle support - cannot update IDEA projects once one of build.gradle...
authorDenis.Zhdanov <Denis.Zhdanov@jetbrains.com>
Tue, 31 Jan 2012 16:02:43 +0000 (20:02 +0400)
committerDenis.Zhdanov <Denis.Zhdanov@jetbrains.com>
Tue, 31 Jan 2012 16:06:43 +0000 (20:06 +0400)
Added 'navigate to the linked gradle script' action

plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleOpenScriptAction.java

index c6922d6924306a44b10a2475f615290d26914c58..f010e59ebde882bf93ec95ca31c951e9902bc5d5 100644 (file)
@@ -3,8 +3,13 @@ package org.jetbrains.plugins.gradle.action;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.fileEditor.OpenFileDescriptor;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.gradle.config.GradleSettings;
 import org.jetbrains.plugins.gradle.util.GradleBundle;
@@ -19,6 +24,8 @@ import org.jetbrains.plugins.gradle.util.GradleBundle;
  */
 public class GradleOpenScriptAction extends AbstractGradleLinkedProjectAction implements DumbAware {
 
+  private static final Logger LOG = Logger.getInstance("#" + GradleOpenScriptAction.class.getName());
+  
   public GradleOpenScriptAction() {
     getTemplatePresentation().setText(GradleBundle.message("gradle.action.open.script.text"));
     getTemplatePresentation().setDescription(GradleBundle.message("gradle.action.open.script.description"));
@@ -30,6 +37,12 @@ public class GradleOpenScriptAction extends AbstractGradleLinkedProjectAction im
 
   @Override
   protected void doActionPerformed(@NotNull Project project, @NotNull String linkedProjectPath) {
-    // TODO den implement 
+    final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(linkedProjectPath);
+    if (virtualFile == null) {
+      LOG.warn(String.format("Can't obtain virtual file for the target file path: '%s'", linkedProjectPath));
+      return;
+    }
+    OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile);
+    FileEditorManager.getInstance(project).openTextEditor(descriptor, true); 
   }
 }