use of com.intellij.openapi.keymap.impl.ui.KeymapPanel in project intellij-community by JetBrains.
the class MavenKeymapExtension method createGroup.
@Override
public KeymapGroup createGroup(Condition<AnAction> condition, final Project project) {
KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(TasksBundle.message("maven.tasks.action.group.name"), MavenIcons.MavenLogo);
if (project == null)
return result;
Comparator<MavenProject> projectComparator = (o1, o2) -> o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
Map<MavenProject, Set<Pair<String, String>>> projectToActionsMapping = new TreeMap<>(projectComparator);
ActionManager actionManager = ActionManager.getInstance();
//noinspection TestOnlyProblems
for (String eachId : actionManager.getActionIds(getActionPrefix(project, null))) {
AnAction eachAction = actionManager.getAction(eachId);
if (!(eachAction instanceof MavenGoalAction))
continue;
if (condition != null && !condition.value(actionManager.getActionOrStub(eachId)))
continue;
MavenGoalAction mavenAction = (MavenGoalAction) eachAction;
MavenProject mavenProject = mavenAction.getMavenProject();
Set<Pair<String, String>> actions = projectToActionsMapping.get(mavenProject);
if (actions == null) {
final List<String> projectGoals = collectGoals(mavenProject);
actions = new TreeSet<>((o1, o2) -> {
String goal1 = o1.getFirst();
String goal2 = o2.getFirst();
int index1 = projectGoals.indexOf(goal1);
int index2 = projectGoals.indexOf(goal2);
if (index1 == index2)
return goal1.compareToIgnoreCase(goal2);
return (index1 < index2 ? -1 : 1);
});
projectToActionsMapping.put(mavenProject, actions);
}
actions.add(Pair.create(mavenAction.getGoal(), eachId));
}
for (Map.Entry<MavenProject, Set<Pair<String, String>>> each : projectToActionsMapping.entrySet()) {
Set<Pair<String, String>> goalsToActionIds = each.getValue();
for (Pair<String, String> eachGoalToActionId : goalsToActionIds) {
result.addActionId(eachGoalToActionId.getSecond());
}
}
Icon icon = SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add;
((Group) result).addHyperlink(new Hyperlink(icon, "Choose a phase/goal to assign a shortcut") {
@Override
public void onClick(MouseEvent e) {
SelectMavenGoalDialog dialog = new SelectMavenGoalDialog(project);
if (dialog.showAndGet() && dialog.getResult() != null) {
MavenProjectsStructure.GoalNode goalNode = dialog.getResult();
String goal = goalNode.getGoal();
String actionId = MavenShortcutsManager.getInstance(project).getActionId(goalNode.getProjectPath(), goal);
getOrRegisterAction(goalNode.getMavenProject(), actionId, goal);
ApplicationManager.getApplication().getMessageBus().syncPublisher(KeymapListener.CHANGE_TOPIC).processCurrentKeymapChanged();
Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(e.getComponent()));
KeymapPanel keymapPanel = allSettings != null ? allSettings.find(KeymapPanel.class) : null;
if (keymapPanel != null) {
// clear actions filter
keymapPanel.showOption("");
keymapPanel.selectAction(actionId);
}
}
}
});
return result;
}
use of com.intellij.openapi.keymap.impl.ui.KeymapPanel in project intellij-community by JetBrains.
the class TraverseUIStarter method startup.
public static void startup(String outputPath) throws IOException {
Map<SearchableConfigurable, Set<OptionDescription>> options = new LinkedHashMap<>();
try {
SearchUtil.processProjectConfigurables(ProjectManager.getInstance().getDefaultProject(), options);
Element root = new Element(OPTIONS);
for (SearchableConfigurable option : options.keySet()) {
SearchableConfigurable configurable = option;
Element configurableElement = new Element(CONFIGURABLE);
String id = configurable.getId();
configurableElement.setAttribute(ID, id);
configurableElement.setAttribute(CONFIGURABLE_NAME, configurable.getDisplayName());
Set<OptionDescription> sortedOptions = options.get(configurable);
writeOptions(configurableElement, sortedOptions);
if (configurable instanceof ConfigurableWrapper) {
UnnamedConfigurable wrapped = ((ConfigurableWrapper) configurable).getConfigurable();
if (wrapped instanceof SearchableConfigurable) {
configurable = (SearchableConfigurable) wrapped;
}
}
if (configurable instanceof KeymapPanel) {
processKeymap(configurableElement);
} else if (configurable instanceof OptionsContainingConfigurable) {
processOptionsContainingConfigurable((OptionsContainingConfigurable) configurable, configurableElement);
} else if (configurable instanceof PluginManagerConfigurable) {
for (OptionDescription description : wordsToOptionDescriptors(Collections.singleton(AvailablePluginsManagerMain.MANAGE_REPOSITORIES))) {
append(null, AvailablePluginsManagerMain.MANAGE_REPOSITORIES, description.getOption(), configurableElement);
}
} else if (configurable instanceof AllFileTemplatesConfigurable) {
processFileTemplates(configurableElement);
}
root.addContent(configurableElement);
}
FileUtil.ensureCanCreateFile(new File(outputPath));
JDOMUtil.writeDocument(new Document(root), outputPath, "\n");
System.out.println("Searchable options index builder completed");
} finally {
for (SearchableConfigurable configurable : options.keySet()) {
configurable.disposeUIResources();
}
}
}
Aggregations