コード例 #1
0
  @Nullable
  public static String getDownloadVersions() {

    String userAgent =
        String.format(
            "%s / %s / Symfony Plugin %s",
            ApplicationInfo.getInstance().getVersionName(),
            ApplicationInfo.getInstance().getBuild(),
            PluginManager.getPlugin(PluginId.getId("fr.adrienbrault.idea.symfony2plugin"))
                .getVersion());

    try {

      // @TODO: PhpStorm9:
      // simple replacement for: com.intellij.util.io.HttpRequests
      URL url = new URL("http://symfony.com/versions.json");
      URLConnection conn = url.openConnection();
      conn.setRequestProperty("User-Agent", userAgent);
      conn.connect();

      BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));

      String content = "";
      String line;
      while ((line = in.readLine()) != null) {
        content += line;
      }

      in.close();

      return content;
    } catch (IOException e) {
      return null;
    }
  }
コード例 #2
0
  static boolean shouldSkipPlugin(
      final IdeaPluginDescriptor descriptor, IdeaPluginDescriptor[] loaded) {
    final String idString = descriptor.getPluginId().getIdString();
    if (idString.equals(CORE_PLUGIN_ID)) {
      return false;
    }

    //noinspection HardCodedStringLiteral
    final String pluginId = System.getProperty("idea.load.plugins.id");
    if (pluginId == null) {
      if (descriptor instanceof IdeaPluginDescriptorImpl && !descriptor.isEnabled()) return true;

      if (!shouldLoadPlugins()) return true;
    }
    final List<String> pluginIds = pluginId == null ? null : StringUtil.split(pluginId, ",");

    final boolean checkModuleDependencies =
        !ourAvailableModules.isEmpty() && !ourAvailableModules.contains("com.intellij.modules.all");
    if (checkModuleDependencies && !hasModuleDependencies(descriptor)) {
      return true;
    }

    boolean shouldLoad;
    //noinspection HardCodedStringLiteral
    final String loadPluginCategory = System.getProperty("idea.load.plugins.category");
    if (loadPluginCategory != null) {
      shouldLoad = loadPluginCategory.equals(descriptor.getCategory());
    } else {
      if (pluginIds != null) {
        shouldLoad = pluginIds.contains(idString);
        if (!shouldLoad) {
          Map<PluginId, IdeaPluginDescriptor> map = new HashMap<PluginId, IdeaPluginDescriptor>();
          for (final IdeaPluginDescriptor pluginDescriptor : loaded) {
            map.put(pluginDescriptor.getPluginId(), pluginDescriptor);
          }
          addModulesAsDependents(map);
          final IdeaPluginDescriptor descriptorFromProperty = map.get(PluginId.getId(pluginId));
          shouldLoad =
              descriptorFromProperty != null
                  && isDependent(
                      descriptorFromProperty,
                      descriptor.getPluginId(),
                      map,
                      checkModuleDependencies);
        }
      } else {
        shouldLoad = !getDisabledPlugins().contains(idString);
      }
      if (shouldLoad && descriptor instanceof IdeaPluginDescriptorImpl) {
        if (isIncompatible(descriptor)) return true;
      }
    }

    return !shouldLoad;
  }
コード例 #3
0
 public NamespaceMakeActions_ActionGroup() {
   super("NamespaceMakeActions", ID);
   this.setIsInternal(false);
   this.setPopup(false);
   {
     LabelledAnchor action = new LabelledAnchor(NamespaceMakeActions_ActionGroup.LABEL_ID_make);
     ActionManagerEx manager = ActionManagerEx.getInstanceEx();
     manager.registerAction(action.getId(), action, PluginId.getId("jetbrains.mps.ide"));
     NamespaceMakeActions_ActionGroup.this.addAction(action);
   }
 }
コード例 #4
0
 static {
   // enables rerun failed tests action in RubyMine
   final String rerunFailedTestsActionId = "RerunFailedTests";
   ActionManager actionManager = ActionManager.getInstance();
   AnAction rerunFailedTestsAction = actionManager.getAction(rerunFailedTestsActionId);
   if (rerunFailedTestsAction == null) {
     AbstractRerunFailedTestsAction action = new AbstractRerunFailedTestsAction();
     actionManager.registerAction(
         rerunFailedTestsActionId, action, PluginId.getId("org.jetbrains.erlang"));
     action.getTemplatePresentation().setIcon(AllIcons.RunConfigurations.RerunFailedTests);
   }
 }
