List of usage examples for com.intellij.openapi.application ApplicationBundle message
@NotNull
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key,
Object @NotNull... params)
From source file:com.intellij.ide.actions.CreateDesktopEntryAction.java
License:Apache License
private static File prepare() throws IOException { final String homePath = PathManager.getHomePath(); assert homePath != null && new File(homePath).isDirectory() : "Invalid home path: '" + homePath + "'"; final String binPath = homePath + "/bin"; assert new File(binPath).isDirectory() : "Invalid bin/ path: '" + binPath + "'"; String name = ApplicationNamesInfo.getInstance().getFullProductName(); final String iconPath = AppUIUtil.findIcon(binPath); if (iconPath == null) { throw new RuntimeException(ApplicationBundle.message("desktop.entry.icon.missing", binPath)); }/*from ww w . j av a 2s .co m*/ final String execPath = findScript(binPath); if (execPath == null) { throw new RuntimeException(ApplicationBundle.message("desktop.entry.script.missing", binPath)); } final String wmClass = AppUIUtil.getFrameClass(); final String content = ExecUtil.loadTemplate(CreateDesktopEntryAction.class.getClassLoader(), "entry.desktop", newHashMap(asList("$NAME$", "$SCRIPT$", "$ICON$", "$WM_CLASS$"), asList(name, execPath, iconPath, wmClass))); final String entryName = wmClass + ".desktop"; final File entryFile = new File(FileUtil.getTempDirectory(), entryName); FileUtil.writeToFile(entryFile, content); entryFile.deleteOnExit(); return entryFile; }
From source file:com.intellij.ide.actions.CreateLauncherScriptAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { if (!isAvailable()) return;// w w w . j a v a 2 s .c o m Project project = e.getProject(); CreateLauncherScriptDialog dialog = new CreateLauncherScriptDialog(project); dialog.show(); if (!dialog.isOK()) { return; } String path = dialog.myPathField.getText(); if (!path.startsWith("/")) { final String home = System.getenv("HOME"); if (home != null && new File(home).isDirectory()) { if (path.startsWith("~")) { path = home + path.substring(1); } else { path = home + "/" + path; } } } final File target = new File(path, dialog.myNameField.getText()); if (target.exists()) { int rc = Messages.showOkCancelDialog(project, ApplicationBundle.message("launcher.script.overwrite", target), "Create Launcher Script", Messages.getQuestionIcon()); if (rc != 0) { return; } } createLauncherScript(project, target.getAbsolutePath()); }
From source file:com.intellij.ide.actions.CreateLauncherScriptAction.java
License:Apache License
public static void createLauncherScript(Project project, String pathName) { if (!isAvailable()) return;/*from www . ja va 2 s. c om*/ try { final File scriptFile = createLauncherScriptFile(); final File scriptTarget = new File(pathName); final File launcherScriptContainingDir = scriptTarget.getParentFile(); if (!(launcherScriptContainingDir.exists() || launcherScriptContainingDir.mkdirs()) || !scriptFile.renameTo(scriptTarget)) { final String launcherScriptContainingDirPath = launcherScriptContainingDir.getCanonicalPath(); final String installationScriptSrc = "#!/bin/sh\n" + // create all intermediate folders "mkdir -p \"" + launcherScriptContainingDirPath + "\"\n" + // copy file and change ownership to root (UID 0 = root, GID 0 = root (wheel on Macs)) "install -g 0 -o 0 \"" + scriptFile.getCanonicalPath() + "\" \"" + pathName + "\""; final File installationScript = ExecUtil.createTempExecutableScript("launcher_installer", ".sh", installationScriptSrc); final String prompt = ApplicationBundle.message("launcher.script.sudo.prompt", launcherScriptContainingDirPath); ExecUtil.sudoAndGetOutput(asList(installationScript.getPath()), prompt, null); } } catch (Exception e) { final String message = e.getMessage(); if (!StringUtil.isEmptyOrSpaces(message)) { LOG.warn(e); Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Failed to create launcher script", message, NotificationType.ERROR), project); } else { LOG.error(e); } } }