use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class CheckRegExpForm method setBalloonState.
void setBalloonState(RegExpMatchResult result) {
mySampleText.setBackground(result == RegExpMatchResult.MATCHES ? BACKGROUND_COLOR_MATCH : BACKGROUND_COLOR_NOMATCH);
switch(result) {
case MATCHES:
myMessage.setText("Matches!");
break;
case NO_MATCH:
myMessage.setText("No match");
break;
case TIMEOUT:
myMessage.setText("Pattern is too complex");
break;
case BAD_REGEXP:
myMessage.setText("Bad pattern");
break;
}
myRootPanel.revalidate();
Balloon balloon = JBPopupFactory.getInstance().getParentBalloonFor(myRootPanel);
if (balloon != null && !balloon.isDisposed())
balloon.revalidate();
}
use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class SearchForUsagesRunnable method searchUsages.
private void searchUsages(@NotNull final AtomicBoolean findStartedBalloonShown) {
ProgressIndicator indicator = ProgressWrapper.unwrap(ProgressManager.getInstance().getProgressIndicator());
assert indicator != null : "must run find usages under progress";
TooManyUsagesStatus.createFor(indicator);
Alarm findUsagesStartedBalloon = new Alarm();
findUsagesStartedBalloon.addRequest(() -> {
notifyByFindBalloon(null, MessageType.WARNING, myProcessPresentation, myProject, Collections.singletonList(StringUtil.escapeXml(UsageViewManagerImpl.getProgressTitle(myPresentation))));
findStartedBalloonShown.set(true);
}, 300, ModalityState.NON_MODAL);
UsageSearcher usageSearcher = mySearcherFactory.create();
usageSearcher.generate(usage -> {
ProgressIndicator indicator1 = ProgressWrapper.unwrap(ProgressManager.getInstance().getProgressIndicator());
assert indicator1 != null : "must run find usages under progress";
if (indicator1.isCanceled())
return false;
if (!UsageViewManagerImpl.isInScope(usage, mySearchScopeToWarnOfFallingOutOf)) {
myOutOfScopeUsages.incrementAndGet();
return true;
}
boolean incrementCounter = !UsageViewManager.isSelfUsage(usage, mySearchFor);
if (incrementCounter) {
final int usageCount = myUsageCountWithoutDefinition.incrementAndGet();
if (usageCount == 1 && !myProcessPresentation.isShowPanelIfOnlyOneUsage()) {
myFirstUsage.compareAndSet(null, usage);
}
final UsageViewImpl usageView = getUsageView(indicator1);
TooManyUsagesStatus tooManyUsagesStatus = TooManyUsagesStatus.getFrom(indicator1);
if (usageCount > UsageLimitUtil.USAGES_LIMIT && tooManyUsagesStatus.switchTooManyUsagesStatus()) {
UsageViewManagerImpl.showTooManyUsagesWarning(myProject, tooManyUsagesStatus, indicator1, myPresentation, usageCount, usageView);
}
tooManyUsagesStatus.pauseProcessingIfTooManyUsages();
if (usageView != null) {
ApplicationManager.getApplication().runReadAction(() -> usageView.appendUsage(usage));
}
}
return !indicator1.isCanceled();
});
if (getUsageView(indicator) != null) {
ApplicationManager.getApplication().invokeLater(() -> myUsageViewManager.showToolWindow(true), myProject.getDisposed());
}
Disposer.dispose(findUsagesStartedBalloon);
ApplicationManager.getApplication().invokeLater(() -> {
if (findStartedBalloonShown.get()) {
Balloon balloon = ToolWindowManager.getInstance(myProject).getToolWindowBalloon(ToolWindowId.FIND);
if (balloon != null) {
balloon.hide();
}
}
}, myProject.getDisposed());
}
use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class BalloonImpl method createComponent.
private void createComponent() {
myComp = new MyComponent(myContent, this, myShadowBorderProvider != null ? null : myShowPointer ? myPosition.createBorder(this) : getPointlessBorder());
if (myActionProvider == null) {
final Consumer<MouseEvent> listener = event -> {
SwingUtilities.invokeLater(() -> hide());
};
myActionProvider = new ActionProvider() {
private ActionButton myCloseButton;
@NotNull
@Override
public List<ActionButton> createActions() {
myCloseButton = new CloseButton(listener);
return Collections.singletonList(myCloseButton);
}
@Override
public void layout(@NotNull Rectangle lpBounds) {
if (!myCloseButton.isVisible()) {
return;
}
Icon icon = getCloseButton();
int iconWidth = icon.getIconWidth();
int iconHeight = icon.getIconHeight();
Rectangle r = new Rectangle(lpBounds.x + lpBounds.width - iconWidth + (int) (iconWidth * 0.3), lpBounds.y - (int) (iconHeight * 0.3), iconWidth, iconHeight);
Insets border = getShadowBorderInsets();
r.x -= border.left;
r.y -= border.top;
myCloseButton.setBounds(r);
}
};
}
myComp.clear();
myComp.myAlpha = isAnimationEnabled() ? 0f : -1;
myComp.setBorder(new EmptyBorder(getShadowBorderInsets()));
myLayeredPane.add(myComp);
// the second balloon must be over the first one
myLayeredPane.setLayer(myComp, getLayer(), 0);
myPosition.updateBounds(this);
if (myBlockClicks) {
myComp.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
e.consume();
}
@Override
public void mousePressed(MouseEvent e) {
e.consume();
}
@Override
public void mouseReleased(MouseEvent e) {
e.consume();
}
});
}
}
use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class BalloonLayoutImpl method add.
@Override
public void add(@NotNull final Balloon balloon, @Nullable Object layoutData) {
ApplicationManager.getApplication().assertIsDispatchThread();
Balloon merge = merge(layoutData);
if (merge == null) {
if (getVisibleCount() > 0 && layoutData instanceof BalloonLayoutData && ((BalloonLayoutData) layoutData).groupId != null) {
int index = -1;
int count = 0;
for (int i = 0, size = myBalloons.size(); i < size; i++) {
BalloonLayoutData ld = myLayoutData.get(myBalloons.get(i));
if (ld != null && ld.groupId != null) {
if (index == -1) {
index = i;
}
count++;
}
}
if (count > 0 && count == getVisibleCount()) {
remove(myBalloons.get(index));
}
}
myBalloons.add(balloon);
} else {
int index = myBalloons.indexOf(merge);
remove(merge);
myBalloons.add(index, balloon);
}
if (layoutData instanceof BalloonLayoutData) {
BalloonLayoutData balloonLayoutData = (BalloonLayoutData) layoutData;
balloonLayoutData.closeAll = myCloseAll;
balloonLayoutData.doLayout = myLayoutRunnable;
myLayoutData.put(balloon, balloonLayoutData);
}
Disposer.register(balloon, new Disposable() {
public void dispose() {
clearNMore(balloon);
remove(balloon, false);
queueRelayout();
}
});
if (myLafListener == null && layoutData != null) {
myLafListener = new LafManagerListener() {
@Override
public void lookAndFeelChanged(LafManager source) {
for (BalloonLayoutData layoutData : myLayoutData.values()) {
if (layoutData.lafHandler != null) {
layoutData.lafHandler.run();
}
}
}
};
LafManager.getInstance().addLafManagerListener(myLafListener);
}
calculateSize();
relayout();
if (!balloon.isDisposed()) {
balloon.show(myLayeredPane);
}
fireRelayout();
}
use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.
the class BalloonLayoutImpl method calculateSize.
private void calculateSize() {
myWidth = null;
for (Balloon balloon : myBalloons) {
BalloonLayoutData layoutData = myLayoutData.get(balloon);
if (layoutData != null) {
layoutData.height = balloon.getPreferredSize().height;
}
}
myWidth = BalloonLayoutConfiguration.FixedWidth;
}
Aggregations