コード例 #5
0
ファイル: LuaFileUtil.java プロジェクト: E-Fir/IDLua
  @Nullable
  public static VirtualFile getPluginVirtualDirectory() {
    IdeaPluginDescriptor descriptor = PluginManager.getPlugin(PluginId.getId("Lua"));
    if (descriptor != null) {
      File pluginPath = descriptor.getPath();

      String url = VfsUtil.pathToUrl(pluginPath.getAbsolutePath());

      return VirtualFileManager.getInstance().findFileByUrl(url);
    }

    return null;
  }
コード例 #6
0
 public GenerateOptions_ActionGroup() {
   super("GenerateOptions", ID);
   this.setIsInternal(false);
   this.setPopup(false);
   GenerateOptions_ActionGroup.this.addAction("jetbrains.mps.ide.make.actions.Options_Action");
   {
     LabelledAnchor action =
         new LabelledAnchor(GenerateOptions_ActionGroup.LABEL_ID_saveTransientModels);
     ActionManagerEx manager = ActionManagerEx.getInstanceEx();
     manager.registerAction(action.getId(), action, PluginId.getId("jetbrains.mps.ide.make"));
     GenerateOptions_ActionGroup.this.addAction(action);
   }
   GenerateOptions_ActionGroup.this.addAction(
       "jetbrains.mps.ide.make.actions.CheckModelsBeforeGeneration_Action");
 }
コード例 #7
0
 public LanguageActions_ActionGroup() {
   super("LanguageActions", ID);
   this.setIsInternal(false);
   this.setPopup(false);
   try {
     {
       LabelledAnchor action = new LabelledAnchor(LanguageActions_ActionGroup.LABEL_ID_newGroup);
       ActionManagerEx manager = ActionManagerEx.getInstanceEx();
       manager.registerAction(action.getId(), action, PluginId.getId("jetbrains.mps.ide"));
       LanguageActions_ActionGroup.this.addAction(action);
     }
     {
       LabelledAnchor action =
           new LabelledAnchor(LanguageActions_ActionGroup.LABEL_ID_commonModule);
       ActionManagerEx manager = ActionManagerEx.getInstanceEx();
       manager.registerAction(action.getId(), action, PluginId.getId("jetbrains.mps.ide"));
       LanguageActions_ActionGroup.this.addAction(action);
     }
     LanguageActions_ActionGroup.this.addSeparator();
     {
       LabelledAnchor action =
           new LabelledAnchor(LanguageActions_ActionGroup.LABEL_ID_find_usages);
       ActionManagerEx manager = ActionManagerEx.getInstanceEx();
       manager.registerAction(action.getId(), action, PluginId.getId("jetbrains.mps.ide"));
       LanguageActions_ActionGroup.this.addAction(action);
     }
     {
       LabelledAnchor action =
           new LabelledAnchor(LanguageActions_ActionGroup.LABEL_ID_find_instances);
       ActionManagerEx manager = ActionManagerEx.getInstanceEx();
       manager.registerAction(action.getId(), action, PluginId.getId("jetbrains.mps.ide"));
       LanguageActions_ActionGroup.this.addAction(action);
     }
     {
       LabelledAnchor action =
           new LabelledAnchor(LanguageActions_ActionGroup.LABEL_ID_find_javastub_usages);
       ActionManagerEx manager = ActionManagerEx.getInstanceEx();
       manager.registerAction(action.getId(), action, PluginId.getId("jetbrains.mps.ide"));
       LanguageActions_ActionGroup.this.addAction(action);
     }
     LanguageActions_ActionGroup.this.addSeparator();
     {
       LabelledAnchor action = new LabelledAnchor(LanguageActions_ActionGroup.LABEL_ID_ex);
       ActionManagerEx manager = ActionManagerEx.getInstanceEx();
       manager.registerAction(action.getId(), action, PluginId.getId("jetbrains.mps.ide"));
       LanguageActions_ActionGroup.this.addAction(action);
     }
     LanguageActions_ActionGroup.this.addAction(
         "jetbrains.mps.ide.actions.ModuleProperties_Action");
   } catch (Throwable t) {
     LOG.error("User group error", t);
   }
 }
