本文整理汇总了Java中com.intellij.openapi.ui.popup.JBPopup类的典型用法代码示例。如果您正苦于以下问题:Java JBPopup类的具体用法?Java JBPopup怎么用?Java JBPopup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JBPopup类属于com.intellij.openapi.ui.popup包,在下文中一共展示了JBPopup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openSample
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
private void openSample(Project project, Editor editor) {
EditorTextField field = new EditorTextField(editor.getDocument(), project, WeexFileType.INSTANCE, true, false) {
@Override
protected EditorEx createEditor() {
EditorEx editor1 = super.createEditor();
editor1.setVerticalScrollbarVisible(true);
editor1.setHorizontalScrollbarVisible(true);
return editor1;
}
};
field.setFont(editor.getContentComponent().getFont());
JBPopup jbPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(field, null)
.createPopup();
jbPopup.setSize(new Dimension(500, 500));
jbPopup.showInBestPositionFor(editor);
}
示例2: evaluate
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
public void evaluate(@NotNull final XFullValueEvaluationCallback callback) throws Exception {
final T data = getData();
DebuggerUIUtil.invokeLater(new Runnable() {
@Override
public void run() {
if (callback.isObsolete()) return;
final JComponent comp = createComponent(data);
Project project = getEvaluationContext().getProject();
JBPopup popup = DebuggerUIUtil.createValuePopup(project, comp, null);
JFrame frame = WindowManager.getInstance().getFrame(project);
Dimension frameSize = frame.getSize();
Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2);
popup.setSize(size);
if (comp instanceof Disposable) {
Disposer.register(popup, (Disposable)comp);
}
callback.evaluated("");
popup.show(new RelativePoint(frame, new Point(size.width / 2, size.height / 2)));
}
});
}
示例3: navigate
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
public void navigate(MouseEvent e, PsiElement nameIdentifier) {
final PsiElement listOwner = nameIdentifier.getParent();
final PsiFile containingFile = listOwner.getContainingFile();
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(listOwner);
if (virtualFile != null && containingFile != null) {
final Project project = listOwner.getProject();
final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor != null) {
editor.getCaretModel().moveToOffset(nameIdentifier.getTextOffset());
final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file != null && virtualFile.equals(file.getVirtualFile())) {
final JBPopup popup = createActionGroupPopup(containingFile, project, editor);
if (popup != null) {
popup.show(new RelativePoint(e));
}
}
}
}
}
示例4: createActionGroupPopup
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Nullable
protected JBPopup createActionGroupPopup(PsiFile file, Project project, Editor editor) {
final DefaultActionGroup group = new DefaultActionGroup();
for (final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) {
if (shouldShowInGutterPopup(action) && action.isAvailable(project, editor, file)) {
group.add(new ApplyIntentionAction(action, action.getText(), editor, file));
}
}
if (group.getChildrenCount() > 0) {
final DataContext context = SimpleDataContext.getProjectContext(null);
return JBPopupFactory.getInstance()
.createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);
}
return null;
}
示例5: getOwner
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Nullable
public static Component getOwner(@Nullable Component c) {
if (c == null) return null;
final Window wnd = SwingUtilities.getWindowAncestor(c);
if (wnd instanceof JWindow) {
final JRootPane root = ((JWindow)wnd).getRootPane();
final JBPopup popup = (JBPopup)root.getClientProperty(JBPopup.KEY);
if (popup == null) return c;
final Component owner = popup.getOwner();
if (owner == null) return c;
return getOwner(owner);
}
else {
return c;
}
}
示例6: createPopup
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@NotNull
JBPopup createPopup() {
JPanel panel = new JPanel(new BorderLayout());
panel.add(myTextField, BorderLayout.CENTER);
ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField)
.setCancelOnClickOutside(true)
.setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish")
.setRequestFocus(true)
.setResizable(true)
.setMayBeParent(true);
final JBPopup popup = builder.createPopup();
popup.setMinimumSize(new Dimension(200, 90));
AnAction okAction = new DumbAwareAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
unregisterCustomShortcutSet(popup.getContent());
popup.closeOk(e.getInputEvent());
}
};
okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent());
return popup;
}
示例7: adjustContainerWindow
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
public void adjustContainerWindow(Component c, Dimension oldSize, Dimension newSize) {
if (c == null) return;
Window wnd = SwingUtilities.getWindowAncestor(c);
if (wnd instanceof JWindow) {
JBPopup popup = (JBPopup)((JWindow)wnd).getRootPane().getClientProperty(JBPopup.KEY);
if (popup != null) {
if (oldSize.height < newSize.height) {
Dimension size = popup.getSize();
size.height += newSize.height - oldSize.height;
popup.setSize(size);
popup.moveToFitScreen();
}
}
}
}
示例8: DialogPopupWrapper
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
public DialogPopupWrapper(Component owner, Component content, int x, int y, JBPopup jbPopup) {
if (!owner.isShowing()) {
throw new IllegalArgumentException("Popup owner must be showing");
}
final Window wnd = UIUtil.getWindow(owner);
if (wnd instanceof Frame) {
myDialog = new JDialog((Frame)wnd);
} else if (wnd instanceof Dialog) {
myDialog = new JDialog((Dialog)wnd);
} else {
myDialog = new JDialog();
}
myDialog.getContentPane().setLayout(new BorderLayout());
myDialog.getContentPane().add(content, BorderLayout.CENTER);
myDialog.getRootPane().putClientProperty(JBPopup.KEY, jbPopup);
myDialog.setUndecorated(true);
myDialog.setBackground(UIUtil.getPanelBackground());
myDialog.pack();
myDialog.setLocation(x, y);
}
示例9: getChildPopups
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@NotNull
public static List<JBPopup> getChildPopups(@NotNull final Component component) {
List<JBPopup> result = new ArrayList<JBPopup>();
final Window window = UIUtil.getWindow(component);
if (window == null) return result;
final List<FocusTrackback> stack = getCleanStackForRoot(findUtlimateParent(window));
for (FocusTrackback each : stack) {
if (each.isChildFor(component) && each.getRequestor() instanceof JBPopup) {
result.add((JBPopup)each.getRequestor());
}
}
return result;
}
示例10: actionPerformed
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
Disposable disposable = Disposer.newDisposable();
NewRecentProjectPanel panel = new NewRecentProjectPanel(disposable);
JList list = UIUtil.findComponentOfType(panel, JList.class);
JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, list)
.setTitle("Recent Projects")
.setFocusable(true)
.setRequestFocus(true)
.setMayBeParent(true)
.setMovable(true)
.createPopup();
Disposer.register(popup, disposable);
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
popup.showCenteredInCurrentWindow(project);
}
示例11: createPopup
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@NotNull
@Override
protected JBPopup createPopup(@NotNull AnActionEvent e) {
Project project = e.getProject();
if (project == null) project = ProjectManager.getInstance().getDefaultProject();
Ref<JBPopup> popup = new Ref<JBPopup>();
ChangesBrowser cb = new MyChangesBrowser(project, getChanges(), getCurrentSelection(), popup);
popup.set(JBPopupFactory.getInstance()
.createComponentPopupBuilder(cb, cb.getPreferredFocusedComponent())
.setResizable(true)
.setModalContext(false)
.setFocusable(true)
.setRequestFocus(true)
.setCancelOnWindowDeactivation(true)
.setCancelOnOtherWindowOpen(true)
.setMovable(true)
.setCancelKeyEnabled(true)
.setCancelOnClickOutside(true)
.setDimensionServiceKey(project, "Diff.GoToChangePopup", false)
.createPopup());
return popup.get();
}
示例12: MyChangesBrowser
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
public MyChangesBrowser(@NotNull Project project,
@NotNull List<Change> changes,
@Nullable final Change currentChange,
@NotNull Ref<JBPopup> popup) {
super(project, null, changes, null, false, false, null, MyUseCase.LOCAL_CHANGES, null);
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setChangesToDisplay(changes);
UiNotifyConnector.doWhenFirstShown(this, new Runnable() {
@Override
public void run() {
if (currentChange != null) select(Collections.singletonList(currentChange));
}
});
myPopup = popup;
}
示例13: createComboBoxButton
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Override
protected FlatComboButton createComboBoxButton(Presentation presentation) {
if (myShowDisabledActions) {
return new FlatComboButton(presentation) {
@Override
protected JBPopup createPopup(Runnable onDispose) {
ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
null, createPopupActionGroup(this), getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true, onDispose,
getMaxRows());
popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
return popup;
}
};
}
return super.createComboBoxButton(presentation);
}
示例14: getActiveDocComponent
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@Nullable
public static DocumentationComponent getActiveDocComponent(@NotNull Project project) {
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
DocumentationComponent component;
JBPopup hint = documentationManager.getDocInfoHint();
if (hint != null) {
component = (DocumentationComponent)((AbstractPopup)hint).getComponent();
}
else if (documentationManager.hasActiveDockedDocWindow()) {
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION);
Content selectedContent = toolWindow == null ? null : toolWindow.getContentManager().getSelectedContent();
component = selectedContent == null ? null : (DocumentationComponent)selectedContent.getComponent();
}
else {
component = null;
}
return component;
}
示例15: getRelatedItemsPopup
import com.intellij.openapi.ui.popup.JBPopup; //导入依赖的package包/类
@NotNull
public static JBPopup getRelatedItemsPopup(final List<? extends GotoRelatedItem> items, String title) {
Object[] elements = new Object[items.size()];
//todo[nik] move presentation logic to GotoRelatedItem class
final Map<PsiElement, GotoRelatedItem> itemsMap = new HashMap<PsiElement, GotoRelatedItem>();
for (int i = 0; i < items.size(); i++) {
GotoRelatedItem item = items.get(i);
elements[i] = item.getElement() != null ? item.getElement() : item;
itemsMap.put(item.getElement(), item);
}
return getPsiElementPopup(elements, itemsMap, title, new Processor<Object>() {
@Override
public boolean process(Object element) {
if (element instanceof PsiElement) {
//noinspection SuspiciousMethodCalls
itemsMap.get(element).navigate();
}
else {
((GotoRelatedItem)element).navigate();
}
return true;
}
}
);
}