use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class DirDiffTableModel method reportException.
private void reportException(final String htmlContent) {
Runnable balloonShower = () -> {
Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(htmlContent, MessageType.WARNING, null).setShowCallout(false).setHideOnClickOutside(true).setHideOnAction(true).setHideOnFrameResize(true).setHideOnKeyOutside(true).createBalloon();
final Rectangle rect = myPanel.getPanel().getBounds();
final Point p = new Point(rect.x + rect.width - 100, rect.y + 50);
final RelativePoint point = new RelativePoint(myPanel.getPanel(), p);
balloon.show(point, Balloon.Position.below);
Disposer.register(myProject != null ? myProject : ApplicationManager.getApplication(), balloon);
};
ApplicationManager.getApplication().invokeLater(balloonShower, o -> !(myProject == null || myProject.isDefault()) && ((!myProject.isOpen()) || myProject.isDisposed()));
}
use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class NewColorAndFontPanel method notifyAtSchemePanel.
private void notifyAtSchemePanel(@NotNull String message) {
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
Balloon balloon = popupFactory.createHtmlTextBalloonBuilder(message, MessageType.INFO, null).setHideOnClickOutside(true).setHideOnKeyOutside(true).createBalloon();
Disposer.register(ApplicationManager.getApplication(), balloon);
balloon.show(new RelativePoint(mySchemesPanel, new Point(mySchemesPanel.getWidth() / 10, mySchemesPanel.getHeight())), Balloon.Position.below);
}
use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class QuickEditHandler method showBalloon.
public static void showBalloon(Editor editor, PsiFile newFile, JComponent component) {
final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(component).setShadow(true).setAnimationCycle(0).setHideOnClickOutside(true).setHideOnKeyOutside(true).setHideOnAction(false).setFillColor(UIUtil.getControlColor()).createBalloon();
new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
balloon.hide();
}
}.registerCustomShortcutSet(CommonShortcuts.ESCAPE, component);
Disposer.register(newFile.getProject(), balloon);
final Balloon.Position position = QuickEditAction.getBalloonPosition(editor);
RelativePoint point = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
if (position == Balloon.Position.above) {
final Point p = point.getPoint();
point = new RelativePoint(point.getComponent(), new Point(p.x, p.y - editor.getLineHeight()));
}
balloon.show(point, position);
}
use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class ShowRunningListAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getProject();
if (project == null || project.isDisposed())
return;
final Ref<Pair<? extends JComponent, String>> stateRef = new Ref<>();
final Ref<Balloon> balloonRef = new Ref<>();
final Timer timer = UIUtil.createNamedTimer("runningLists", 250);
ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Balloon balloon = balloonRef.get();
if (project.isDisposed() || (balloon != null && balloon.isDisposed())) {
timer.stop();
return;
}
ArrayList<Project> projects = new ArrayList<>(Arrays.asList(ProjectManager.getInstance().getOpenProjects()));
//List should begin with current project
projects.remove(project);
projects.add(0, project);
Pair<? extends JComponent, String> state = getCurrentState(projects);
Pair<? extends JComponent, String> prevState = stateRef.get();
if (prevState != null && prevState.getSecond().equals(state.getSecond()))
return;
stateRef.set(state);
BalloonBuilder builder = JBPopupFactory.getInstance().createBalloonBuilder(state.getFirst());
builder.setShowCallout(false).setTitle(ExecutionBundle.message("show.running.list.balloon.title")).setBlockClicksThroughBalloon(true).setDialogMode(true).setHideOnKeyOutside(false);
IdeFrame frame = IdeFrame.KEY.getData(e.getDataContext());
if (frame == null) {
frame = WindowManagerEx.getInstanceEx().getFrame(project);
}
if (balloon != null) {
balloon.hide();
}
builder.setClickHandler(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof MouseEvent) {
MouseEvent mouseEvent = (MouseEvent) e.getSource();
Component component = mouseEvent.getComponent();
component = SwingUtilities.getDeepestComponentAt(component, mouseEvent.getX(), mouseEvent.getY());
Object value = ((JComponent) component).getClientProperty(KEY);
if (value instanceof Trinity) {
Project aProject = (Project) ((Trinity) value).first;
JFrame aFrame = WindowManager.getInstance().getFrame(aProject);
if (aFrame != null && !aFrame.isActive()) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(aFrame, true);
});
}
ExecutionManagerImpl.getInstance(aProject).getContentManager().toFrontRunContent((Executor) ((Trinity) value).second, (RunContentDescriptor) ((Trinity) value).third);
}
}
}
}, false);
balloon = builder.createBalloon();
balloonRef.set(balloon);
JComponent component = frame.getComponent();
RelativePoint point = new RelativePoint(component, new Point(component.getWidth(), 0));
balloon.show(point, Balloon.Position.below);
}
};
timer.addActionListener(actionListener);
timer.setInitialDelay(0);
timer.start();
}
use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class InplaceRefactoring method showBalloon.
protected void showBalloon() {
final JComponent component = getComponent();
if (component == null)
return;
if (ApplicationManager.getApplication().isHeadlessEnvironment())
return;
final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(component, null).setSmallVariant(true);
myBalloon = balloonBuilder.createBalloon();
Disposer.register(myProject, myBalloon);
Disposer.register(myBalloon, new Disposable() {
@Override
public void dispose() {
releaseIfNotRestart();
myEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);
}
});
EditorUtil.disposeWithEditor(myEditor, myBalloon);
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {
@Override
public RelativePoint recalculateLocation(Balloon object) {
if (myTarget != null && !popupFactory.isBestPopupLocationVisible(myEditor)) {
return myTarget;
}
if (myCaretRangeMarker != null && myCaretRangeMarker.isValid()) {
myEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, myEditor.offsetToVisualPosition(myCaretRangeMarker.getStartOffset()));
}
final RelativePoint target = popupFactory.guessBestPopupLocation(myEditor);
final Point screenPoint = target.getScreenPoint();
int y = screenPoint.y;
if (target.getPoint().getY() > myEditor.getLineHeight() + myBalloon.getPreferredSize().getHeight()) {
y -= myEditor.getLineHeight();
}
myTarget = new RelativePoint(new Point(screenPoint.x, y));
return myTarget;
}
}, Balloon.Position.above);
}
Aggregations