コード例 #8
0
  @Nullable
  static String filterBadPlugins(
      List<? extends IdeaPluginDescriptor> result, final Map<String, String> disabledPluginNames) {
    final Map<PluginId, IdeaPluginDescriptor> idToDescriptorMap =
        new HashMap<PluginId, IdeaPluginDescriptor>();
    final StringBuffer message = new StringBuffer();
    boolean pluginsWithoutIdFound = false;
    for (Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext(); ) {
      final IdeaPluginDescriptor descriptor = it.next();
      final PluginId id = descriptor.getPluginId();
      if (id == null) {
        pluginsWithoutIdFound = true;
      }
      if (idToDescriptorMap.containsKey(id)) {
        message.append("<br>");
        message.append(IdeBundle.message("message.duplicate.plugin.id"));
        message.append(id);
        it.remove();
      } else if (descriptor.isEnabled()) {
        idToDescriptorMap.put(id, descriptor);
      }
    }
    addModulesAsDependents(idToDescriptorMap);
    final List<String> disabledPluginIds = new ArrayList<String>();
    final LinkedHashSet<String> faultyDescriptors = new LinkedHashSet<String>();
    for (final Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext(); ) {
      final IdeaPluginDescriptor pluginDescriptor = it.next();
      checkDependants(
          pluginDescriptor,
          new Function<PluginId, IdeaPluginDescriptor>() {
            @Override
            public IdeaPluginDescriptor fun(final PluginId pluginId) {
              return idToDescriptorMap.get(pluginId);
            }
          },
          new Condition<PluginId>() {
            @Override
            public boolean value(final PluginId pluginId) {
              if (!idToDescriptorMap.containsKey(pluginId)) {
                pluginDescriptor.setEnabled(false);
                if (!pluginId.getIdString().startsWith(MODULE_DEPENDENCY_PREFIX)) {
                  faultyDescriptors.add(pluginId.getIdString());
                  disabledPluginIds.add(pluginDescriptor.getPluginId().getIdString());
                  message.append("<br>");
                  final String name = pluginDescriptor.getName();
                  final IdeaPluginDescriptor descriptor = idToDescriptorMap.get(pluginId);
                  String pluginName;
                  if (descriptor == null) {
                    pluginName = pluginId.getIdString();
                    if (disabledPluginNames.containsKey(pluginName)) {
                      pluginName = disabledPluginNames.get(pluginName);
                    }
                  } else {
                    pluginName = descriptor.getName();
                  }

                  message.append(
                      getDisabledPlugins().contains(pluginId.getIdString())
                          ? IdeBundle.message("error.required.plugin.disabled", name, pluginName)
                          : IdeBundle.message(
                              "error.required.plugin.not.installed", name, pluginName));
                }
                it.remove();
                return false;
              }
              return true;
            }
          });
    }
    if (!disabledPluginIds.isEmpty()) {
      myPlugins2Disable = disabledPluginIds;
      myPlugins2Enable = faultyDescriptors;
      message.append("<br>");
      message.append("<br>").append("<a href=\"" + DISABLE + "\">Disable ");
      if (disabledPluginIds.size() == 1) {
        final PluginId pluginId2Disable = PluginId.getId(disabledPluginIds.iterator().next());
        message.append(
            idToDescriptorMap.containsKey(pluginId2Disable)
                ? idToDescriptorMap.get(pluginId2Disable).getName()
                : pluginId2Disable.getIdString());
      } else {
        message.append("not loaded plugins");
      }
      message.append("</a>");
      boolean possibleToEnable = true;
      for (String descriptor : faultyDescriptors) {
        if (disabledPluginNames.get(descriptor) == null) {
          possibleToEnable = false;
          break;
        }
      }
      if (possibleToEnable) {
        message
            .append("<br>")
            .append("<a href=\"" + ENABLE + "\">Enable ")
            .append(
                faultyDescriptors.size() == 1
                    ? disabledPluginNames.get(faultyDescriptors.iterator().next())
                    : " all necessary plugins")
            .append("</a>");
      }
      message.append("<br>").append("<a href=\"" + EDIT + "\">Open plugin manager</a>");
    }
    if (pluginsWithoutIdFound) {
      message.append("<br>");
      message.append(IdeBundle.message("error.plugins.without.id.found"));
    }
    if (message.length() > 0) {
      message.insert(0, IdeBundle.message("error.problems.found.loading.plugins"));
      return message.toString();
    }
    return null;
  }
