use of com.intellij.openapi.ui.popup.BalloonBuilder in project intellij-community by JetBrains.
the class LivePreview method showBalloon.
private void showBalloon(Editor editor, String replacementPreviewText) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
myReplacementPreviewText = replacementPreviewText;
return;
}
ReplacementView replacementView = new ReplacementView(replacementPreviewText);
BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(replacementView);
balloonBuilder.setFadeoutTime(0);
balloonBuilder.setFillColor(IdeTooltipManager.GRAPHITE_COLOR);
balloonBuilder.setAnimationCycle(0);
balloonBuilder.setHideOnClickOutside(false);
balloonBuilder.setHideOnKeyOutside(false);
balloonBuilder.setHideOnAction(false);
balloonBuilder.setCloseButtonEnabled(true);
myReplacementBalloon = balloonBuilder.createBalloon();
EditorUtil.disposeWithEditor(editor, myReplacementBalloon);
myReplacementBalloon.show(new ReplacementBalloonPositionTracker(editor), Balloon.Position.below);
}
use of com.intellij.openapi.ui.popup.BalloonBuilder in project intellij-community by JetBrains.
the class AbstractSchemesPanel method showStatus.
public void showStatus(final String message, MessageType messageType) {
BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(), messageType.getPopupBackground(), null);
balloonBuilder.setFadeoutTime(5000);
final Balloon balloon = balloonBuilder.createBalloon();
Point pointOnComponent = new Point(myToolbar.getWidth() / 4, myToolbar.getHeight() / 4);
balloon.show(new RelativePoint(myToolbar, pointOnComponent), Balloon.Position.above);
Disposer.register(ProjectManager.getInstance().getDefaultProject(), balloon);
}
use of com.intellij.openapi.ui.popup.BalloonBuilder in project intellij-community by JetBrains.
the class JsonSchemaMappingsView method createUI.
private void createUI(final Project project) {
myProject = project;
myTableView = new TableView<>();
myTableView.getTableHeader().setVisible(false);
myDecorator = ToolbarDecorator.createDecorator(myTableView);
myDecorator.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final int[] rows = myTableView.getSelectedRows();
if (rows != null && rows.length > 0) {
int cnt = 0;
for (int row : rows) {
myTableView.getListTableModel().removeRow(row - cnt);
++cnt;
}
myTableView.getListTableModel().fireTableDataChanged();
myTreeUpdater.run();
}
}
}).setAddAction(new MyAddActionButtonRunnable(project)).disableUpDownActions();
mySchemaField = new TextFieldWithBrowseButton();
SwingHelper.installFileCompletionAndBrowseDialog(myProject, mySchemaField, JsonBundle.message("json.schema.add.schema.chooser.title"), FileChooserDescriptorFactory.createSingleFileDescriptor());
attachNavigateToSchema();
myError = SwingHelper.createHtmlLabel("Warning: conflicting mappings. <a href=\"#\">Show details</a>", null, s -> {
final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(myErrorText, UIUtil.getBalloonWarningIcon(), MessageType.WARNING.getPopupBackground(), null);
builder.setDisposable(this);
builder.setHideOnClickOutside(true);
builder.setCloseButtonEnabled(true);
builder.createBalloon().showInCenterOf(myError);
});
final FormBuilder builder = FormBuilder.createFormBuilder();
final JBLabel label = new JBLabel("JSON schema file:");
builder.addLabeledComponent(label, mySchemaField);
label.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
mySchemaField.setBorder(JBUI.Borders.empty(0, 0, 0, 10));
final JPanel wrapper = new JPanel(new BorderLayout());
wrapper.setBorder(JBUI.Borders.empty(0, 10, 0, 10));
myErrorIcon = new JBLabel(UIUtil.getBalloonWarningIcon());
wrapper.add(myErrorIcon, BorderLayout.WEST);
wrapper.add(myError, BorderLayout.CENTER);
builder.addComponent(wrapper);
builder.addComponentFillVertically(myDecorator.createPanel(), 5);
myComponent = builder.getPanel();
}
use of com.intellij.openapi.ui.popup.BalloonBuilder 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.BalloonBuilder in project intellij-community by JetBrains.
the class InplaceChangeSignature method showBalloon.
protected void showBalloon() {
NonFocusableCheckBox checkBox = new NonFocusableCheckBox(RefactoringBundle.message("delegation.panel.delegate.via.overloading.method"));
checkBox.addActionListener(e -> {
myDelegate = checkBox.isSelected();
updateCurrentInfo();
});
JPanel content = new JPanel(new BorderLayout());
content.add(new JBLabel("Performed signature modifications:"), BorderLayout.NORTH);
content.add(myPreview.getComponent(), BorderLayout.CENTER);
updateMethodSignature(myStableChange);
content.add(checkBox, BorderLayout.SOUTH);
final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(content, null).setSmallVariant(true);
myBalloon = balloonBuilder.createBalloon();
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {
@Override
public RelativePoint recalculateLocation(Balloon object) {
int offset = myStableChange.getMethod().getTextOffset();
VisualPosition visualPosition = myEditor.offsetToVisualPosition(offset);
Point point = myEditor.visualPositionToXY(new VisualPosition(visualPosition.line, visualPosition.column));
return new RelativePoint(myEditor.getContentComponent(), point);
}
}, Balloon.Position.above);
Disposer.register(myBalloon, () -> {
EditorFactory.getInstance().releaseEditor(myPreview);
myPreview = null;
});
}
Aggregations