use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class MorphAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
Processor<ComponentItem> processor = selectedValue -> {
Runnable runnable = () -> {
for (RadComponent c : selection) {
if (!morphComponent(editor, c, selectedValue))
break;
}
editor.refreshAndSave(true);
};
CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(editor.getGlassLayer(), true);
});
return true;
};
PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastMorphComponent, processor, UIDesignerBundle.message("morph.component.title"));
step.hideNonAtomic();
if (selection.size() == 1) {
step.hideComponentClass(selection.get(0).getComponentClassName());
}
final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class BoundIconRenderer method getClickAction.
@Override
@Nullable
public AnAction getClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
List<PsiFile> formFiles = getBoundFormFiles();
if (formFiles.size() > 0) {
final VirtualFile virtualFile = formFiles.get(0).getVirtualFile();
if (virtualFile == null) {
return;
}
Project project = myElement.getProject();
FileEditor[] editors = FileEditorManager.getInstance(project).openFile(virtualFile, true);
if (myElement instanceof PsiField) {
for (FileEditor editor : editors) {
if (editor instanceof UIFormEditor) {
((UIFormEditor) editor).selectComponent(((PsiField) myElement).getName());
}
}
}
}
}
};
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class TestNGConfigurationEditor method createView.
private void createView() {
commonParametersPanel.add(commonJavaParameters, BorderLayout.CENTER);
classField.setComponent(new EditorTextFieldWithBrowseButton(project, true, new JavaCodeFragment.VisibilityChecker() {
@Override
public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
if (declaration instanceof PsiClass && place.getParent() instanceof PsiJavaCodeReferenceElement) {
return Visibility.VISIBLE;
}
try {
if (declaration instanceof PsiClass && new TestClassBrowser(project, TestNGConfigurationEditor.this).getFilter().isAccepted((PsiClass) declaration)) {
return Visibility.VISIBLE;
}
} catch (MessageInfoException e) {
return Visibility.NOT_VISIBLE;
}
return Visibility.NOT_VISIBLE;
}
}));
final EditorTextFieldWithBrowseButton methodEditorTextField = new EditorTextFieldWithBrowseButton(project, true, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, PlainTextLanguage.INSTANCE.getAssociatedFileType());
methodField.setComponent(methodEditorTextField);
groupField.setComponent(new TextFieldWithBrowseButton.NoPathCompletion());
suiteField.setComponent(new TextFieldWithBrowseButton());
packageField.setVisible(true);
packageField.setEnabled(true);
packageField.setComponent(new EditorTextFieldWithBrowseButton(project, false));
TextFieldWithBrowseButton outputDirectoryButton = new TextFieldWithBrowseButton();
outputDirectory.setComponent(outputDirectoryButton);
outputDirectoryButton.addBrowseFolderListener("TestNG", "Select test output directory", project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
moduleClasspath.setEnabled(true);
moduleClasspath.setComponent(new ModulesComboBox());
propertiesTableModel = new TestNGParametersTableModel();
listenerModel = new TestNGListenersTableModel();
TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
propertiesFile.setComponent(textFieldWithBrowseButton);
FileChooserDescriptor propertiesFileDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileVisible(VirtualFile virtualFile, boolean showHidden) {
if (!showHidden && virtualFile.getName().charAt(0) == '.')
return false;
return virtualFile.isDirectory() || "properties".equals(virtualFile.getExtension());
}
};
textFieldWithBrowseButton.addBrowseFolderListener("TestNG", "Select .properties file for test properties", project, propertiesFileDescriptor);
propertiesTableView = new TableView(propertiesTableModel);
myPropertiesPanel.add(ToolbarDecorator.createDecorator(propertiesTableView).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
propertiesTableModel.addParameter();
int index = propertiesTableModel.getRowCount() - 1;
propertiesTableView.setRowSelectionInterval(index, index);
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int idx = propertiesTableView.getSelectedRow() - 1;
for (int row : propertiesTableView.getSelectedRows()) {
propertiesTableModel.removeProperty(row);
}
if (idx > -1)
propertiesTableView.setRowSelectionInterval(idx, idx);
}
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
myListenersList = new JBList(listenerModel);
myListenersPanel.add(ToolbarDecorator.createDecorator(myListenersList).setAddAction(new AddActionButtonRunnable()).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int idx = myListenersList.getSelectedIndex() - 1;
for (int row : myListenersList.getSelectedIndices()) {
listenerModel.removeListener(row);
}
if (idx > -1)
myListenersList.setSelectedIndex(idx);
}
}).setAddActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return !project.isDefault();
}
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class JBTabbedTerminalWidget method convertActions.
public static void convertActions(@NotNull JComponent component, @NotNull List<TerminalAction> actions, @Nullable final Predicate<KeyEvent> elseAction) {
for (final TerminalAction action : actions) {
if (action.isHidden()) {
continue;
}
AnAction a = new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
KeyEvent event = e.getInputEvent() instanceof KeyEvent ? (KeyEvent) e.getInputEvent() : null;
if (!action.perform(event)) {
if (elseAction != null) {
elseAction.apply(event);
}
}
}
};
a.registerCustomShortcutSet(action.getKeyCode(), action.getModifiers(), component);
}
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class OpenUrlHyperlinkInfo method getPopupMenuGroup.
@Override
public ActionGroup getPopupMenuGroup(@NotNull MouseEvent event) {
DefaultActionGroup group = new DefaultActionGroup();
for (final WebBrowser browser : WebBrowserManager.getInstance().getActiveBrowsers()) {
if (browserCondition.value(browser)) {
group.add(new AnAction("Open in " + browser.getName(), "Open URL in " + browser.getName(), browser.getIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
BrowserLauncher.getInstance().browse(url, browser, e.getProject());
}
});
}
}
group.add(new AnAction("Copy URL", "Copy URL to clipboard", PlatformIcons.COPY_ICON) {
@Override
public void actionPerformed(AnActionEvent e) {
CopyPasteManager.getInstance().setContents(new StringSelection(url));
}
});
return group;
}
Aggregations