Search in sources :

Example 31 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.

the class AutoScrollToSourceHandler method scrollToSource.

protected void scrollToSource(final Component tree) {
    DataContext dataContext = DataManager.getInstance().getDataContext(tree);
    getReady(dataContext).doWhenDone(() -> {
        DataContext context = DataManager.getInstance().getDataContext(tree);
        final VirtualFile vFile = CommonDataKeys.VIRTUAL_FILE.getData(context);
        if (vFile != null) {
            // asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
            if (vFile.getFileType() == FileTypes.UNKNOWN || vFile.getFileType() instanceof INativeFileType)
                return;
            //IDEA-84881 Don't autoscroll to very large files
            if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize())
                return;
        }
        Navigatable[] navigatables = CommonDataKeys.NAVIGATABLE_ARRAY.getData(context);
        if (navigatables != null) {
            if (navigatables.length > 1) {
                return;
            }
            for (Navigatable navigatable : navigatables) {
                // we are not going to open modal dialog during autoscrolling
                if (!navigatable.canNavigateToSource())
                    return;
            }
        }
        OpenSourceUtil.navigate(false, true, navigatables);
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) INativeFileType(com.intellij.openapi.fileTypes.INativeFileType) Navigatable(com.intellij.pom.Navigatable)

Example 32 with Navigatable

use of com.intellij.pom.Navigatable in project intellij-plugins by JetBrains.

the class ResolveExternalInlineStyleSourceAction method run.

@Override
public void run() {
    Navigatable target = find();
    if (target == null) {
        LOG.error("Can't find target property " + targetStyleName + " of " + elementFqn + " in " + parentFqn);
    } else {
        target.navigate(true);
        ProjectUtil.focusProjectWindow(project, true);
    }
}
Also used : Navigatable(com.intellij.pom.Navigatable)

Example 33 with Navigatable

use of com.intellij.pom.Navigatable in project intellij by bazelbuild.

the class IssueOutputFilter method openConsoleToHyperlink.

private Navigatable openConsoleToHyperlink(HyperlinkInfo link, int originalOffset) {
    return new Navigatable() {

        @Override
        public void navigate(boolean requestFocus) {
            BlazeConsoleView consoleView = BlazeConsoleView.getInstance(project);
            ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(BlazeConsoleToolWindowFactory.ID);
            toolWindow.activate(() -> consoleView.navigateToHyperlink(link, originalOffset), true);
        }

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

        @Override
        public boolean canNavigateToSource() {
            return true;
        }
    };
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Navigatable(com.intellij.pom.Navigatable) BlazeConsoleView(com.google.idea.blaze.base.console.BlazeConsoleView)

Example 34 with Navigatable

use of com.intellij.pom.Navigatable in project intellij by bazelbuild.

the class AndroidSdkFromProjectView method getAndroidSdkPlatform.

@Nullable
public static AndroidSdkPlatform getAndroidSdkPlatform(BlazeContext context, ProjectViewSet projectViewSet) {
    List<Sdk> sdks = BlazeSdkProvider.getInstance().getAllAndroidSdks();
    if (sdks.isEmpty()) {
        IssueOutput.error("No Android SDK configured. Please use the SDK manager to configure.").navigatable(new Navigatable() {

            @Override
            public void navigate(boolean b) {
                SdkUtil.openSdkManager();
            }

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

            @Override
            public boolean canNavigateToSource() {
                return false;
            }
        }).submit(context);
        return null;
    }
    if (projectViewSet == null) {
        return null;
    }
    String androidSdk = projectViewSet.getScalarValue(AndroidSdkPlatformSection.KEY).orElse(null);
    Integer androidMinSdk = projectViewSet.getScalarValue(AndroidMinSdkSection.KEY).orElse(null);
    if (androidSdk == null) {
        ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
        IssueOutput.error(("No android_sdk_platform set. Please set to an android platform. " + "Available android_sdk_platforms are: " + getAvailableTargetHashesAsList(sdks))).inFile(projectViewFile != null ? projectViewFile.projectViewFile : null).submit(context);
        return null;
    }
    Sdk sdk = BlazeSdkProvider.getInstance().findSdk(androidSdk);
    if (sdk == null) {
        ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
        IssueOutput.error(("No such android_sdk_platform: '" + androidSdk + "'. " + "Available android_sdk_platforms are: " + getAvailableTargetHashesAsList(sdks) + ". " + "Please change android_sdk_platform or run SDK manager " + "to download missing SDK platforms.")).inFile(projectViewFile != null ? projectViewFile.projectViewFile : null).submit(context);
        return null;
    }
    if (androidMinSdk == null) {
        androidMinSdk = getAndroidSdkApiLevel(sdk);
    }
    return new AndroidSdkPlatform(androidSdk, androidMinSdk);
}
Also used : AndroidSdkPlatform(com.google.idea.blaze.android.sync.model.AndroidSdkPlatform) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) Sdk(com.intellij.openapi.projectRoots.Sdk) Navigatable(com.intellij.pom.Navigatable) Nullable(javax.annotation.Nullable)

Example 35 with Navigatable

use of com.intellij.pom.Navigatable in project intellij by bazelbuild.

the class BlazeProblemsViewPanel method scrollToSource.

private void scrollToSource(Component tree) {
    DataContext dataContext = DataManager.getInstance().getDataContext(tree);
    getReady(dataContext).doWhenDone(() -> TransactionGuard.submitTransaction(ApplicationManager.getApplication(), () -> {
        DataContext context = DataManager.getInstance().getDataContext(tree);
        Navigatable navigatable = BLAZE_CONSOLE_NAVIGATABLE_DATA_KEY.getData(context);
        if (navigatable != null) {
            OpenSourceUtil.navigate(false, true, navigatable);
        }
    }));
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Navigatable(com.intellij.pom.Navigatable)

Aggregations

Navigatable (com.intellij.pom.Navigatable)70 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)19 Project (com.intellij.openapi.project.Project)14 Nullable (org.jetbrains.annotations.Nullable)14 PsiElement (com.intellij.psi.PsiElement)11 ArrayList (java.util.ArrayList)9 PsiFile (com.intellij.psi.PsiFile)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)7 TreePath (javax.swing.tree.TreePath)7 NotNull (org.jetbrains.annotations.NotNull)6 Editor (com.intellij.openapi.editor.Editor)4 List (java.util.List)4 TextRange (com.intellij.openapi.util.TextRange)3 XmlTag (com.intellij.psi.xml.XmlTag)3 BlazeConsoleView (com.google.idea.blaze.base.console.BlazeConsoleView)2 IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Document (com.intellij.openapi.editor.Document)2