public static void initLoggers() { if (!SystemProperties.getBooleanProperty(GlobalOptions.USE_DEFAULT_FILE_LOGGING_OPTION, true)) { return; } try { final String logDir = System.getProperty(GlobalOptions.LOG_DIR_OPTION, null); final File configFile = logDir != null? new File(logDir, LOG_CONFIG_FILE_NAME) : new File(LOG_CONFIG_FILE_NAME); ensureLogConfigExists(configFile); String text = FileUtil.loadFile(configFile); final String logFile = logDir != null? new File(logDir, LOG_FILE_NAME).getAbsolutePath() : LOG_FILE_NAME; text = StringUtil.replace(text, LOG_FILE_MACRO, StringUtil.replace(logFile, "\\", "\\\\")); PropertyConfigurator.configure(new ByteArrayInputStream(text.getBytes("UTF-8"))); } catch (IOException e) { //noinspection UseOfSystemOutOrSystemErr System.err.println("Failed to configure logging: "); //noinspection UseOfSystemOutOrSystemErr e.printStackTrace(System.err); } Logger.setFactory(MyLoggerFactory.class); }
private static File[] getProfilesDirs() { final String userHome = SystemProperties.getUserHome(); if (SystemInfo.isMac) { return new File[] { new File(userHome, "Library" + File.separator + "Mozilla" + File.separator + "Firefox"), new File(userHome, "Library" + File.separator + "Application Support" + File.separator + "Firefox"), }; } if (SystemInfo.isUnix) { return new File[] {new File(userHome, ".mozilla" + File.separator + "firefox")}; } String localPath = "Mozilla" + File.separator + "Firefox"; return new File[] { new File(System.getenv("APPDATA"), localPath), new File(userHome, "AppData" + File.separator + "Roaming" + File.separator + localPath), new File(userHome, "Application Data" + File.separator + localPath) }; }
private void getReportText(StringBuffer buffer, final ErrorTreeElement element, boolean withUsages, final int indent) { final String newline = SystemProperties.getLineSeparator(); Object[] children = myStructure.getChildElements(element); for (final Object child : children) { if (!(child instanceof ErrorTreeElement)) { continue; } if (!withUsages && child instanceof NavigatableMessageElement) { continue; } final ErrorTreeElement childElement = (ErrorTreeElement)child; if (buffer.length() > 0) { buffer.append(newline); } shift(buffer, indent); exportElement(childElement, buffer, indent, newline); getReportText(buffer, childElement, withUsages, indent + 4); } }
public static void setScaleFactor(float scale) { if (SystemProperties.has("hidpi") && !SystemProperties.is("hidpi")) { return; } if (scale < 1.25f) scale = 1.0f; else if (scale < 1.5f) scale = 1.25f; else if (scale < 1.75f) scale = 1.5f; else if (scale < 2f) scale = 1.75f; else scale = 2.0f; if (SystemInfo.isLinux && scale == 1.25f) { //Default UI font size for Unity and Gnome is 15. Scaling factor 1.25f works badly on Linux scale = 1f; } SCALE_FACTOR = scale; IconLoader.setScale(scale); }
@NotNull public static XDebugSessionTab create(@NotNull XDebugSessionImpl session, @Nullable Icon icon, @Nullable ExecutionEnvironment environment, @Nullable RunContentDescriptor contentToReuse) { if (contentToReuse != null && SystemProperties.getBooleanProperty("xdebugger.reuse.session.tab", false)) { JComponent component = contentToReuse.getComponent(); if (component != null) { XDebugSessionTab oldTab = TAB_KEY.getData(DataManager.getInstance().getDataContext(component)); if (oldTab != null) { oldTab.setSession(session, environment, icon); oldTab.attachToSession(session); return oldTab; } } } return new XDebugSessionTab(session, icon, environment); }
@Override public void performCopy(@NotNull DataContext dataContext) { final Set<TemplateImpl> templates = myConfigurable.getSelectedTemplates().keySet(); CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.join(templates, new Function<TemplateImpl, String>() { @Override public String fun(TemplateImpl template) { TemplateContext zeroContext = new TemplateContext(); for (TemplateContextType type : TemplateContextType.EP_NAME.getExtensions()) { zeroContext.setEnabled(type, false); } return JDOMUtil.writeElement(TemplateSettings.serializeTemplate(template, zeroContext)); } }, SystemProperties.getLineSeparator()))); }
public static List<VirtualFile> getCondaDefaultLocations() { List<VirtualFile> roots = new ArrayList<VirtualFile>(); final VirtualFile userHome = LocalFileSystem.getInstance().findFileByPath(SystemProperties.getUserHome().replace('\\','/')); if (userHome != null) { for (String root : CONDA_DEFAULT_ROOTS) { VirtualFile condaFolder = userHome.findChild(root); addEnvsFolder(roots, condaFolder); if (SystemInfo.isWindows) { final VirtualFile appData = userHome.findFileByRelativePath("AppData\\Local\\Continuum\\" + root); addEnvsFolder(roots, appData); condaFolder = LocalFileSystem.getInstance().findFileByPath("C:\\" + root); addEnvsFolder(roots, condaFolder); } else { final String systemWidePath = "/opt/anaconda"; condaFolder = LocalFileSystem.getInstance().findFileByPath(systemWidePath); addEnvsFolder(roots, condaFolder); } } } return roots; }
@Nullable public static String getCondaExecutable(@NotNull final String condaName) { final VirtualFile userHome = LocalFileSystem.getInstance().findFileByPath(SystemProperties.getUserHome().replace('\\', '/')); if (userHome != null) { for (String root : VirtualEnvSdkFlavor.CONDA_DEFAULT_ROOTS) { VirtualFile condaFolder = userHome.findChild(root); String executableFile = findExecutable(condaName, condaFolder); if (executableFile != null) return executableFile; if (SystemInfo.isWindows) { condaFolder = LocalFileSystem.getInstance().findFileByPath("C:\\" + root); executableFile = findExecutable(condaName, condaFolder); if (executableFile != null) return executableFile; } else { final String systemWidePath = "/opt/anaconda"; condaFolder = LocalFileSystem.getInstance().findFileByPath(systemWidePath); executableFile = findExecutable(condaName, condaFolder); if (executableFile != null) return executableFile; } } } return null; }
public static ProcessOutput runJython(String workDir, String pythonPath, String... args) throws ExecutionException { final SimpleJavaSdkType sdkType = new SimpleJavaSdkType(); final Sdk ideaJdk = sdkType.createJdk("tmp", SystemProperties.getJavaHome()); SimpleJavaParameters parameters = new SimpleJavaParameters(); parameters.setJdk(ideaJdk); parameters.setMainClass("org.python.util.jython"); File jythonJar = new File(PythonHelpersLocator.getPythonCommunityPath(), "lib/jython.jar"); parameters.getClassPath().add(jythonJar.getPath()); parameters.getProgramParametersList().add("-Dpython.path=" + pythonPath + File.pathSeparator + workDir); parameters.getProgramParametersList().addAll(args); parameters.setWorkingDirectory(workDir); final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(sdkType.getVMExecutablePath(ideaJdk), parameters, false); final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine.createProcess()); return processHandler.runProcess(); }
BuilderExecutionSettings() { myEmbeddedModeEnabled = SystemProperties.getBooleanProperty(USE_EMBEDDED_GRADLE_DAEMON, false); myGradleHomeDir = findDir(GRADLE_HOME_DIR_PATH, "Gradle home"); myGradleServiceDir = findDir(GRADLE_SERVICE_DIR_PATH, "Gradle service"); myJavaHomeDir = findDir(GRADLE_JAVA_HOME_DIR_PATH, "Java home"); myProjectDir = findProjectRootDir(); String buildActionName = System.getProperty(BUILD_MODE); myBuildMode = Strings.isNullOrEmpty(buildActionName) ? BuildMode.DEFAULT_BUILD_MODE : BuildMode.valueOf(buildActionName); myGradleTasksToInvoke = getJvmArgGroup(GRADLE_TASKS_TO_INVOKE_PROPERTY_PREFIX); myCommandLineOptions = getJvmArgGroup(GRADLE_DAEMON_COMMAND_LINE_OPTION_PREFIX); myJvmOptions = getJvmArgGroup(GRADLE_DAEMON_JVM_OPTION_PREFIX); myVerboseLoggingEnabled = SystemProperties.getBooleanProperty(USE_GRADLE_VERBOSE_LOGGING, false); myParallelBuild = SystemProperties.getBooleanProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, false); myOfflineBuildMode = SystemProperties.getBooleanProperty(GRADLE_OFFLINE_BUILD_MODE, false); myConfigureOnDemand = SystemProperties.getBooleanProperty(GRADLE_CONFIGURATION_ON_DEMAND, false); populateHttpProxyJvmOptions(); }
/** * Updates the version metadata with the given XML document. * * @param metadata the XML document containing the new metadata. * @return {@code true} if the metadata was updated, {@code false} otherwise. */ boolean updateMetadata(@NotNull Document metadata) { try { VersionMetadata updated = loadMetadata(metadata.getRootElement()); if (updated.dataVersion > myMetadata.dataVersion) { myMetadata = updated; File metadataFilePath = getMetadataFilePath(); writeDocument(metadata, metadataFilePath, SystemProperties.getLineSeparator()); LOG.info("Saved component version metadata to: " + metadataFilePath); return true; } } catch (Throwable e) { LOG.info("Failed to update component version metadata", e); } return false; }
private void findAndShowVariantConflicts() { ConflictSet conflicts = findConflicts(myProject); List<Conflict> structureConflicts = conflicts.getStructureConflicts(); if (!structureConflicts.isEmpty() && SystemProperties.getBooleanProperty("enable.project.profiles", false)) { ProjectProfileSelectionDialog dialog = new ProjectProfileSelectionDialog(myProject, structureConflicts); dialog.show(); } List<Conflict> selectionConflicts = conflicts.getSelectionConflicts(); if (!selectionConflicts.isEmpty()) { boolean atLeastOneSolved = solveSelectionConflicts(selectionConflicts); if (atLeastOneSolved) { conflicts = findConflicts(myProject); } } conflicts.showSelectionConflicts(); }
@NotNull private static String getHeaderComment() { String[] lines = { "# Project-wide Gradle settings.", "", "# For more details on how to configure your build environment visit", "# http://www.gradle.org/docs/current/userguide/build_environment.html", "", "# Specifies the JVM arguments used for the daemon process.", "# The setting is particularly useful for tweaking memory settings.", "# Default value: -Xmx10248m -XX:MaxPermSize=256m", "# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8", "", "# When configured, Gradle will run in incubating parallel mode.", "# This option should only be used with decoupled projects. More details, visit", "# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects", "# org.gradle.parallel=true" }; return Joiner.on(SystemProperties.getLineSeparator()).join(lines); }
/** * Returns the value for property 'lastSdkPath' as stored in the properties file at $HOME/.android/ddms.cfg, or {@code null} if the file * or property doesn't exist. * * This is only useful in a scenario where existing users of ADT/Eclipse get Studio, but without the bundle. This method duplicates some * functionality of {@link com.android.prefs.AndroidLocation} since we don't want any file system writes to happen during this process. */ @Nullable private static String getLastSdkPathUsedByAndroidTools() { String userHome = SystemProperties.getUserHome(); if (userHome == null) { return null; } File file = new File(new File(userHome, ".android"), "ddms.cfg"); if (!file.exists()) { return null; } try { Properties properties = getProperties(file); return properties.getProperty("lastSdkPath"); } catch (IOException e) { return null; } }
public static String mergeGradleSettingsFile(@NotNull String source, @NotNull String dest) throws IOException, TemplateException { // TODO: Right now this is implemented as a dumb text merge. It would be much better to read it into PSI using IJ's Groovy support. // If Gradle build files get first-class PSI support in the future, we will pick that up cheaply. At the moment, Our Gradle-Groovy // support requires a project, which we don't necessarily have when instantiating a template. StringBuilder contents = new StringBuilder(dest); for (String line : Splitter.on('\n').omitEmptyStrings().trimResults().split(source)) { if (!line.startsWith("include")) { throw new RuntimeException("When merging settings.gradle files, only include directives can be merged."); } line = line.substring("include".length()).trim(); Matcher matcher = INCLUDE_PATTERN.matcher(contents); if (matcher.find()) { contents.insert(matcher.end(), ", " + line); } else { contents.insert(0, "include " + line + SystemProperties.getLineSeparator()); } } return contents.toString(); }
/** * Find all potential folders that may contain Java SDKs. * Those folders are guaranteed to exist but they may not be valid Java homes. */ @NotNull private static List<File> getPotentialJdkPaths() { JavaSdk javaSdk = JavaSdk.getInstance(); List<String> jdkPaths = Lists.newArrayList(javaSdk.suggestHomePaths()); jdkPaths.add(SystemProperties.getJavaHome()); List<File> virtualFiles = Lists.newArrayListWithCapacity(jdkPaths.size()); for (String jdkPath : jdkPaths) { if (jdkPath != null) { File javaHome = new File(jdkPath); if (javaHome.isDirectory()) { virtualFiles.add(javaHome); } } } return virtualFiles; }
@Nullable public static String getJdkHomePath(@NotNull LanguageLevel langLevel) { Collection<String> jdkHomePaths = new ArrayList<String>(JavaSdk.getInstance().suggestHomePaths()); if (jdkHomePaths.isEmpty()) { return null; } // prefer jdk path of getJavaHome(), since we have to allow access to it in tests // see AndroidProjectDataServiceTest#testImportData() final List<String> list = new ArrayList<String>(); String javaHome = SystemProperties.getJavaHome(); if (javaHome != null && !javaHome.isEmpty()) { for (Iterator<String> it = jdkHomePaths.iterator(); it.hasNext(); ) { final String path = it.next(); if (path != null && javaHome.startsWith(path)) { it.remove(); list.add(path); } } } list.addAll(jdkHomePaths); return getBestJdkHomePath(list, langLevel); }
@Override protected void collectAllowedRoots(final List<String> roots) throws IOException { JavaSdk javaSdk = JavaSdk.getInstance(); final List<String> jdkPaths = Lists.newArrayList(javaSdk.suggestHomePaths()); jdkPaths.add(SystemProperties.getJavaHome()); roots.addAll(jdkPaths); for (final String jdkPath : jdkPaths) { FileUtil.processFilesRecursively(new File(jdkPath), new Processor<File>() { @Override public boolean process(File file) { try { String path = file.getCanonicalPath(); if (!FileUtil.isAncestor(jdkPath, path, false)) { roots.add(path); } } catch (IOException ignore) { } return true; } }); } }
public SVNAuthentication requestClientAuthentication(final String kind, final SVNURL url, final String realm, SVNErrorMessage errorMessage, final SVNAuthentication previousAuth, final boolean authMayBeStored) { if (ApplicationManager.getApplication().isUnitTestMode() && ISVNAuthenticationManager.USERNAME.equals(kind)) { final String userName = previousAuth != null && previousAuth.getUserName() != null ? previousAuth.getUserName() : SystemProperties.getUserName(); return new SVNUserNameAuthentication(userName, false); } final SvnAuthenticationNotifier.AuthenticationRequest obj = new SvnAuthenticationNotifier.AuthenticationRequest(myProject, kind, url, realm); final SVNURL wcUrl = myAuthenticationNotifier.getWcUrl(obj); if (wcUrl == null || ourForceInteractive.contains(Thread.currentThread())) { // outside-project url return mySvnInteractiveAuthenticationProvider.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored); } else { if (myAuthenticationNotifier.ensureNotify(obj)) { return myAuthenticationManager.requestFromCache(kind, url, realm, errorMessage, previousAuth, authMayBeStored); } } return null; }
@Override public GroovycContinuation runGroovyc(final Collection<String> compilationClassPath, final boolean forStubs, final JpsGroovySettings settings, final File tempFile, final GroovycOutputParser parser) throws Exception { boolean jointPossible = forStubs && !myHasStubExcludes; final LinkedBlockingQueue<String> mailbox = jointPossible && SystemProperties.getBooleanProperty("groovyc.joint.compilation", true) ? new LinkedBlockingQueue<String>() : null; final JointCompilationClassLoader loader = createCompilationClassLoader(compilationClassPath); final Future<Void> future = ourExecutor.submit(new Callable<Void>() { @Override public Void call() throws Exception { runGroovycInThisProcess(loader, forStubs, settings, tempFile, parser, mailbox); return null; } }); if (mailbox == null) { future.get(); return null; } return waitForStubGeneration(future, mailbox, parser, loader); }
private static void collectScriptsFromUserHome(Set<String> result) { String userHome = SystemProperties.getUserHome(); if (userHome == null) return; File scriptFolder = new File(userHome, ".grails/scripts"); File[] files = scriptFolder.listFiles(); if (files == null) return; for (File file : files) { if (file.getName().startsWith("IdeaPrintProjectSettings")) continue; if (isScriptFile(file)) { String name = file.getName(); int idx = name.lastIndexOf('.'); if (idx != -1) { name = name.substring(0, idx); } result.add(GroovyNamesUtil.camelToSnake(name)); } } }
@Nullable private static String getJdkHomePath(LanguageLevel langLevel) { Collection<String> jdkHomePaths = new ArrayList<>(JavaSdk.getInstance().suggestHomePaths()); if (jdkHomePaths.isEmpty()) { return null; } // prefer jdk path of getJavaHome(), since we have to allow access to it in tests // see AndroidProjectDataServiceTest#testImportData() final List<String> list = new ArrayList<>(); String javaHome = SystemProperties.getJavaHome(); if (javaHome != null && !javaHome.isEmpty()) { for (Iterator<String> it = jdkHomePaths.iterator(); it.hasNext(); ) { final String path = it.next(); if (path != null && javaHome.startsWith(path)) { it.remove(); list.add(path); } } } list.addAll(jdkHomePaths); return getBestJdkHomePath(list, langLevel); }
@NotNull public static String getPluginsPath() { if (ourPluginsPath != null) { String tmp9_6 = ourPluginsPath; if (tmp9_6 == null) { throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/intellij/openapi/application/PathManager", "getPluginsPath" })); } return tmp9_6; } if (System.getProperty("idea.plugins.path") != null) { ourPluginsPath = getAbsolutePath(trimPathQuotes(System.getProperty("idea.plugins.path"))); } else if ((SystemInfo.isMac) && (PATHS_SELECTOR != null)) { ourPluginsPath = SystemProperties.getUserHome() + File.separator + "Library/Application Support" + File.separator + PATHS_SELECTOR; } else { ourPluginsPath = getConfigPath() + File.separatorChar + "plugins"; } String tmp159_156 = ourPluginsPath; if (tmp159_156 == null) { throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/intellij/openapi/application/PathManager", "getPluginsPath" })); } return tmp159_156; }
@Nullable private static String getUnityUserPath() { if(SystemInfo.isWinVistaOrNewer) { PointerByReference pointerByReference = new PointerByReference(); WinNT.HRESULT hresult = Shell32.INSTANCE.SHGetKnownFolderPath(Guid.GUID.fromString("{A520A1A4-1780-4FF6-BD18-167343C5AF16}"), 0, null, pointerByReference); if(hresult.longValue() != 0) { return null; } return pointerByReference.getValue().getWideString(0) + "\\Unity"; } else if(SystemInfo.isMac) { return SystemProperties.getUserHome() + "/Library/Unity"; } else if(SystemInfo.isLinux) { return SystemProperties.getUserHome() + "/.config/unity3d"; } return null; }
private String getTitle2Text(ReopenProjectAction action, JComponent pathLabel) { String fullText = action.getProjectPath(); int labelWidth = pathLabel.getWidth(); if (fullText == null || fullText.length() == 0) return " "; String home = SystemProperties.getUserHome(); if (FileUtil.startsWith(fullText, home)) { fullText = "~" + fullText.substring(home.length()); } if (pathLabel.getFontMetrics(pathLabel.getFont()).stringWidth(fullText) > labelWidth) { return myPathShortener.getShortPath(action); } return fullText; }
public SVNAuthentication requestClientAuthentication(final String kind, final SVNURL url, final String realm, SVNErrorMessage errorMessage, final SVNAuthentication previousAuth, final boolean authMayBeStored) { if (ApplicationManager.getApplication().isUnitTestMode() && ISVNAuthenticationManager.USERNAME.equals(kind)) { final String userName = previousAuth != null && previousAuth.getUserName() != null ? previousAuth.getUserName() : SystemProperties.getUserName(); return new SVNUserNameAuthentication(userName, false); } final SvnAuthenticationNotifier.AuthenticationRequest obj = new SvnAuthenticationNotifier.AuthenticationRequest(myProject, kind, url, realm); final SVNURL wcUrl = myAuthenticationNotifier.getWcUrl(obj); if (wcUrl == null || ourForceInteractive.contains(Thread.currentThread())) { // outside-project url return mySvnInteractiveAuthenticationProvider.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored); } else { if (myAuthenticationNotifier.ensureNotify(obj)) { return (SVNAuthentication) myAuthenticationStorage.getData(kind, realm); } } return null; }
private static void collectScriptsFromUserHome(Set<String> result) { String userHome = SystemProperties.getUserHome(); if (userHome == null) return; File scriptFolder = new File(userHome, ".grails/scripts"); File[] files = scriptFolder.listFiles(); if (files == null) return; for (File file : files) { if (isScriptFile(file)) { String name = file.getName(); int idx = name.lastIndexOf('.'); if (idx != -1) { name = name.substring(0, idx); } result.add(GroovyNamesUtil.camelToSnake(name)); } } }
private static void calculateScaleFactor() { if (SystemInfo.isMac) { LOG.info("UI scale factor: 1.0"); scaleFactor = 1.0f; return; } if (SystemProperties.has("hidpi") && !SystemProperties.is("hidpi")) { LOG.info("UI scale factor: 1.0"); scaleFactor = 1.0f; return; } UIUtil.initSystemFontData(); Pair<String, Integer> fdata = UIUtil.getSystemFontData(); int size; if (fdata != null) { size = fdata.getSecond(); } else { size = Fonts.label().getSize(); } setScaleFactor(size/UIUtil.DEF_SYSTEM_FONT_SIZE); }
public static void setScaleFactor(float scale) { if (SystemProperties.has("hidpi") && !SystemProperties.is("hidpi")) { return; } if (scale < 1.25f) scale = 1.0f; else if (scale < 1.5f) scale = 1.25f; else if (scale < 1.75f) scale = 1.5f; else if (scale < 2f) scale = 1.75f; else scale = 2.0f; if (SystemInfo.isLinux && scale == 1.25f) { //Default UI font size for Unity and Gnome is 15. Scaling factor 1.25f works badly on Linux scale = 1f; } if (scaleFactor == scale) { return; } LOG.info("UI scale factor: " + scale); scaleFactor = scale; // IconLoader.setScale(scale); }
@Nullable public static byte[] getNewByteIfDiffers(@Nonnull String key, @Nonnull Object newState, @Nonnull byte[] oldState) { byte[] newBytes = newState instanceof Element ? archiveState((Element)newState) : (byte[])newState; if (Arrays.equals(newBytes, oldState)) { return null; } else if (LOG.isDebugEnabled() && SystemProperties.getBooleanProperty("idea.log.changed.components", false)) { String before = stateToString(oldState); String after = stateToString(newState); if (before.equals(after)) { LOG.debug("Serialization error: serialized are different, but unserialized are equal"); } else { LOG.debug(key + " " + StringUtil.repeat("=", 80 - key.length()) + "\nBefore:\n" + before + "\nAfter:\n" + after); } } return newBytes; }
@Nonnull public static XDebugSessionTab create(@Nonnull XDebugSessionImpl session, @Nullable Icon icon, @Nullable ExecutionEnvironment environment, @Nullable RunContentDescriptor contentToReuse) { if (contentToReuse != null && SystemProperties.getBooleanProperty("xdebugger.reuse.session.tab", false)) { JComponent component = contentToReuse.getComponent(); if (component != null) { XDebugSessionTab oldTab = DataManager.getInstance().getDataContext(component).getData(TAB_KEY); if (oldTab != null) { oldTab.setSession(session, environment, icon); oldTab.attachToSession(session); return oldTab; } } } XDebugSessionTab tab = new XDebugSessionTab(session, icon, environment); tab.myRunContentDescriptor.setActivateToolWindowWhenAdded(contentToReuse == null || contentToReuse.isActivateToolWindowWhenAdded()); return tab; }
@Override public void initComponent() { if (SystemProperties.is("consulo.disable.predefined.bundles")) { return; } Consumer<SdkImpl> consumer = new Consumer<SdkImpl>() { @Override @RequiredDispatchThread public void consume(final SdkImpl sdk) { ApplicationManager.getApplication().runWriteAction(() -> { sdk.setPredefined(true); SdkTable.getInstance().addSdk(sdk); }); } }; for (PredefinedBundlesProvider predefinedBundlesProvider : PredefinedBundlesProvider.EP_NAME.getExtensions()) { try { predefinedBundlesProvider.createBundles(consumer); } catch (Throwable e) { LOGGER.error(e); } } }
public SdkVersionSelectionDialog(JComponent parent, String title, String name, List<String> scalaVersions) { super(parent, false); setTitle(title); //Create and populate the panel. centerPanel = new JPanel(new SpringLayout()); versionLabel = new JLabel(name, JLabel.TRAILING); versionComboBox = new ComboBox(new DefaultComboBoxModel<>(scalaVersions.toArray())); versionLabel.setLabelFor(versionComboBox); centerPanel.add(versionLabel); centerPanel.add(versionComboBox); destination = new TextFieldWithBrowseButton(); destination.addBrowseFolderListener("Select new Mule distribution destination", null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor()); destinationLabel = new JLabel("Destination:", JLabel.TRAILING); destinationLabel.setLabelFor(destination); //By default, should be ~/mule-distro File distro = new File(SystemProperties.getUserHome(), "mule-distro"); destination.setText(distro.getAbsolutePath()); centerPanel.add(destinationLabel); centerPanel.add(destination); //Lay out the panel. SpringUtilities.makeCompactGrid(centerPanel, 2, 2, //rows, cols 6, 6, //initX, initY 6, 6); //xPad, yPad init(); }
private static int getCompilerSdkVersion(CompileContext context) { final Integer cached = JAVA_COMPILER_VERSION_KEY.get(context); if (cached != null) { return cached; } int javaVersion = convertToNumber(SystemProperties.getJavaVersion()); JAVA_COMPILER_VERSION_KEY.set(context, javaVersion); return javaVersion; }