Search in sources :

Example 6 with ApplicationInfoEx

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

the class PermanentInstallationID method calculateInstallationId.

private static String calculateInstallationId() {
    final ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
    final Preferences oldPrefs = Preferences.userRoot();
    // compatibility with previous versions
    final String oldValue = appInfo.isVendorJetBrains() ? oldPrefs.get(OLD_USER_ON_MACHINE_ID_KEY, null) : null;
    final String companyName = appInfo.getShortCompanyName();
    final Preferences prefs = Preferences.userRoot().node(StringUtil.isEmptyOrSpaces(companyName) ? "jetbrains" : companyName.toLowerCase(Locale.US));
    String installationId = prefs.get(INSTALLATION_ID_KEY, null);
    if (StringUtil.isEmptyOrSpaces(installationId)) {
        installationId = !StringUtil.isEmptyOrSpaces(oldValue) ? oldValue : UUID.randomUUID().toString();
        prefs.put(INSTALLATION_ID_KEY, installationId);
    }
    if (!appInfo.isVendorJetBrains()) {
        return installationId;
    }
    // for Windows attempt to use PermanentUserId, so that DotNet products and IDEA would use the same ID.
    if (SystemInfo.isWindows) {
        final String appdata = System.getenv("APPDATA");
        if (appdata != null) {
            final File dir = new File(appdata, "JetBrains");
            if (dir.exists() || dir.mkdirs()) {
                final File permanentIdFile = new File(dir, "PermanentUserId");
                try {
                    String fromFile = "";
                    if (permanentIdFile.exists()) {
                        fromFile = loadFromFile(permanentIdFile).trim();
                    }
                    if (!fromFile.isEmpty()) {
                        if (!fromFile.equals(installationId)) {
                            installationId = fromFile;
                            prefs.put(INSTALLATION_ID_KEY, installationId);
                        }
                    } else {
                        writeToFile(permanentIdFile, installationId);
                    }
                } catch (IOException ignored) {
                }
            }
        }
    }
    // make sure values in older location and in the new location are the same
    if (!installationId.equals(oldValue)) {
        oldPrefs.put(OLD_USER_ON_MACHINE_ID_KEY, installationId);
    }
    return installationId;
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) Preferences(java.util.prefs.Preferences)

Example 7 with ApplicationInfoEx

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

the class IdeBackgroundUtil method initFramePainters.

public static void initFramePainters(@NotNull IdeGlassPaneImpl glassPane) {
    PaintersHelper painters = glassPane.getNamedPainters(FRAME_PROP);
    PaintersHelper.initWallpaperPainter(FRAME_PROP, painters);
    ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
    String path = /*UIUtil.isUnderDarcula()? appInfo.getEditorBackgroundImageUrl() : */
    null;
    URL url = path == null ? null : appInfo.getClass().getResource(path);
    Image centerImage = url == null ? null : ImageLoader.loadFromUrl(url);
    if (centerImage != null) {
        painters.addPainter(PaintersHelper.newImagePainter(centerImage, PaintersHelper.Fill.PLAIN, PaintersHelper.Place.TOP_CENTER, 1.0f, JBUI.insets(10, 0, 0, 0)), null);
    }
    painters.addPainter(new AbstractPainter() {

        EditorEmptyTextPainter p = ServiceManager.getService(EditorEmptyTextPainter.class);

        @Override
        public boolean needsRepaint() {
            return true;
        }

        @Override
        public void executePaint(Component component, Graphics2D g) {
            p.paintEmptyText((JComponent) component, g);
        }
    }, null);
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) EditorEmptyTextPainter(com.intellij.openapi.fileEditor.impl.EditorEmptyTextPainter) BufferedImage(java.awt.image.BufferedImage) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) URL(java.net.URL) AbstractPainter(com.intellij.openapi.ui.AbstractPainter)

Example 8 with ApplicationInfoEx

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

the class StartupUtil method runStartupWizard.

static void runStartupWizard() {
    ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
    String stepsProviderName = appInfo.getCustomizeIDEWizardStepsProvider();
    if (stepsProviderName != null) {
        CustomizeIDEWizardStepsProvider provider;
        try {
            Class<?> providerClass = Class.forName(stepsProviderName);
            provider = (CustomizeIDEWizardStepsProvider) providerClass.newInstance();
        } catch (Throwable e) {
            Main.showMessage("Configuration Wizard Failed", e);
            return;
        }
        CloudConfigProvider configProvider = CloudConfigProvider.getProvider();
        if (configProvider != null) {
            configProvider.beforeStartupWizard();
        }
        new CustomizeIDEWizardDialog(provider).show();
        PluginManagerCore.invalidatePlugins();
        if (configProvider != null) {
            configProvider.startupWizardFinished();
        }
        return;
    }
    List<ApplicationInfoEx.PluginChooserPage> pages = appInfo.getPluginChooserPages();
    if (!pages.isEmpty()) {
        new StartupWizard(pages).show();
        PluginManagerCore.invalidatePlugins();
    }
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) CustomizeIDEWizardStepsProvider(com.intellij.ide.customize.CustomizeIDEWizardStepsProvider) CustomizeIDEWizardDialog(com.intellij.ide.customize.CustomizeIDEWizardDialog) CloudConfigProvider(com.intellij.ide.cloudConfig.CloudConfigProvider) StartupWizard(com.intellij.ide.startupWizard.StartupWizard)

Example 9 with ApplicationInfoEx

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

the class SearchableOptionsRegistrarImpl method loadHugeFilesIfNecessary.

