Search in sources :

Example 11 with ApplicationInfo

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

the class GoogleCrash method createPost.

@NotNull
private HttpUriRequest createPost(@NotNull FlightRecorder flightRecorder, @NotNull String issueText, @NotNull List<Path> logFiles) {
    HttpPost post = new HttpPost(myCrashUrl);
    ApplicationInfo applicationInfo = getApplicationInfo();
    String strictVersion = applicationInfo == null ? "0.0.0.0" : applicationInfo.getStrictVersion();
    MultipartEntityBuilder builder = MultipartEntityBuilder.create();
    // key names recognized by crash
    builder.addTextBody(KEY_PRODUCT_ID, "AndroidStudio");
    builder.addTextBody(KEY_VERSION, strictVersion);
    builder.addTextBody("exception_info", getUniqueStackTrace());
    builder.addTextBody("user_report", issueText);
    if (ANONYMIZED_UID != null) {
        builder.addTextBody("guid", ANONYMIZED_UID);
    }
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    builder.addTextBody("ptime", Long.toString(runtimeMXBean.getUptime()));
    // product specific key value pairs
    builder.addTextBody("fullVersion", applicationInfo == null ? "0.0.0.0" : applicationInfo.getFullVersion());
    builder.addTextBody("osName", StringUtil.notNullize(SystemInfo.OS_NAME));
    builder.addTextBody("osVersion", StringUtil.notNullize(SystemInfo.OS_VERSION));
    builder.addTextBody("osArch", StringUtil.notNullize(SystemInfo.OS_ARCH));
    builder.addTextBody("locale", StringUtil.notNullize(LOCALE));
    builder.addTextBody("vmName", StringUtil.notNullize(runtimeMXBean.getVmName()));
    builder.addTextBody("vmVendor", StringUtil.notNullize(runtimeMXBean.getVmVendor()));
    builder.addTextBody("vmVersion", StringUtil.notNullize(runtimeMXBean.getVmVersion()));
    MemoryUsage usage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    builder.addTextBody("heapUsed", Long.toString(usage.getUsed()));
    builder.addTextBody("heapCommitted", Long.toString(usage.getCommitted()));
    builder.addTextBody("heapMax", Long.toString(usage.getMax()));
    // add report specific data
    builder.addTextBody("Type", "InstantRunFlightRecorder");
    addFlightRecorderLogs(builder, flightRecorder, logFiles);
    post.setEntity(new GzipCompressingEntity(builder.build()));
    return post;
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) MultipartEntityBuilder(org.apache.http.entity.mime.MultipartEntityBuilder) GzipCompressingEntity(org.apache.http.client.entity.GzipCompressingEntity) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) RuntimeMXBean(java.lang.management.RuntimeMXBean) MemoryUsage(java.lang.management.MemoryUsage) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with ApplicationInfo

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

the class IdeVersionReaderTest method testAppliesToWithIdea.

public void testAppliesToWithIdea() {
    ApplicationInfo applicationInfo = replaceApplicationInfo();
    String name = "Idea";
    when(applicationInfo.getVersionName()).thenReturn(name);
    assertFalse(myVersionReader.appliesTo(mock(Module.class)));
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Example 13 with ApplicationInfo

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

the class IdeVersionReaderTest method testAppliesToWithAndroidStudio.

public void testAppliesToWithAndroidStudio() {
    ApplicationInfo applicationInfo = replaceApplicationInfo();
    String name = "Android Studio";
    when(applicationInfo.getVersionName()).thenReturn(name);
    assertTrue(myVersionReader.appliesTo(mock(Module.class)));
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Example 14 with ApplicationInfo

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

the class RegistryUi method processClose.

private void processClose() {
    if (Registry.getInstance().isRestartNeeded()) {
        final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication();
        final ApplicationInfo info = ApplicationInfo.getInstance();
        final int r = Messages.showOkCancelDialog(myContent, "You need to restart " + info.getVersionName() + " for the changes to take effect", "Restart Required", app.isRestartCapable() ? "Restart Now" : "Shutdown Now", app.isRestartCapable() ? "Restart Later" : "Shutdown Later", Messages.getQuestionIcon());
        if (r == Messages.OK) {
            ApplicationManager.getApplication().invokeLater(() -> app.restart(true), ModalityState.NON_MODAL);
        }
    }
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Example 15 with ApplicationInfo

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

the class ProjectNameStep method validate.

public boolean validate() throws ConfigurationException {
    String name = myNamePathComponent.getNameValue();
    if (name.length() == 0) {
        final ApplicationInfo info = ApplicationInfo.getInstance();
        throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name", info.getVersionName(), myWizardContext.getPresentationName()));
    }
    final String projectFileDirectory = getProjectFileDirectory();
    if (projectFileDirectory.length() == 0) {
        throw new ConfigurationException(IdeBundle.message("prompt.enter.project.file.location", myWizardContext.getPresentationName()));
    }
    final boolean shouldPromptCreation = myNamePathComponent.isPathChangedByUser();
    String prefix = IdeBundle.message("directory.project.file.directory", myWizardContext.getPresentationName());
    if (!ProjectWizardUtil.createDirectoryIfNotExists(prefix, projectFileDirectory, shouldPromptCreation)) {
        return false;
    }
    boolean shouldContinue = true;
    final String path = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED ? getProjectFileDirectory() + "/" + Project.DIRECTORY_STORE_FOLDER : getProjectFilePath();
    final File projectFile = new File(path);
    if (projectFile.exists()) {
        final String title = myWizardContext.isCreatingNewProject() ? IdeBundle.message("title.new.project") : IdeBundle.message("title.add.module");
        final String message = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED ? IdeBundle.message("prompt.overwrite.project.folder", Project.DIRECTORY_STORE_FOLDER, projectFile.getParentFile().getAbsolutePath()) : IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(), myWizardContext.getPresentationName());
        int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
        shouldContinue = answer == Messages.YES;
    }
    return shouldContinue;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) File(java.io.File)

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