| /* |
| * Copyright 2000-2009 JetBrains s.r.o. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package com.intellij.ide.actions; |
| |
| import com.intellij.featureStatistics.FeatureUsageTracker; |
| import com.intellij.ide.util.EditSourceUtil; |
| import com.intellij.ide.util.gotoByName.*; |
| import com.intellij.lang.Language; |
| import com.intellij.navigation.ChooseByNameRegistry; |
| import com.intellij.navigation.NavigationItem; |
| import com.intellij.openapi.actionSystem.AnActionEvent; |
| import com.intellij.openapi.actionSystem.CommonDataKeys; |
| import com.intellij.openapi.actionSystem.DataContext; |
| import com.intellij.openapi.actionSystem.PlatformDataKeys; |
| import com.intellij.openapi.project.Project; |
| import com.intellij.psi.PsiDocumentManager; |
| import org.jetbrains.annotations.NotNull; |
| |
| public class GotoSymbolAction extends GotoActionBase { |
| |
| @Override |
| public void gotoActionPerformed(AnActionEvent e) { |
| FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.symbol"); |
| final Project project = e.getData(CommonDataKeys.PROJECT); |
| final GotoSymbolModel2 model = new GotoSymbolModel2(project); |
| PsiDocumentManager.getInstance(project).commitAllDocuments(); |
| showNavigationPopup(e, model, new GotoActionCallback<Language>() { |
| @Override |
| protected ChooseByNameFilter<Language> createFilter(@NotNull ChooseByNamePopup popup) { |
| return new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project), project); |
| } |
| |
| @Override |
| public void elementChosen(ChooseByNamePopup popup, Object element) { |
| EditSourceUtil.navigate((NavigationItem)element, true, popup.isOpenInCurrentWindowRequested()); |
| } |
| }, "Symbols matching patterns", true); |
| } |
| |
| @Override |
| protected boolean hasContributors(DataContext dataContext) { |
| return ChooseByNameRegistry.getInstance().getSymbolModelContributors().length > 0; |
| } |
| |
| } |