Search in sources :

Example 6 with BalloonBuilder

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);
}
Also used : BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder)

Example 7 with BalloonBuilder

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);
}
Also used : Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder)

Example 8 with BalloonBuilder

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();
}
Also used : FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) Getter(com.intellij.openapi.util.Getter) MessageType(com.intellij.openapi.ui.MessageType) ActionListener(java.awt.event.ActionListener) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModalityState(com.intellij.openapi.application.ModalityState) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBLabel(com.intellij.ui.components.JBLabel) ArrayList(java.util.ArrayList) Balloon(com.intellij.openapi.ui.popup.Balloon) JBTextField(com.intellij.ui.components.JBTextField) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) Disposer(com.intellij.openapi.util.Disposer) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) Project(com.intellij.openapi.project.Project) FileUtil(com.intellij.openapi.util.io.FileUtil) AnActionButton(com.intellij.ui.AnActionButton) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) JsonBundle(com.intellij.json.JsonBundle) StringUtil(com.intellij.openapi.util.text.StringUtil) TableView(com.intellij.ui.table.TableView) JBRadioButton(com.intellij.ui.components.JBRadioButton) ActionEvent(java.awt.event.ActionEvent) Disposable(com.intellij.openapi.Disposable) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) File(java.io.File) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) Nullable(org.jetbrains.annotations.Nullable) CommonShortcuts(com.intellij.openapi.actionSystem.CommonShortcuts) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) com.intellij.util.ui(com.intellij.util.ui) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) JBPanel(com.intellij.ui.components.JBPanel) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) Alarm(com.intellij.util.Alarm) javax.swing(javax.swing) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) JBLabel(com.intellij.ui.components.JBLabel) AnActionButton(com.intellij.ui.AnActionButton) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder)

Example 9 with BalloonBuilder

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();
}
Also used : Trinity(com.intellij.openapi.util.Trinity) ActionEvent(java.awt.event.ActionEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ArrayList(java.util.ArrayList) Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) IdeFrame(com.intellij.openapi.wm.IdeFrame) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder) Executor(com.intellij.execution.Executor) Pair(com.intellij.openapi.util.Pair) MouseEvent(java.awt.event.MouseEvent) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) RelativePoint(com.intellij.ui.awt.RelativePoint) Project(com.intellij.openapi.project.Project) Ref(com.intellij.openapi.util.Ref) ActionListener(java.awt.event.ActionListener)

Example 10 with BalloonBuilder

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;
    });
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder)

Aggregations

BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)14 Balloon (com.intellij.openapi.ui.popup.Balloon)12 RelativePoint (com.intellij.ui.awt.RelativePoint)7 Disposable (com.intellij.openapi.Disposable)3 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 Project (com.intellij.openapi.project.Project)2 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)2 JBLabel (com.intellij.ui.components.JBLabel)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 MouseEvent (java.awt.event.MouseEvent)2 ArrayList (java.util.ArrayList)2 Executor (com.intellij.execution.Executor)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 JsonBundle (com.intellij.json.JsonBundle)1 CommonShortcuts (com.intellij.openapi.actionSystem.CommonShortcuts)1 ModalityState (com.intellij.openapi.application.ModalityState)1 FileChooserDescriptorFactory (com.intellij.openapi.fileChooser.FileChooserDescriptorFactory)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1