本文整理汇总了Java中com.intellij.ui.popup.PopupFactoryImpl类的典型用法代码示例。如果您正苦于以下问题:Java PopupFactoryImpl类的具体用法?Java PopupFactoryImpl怎么用?Java PopupFactoryImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PopupFactoryImpl类属于com.intellij.ui.popup包,在下文中一共展示了PopupFactoryImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showPopup
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
protected void showPopup(DataContext context, ListPopup popup, JComponent contextComponent) {
Component focusedComponent = contextComponent != null ? contextComponent : PlatformDataKeys.CONTEXT_COMPONENT.getData(context);
if (focusedComponent != null) {
if (popup instanceof PopupFactoryImpl.ActionGroupPopup && focusedComponent instanceof JLabel) {
((PopupFactoryImpl.ActionGroupPopup)popup).showUnderneathOfLabel((JLabel)focusedComponent);
} else {
popup.showUnderneathOf(focusedComponent);
}
}
else {
Rectangle r;
int x;
int y;
focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
r = WindowManagerEx.getInstanceEx().getScreenBounds();
x = r.x + r.width / 2;
y = r.y + r.height / 2;
Point point = new Point(x, y);
SwingUtilities.convertPointToScreen(point, focusedComponent.getParent());
popup.showInScreenCoordinates(focusedComponent.getParent(), point);
}
}
示例2: createActionLink
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
private JComponent createActionLink(final String text, final String groupId, Icon icon, boolean focusListOnLeft) {
final Ref<ActionLink> ref = new Ref<ActionLink>(null);
AnAction action = new AnAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
ActionGroup configureGroup = (ActionGroup)ActionManager.getInstance().getAction(groupId);
final PopupFactoryImpl.ActionGroupPopup popup = (PopupFactoryImpl.ActionGroupPopup)JBPopupFactory.getInstance()
.createActionGroupPopup(null, new IconsFreeActionGroup(configureGroup), e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false,
ActionPlaces.WELCOME_SCREEN);
popup.showUnderneathOfLabel(ref.get());
UsageTrigger.trigger("welcome.screen." + groupId);
}
};
ref.set(new ActionLink(text, icon, action));
ref.get().setPaintUnderline(false);
ref.get().setNormalColor(getLinkNormalColor());
NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
panel.setBorder(JBUI.Borders.empty(4, 6, 4, 6));
panel.add(ref.get());
panel.add(createArrow(ref.get()), BorderLayout.EAST);
installFocusable(panel, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, focusListOnLeft);
return panel;
}
示例3: selectItemByText
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
private static void selectItemByText(@NotNull final JList list, @NotNull final String text) {
final Integer appIndex = execute(new GuiQuery<Integer>() {
@Override
protected Integer executeInEDT() throws Throwable {
ListPopupModel popupModel = (ListPopupModel)list.getModel();
for (int i = 0; i < popupModel.getSize(); ++i) {
PopupFactoryImpl.ActionItem actionItem = (PopupFactoryImpl.ActionItem)popupModel.get(i);
assertNotNull(actionItem);
if (text.equals(actionItem.getText())) {
return i;
}
}
return -1;
}
});
//noinspection ConstantConditions
assertTrue(appIndex >= 0);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
list.setSelectedIndex(appIndex);
}
});
assertEquals(text, ((PopupFactoryImpl.ActionItem)list.getSelectedValue()).getText());
}
示例4: preselectedIndex
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
private int preselectedIndex(Iterator items) {
for( int index = 0; items.hasNext(); index++ ) {
Object item = items.next();
GuardPopupAction<?> action = null;
if ( item instanceof GuardPopupAction ) {
action = (GuardPopupAction)item;
}
else if ( item instanceof PopupFactoryImpl.ActionItem && ((PopupFactoryImpl.ActionItem)item).getAction() instanceof GuardPopupAction ) {
action= (GuardPopupAction)((PopupFactoryImpl.ActionItem)item).getAction();
}
if ( action == null ) {
continue;
}
if ( action.getSelectionKey() != null && action.getSelectionKey().isSelectableBy(selection) ) {
return index;
}
}
return -1;
}
示例5: actionPerformed
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
@SuppressWarnings("SuspiciousMethodCalls")
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
AnAction perform = whenSelected.get(list.getSelectedValue());
if ( perform != null) {
PopupFactoryImpl.ActionItem selected = (PopupFactoryImpl.ActionItem)list.getSelectedValue();
if ( selected.isEnabled() && selected.equals(list.getSelectedValue()) ) {
Presentation presentation = perform.getTemplatePresentation().clone();
perform.update(event);
perform.beforeActionPerformedUpdate(event);
event = new AnActionEvent(
event.getInputEvent(), event.getDataContext(), event.getPlace(),
presentation, ActionManager.getInstance(), event.getModifiers());
if ( presentation.isEnabled() ) {
perform.actionPerformed(event);
}
}
}
else if ( selectItem != null ) {
if ( selectItem.isEnabled() ) {
list.setSelectedValue(selectItem, true);
popup.handleSelect(selectHandleFinalChoices);
}
}
}
示例6: registerActions
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
private void registerActions(final ListPopupImpl popup) {
popup.registerAction("delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), new AbstractAction() {
public void actionPerformed(ActionEvent e) {
JList list = popup.getList();
int selectedIndex = list.getSelectedIndex();
ListPopupModel model = (ListPopupModel) list.getModel();
PopupFactoryImpl.ActionItem selectedItem = (PopupFactoryImpl.ActionItem) model.get(selectedIndex);
if (selectedItem != null && selectedItem.getAction() instanceof RunGoalAction) {
RunGoalAction action = (RunGoalAction) selectedItem.getAction();
boolean deleted = ApplicationComponent.getInstance().getState().removeGoal(action.getGoal());
if (deleted) {
model.deleteItem(selectedItem);
if (selectedIndex == list.getModel().getSize()) { // is last
list.setSelectedIndex(selectedIndex - 1);
} else {
list.setSelectedIndex(selectedIndex);
}
}
}
}
});
}
示例7: showPopup
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
protected void showPopup(DataContext context, ListPopup popup, JComponent contextComponent) {
Component focusedComponent = contextComponent != null ? contextComponent : context.getData(PlatformDataKeys.CONTEXT_COMPONENT);
if (focusedComponent != null) {
if (popup instanceof PopupFactoryImpl.ActionGroupPopup && focusedComponent instanceof JLabel) {
((PopupFactoryImpl.ActionGroupPopup)popup).showUnderneathOfLabel((JLabel)focusedComponent);
} else {
popup.showUnderneathOf(focusedComponent);
}
}
else {
Rectangle r;
int x;
int y;
focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent((Project)null);
r = WindowManagerEx.getInstanceEx().getScreenBounds();
x = r.x + r.width / 2;
y = r.y + r.height / 2;
Point point = new Point(x, y);
SwingUtilities.convertPointToScreen(point, focusedComponent.getParent());
popup.showInScreenCoordinates(focusedComponent.getParent(), point);
}
}
示例8: createActionLink
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
private JComponent createActionLink(final String text, final String groupId, Icon icon, boolean focusListOnLeft) {
final Ref<ActionLink> ref = new Ref<>(null);
AnAction action = new AnAction() {
@RequiredDispatchThread
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
ActionGroup configureGroup = (ActionGroup)ActionManager.getInstance().getAction(groupId);
final PopupFactoryImpl.ActionGroupPopup popup = (PopupFactoryImpl.ActionGroupPopup)JBPopupFactory.getInstance()
.createActionGroupPopup(null, new IconsFreeActionGroup(configureGroup), e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false, ActionPlaces.WELCOME_SCREEN);
popup.showUnderneathOfLabel(ref.get());
UsageTrigger.trigger("welcome.screen." + groupId);
}
};
JComponent panel = createActionLink(text, icon, ref, action);
installFocusable(panel, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, focusListOnLeft);
return panel;
}
示例9: showPopupBalloon
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
private void showPopupBalloon(final String result) {
ApplicationManager.getApplication().invokeLater(() -> {
mEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);//解决因为TranslationPlugin而导致的泡泡显示错位问题
JBPopupFactory factory = JBPopupFactory.getInstance();
factory.createHtmlTextBalloonBuilder(result, null, new JBColor(Gray._242, Gray._0), null)
.createBalloon()
.show(factory.guessBestPopupLocation(mEditor), Balloon.Position.below);
});
}
示例10: getRootAction
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
@Nullable
private static RootAction getRootAction(Object value) {
if (value instanceof PopupFactoryImpl.ActionItem) {
AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction();
if (action instanceof RootAction) {
return (RootAction)action;
}
}
return null;
}
示例11: run
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
@Override
public void run() {
myAlarm.cancelAllRequests();
// Skip the request if it's outdated (the mouse is moved other another element).
DelayedQuickDocInfo info = myDelayedQuickDocInfo;
if (info == null || !info.targetElement.equals(myActiveElements.get(info.editor))) {
return;
}
// Skip the request if there is a control shown as a result of explicit 'show quick doc' (Ctrl + Q) invocation.
if (info.docManager.getDocInfoHint() != null && !info.docManager.isCloseOnSneeze()) {
return;
}
// We don't want to show a quick doc control if there is an active hint (e.g. the mouse is under an invalid element
// and corresponding error info is shown).
if (!info.docManager.hasActiveDockedDocWindow() && myHintManager.hasShownHintsThatWillHideByOtherHint(false)) {
myAlarm.addRequest(this, EditorSettingsExternalizable.getInstance().getQuickDocOnMouseOverElementDelayMillis());
return;
}
info.editor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION,
info.editor.offsetToVisualPosition(info.originalElement.getTextRange().getStartOffset()));
try {
info.docManager.showJavaDocInfo(info.editor, info.targetElement, info.originalElement, myHintCloseCallback, true);
myDocumentationManager = new WeakReference<DocumentationManager>(info.docManager);
}
finally {
info.editor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);
}
}
示例12: getRunConfigList
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
@NotNull
private JList getRunConfigList() {
final JList runConfigList = robot.finder().findByType(JBListWithHintProvider.class);
pause(new Condition("Wait until the list is populated.") {
@Override
public boolean test() {
//noinspection ConstantConditions
return execute(new GuiQuery<Boolean>() {
@Override
protected Boolean executeInEDT() throws Throwable {
return runConfigList.getComponentCount() >= 2; // At least 2, since there is always one option present (the option to edit).
}
});
}
}, SHORT_TIMEOUT);
Object selectedValue = execute(new GuiQuery<Object>() {
@Override
protected Object executeInEDT() throws Throwable {
return runConfigList.getSelectedValue();
}
});
assertThat(selectedValue).isInstanceOf(PopupFactoryImpl.ActionItem.class);
return runConfigList;
}
示例13: run
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
@Override
public void run() {
myAlarm.cancelAllRequests();
// Skip the request if it's outdated (the mouse is moved other another element).
DelayedQuickDocInfo info = myDelayedQuickDocInfo;
if (info == null || !info.targetElement.equals(myActiveElements.get(info.editor))) {
return;
}
// Skip the request if there is a control shown as a result of explicit 'show quick doc' (Ctrl + Q) invocation.
if (info.docManager.getDocInfoHint() != null && !info.docManager.isCloseOnSneeze()) {
return;
}
// We don't want to show a quick doc control if there is an active hint (e.g. the mouse is under an invalid element
// and corresponding error info is shown).
if (!info.docManager.hasActiveDockedDocWindow() && myHintManager.hasShownHintsThatWillHideByOtherHint(false)) {
myAlarm.addRequest(this, EditorSettingsExternalizable.getInstance().getQuickDocOnMouseOverElementDelayMillis());
return;
}
info.editor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION,
info.editor.offsetToVisualPosition(info.originalElement.getTextRange().getStartOffset()));
try {
info.docManager.showJavaDocInfo(info.editor, info.targetElement, info.originalElement, myHintCloseCallback, true, true);
myDocumentationManager = new WeakReference<DocumentationManager>(info.docManager);
myDocumentationManager = new WeakReference<DocumentationManager>(info.docManager);
}
finally {
info.editor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);
}
}
示例14: preselect
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
private void preselect(final ListPopup popup) {
Iterator items = popup.getListStep().getValues().iterator();
int index = preselectedIndex(items);
if ( index >= 0 ) {
findJList(popup).setSelectedIndex(index);
AnAction action = ((PopupFactoryImpl.ActionItem)popup.getListStep().getValues().get(index)).getAction();
if ( action instanceof ActionGroup ) {
if ( preselectedIndex(Arrays.asList(((ActionGroup)action).getChildren(null)).iterator()) >= 0 ) {
// ensure that the next sub-menu gets activated
Window window = (Window)SwingUtilities.getRoot(popup.getContent());
if ( window.isVisible() ) {
popup.handleSelect(false);
}
else {
window.addWindowListener(
new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
popup.handleSelect(false);
e.getWindow().removeWindowListener(this);
}
});
}
}
}
}
}
示例15: install
import com.intellij.ui.popup.PopupFactoryImpl; //导入依赖的package包/类
void install(JComponent component) {
for( Object item : popup.getListStep().getValues() ) {
if ( item instanceof PopupFactoryImpl.ActionItem ) {
if ( ((PopupFactoryImpl.ActionItem)item).getAction() instanceof GuardPopupAction ) {
((GuardPopupAction)((PopupFactoryImpl.ActionItem)item).getAction())
.extendKeyboardActions(new Extender((PopupFactoryImpl.ActionItem)item));
}
}
}
for( Map.Entry<KeyStroke, Mapping> mapping : mappings.entrySet() ) {
mapping.getValue().registerCustomShortcutSet(new CustomShortcutSet(mapping.getKey()), component);
}
}