Search in sources :

Example 1 with JBPopupFactory

use of com.intellij.openapi.ui.popup.JBPopupFactory in project intellij-community by JetBrains.

the class EmmetAbbreviationBalloon method show.

public void show(@NotNull final CustomTemplateCallback customTemplateCallback) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        if (ourTestingAbbreviation == null) {
            throw new RuntimeException("Testing abbreviation is not set. See EmmetAbbreviationBalloon#setTestingAbbreviation");
        }
        myCallback.onEnter(ourTestingAbbreviation);
        return;
    }
    final TextFieldWithStoredHistory field = new TextFieldWithStoredHistory(myAbbreviationsHistoryKey);
    final Dimension fieldPreferredSize = field.getPreferredSize();
    field.setPreferredSize(new Dimension(Math.max(220, fieldPreferredSize.width), fieldPreferredSize.height));
    field.setHistorySize(10);
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final BalloonImpl balloon = (BalloonImpl) popupFactory.createDialogBalloonBuilder(field, myTitle).setCloseButtonEnabled(false).setBlockClicksThroughBalloon(true).setAnimationCycle(0).setHideOnKeyOutside(true).setHideOnClickOutside(true).createBalloon();
    final DocumentAdapter documentListener = new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (!isValid(customTemplateCallback)) {
                balloon.hide();
                return;
            }
            validateTemplateKey(field, balloon, field.getText(), customTemplateCallback);
        }
    };
    field.addDocumentListener(documentListener);
    final KeyAdapter keyListener = new KeyAdapter() {

        @Override
        public void keyPressed(@NotNull KeyEvent e) {
            if (!field.isPopupVisible()) {
                if (!isValid(customTemplateCallback)) {
                    balloon.hide();
                    return;
                }
                switch(e.getKeyCode()) {
                    case KeyEvent.VK_ENTER:
                        final String abbreviation = field.getText();
                        if (validateTemplateKey(field, balloon, abbreviation, customTemplateCallback)) {
                            myCallback.onEnter(abbreviation);
                            PropertiesComponent.getInstance().setValue(myLastAbbreviationKey, abbreviation);
                            field.addCurrentTextToHistory();
                            balloon.hide();
                        }
                        break;
                    case KeyEvent.VK_ESCAPE:
                        balloon.hide(false);
                        break;
                }
            }
        }
    };
    field.addKeyboardListener(keyListener);
    balloon.addListener(new JBPopupListener.Adapter() {

        @Override
        public void beforeShown(LightweightWindowEvent event) {
            field.setText(PropertiesComponent.getInstance().getValue(myLastAbbreviationKey, ""));
        }

        @Override
        public void onClosed(LightweightWindowEvent event) {
            field.removeKeyListener(keyListener);
            field.removeDocumentListener(documentListener);
            super.onClosed(event);
        }
    });
    balloon.show(popupFactory.guessBestPopupLocation(customTemplateCallback.getEditor()), Balloon.Position.below);
    final IdeFocusManager focusManager = IdeFocusManager.getInstance(customTemplateCallback.getProject());
    focusManager.doWhenFocusSettlesDown(() -> {
        focusManager.requestFocus(field, true);
        field.selectText();
    });
}
Also used : KeyAdapter(java.awt.event.KeyAdapter) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) DocumentEvent(javax.swing.event.DocumentEvent) NotNull(org.jetbrains.annotations.NotNull) LightweightWindowEvent(com.intellij.openapi.ui.popup.LightweightWindowEvent) KeyEvent(java.awt.event.KeyEvent) JBPopupListener(com.intellij.openapi.ui.popup.JBPopupListener) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory)

Example 2 with JBPopupFactory

use of com.intellij.openapi.ui.popup.JBPopupFactory in project intellij-community by JetBrains.