コード例 #9
0
  public static void runCheck(@NotNull final Project project) {
    List<DependencyOnPlugin> dependencies =
        ExternalDependenciesManager.getInstance(project).getDependencies(DependencyOnPlugin.class);
    if (dependencies.isEmpty()) return;

    List<String> customRepositories = UpdateSettings.getInstance().getStoredPluginHosts();

    final List<String> errorMessages = new ArrayList<String>();
    final List<String> missingCustomRepositories = new ArrayList<String>();
    final List<IdeaPluginDescriptor> disabled = new ArrayList<IdeaPluginDescriptor>();
    final List<PluginId> notInstalled = new ArrayList<PluginId>();
    for (DependencyOnPlugin dependency : dependencies) {
      PluginId pluginId = PluginId.getId(dependency.getPluginId());
      String channel = dependency.getChannel();
      String customRepository = getCustomRepository(pluginId, channel);
      if (!StringUtil.isEmpty(channel)
          && customRepositoryNotSpecified(customRepositories, customRepository)) {
        errorMessages.add(
            "Custom repository '"
                + customRepository
                + "' required for '"
                + project.getName()
                + "' project isn't installed.");
        missingCustomRepositories.add(customRepository);
      }
      IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
      if (plugin == null) {
        errorMessages.add(
            "Plugin '"
                + dependency.getPluginId()
                + "' required for '"
                + project.getName()
                + "' project isn't installed.");
        notInstalled.add(pluginId);
        continue;
      }
      if (!plugin.isEnabled()) {
        errorMessages.add(
            "Plugin '"
                + plugin.getName()
                + "' required for '"
                + project.getName()
                + "' project is disabled.");
        disabled.add(plugin);
        continue;
      }
      String minVersion = dependency.getMinVersion();
      if (minVersion != null
          && VersionComparatorUtil.compare(plugin.getVersion(), minVersion) < 0) {
        errorMessages.add(
            "Project '"
                + project.getName()
                + "' requires plugin  '"
                + plugin.getName()
                + "' version '"
                + minVersion
                + "' or higher, but '"
                + plugin.getVersion()
                + "' is installed.");
      }
      String maxVersion = dependency.getMaxVersion();
      if (maxVersion != null
          && VersionComparatorUtil.compare(plugin.getVersion(), maxVersion) > 0) {
        errorMessages.add(
            "Project '"
                + project.getName()
                + "' requires plugin  '"
                + plugin.getName()
                + "' version '"
                + minVersion
                + "' or lower, but '"
                + plugin.getVersion()
                + "' is installed.");
      }
    }

    if (!errorMessages.isEmpty()) {
      if (!missingCustomRepositories.isEmpty()) {
        errorMessages.add(
            "<a href=\"addRepositories\">Add custom repositories and install required plugins</a>");
      } else if (!disabled.isEmpty() && notInstalled.isEmpty()) {
        String plugins = disabled.size() == 1 ? disabled.get(0).getName() : "required plugins";
        errorMessages.add("<a href=\"enable\">Enable " + plugins + "</a>");
      } else if (!disabled.isEmpty() || !notInstalled.isEmpty()) {
        errorMessages.add("<a href=\"install\">Install required plugins</a>");
      }
      NOTIFICATION_GROUP
          .createNotification(
              "Required plugins weren't loaded",
              StringUtil.join(errorMessages, "<br>"),
              NotificationType.ERROR,
              new NotificationListener() {
                @Override
                public void hyperlinkUpdate(
                    @NotNull final Notification notification, @NotNull HyperlinkEvent event) {
                  if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    if ("addRepositories".equals(event.getDescription())) {
                      UpdateSettings.getInstance()
                          .getStoredPluginHosts()
                          .addAll(missingCustomRepositories);
                    }
                    if ("enable".equals(event.getDescription())) {
                      notification.expire();
                      for (IdeaPluginDescriptor descriptor : disabled) {
                        PluginManagerCore.enablePlugin(descriptor.getPluginId().getIdString());
                      }
                      PluginManagerMain.notifyPluginsUpdated(project);
                    } else if ("install".equals(event.getDescription())
                        || "addRepositories".equals(event.getDescription())) {
                      Set<String> pluginIds = new HashSet<String>();
                      for (IdeaPluginDescriptor descriptor : disabled) {
                        pluginIds.add(descriptor.getPluginId().getIdString());
                      }
                      for (PluginId pluginId : notInstalled) {
                        pluginIds.add(pluginId.getIdString());
                      }
                      PluginsAdvertiser.installAndEnablePlugins(
                          pluginIds, () -> notification.expire());
                    }
                  }
                }
              })
          .notify(project);
    }
  }
