use of com.intellij.openapi.actionSystem.DataContext in project buck by facebook.
the class BuckToolWindowFactory method handleClickOnError.
private void handleClickOnError(BuckTreeNodeDetailError node) {
TreeNode parentNode = node.getParent();
if (parentNode instanceof BuckTreeNodeFileError) {
BuckTreeNodeFileError buckParentNode = (BuckTreeNodeFileError) parentNode;
DataContext dataContext = DataManager.getInstance().getDataContext();
Project project = DataKeys.PROJECT.getData(dataContext);
String relativePath = buckParentNode.getFilePath().replace(project.getBasePath(), "");
VirtualFile virtualFile = project.getBaseDir().findFileByRelativePath(relativePath);
OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(project, virtualFile, node.getLine() - 1, node.getColumn() - 1);
openFileDescriptor.navigate(true);
}
}
use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.
the class PyTestCase method createRunConfigurationFromContext.
/**
* Creates run configuration from right click menu
*
* @param fixture test fixture
* @param expectedClass expected class of run configuration
* @param <C> expected class of run configuration
* @return configuration (if created) or null (otherwise)
*/
@Nullable
public static <C extends RunConfiguration> C createRunConfigurationFromContext(@NotNull final CodeInsightTestFixture fixture, @NotNull final Class<C> expectedClass) {
final DataContext context = DataManager.getInstance().getDataContext(fixture.getEditor().getComponent());
for (final RunConfigurationProducer<?> producer : RunConfigurationProducer.EP_NAME.getExtensions()) {
final ConfigurationFromContext fromContext = producer.createConfigurationFromContext(ConfigurationContext.getFromContext(context));
if (fromContext == null) {
continue;
}
final C result = PyUtil.as(fromContext.getConfiguration(), expectedClass);
if (result != null) {
return result;
}
}
return null;
}
use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.
the class HgAbstractGlobalAction method actionPerformed.
public void actionPerformed(@NotNull AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
VirtualFile[] files = event.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
final HgRepositoryManager repositoryManager = HgUtil.getRepositoryManager(project);
List<HgRepository> repositories = repositoryManager.getRepositories();
if (!repositories.isEmpty()) {
List<HgRepository> selectedRepositories = files != null ? HgActionUtil.collectRepositoriesFromFiles(repositoryManager, Arrays.asList(files)) : ContainerUtil.<HgRepository>emptyList();
execute(project, repositories, selectedRepositories.isEmpty() ? Collections.singletonList(HgUtil.getCurrentRepository(project)) : selectedRepositories);
}
}
use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.
the class HgActionUtil method getSelectedRepositoryFromEvent.
@Nullable
@CalledInAwt
public static HgRepository getSelectedRepositoryFromEvent(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return null;
}
VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
HgRepositoryManager repositoryManager = HgUtil.getRepositoryManager(project);
return file != null ? repositoryManager.getRepositoryForFileQuick(file) : HgUtil.getCurrentRepository(project);
}
use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.
the class IgnoreActionGroup method update.
public void update(final AnActionEvent e) {
final FileGroupInfo fileGroupInfo = new FileGroupInfo();
myHelperAction.setFileIterationListener(fileGroupInfo);
myHelperAction.update(e);
myGetterStub.setDelegate(fileGroupInfo);
if ((e.getPresentation().isEnabled())) {
removeAll();
if (myHelperAction.allAreIgnored()) {
final DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
SvnVcs vcs = SvnVcs.getInstance(project);
final Ref<Boolean> filesOk = new Ref<>(Boolean.FALSE);
final Ref<Boolean> extensionOk = new Ref<>(Boolean.FALSE);
// virtual files parameter is not used -> can pass null
SvnPropertyService.doCheckIgnoreProperty(vcs, null, fileGroupInfo, fileGroupInfo.getExtensionMask(), filesOk, extensionOk);
if (Boolean.TRUE.equals(filesOk.get())) {
myRemoveExactAction.setActionText(fileGroupInfo.oneFileSelected() ? fileGroupInfo.getFileName() : SvnBundle.message("action.Subversion.UndoIgnore.text"));
add(myRemoveExactAction);
}
if (Boolean.TRUE.equals(extensionOk.get())) {
myRemoveExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
add(myRemoveExtensionAction);
}
e.getPresentation().setText(SvnBundle.message("group.RevertIgnoreChoicesGroup.text"));
} else if (myHelperAction.allCanBeIgnored()) {
final String ignoreExactlyName = (fileGroupInfo.oneFileSelected()) ? fileGroupInfo.getFileName() : SvnBundle.message("action.Subversion.Ignore.ExactMatch.text");
myAddExactAction.setActionText(ignoreExactlyName);
add(myAddExactAction);
if (fileGroupInfo.sameExtension()) {
myAddExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
add(myAddExtensionAction);
}
e.getPresentation().setText(SvnBundle.message("group.IgnoreChoicesGroup.text"));
}
}
}
Aggregations