the class CreateListenerAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    final DefaultActionGroup actionGroup = prepareActionGroup(selection);
    final JComponent selectedComponent = selection.get(0).getDelegee();
    final DataContext context = DataManager.getInstance().getDataContext(selectedComponent);
    final JBPopupFactory factory = JBPopupFactory.getInstance();
    final ListPopup popup = factory.createActionGroupPopup(UIDesignerBundle.message("create.listener.title"), actionGroup, context, JBPopupFactory.ActionSelectionAid.NUMBERING, true);
    FormEditingUtil.showPopupUnderComponent(popup, selection.get(0));
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ListPopup(com.intellij.openapi.ui.popup.ListPopup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 3 with JBPopupFactory

use of com.intellij.openapi.ui.popup.JBPopupFactory in project intellij-community by JetBrains.

the class GroupToolbarAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final ListPopupStep popupStep = popupFactory.createActionsStep(myGroup, e.getDataContext(), false, false, myGroup.getTemplatePresentation().getText(), myToolbarComponent, false, 0, false);
    popupFactory.createListPopup(popupStep).showUnderneathOf(myToolbarComponent);
}
Also used : ListPopupStep(com.intellij.openapi.ui.popup.ListPopupStep) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory)

Example 4 with JBPopupFactory

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

Example 5 with JBPopupFactory

use of com.intellij.openapi.ui.popup.JBPopupFactory in project intellij-community by JetBrains.

the class BeforeRunStepsPanel method doAddAction.

void doAddAction(AnActionButton button) {
    if (isUnknown()) {
        return;
    }
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, myRunConfiguration.getProject());
    Set<Key> activeProviderKeys = getActiveProviderKeys();
    DefaultActionGroup actionGroup = new DefaultActionGroup(null, false);
    for (final BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
        if (provider.createTask(myRunConfiguration) == null)
            continue;
        if (activeProviderKeys.contains(provider.getId()) && provider.isSingleton())
            continue;
        AnAction providerAction = new AnAction(provider.getName(), null, provider.getIcon()) {

            @Override
            public void actionPerformed(AnActionEvent e) {
                BeforeRunTask task = provider.createTask(myRunConfiguration);
                if (task != null) {
                    provider.configureTask(myRunConfiguration, task);
                    if (!provider.canExecuteTask(myRunConfiguration, task))
                        return;
                } else {
                    return;
                }
                task.setEnabled(true);
                Set<RunConfiguration> configurationSet = new HashSet<>();
                getAllRunBeforeRuns(task, configurationSet);
                if (configurationSet.contains(myRunConfiguration)) {
                    JOptionPane.showMessageDialog(BeforeRunStepsPanel.this, ExecutionBundle.message("before.launch.panel.cyclic_dependency_warning", myRunConfiguration.getName(), provider.getDescription(task)), ExecutionBundle.message("warning.common.title"), JOptionPane.WARNING_MESSAGE);
                    return;
                }
                addTask(task);
                myListener.fireStepsBeforeRunChanged();
            }
        };
        actionGroup.add(providerAction);
    }
    final ListPopup popup = popupFactory.createActionGroupPopup(ExecutionBundle.message("add.new.run.configuration.acrtion.name"), actionGroup, SimpleDataContext.getProjectContext(myRunConfiguration.getProject()), false, false, false, null, -1, Conditions.<AnAction>alwaysTrue());
    popup.show(button.getPreferredPopupPoint());
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) BeforeRunTask(com.intellij.execution.BeforeRunTask) UnknownRunConfiguration(com.intellij.execution.configurations.UnknownRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) BeforeRunTaskProvider(com.intellij.execution.BeforeRunTaskProvider) Key(com.intellij.openapi.util.Key) HashSet(com.intellij.util.containers.hash.HashSet)

Aggregations

JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)12 ListPopup (com.intellij.openapi.ui.popup.ListPopup)5 DataContext (com.intellij.openapi.actionSystem.DataContext)3 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)3 Balloon (com.intellij.openapi.ui.popup.Balloon)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 JBPopupListener (com.intellij.openapi.ui.popup.JBPopupListener)2 NotNull (org.jetbrains.annotations.NotNull)2 BeforeRunTask (com.intellij.execution.BeforeRunTask)1 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 UnknownRunConfiguration (com.intellij.execution.configurations.UnknownRunConfiguration)1 Notification (com.intellij.notification.Notification)1 Disposable (com.intellij.openapi.Disposable)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)1 JBPopup (com.intellij.openapi.ui.popup.JBPopup)1