コード例 #10
0
  static void initializePlugins(@Nullable StartupProgress progress) {
    configureExtensions();

    final IdeaPluginDescriptorImpl[] pluginDescriptors = loadDescriptors(progress);

    final Class callerClass = ReflectionUtil.findCallerClass(1);
    assert callerClass != null;
    final ClassLoader parentLoader = callerClass.getClassLoader();

    final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>();
    final HashMap<String, String> disabledPluginNames = new HashMap<String, String>();
    for (IdeaPluginDescriptorImpl descriptor : pluginDescriptors) {
      if (descriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID)) {
        final List<String> modules = descriptor.getModules();
        if (modules != null) {
          ourAvailableModules.addAll(modules);
        }
      }

      if (!shouldSkipPlugin(descriptor, pluginDescriptors)) {
        result.add(descriptor);
      } else {
        descriptor.setEnabled(false);
        disabledPluginNames.put(descriptor.getPluginId().getIdString(), descriptor.getName());
        initClassLoader(parentLoader, descriptor);
      }
    }

    prepareLoadingPluginsErrorMessage(filterBadPlugins(result, disabledPluginNames));

    final Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap =
        new HashMap<PluginId, IdeaPluginDescriptorImpl>();
    for (final IdeaPluginDescriptorImpl descriptor : result) {
      idToDescriptorMap.put(descriptor.getPluginId(), descriptor);
    }

    final IdeaPluginDescriptor corePluginDescriptor =
        idToDescriptorMap.get(PluginId.getId(CORE_PLUGIN_ID));
    assert corePluginDescriptor != null
        : CORE_PLUGIN_ID
            + " not found; platform prefix is "
            + System.getProperty(PlatformUtilsCore.PLATFORM_PREFIX_KEY);
    for (IdeaPluginDescriptorImpl descriptor : result) {
      if (descriptor != corePluginDescriptor) {
        descriptor.insertDependency(corePluginDescriptor);
      }
    }

    mergeOptionalConfigs(idToDescriptorMap);

    // sort descriptors according to plugin dependencies
    Collections.sort(result, getPluginDescriptorComparator(idToDescriptorMap));

    for (int i = 0; i < result.size(); i++) {
      ourId2Index.put(result.get(i).getPluginId(), i);
    }

    int i = 0;
    for (final IdeaPluginDescriptorImpl pluginDescriptor : result) {
      if (pluginDescriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID)
          || pluginDescriptor.isUseCoreClassLoader()) {
        pluginDescriptor.setLoader(parentLoader, true);
      } else {
        final List<File> classPath = pluginDescriptor.getClassPath();
        final PluginId[] dependentPluginIds = pluginDescriptor.getDependentPluginIds();
        final ClassLoader[] parentLoaders = getParentLoaders(idToDescriptorMap, dependentPluginIds);

        final ClassLoader pluginClassLoader =
            createPluginClassLoader(
                classPath.toArray(new File[classPath.size()]),
                parentLoaders.length > 0 ? parentLoaders : new ClassLoader[] {parentLoader},
                pluginDescriptor);
        pluginDescriptor.setLoader(pluginClassLoader, true);
      }

      pluginDescriptor.registerExtensions();
      if (progress != null) {
        progress.showProgress(
            "", PLUGINS_PROGRESS_MAX_VALUE + (i++ / (float) result.size()) * 0.35f);
      }
    }

    ourPlugins = pluginDescriptors;
  }
コード例 #11
0
 private static void addModulesAsDependents(Map<PluginId, ? super IdeaPluginDescriptorImpl> map) {
   for (String module : ourAvailableModules) {
     // fake plugin descriptors to satisfy dependencies
     map.put(PluginId.getId(module), new IdeaPluginDescriptorImpl());
   }
 }
