use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class BasicAction method update.
/**
* Disable the action if the event does not apply in this context.
*
* @param e The update event
*/
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
presentation.setEnabled(false);
presentation.setVisible(false);
return;
}
VirtualFile[] vFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (vFiles == null || vFiles.length == 0) {
presentation.setEnabled(false);
presentation.setVisible(true);
return;
}
GitVcs vcs = GitVcs.getInstance(project);
boolean enabled = ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, vFiles) && isEnabled(project, vcs, vFiles);
// only enable action if all the targets are under the vcs and the action supports all of them
presentation.setEnabled(enabled);
if (ActionPlaces.isPopupPlace(e.getPlace())) {
presentation.setVisible(enabled);
} else {
presentation.setVisible(true);
}
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class GitAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
Presentation presentation = e.getPresentation();
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null || project.isDisposed()) {
presentation.setEnabled(false);
presentation.setVisible(false);
return;
}
presentation.setEnabled(isEnabled(e));
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class GradleExecuteTaskAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
Presentation p = e.getPresentation();
p.setVisible(isVisible(e));
p.setEnabled(isEnabled(e));
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class InspectionViewActionBase method update.
@Override
public final void update(AnActionEvent e) {
final InspectionResultsView view = getView(e);
final boolean enabled = view != null && isEnabled(view, e);
final Presentation presentation = e.getPresentation();
presentation.setEnabled(enabled);
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class BaseCodeInsightAction method update.
@Override
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
DataContext dataContext = event.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
presentation.setEnabled(false);
return;
}
final Lookup activeLookup = LookupManager.getInstance(project).getActiveLookup();
if (activeLookup != null) {
presentation.setEnabled(isValidForLookup());
} else {
super.update(event);
}
}
Aggregations