use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class CheckRegExpForm method createUIComponents.
private void createUIComponents() {
myProject = myRegexpFile.getProject();
Document document = PsiDocumentManager.getInstance(myProject).getDocument(myRegexpFile);
final Language language = myRegexpFile.getLanguage();
final LanguageFileType fileType;
if (language instanceof RegExpLanguage) {
fileType = RegExpLanguage.INSTANCE.getAssociatedFileType();
} else {
// for correct syntax highlighting
fileType = new RegExpFileType(language);
}
myRegExp = new EditorTextField(document, myProject, fileType);
final String sampleText = PropertiesComponent.getInstance(myProject).getValue(LAST_EDITED_REGEXP, "Sample Text");
mySampleText = new EditorTextField(sampleText, myProject, PlainTextFileType.INSTANCE) {
@Override
protected void updateBorder(@NotNull EditorEx editor) {
setupBorder(editor);
}
};
mySampleText.setOneLineMode(false);
int preferredWidth = Math.max(JBUI.scale(250), myRegExp.getPreferredSize().width);
myRegExp.setPreferredWidth(preferredWidth);
mySampleText.setPreferredWidth(preferredWidth);
myRootPanel = new JPanel(new BorderLayout()) {
Disposable disposable;
Alarm updater;
@Override
public void addNotify() {
super.addNotify();
disposable = Disposer.newDisposable();
IdeFocusManager.getGlobalInstance().requestFocus(mySampleText, true);
new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
IdeFocusManager.findInstance().requestFocus(myRegExp.getFocusTarget(), true);
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("shift TAB"), mySampleText);
updater = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, disposable);
DocumentAdapter documentListener = new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
update();
}
};
myRegExp.addDocumentListener(documentListener);
mySampleText.addDocumentListener(documentListener);
update();
mySampleText.selectAll();
}
public void update() {
final TransactionId transactionId = TransactionGuard.getInstance().getContextTransaction();
updater.cancelAllRequests();
if (!updater.isDisposed()) {
updater.addRequest(() -> {
final RegExpMatchResult result = isMatchingText(myRegexpFile, mySampleText.getText());
TransactionGuard.getInstance().submitTransaction(myProject, transactionId, () -> setBalloonState(result));
}, 200);
}
}
@Override
public void removeNotify() {
super.removeNotify();
Disposer.dispose(disposable);
PropertiesComponent.getInstance(myProject).setValue(LAST_EDITED_REGEXP, mySampleText.getText());
}
};
myRootPanel.setBorder(JBUI.Borders.empty(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP));
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project android by JetBrains.
the class GutterIconRenderer method getClickAction.
@Nullable
@Override
public AnAction getClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
if (editor != null) {
Project project = editor.getProject();
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(myFile);
if (project != null && virtualFile != null) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile, -1);
FileEditorManager.getInstance(project).openEditor(descriptor, true);
}
}
}
};
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project android by JetBrains.
the class TargetArtifactsPanel method setHeaderActions.
private void setHeaderActions() {
List<AnAction> additionalActions = Lists.newArrayList();
additionalActions.add(new AbstractBaseExpandAllAction(myTree) {
@Override
public void actionPerformed(AnActionEvent e) {
myTree.requestFocusInWindow();
myTreeBuilder.expandAllNodes();
}
});
additionalActions.add(new AbstractBaseCollapseAllAction(myTree) {
@Override
public void actionPerformed(AnActionEvent e) {
myTree.requestFocusInWindow();
myTreeBuilder.collapseAllNodes();
}
});
getHeader().setAdditionalActions(additionalActions);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project android by JetBrains.
the class GradleBuildTreeViewPanel method fillRightToolbarGroup.
@Override
protected void fillRightToolbarGroup(DefaultActionGroup group) {
super.fillRightToolbarGroup(group);
group.add(new DumbAwareAction("Show Console Output", null, AndroidIcons.GradleConsole) {
@Override
public void actionPerformed(AnActionEvent e) {
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(GradleConsoleToolWindowFactory.ID);
if (window != null) {
window.activate(null, false);
}
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(true);
}
});
DefaultActionGroup filterGroup = new DefaultActionGroup("GradleBuildMessagesFilter", true) {
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setDescription("Filter messages to display");
presentation.setIcon(AllIcons.General.Filter);
}
@Override
public boolean isDumbAware() {
return true;
}
};
// We could have iterated through ErrorTreeElementKind.values() and have less code, but we want to keep this order:
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.ERROR));
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.WARNING));
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.INFO));
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.NOTE));
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.GENERIC));
group.add(filterGroup);
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project android by JetBrains.
the class ConfigurationMenuAction method addMultiConfigActions.
private void addMultiConfigActions(DefaultActionGroup group) {
Configuration configuration = mySurface.getConfiguration();
if (configuration == null) {
return;
}
VirtualFile file = configuration.getFile();
if (file == null) {
return;
}
ConfigurationManager configurationManager = configuration.getConfigurationManager();
group.addSeparator();
group.add(new PreviewAction(mySurface, "Preview Representative Sample", ACTION_PREVIEW_MODE, RenderPreviewMode.DEFAULT, true));
addScreenSizeAction(mySurface, group);
boolean haveMultipleLocales = configurationManager.getLocales().size() > 1;
addLocalePreviewAction(mySurface, group, haveMultipleLocales);
addRtlPreviewAction(mySurface, group);
addApiLevelPreviewAction(mySurface, group);
// TODO: Support included layouts
boolean DISABLE_RENDER_INCLUDED = true;
boolean canPreviewIncluded = !DISABLE_RENDER_INCLUDED && hasCapability(mySurface, Features.EMBEDDED_LAYOUT);
group.add(new PreviewAction(mySurface, "Preview Included", ACTION_PREVIEW_MODE, RenderPreviewMode.INCLUDES, canPreviewIncluded));
List<VirtualFile> variations = ResourceHelper.getResourceVariations(file, true);
group.add(new PreviewAction(mySurface, "Preview Layout Versions", ACTION_PREVIEW_MODE, RenderPreviewMode.VARIATIONS, variations.size() > 1));
group.add(new PreviewAction(mySurface, "None", ACTION_PREVIEW_MODE, RenderPreviewMode.NONE, true));
// Debugging only
group.addSeparator();
group.add(new AnAction("Toggle Layout Mode") {
@Override
public void actionPerformed(AnActionEvent e) {
}
});
}
Aggregations