Search in sources :

Example 1 with Navigatable

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

the class XmlAttributeDeclImpl method navigate.

@Override
public void navigate(final boolean requestFocus) {
    if (isPhysical()) {
        super.navigate(requestFocus);
        return;
    }
    final PsiNamedElement psiNamedElement = XmlUtil.findRealNamedElement(this);
    Navigatable navigatable = PsiNavigationSupport.getInstance().getDescriptor(psiNamedElement);
    if (psiNamedElement instanceof XmlEntityDecl) {
        navigatable = PsiNavigationSupport.getInstance().createNavigatable(psiNamedElement.getProject(), psiNamedElement.getContainingFile().getVirtualFile(), psiNamedElement.getTextRange().getStartOffset() + psiNamedElement.getText().indexOf(getName()));
    }
    if (navigatable != null) {
        navigatable.navigate(requestFocus);
    }
}
Also used : PsiNamedElement(com.intellij.psi.PsiNamedElement) Navigatable(com.intellij.pom.Navigatable)

Example 2 with Navigatable

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

the class AddNewPropertyFileAction method update.

@Override
public void update(AnActionEvent e) {
    final Navigatable[] data = CommonDataKeys.NAVIGATABLE_ARRAY.getData(e.getDataContext());
    if (data != null && data.length == 1) {
        if (data[0] instanceof ResourceBundleNode || data[0] instanceof CustomResourceBundlePropertiesFileNode) {
            final ResourceBundle resourceBundle = (ResourceBundle) ((ProjectViewNode) data[0]).getValue();
            LOG.assertTrue(resourceBundle != null);
            if (CreateResourceBundleDialogComponent.getResourceBundlePlacementDirectory(resourceBundle) != null) {
                e.getPresentation().setEnabledAndVisible(true);
                return;
            }
        }
    }
    e.getPresentation().setEnabledAndVisible(false);
}
Also used : ResourceBundleNode(com.intellij.lang.properties.projectView.ResourceBundleNode) CustomResourceBundlePropertiesFileNode(com.intellij.lang.properties.projectView.CustomResourceBundlePropertiesFileNode) ResourceBundle(com.intellij.lang.properties.ResourceBundle) Navigatable(com.intellij.pom.Navigatable)

Example 3 with Navigatable

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

the class CompilerTask method doAddMessage.

private void doAddMessage(final CompilerMessage message) {
    synchronized (myMessageViewLock) {
        if (myErrorTreeView != null) {
            final Navigatable navigatable = message.getNavigatable();
            final VirtualFile file = message.getVirtualFile();
            final CompilerMessageCategory category = message.getCategory();
            final int type = translateCategory(category);
            final String[] text = convertMessage(message);
            if (navigatable != null) {
                final String groupName = file != null ? file.getPresentableUrl() : category.getPresentableText();
                myErrorTreeView.addMessage(type, text, groupName, navigatable, message.getExportTextPrefix(), message.getRenderTextPrefix(), message.getVirtualFile());
            } else {
                myErrorTreeView.addMessage(type, text, file, -1, -1, message.getVirtualFile());
            }
            final boolean shouldAutoActivate = !myMessagesAutoActivated && (CompilerMessageCategory.ERROR.equals(category) || (CompilerMessageCategory.WARNING.equals(category) && !ErrorTreeViewConfiguration.getInstance(myProject).isHideWarnings()));
            if (shouldAutoActivate) {
                myMessagesAutoActivated = true;
                activateMessageView();
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CompilerMessageCategory(com.intellij.openapi.compiler.CompilerMessageCategory) Navigatable(com.intellij.pom.Navigatable)

Example 4 with Navigatable

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

the class OccurenceNavigatorActionBase method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null)
        return;
    OccurenceNavigator navigator = getNavigator(e.getDataContext());
    if (navigator == null) {
        return;
    }
    if (!hasOccurenceToGo(navigator)) {
        return;
    }
    OccurenceNavigator.OccurenceInfo occurenceInfo = go(navigator);
    if (occurenceInfo == null) {
        return;
    }
    Navigatable descriptor = occurenceInfo.getNavigateable();
    if (descriptor != null && descriptor.canNavigate()) {
        descriptor.navigate(true);
    }
    if (occurenceInfo.getOccurenceNumber() == -1 || occurenceInfo.getOccurencesCount() == -1) {
        return;
    }
    WindowManager.getInstance().getStatusBar(project).setInfo(IdeBundle.message("message.occurrence.N.of.M", occurenceInfo.getOccurenceNumber(), occurenceInfo.getOccurencesCount()));
}
Also used : Project(com.intellij.openapi.project.Project) OccurenceNavigator(com.intellij.ide.OccurenceNavigator) Navigatable(com.intellij.pom.Navigatable)

Example 5 with Navigatable

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

the class EditSourceForDialogAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
    if (navigatableArray != null && navigatableArray.length > 0) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {

            public void run() {
                OpenSourceUtil.navigate(navigatableArray);
            }
        });
        DialogWrapper dialog = DialogWrapper.findInstance(mySourceComponent);
        if (dialog != null && dialog.isModal()) {
            dialog.doCancelAction();
        }
    }
}
Also used : DialogWrapper(com.intellij.openapi.ui.DialogWrapper) 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