当前位置: 首页>>代码示例>>Java>>正文


Java NotificationListener类代码示例

本文整理汇总了Java中com.intellij.notification.NotificationListener的典型用法代码示例。如果您正苦于以下问题:Java NotificationListener类的具体用法?Java NotificationListener怎么用?Java NotificationListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NotificationListener类属于com.intellij.notification包,在下文中一共展示了NotificationListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: projectOpened

import com.intellij.notification.NotificationListener; //导入依赖的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));
      }
    }));
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:24,代码来源:PyStudyShowTutorial.java

示例2: onThreadBlocked

import com.intellij.notification.NotificationListener; //导入依赖的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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ThreadBlockedMonitor.java

示例3: notifyUser

import com.intellij.notification.NotificationListener; //导入依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ChangeListStorageImpl.java

示例4: UnableToSaveProjectNotification

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
public UnableToSaveProjectNotification(@NotNull final Project project, @NotNull VirtualFile[] readOnlyFiles) {
  super("Project Settings", "Could not save project", "Unable to save project files. Please ensure project files are writable and you have permissions to modify them." +
                                                       " <a href=\"\">Try to save project again</a>.", NotificationType.ERROR, new NotificationListener() {
    @Override
    public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
      final UnableToSaveProjectNotification unableToSaveProjectNotification = (UnableToSaveProjectNotification)notification;
      final Project _project = unableToSaveProjectNotification.myProject;
      notification.expire();

      if (_project != null && !_project.isDisposed()) {
        _project.save();
      }
    }
  });

  myProject = project;
  myFiles = readOnlyFiles;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ProjectManagerImpl.java