コード例 #12
0
  // used in upsource
  protected void readExternal(@NotNull Element element) {
    final PluginBean pluginBean = XmlSerializer.deserialize(element, PluginBean.class);

    url = pluginBean.url;
    myName = pluginBean.name;
    String idString = pluginBean.id;
    if (idString == null || idString.isEmpty()) {
      idString = myName;
    }
    myId = idString == null ? null : PluginId.getId(idString);

    String internalVersionString = pluginBean.formatVersion;
    if (internalVersionString != null) {
      try {
        //noinspection ResultOfMethodCallIgnored
        Integer.parseInt(internalVersionString);
      } catch (NumberFormatException e) {
        LOG.error(
            new PluginException(
                "Invalid value in plugin.xml format version: '" + internalVersionString + "'",
                e,
                myId));
      }
    }
    myUseIdeaClassLoader = pluginBean.useIdeaClassLoader;
    myAllowBundledUpdate = pluginBean.allowBundledUpdate;
    if (pluginBean.ideaVersion != null) {
      mySinceBuild = pluginBean.ideaVersion.sinceBuild;
      myUntilBuild = convertExplicitBigNumberInUntilBuildToStar(pluginBean.ideaVersion.untilBuild);
    }

    myResourceBundleBaseName = pluginBean.resourceBundle;

    myDescriptionChildText = pluginBean.description;
    myChangeNotes = pluginBean.changeNotes;
    myVersion = pluginBean.pluginVersion;
    if (myVersion == null) {
      myVersion = PluginManagerCore.getBuildNumber().asStringWithoutProductCode();
    }

    myCategory = pluginBean.category;

    if (pluginBean.vendor != null) {
      myVendor = pluginBean.vendor.name;
      myVendorEmail = pluginBean.vendor.email;
      myVendorUrl = pluginBean.vendor.url;
      myVendorLogoPath = pluginBean.vendor.logo;
    }

    // preserve items order as specified in xml (filterBadPlugins will not fail if module comes
    // first)
    Set<PluginId> dependentPlugins = new LinkedHashSet<PluginId>();
    Set<PluginId> optionalDependentPlugins = new LinkedHashSet<PluginId>();
    if (pluginBean.dependencies != null) {
      myOptionalConfigs = new THashMap<PluginId, String>();
      for (PluginDependency dependency : pluginBean.dependencies) {
        String text = dependency.pluginId;
        if (!StringUtil.isEmpty(text)) {
          PluginId id = PluginId.getId(text);
          dependentPlugins.add(id);
          if (dependency.optional) {
            optionalDependentPlugins.add(id);
            if (!StringUtil.isEmpty(dependency.configFile)) {
              myOptionalConfigs.put(id, dependency.configFile);
            }
          }
        }
      }
    }

    myDependencies =
        dependentPlugins.isEmpty()
            ? PluginId.EMPTY_ARRAY
            : dependentPlugins.toArray(new PluginId[dependentPlugins.size()]);
    myOptionalDependencies =
        optionalDependentPlugins.isEmpty()
            ? PluginId.EMPTY_ARRAY
            : optionalDependentPlugins.toArray(new PluginId[optionalDependentPlugins.size()]);

    if (pluginBean.helpSets == null || pluginBean.helpSets.length == 0) {
      myHelpSets = HelpSetPath.EMPTY;
    } else {
      myHelpSets = new HelpSetPath[pluginBean.helpSets.length];
      PluginHelpSet[] sets = pluginBean.helpSets;
      for (int i = 0, n = sets.length; i < n; i++) {
        PluginHelpSet pluginHelpSet = sets[i];
        myHelpSets[i] = new HelpSetPath(pluginHelpSet.file, pluginHelpSet.path);
      }
    }

    myAppComponents = pluginBean.applicationComponents;
    myProjectComponents = pluginBean.projectComponents;
    myModuleComponents = pluginBean.moduleComponents;

    if (myAppComponents == null) myAppComponents = ComponentConfig.EMPTY_ARRAY;
    if (myProjectComponents == null) myProjectComponents = ComponentConfig.EMPTY_ARRAY;
    if (myModuleComponents == null) myModuleComponents = ComponentConfig.EMPTY_ARRAY;

    StringInterner interner = new StringInterner();
    List<Element> extensions = copyElements(pluginBean.extensions, interner);
    if (extensions != null) {
      myExtensions = MultiMap.createSmart();
      for (Element extension : extensions) {
        myExtensions.putValue(ExtensionsAreaImpl.extractEPName(extension), extension);
      }
    }

    List<Element> extensionPoints = copyElements(pluginBean.extensionPoints, interner);
    if (extensionPoints != null) {
      myExtensionsPoints = MultiMap.createSmart();
      for (Element extensionPoint : extensionPoints) {
        myExtensionsPoints.putValue(
            StringUtil.notNullize(
                extensionPoint.getAttributeValue(ExtensionsAreaImpl.ATTRIBUTE_AREA)),
            extensionPoint);
      }
    }

    myActionsElements = copyElements(pluginBean.actions, interner);

    if (pluginBean.modules != null && !pluginBean.modules.isEmpty()) {
      myModules = pluginBean.modules;
    }
  }
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      final Component orig =
          super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (myPluginDescriptor != null) {
        myNameLabel.setText(myPluginDescriptor.getName());
        final PluginId pluginId = myPluginDescriptor.getPluginId();
        final String idString = pluginId.getIdString();
        if (myPluginDescriptor.isBundled()) {
          myBundledLabel.setText("Bundled");
        } else {
          final String host = myPlugin2host.get(idString);
          if (host != null) {
            String presentableUrl = VfsUtil.urlToPath(host);
            final int idx = presentableUrl.indexOf('/');
            if (idx > -1) {
              presentableUrl = presentableUrl.substring(0, idx);
            }
            myBundledLabel.setText("From " + presentableUrl);
          } else {
            if (PluginManagerUISettings.getInstance().getInstalledPlugins().contains(idString)) {
              myBundledLabel.setText("From repository");
            } else {
              myBundledLabel.setText("Custom");
            }
          }
        }
        if (myPluginDescriptor instanceof IdeaPluginDescriptorImpl
            && ((IdeaPluginDescriptorImpl) myPluginDescriptor).isDeleted()) {
          myNameLabel.setIcon(AllIcons.Actions.Clean);
        } else if (hasNewerVersion(pluginId)) {
          myNameLabel.setIcon(AllIcons.Nodes.Pluginobsolete);
          myPanel.setToolTipText("Newer version of the plugin is available");
        } else {
          myNameLabel.setIcon(AllIcons.Nodes.Plugin);
        }

        final Color fg = orig.getForeground();
        final Color bg = orig.getBackground();
        final Color grayedFg = isSelected ? fg : Color.GRAY;

        myPanel.setBackground(bg);
        myNameLabel.setBackground(bg);
        myBundledLabel.setBackground(bg);

        myNameLabel.setForeground(fg);
        final boolean wasUpdated = wasUpdated(pluginId);
        if (wasUpdated || PluginManager.getPlugin(pluginId) == null) {
          if (!isSelected) {
            myNameLabel.setForeground(FileStatus.COLOR_ADDED);
          }
          if (wasUpdated) {
            myPanel.setToolTipText(
                "Plugin was updated to the newest version. Changes will be available after restart");
          } else {
            myPanel.setToolTipText("Plugin will be activated after restart.");
          }
        }
        myBundledLabel.setForeground(grayedFg);

        final Set<PluginId> required = myDependentToRequiredListMap.get(pluginId);
        if (required != null && required.size() > 0) {
          myNameLabel.setForeground(Color.RED);

          final StringBuilder s = new StringBuilder();
          if (myEnabled.get(pluginId) == null) {
            s.append("Plugin was not loaded.\n");
          }
          if (required.contains(PluginId.getId("com.intellij.modules.ultimate"))) {
            s.append("The plugin requires IntelliJ IDEA Ultimate");
          } else {
            s.append("Required plugin").append(required.size() == 1 ? " \"" : "s \"");
            s.append(
                StringUtil.join(
                    required,
                    new Function<PluginId, String>() {
                      @Override
                      public String fun(final PluginId id) {
                        final IdeaPluginDescriptor plugin = PluginManager.getPlugin(id);
                        return plugin == null ? id.getIdString() : plugin.getName();
                      }
                    },
                    ","));

            s.append(required.size() == 1 ? "\" is not enabled!" : "\" are not enabled!");
          }
          myPanel.setToolTipText(s.toString());
        }

        if (PluginManager.isIncompatible(myPluginDescriptor)) {
          myPanel.setToolTipText(
              IdeBundle.message(
                  "plugin.manager.incompatible.tooltip.warning",
                  ApplicationNamesInfo.getInstance().getFullProductName()));
          myNameLabel.setForeground(Color.red);
        }
      }

      return myPanel;
    }
