use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class HgRemoteChangesetsCommand method executeCommandInCurrentThread.
@Override
protected HgCommandResult executeCommandInCurrentThread(VirtualFile repo, List<String> args) {
String repositoryURL = getRepositoryUrl(repo);
if (repositoryURL == null) {
LOG.info("executeCommand no default path configured");
return null;
}
HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(project, repositoryURL);
HgCommandResult result = executor.executeInCurrentThread(repo, command, args);
if (result == HgCommandResult.CANCELLED || HgErrorUtil.isAuthorizationError(result)) {
final HgVcs vcs = HgVcs.getInstance(project);
if (vcs == null) {
return result;
}
new HgCommandResultNotifier(project).notifyError(result, "Checking for incoming/outgoing changes disabled", "Authentication is required to check incoming/outgoing changes in " + repositoryURL + "<br/>You may enable checking for changes <a href='#'>in the Settings</a>.", new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, vcs.getConfigurable().getDisplayName());
}
});
final HgProjectSettings projectSettings = vcs.getProjectSettings();
projectSettings.setCheckIncomingOutgoing(false);
project.getMessageBus().syncPublisher(HgVcs.INCOMING_OUTGOING_CHECK_TOPIC).hide();
}
return result;
}
use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class MavenServerManager method createRunProfileState.
private RunProfileState createRunProfileState() {
return new CommandLineState(null) {
private SimpleJavaParameters createJavaParameters() {
final SimpleJavaParameters params = new SimpleJavaParameters();
final Sdk jdk = getJdk();
params.setJdk(jdk);
params.setWorkingDirectory(PathManager.getBinPath());
params.setMainClass(MAIN_CLASS);
Map<String, String> defs = new THashMap<>();
defs.putAll(MavenUtil.getPropertiesFromMavenOpts());
// pass ssl-related options
for (Map.Entry<Object, Object> each : System.getProperties().entrySet()) {
Object key = each.getKey();
Object value = each.getValue();
if (key instanceof String && value instanceof String && ((String) key).startsWith("javax.net.ssl")) {
defs.put((String) key, (String) value);
}
}
if (SystemInfo.isMac) {
String arch = System.getProperty("sun.arch.data.model");
if (arch != null) {
params.getVMParametersList().addParametersString("-d" + arch);
}
}
defs.put("java.awt.headless", "true");
for (Map.Entry<String, String> each : defs.entrySet()) {
params.getVMParametersList().defineProperty(each.getKey(), each.getValue());
}
params.getVMParametersList().addProperty("idea.version=", MavenUtil.getIdeaVersionToPassToMavenProcess());
boolean xmxSet = false;
boolean forceMaven2 = false;
if (myState.vmOptions != null) {
ParametersList mavenOptsList = new ParametersList();
mavenOptsList.addParametersString(myState.vmOptions);
for (String param : mavenOptsList.getParameters()) {
if (param.startsWith("-Xmx")) {
xmxSet = true;
}
if (param.equals(FORCE_MAVEN2_OPTION)) {
forceMaven2 = true;
}
params.getVMParametersList().add(param);
}
}
final File mavenHome;
final String mavenVersion;
final File currentMavenHomeFile = forceMaven2 ? BundledMavenPathHolder.myBundledMaven2Home : getCurrentMavenHomeFile();
if (currentMavenHomeFile == null) {
mavenHome = BundledMavenPathHolder.myBundledMaven3Home;
mavenVersion = getMavenVersion(mavenHome);
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
final Project project = openProjects.length == 1 ? openProjects[0] : null;
if (project != null) {
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message("external.maven.home.invalid.substitution.warning.with.fix", myState.mavenHome, mavenVersion), NotificationType.WARNING, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
}
}).notify(null);
} else {
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message("external.maven.home.invalid.substitution.warning", myState.mavenHome, mavenVersion), NotificationType.WARNING).notify(null);
}
} else {
mavenHome = currentMavenHomeFile;
mavenVersion = getMavenVersion(mavenHome);
}
assert mavenVersion != null;
params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_VERSION, mavenVersion);
String sdkConfigLocation = "Settings | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for Importer";
verifyMavenSdkRequirements(jdk, mavenVersion, sdkConfigLocation);
final List<String> classPath = new ArrayList<>();
classPath.add(PathUtil.getJarPathForClass(org.apache.log4j.Logger.class));
if (StringUtil.compareVersionNumbers(mavenVersion, "3.1") < 0) {
classPath.add(PathUtil.getJarPathForClass(Logger.class));
classPath.add(PathUtil.getJarPathForClass(Log4jLoggerFactory.class));
}
classPath.addAll(PathManager.getUtilClassPath());
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(Query.class));
params.getClassPath().add(PathManager.getResourceRoot(getClass(), "/messages/CommonBundle.properties"));
params.getClassPath().addAll(classPath);
params.getClassPath().addAllFiles(collectClassPathAndLibsFolder(mavenVersion, mavenHome));
String embedderXmx = System.getProperty("idea.maven.embedder.xmx");
if (embedderXmx != null) {
params.getVMParametersList().add("-Xmx" + embedderXmx);
} else {
if (!xmxSet) {
params.getVMParametersList().add("-Xmx768m");
}
}
String mavenEmbedderDebugPort = System.getProperty("idea.maven.embedder.debug.port");
if (mavenEmbedderDebugPort != null) {
params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + mavenEmbedderDebugPort);
}
String mavenEmbedderParameters = System.getProperty("idea.maven.embedder.parameters");
if (mavenEmbedderParameters != null) {
params.getProgramParametersList().addParametersString(mavenEmbedderParameters);
}
String mavenEmbedderCliOptions = System.getProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS);
if (mavenEmbedderCliOptions != null) {
params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS, mavenEmbedderCliOptions);
}
return params;
}
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
ProcessHandler processHandler = startProcess();
return new DefaultExecutionResult(processHandler);
}
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
SimpleJavaParameters params = createJavaParameters();
GeneralCommandLine commandLine = params.toCommandLine();
OSProcessHandler processHandler = new OSProcessHandler(commandLine);
processHandler.setShouldDestroyProcessRecursively(false);
return processHandler;
}
};
}
use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class HotSwapProgressImpl method notifyUser.
private void notifyUser(String title, String message, NotificationType type) {
NotificationListener notificationListener = null;
if (SoftReference.dereference(mySessionRef) != null) {
notificationListener = (notification, event) -> {
if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
return;
}
XDebugSession session = SoftReference.dereference(mySessionRef);
if (session == null) {
return;
}
notification.expire();
switch(event.getDescription()) {
case "stop":
session.stop();
break;
case "restart":
ExecutionEnvironment environment = ((XDebugSessionImpl) session).getExecutionEnvironment();
if (environment != null) {
ExecutionUtil.restart(environment);
}
break;
}
};
}
NOTIFICATION_GROUP.createNotification(title, message, type, notificationListener).setImportant(false).notify(getProject());
}
use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class FrameworkDetectionManager method doRunDetection.
private void doRunDetection() {
Set<Integer> detectorsToProcess;
synchronized (myLock) {
detectorsToProcess = new HashSet<>(myDetectorsToProcess);
detectorsToProcess.addAll(myDetectorsToProcess);
myDetectorsToProcess.clear();
}
if (detectorsToProcess.isEmpty())
return;
if (LOG.isDebugEnabled()) {
LOG.debug("Starting framework detectors: " + detectorsToProcess);
}
final FileBasedIndex index = FileBasedIndex.getInstance();
List<DetectedFrameworkDescription> newDescriptions = new ArrayList<>();
List<DetectedFrameworkDescription> oldDescriptions = new ArrayList<>();
final DetectionExcludesConfiguration excludesConfiguration = DetectionExcludesConfiguration.getInstance(myProject);
for (Integer id : detectorsToProcess) {
final List<? extends DetectedFrameworkDescription> frameworks = runDetector(id, index, excludesConfiguration, true);
oldDescriptions.addAll(frameworks);
final Collection<? extends DetectedFrameworkDescription> updated = myDetectedFrameworksData.updateFrameworksList(id, frameworks);
newDescriptions.addAll(updated);
oldDescriptions.removeAll(updated);
if (LOG.isDebugEnabled()) {
LOG.debug(frameworks.size() + " frameworks detected, " + updated.size() + " changed");
}
}
Set<String> frameworkNames = new HashSet<>();
for (final DetectedFrameworkDescription description : FrameworkDetectionUtil.removeDisabled(newDescriptions, oldDescriptions)) {
frameworkNames.add(description.getDetector().getFrameworkType().getPresentableName());
}
if (!frameworkNames.isEmpty()) {
String names = StringUtil.join(frameworkNames, ", ");
final String text = ProjectBundle.message("framework.detected.info.text", names, frameworkNames.size());
FRAMEWORK_DETECTION_NOTIFICATION.createNotification("Frameworks detected", text, NotificationType.INFORMATION, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
showSetupFrameworksDialog(notification);
}
}
}).notify(myProject);
}
}
use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class ChangeListStorageImpl method notifyUser.
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);
}
Aggregations