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;
}
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);
}
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();
}
}
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);
}
}
}
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);
}
Aggregations