private static void startLogging(final Logger log) { Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") { @Override public void run() { log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); } }); log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------"); ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance(); ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance(); String buildDate = new SimpleDateFormat("dd MMM yyyy HH:ss", Locale.US).format(appInfo.getBuildDate().getTime()); log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild().asStringWithAllDetails() + ", " + buildDate + ")"); log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ", " + SystemInfo.OS_ARCH + ")"); log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")"); log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.name", "-") + ")"); List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); if (arguments != null) { log.info("JVM Args: " + StringUtil.join(arguments, " ")); } }
@Override protected void setUp() throws Exception { super.setUp(); myNestedFormLoader = new MyNestedFormLoader(); final String swingPath = PathUtil.getJarPathForClass(AbstractButton.class); java.util.List<URL> cp = new ArrayList<URL>(); appendPath(cp, JBTabbedPane.class); appendPath(cp, TIntObjectHashMap.class); appendPath(cp, UIUtil.class); appendPath(cp, SystemInfoRt.class); appendPath(cp, ApplicationManager.class); appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/messages/UIBundle.properties")); appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/RuntimeBundle.properties")); appendPath(cp, GridLayoutManager.class); // forms_rt appendPath(cp, DataProvider.class); myClassFinder = new MyClassFinder( new URL[] {new File(swingPath).toURI().toURL()}, cp.toArray(new URL[cp.size()]) ); }
private static void startLogging(final Logger log) { Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") { public void run() { log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); } }); log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------"); ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance(); ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance(); log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild() + ", " + DateFormatUtilRt.formatBuildDate(appInfo.getBuildDate()) + ")"); log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ")"); log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")"); log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.vendor", "-") + ")"); List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); if (arguments != null) { log.info("JVM Args: " + StringUtil.join(arguments, " ")); } }
@Override protected void setUp() throws Exception { super.setUp(); myNestedFormLoader = new MyNestedFormLoader(); final String swingPath = PathUtil.getJarPathForClass(AbstractButton.class); java.util.List<URL> cp = new ArrayList<URL>(); appendPath(cp, JBTabbedPane.class); appendPath(cp, TIntObjectHashMap.class); appendPath(cp, UIUtil.class); appendPath(cp, SystemInfoRt.class); appendPath(cp, ApplicationManager.class); appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/messages/UIBundle.properties")); appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/RuntimeBundle.properties")); appendPath(cp, GridLayoutManager.class); // forms_rt myClassFinder = new MyClassFinder( new URL[] {new File(swingPath).toURI().toURL()}, cp.toArray(new URL[cp.size()]) ); }
@NotNull public static String fixURLforIDEA(@NotNull String url ) { int idx = url.indexOf(":/"); if( idx >= 0 && idx+2 < url.length() && url.charAt(idx+2) != '/' ) { String prefix = url.substring(0, idx); String suffix = url.substring(idx+2); if (SystemInfoRt.isWindows) { url = prefix+"://"+suffix; } else { url = prefix+":///"+suffix; } } return url; }
public static boolean extensionEquals(@NotNull String filePath, @NotNull String extension) { int extLen = extension.length(); if (extLen == 0) { int lastSlash = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\')); return filePath.indexOf('.', lastSlash+1) == -1; } int extStart = filePath.length() - extLen; return extStart >= 1 && filePath.charAt(extStart-1) == '.' && filePath.regionMatches(!SystemInfoRt.isFileSystemCaseSensitive, extStart, extension, 0, extLen); }
@NotNull private static String calcCanonicalTempPath() { final File file = new File(System.getProperty("java.io.tmpdir")); try { final String canonical = file.getCanonicalPath(); if (!SystemInfoRt.isWindows || !canonical.contains(" ")) { return canonical; } } catch (IOException ignore) { } return file.getAbsolutePath(); }
public static boolean isProjectOrWorkspaceFile(@NotNull VirtualFile file, @Nullable final FileType fileType) { if (fileType instanceof InternalFileType) return true; VirtualFile parent = file.isDirectory() ? file: file.getParent(); while (parent != null) { if (Comparing.equal(parent.getNameSequence(), DIRECTORY_BASED_PROJECT_DIR, SystemInfoRt.isFileSystemCaseSensitive)) return true; parent = parent.getParent(); } return false; }
@NotNull public static String toIdeaUrl(@NotNull String url, boolean removeLocalhostPrefix) { int index = url.indexOf(":/"); if (index < 0 || (index + 2) >= url.length()) { return url; } if (url.charAt(index + 2) != '/') { String prefix = url.substring(0, index); String suffix = url.substring(index + 2); if (SystemInfoRt.isWindows) { return prefix + URLUtil.SCHEME_SEPARATOR + suffix; } else if (removeLocalhostPrefix && prefix.equals(URLUtil.FILE_PROTOCOL) && suffix.startsWith(LOCALHOST_URI_PATH_PREFIX)) { // sometimes (e.g. in Google Chrome for Mac) local file url is prefixed with 'localhost' so we need to remove it return prefix + ":///" + suffix.substring(LOCALHOST_URI_PATH_PREFIX.length()); } else { return prefix + ":///" + suffix; } } else if (SystemInfoRt.isWindows && (index + 3) < url.length() && url.charAt(index + 3) == '/' && url.regionMatches(0, StandardFileSystems.FILE_PROTOCOL_PREFIX, 0, StandardFileSystems.FILE_PROTOCOL_PREFIX.length())) { // file:///C:/test/file.js -> file://C:/test/file.js for (int i = index + 4; i < url.length(); i++) { char c = url.charAt(i); if (c == '/') { break; } else if (c == ':') { return StandardFileSystems.FILE_PROTOCOL_PREFIX + url.substring(index + 4); } } return url; } return url; }
@Override public void update(AnActionEvent e) { ProjectSystemId externalSystemId = ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID.getData(e.getDataContext()); if (externalSystemId != null) { String name = externalSystemId.getReadableName(); e.getPresentation().setText(ExternalSystemBundle.message("action.attach.external.project.text", name)); e.getPresentation().setDescription(ExternalSystemBundle.message("action.attach.external.project.description", name)); } e.getPresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add); }
public static boolean equalsIgnoreParameters(@NotNull Url url, @NotNull VirtualFile file) { if (file.isInLocalFileSystem()) { return url.isInLocalFileSystem() && (SystemInfoRt.isFileSystemCaseSensitive ? url.getPath().equals(file.getPath()) : url.getPath().equalsIgnoreCase(file.getPath())); } else if (url.isInLocalFileSystem()) { return false; } Url fileUrl = parseUrl(file.getUrl()); return fileUrl != null && fileUrl.equalsIgnoreParameters(url); }
@NotNull public static URI toUriWithoutParameters(@NotNull Url url) { try { String externalPath = url.getPath(); boolean inLocalFileSystem = url.isInLocalFileSystem(); if (inLocalFileSystem && SystemInfoRt.isWindows && externalPath.charAt(0) != '/') { externalPath = '/' + externalPath; } return new URI(inLocalFileSystem ? "file" : url.getScheme(), inLocalFileSystem ? "" : url.getAuthority(), externalPath, null, null); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
private static String getBundledJava(String javaHome) throws Exception { String javaHomeCopy = System.getProperty("user.home") + "/." + System.getProperty("idea.paths.selector") + "/restart/jre"; File javaCopy = SystemInfoRt.isWindows ? new File(javaHomeCopy + "/bin/java.exe") : new File(javaHomeCopy + "/bin/java"); if (javaCopy != null && javaCopy.isFile() && checkBundledJava(javaCopy)) { javaHome = javaHomeCopy; } if (javaHome != javaHomeCopy) { File javaHomeCopyDir = new File(javaHomeCopy); if (javaHomeCopyDir.exists()) FileUtil.delete(javaHomeCopyDir); System.out.println("Updater: java: " + javaHome + " copied to " + javaHomeCopy); FileUtil.copyDir(new File(javaHome), javaHomeCopyDir); javaHome = javaHomeCopy; } return javaHome; }
public static boolean extensionEquals(@NotNull String fileName, @NotNull String extension) { int extLen = extension.length(); if (extLen == 0) { return fileName.indexOf('.') == -1; } int extStart = fileName.length() - extLen; return extStart >= 1 && fileName.charAt(extStart-1) == '.' && fileName.regionMatches(!SystemInfoRt.isFileSystemCaseSensitive, extStart, extension, 0, extLen); }
private static String calcCanonicalTempPath() { final File file = new File(System.getProperty("java.io.tmpdir")); try { final String canonical = file.getCanonicalPath(); if (!SystemInfoRt.isWindows || !canonical.contains(" ")) { return canonical; } } catch (IOException ignore) { } return file.getAbsolutePath(); }
@NotNull public static String toIdeaUrl(@NotNull String url, boolean removeLocalhostPrefix) { int index = url.indexOf(":/"); if (index < 0 || (index + 2) >= url.length()) { return url; } if (url.charAt(index + 2) != '/') { String prefix = url.substring(0, index); String suffix = url.substring(index + 2); if (SystemInfoRt.isWindows) { return prefix + "://" + suffix; } else if (removeLocalhostPrefix && prefix.equals(StandardFileSystems.FILE_PROTOCOL) && suffix.startsWith(LOCALHOST_URI_PATH_PREFIX)) { // sometimes (e.g. in Google Chrome for Mac) local file url is prefixed with 'localhost' so we need to remove it return prefix + ":///" + suffix.substring(LOCALHOST_URI_PATH_PREFIX.length()); } else { return prefix + ":///" + suffix; } } else if (url.charAt(index + 3) == '/' && SystemInfoRt.isWindows && url.regionMatches(0, StandardFileSystems.FILE_PROTOCOL_PREFIX, 0, StandardFileSystems.FILE_PROTOCOL_PREFIX.length())) { // file:///C:/test/file.js -> file://C:/test/file.js for (int i = index + 4; i < url.length(); i++) { char c = url.charAt(i); if (c == '/') { break; } else if (c == ':') { return StandardFileSystems.FILE_PROTOCOL_PREFIX + url.substring(index + 4); } } return url; } return url; }
@NotNull public static Collection<String> getUtilClassPath() { final List<Class<?>> classes = Arrays.asList( PathManager.class, // module 'util' NotNull.class, // module 'annotations' SystemInfoRt.class, // module 'util-rt' Document.class, // jDOM Appender.class, // log4j THashSet.class, // trove4j PicoContainer.class, // PicoContainer TypeMapper.class, // JNA FileUtils.class, // JNA (jna-utils) PatternMatcher.class // OROMatcher ); final Set<String> classPath = new HashSet<String>(); for (Class<?> aClass : classes) { final String path = getJarPathForClass(aClass); if (path != null) { classPath.add(path); } } final String resourceRoot = getResourceRoot(PathManager.class, "/messages/CommonBundle.properties"); // platform-resources-en if (resourceRoot != null) { classPath.add(new File(resourceRoot).getAbsolutePath()); } return Collections.unmodifiableCollection(classPath); }
public static boolean extensionEquals(@Nonnull String filePath, @Nonnull String extension) { int extLen = extension.length(); if (extLen == 0) { int lastSlash = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\')); return filePath.indexOf('.', lastSlash + 1) == -1; } int extStart = filePath.length() - extLen; return extStart >= 1 && filePath.charAt(extStart - 1) == '.' && filePath.regionMatches(!SystemInfoRt.isFileSystemCaseSensitive, extStart, extension, 0, extLen); }
@Nonnull private static String calcCanonicalTempPath() { final File file = new File(System.getProperty("java.io.tmpdir")); try { final String canonical = file.getCanonicalPath(); if (!SystemInfoRt.isWindows || !canonical.contains(" ")) { return canonical; } } catch (IOException ignore) { } return file.getAbsolutePath(); }
private static Charset fsCharset() { if (!SystemInfoRt.isWindows && !SystemInfoRt.isMac) { String property = System.getProperty("sun.jnu.encoding"); if (property != null) { try { return Charset.forName(property); } catch (Exception e) { LoggerRt.getInstance(PathUtilRt.class).warn("unknown JNU charset: " + property, e); } } } return null; }
public static boolean isProjectOrWorkspaceFile(@Nonnull VirtualFile file, @Nullable FileType fileType) { VirtualFile parent = file.isDirectory() ? file : file.getParent(); while (parent != null) { if (Comparing.equal(parent.getNameSequence(), Project.DIRECTORY_STORE_FOLDER, SystemInfoRt.isFileSystemCaseSensitive)) return true; parent = parent.getParent(); } return false; }
@Nonnull public static String toIdeaUrl(@Nonnull String url, boolean removeLocalhostPrefix) { int index = url.indexOf(":/"); if (index < 0 || (index + 2) >= url.length()) { return url; } if (url.charAt(index + 2) != '/') { String prefix = url.substring(0, index); String suffix = url.substring(index + 2); if (SystemInfoRt.isWindows) { return prefix + URLUtil.SCHEME_SEPARATOR + suffix; } else if (removeLocalhostPrefix && prefix.equals(URLUtil.FILE_PROTOCOL) && suffix.startsWith(LOCALHOST_URI_PATH_PREFIX)) { // sometimes (e.g. in Google Chrome for Mac) local file url is prefixed with 'localhost' so we need to remove it return prefix + ":///" + suffix.substring(LOCALHOST_URI_PATH_PREFIX.length()); } else { return prefix + ":///" + suffix; } } else if (SystemInfoRt.isWindows && (index + 3) < url.length() && url.charAt(index + 3) == '/' && url.regionMatches(0, StandardFileSystems.FILE_PROTOCOL_PREFIX, 0, StandardFileSystems.FILE_PROTOCOL_PREFIX.length())) { // file:///C:/test/file.js -> file://C:/test/file.js for (int i = index + 4; i < url.length(); i++) { char c = url.charAt(i); if (c == '/') { break; } else if (c == ':') { return StandardFileSystems.FILE_PROTOCOL_PREFIX + url.substring(index + 4); } } return url; } return url; }
@RequiredDispatchThread @Override public void update(@Nonnull AnActionEvent e) { ProjectSystemId externalSystemId = e.getDataContext().getData(ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID); if (externalSystemId != null) { String name = externalSystemId.getReadableName(); e.getPresentation().setText(ExternalSystemBundle.message("action.attach.external.project.text", name)); e.getPresentation().setDescription(ExternalSystemBundle.message("action.attach.external.project.description", name)); } e.getPresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add); }
public static boolean equalsIgnoreParameters(@Nonnull Url url, @Nonnull VirtualFile file) { if (file.isInLocalFileSystem()) { return url.isInLocalFileSystem() && (SystemInfoRt.isFileSystemCaseSensitive ? url.getPath().equals(file.getPath()) : url.getPath().equalsIgnoreCase(file.getPath())); } else if (url.isInLocalFileSystem()) { return false; } Url fileUrl = parseUrl(file.getUrl()); return fileUrl != null && fileUrl.equalsIgnoreParameters(url); }
@Nonnull public static URI toUriWithoutParameters(@Nonnull Url url) { try { String externalPath = url.getPath(); boolean inLocalFileSystem = url.isInLocalFileSystem(); if (inLocalFileSystem && SystemInfoRt.isWindows && externalPath.charAt(0) != '/') { externalPath = '/' + externalPath; } return new URI(inLocalFileSystem ? "file" : url.getScheme(), inLocalFileSystem ? "" : url.getAuthority(), externalPath, null, null); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
private static void startLogging(final Logger log) { Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") { @Override public void run() { log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); } }); log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------"); ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance(); ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance(); String buildDate = new SimpleDateFormat("dd MMM yyyy HH:ss", Locale.US).format(appInfo.getBuildDate().getTime()); log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild().asString() + ", " + buildDate + ")"); log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ", " + SystemInfo.OS_ARCH + ")"); log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")"); log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.name", "-") + ")"); List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); if (arguments != null) { log.info("JVM Args: " + StringUtil.join(arguments, " ")); } IdeaForkJoinWorkerThreadFactory.setupForkJoinCommonPool(); log.info("ForkJoinPool.commonPool: " + ForkJoinPool.commonPool()); String extDirs = System.getProperty("java.ext.dirs"); if (extDirs != null) { for (String dir : StringUtil.split(extDirs, File.pathSeparator)) { String[] content = new File(dir).list(); if (content != null && content.length > 0) { log.info("ext: " + dir + ": " + Arrays.toString(content)); } } } log.info("JNU charset: " + System.getProperty("sun.jnu.encoding")); }
@Nonnull public static Collection<String> getUtilClassPath() { final Class<?>[] classes = {PathManager.class, // module 'util' Nonnull.class, // module 'annotations' SystemInfoRt.class, // module 'util-rt' Document.class, // jDOM Appender.class, // log4j THashSet.class, // trove4j PicoContainer.class, // PicoContainer TypeMapper.class, // JNA FileUtils.class, // JNA (jna-platform) PatternMatcher.class // OROMatcher }; final Set<String> classPath = new HashSet<String>(); for (Class<?> aClass : classes) { final String path = getJarPathForClass(aClass); if (path != null) { classPath.add(path); } } final String resourceRoot = getResourceRoot(PathManager.class, "/messages/CommonBundle.properties"); // platform-resources-en if (resourceRoot != null) { classPath.add(new File(resourceRoot).getAbsolutePath()); } return Collections.unmodifiableCollection(classPath); }
@Nonnull public static String getRelativePath(@Nullable FilePath parent, @Nonnull FilePath child) { boolean isLocal = !child.isNonLocal(); boolean caseSensitive = isLocal && SystemInfoRt.isFileSystemCaseSensitive; String result = parent != null ? FileUtil.getRelativePath(parent.getPath(), child.getPath(), '/', caseSensitive) : null; result = result == null ? child.getPath() : result; return isLocal ? FileUtil.toSystemDependentName(result) : result; }
public static String replaceMnemonicAmpersand(@Nullable final String value) { if (value == null) { //noinspection ConstantConditions return null; } if (value.indexOf('&') >= 0) { boolean useMacMnemonic = value.contains("&&"); StringBuilder realValue = new StringBuilder(); int i = 0; while (i < value.length()) { char c = value.charAt(i); if (c == '\\') { if (i < value.length() - 1 && value.charAt(i + 1) == '&') { realValue.append('&'); i++; } else { realValue.append(c); } } else if (c == '&') { if (i < value.length() - 1 && value.charAt(i + 1) == '&') { if (SystemInfoRt.isMac) { realValue.append(MNEMONIC); } i++; } else { if (!SystemInfoRt.isMac || !useMacMnemonic) { realValue.append(MNEMONIC); } } } else { realValue.append(c); } i++; } return realValue.toString(); } return value; }
@Nullable public static String getRelativePath(@NotNull String basePath, @NotNull String filePath, char separator) { return getRelativePath(basePath, filePath, separator, SystemInfoRt.isFileSystemCaseSensitive); }
@NotNull private static File normalizeFile(@NotNull File temp) throws IOException { final File canonical = temp.getCanonicalFile(); return SystemInfoRt.isWindows && canonical.getAbsolutePath().contains(" ") ? temp.getAbsoluteFile() : canonical; }
public DetachExternalProjectAction() { super(ProjectData.class); getTemplatePresentation().setText(ExternalSystemBundle.message("action.detach.external.project.text", "external")); getTemplatePresentation().setDescription(ExternalSystemBundle.message("action.detach.external.project.description")); getTemplatePresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Remove : AllIcons.ToolbarDecorator.Remove); }
public AddArrangementSectionRuleAction() { getTemplatePresentation().setText(ApplicationBundle.message("arrangement.action.section.rule.add.text")); getTemplatePresentation().setDescription(ApplicationBundle.message("arrangement.action.section.rule.add.description")); getTemplatePresentation().setIcon(SystemInfoRt.isMac ? AllIcons.CodeStyle.Mac.AddNewSectionRule : AllIcons.CodeStyle.AddNewSectionRule); }
private static void installPatch() throws Exception { String platform = System.getProperty(PLATFORM_PREFIX_PROPERTY, "idea"); String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase(Locale.US); String tempDir = System.getProperty("java.io.tmpdir"); // always delete previous patch copy File patchCopy = new File(tempDir, patchFileName + "_copy"); File log4jCopy = new File(tempDir, "log4j.jar." + platform + "_copy"); File jnaUtilsCopy = new File(tempDir, "jna-platform.jar." + platform + "_copy"); File jnaCopy = new File(tempDir, "jna.jar." + platform + "_copy"); if (!FileUtilRt.delete(patchCopy) || !FileUtilRt.delete(log4jCopy) || !FileUtilRt.delete(jnaUtilsCopy) || !FileUtilRt.delete(jnaCopy)) { throw new IOException("Cannot delete temporary files in " + tempDir); } File patch = new File(tempDir, patchFileName); if (!patch.exists()) return; File log4j = new File(PathManager.getLibPath(), "log4j.jar"); if (!log4j.exists()) throw new IOException("Log4J is missing: " + log4j); File jnaUtils = new File(PathManager.getLibPath(), "jna-platform.jar"); if (!jnaUtils.exists()) throw new IOException("jna-platform.jar is missing: " + jnaUtils); File jna = new File(PathManager.getLibPath(), "jna.jar"); if (!jna.exists()) throw new IOException("jna is missing: " + jna); copyFile(patch, patchCopy, true); copyFile(log4j, log4jCopy, false); copyFile(jna, jnaCopy, false); copyFile(jnaUtils, jnaUtilsCopy, false); int status = 0; if (Restarter.isSupported()) { List<String> args = new ArrayList<String>(); if (SystemInfoRt.isWindows) { File launcher = new File(PathManager.getBinPath(), "VistaLauncher.exe"); args.add(Restarter.createTempExecutable(launcher).getPath()); Restarter.createTempExecutable(new File(PathManager.getBinPath(), "restarter.exe")); } //noinspection SpellCheckingInspection String java = getJava(); Collections.addAll(args, java, "-Xmx750m", "-Djna.nosys=true", "-Djna.boot.library.path=", "-Djna.debug_load=true", "-Djna.debug_load.jna=true", "-classpath", patchCopy.getPath() + pathSeparator + log4jCopy.getPath() + pathSeparator + jnaCopy.getPath() + pathSeparator + jnaUtilsCopy.getPath(), "-Djava.io.tmpdir=" + tempDir, "-Didea.updater.log=" + PathManager.getLogPath(), "-Dswing.defaultlaf=" + UIManager.getSystemLookAndFeelClassName(), "com.intellij.updater.Runner", "install", PathManager.getHomePath()); status = Restarter.scheduleRestart(ArrayUtilRt.toStringArray(args)); } else { String message = "Patch update is not supported - please do it manually"; showMessage("Update Error", message, true); } System.exit(status); }
@Override public KeymapGroup createGroup(Condition<AnAction> condition, final Project project) { KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(TasksBundle.message("maven.tasks.action.group.name"), MavenIcons.MavenLogo ); if (project == null) return result; Comparator<MavenProject> projectComparator = new Comparator<MavenProject>() { public int compare(MavenProject o1, MavenProject o2) { return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName()); } }; Map<MavenProject, Set<Pair<String, String>>> projectToActionsMapping = new TreeMap<MavenProject, Set<Pair<String, String>>>(projectComparator); ActionManager actionManager = ActionManager.getInstance(); //noinspection TestOnlyProblems for (String eachId : actionManager.getActionIds(getActionPrefix(project, null))) { AnAction eachAction = actionManager.getAction(eachId); if (!(eachAction instanceof MavenGoalAction)) continue; if (condition != null && !condition.value(actionManager.getActionOrStub(eachId))) continue; MavenGoalAction mavenAction = (MavenGoalAction)eachAction; MavenProject mavenProject = mavenAction.getMavenProject(); Set<Pair<String, String>> actions = projectToActionsMapping.get(mavenProject); if (actions == null) { final List<String> projectGoals = collectGoals(mavenProject); actions = new TreeSet<Pair<String, String>>(new Comparator<Pair<String, String>>() { public int compare(Pair<String, String> o1, Pair<String, String> o2) { String goal1 = o1.getFirst(); String goal2 = o2.getFirst(); int index1 = projectGoals.indexOf(goal1); int index2 = projectGoals.indexOf(goal2); if (index1 == index2) return goal1.compareToIgnoreCase(goal2); return (index1 < index2 ? -1 : 1); } }); projectToActionsMapping.put(mavenProject, actions); } actions.add(Pair.create(mavenAction.getGoal(), eachId)); } for (Map.Entry<MavenProject, Set<Pair<String, String>>> each : projectToActionsMapping.entrySet()) { Set<Pair<String, String>> goalsToActionIds = each.getValue(); for (Pair<String, String> eachGoalToActionId : goalsToActionIds) { result.addActionId(eachGoalToActionId.getSecond()); } } Icon icon = SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add; ((Group)result).addHyperlink(new Hyperlink(icon, "Choose a phase/goal to assign a shortcut") { @Override public void onClick(MouseEvent e) { SelectMavenGoalDialog dialog = new SelectMavenGoalDialog(project); if (dialog.showAndGet() && dialog.getResult() != null) { MavenProjectsStructure.GoalNode goalNode = dialog.getResult(); String goal = goalNode.getGoal(); String actionId = MavenShortcutsManager.getInstance(project).getActionId(goalNode.getProjectPath(), goal); getOrRegisterAction(goalNode.getMavenProject(), actionId, goal); ApplicationManager.getApplication().getMessageBus().syncPublisher(KeymapListener.CHANGE_TOPIC).processCurrentKeymapChanged(); Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(e.getComponent())); KeymapPanel keymapPanel = allSettings != null ? allSettings.find(KeymapPanel.class) : null; if (keymapPanel != null) { // clear actions filter keymapPanel.showOption(""); keymapPanel.selectAction(actionId); } } } }); return result; }
@Nullable public static String getRelativePath(@NotNull String basePath, @NotNull String filePath, final char separator) { return getRelativePath(basePath, filePath, separator, SystemInfoRt.isFileSystemCaseSensitive); }