use of com.intellij.ui.BalloonLayout in project intellij-community by JetBrains.
the class ExtractCodeStyleAction method reportResult.
public void reportResult(final ValuesExtractionResult forSelection, final Project project, final CodeStyleSettings cloneSettings, final PsiFile file, final Map<Value, Object> backup) {
final Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder("Formatting Options were extracted<br/><a href=\"apply\">Apply</a> <a href=\"details\">Details...</a>", MessageType.INFO, new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
boolean apply = "apply".equals(e.getDescription());
ExtractedSettingsDialog myDialog = null;
if (!apply) {
final List<Value> values = forSelection.getValues();
final LanguageCodeStyleSettingsProvider[] providers = Extensions.getExtensions(LanguageCodeStyleSettingsProvider.EP_NAME);
Language language = file.getLanguage();
CodeStyleSettingsNameProvider nameProvider = new CodeStyleSettingsNameProvider();
for (final LanguageCodeStyleSettingsProvider provider : providers) {
Language target = provider.getLanguage();
if (target.equals(language)) {
//this is our language
nameProvider.addSettings(provider);
myDialog = new ExtractedSettingsDialog(project, nameProvider, values);
apply = myDialog.showAndGet();
break;
}
}
}
if (apply && myDialog != null) {
//create new settings named after the file
final ExtractedSettingsDialog finalMyDialog = myDialog;
forSelection.applyConditioned(value -> finalMyDialog.valueIsSelectedInTree(value), backup);
CodeStyleScheme derivedScheme = CodeStyleSchemes.getInstance().createNewScheme("Derived from " + file.getName(), null);
derivedScheme.getCodeStyleSettings().copyFrom(cloneSettings);
CodeStyleSchemes.getInstance().addScheme(derivedScheme);
CodeStyleSchemesImpl.getSchemeManager().setCurrent(derivedScheme);
CodeStyleSettingsManager.getInstance(project).PREFERRED_PROJECT_CODE_STYLE = derivedScheme.getName();
}
}
}
}).setDisposable(ApplicationManager.getApplication()).setShowCallout(false).setFadeoutTime(0).setShowCallout(false).setAnimationCycle(0).setHideOnClickOutside(false).setHideOnKeyOutside(false).setCloseButtonEnabled(true).setHideOnLinkClick(true).createBalloon();
ApplicationManager.getApplication().invokeLater(() -> {
Window window = WindowManager.getInstance().getFrame(project);
if (window == null) {
window = JOptionPane.getRootFrame();
}
if (window instanceof IdeFrame) {
BalloonLayout layout = ((IdeFrame) window).getBalloonLayout();
if (layout != null) {
layout.add(balloon);
}
}
});
}
use of com.intellij.ui.BalloonLayout in project intellij-community by JetBrains.
the class IdeRootPane method uiSettingsChanged.
@Override
public void uiSettingsChanged(UISettings uiSettings) {
setMemoryIndicatorVisible(uiSettings.getShowMemoryIndicator());
updateToolbarVisibility();
updateStatusBarVisibility();
for (IdeRootPaneNorthExtension component : myNorthComponents) {
component.uiSettingsChanged(uiSettings);
}
IdeFrame frame = UIUtil.getParentOfType(IdeFrame.class, this);
BalloonLayout layout = frame != null ? frame.getBalloonLayout() : null;
if (layout instanceof BalloonLayoutImpl)
((BalloonLayoutImpl) layout).queueRelayout();
}
use of com.intellij.ui.BalloonLayout in project intellij-community by JetBrains.
the class IdeMessagePanel method showErrorNotification.
private void showErrorNotification(@Nullable String notificationText, @NotNull Project project) {
Notification notification = new Notification("", AllIcons.Ide.FatalError, notificationText == null ? ERROR_TITLE : "", null, notificationText == null ? "" : notificationText, NotificationType.ERROR, null);
if (notificationText == null) {
notification.addAction(new NotificationAction(ERROR_LINK) {
@Override
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
notification.expire();
_openFatals(null);
}
});
}
BalloonLayout layout = myFrame.getBalloonLayout();
assert layout != null;
BalloonLayoutData layoutData = BalloonLayoutData.createEmpty();
layoutData.fadeoutTime = 5000;
layoutData.fillColor = new JBColor(0XF5E6E7, 0X593D41);
layoutData.borderColor = new JBColor(0XE0A8A9, 0X73454B);
assert myBalloon == null;
myBalloon = NotificationsManagerImpl.createBalloon(myFrame, notification, false, false, new Ref<>(layoutData), project);
Disposer.register(myBalloon, () -> myBalloon = null);
layout.add(myBalloon);
}
use of com.intellij.ui.BalloonLayout in project intellij-plugins by JetBrains.
the class DocumentProblemManager method report.
// Notification.notify is not suitable for us -
// 1) it is not suitable for content with <ul> tags (due to <p> around message, see NotificationsUtil.buildHtml)
// 2) it is buggy - balloon disappeared while user selects message text
// 3) in any case, event log cannot show our message, may be due to <ul> tags?
// todo fix platform Notification impl or how use it correctly?
public void report(@Nullable final Project project, String message, MessageType messageType) {
//Notification notification = new Notification(FlashUIDesignerBundle.message("plugin.name"),
// title == null ? FlashUIDesignerBundle.message("plugin.name") : title, message, NotificationType.ERROR);
//notification.notify(project);
final Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType, BrowserHyperlinkListener.INSTANCE).setShowCallout(false).setHideOnAction(false).createBalloon();
ApplicationManager.getApplication().invokeLater(() -> {
Window window = WindowManager.getInstance().getFrame(project);
if (window == null) {
window = JOptionPane.getRootFrame();
}
if (window instanceof IdeFrame) {
BalloonLayout layout = ((IdeFrame) window).getBalloonLayout();
if (layout != null) {
layout.add(balloon);
}
}
});
}
use of com.intellij.ui.BalloonLayout in project intellij-plugins by JetBrains.
the class DartFeedbackBuilder method showErrorNotification.
private static void showErrorNotification(@NotNull Notification notification, @NotNull Project project) {
// Adapted from IdeMessagePanel.showErrorNotification()
IdeFrame myFrame = WindowManager.getInstance().getIdeFrame(project);
BalloonLayout layout = myFrame.getBalloonLayout();
assert layout != null;
BalloonLayoutData layoutData = BalloonLayoutData.createEmpty();
layoutData.fadeoutTime = 5000;
layoutData.fillColor = new JBColor(0XF5E6E7, 0X593D41);
layoutData.borderColor = new JBColor(0XE0A8A9, 0X73454B);
Balloon balloon = NotificationsManagerImpl.createBalloon(myFrame, notification, false, false, new Ref<>(layoutData), project);
layout.add(balloon);
}
Aggregations