mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
This commit is contained in:
@@ -48,7 +48,8 @@ public abstract class JBPopupFactory {
|
||||
return ServiceManager.getService(JBPopupFactory.class);
|
||||
}
|
||||
|
||||
public PopupChooserBuilder createListPopupBuilder(JList list) {
|
||||
@NotNull
|
||||
public PopupChooserBuilder createListPopupBuilder(@NotNull JList list) {
|
||||
return new PopupChooserBuilder(list);
|
||||
}
|
||||
|
||||
@@ -60,6 +61,7 @@ public abstract class JBPopupFactory {
|
||||
* @param defaultOptionIndex the index of the option which is selected by default.
|
||||
* @return the popup instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract ListPopup createConfirmation(String title, Runnable onYes, int defaultOptionIndex);
|
||||
|
||||
/**
|
||||
@@ -72,6 +74,7 @@ public abstract class JBPopupFactory {
|
||||
* @param defaultOptionIndex the index of the option which is selected by default.
|
||||
* @return the popup instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract ListPopup createConfirmation(String title, String yesText, String noText, Runnable onYes, int defaultOptionIndex);
|
||||
|
||||
/**
|
||||
@@ -85,9 +88,16 @@ public abstract class JBPopupFactory {
|
||||
* @param defaultOptionIndex the index of the option which is selected by default.
|
||||
* @return the popup instance.
|
||||
*/
|
||||
public abstract ListPopup createConfirmation(String title, String yesText, String noText, Runnable onYes, Runnable onNo, int defaultOptionIndex);
|
||||
@NotNull
|
||||
public abstract ListPopup createConfirmation(String title,
|
||||
String yesText,
|
||||
String noText,
|
||||
Runnable onYes,
|
||||
Runnable onNo,
|
||||
int defaultOptionIndex);
|
||||
|
||||
public abstract ListPopupStep createActionsStep(ActionGroup actionGroup,
|
||||
@NotNull
|
||||
public abstract ListPopupStep createActionsStep(@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
@@ -95,7 +105,8 @@ public abstract class JBPopupFactory {
|
||||
Component component,
|
||||
boolean honorActionMnemonics);
|
||||
|
||||
public abstract ListPopupStep createActionsStep(ActionGroup actionGroup,
|
||||
@NotNull
|
||||
public abstract ListPopupStep createActionsStep(@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
@@ -104,7 +115,8 @@ public abstract class JBPopupFactory {
|
||||
boolean honorActionMnemonics,
|
||||
int defaultOptionIndex, final boolean autoSelectionEnabled);
|
||||
|
||||
public abstract RelativePoint guessBestPopupLocation(JComponent component);
|
||||
@NotNull
|
||||
public abstract RelativePoint guessBestPopupLocation(@NotNull JComponent component);
|
||||
|
||||
public boolean isChildPopupFocused(@Nullable Component parent) {
|
||||
return getChildFocusedPopup(parent) != null;
|
||||
@@ -155,8 +167,9 @@ public abstract class JBPopupFactory {
|
||||
* @param showDisabledActions if true, disabled actions are shown as disabled; if false, disabled actions are not shown
|
||||
* @return the popup instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract ListPopup createActionGroupPopup(@Nullable String title,
|
||||
ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions);
|
||||
@@ -172,8 +185,9 @@ public abstract class JBPopupFactory {
|
||||
* @param actionPlace action place for ActionManager to use when creating the popup
|
||||
* @return the popup instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions, @Nullable final String actionPlace);
|
||||
@@ -191,16 +205,18 @@ public abstract class JBPopupFactory {
|
||||
* is displayed)
|
||||
* @return the popup instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions,
|
||||
@Nullable Runnable disposeCallback,
|
||||
int maxRowCount);
|
||||
|
||||
@NotNull
|
||||
public abstract ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
@@ -212,7 +228,8 @@ public abstract class JBPopupFactory {
|
||||
/**
|
||||
* @deprecated use {@link #createListPopup(ListPopupStep)} instead (<code>step</code> must be a ListPopupStep in any case)
|
||||
*/
|
||||
public abstract ListPopup createWizardStep(PopupStep step);
|
||||
@NotNull
|
||||
public abstract ListPopup createWizardStep(@NotNull PopupStep step);
|
||||
|
||||
/**
|
||||
* Creates a custom list popup with the specified step.
|
||||
@@ -220,12 +237,16 @@ public abstract class JBPopupFactory {
|
||||
* @param step the custom step for the list popup.
|
||||
* @return the popup instance.
|
||||
*/
|
||||
public abstract ListPopup createListPopup(ListPopupStep step);
|
||||
@NotNull
|
||||
public abstract ListPopup createListPopup(@NotNull ListPopupStep step);
|
||||
|
||||
public abstract TreePopup createTree(JBPopup parent, TreePopupStep step, Object parentValue);
|
||||
public abstract TreePopup createTree(TreePopupStep step);
|
||||
@NotNull
|
||||
public abstract TreePopup createTree(JBPopup parent, @NotNull TreePopupStep step, Object parentValue);
|
||||
@NotNull
|
||||
public abstract TreePopup createTree(@NotNull TreePopupStep step);
|
||||
|
||||
public abstract ComponentPopupBuilder createComponentPopupBuilder(JComponent content, @Nullable JComponent preferableFocusComponent);
|
||||
@NotNull
|
||||
public abstract ComponentPopupBuilder createComponentPopupBuilder(@NotNull JComponent content, @Nullable JComponent preferableFocusComponent);
|
||||
|
||||
/**
|
||||
* Returns the location where a popup with the specified data context is displayed.
|
||||
@@ -237,6 +258,7 @@ public abstract class JBPopupFactory {
|
||||
* - current selected node for tree<br>
|
||||
* - current selected row for list<br>
|
||||
*/
|
||||
@NotNull
|
||||
public abstract RelativePoint guessBestPopupLocation(@NotNull DataContext dataContext);
|
||||
|
||||
/**
|
||||
@@ -245,30 +267,36 @@ public abstract class JBPopupFactory {
|
||||
* @param editor the editor over which the popup is shown.
|
||||
* @return location as close as possible to the action origin.
|
||||
*/
|
||||
public abstract RelativePoint guessBestPopupLocation(Editor editor);
|
||||
@NotNull
|
||||
public abstract RelativePoint guessBestPopupLocation(@NotNull Editor editor);
|
||||
|
||||
/**
|
||||
* @param editor the editor over which the popup is shown.
|
||||
* @return true if popup location is located in visible area
|
||||
* false if center would be suggested instead
|
||||
*/
|
||||
public abstract boolean isBestPopupLocationVisible(Editor editor);
|
||||
public abstract boolean isBestPopupLocationVisible(@NotNull Editor editor);
|
||||
|
||||
public abstract Point getCenterOf(JComponent container, JComponent content);
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public abstract List<JBPopup> getChildPopups(@NotNull Component parent);
|
||||
|
||||
public abstract boolean isPopupActive();
|
||||
|
||||
@NotNull
|
||||
public abstract BalloonBuilder createBalloonBuilder(@NotNull JComponent content);
|
||||
|
||||
@NotNull
|
||||
public abstract BalloonBuilder createDialogBalloonBuilder(@NotNull JComponent content, String title);
|
||||
|
||||
@NotNull
|
||||
public abstract BalloonBuilder createHtmlTextBalloonBuilder(@NotNull String htmlContent, @Nullable Icon icon, Color fillColor, @Nullable HyperlinkListener listener);
|
||||
|
||||
@NotNull
|
||||
public abstract BalloonBuilder createHtmlTextBalloonBuilder(@NotNull String htmlContent, MessageType messageType, @Nullable HyperlinkListener listener);
|
||||
|
||||
@NotNull
|
||||
public abstract JBPopup createMessage(String text);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -82,75 +82,86 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder {
|
||||
private List<Pair<ActionListener, KeyStroke>> myKeyboardActions = Collections.emptyList();
|
||||
private Component mySettingsButtons;
|
||||
private boolean myMayBeParent;
|
||||
private int myAdAlignment = SwingUtilities.LEFT;
|
||||
private int myAdAlignment = SwingConstants.LEFT;
|
||||
private BooleanFunction<KeyEvent> myKeyEventHandler;
|
||||
|
||||
public ComponentPopupBuilderImpl(final JComponent component,
|
||||
public ComponentPopupBuilderImpl(@NotNull JComponent component,
|
||||
final JComponent preferredFocusedComponent) {
|
||||
myComponent = component;
|
||||
myPreferredFocusedComponent = preferredFocusedComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setMayBeParent(boolean mayBeParent) {
|
||||
myMayBeParent = mayBeParent;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setTitle(String title) {
|
||||
myTitle = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setResizable(final boolean resizable) {
|
||||
myResizable = resizable;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setMovable(final boolean movable) {
|
||||
myMovable = movable;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setCancelOnClickOutside(final boolean cancel) {
|
||||
myCancelOnClickOutside = cancel;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setCancelOnMouseOutCallback(final MouseChecker shouldCancel) {
|
||||
myCancelOnMouseOutCallback = shouldCancel;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder addListener(final JBPopupListener listener) {
|
||||
myListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setRequestFocus(final boolean requestFocus) {
|
||||
myRequestFocus = requestFocus;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setFocusable(final boolean focusable) {
|
||||
myFocusable = focusable;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setForceHeavyweight(final boolean forceHeavyweight) {
|
||||
myForceHeavyweight = forceHeavyweight;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setDimensionServiceKey(final Project project, final String dimensionServiceKey, final boolean useForXYLocation) {
|
||||
myDimensionServiceKey = dimensionServiceKey;
|
||||
@@ -159,41 +170,48 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setCancelCallback(final Computable<Boolean> shouldProceed) {
|
||||
myCallback = shouldProceed;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setCancelButton(@NotNull final IconButton cancelButton) {
|
||||
myCancelButton = cancelButton;
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setCommandButton(@NotNull ActiveComponent button) {
|
||||
myCommandButton = button;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setCouldPin(@Nullable final Processor<JBPopup> callback) {
|
||||
myPinCallback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setKeyboardActions(@NotNull List<Pair<ActionListener, KeyStroke>> keyboardActions) {
|
||||
myKeyboardActions = keyboardActions;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setSettingButtons(@NotNull Component button) {
|
||||
mySettingsButtons = button;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setCancelOnOtherWindowOpen(final boolean cancelOnWindow) {
|
||||
myCancelOnWindow = cancelOnWindow;
|
||||
@@ -213,12 +231,14 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setProject(Project project) {
|
||||
myProject = project;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JBPopup createPopup() {
|
||||
final AbstractPopup popup = new AbstractPopup().init(myProject, myComponent, myPreferredFocusedComponent, myRequestFocus, myFocusable, myForceHeavyweight,
|
||||
@@ -237,36 +257,42 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder {
|
||||
return popup;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setRequestFocusCondition(Project project, Condition<Project> condition) {
|
||||
myRequestFocus = condition.value(project);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setTitleIcon(@NotNull final ActiveIcon icon) {
|
||||
myTitleIcon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setCancelKeyEnabled(final boolean enabled) {
|
||||
myCancelKeyEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setLocateByContent(final boolean byContent) {
|
||||
myLocateByContent = byContent;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setLocateWithinScreenBounds(final boolean within) {
|
||||
myPlacewithinScreen = within;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setMinSize(final Dimension minSize) {
|
||||
myMinSize = minSize;
|
||||
@@ -279,18 +305,21 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setAlpha(final float alpha) {
|
||||
myAlpha = alpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setBelongsToGlobalPopupStack(final boolean isInStack) {
|
||||
myInStack = isInStack;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder addUserData(final Object object) {
|
||||
if (myUserData == null) {
|
||||
@@ -300,21 +329,24 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setModalContext(final boolean modal) {
|
||||
myModalContext = modal;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setFocusOwners(@NotNull final Component[] focusOwners) {
|
||||
myFocusOwners = focusOwners;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ComponentPopupBuilder setAdText(@Nullable final String text) {
|
||||
return setAdText(text, SwingUtilities.LEFT);
|
||||
return setAdText(text, SwingConstants.LEFT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -81,14 +81,20 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
private final Map<Disposable, List<Balloon>> myStorage = new WeakHashMap<Disposable, List<Balloon>>();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createConfirmation(String title, final Runnable onYes, int defaultOptionIndex) {
|
||||
return createConfirmation(title, CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText(), onYes, defaultOptionIndex);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createConfirmation(String title, final String yesText, String noText, final Runnable onYes, int defaultOptionIndex) {
|
||||
return createConfirmation(title, yesText, noText, onYes, EmptyRunnable.getInstance(), defaultOptionIndex);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JBPopup createMessage(String text) {
|
||||
return createListPopup(new BaseListPopupStep<String>(null, new String[]{text}));
|
||||
}
|
||||
@@ -110,6 +116,8 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createConfirmation(String title,
|
||||
final String yesText,
|
||||
String noText,
|
||||
@@ -119,6 +127,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
{
|
||||
|
||||
final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, new String[]{yesText, noText}) {
|
||||
@Override
|
||||
public PopupStep onChosen(String selectedValue, final boolean finalChoice) {
|
||||
if (selectedValue.equals(yesText)) {
|
||||
onYes.run();
|
||||
@@ -129,10 +138,12 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void canceled() {
|
||||
onNo.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMnemonicsNavigationEnabled() {
|
||||
return true;
|
||||
}
|
||||
@@ -145,7 +156,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
|
||||
private static ListPopup createActionGroupPopup(final String title,
|
||||
final ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean useAlphaAsNumbers,
|
||||
@@ -170,7 +181,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
|
||||
private static ListPopup createActionGroupPopup(final String title,
|
||||
final ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean useAlphaAsNumbers,
|
||||
@@ -188,7 +199,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
private final Runnable myDisposeCallback;
|
||||
private final Component myComponent;
|
||||
|
||||
public ActionGroupPopup(final String title, final ActionGroup actionGroup, @NotNull DataContext dataContext,
|
||||
public ActionGroupPopup(final String title, @NotNull ActionGroup actionGroup, @NotNull DataContext dataContext,
|
||||
boolean showNumbers, boolean useAlphaAsNumbers, boolean showDisabledActions, boolean honorActionMnemonics,
|
||||
final Runnable disposeCallback, final int maxRowCount, final Condition<AnAction> preselectActionCondition,
|
||||
@Nullable final String actionPlace) {
|
||||
@@ -199,6 +210,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
myComponent = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
|
||||
|
||||
addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
final JList list = (JList)e.getSource();
|
||||
final ActionItem actionItem = (ActionItem)list.getSelectedValue();
|
||||
@@ -214,7 +226,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
});
|
||||
}
|
||||
|
||||
private static ListPopupStep createStep(String title, ActionGroup actionGroup, @NotNull DataContext dataContext,
|
||||
private static ListPopupStep createStep(String title, @NotNull ActionGroup actionGroup, @NotNull DataContext dataContext,
|
||||
boolean showNumbers, boolean useAlphaAsNumbers, boolean showDisabledActions,
|
||||
boolean honorActionMnemonics,
|
||||
Condition<AnAction> preselectActionCondition, @Nullable String actionPlace) {
|
||||
@@ -242,8 +254,10 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createActionGroupPopup(final String title,
|
||||
final ActionGroup actionGroup,
|
||||
@NotNull final ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
@@ -255,8 +269,10 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
disposeCallback, maxRowCount, preselectActionCondition, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions) {
|
||||
@@ -268,8 +284,10 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
null, -1);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions,
|
||||
@@ -282,8 +300,10 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
null, -1, null, actionPlace);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions,
|
||||
@@ -298,7 +318,9 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
maxRowCount);
|
||||
}
|
||||
|
||||
public ListPopupStep createActionsStep(final ActionGroup actionGroup,
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopupStep createActionsStep(@NotNull final ActionGroup actionGroup,
|
||||
@NotNull DataContext dataContext,
|
||||
final boolean showNumbers,
|
||||
final boolean showDisabledActions,
|
||||
@@ -308,7 +330,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return createActionsStep(actionGroup, dataContext, showNumbers, showDisabledActions, title, component, honorActionMnemonics, 0, false);
|
||||
}
|
||||
|
||||
private static ListPopupStep createActionsStep(ActionGroup actionGroup, @NotNull DataContext dataContext,
|
||||
private static ListPopupStep createActionsStep(@NotNull ActionGroup actionGroup, @NotNull DataContext dataContext,
|
||||
boolean showNumbers, boolean useAlphaAsNumbers, boolean showDisabledActions,
|
||||
String title, Component component, boolean honorActionMnemonics,
|
||||
final int defaultOptionIndex, final boolean autoSelectionEnabled) {
|
||||
@@ -325,7 +347,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}, autoSelectionEnabled, showDisabledActions);
|
||||
}
|
||||
|
||||
private static List<ActionItem> makeActionItemsFromActionGroup(ActionGroup actionGroup,
|
||||
private static List<ActionItem> makeActionItemsFromActionGroup(@NotNull ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean useAlphaAsNumbers,
|
||||
@@ -337,7 +359,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return builder.getItems();
|
||||
}
|
||||
|
||||
private static ListPopupStep createActionsStep(ActionGroup actionGroup, @NotNull DataContext dataContext,
|
||||
private static ListPopupStep createActionsStep(@NotNull ActionGroup actionGroup, @NotNull DataContext dataContext,
|
||||
boolean showNumbers, boolean useAlphaAsNumbers, boolean showDisabledActions,
|
||||
String title, Component component, boolean honorActionMnemonics,
|
||||
Condition<AnAction> preselectActionCondition, boolean autoSelectionEnabled) {
|
||||
@@ -347,7 +369,9 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
autoSelectionEnabled, showDisabledActions);
|
||||
}
|
||||
|
||||
public ListPopupStep createActionsStep(ActionGroup actionGroup, @NotNull DataContext dataContext, boolean showNumbers, boolean showDisabledActions,
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopupStep createActionsStep(@NotNull ActionGroup actionGroup, @NotNull DataContext dataContext, boolean showNumbers, boolean showDisabledActions,
|
||||
String title, Component component, boolean honorActionMnemonics, int defaultOptionIndex,
|
||||
final boolean autoSelectionEnabled) {
|
||||
return createActionsStep(actionGroup, dataContext, showNumbers, true, showDisabledActions, title, component, honorActionMnemonics,
|
||||
@@ -362,27 +386,39 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ListPopup createWizardStep(PopupStep step) {
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createWizardStep(@NotNull PopupStep step) {
|
||||
return new ListPopupImpl((ListPopupStep) step);
|
||||
}
|
||||
|
||||
public ListPopup createListPopup(ListPopupStep step) {
|
||||
@NotNull
|
||||
@Override
|
||||
public ListPopup createListPopup(@NotNull ListPopupStep step) {
|
||||
return new ListPopupImpl(step);
|
||||
}
|
||||
|
||||
public TreePopup createTree(JBPopup parent, TreePopupStep aStep, Object parentValue) {
|
||||
@NotNull
|
||||
@Override
|
||||
public TreePopup createTree(JBPopup parent, @NotNull TreePopupStep aStep, Object parentValue) {
|
||||
return new TreePopupImpl(parent, aStep, parentValue);
|
||||
}
|
||||
|
||||
public TreePopup createTree(TreePopupStep aStep) {
|
||||
@NotNull
|
||||
@Override
|
||||
public TreePopup createTree(@NotNull TreePopupStep aStep) {
|
||||
return new TreePopupImpl(aStep);
|
||||
}
|
||||
|
||||
public ComponentPopupBuilder createComponentPopupBuilder(JComponent content, JComponent prefferableFocusComponent) {
|
||||
@NotNull
|
||||
@Override
|
||||
public ComponentPopupBuilder createComponentPopupBuilder(@NotNull JComponent content, JComponent prefferableFocusComponent) {
|
||||
return new ComponentPopupBuilderImpl(content, prefferableFocusComponent);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public RelativePoint guessBestPopupLocation(@NotNull DataContext dataContext) {
|
||||
KeyboardFocusManager focusManager=KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
Component component = focusManager.getFocusOwner();
|
||||
@@ -411,7 +447,9 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public RelativePoint guessBestPopupLocation(final JComponent component) {
|
||||
@NotNull
|
||||
@Override
|
||||
public RelativePoint guessBestPopupLocation(@NotNull final JComponent component) {
|
||||
Point popupMenuPoint = null;
|
||||
final Rectangle visibleRect = component.getVisibleRect();
|
||||
if (component instanceof JList) { // JList
|
||||
@@ -476,11 +514,13 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBestPopupLocationVisible(Editor editor) {
|
||||
public boolean isBestPopupLocationVisible(@NotNull Editor editor) {
|
||||
return getVisibleBestPopupLocation(editor) != null;
|
||||
}
|
||||
|
||||
public RelativePoint guessBestPopupLocation(Editor editor) {
|
||||
@NotNull
|
||||
@Override
|
||||
public RelativePoint guessBestPopupLocation(@NotNull Editor editor) {
|
||||
Point p = getVisibleBestPopupLocation(editor);
|
||||
if (p == null) {
|
||||
final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
|
||||
@@ -490,7 +530,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Point getVisibleBestPopupLocation(Editor editor) {
|
||||
private static Point getVisibleBestPopupLocation(@NotNull Editor editor) {
|
||||
VisualPosition visualPosition = editor.getUserData(ANCHOR_POPUP_POSITION);
|
||||
|
||||
if (visualPosition == null) {
|
||||
@@ -509,6 +549,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return visibleArea.contains(p) ? p : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getCenterOf(JComponent container, JComponent content) {
|
||||
return AbstractPopup.getCenterOf(container, content);
|
||||
}
|
||||
@@ -593,15 +634,18 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return defaultOptionIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<ActionItem> getValues() {
|
||||
return myItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelectable(final ActionItem value) {
|
||||
return value.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMnemonicPos(final ActionItem value) {
|
||||
final String text = getTextFor(value);
|
||||
int i = text.indexOf(UIUtil.MNEMONIC);
|
||||
@@ -614,27 +658,33 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIconFor(final ActionItem aValue) {
|
||||
return aValue.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTextFor(final ActionItem value) {
|
||||
return value.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListSeparator getSeparatorAbove(final ActionItem value) {
|
||||
return value.isPrependWithSeparator() ? new ListSeparator(value.getSeparatorText()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultOptionIndex() {
|
||||
return myDefaultOptionIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return myTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PopupStep onChosen(final ActionItem actionChoice, final boolean finalChoice) {
|
||||
if (!actionChoice.isEnabled()) return FINAL_CHOICE;
|
||||
final AnAction action = actionChoice.getAction();
|
||||
@@ -648,6 +698,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
else {
|
||||
myFinalRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
action.actionPerformed(
|
||||
new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, action.getTemplatePresentation().clone(),
|
||||
@@ -658,47 +709,58 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable getFinalRunnable() {
|
||||
return myFinalRunnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubstep(final ActionItem selectedValue) {
|
||||
return selectedValue != null && selectedValue.isEnabled() && selectedValue.getAction() instanceof ActionGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void canceled() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMnemonicsNavigationEnabled() {
|
||||
return myEnableMnemonics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MnemonicNavigationFilter<ActionItem> getMnemonicNavigationFilter() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(final ActionItem value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexedString(final ActionItem value) {
|
||||
return getTextFor(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpeedSearchEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoSelectionEnabled() {
|
||||
return myAutoSelectionEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpeedSearchFilter<ActionItem> getSpeedSearchFilter() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@NotNull
|
||||
public List<JBPopup> getChildPopups(@NotNull final Component component) {
|
||||
return FocusTrackback.getChildPopups(component);
|
||||
}
|
||||
@@ -748,7 +810,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return myListModel;
|
||||
}
|
||||
|
||||
public void buildGroup(ActionGroup actionGroup) {
|
||||
public void buildGroup(@NotNull ActionGroup actionGroup) {
|
||||
calcMaxIconSize(actionGroup);
|
||||
myEmptyIcon = myMaxIconHeight != -1 && myMaxIconWidth != -1 ? new EmptyIcon(myMaxIconWidth, myMaxIconHeight) : null;
|
||||
|
||||
@@ -786,7 +848,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private void appendActionsFromGroup(final ActionGroup actionGroup) {
|
||||
private void appendActionsFromGroup(@NotNull ActionGroup actionGroup) {
|
||||
AnAction[] actions = actionGroup.getChildren(new AnActionEvent(null, myDataContext, myActionPlace,
|
||||
getPresentation(actionGroup), ActionManager.getInstance(), 0));
|
||||
for (AnAction action : actions) {
|
||||
@@ -891,10 +953,13 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public BalloonBuilder createBalloonBuilder(@NotNull final JComponent content) {
|
||||
return new BalloonPopupBuilderImpl(myStorage, content);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public BalloonBuilder createDialogBalloonBuilder(@NotNull JComponent content, String title) {
|
||||
final BalloonPopupBuilderImpl builder = new BalloonPopupBuilderImpl(myStorage, content);
|
||||
@@ -916,6 +981,8 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return builder;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public BalloonBuilder createHtmlTextBalloonBuilder(@NotNull final String htmlContent, @Nullable final Icon icon, final Color fillColor,
|
||||
@Nullable final HyperlinkListener listener)
|
||||
{
|
||||
@@ -956,6 +1023,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return builder;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public BalloonBuilder createHtmlTextBalloonBuilder(@NotNull String htmlContent,
|
||||
MessageType messageType,
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -55,7 +56,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
|
||||
private final Timer myAutoSelectionTimer = UIUtil.createNamedTimer("Wizard autoselection",AUTO_POPUP_DELAY, this);
|
||||
|
||||
private MnemonicsSearch myMnemonicsSearch;
|
||||
private final MnemonicsSearch myMnemonicsSearch;
|
||||
private Object myParentValue;
|
||||
|
||||
private Point myLastOwnerPoint;
|
||||
@@ -65,11 +66,11 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
private final ActionMap myActionMap = new ActionMap();
|
||||
private final InputMap myInputMap = new InputMap();
|
||||
|
||||
public WizardPopup(PopupStep<Object> aStep) {
|
||||
public WizardPopup(@NotNull PopupStep<Object> aStep) {
|
||||
this(null, aStep);
|
||||
}
|
||||
|
||||
public WizardPopup(JBPopup aParent, PopupStep<Object> aStep) {
|
||||
public WizardPopup(@Nullable JBPopup aParent, @NotNull PopupStep<Object> aStep) {
|
||||
myParent = (WizardPopup) aParent;
|
||||
myStep = aStep;
|
||||
|
||||
@@ -90,10 +91,11 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
|
||||
init(project, scrollPane, getPreferredFocusableComponent(), true, true, true, true, null,
|
||||
false, aStep.getTitle(), null, true, null, false, null, null, null, false, null, true, false, true, null, 0f,
|
||||
null, true, false, new Component[0], null, SwingUtilities.LEFT, true, Collections.<Pair<ActionListener, KeyStroke>>emptyList(), null, null, false, true,
|
||||
null, true, false, new Component[0], null, SwingConstants.LEFT, true, Collections.<Pair<ActionListener, KeyStroke>>emptyList(), null, null, false, true,
|
||||
true, null);
|
||||
|
||||
registerAction("disposeAll", KeyEvent.VK_ESCAPE, InputEvent.SHIFT_MASK, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (mySpeedSearch.isHoldingFilter()) {
|
||||
mySpeedSearch.reset();
|
||||
@@ -105,6 +107,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
});
|
||||
|
||||
AbstractAction goBackAction = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
goBack();
|
||||
}
|
||||
@@ -113,6 +116,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
registerAction("goBack3", KeyEvent.VK_ESCAPE, 0, goBackAction);
|
||||
|
||||
myMnemonicsSearch = new MnemonicsSearch(this) {
|
||||
@Override
|
||||
protected void select(Object value) {
|
||||
onSelectByMnemonic(value);
|
||||
}
|
||||
@@ -144,6 +148,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
|
||||
protected abstract JComponent createContent();
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
|
||||
@@ -167,6 +172,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(final Component owner, final int aScreenX, final int aScreenY, final boolean considerForcedXY) {
|
||||
LOG.assertTrue (!isDisposed());
|
||||
|
||||
@@ -193,6 +199,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
super.show(owner, targetBounds.x, targetBounds.y, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterShow() {
|
||||
super.afterShow();
|
||||
registerAutoMove();
|
||||
@@ -231,6 +238,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
|
||||
protected abstract JComponent getPreferredFocusableComponent();
|
||||
|
||||
@Override
|
||||
public void cancel(InputEvent e) {
|
||||
super.cancel(e);
|
||||
disposeChildren();
|
||||
@@ -273,6 +281,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
myParentValue = parentValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected MyContentPanel createContentPanel(final boolean resizable, final PopupBorder border, final boolean isToDrawMacCorner) {
|
||||
return new MyContainer(resizable, border, isToDrawMacCorner);
|
||||
@@ -286,6 +295,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
setFocusCycleRoot(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
Point p = null;
|
||||
@@ -375,6 +385,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void actionPerformed(ActionEvent e) {
|
||||
myAutoSelectionTimer.stop();
|
||||
if (getStep().isAutoSelectionEnabled()) {
|
||||
@@ -399,6 +410,7 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeShowing(Object value) {
|
||||
if (!myStep.isSpeedSearchEnabled()) return true;
|
||||
SpeedSearchFilter<Object> filter = myStep.getSpeedSearchFilter();
|
||||
@@ -425,11 +437,13 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
|
||||
|
||||
private class MyComponentAdapter extends ComponentAdapter {
|
||||
@Override
|
||||
public void componentMoved(final ComponentEvent e) {
|
||||
processParentWindowMoved();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setFinalRunnable(Runnable runnable) {
|
||||
if (getParent() == null) {
|
||||
super.setFinalRunnable(runnable);
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.popup.ClosableByLeftArrow;
|
||||
import com.intellij.ui.popup.WizardPopup;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
@@ -53,22 +54,22 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
private int myMaxRowCount = 20;
|
||||
private boolean myAutoHandleBeforeShow;
|
||||
|
||||
public ListPopupImpl(ListPopupStep aStep, int maxRowCount) {
|
||||
public ListPopupImpl(@NotNull ListPopupStep aStep, int maxRowCount) {
|
||||
super(aStep);
|
||||
if (maxRowCount != -1){
|
||||
myMaxRowCount = maxRowCount;
|
||||
}
|
||||
}
|
||||
|
||||
public ListPopupImpl(ListPopupStep aStep) {
|
||||
public ListPopupImpl(@NotNull ListPopupStep aStep) {
|
||||
this(aStep, -1);
|
||||
}
|
||||
|
||||
public ListPopupImpl(WizardPopup aParent, ListPopupStep aStep, Object parentValue) {
|
||||
public ListPopupImpl(WizardPopup aParent, @NotNull ListPopupStep aStep, Object parentValue) {
|
||||
this(aParent, aStep, parentValue, -1);
|
||||
}
|
||||
|
||||
public ListPopupImpl(WizardPopup aParent, ListPopupStep aStep, Object parentValue, int maxRowCount) {
|
||||
public ListPopupImpl(WizardPopup aParent, @NotNull ListPopupStep aStep, Object parentValue, int maxRowCount) {
|
||||
super(aParent, aStep);
|
||||
setParentValue(parentValue);
|
||||
if (maxRowCount != -1){
|
||||
@@ -80,6 +81,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
return myListModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean beforeShow() {
|
||||
myList.addMouseMotionListener(myMouseMotionListener);
|
||||
myList.addMouseListener(myMouseListener);
|
||||
@@ -95,6 +97,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
return shouldShow;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterShow() {
|
||||
tryToAutoSelect(false);
|
||||
}
|
||||
@@ -202,6 +205,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
return myList;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createContent() {
|
||||
myMouseMotionListener = new MyMouseMotionListener();
|
||||
myMouseListener = new MyMouseListener();
|
||||
@@ -225,18 +229,21 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
myList.getActionMap().get("selectPreviousColumn").setEnabled(false);
|
||||
|
||||
registerAction("handleSelection1", KeyEvent.VK_ENTER, 0, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleSelect(true);
|
||||
}
|
||||
});
|
||||
|
||||
registerAction("handleSelection2", KeyEvent.VK_RIGHT, 0, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleSelect(false);
|
||||
}
|
||||
});
|
||||
|
||||
registerAction("goBack2", KeyEvent.VK_LEFT, 0, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (isClosableByLeftArrow()) {
|
||||
goBack();
|
||||
@@ -258,10 +265,12 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
return getParent() != null || myStep instanceof ClosableByLeftArrow;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionMap getActionMap() {
|
||||
return myList.getActionMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputMap getInputMap() {
|
||||
return myList.getInputMap();
|
||||
}
|
||||
@@ -270,10 +279,12 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
return new PopupListElementRenderer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListPopupStep<Object> getListStep() {
|
||||
return (ListPopupStep<Object>) myStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myList.removeMouseMotionListener(myMouseMotionListener);
|
||||
myList.removeMouseListener(myMouseListener);
|
||||
@@ -288,11 +299,13 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
return myList.getCellBounds(i, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeChildren() {
|
||||
setIndexForShowingChild(-1);
|
||||
super.disposeChildren();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAutoSelectionTimer() {
|
||||
if (myList.getModel().getSize() > 0 && !myList.isSelectionEmpty() ) {
|
||||
handleSelect(false);
|
||||
@@ -303,10 +316,12 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelect(boolean handleFinalChoices) {
|
||||
_handleSelect(handleFinalChoices, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelect(boolean handleFinalChoices, InputEvent e) {
|
||||
_handleSelect(handleFinalChoices, e);
|
||||
}
|
||||
@@ -397,6 +412,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
private class MyMouseMotionListener extends MouseMotionAdapter {
|
||||
private int myLastSelectedIndex = -2;
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
Point point = e.getPoint();
|
||||
int index = myList.locationToIndex(point);
|
||||
@@ -445,6 +461,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
return bounds != null && point.getX() > bounds.width + bounds.getX() - AllIcons.Icons.Ide.NextStep.getIconWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process(KeyEvent aEvent) {
|
||||
myList.processKeyEvent(aEvent);
|
||||
}
|
||||
@@ -462,10 +479,12 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
super(myListModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredScrollableViewportSize() {
|
||||
return new Dimension(super.getPreferredScrollableViewportSize().width, getPreferredSize().height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processKeyEvent(KeyEvent e) {
|
||||
e.setSource(this);
|
||||
super.processKeyEvent(e);
|
||||
@@ -479,6 +498,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
super.processMouseEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(String dataId) {
|
||||
if (PlatformDataKeys.SELECTED_ITEM.is(dataId)){
|
||||
return myList.getSelectedValue();
|
||||
@@ -490,6 +510,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSpeedSearchPatternChanged() {
|
||||
myListModel.refilter();
|
||||
if (myListModel.getSize() > 0) {
|
||||
@@ -506,6 +527,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSelectByMnemonic(Object value) {
|
||||
if (myListModel.isVisible(value)) {
|
||||
myList.setSelectedValue(value, true);
|
||||
@@ -514,20 +536,24 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent getPreferredFocusableComponent() {
|
||||
return myList;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChildSelectedFor(Object value) {
|
||||
if (myList.getSelectedValue() != value) {
|
||||
myList.setSelectedValue(value, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHandleAutoSelectionBeforeShow(final boolean autoHandle) {
|
||||
myAutoHandleBeforeShow = autoHandle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModalContext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder;
|
||||
import com.intellij.ui.treeStructure.filtered.FilteringTreeStructure;
|
||||
import com.intellij.util.Range;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
@@ -54,15 +55,16 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
private TreePath myPendingChildPath;
|
||||
private FilteringTreeBuilder myBuilder;
|
||||
|
||||
public TreePopupImpl(JBPopup parent, TreePopupStep aStep, Object parentValue) {
|
||||
public TreePopupImpl(JBPopup parent, @NotNull TreePopupStep aStep, Object parentValue) {
|
||||
super(parent, aStep);
|
||||
setParentValue(parentValue);
|
||||
}
|
||||
|
||||
public TreePopupImpl(TreePopupStep aStep) {
|
||||
public TreePopupImpl(@NotNull TreePopupStep aStep) {
|
||||
this(null, aStep, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createContent() {
|
||||
myWizardTree = new MyTree();
|
||||
myWizardTree.getAccessibleContext().setAccessibleName("WizardTree");
|
||||
@@ -83,6 +85,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
}
|
||||
|
||||
myWizardTree.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
toggleExpansion(myWizardTree.getAnchorSelectionPath());
|
||||
@@ -100,12 +103,14 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
myMouseListener = new MyMouseListener();
|
||||
|
||||
registerAction("select", KeyEvent.VK_ENTER, 0, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleSelect(true, null);
|
||||
}
|
||||
});
|
||||
|
||||
registerAction("toggleExpansion", KeyEvent.VK_SPACE, 0, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
toggleExpansion(myWizardTree.getSelectionPath());
|
||||
}
|
||||
@@ -113,6 +118,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
|
||||
final Action oldExpandAction = getActionMap().get("selectChild");
|
||||
getActionMap().put("selectChild", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final TreePath path = myWizardTree.getSelectionPath();
|
||||
if (path != null && 0 == myWizardTree.getModel().getChildCount(path.getLastPathComponent())) {
|
||||
@@ -125,6 +131,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
|
||||
final Action oldCollapseAction = getActionMap().get("selectParent");
|
||||
getActionMap().put("selectParent", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final TreePath path = myWizardTree.getSelectionPath();
|
||||
if (shouldHidePopup(path)) {
|
||||
@@ -148,10 +155,12 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
return path.getPathCount() == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionMap getActionMap() {
|
||||
return myWizardTree.getActionMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputMap getInputMap() {
|
||||
return myWizardTree.getInputMap();
|
||||
}
|
||||
@@ -161,6 +170,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
myWizardTree.addMouseListener(myMouseListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
mySavedExpanded.clear();
|
||||
final Enumeration<TreePath> expanded = myWizardTree.getExpandedDescendants(new TreePath(myWizardTree.getModel().getRoot()));
|
||||
@@ -176,6 +186,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean beforeShow() {
|
||||
addListeners();
|
||||
|
||||
@@ -191,6 +202,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
return super.beforeShow();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterShow() {
|
||||
selectFirstSelectableItem();
|
||||
}
|
||||
@@ -237,6 +249,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
}
|
||||
|
||||
private class MyMouseMotionListener extends MouseMotionAdapter {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
final TreePath path = getPath(e);
|
||||
if (path != null) {
|
||||
@@ -262,6 +275,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
|
||||
private class MyMouseListener extends MouseAdapter {
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
final TreePath path = getPath(e);
|
||||
if (path == null) {
|
||||
@@ -284,6 +298,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
@@ -346,6 +361,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
|
||||
private class MyRenderer extends SimpleNodeRenderer {
|
||||
|
||||
@Override
|
||||
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
|
||||
final boolean shouldPaintSelected = (getTreeStep().isSelectable(value, extractUserObject(value)) && selected) || (getTreeStep().isSelectable(value, extractUserObject(value)) && hasFocus);
|
||||
final boolean shouldPaintFocus =
|
||||
@@ -360,6 +376,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
return box != null && box.isWithin(mouseX);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process(KeyEvent aEvent) {
|
||||
myWizardTree.processKeyEvent(aEvent);
|
||||
}
|
||||
@@ -373,6 +390,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
}
|
||||
|
||||
private class MyTree extends SimpleTree {
|
||||
@Override
|
||||
public void processKeyEvent(KeyEvent e) {
|
||||
e.setSource(this);
|
||||
super.processKeyEvent(e);
|
||||
@@ -384,6 +402,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
return new Dimension(pref.width + 10, pref.height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintChildren(Graphics g) {
|
||||
super.paintChildren(g);
|
||||
|
||||
@@ -412,18 +431,22 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
return getTreeStep().getProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAutoSelectionTimer() {
|
||||
handleSelect(false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent getPreferredFocusableComponent() {
|
||||
return myWizardTree;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSpeedSearchPatternChanged() {
|
||||
myBuilder.refilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChildSelectedFor(Object value) {
|
||||
TreePath path = (TreePath) value;
|
||||
if (myWizardTree.getSelectionPath() != path) {
|
||||
@@ -431,6 +454,7 @@ public class TreePopupImpl extends WizardPopup implements TreePopup {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModalContext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user