use of com.intellij.util.xml.TypeChooser in project intellij-community by JetBrains.
the class AddDomElementAction method getChildren.
@NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
Project project = e == null ? null : e.getProject();
if (project == null)
return AnAction.EMPTY_ARRAY;
DomCollectionChildDescription[] descriptions = getDomCollectionChildDescriptions(e);
final List<AnAction> actions = new ArrayList<>();
for (DomCollectionChildDescription description : descriptions) {
final TypeChooser chooser = DomManager.getDomManager(project).getTypeChooserManager().getTypeChooser(description.getType());
for (Type type : chooser.getChooserTypes()) {
final Class<?> rawType = ReflectionUtil.getRawType(type);
String name = TypePresentationService.getService().getTypePresentableName(rawType);
Icon icon = null;
if (!showAsPopup() || descriptions.length == 1) {
// if (descriptions.length > 1) {
icon = ElementPresentationManager.getIconForClass(rawType);
// }
}
actions.add(createAddingAction(e, ApplicationBundle.message("action.add") + " " + name, icon, type, description));
}
}
if (actions.size() > 1 && showAsPopup()) {
ActionGroup group = new ActionGroup() {
@Override
@NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return actions.toArray(new AnAction[actions.size()]);
}
};
return new AnAction[] { new ShowPopupAction(group) };
} else {
if (actions.size() > 1) {
actions.add(Separator.getInstance());
} else if (actions.size() == 1) {
}
}
return actions.toArray(new AnAction[actions.size()]);
}
Aggregations