コード例 #14
0
  @Override
  public void initComponent() {
    ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
    List<Sdk> sdkList = new ArrayList<Sdk>();

    sdkList.addAll(GoSdkUtil.getSdkOfType(GoSdkType.getInstance(), jdkTable));

    for (Sdk sdk : sdkList) {
      GoSdkData sdkData = (GoSdkData) sdk.getSdkAdditionalData();

      boolean needsUpgrade = sdkData == null;
      try {
        if (!needsUpgrade) {
          sdkData.checkValid();
        }
      } catch (ConfigurationException ex) {
        needsUpgrade = true;
      }

      if (!needsUpgrade) continue;

      needsUpgrade = false;
      GoSdkData data = GoSdkUtil.testGoogleGoSdk(sdk.getHomePath());

      if (data == null) needsUpgrade = true;

      try {
        if (data != null) {
          data.checkValid();
        }
      } catch (ConfigurationException ex) {
        needsUpgrade = true;
      }

      if (needsUpgrade) {
        Notifications.Bus.notify(
            new Notification(
                "Go SDK validator",
                "Corrupt Go SDK",
                getContent("Go", sdk.getName()),
                NotificationType.WARNING),
            myProject);
      }

      SdkModificator sdkModificator = sdk.getSdkModificator();
      sdkModificator.setSdkAdditionalData(data);
      sdkModificator.commitChanges();
    }

    sdkList.clear();
    sdkList.addAll(GoSdkUtil.getSdkOfType(GoAppEngineSdkType.getInstance(), jdkTable));

    Boolean hasGAESdk = sdkList.size() > 0;

    for (Sdk sdk : sdkList) {
      GoAppEngineSdkData sdkData = (GoAppEngineSdkData) sdk.getSdkAdditionalData();

      if (sdkData == null || sdkData.TARGET_ARCH == null || sdkData.TARGET_OS == null) {
        Notifications.Bus.notify(
            new Notification(
                "Go AppEngine SDK validator",
                "Corrupt Go App Engine SDK",
                getContent("Go App Engine", sdk.getName()),
                NotificationType.WARNING),
            myProject);

        continue;
      }

      boolean needsUpgrade = false;
      try {
        sdkData.checkValid();
      } catch (ConfigurationException ex) {
        needsUpgrade = true;
      }

      if (!needsUpgrade) continue;

      needsUpgrade = false;
      GoAppEngineSdkData data = GoSdkUtil.testGoAppEngineSdk(sdk.getHomePath());

      if (data == null) needsUpgrade = true;

      try {
        if (data != null) {
          data.checkValid();
        }
      } catch (ConfigurationException ex) {
        needsUpgrade = true;
      }

      // GAE SDK auto-update needs a bit more love
      if (data != null && !(new File(data.GOAPP_BIN_PATH)).exists()) {
        needsUpgrade = true;
      }

      if (needsUpgrade) {
        Notifications.Bus.notify(
            new Notification(
                "Go AppEngine SDK validator",
                "Corrupt Go App Engine SDK",
                getContent("Go AppEngine", sdk.getName()),
                NotificationType.WARNING),
            myProject);
      }

      SdkModificator sdkModificator = sdk.getSdkModificator();
      sdkModificator.setSdkAdditionalData(data);
      sdkModificator.commitChanges();
    }

    if (hasGAESdk) {
      String sysAppEngineDevServerPath = GoSdkUtil.getAppEngineDevServer();
      if (sysAppEngineDevServerPath.isEmpty())
        Notifications.Bus.notify(
            new Notification(
                "Go AppEngine SDK validator",
                "Problem with env variables",
                getInvalidAPPENGINE_DEV_APPSERVEREnvMessage(),
                NotificationType.WARNING,
                NotificationListener.URL_OPENING_LISTENER),
            myProject);
    }

    PluginDescriptor pluginDescriptor =
        PluginManager.getPlugin(PluginId.getId("ro.redeul.google.go"));
    if (pluginDescriptor != null) {
      String version = ((IdeaPluginDescriptorImpl) pluginDescriptor).getVersion();

      if (version.endsWith("-dev")
          && !System.getProperty("go.skip.dev.warn", "false").equals("true")) {
        Notifications.Bus.notify(
            new Notification(
                "Go plugin notice",
                "Development version detected",
                getDevVersionMessage(),
                NotificationType.WARNING,
                null),
            myProject);
      }
    }

    super.initComponent();
  }
コード例 #15
0
  @NotNull
  @SuppressWarnings("ConstantConditions")
  public static IdeaPluginDescriptor getPlugin() {

    return PluginManager.getPlugin(PluginId.getId(PLUGIN_ID));
  }
コード例 #16
0
 public void registerExtensionPoint(String pluginName, Element extensionPointElement) {
   registerExtensionPoint(
       new DefaultPluginDescriptor(PluginId.getId(pluginName)), extensionPointElement);
 }
コード例 #17
0
 public void registerExtension(final String pluginName, final Element extensionElement) {
   registerExtension(new DefaultPluginDescriptor(PluginId.getId(pluginName)), extensionElement);
 }
コード例 #18
0
 // Get version info of our Plugin
 private String getPluginVersion() {
   final IdeaPluginDescriptor plugin =
       PluginManager.getPlugin(PluginId.getId("com.microsoft.vso.idea"));
   final String v = plugin != null ? plugin.getVersion() : DEFAULT_VERSION;
   return StringUtils.isNotEmpty(v) ? v : DEFAULT_VERSION;
 }