use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class ConfigureBranchesAction method update.
public void update(final AnActionEvent e) {
final Project project = e.getProject();
final Presentation presentation = e.getPresentation();
if (project == null) {
presentation.setEnabled(false);
presentation.setVisible(false);
return;
}
presentation.setText(SvnBundle.message("configure.branches.item"));
presentation.setDescription(SvnBundle.message("configure.branches.item"));
presentation.setIcon(SvnIcons.ConfigureBranches);
presentation.setVisible(true);
final ChangeList[] cls = e.getData(VcsDataKeys.CHANGE_LISTS);
presentation.setEnabled((cls != null) && (cls.length > 0) && (SvnVcs.getInstance(project).getName().equals(((CommittedChangeList) cls[0]).getVcs().getName())) && (((SvnChangeList) cls[0]).getRoot() != null));
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class AbstractComboBoxAction method createPopupActionGroup.
@NotNull
@Override
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
DefaultActionGroup actionGroup = new DefaultActionGroup();
for (final T item : myItems) {
if (addSeparator(actionGroup, item)) {
continue;
}
AnAction action = new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
if (mySelection != item && selectionChanged(item)) {
mySelection = item;
AbstractComboBoxAction.this.update(item, myPresentation, false);
}
}
};
actionGroup.add(action);
Presentation presentation = action.getTemplatePresentation();
presentation.setIcon(mySelection == item ? CHECKED : null);
update(item, presentation, true);
}
return actionGroup;
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class CCChangeCourseInfo method update.
@Override
public void update(@NotNull AnActionEvent event) {
final Project project = event.getProject();
final Presentation presentation = event.getPresentation();
if (project == null) {
return;
}
presentation.setEnabledAndVisible(false);
if (!CCUtils.isCourseCreator(project)) {
return;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return;
}
presentation.setEnabledAndVisible(true);
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class CCCreateCourseArchive method update.
@Override
public void update(@NotNull AnActionEvent e) {
Presentation presentation = e.getPresentation();
Project project = e.getProject();
presentation.setEnabledAndVisible(project != null && CCUtils.isCourseCreator(project));
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class CCCreateStudyItemActionBase method update.
@Override
public void update(@NotNull AnActionEvent event) {
final Presentation presentation = event.getPresentation();
presentation.setEnabledAndVisible(false);
final Project project = event.getData(CommonDataKeys.PROJECT);
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (project == null || view == null) {
return;
}
if (!StudyUtils.isStudyProject(project) || !CCUtils.isCourseCreator(project)) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return;
}
final PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null || sourceDirectory == null) {
return;
}
if (!isAddedAsLast(sourceDirectory, project, course) && getThresholdItem(course, sourceDirectory) == null) {
return;
}
if (CommonDataKeys.PSI_FILE.getData(event.getDataContext()) != null) {
return;
}
presentation.setEnabledAndVisible(true);
}
Aggregations