Search in sources :

Example 1 with ProjectExternalDependency

use of com.intellij.externalDependencies.ProjectExternalDependency in project intellij by bazelbuild.

the class PluginDependencyHelper method addDependency.

/**
 * Adds dependency, or replaces existing dependency of same type. Doesn't trigger any update
 * checking
 */
private static void addDependency(Project project, DependencyOnPlugin newDep) {
    ExternalDependenciesManager manager = ExternalDependenciesManager.getInstance(project);
    List<ProjectExternalDependency> deps = Lists.newArrayList(manager.getAllDependencies());
    boolean added = false;
    for (int i = 0; i < deps.size(); i++) {
        ProjectExternalDependency dep = deps.get(i);
        if (!(dep instanceof DependencyOnPlugin)) {
            continue;
        }
        DependencyOnPlugin pluginDep = (DependencyOnPlugin) dep;
        if (pluginDep.getPluginId().equals(newDep.getPluginId())) {
            added = true;
            deps.set(i, newDep);
        }
    }
    if (!added) {
        deps.add(newDep);
    }
    manager.setAllDependencies(deps);
}
Also used : ExternalDependenciesManager(com.intellij.externalDependencies.ExternalDependenciesManager) ProjectExternalDependency(com.intellij.externalDependencies.ProjectExternalDependency) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin)

Example 2 with ProjectExternalDependency

use of com.intellij.externalDependencies.ProjectExternalDependency in project intellij-community by JetBrains.

the class ExternalDependenciesConfigurable method replaceDependency.

private void replaceDependency(DependencyOnPlugin original, JBList dependenciesList) {
    DependencyOnPlugin dependency = editPluginDependency(dependenciesList, original);
    if (dependency != null) {
        for (ProjectExternalDependency dependency1 : new ArrayList<>(myListModel.getItems())) {
            if (dependency1 instanceof DependencyOnPlugin && ((DependencyOnPlugin) dependency1).getPluginId().equals(dependency.getPluginId())) {
                myListModel.remove(dependency1);
            }
        }
        myListModel.add(dependency);
        dependenciesList.setSelectedValue(dependency, true);
    }
}
Also used : ProjectExternalDependency(com.intellij.externalDependencies.ProjectExternalDependency) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin)

Example 3 with ProjectExternalDependency

use of com.intellij.externalDependencies.ProjectExternalDependency in project intellij-community by JetBrains.

the class ExternalDependenciesManagerImpl method loadState.

@Override
public void loadState(ExternalDependenciesState state) {
    ArrayList<ProjectExternalDependency> oldDependencies = new ArrayList<>(myDependencies);
    myDependencies.clear();
    for (DependencyOnPluginState dependency : state.myDependencies) {
        myDependencies.add(new DependencyOnPlugin(dependency.myId, dependency.myMinVersion, dependency.myMaxVersion, dependency.myChannel));
    }
    if (!oldDependencies.equals(myDependencies) && !myDependencies.isEmpty()) {
        StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {

            @Override
            public void run() {
                CheckRequiredPluginsActivity.runCheck(myProject);
            }
        });
    }
}
Also used : ArrayList(java.util.ArrayList) ProjectExternalDependency(com.intellij.externalDependencies.ProjectExternalDependency) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin)

Example 4 with ProjectExternalDependency

use of com.intellij.externalDependencies.ProjectExternalDependency in project intellij by bazelbuild.

the class PluginDependencyHelper method removeDependencyOnOldPlugin.

/**
 * Removes a project depedency on a given plugin, if one exists. Doesn't trigger any update
 * checking. This is to handle migration of the IntelliJ-with-Bazel plugin to a different plugin
 * ID. This is introduced in v1.9, remove in v2.2+
 */
@Deprecated
public static void removeDependencyOnOldPlugin(Project project, String pluginId) {
    ExternalDependenciesManager manager = ExternalDependenciesManager.getInstance(project);
    List<ProjectExternalDependency> deps = Lists.newArrayList(manager.getAllDependencies());
    Iterator<ProjectExternalDependency> iter = deps.iterator();
    while (iter.hasNext()) {
        ProjectExternalDependency dep = iter.next();
        if (!(dep instanceof DependencyOnPlugin)) {
            continue;
        }
        DependencyOnPlugin pluginDep = (DependencyOnPlugin) dep;
        if (pluginDep.getPluginId().equals(pluginId)) {
            iter.remove();
        }
    }
    manager.setAllDependencies(deps);
}
Also used : ExternalDependenciesManager(com.intellij.externalDependencies.ExternalDependenciesManager) ProjectExternalDependency(com.intellij.externalDependencies.ProjectExternalDependency) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin)

Aggregations

DependencyOnPlugin (com.intellij.externalDependencies.DependencyOnPlugin)4 ProjectExternalDependency (com.intellij.externalDependencies.ProjectExternalDependency)4 ExternalDependenciesManager (com.intellij.externalDependencies.ExternalDependenciesManager)2 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)1 ArrayList (java.util.ArrayList)1