use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class ListenerNavigateButton method buildNavigateActionGroup.
private static DefaultActionGroup buildNavigateActionGroup(RadComponent component, final PsiField boundField) {
final DefaultActionGroup actionGroup = new DefaultActionGroup();
final EventSetDescriptor[] eventSetDescriptors;
try {
BeanInfo beanInfo = Introspector.getBeanInfo(component.getComponentClass());
eventSetDescriptors = beanInfo.getEventSetDescriptors();
} catch (IntrospectionException e) {
LOG.error(e);
return null;
}
PsiFile boundClassFile = boundField.getContainingFile();
if (boundClassFile == null) {
return null;
}
final LocalSearchScope scope = new LocalSearchScope(boundClassFile);
ReferencesSearch.search(boundField, scope).forEach(ref -> {
final PsiElement element = ref.getElement();
if (element.getParent() instanceof PsiReferenceExpression) {
PsiReferenceExpression refExpr = (PsiReferenceExpression) element.getParent();
if (refExpr.getParent() instanceof PsiMethodCallExpression) {
PsiMethodCallExpression methodCall = (PsiMethodCallExpression) refExpr.getParent();
final PsiElement psiElement = refExpr.resolve();
if (psiElement instanceof PsiMethod) {
PsiMethod method = (PsiMethod) psiElement;
for (EventSetDescriptor eventSetDescriptor : eventSetDescriptors) {
if (Comparing.equal(eventSetDescriptor.getAddListenerMethod().getName(), method.getName())) {
final String eventName = eventSetDescriptor.getName();
final PsiExpression[] args = methodCall.getArgumentList().getExpressions();
if (args.length > 0) {
addListenerRef(actionGroup, eventName, args[0]);
}
}
}
}
}
}
return true;
});
return actionGroup;
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class ListenerNavigateButton method showNavigatePopup.
public static void showNavigatePopup(final RadComponent component, final boolean showIfEmpty) {
final DefaultActionGroup actionGroup = prepareActionGroup(component);
if (actionGroup != null && actionGroup.getChildrenCount() == 0 && showIfEmpty) {
actionGroup.add(new MyNavigateAction(UIDesignerBundle.message("navigate.to.listener.empty"), null));
}
if (actionGroup != null && actionGroup.getChildrenCount() > 0) {
final DataContext context = DataManager.getInstance().getDataContext(component.getDelegee());
final JBPopupFactory factory = JBPopupFactory.getInstance();
final ListPopup popup = factory.createActionGroupPopup(UIDesignerBundle.message("navigate.to.listener.title"), actionGroup, context, JBPopupFactory.ActionSelectionAid.NUMBERING, true);
FormEditingUtil.showPopupUnderComponent(popup, component);
}
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class GitBranchPopup method createRepositoriesActions.
@NotNull
@Override
protected DefaultActionGroup createRepositoriesActions() {
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
popupGroup.addSeparator("Repositories");
List<ActionGroup> rootActions = DvcsUtil.sortRepositories(myRepositoryManager.getRepositories()).stream().map(repo -> new RootAction<>(repo, highlightCurrentRepo() ? myCurrentRepository : null, new GitBranchPopupActions(repo.getProject(), repo).createActions(), GitBranchUtil.getDisplayableBranchText(repo))).collect(toList());
wrapWithMoreActionIfNeeded(myProject, popupGroup, rootActions, rootActions.size() > MAX_NUM ? DEFAULT_NUM : MAX_NUM, SHOW_ALL_REPOSITORIES);
return popupGroup;
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class ProjectLevelVcsManagerImpl method getOrCreateConsoleContent.
private Content getOrCreateConsoleContent(final ContentManager contentManager) {
final String displayName = VcsBundle.message("vcs.console.toolwindow.display.name");
Content content = contentManager.findContent(displayName);
if (content == null) {
releaseConsole();
myConsole = TextConsoleBuilderFactory.getInstance().createBuilder(myProject).getConsole();
JPanel panel = new JPanel(new BorderLayout());
panel.add(myConsole.getComponent(), BorderLayout.CENTER);
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, new DefaultActionGroup(myConsole.createConsoleActions()), false);
panel.add(toolbar.getComponent(), BorderLayout.WEST);
content = ContentFactory.SERVICE.getInstance().createContent(panel, displayName, true);
content.setDisposer(myConsoleDisposer);
contentManager.addContent(content);
for (Pair<String, ConsoleViewContentType> pair : myPendingOutput) {
printToConsole(pair.first, pair.second);
}
myPendingOutput.clear();
}
return content;
}
use of com.intellij.openapi.actionSystem.DefaultActionGroup in project intellij-community by JetBrains.
the class RemoteFilePanel method initToolbar.
private void initToolbar(Project project) {
DefaultActionGroup group = new DefaultActionGroup();
group.add(new RefreshRemoteFileAction(myVirtualFile));
for (RemoteFileEditorActionProvider actionProvider : RemoteFileEditorActionProvider.EP_NAME.getExtensions()) {
group.addAll(actionProvider.createToolbarActions(project, myVirtualFile));
}
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
myToolbarPanel.add(actionToolbar.getComponent(), BorderLayout.CENTER);
}
Aggregations