Search in sources :

Example 1 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project intellij-community by JetBrains.

the class StartupUtil method startLogging.

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, " "));
    }
    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"));
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Example 2 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project intellij-community by JetBrains.

the class NamePathComponent method validateNameAndPath.

public boolean validateNameAndPath(WizardContext context, boolean defaultFormat) throws ConfigurationException {
    String name = getNameValue();
    if (StringUtil.isEmptyOrSpaces(name)) {
        ApplicationInfo info = ApplicationInfo.getInstance();
        throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name", info.getVersionName(), context.getPresentationName()));
    }
    String projectDirectory = getPath();
    if (StringUtil.isEmptyOrSpaces(projectDirectory)) {
        throw new ConfigurationException(IdeBundle.message("prompt.enter.project.file.location", context.getPresentationName()));
    }
    if (myShouldBeAbsolute && !new File(projectDirectory).isAbsolute()) {
        throw new ConfigurationException(StringUtil.capitalize(IdeBundle.message("file.location.should.be.absolute", context.getPresentationName())));
    }
    boolean shouldPromptCreation = isPathChangedByUser();
    String message = IdeBundle.message("directory.project.file.directory", context.getPresentationName());
    if (!ProjectWizardUtil.createDirectoryIfNotExists(message, projectDirectory, shouldPromptCreation)) {
        return false;
    }
    File file = new File(projectDirectory);
    if (file.exists() && !file.canWrite()) {
        throw new ConfigurationException(String.format("Directory '%s' is not seem to be writable. Please consider another location.", projectDirectory));
    }
    for (Project p : ProjectManager.getInstance().getOpenProjects()) {
        if (ProjectUtil.isSameProject(projectDirectory, p)) {
            throw new ConfigurationException(String.format("Directory '%s' is already taken by the project '%s'. Please consider another location.", projectDirectory, p.getName()));
        }
    }
    boolean shouldContinue = true;
    String fileName = defaultFormat ? name + ProjectFileType.DOT_DEFAULT_EXTENSION : Project.DIRECTORY_STORE_FOLDER;
    File projectFile = new File(file, fileName);
    if (projectFile.exists()) {
        message = IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(), context.getPresentationName());
        int answer = Messages.showYesNoDialog(message, IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
        shouldContinue = (answer == Messages.YES);
    }
    return shouldContinue;
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) File(java.io.File)

Example 3 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project android by JetBrains.

the class IdeVersionReaderTest method testGetComponentName.

public void testGetComponentName() {
    ApplicationInfo applicationInfo = replaceApplicationInfo();
    String name = "Android Studio";
    when(applicationInfo.getVersionName()).thenReturn(name);
    assertEquals(name, myVersionReader.getComponentName());
    verify(applicationInfo).getVersionName();
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Example 4 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project android by JetBrains.

the class IdeVersionReaderTest method testGetComponentVersion.

public void testGetComponentVersion() {
    ApplicationInfo applicationInfo = replaceApplicationInfo();
    String version = "2.0";
    when(applicationInfo.getStrictVersion()).thenReturn(version);
    assertEquals(version, myVersionReader.getComponentVersion(mock(Module.class)));
    verify(applicationInfo).getStrictVersion();
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Example 5 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project android by JetBrains.

the class StringResourceViewPanel method hyperlinkUpdate.

@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    StringBuilder sb = new StringBuilder("https://translate.google.com/manager/android_studio/");
    // Application Version
    sb.append("?asVer=");
    ApplicationInfo ideInfo = ApplicationInfo.getInstance();
    // @formatter:off
    sb.append(ideInfo.getMajorVersion()).append('.').append(ideInfo.getMinorVersion()).append('.').append(ideInfo.getMicroVersion()).append('.').append(ideInfo.getPatchVersion());
    // @formatter:on
    // Package name
    MergedManifest manifest = MergedManifest.get(myFacet);
    String pkg = manifest.getPackage();
    if (pkg != null) {
        sb.append("&pkgName=");
        sb.append(pkg.replace('.', '_'));
    }
    // Application ID
    AndroidModuleInfo moduleInfo = AndroidModuleInfo.get(myFacet);
    String appId = moduleInfo.getPackage();
    if (appId != null) {
        sb.append("&appId=");
        sb.append(appId.replace('.', '_'));
    }
    // Version code
    Integer versionCode = manifest.getVersionCode();
    if (versionCode != null) {
        sb.append("&apkVer=");
        sb.append(versionCode.toString());
    }
    // If we support additional IDE languages, we can send the language used in the IDE here
    //sb.append("&lang=en");
    BrowserUtil.browse(sb.toString());
}
Also used : AndroidModuleInfo(com.android.tools.idea.model.AndroidModuleInfo) MergedManifest(com.android.tools.idea.model.MergedManifest) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Aggregations

ApplicationInfo (com.intellij.openapi.application.ApplicationInfo)20 File (java.io.File)5 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 Project (com.intellij.openapi.project.Project)3 NotNull (org.jetbrains.annotations.NotNull)3 PubRoot (io.flutter.pub.PubRoot)2 MemoryUsage (java.lang.management.MemoryUsage)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)2 AndroidModuleInfo (com.android.tools.idea.model.AndroidModuleInfo)1 MergedManifest (com.android.tools.idea.model.MergedManifest)1 ScratchRootType (com.intellij.ide.scratch.ScratchRootType)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)1 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)1 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)1 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)1 PluginId (com.intellij.openapi.extensions.PluginId)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1