use of com.intellij.ide.ui.search.BooleanOptionDescription in project intellij-community by JetBrains.
the class VcsOptionsTopHitProvider method getOptions.
@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
if (project == null || ProjectLevelVcsManager.getInstance(project).getAllVcss().length == 0) {
return Collections.emptyList();
}
VcsConfiguration vcs = VcsConfiguration.getInstance(project);
if (vcs == null) {
return Collections.emptyList();
}
ArrayList<BooleanOptionDescription> options = new ArrayList<>();
// process Version Control settings
String id = "project.propVCSSupport.Mappings";
options.add(option(vcs, id, "Limit history by " + vcs.MAXIMUM_HISTORY_ROWS + " rows", "LIMIT_HISTORY"));
options.add(option(vcs, id, "Show directories with changed descendants", "SHOW_DIRTY_RECURSIVELY"));
VcsContentAnnotationSettings vcsCA = VcsContentAnnotationSettings.getInstance(project);
if (vcsCA != null) {
options.add(option(vcsCA, id, "Show changed in last " + vcsCA.getLimitDays() + " days", "isShow", "setShow"));
}
options.add(option(vcs, id, "Notify about VCS root errors", "SHOW_VCS_ERROR_NOTIFICATIONS"));
options.add(option(vcs, id, "Commit message right margin " + vcs.COMMIT_MESSAGE_MARGIN_SIZE + " columns", "USE_COMMIT_MESSAGE_MARGIN"));
options.add(option(vcs, id, ApplicationBundle.message("checkbox.wrap.typing.on.right.margin"), "WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN"));
// process Version Control / Confirmation settings
id = "project.propVCSSupport.Confirmation";
ReadonlyStatusHandler vcsROSH = ReadonlyStatusHandler.getInstance(project);
if (vcsROSH instanceof ReadonlyStatusHandlerImpl) {
options.add(option(((ReadonlyStatusHandlerImpl) vcsROSH).getState(), id, "Show \"Clear Read-only Status\" Dialog", "SHOW_DIALOG"));
}
options.add(option(vcs, id, "Confirmation: Suggest to move uncommitted changes to another changelist", "OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT"));
options.add(option(vcs, id, "Confirmation: Force non-empty checkin comments", "FORCE_NON_EMPTY_COMMENT"));
options.add(option(vcs, id, "Confirmation: Clear initial commit message", "CLEAR_INITIAL_COMMIT_MESSAGE"));
// process Version Control / Background settings
id = "project.propVCSSupport.Background";
options.add(option(vcs, id, "Perform in background: update from VCS", "PERFORM_UPDATE_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: commit to VCS", "PERFORM_COMMIT_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: checkout from VCS", "PERFORM_CHECKOUT_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: Edit/Checkout", "PERFORM_EDIT_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: Add/Remove", "PERFORM_ADD_REMOVE_IN_BACKGROUND"));
options.add(option(vcs, id, "Perform in background: revert", "PERFORM_ROLLBACK_IN_BACKGROUND"));
id = ShelfProjectConfigurable.HELP_ID;
options.add(option(vcs, id, VcsBundle.message("vcs.shelf.store.base.content"), "INCLUDE_TEXT_INTO_SHELF"));
if (!project.isDefault()) {
// process Version Control / Changelist Conflicts settings
options.add(tracker(project, "Changelists: Enable changelist conflict tracking", "TRACKING_ENABLED"));
options.add(tracker(project, "Changelists: Show conflict resolving dialog", "SHOW_DIALOG"));
options.add(tracker(project, "Changelists: Highlight files with conflicts", "HIGHLIGHT_CONFLICTS"));
options.add(tracker(project, "Changelists: Highlight files from non-active changelists", "HIGHLIGHT_NON_ACTIVE_CHANGELIST"));
}
return Collections.unmodifiableCollection(options);
}
use of com.intellij.ide.ui.search.BooleanOptionDescription in project intellij-community by JetBrains.
the class GotoActionAction method processOptionInplace.
private static boolean processOptionInplace(Object value, ChooseByNamePopup popup, Component component, AnActionEvent e) {
if (value instanceof BooleanOptionDescription) {
BooleanOptionDescription option = (BooleanOptionDescription) value;
option.setOptionState(!option.isOptionEnabled());
repaint(popup);
return true;
} else if (value instanceof GotoActionModel.ActionWrapper) {
AnAction action = ((GotoActionModel.ActionWrapper) value).getAction();
if (action instanceof ToggleAction) {
performAction(action, component, e, () -> repaint(popup));
return true;
}
}
return false;
}
use of com.intellij.ide.ui.search.BooleanOptionDescription in project intellij-community by JetBrains.
the class GotoActionAction method createPopup.
@Nullable
private static ChooseByNamePopup createPopup(@Nullable Project project, @NotNull final GotoActionModel model, String initialText, int initialIndex, final Component component, final AnActionEvent e) {
ChooseByNamePopup oldPopup = project == null ? null : project.getUserData(ChooseByNamePopup.CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY);
if (oldPopup != null) {
oldPopup.close(false);
}
final Disposable disposable = Disposer.newDisposable();
final ChooseByNamePopup popup = new ChooseByNamePopup(project, model, new GotoActionItemProvider(model), oldPopup, initialText, false, initialIndex) {
private boolean myPaintInternalInfo;
@Override
protected void initUI(Callback callback, ModalityState modalityState, boolean allowMultipleSelection) {
super.initUI(callback, modalityState, allowMultipleSelection);
myList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
Object value = myList.getSelectedValue();
String text = getText(value);
if (text != null && myDropdownPopup != null) {
myDropdownPopup.setAdText(text, SwingConstants.LEFT);
}
String description = getValueDescription(value);
ActionMenu.showDescriptionInStatusBar(true, myList, description);
}
@Nullable
private String getText(@Nullable Object o) {
if (o instanceof GotoActionModel.MatchedValue) {
GotoActionModel.MatchedValue mv = (GotoActionModel.MatchedValue) o;
if (myPaintInternalInfo) {
if (mv.value instanceof GotoActionModel.ActionWrapper) {
AnAction action = ((GotoActionModel.ActionWrapper) mv.value).getAction();
String actionId = ActionManager.getInstance().getId(action);
return StringUtil.notNullize(actionId, "class: " + action.getClass().getName());
}
}
if (mv.value instanceof BooleanOptionDescription || mv.value instanceof GotoActionModel.ActionWrapper && ((GotoActionModel.ActionWrapper) mv.value).getAction() instanceof ToggleAction) {
return "Press " + KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)) + " to toggle option";
}
}
return getAdText();
}
});
myList.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
int index = myList.locationToIndex(e.getPoint());
if (index == -1)
return;
Object value = myList.getModel().getElementAt(index);
String description = getValueDescription(value);
ActionMenu.showDescriptionInStatusBar(true, myList, description);
}
});
if (Registry.is("show.configurables.ids.in.settings")) {
new HeldDownKeyListener() {
@Override
protected void heldKeyTriggered(JComponent component, boolean pressed) {
myPaintInternalInfo = pressed;
// an easy way to repaint the AdText
ListSelectionEvent event = new ListSelectionEvent(this, -1, -1, false);
for (ListSelectionListener listener : myList.getListSelectionListeners()) {
listener.valueChanged(event);
}
}
}.installOn(myTextField);
}
}
@Nullable
private String getValueDescription(@Nullable Object value) {
if (value instanceof GotoActionModel.MatchedValue) {
GotoActionModel.MatchedValue mv = (GotoActionModel.MatchedValue) value;
if (mv.value instanceof GotoActionModel.ActionWrapper) {
AnAction action = ((GotoActionModel.ActionWrapper) mv.value).getAction();
return action.getTemplatePresentation().getDescription();
}
}
return null;
}
@NotNull
@Override
protected Set<Object> filter(@NotNull Set<Object> elements) {
return super.filter(model.sortItems(elements));
}
@Override
protected boolean closeForbidden(boolean ok) {
if (!ok)
return false;
Object element = getChosenElement();
return element instanceof GotoActionModel.MatchedValue && processOptionInplace(((GotoActionModel.MatchedValue) element).value, this, component, e) || super.closeForbidden(true);
}
@Override
public void setDisposed(boolean disposedFlag) {
super.setDisposed(disposedFlag);
Disposer.dispose(disposable);
ActionMenu.showDescriptionInStatusBar(true, myList, null);
for (ListSelectionListener listener : myList.getListSelectionListeners()) {
myList.removeListSelectionListener(listener);
}
UIUtil.dispose(myList);
}
};
ApplicationManager.getApplication().getMessageBus().connect(disposable).subscribe(ProgressWindow.TOPIC, new ProgressWindow.Listener() {
@Override
public void progressWindowCreated(ProgressWindow pw) {
Disposer.register(pw, new Disposable() {
@Override
public void dispose() {
if (!popup.checkDisposed()) {
popup.repaintList();
}
}
});
}
});
if (project != null) {
project.putUserData(ChooseByNamePopup.CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY, popup);
}
popup.addMouseClickListener(new MouseAdapter() {
@Override
public void mouseClicked(@NotNull MouseEvent me) {
Object element = popup.getSelectionByPoint(me.getPoint());
if (element instanceof GotoActionModel.MatchedValue) {
if (processOptionInplace(((GotoActionModel.MatchedValue) element).value, popup, component, e)) {
me.consume();
}
}
}
});
CustomShortcutSet shortcutSet = new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
Object o = popup.getChosenElement();
if (o instanceof GotoActionModel.MatchedValue) {
Comparable value = ((GotoActionModel.MatchedValue) o).value;
if (value instanceof GotoActionModel.ActionWrapper) {
GotoActionModel.ActionWrapper aw = (GotoActionModel.ActionWrapper) value;
boolean available = aw.isAvailable();
if (available) {
AnAction action = aw.getAction();
String id = ActionManager.getInstance().getId(action);
KeymapManagerImpl km = ((KeymapManagerImpl) KeymapManager.getInstance());
Keymap k = km.getActiveKeymap();
if (!k.canModify())
return;
KeymapPanel.addKeyboardShortcut(id, ActionShortcutRestrictions.getInstance().getForActionId(id), k, component);
popup.repaintListImmediate();
}
}
}
}
}.registerCustomShortcutSet(shortcutSet, popup.getTextField(), disposable);
return popup;
}
use of com.intellij.ide.ui.search.BooleanOptionDescription in project intellij-community by JetBrains.
the class ConfigurableOptionsTopHitProvider method getOptions.
@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
try {
Configurable configurable = getConfigurable(project);
Component component = configurable.createComponent();
configurable.reset();
myPrefix.clear();
String name = getName(configurable);
if (name != null) {
myPrefix.push(name);
}
Collection<BooleanOptionDescription> options = new ArrayList<>();
init(options, configurable, component);
return Collections.unmodifiableCollection(options);
} catch (Exception exception) {
LOG.debug(exception);
}
return Collections.emptyList();
}
use of com.intellij.ide.ui.search.BooleanOptionDescription in project intellij-community by JetBrains.
the class GitOptionsTopHitProvider method getOptions.
@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
if (project != null) {
for (VcsDescriptor descriptor : ProjectLevelVcsManager.getInstance(project).getAllVcss()) {
if ("Git".equals(descriptor.getDisplayName())) {
final GitVcsSettings settings = GitVcsSettings.getInstance(project);
ArrayList<BooleanOptionDescription> options = new ArrayList<>();
options.add(option(project, "Git: Commit automatically on cherry-pick", "isAutoCommitOnCherryPick", "setAutoCommitOnCherryPick"));
options.add(option(project, "Git: Auto-update if push of the current branch was rejected", "autoUpdateIfPushRejected", "setAutoUpdateIfPushRejected"));
GitRepositoryManager manager = GitRepositoryManager.getInstance(project);
if (manager != null && manager.moreThanOneRoot()) {
options.add(new BooleanOptionDescription("Git: Control repositories synchronously", "vcs.Git") {
@Override
public boolean isOptionEnabled() {
return settings.getSyncSetting() == DvcsSyncSettings.Value.SYNC;
}
@Override
public void setOptionState(boolean enabled) {
settings.setSyncSetting(enabled ? DvcsSyncSettings.Value.SYNC : DvcsSyncSettings.Value.DONT_SYNC);
}
});
}
options.add(option(project, "Git: Warn if CRLF line separators are about to be committed", "warnAboutCrlf", "setWarnAboutCrlf"));
options.add(option(project, "Git: Warn when committing in detached HEAD or during rebase", "warnAboutDetachedHead", "setWarnAboutDetachedHead"));
options.add(option(project, "Git: Allow force push", "isForcePushAllowed", "setForcePushAllowed"));
return Collections.unmodifiableCollection(options);
}
}
}
return Collections.emptyList();
}
Aggregations