本文整理匯總了Java中com.intellij.notification.Notification類的典型用法代碼示例。如果您正苦於以下問題:Java Notification類的具體用法?Java Notification怎麽用?Java Notification使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Notification類屬於com.intellij.notification包,在下文中一共展示了Notification類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initComponent
import com.intellij.notification.Notification; //導入依賴的package包/類
@Override
public void initComponent() {
MessageBus bus = ApplicationManager.getApplication().getMessageBus();
connection = bus.connect();
ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerListener() {
@Override
public void projectOpened(Project project) {
Config config = Config.getInstance(project);
if(config == null) {
return;
}
if(!config.isConfigFilled()) {
Notifications.Bus.notify(
new Notification("Settings Error", "Gherkin TS Runner", "Settings have to be filled.", NotificationType.WARNING)
);
return;
}
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new GherkinFileEditorManagerListener(project));
}
});
}
示例2: showDiscountOffer
import com.intellij.notification.Notification; //導入依賴的package包/類
private void showDiscountOffer(final Project project) {
final PropertiesComponent properties = PropertiesComponent.getInstance();
final long lastNotificationTime = properties.getOrInitLong(LAST_DISCOUNT_OFFER_TIME_PROPERTY, 0);
final long currentTime = System.currentTimeMillis();
if (currentTime - lastNotificationTime >= DateFormatUtil.MONTH) {
properties.setValue(LAST_DISCOUNT_OFFER_TIME_PROPERTY, String.valueOf(currentTime));
final Notification notification = notificationGroup.createNotification(
HybrisI18NBundleUtils.message("evaluation.license.discount.offer.bubble.title"),
HybrisI18NBundleUtils.message("evaluation.license.discount.offer.bubble.text"),
NotificationType.INFORMATION,
(myNotification, myHyperlinkEvent) -> goToDiscountOffer(myHyperlinkEvent)
);
notification.setImportant(true);
Notifications.Bus.notify(notification, project);
ApplicationManager.getApplication().invokeLater(() -> {
if (!notificationClosingAlarm.isDisposed()) {
notificationClosingAlarm.addRequest(notification::hideBalloon, 3000);
}
});
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:26,代碼來源:HybrisProjectManagerListener.java
示例3: projectOpened
import com.intellij.notification.Notification; //導入依賴的package包/類
@Override
public void projectOpened() {
ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> ApplicationManager.getApplication().runWriteAction(
(DumbAwareRunnable)() -> {
if (PropertiesComponent.getInstance().getBoolean(ourShowPopup, true)) {
final String content = "<html>If you'd like to learn more about PyCharm Edu, " +
"click <a href=\"https://www.jetbrains.com/pycharm-edu/quickstart/\">here</a> to watch a tutorial</html>";
final Notification notification = new Notification("Watch Tutorials!", "", content, NotificationType.INFORMATION,
new NotificationListener.UrlOpeningListener(true));
StartupManager.getInstance(myProject).registerPostStartupActivity(() -> Notifications.Bus.notify(notification));
Balloon balloon = notification.getBalloon();
if (balloon != null) {
balloon.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
notification.expire();
}
});
}
notification.whenExpired(() -> PropertiesComponent.getInstance().setValue(ourShowPopup, false, true));
}
}));
}
示例4: createChat
import com.intellij.notification.Notification; //導入依賴的package包/類
private void createChat(MMUserStatus user) throws IOException, URISyntaxException {
Channel.ChannelData channel = client.createChat(user.userId());
if (channel == null) {
Notifications.Bus.notify(new Notification("mattermost", "channel error", "no channel found for " + user.username(), NotificationType.ERROR));
return;
}
SwingUtilities.invokeLater(() -> {
String name = user.username();
Chat chat = this.channelIdChatMap.computeIfAbsent(channel.getId(), k -> new Chat());
chat.channelId = channel.getId();
if (this.toolWindow.getContentManager().getContent(chat) == null) {
Content messages = ContentFactory.SERVICE.getInstance().createContent(chat, name, false);
messages.setIcon(TEAM);
this.toolWindow.getContentManager().addContent(messages);
this.toolWindow.getContentManager().setSelectedContent(messages);
} else {
Content c = this.toolWindow.getContentManager().getContent(chat);
this.toolWindow.getContentManager().setSelectedContent(c);
}
SwingUtilities.invokeLater(chat.inputArea::grabFocus);
});
}
示例5: addToolsJar
import com.intellij.notification.Notification; //導入依賴的package包/類
static void addToolsJar( @NotNull ModifiableRootModel rootModel )
{
if( hasToolsJar( rootModel ) )
{
return;
}
VirtualFile toolsJarFile = findToolsJarFile( rootModel.getProject() );
if( toolsJarFile == null )
{
Notifications.Bus.notify( new Notification( "Project JDK", "tools.jar not found!", "Please add tools.jar to your JDK", NotificationType.ERROR ) );
return;
}
SdkModificator sdkModificator = rootModel.getSdk().getSdkModificator();
sdkModificator.addRoot( toolsJarFile, OrderRootType.CLASSES );
sdkModificator.commitChanges();
}
示例6: notifyEnableMessage
import com.intellij.notification.Notification; //導入依賴的package包/類
public static void notifyEnableMessage(@NotNull final Project project) {
Notification notification = new Notification("Grav Plugin", "Grav Plugin",
"<a href=\"enable\">Enable</a> the Grav Plugin now, or open <a href=\"config\">Project Settings</a>. <br/>" +
"<a href=\"dismiss\">Do not</a> ask again.", NotificationType.INFORMATION, (notification1, event) -> {
// handle html click events
if ("config".equals(event.getDescription())) {
// open settings dialog and show panel
GravProjectConfigurable.show(project);
} else if ("enable".equals(event.getDescription())) {
enablePluginAndConfigure(project);
Notifications.Bus.notify(new Notification("Grav Plugin", "Grav Plugin", "Plugin enabled", NotificationType.INFORMATION), project);
} else if ("dismiss".equals(event.getDescription())) {
// user dont want to show notification again
GravProjectSettings.getInstance(project).dismissEnableNotification = true;
}
notification1.expire();
});
Notifications.Bus.notify(notification, project);
}
示例7: showNotification
import com.intellij.notification.Notification; //導入依賴的package包/類
private static void showNotification(@NotNull DiffViewerBase viewer, @NotNull Notification notification) {
JComponent component = viewer.getComponent();
Window window = UIUtil.getWindow(component);
if (window instanceof IdeFrame && NotificationsManagerImpl.findWindowForBalloon(viewer.getProject()) == window) {
notification.notify(viewer.getProject());
return;
}
Balloon balloon = NotificationsManagerImpl.createBalloon(component, notification, false, true);
Disposer.register(viewer, balloon);
Dimension componentSize = component.getSize();
Dimension balloonSize = balloon.getPreferredSize();
int width = Math.min(balloonSize.width, componentSize.width);
int height = Math.min(balloonSize.height, componentSize.height);
// top-right corner, 20px to the edges
RelativePoint point = new RelativePoint(component, new Point(componentSize.width - 20 - width / 2, 20 + height / 2));
balloon.show(point, Balloon.Position.above);
}
示例8: validateLocale
import com.intellij.notification.Notification; //導入依賴的package包/類
@Nullable
private Notification validateLocale() throws SvnBindException {
ProcessOutput versionOutput = getVersionClient().runCommand(false);
Notification result = null;
Matcher matcher = INVALID_LOCALE_WARNING_PATTERN.matcher(versionOutput.getStderr());
if (matcher.find()) {
LOG.info(matcher.group());
result = new ExecutableNotValidNotification(prepareDescription(UIUtil.getHtmlBody(matcher.group()), false), NotificationType.WARNING);
}
else if (!isEnglishOutput(versionOutput.getStdout())) {
LOG.info("\"svn --version\" command contains non-English output " + versionOutput.getStdout());
result = new ExecutableNotValidNotification(prepareDescription(SvnBundle.message("non.english.locale.detected.warning"), false),
NotificationType.WARNING);
}
return result;
}
示例9: notifyOnPowerSaveMode
import com.intellij.notification.Notification; //導入依賴的package包/類
static void notifyOnPowerSaveMode(Project project) {
if (PropertiesComponent.getInstance().getBoolean(IGNORE_POWER_SAVE_MODE)) {
return;
}
String message = "Code insight and other background tasks are disabled." +
"<br/><a href=\"ignore\">Do not show again</a>" +
"<br/><a href=\"turnOff\">Disable Power Save Mode</a>";
POWER_SAVE_MODE.createNotification("Power save mode is on", message, NotificationType.WARNING, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
final String description = event.getDescription();
if ("ignore".equals(description)) {
PropertiesComponent.getInstance().setValue(IGNORE_POWER_SAVE_MODE, true);
notification.expire();
}
else if ("turnOff".equals(description)) {
PowerSaveMode.setEnabled(false);
notification.expire();
}
}
}).notify(project);
}
示例10: createNotification
import com.intellij.notification.Notification; //導入依賴的package包/類
@NonNull
@Override
public Notification createNotification(@NotNull final String groupDisplayId,
@Nullable NotificationListener listener) {
final String fullProductName = ApplicationNamesInfo.getInstance().getFullProductName();
final String companyName = ApplicationInfo.getInstance().getCompanyName();
String text =
"<html>Please click <a href='allow'>I agree</a> if you want to help make " + fullProductName +
" better or <a href='decline'>I don't agree</a> otherwise. <a href='settings'>more...</a></html>";
String title = "Help improve " + fullProductName + " by sending usage statistics to " + companyName;
return new Notification(groupDisplayId, title,
text,
NotificationType.INFORMATION,
listener);
}
示例11: hyperlinkActivated
import com.intellij.notification.Notification; //導入依賴的package包/類
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getDescription().equals("configure") && !myProject.isDisposed()) {
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, ActionsBundle.message("group.VcsGroup.text"));
Collection<VcsRootError> errorsAfterPossibleFix = getInstance(myProject).scan();
if (errorsAfterPossibleFix.isEmpty() && !notification.isExpired()) {
notification.expire();
}
}
else if (event.getDescription().equals("ignore")) {
mySettings.addIgnoredUnregisteredRoots(ContainerUtil.map(myImportantUnregisteredRoots, PATH_FROM_ROOT_ERROR));
notification.expire();
}
else if (event.getDescription().equals("add")) {
List<VcsDirectoryMapping> mappings = myVcsManager.getDirectoryMappings();
for (VcsRootError root : myImportantUnregisteredRoots) {
mappings = VcsUtil.addMapping(mappings, root.getMapping(), root.getVcsKey().getName());
}
myVcsManager.setDirectoryMappings(mappings);
}
}
示例12: onThreadBlocked
import com.intellij.notification.Notification; //導入依賴的package包/類
private void onThreadBlocked(@NotNull final ThreadReference blockedThread,
@NotNull final ThreadReference blockingThread,
final DebugProcessImpl process) {
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(
DebuggerBundle.message("status.thread.blocked.by", blockedThread.name(), blockingThread.name()),
DebuggerBundle.message("status.thread.blocked.by.resume", blockingThread.name()),
NotificationType.INFORMATION, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
notification.expire();
process.getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
ThreadReferenceProxyImpl threadProxy = process.getVirtualMachineProxy().getThreadReferenceProxy(blockingThread);
SuspendContextImpl suspendingContext = SuspendManagerUtil.getSuspendingContext(process.getSuspendManager(), threadProxy);
process.getManagerThread()
.invoke(process.createResumeThreadCommand(suspendingContext, threadProxy));
}
});
}
}
}).notify(process.getProject());
}
示例13: validate
import com.intellij.notification.Notification; //導入依賴的package包/類
@Override
@Nullable
protected Notification validate(@NotNull String executable) {
Notification result = createDefaultNotification();
// Necessary executable path will be taken from settings while command execution
final Version version = getConfiguredClientVersion();
if (version != null) {
try {
result = validateVersion(version);
if (result == null) {
result = validateLocale();
}
}
catch (Throwable e) {
LOG.info(e);
}
}
return result;
}
示例14: notifyUnresolvedRemain
import com.intellij.notification.Notification; //導入依賴的package包/類
@Override
protected void notifyUnresolvedRemain() {
VcsNotifier.getInstance(myProject).notifyImportantWarning("Conflicts were not resolved during unstash",
"Unstash is not complete, you have unresolved merges in your working tree<br/>" +
"<a href='resolve'>Resolve</a> conflicts.", new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (event.getDescription().equals("resolve")) {
new UnstashConflictResolver(myProject, myRoot, myStashInfo).mergeNoProceed();
}
}
}
}
);
}
示例15: notifyUser
import com.intellij.notification.Notification; //導入依賴的package包/類
public static void notifyUser(String message) {
final String logFile = PathManager.getLogPath();
/*String createIssuePart = "<br>" +
"<br>" +
"Please attach log files from <a href=\"file\">" + logFile + "</a><br>" +
"to the <a href=\"url\">YouTrack issue</a>";*/
Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
"Local History is broken",
message /*+ createIssuePart*/,
NotificationType.ERROR,
new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification,
@NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if ("url".equals(event.getDescription())) {
BrowserUtil.browse("http://youtrack.jetbrains.net/issue/IDEA-71270");
}
else {
File file = new File(logFile);
ShowFilePathAction.openFile(file);
}
}
}
}), null);
}