示例5: doNotify

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
private static void doNotify(@NotNull final Set<String> macros, @NotNull final Project project,
                             @NotNull final Map<TrackingPathMacroSubstitutor, IComponentStore> substitutorToStore) {
  String format = "<p><i>%s</i> %s undefined. <a href=\"define\">Fix it</a></p>";
  String productName = ApplicationNamesInfo.getInstance().getProductName();
  String content = String.format(format, StringUtil.join(macros, ", "), macros.size() == 1 ? "is" : "are") +
                   "<br>Path variables are used to substitute absolute paths " +
                   "in " + productName + " project files " +
                   "and allow project file sharing in version control systems.<br>" +
                   "Some of the files describing the current project settings contain unknown path variables " +
                   "and " + productName + " cannot restore those paths.";
  new UnknownMacroNotification("Load Error", "Load error: undefined path variables", content, NotificationType.ERROR,
                               new NotificationListener() {
                                 @Override
                                 public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                                   checkUnknownMacros(project, true, macros, substitutorToStore);
                                 }
                               }, macros).notify(project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:StorageUtil.java

示例6: createNotification

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
@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 anonymous usage statistics to " + companyName;

  return new Notification(groupDisplayId, title,
                          text,
                          NotificationType.INFORMATION,
                          listener);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RemotelyConfigurableStatisticsService.java

示例7: checkFsSanity

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
private void checkFsSanity() {
  try {
    String path = myProject.getProjectFilePath();
    if (path == null || FileUtil.isAncestor(PathManager.getConfigPath(), path, true)) {
      return;
    }

    boolean actual = FileUtil.isFileSystemCaseSensitive(path);
    LOG.info(path + " case-sensitivity: " + actual);
    if (actual != SystemInfo.isFileSystemCaseSensitive) {
      int prefix = SystemInfo.isFileSystemCaseSensitive ? 1 : 0;  // IDE=true -> FS=false -> prefix='in'
      String title = ApplicationBundle.message("fs.case.sensitivity.mismatch.title");
      String text = ApplicationBundle.message("fs.case.sensitivity.mismatch.message", prefix);
      Notifications.Bus.notify(
        new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, title, text, NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER),
        myProject);
    }
  }
  catch (FileNotFoundException e) {
    LOG.warn(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:StartupManagerImpl.java

示例8: wrapListener

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
@Nullable
public static HyperlinkListener wrapListener(@NotNull final Notification notification) {
  final NotificationListener listener = notification.getListener();
  if (listener == null) return null;

  return new HyperlinkListener() {
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        final NotificationListener listener1 = notification.getListener();
        if (listener1 != null) {
          listener1.hyperlinkUpdate(notification, e);
        }
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:NotificationsUtil.java

示例9: notifyAboutSyncedBranches

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
private void notifyAboutSyncedBranches() {
  String description =
    "You have several " + myVcs.getDisplayName() + " roots in the project and they all are checked out at the same branch. " +
    "We've enabled synchronous branch control for the project. <br/>" +
    "If you wish to control branches in different roots separately, " +
    "you may <a href='settings'>disable</a> the setting.";
  NotificationListener listener = new NotificationListener() {
    @Override
    public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
      if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        ShowSettingsUtil.getInstance().showSettingsDialog(myProject, myVcs.getConfigurable().getDisplayName());
        if (myVcsSettings.getSyncSetting() == DvcsSyncSettings.Value.DONT_SYNC) {
          notification.expire();
        }
      }
    }
  };
  VcsNotifier.getInstance(myProject).notifyImportantInfo("Synchronous branch control enabled", description, listener);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:DvcsBranchPopup.java

示例10: notifyOnPowerSaveMode

import com.intellij.notification.NotificationListener; //导入依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PowerSaveModeNotifier.java

示例11: createNotification

import com.intellij.notification.NotificationListener; //导入依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AndroidStatisticsService.java

示例12: testCreateNotification

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
public void testCreateNotification() {
  String projectName = "project1";
  String errorMsg = "Hello";

  expect(myProject.getName()).andReturn(projectName);
  replay(myProject);

  NotificationData notification = new NotificationData("title", "msg", NotificationCategory.ERROR, NotificationSource.PROJECT_SYNC);
  AbstractSyncErrorHandler.updateNotification(notification, myProject, errorMsg, myHyperlink1, myHyperlink2);

  verify(myProject);

  String title = notification.getTitle();
  assertNotNull(title);
  assertTrue(title.contains("'" + projectName + "'"));

  assertEquals(errorMsg + "\n<a href=\"1\">Hyperlink 1</a><br><a href=\"2\">Hyperlink 2</a>", notification.getMessage());

  NotificationListener notificationListener = notification.getListener();
  assertNotNull(notificationListener);
  List<String> hyperlinks = notification.getRegisteredListenerIds();
  assertEquals(2, hyperlinks.size());
  assertTrue(hyperlinks.contains(myHyperlink1.getUrl()));
  assertTrue(hyperlinks.contains(myHyperlink2.getUrl()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AbstractSyncErrorHandlerTest.java

示例13: RepositoryNotifier

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
public RepositoryNotifier(CloudGitDeploymentDetector deploymentDetector, GitRepository repository) {
  myDeploymentDetector = deploymentDetector;
  myRepositoryRoot = repository.getRoot();
  myCloudName = deploymentDetector.getCloudType().getPresentableName();
  String path = FileUtil.toSystemDependentName(myRepositoryRoot.getPath());
  myNotification = myNotifier.showMessage(CloudBundle.getText("git.cloud.app.detected", myCloudName, path),
                                          MessageType.INFO,
                                          new NotificationListener() {

                                            @Override
                                            public void hyperlinkUpdate(@NotNull Notification notification,
                                                                        @NotNull HyperlinkEvent event) {
                                              setupRunConfiguration();
                                            }
                                          });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CloudGitRemoteDetector.java

示例14: notifyUnresolvedRemain

import com.intellij.notification.NotificationListener; //导入依赖的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();
          }
        }
      }
    }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GitUnstashDialog.java

示例15: showUnmergedFilesNotification

import com.intellij.notification.NotificationListener; //导入依赖的package包/类
@Override
public void showUnmergedFilesNotification(@NotNull final String operationName, @NotNull final Collection<GitRepository> repositories) {
  String title = unmergedFilesErrorTitle(operationName);
  String description = unmergedFilesErrorNotificationDescription(operationName);
  VcsNotifier.getInstance(myProject).notifyError(title, description,
    new NotificationListener() {
      @Override
      public void hyperlinkUpdate(@NotNull Notification notification,
                                  @NotNull HyperlinkEvent event) {
        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && event.getDescription().equals("resolve")) {
          GitConflictResolver.Params params = new GitConflictResolver.Params().
            setMergeDescription(String.format("The following files have unresolved conflicts. You need to resolve them before %s.",
                                              operationName)).
            setErrorNotificationTitle("Unresolved files remain.");
          new GitConflictResolver(myProject, myGit, myFacade, GitUtil.getRootsFromRepositories(repositories), params).merge();
        }
      }
    }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GitBranchUiHandlerImpl.java


注:本文中的com.intellij.notification.NotificationListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。