use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class XDebuggerEditorBase method createLanguagePopup.
private ListPopup createLanguagePopup() {
DefaultActionGroup actions = new DefaultActionGroup();
for (Language language : getSupportedLanguages()) {
//noinspection ConstantConditions
actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
XExpression currentExpression = getExpression();
setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo()));
requestFocusInEditor();
}
});
}
DataContext dataContext = DataManager.getInstance().getDataContext(getComponent());
return JBPopupFactory.getInstance().createActionGroupPopup("Choose Language", actions, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class CreateClassDialog method createNorthPanel.
@Override
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.insets = JBUI.insets(4, 8);
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.anchor = GridBagConstraints.WEST;
if (myClassNameEditable) {
gbConstraints.weightx = 0;
gbConstraints.gridwidth = 1;
panel.add(myInformationLabel, gbConstraints);
gbConstraints.insets = JBUI.insets(4, 8);
gbConstraints.gridx = 1;
gbConstraints.weightx = 1;
gbConstraints.gridwidth = 1;
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.anchor = GridBagConstraints.WEST;
panel.add(myTfClassName, gbConstraints);
myTfClassName.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
getOKAction().setEnabled(PsiNameHelper.getInstance(myProject).isIdentifier(myTfClassName.getText()));
}
});
getOKAction().setEnabled(StringUtil.isNotEmpty(myClassName));
}
gbConstraints.gridx = 0;
gbConstraints.gridy = 2;
gbConstraints.weightx = 0;
gbConstraints.gridwidth = 1;
panel.add(myPackageLabel, gbConstraints);
gbConstraints.gridx = 1;
gbConstraints.weightx = 1;
new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
myPackageComponent.getButton().doClick();
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), myPackageComponent.getChildComponent());
JPanel _panel = new JPanel(new BorderLayout());
_panel.add(myPackageComponent, BorderLayout.CENTER);
panel.add(_panel, gbConstraints);
gbConstraints.gridy = 3;
gbConstraints.gridx = 0;
gbConstraints.gridwidth = 2;
gbConstraints.insets.top = 12;
gbConstraints.anchor = GridBagConstraints.WEST;
gbConstraints.fill = GridBagConstraints.NONE;
final JBLabel label = new JBLabel(RefactoringBundle.message("target.destination.folder"));
panel.add(label, gbConstraints);
gbConstraints.gridy = 4;
gbConstraints.gridx = 0;
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.insets.top = 4;
panel.add(myDestinationCB, gbConstraints);
final boolean isMultipleSourceRoots = JavaProjectRootsUtil.getSuitableDestinationSourceRoots(myProject).size() > 1;
myDestinationCB.setVisible(isMultipleSourceRoots);
label.setVisible(isMultipleSourceRoots);
label.setLabelFor(myDestinationCB);
return panel;
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class FileSystemTreeFactoryImpl method createDefaultFileSystemActions.
public DefaultActionGroup createDefaultFileSystemActions(FileSystemTree fileSystemTree) {
DefaultActionGroup group = new DefaultActionGroup();
final ActionManager actionManager = ActionManager.getInstance();
group.add(actionManager.getAction("FileChooser.GotoHome"));
group.add(actionManager.getAction("FileChooser.GotoProject"));
group.addSeparator();
group.add(actionManager.getAction("FileChooser.NewFolder"));
group.add(actionManager.getAction("FileChooser.Delete"));
group.addSeparator();
SynchronizeAction action1 = new SynchronizeAction();
AnAction original = actionManager.getAction(IdeActions.ACTION_SYNCHRONIZE);
action1.copyFrom(original);
action1.registerCustomShortcutSet(original.getShortcutSet(), fileSystemTree.getTree());
group.add(action1);
group.addSeparator();
group.add(actionManager.getAction("FileChooser.ShowHiddens"));
return group;
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class ChooseFileEncodingAction method fillCharsetActions.
private void fillCharsetActions(@NotNull DefaultActionGroup group, @Nullable final VirtualFile virtualFile, @NotNull List<Charset> charsets, @NotNull final Function<Charset, String> charsetFilter) {
for (final Charset charset : charsets) {
AnAction action = new DumbAwareAction(charset.displayName(), null, EmptyIcon.ICON_16) {
@Override
public void actionPerformed(AnActionEvent e) {
chosen(virtualFile, charset);
}
@Override
public void update(AnActionEvent e) {
super.update(e);
String description = charsetFilter.fun(charset);
e.getPresentation().setIcon(description == null ? AllIcons.General.Warning : null);
e.getPresentation().setDescription(description);
}
};
group.add(action);
}
}
use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.
the class WinDockDelegate method updateRecentProjectsMenu.
@Override
public void updateRecentProjectsMenu() {
final AnAction[] recentProjectActions = RecentProjectsManager.getInstance().getRecentProjectsActions(false);
RecentTasks.clear();
String name = ApplicationNamesInfo.getInstance().getProductName().toLowerCase(Locale.US);
String launcher = RecentTasks.getShortenPath(PathManager.getBinPath() + File.separator + name + (SystemInfo.is64Bit ? "64" : "") + ".exe");
Task[] tasks = new Task[recentProjectActions.length];
for (int i = 0; i < recentProjectActions.length; i++) {
ReopenProjectAction rpa = (ReopenProjectAction) recentProjectActions[i];
tasks[i] = new Task(launcher, RecentTasks.getShortenPath(rpa.getProjectPath()), rpa.getTemplatePresentation().getText());
}
RecentTasks.addTasks(tasks);
}
Aggregations