private Map<String, String> getPluginNameByIdMap() {
   if (myPluginNameById == null) {
     myPluginNameById = new HashMap<String, String>();
     for (IdeaPluginDescriptor descriptor : PluginManagerCore.getPlugins()) {
       myPluginNameById.put(descriptor.getPluginId().getIdString(), descriptor.getName());
     }
   }
   return myPluginNameById;
 }
Ejemplo n.º 2
0
 @Nullable
 IdeaPluginDescriptor findPlugin(String id) {
   for (IdeaPluginDescriptor pluginDescriptor : myAllPlugins) {
     PluginId pluginId = pluginDescriptor.getPluginId();
     if (pluginId != null && StringUtil.equals(pluginId.getIdString(), id)) {
       return pluginDescriptor;
     }
   }
   return null;
 }
 private static void checkForUpdates() {
   PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
   long lastUpdate = propertiesComponent.getOrInitLong(KEY, 0);
   if (lastUpdate == 0 || System.currentTimeMillis() - lastUpdate > TimeUnit.DAYS.toMillis(1)) {
     ApplicationManager.getApplication()
         .executeOnPooledThread(
             () -> {
               try {
                 String buildNumber = ApplicationInfo.getInstance().getBuild().asString();
                 IdeaPluginDescriptor plugin = getPlugin();
                 String pluginVersion = plugin.getVersion();
                 String pluginId = plugin.getPluginId().getIdString();
                 String os =
                     URLEncoder.encode(
                         SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8);
                 String uid = PermanentInstallationID.get();
                 String url =
                     "https://plugins.jetbrains.com/plugins/list"
                         + "?pluginId="
                         + pluginId
                         + "&build="
                         + buildNumber
                         + "&pluginVersion="
                         + pluginVersion
                         + "&os="
                         + os
                         + "&uuid="
                         + uid;
                 PropertiesComponent.getInstance()
                     .setValue(KEY, String.valueOf(System.currentTimeMillis()));
                 HttpRequests.request(url)
                     .connect(
                         request -> {
                           try {
                             JDOMUtil.load(request.getReader());
                             LOG.info(
                                 (request.isSuccessful() ? "Successful" : "Unsuccessful")
                                     + " update: "
                                     + url);
                           } catch (JDOMException e) {
                             LOG.warn(e);
                           }
                           return null;
                         });
               } catch (UnknownHostException ignored) {
               } catch (IOException e) {
                 LOG.warn(e);
               }
             });
   }
 }
Ejemplo n.º 4
0
 private void collectInvolvedIds(final String pluginId, boolean toEnable, Set<String> ids) {
   ids.add(pluginId);
   if (toEnable) {
     for (String id : getNonOptionalDependencies(pluginId)) {
       collectInvolvedIds(id, true, ids);
     }
   } else {
     Condition<PluginId> condition =
         new Condition<PluginId>() {
           @Override
           public boolean value(PluginId id) {
             return pluginId.equals(id.getIdString());
           }
         };
     for (final IdeaPluginDescriptor plugin : myAllPlugins) {
       if (null != ContainerUtil.find(plugin.getDependentPluginIds(), condition)
           && null == ContainerUtil.find(plugin.getOptionalDependentPluginIds(), condition)) {
         collectInvolvedIds(plugin.getPluginId().getIdString(), false, ids);
       }
     }
   }
 }