Search in sources :

Example 1 with Artifact

use of com.intellij.facet.frameworks.beans.Artifact in project intellij-community by JetBrains.

the class FileSetVersionsFetcherBase method fetchVersions.

@NotNull
@Override
public List<FS> fetchVersions() {
    ApplicationManagerEx.getApplicationEx().assertTimeConsuming();
    final Artifact[] versions;
    if (myGroupId != null) {
        versions = LibrariesDownloadAssistant.getVersions(myGroupId, myLocalUrls);
    } else {
        versions = LibrariesDownloadAssistant.getVersions(myLocalUrls);
    }
    final List<FS> result = new ArrayList<>();
    for (Artifact version : versions) {
        final ArtifactItem[] items = version.getItems();
        final List<F> files = new ArrayList<>();
        for (ArtifactItem item : items) {
            String url = item.getUrl();
            final String prefix = version.getUrlPrefix();
            if (url == null) {
                if (prefix != null) {
                    url = prefix + item.getName();
                }
            } else {
                url = prependPrefix(url, prefix);
            }
            assert url != null;
            files.add(createFileDescription(item, url, prefix));
        }
        result.add(createVersion(version, files));
    }
    Collections.sort(result, VERSIONS_COMPARATOR);
    return result;
}
Also used : ArtifactItem(com.intellij.facet.frameworks.beans.ArtifactItem) ArrayList(java.util.ArrayList) Artifact(com.intellij.facet.frameworks.beans.Artifact) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Artifact

use of com.intellij.facet.frameworks.beans.Artifact in project intellij-community by JetBrains.

the class VersionsComponent method createComboBox.

private JComboBox createComboBox(String ri) {
    final JComboBox comboBox = new JComboBox();
    List<Artifact> versions = getSupportedVersions(ri);
    comboBox.setModel(new CollectionComboBoxModel(versions, null));
    comboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            updateCurrentVersion(comboBox);
        }
    });
    return comboBox;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) Artifact(com.intellij.facet.frameworks.beans.Artifact)

Example 3 with Artifact

use of com.intellij.facet.frameworks.beans.Artifact in project intellij-community by JetBrains.

the class VersionsComponent method createRadioButton.

private JRadioButton createRadioButton(final String ri) {
    final JRadioButton radioButton = new JRadioButton(ri);
    radioButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            for (Pair<JRadioButton, JComboBox> pair : myButtons.values()) {
                if (pair.getFirst().equals(radioButton)) {
                    JComboBox comboBox = pair.second;
                    comboBox.setEnabled(true);
                    Artifact currentVersion = getCurrentVersion(ri);
                    if (currentVersion != null) {
                        comboBox.setSelectedItem(currentVersion);
                    } else {
                        if (comboBox.getSelectedIndex() < 0) {
                            comboBox.setSelectedItem(getAppropriateVersion(getSupportedVersions(ri)));
                        } else {
                            // activate already selected
                            updateCurrentVersion(comboBox);
                        }
                    }
                } else {
                    pair.second.setEnabled(false);
                }
            }
        }
    });
    return radioButton;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Artifact(com.intellij.facet.frameworks.beans.Artifact) Pair(com.intellij.openapi.util.Pair)

Example 4 with Artifact

use of com.intellij.facet.frameworks.beans.Artifact in project intellij-community by JetBrains.

the class VersionsComponent method addSingletonReferenceImplementationUI.

private void addSingletonReferenceImplementationUI(@NotNull final String ri) {
    JComboBox comboBox = createComboBox(ri);
    addToPanel(new JLabel(ri), comboBox);
    Artifact version = getCurrentVersion(ri);
    if (version != null) {
        comboBox.setSelectedItem(version);
    }
}
Also used : Artifact(com.intellij.facet.frameworks.beans.Artifact)

Example 5 with Artifact

use of com.intellij.facet.frameworks.beans.Artifact in project intellij-community by JetBrains.

the class VersionsComponent method updateCurrentVersion.

private void updateCurrentVersion(JComboBox comboBox) {
    final Artifact versionInfo = getSelectedVersion(comboBox);
    if (versionInfo != null) {
        myCurrentVersion = versionInfo;
        myValidator.setDescription(getFacetLibrariesValidatorDescription(versionInfo));
        myValidator.setRequiredLibraries(getRequiredLibraries(versionInfo));
    }
}
Also used : Artifact(com.intellij.facet.frameworks.beans.Artifact)

Aggregations

Artifact (com.intellij.facet.frameworks.beans.Artifact)5 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ArtifactItem (com.intellij.facet.frameworks.beans.ArtifactItem)1 Pair (com.intellij.openapi.util.Pair)1 CollectionComboBoxModel (com.intellij.ui.CollectionComboBoxModel)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1