@Override public void navigate(@Nullable final MouseEvent event, @Nullable final PsiElement elt) { final List<PsiElement> list; DumbService dumbService = elt != null ? DumbService.getInstance(elt.getProject()) : null; if (dumbService != null) dumbService.setAlternativeResolveEnabled(true); try { list = getTargetElements(); } finally { if (dumbService != null) dumbService.setAlternativeResolveEnabled(false); } if (list.isEmpty()) { if (myEmptyText != null) { if (event != null) { final JComponent label = HintUtil.createErrorLabel(myEmptyText); label.setBorder(IdeBorderFactory.createEmptyBorder(2, 7, 2, 7)); JBPopupFactory.getInstance().createBalloonBuilder(label) .setFadeoutTime(3000) .setFillColor(HintUtil.ERROR_COLOR) .createBalloon() .show(new RelativePoint(event), Balloon.Position.above); } } return; } if (list.size() == 1) { PsiNavigateUtil.navigate(list.iterator().next()); } else { if (event != null) { final JBPopup popup = NavigationUtil.getPsiElementPopup(PsiUtilCore.toPsiElementArray(list), myCellRenderer.compute(), myPopupTitle); popup.show(new RelativePoint(event)); } } }
protected void doNavigate(XmlFile file) { if (file.isValid() && LayoutPullParserFactory.isSupported(file)) { VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null && virtualFile.isValid()) { if (AndroidEditorSettings.getInstance().getGlobalState().isPreferXmlEditor()) { new OpenFileDescriptor(file.getProject(), virtualFile, 0).navigate(true); } else { new OpenFileDescriptor(file.getProject(), virtualFile).navigate(true); } } } else { PsiNavigateUtil.navigate(file); } }
public void navigate(@Nullable final MouseEvent event, @Nullable final PsiElement elt) { final List<PsiElement> list = getTargetElements(); if (list.isEmpty()) { if (myEmptyText != null) { if (event != null) { final JComponent label = HintUtil.createErrorLabel(myEmptyText); label.setBorder(IdeBorderFactory.createEmptyBorder(2, 7, 2, 7)); JBPopupFactory.getInstance().createBalloonBuilder(label) .setPreferredPosition(Balloon.Position.above) .setFadeoutTime(3000) .setFillColor(HintUtil.ERROR_COLOR) .createBalloon() .show(new RelativePoint(event), Balloon.Position.above); } } return; } if (list.size() == 1) { PsiNavigateUtil.navigate(list.iterator().next()); } else { if (event != null) { final JBPopup popup = NavigationUtil.getPsiElementPopup(PsiUtilCore.toPsiElementArray(list), myCellRenderer.compute(), myPopupTitle); popup.show(new RelativePoint(event)); } } }
@RequiredDispatchThread public void navigate(@Nullable final MouseEvent event, @Nullable final PsiElement elt) { final List<PsiElement> list = getTargetElements(); if (list.isEmpty()) { if (myEmptyText != null) { if (event != null) { final JComponent label = HintUtil.createErrorLabel(myEmptyText); label.setBorder(IdeBorderFactory.createEmptyBorder(2, 7, 2, 7)); JBPopupFactory.getInstance().createBalloonBuilder(label) .setFadeoutTime(3000) .setFillColor(HintUtil.ERROR_COLOR) .createBalloon() .show(new RelativePoint(event), Balloon.Position.above); } } return; } if (list.size() == 1) { PsiNavigateUtil.navigate(list.iterator().next()); } else { if (event != null) { final JBPopup popup = NavigationUtil.getPsiElementPopup(PsiUtilCore.toPsiElementArray(list), myCellRenderer.compute(), myPopupTitle); popup.show(new RelativePoint(event)); } } }
public void navigate() { PsiNavigateUtil.navigate(myElement); }
protected static void navigate(final PsiElement element) { PsiNavigateUtil.navigate(element); }
public static void addHandlerMethodAndNavigate(@NotNull final Project project, @NotNull final PsiClass psiClass, @NotNull final String methodName, @NotNull final String methodParamType) { if (!AndroidUtils.isIdentifier(methodName)) { Messages.showErrorDialog(project, String.format("%1$s is not a valid Java identifier/method name.", methodName), "Invalid Name"); return; } ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { final PsiMethod method = addHandlerMethod(project, psiClass, methodName, methodParamType); if (method == null) { return; } if (!ApplicationManager.getApplication().isUnitTestMode()) { PsiNavigateUtil.navigate(method); } final PsiFile javaFile = method.getContainingFile(); if (javaFile == null) { return; } final Editor javaEditor = PsiUtilBase.findEditor(method); if (javaEditor == null) { return; } final PsiCodeBlock body = method.getBody(); if (body != null) { final PsiJavaToken lBrace = body.getLBrace(); if (lBrace != null) { javaEditor.getCaretModel().moveToOffset(lBrace.getTextRange().getEndOffset()); } } } }); }
@Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { DomElement element = DomUtil.getDomElement(descriptor.getPsiElement()); if (!(element instanceof ExtensionPoint)) { return; } ExtensionPoint extensionPoint = (ExtensionPoint)element; List<PsiField> fields = ExtensionPointBeanClassInspection.collectMissingWithTags(extensionPoint); PsiElement navTarget = null; for (PsiField field : fields) { With with = extensionPoint.addWith(); String tagName = PluginFieldNameConverter.getAnnotationValue(field, Tag.class); if (tagName != null) { with.getTag().setStringValue(tagName); } else { String attributeName = PluginFieldNameConverter.getAttributeAnnotationValue(field); if (attributeName == null) { attributeName = field.getName(); } if (attributeName.equals("forClass")) { continue; } with.getAttribute().setStringValue(attributeName); } String epName = extensionPoint.getName().getStringValue(); String className = ""; if (epName != null) { int pos = epName.lastIndexOf('.'); epName = StringUtil.capitalize(pos >= 0 ? epName.substring(pos+1) : epName); PsiClass[] classesByName = PsiShortNamesCache.getInstance(project).getClassesByName(epName, ProjectScope.getAllScope(project)); if (classesByName.length == 1) { className = classesByName[0].getQualifiedName(); } } with.getImplements().setStringValue(className); if (navTarget == null) { navTarget = with.getImplements().getXmlAttributeValue(); } } if (navTarget != null) { PsiNavigateUtil.navigate(navTarget); } }