private void loadHugeFilesIfNecessary() {
    if (allTheseHugeFilesAreLoaded) {
        return;
    }
    allTheseHugeFilesAreLoaded = true;
    try {
        //index
        final URL indexResource = ResourceUtil.getResource(SearchableOptionsRegistrar.class, "/search/", "searchableOptions.xml");
        if (indexResource == null) {
            LOG.info("No /search/searchableOptions.xml found, settings search won't work!");
            return;
        }
        Document document = JDOMUtil.loadDocument(indexResource);
        Element root = document.getRootElement();
        List configurables = root.getChildren("configurable");
        for (final Object o : configurables) {
            final Element configurable = (Element) o;
            final String id = configurable.getAttributeValue("id");
            final String groupName = configurable.getAttributeValue("configurable_name");
            final List options = configurable.getChildren("option");
            for (Object o1 : options) {
                Element optionElement = (Element) o1;
                final String option = optionElement.getAttributeValue("name");
                final String path = optionElement.getAttributeValue("path");
                final String hit = optionElement.getAttributeValue("hit");
                putOptionWithHelpId(option, id, groupName, hit, path);
            }
        }
        //synonyms
        document = JDOMUtil.loadDocument(ResourceUtil.getResource(SearchableOptionsRegistrar.class, "/search/", "synonyms.xml"));
        root = document.getRootElement();
        configurables = root.getChildren("configurable");
        for (final Object o : configurables) {
            final Element configurable = (Element) o;
            final String id = configurable.getAttributeValue("id");
            final String groupName = configurable.getAttributeValue("configurable_name");
            final List synonyms = configurable.getChildren("synonym");
            for (Object o1 : synonyms) {
                Element synonymElement = (Element) o1;
                final String synonym = synonymElement.getTextNormalize();
                if (synonym != null) {
                    Set<String> words = getProcessedWords(synonym);
                    for (String word : words) {
                        putOptionWithHelpId(word, id, groupName, synonym, null);
                    }
                }
            }
            final List options = configurable.getChildren("option");
            for (Object o1 : options) {
                Element optionElement = (Element) o1;
                final String option = optionElement.getAttributeValue("name");
                final List list = optionElement.getChildren("synonym");
                for (Object o2 : list) {
                    Element synonymElement = (Element) o2;
                    final String synonym = synonymElement.getTextNormalize();
                    if (synonym != null) {
                        Set<String> words = getProcessedWords(synonym);
                        for (String word : words) {
                            putOptionWithHelpId(word, id, groupName, synonym, null);
                        }
                        final Couple<String> key = Couple.of(option, id);
                        Set<String> foundSynonyms = myHighlightOption2Synonym.get(key);
                        if (foundSynonyms == null) {
                            foundSynonyms = new THashSet<>();
                            myHighlightOption2Synonym.put(key, foundSynonyms);
                        }
                        foundSynonyms.add(synonym);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOG.error(e);
    }
    ApplicationInfoEx applicationInfo = ApplicationInfoEx.getInstanceEx();
    for (IdeaPluginDescriptor plugin : PluginManagerCore.getPlugins()) {
        if (applicationInfo.isEssentialPlugin(plugin.getPluginId().getIdString())) {
            continue;
        }
        final String pluginName = plugin.getName();
        final Set<String> words = getProcessedWordsWithoutStemming(pluginName);
        final String description = plugin.getDescription();
        if (description != null) {
            words.addAll(getProcessedWordsWithoutStemming(description));
        }
        for (String word : words) {
            addOption(word, null, pluginName, PluginManagerConfigurable.ID, PluginManagerConfigurable.DISPLAY_NAME);
        }
    }
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) Element(org.jdom.Element) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) Document(org.jdom.Document) URL(java.net.URL) IOException(java.io.IOException)

Example 10 with ApplicationInfoEx

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

the class SendFeedbackAction method launchBrowser.

public static void launchBrowser(@Nullable Project project) {
    final ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
    boolean eap = appInfo.isEAP();
    String urlTemplate = eap ? appInfo.getEAPFeedbackUrl() : appInfo.getReleaseFeedbackUrl();
    urlTemplate = urlTemplate.replace("$BUILD", eap ? appInfo.getBuild().asStringWithoutProductCode() : appInfo.getBuild().asString()).replace("$TIMEZONE", System.getProperty("user.timezone")).replace("$EVAL", isEvaluationLicense() ? "true" : "false").replace("$DESCR", getDescription());
    BrowserUtil.browse(urlTemplate, project);
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx)

Aggregations

ApplicationInfoEx (com.intellij.openapi.application.ex.ApplicationInfoEx)20 NotNull (org.jetbrains.annotations.NotNull)4 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)3 UpdateSettings (com.intellij.openapi.updateSettings.impl.UpdateSettings)3 IOException (java.io.IOException)3 Application (com.intellij.openapi.application.Application)2 Attachment (com.intellij.openapi.diagnostic.Attachment)2 BuildNumber (com.intellij.openapi.util.BuildNumber)2 URL (java.net.URL)2 Nullable (com.android.annotations.Nullable)1 CrashReport (com.android.tools.idea.diagnostics.crash.CrashReport)1 CrashReporter (com.android.tools.idea.diagnostics.crash.CrashReporter)1 Maps (com.google.common.collect.Maps)1 JsonWriter (com.google.gson.stream.JsonWriter)1 AbstractMessage (com.intellij.diagnostic.AbstractMessage)1 IdeErrorsDialog (com.intellij.diagnostic.IdeErrorsDialog)1 ReportMessages (com.intellij.diagnostic.ReportMessages)1 ErrorBean (com.intellij.errorreport.bean.ErrorBean)1 DataManager (com.intellij.ide.DataManager)1