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();
});
}
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));
}
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);
}
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);
}
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());
}
Aggregations