use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class LegacyNewAndroidComponentAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
final Module module = LangDataKeys.MODULE.getData(dataContext);
if (module == null)
return;
final AndroidFacet facet = AndroidFacet.getInstance(module);
assert facet != null;
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null)
return;
NewAndroidComponentDialog dialog = new NewAndroidComponentDialog(module, dir);
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
return;
}
final PsiElement[] createdElements = dialog.getCreatedElements();
for (PsiElement createdElement : createdElements) {
view.selectElement(createdElement);
}
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class OpenStringResourceEditorAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext context = e.getDataContext();
final Project project = e.getProject();
final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
if (project == null || file == null) {
return;
}
StringResourceEditorProvider.openEditor(project, file);
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class MakeGradleModuleAction method updatePresentation.
public static void updatePresentation(@NotNull AnActionEvent e, @NotNull Project project) {
DataContext dataContext = e.getDataContext();
Module[] modules = getModulesToBuildFromSelection(project, dataContext);
int moduleCount = modules.length;
Presentation presentation = e.getPresentation();
presentation.setEnabled(moduleCount > 0);
String presentationText;
if (moduleCount > 0) {
String text = "Make Module";
if (moduleCount > 1) {
text += "s";
}
for (int i = 0; i < moduleCount; i++) {
if (text.length() > 30) {
text = "Make Selected Modules";
break;
}
Module toMake = modules[i];
if (i != 0) {
text += ",";
}
text += " '" + toMake.getName() + "'";
}
presentationText = text;
} else {
presentationText = "Make";
}
presentation.setText(presentationText);
presentation.setVisible(moduleCount > 0 || !PROJECT_VIEW_POPUP.equals(e.getPlace()));
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class LinkExternalCppProjectAction method doUpdate.
@Override
protected void doUpdate(@NotNull AnActionEvent e, @NotNull Project project) {
DataContext dataContext = e.getDataContext();
boolean enable = isValidAndroidGradleModuleSelected(dataContext);
Presentation presentation = e.getPresentation();
presentation.setEnabled(enable);
presentation.setVisible(enable);
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class ConfigurationAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final ActionManagerEx manager = ActionManagerEx.getInstanceEx();
final DataContext dataContext = e.getDataContext();
// Regular actions invoke this method before performing the action. We do so as well since the analytics subsystem hooks into
// this event to monitor invoked actions.
manager.fireBeforeActionPerformed(this, dataContext, e);
tryUpdateConfiguration();
updatePresentation();
}
Aggregations