本文整理汇总了Java中com.intellij.openapi.ui.popup.JBPopup.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java JBPopup.getContent方法的具体用法?Java JBPopup.getContent怎么用?Java JBPopup.getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.ui.popup.JBPopup
的用法示例。
在下文中一共展示了JBPopup.getContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: discoverPopup
import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
private static Component discoverPopup(final DataKey<JBPopup> datakey, Component focusOwner) {
if (focusOwner == null) {
focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
}
if (focusOwner == null) return null;
final DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
if (dataContext == null) return null;
final JBPopup popup = datakey.getData(dataContext);
if (popup != null && popup.isVisible()) {
return popup.getContent();
}
return null;
}
示例2: eventDispatched
import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
@Override
public void eventDispatched(AWTEvent event) {
if (event.getID() == WindowEvent.WINDOW_OPENED) {
final WindowEvent we = (WindowEvent)event;
final List<JBPopup> popups = JBPopupFactory.getInstance().getChildPopups(this);
if (popups != null) {
for (JBPopup each : popups) {
if (each.getContent() != null && SwingUtilities.isDescendingFrom(each.getContent(), we.getWindow())) {
super.setPopupVisible(false);
}
}
}
}
}
示例3: showNotePopup
import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
private void showNotePopup(Project project,
final DnDAwareTree tree,
final Consumer<String> after, final String initText) {
final JTextArea textArea = new JTextArea(3, 50);
textArea.setFont(UIUtil.getTreeFont());
textArea.setText(initText);
final JBScrollPane pane = new JBScrollPane(textArea);
final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(pane, textArea)
.setCancelOnClickOutside(true)
.setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish")
.setTitle("Comment")
.setMovable(true)
.setRequestFocus(true).setResizable(true).setMayBeParent(true);
final JBPopup popup = builder.createPopup();
final JComponent content = popup.getContent();
final AnAction action = new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
popup.closeOk(e.getInputEvent());
unregisterCustomShortcutSet(content);
after.consume(textArea.getText());
}
};
action.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
popup.showInCenterOf(tree);
}
}, ModalityState.NON_MODAL, project.getDisposed());
}
示例4: setSizeAndDimensions
import com.intellij.openapi.ui.popup.JBPopup; //导入方法依赖的package包/类
private void setSizeAndDimensions(@NotNull JTable table,
@NotNull JBPopup popup,
@NotNull RelativePoint popupPosition,
@NotNull List<UsageNode> data) {
JComponent content = popup.getContent();
Window window = SwingUtilities.windowForComponent(content);
Dimension d = window.getSize();
int width = calcMaxWidth(table);
width = (int)Math.max(d.getWidth(), width);
Dimension headerSize = ((AbstractPopup)popup).getHeaderPreferredSize();
width = Math.max((int)headerSize.getWidth(), width);
width = Math.max(myWidth, width);
if (myWidth == -1) myWidth = width;
int newWidth = Math.max(width, d.width + width - myWidth);
myWidth = newWidth;
int rowsToShow = Math.min(30, data.size());
Dimension dimension = new Dimension(newWidth, table.getRowHeight() * rowsToShow);
Rectangle rectangle = fitToScreen(dimension, popupPosition, table);
if (!data.isEmpty()) {
ScrollingUtil.ensureSelectionExists(table);
}
table.setSize(rectangle.getSize());
//table.setPreferredSize(dimension);
//table.setMaximumSize(dimension);
//table.setPreferredScrollableViewportSize(dimension);
Dimension footerSize = ((AbstractPopup)popup).getFooterPreferredSize();
rectangle.height += headerSize.height + footerSize.height + 4/* invisible borders, margins etc*/;
ScreenUtil.fitToScreen(rectangle);
Dimension newDim = rectangle.getSize();
window.setBounds(rectangle);
window.setMinimumSize(newDim);
window.setMaximumSize(newDim);
window.validate();
window.repaint();
}