old libraries downloading panel replaced by new one from redesigned framework support dialog

This commit is contained in:
nik
2010-09-28 14:56:30 +04:00
parent ecc62832ca
commit 192c77766b
12 changed files with 98 additions and 637 deletions
@@ -1,72 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.facet.impl.ui.libraries;
import com.intellij.ide.util.ElementsChooser;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.util.Icons;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.util.Collection;
import java.util.List;
/**
* @author nik
*/
public class ChooseLibrariesDialog extends DialogWrapper {
private final LibraryElementChooser myChooser;
public ChooseLibrariesDialog(final Component parent, final List<Library> libraries) {
super(parent, true);
setTitle(ProjectBundle.message("dialog.title.select.libraries"));
setModal(true);
myChooser = new LibraryElementChooser(libraries);
init();
}
@Nullable
protected JComponent createCenterPanel() {
return myChooser;
}
public void markElements(final Collection<Library> elements) {
myChooser.markElements(elements);
}
public List<Library> getMarkedLibraries() {
return myChooser.getMarkedElements();
}
static class LibraryElementChooser extends ElementsChooser<Library> {
LibraryElementChooser(final List<Library> elements) {
super(elements, false);
}
protected Icon getItemIcon(final Library value) {
return Icons.LIBRARY_ICON;
}
protected String getItemText(@NotNull final Library value) {
return OrderEntryCellAppearanceUtils.forLibrary(value).getText();
}
}
}
@@ -141,7 +141,7 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator {
}
}
}
LibraryCompositionOptionsPanel panel = new LibraryCompositionOptionsPanel(myContext.getLibrariesContainer(), myLibrarySettings, mirrorsMap);
LibraryOptionsPanel panel = new LibraryOptionsPanel(myLibrarySettings, myContext.getLibrariesContainer(), false);
LibraryCompositionDialog dialog = new LibraryCompositionDialog(place, panel, mirrorsMap);
dialog.show();
onChange();
@@ -149,10 +149,10 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator {
}
private class LibraryCompositionDialog extends DialogWrapper {
private final LibraryCompositionOptionsPanel myPanel;
private final LibraryOptionsPanel myPanel;
private final LibraryDownloadingMirrorsMap myMirrorsMap;
private LibraryCompositionDialog(final JComponent parent, final LibraryCompositionOptionsPanel panel,
private LibraryCompositionDialog(final JComponent parent, final LibraryOptionsPanel panel,
final LibraryDownloadingMirrorsMap mirrorsMap) {
super(parent, true);
setTitle(IdeBundle.message("specify.libraries.dialog.title"));
@@ -167,9 +167,9 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator {
protected void doOKAction() {
myPanel.apply();
final LibraryCompositionSettings settings = myPanel.getLibraryCompositionSettings();
final LibraryCompositionSettings settings = myPanel.getSettings();
final LibrariesContainer librariesContainer = myContext.getLibrariesContainer();
if (settings.downloadFiles(myMirrorsMap, librariesContainer, myPanel.getMainPanel(), false)) {
if (settings.downloadFiles(myMirrorsMap, myPanel.getMainPanel(), false)) {
ModifiableRootModel rootModel = myContext.getModifiableRootModel();
if (rootModel == null) {
final ModifiableRootModel model = ModuleRootManager.getInstance(myContext.getModule()).getModifiableModel();
@@ -1,189 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.facet.impl.ui.libraries.LibraryCompositionOptionsPanel">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="565" height="331"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="eff68" binding="myMissingLibrariesPanel" layout-manager="CardLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="450" height="-1"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3966c" class="javax.swing.JLabel" binding="myMissingLibrariesLabel">
<constraints>
<card name="shown"/>
</constraints>
<properties>
<text value="Label"/>
</properties>
</component>
<component id="3125c" class="javax.swing.JLabel" binding="myHiddenLabel">
<constraints>
<card name="hidden"/>
</constraints>
<properties>
<text value="Label"/>
</properties>
</component>
</children>
</grid>
<grid id="d8a5d" binding="myNewLibraryPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="c7640" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="fa75f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="311de" class="javax.swing.JCheckBox" binding="myDownloadMissingJarsCheckBox" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="true"/>
<text resource-bundle="messages/ProjectBundle" key="composing.library.download.missing.jars.to"/>
</properties>
</component>
<hspacer id="150bc">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
<grid id="1f138" binding="myMirrorsPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<component id="bbb02" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myDirectoryField">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="3" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="f7f4" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="57e88" class="javax.swing.JButton" binding="myAddJarsButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ProjectBundle" key="composing.library.add.jars.button"/>
</properties>
</component>
<hspacer id="513f7">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
<grid id="8fa51" binding="myLibraryPropertiesPanel" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="431af" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="2cb6b"/>
<text resource-bundle="messages/ProjectBundle" key="composing.library.name.label"/>
</properties>
</component>
<component id="2cb6b" class="javax.swing.JTextField" binding="myLibraryNameField">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="110" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="9cb54" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="781ad"/>
<text resource-bundle="messages/ProjectBundle" key="composing.library.level.label"/>
</properties>
</component>
<component id="781ad" class="javax.swing.JComboBox" binding="myLibraryLevelComboBox">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model/>
</properties>
</component>
<component id="1fd6d" class="javax.swing.JSeparator">
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="7" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="2525e" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ProjectBundle" key="composing.liibrary.new.library.label"/>
</properties>
</component>
<hspacer id="31c96">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</children>
</grid>
<vspacer id="c39ad">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</form>
@@ -1,202 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.facet.impl.ui.libraries;
import com.intellij.facet.ui.libraries.LibraryDownloadInfo;
import com.intellij.facet.ui.libraries.LibraryInfo;
import com.intellij.facet.ui.libraries.RemoteRepositoryInfo;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.util.MutualMap;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author nik
*/
public class LibraryCompositionOptionsPanel {
private final MutualMap<LibrariesContainer.LibraryLevel, String> myLibraryLevels = new MutualMap<LibrariesContainer.LibraryLevel, String>(true);
private JPanel myMainPanel;
private JButton myAddJarsButton;
private JCheckBox myDownloadMissingJarsCheckBox;
private TextFieldWithBrowseButton myDirectoryField;
private JComboBox myLibraryLevelComboBox;
private JTextField myLibraryNameField;
private JPanel myMissingLibrariesPanel;
private JPanel myNewLibraryPanel;
private JPanel myLibraryPropertiesPanel;
private JPanel myMirrorsPanel;
private JLabel myMissingLibrariesLabel;
private JLabel myHiddenLabel;
private final List<VirtualFile> myAddedJars = new ArrayList<VirtualFile>();
private final LibraryCompositionSettings myLibraryCompositionSettings;
private final LibraryDownloadingMirrorsMap myMirrorsMap;
private List<RemoteRepositoryMirrorPanel> myMirrorPanelsList;
public LibraryCompositionOptionsPanel(final @NotNull LibrariesContainer librariesContainer,
final @NotNull LibraryCompositionSettings libraryCompositionSettings,
final @NotNull LibraryDownloadingMirrorsMap mirrorsMap) {
myLibraryCompositionSettings = libraryCompositionSettings;
myMirrorsMap = mirrorsMap;
addMirrorsPanels();
myDirectoryField.addBrowseFolderListener(ProjectBundle.message("file.chooser.directory.for.downloaded.libraries.title"),
ProjectBundle.message("file.chooser.directory.for.downloaded.libraries.description"), null,
FileChooserDescriptorFactory.createSingleFolderDescriptor());
myAddJarsButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
showFileChooser();
}
});
myDownloadMissingJarsCheckBox.setSelected(myLibraryCompositionSettings.isDownloadLibraries());
myDownloadMissingJarsCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
updateAll();
}
});
myLibraryLevels.put(LibrariesContainer.LibraryLevel.GLOBAL, ProjectBundle.message("combobox.item.global.library"));
myLibraryLevels.put(LibrariesContainer.LibraryLevel.PROJECT, ProjectBundle.message("combobox.item.project.library"));
myLibraryLevels.put(LibrariesContainer.LibraryLevel.MODULE, ProjectBundle.message("combobox.item.module.library"));
for (String level : myLibraryLevels.getValues()) {
myLibraryLevelComboBox.addItem(level);
}
myLibraryLevelComboBox.setSelectedItem(myLibraryLevels.getValue(myLibraryCompositionSettings.getLibraryLevel()));
myLibraryNameField.setText(myLibraryCompositionSettings.getLibraryName());
myDirectoryField.setText(FileUtil.toSystemDependentName(myLibraryCompositionSettings.getDirectoryForDownloadedLibrariesPath()));
String jars = RequiredLibrariesInfo.getLibrariesPresentableText(myLibraryCompositionSettings.getLibraryInfos());
myHiddenLabel.setText(UIUtil.toHtml(ProjectBundle.message("label.text.libraries.are.missing", jars)));
updateAll();
myMissingLibrariesPanel.getPreferredSize();
myMainPanel.validate();
}
public LibraryCompositionSettings getLibraryCompositionSettings() {
return myLibraryCompositionSettings;
}
private void addMirrorsPanels() {
myMirrorsPanel.setLayout(new VerticalFlowLayout());
myMirrorPanelsList = new ArrayList<RemoteRepositoryMirrorPanel>();
Set<String> repositories = new HashSet<String>();
LibraryInfo[] libraryInfos = myLibraryCompositionSettings.getLibraryInfos();
for (LibraryInfo libraryInfo : libraryInfos) {
LibraryDownloadInfo downloadingInfo = libraryInfo.getDownloadingInfo();
if (downloadingInfo != null) {
RemoteRepositoryInfo repositoryInfo = downloadingInfo.getRemoteRepository();
if (repositoryInfo != null && repositories.add(repositoryInfo.getId())) {
RemoteRepositoryMirrorPanel mirrorPanel = new RemoteRepositoryMirrorPanel(repositoryInfo, myMirrorsMap);
myMirrorPanelsList.add(mirrorPanel);
myMirrorsPanel.add(mirrorPanel.getPanel());
}
}
}
}
private void showFileChooser() {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
descriptor.setTitle(IdeBundle.message("file.chooser.select.paths.title"));
descriptor.setDescription(IdeBundle.message("file.chooser.multiselect.description"));
final VirtualFile[] files = FileChooser.chooseFiles(myAddJarsButton, descriptor, getBaseDirectory());
ContainerUtil.addAll(myAddedJars, files);
updateAll();
}
@Nullable
private VirtualFile getBaseDirectory() {
String path = myLibraryCompositionSettings.getBaseDirectoryForDownloadedFiles();
VirtualFile dir = LocalFileSystem.getInstance().findFileByPath(path);
if (dir == null) {
path = path.substring(0, path.lastIndexOf('/'));
dir = LocalFileSystem.getInstance().findFileByPath(path);
}
return dir;
}
private void updateAll() {
String missingJarsText;
List<VirtualFile> roots = new ArrayList<VirtualFile>();
roots.addAll(myAddedJars);
RequiredLibrariesInfo.RequiredClassesNotFoundInfo info = new RequiredLibrariesInfo(myLibraryCompositionSettings.getLibraryInfos()).checkLibraries(
VfsUtil.toVirtualFileArray(roots), false);
if (info != null) {
missingJarsText = ProjectBundle.message("label.text.libraries.are.missing", info.getMissingJarsText());
}
else {
missingJarsText = ProjectBundle.message("label.text.all.library.files.found");
}
myMissingLibrariesLabel.setText(UIUtil.toHtml(missingJarsText));
((CardLayout)myMissingLibrariesPanel.getLayout()).show(myMissingLibrariesPanel, "shown");
if (info == null) {
myDownloadMissingJarsCheckBox.setSelected(false);
}
myNewLibraryPanel.setVisible(info != null || !myAddedJars.isEmpty());
myLibraryPropertiesPanel.setVisible(!myAddedJars.isEmpty() || myDownloadMissingJarsCheckBox.isSelected());
myDownloadMissingJarsCheckBox.setEnabled(info != null);
myDirectoryField.setEnabled(myDownloadMissingJarsCheckBox.isSelected());
UIUtil.setEnabled(myMirrorsPanel, myDownloadMissingJarsCheckBox.isSelected(), true);
}
public void saveSelectedRepositoriesMirrors(final LibraryDownloadingMirrorsMap mirrorsMap) {
for (RemoteRepositoryMirrorPanel mirrorPanel : myMirrorPanelsList) {
mirrorsMap.setMirror(mirrorPanel.getRemoteRepository(), mirrorPanel.getSelectedMirror());
}
}
public void apply() {
saveSelectedRepositoriesMirrors(myMirrorsMap);
if (myDownloadMissingJarsCheckBox.isSelected()) {
myLibraryCompositionSettings.setDownloadLibraries(true);
myLibraryCompositionSettings.setDirectoryForDownloadedLibrariesPath(FileUtil.toSystemIndependentName(myDirectoryField.getText()));
}
else {
myLibraryCompositionSettings.setDownloadLibraries(false);
}
myLibraryCompositionSettings.setLibraryLevel(myLibraryLevels.getKey((String)myLibraryLevelComboBox.getSelectedItem()));
myLibraryCompositionSettings.setLibraryName(myLibraryNameField.getText());
}
public JPanel getMainPanel() {
return myMainPanel;
}
}
@@ -24,21 +24,18 @@ import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author nik
*/
public class LibraryCompositionSettings implements Disposable {
@NonNls private static final String DEFAULT_LIB_FOLDER = "lib";
private final LibraryInfo[] myLibraryInfos;
private final String myBaseDirectoryForDownloadedFiles;
@@ -116,14 +113,11 @@ public class LibraryCompositionSettings implements Disposable {
return myTitle;
}
public boolean downloadFiles(final @NotNull LibraryDownloadingMirrorsMap mirrorsMap,
@NotNull LibrariesContainer librariesContainer, final @NotNull JComponent parent,
boolean all) {
public boolean downloadFiles(final @NotNull LibraryDownloadingMirrorsMap mirrorsMap, final @NotNull JComponent parent, boolean all) {
if (myDownloadLibraries) {
RequiredLibrariesInfo requiredLibraries = new RequiredLibrariesInfo(getLibraryInfos());
List<VirtualFile> roots = new ArrayList<VirtualFile>();
VirtualFile[] jars = VfsUtil.toVirtualFileArray(roots);
VirtualFile[] jars = myLibraryEditor != null ? myLibraryEditor.getFiles(OrderRootType.CLASSES) : VirtualFile.EMPTY_ARRAY;
RequiredLibrariesInfo.RequiredClassesNotFoundInfo info = requiredLibraries.checkLibraries(jars, all);
if (info != null) {
LibraryDownloadInfo[] downloadingInfos = LibraryDownloader.getDownloadingInfos(info.getLibraryInfos());
@@ -21,7 +21,7 @@
<text value="Download from &amp;Maven repository"/>
</properties>
</component>
<component id="f63e3" class="javax.swing.JRadioButton">
<component id="f63e3" class="javax.swing.JRadioButton" binding="myDoNotCreateRadioButton">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
@@ -37,38 +37,6 @@
<text value="Pick up files from &amp;disk"/>
</properties>
</component>
<grid id="4f3d8" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="37d09" class="javax.swing.JLabel" binding="myMessageLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="&lt;html&gt;{} jars will be downloaded into &lt;b&gt;lib&lt;/b&gt; directory&lt;br&gt; Project level library &lt;b&gt;spring&lt;/b&gt; will be created&lt;/html&gt;"/>
</properties>
</component>
<hspacer id="2f96b">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="6cdd8" class="javax.swing.JButton" binding="myConfigureButton" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="2" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Configure..."/>
</properties>
</component>
</children>
</grid>
<vspacer id="79970">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
@@ -104,6 +72,56 @@
</hspacer>
</children>
</grid>
<grid id="7ea1" binding="myConfigurationPanel" layout-manager="CardLayout" hgap="0" vgap="0">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="9c6d3" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<card name="configure"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="bbed6" class="javax.swing.JLabel" binding="myMessageLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<text value="&lt;html&gt;{} jars will be downloaded into &lt;b&gt;lib&lt;/b&gt; directory&lt;br&gt; Project level library &lt;b&gt;spring&lt;/b&gt; will be created&lt;/html&gt;"/>
</properties>
</component>
<hspacer id="6fd69">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="55035" class="javax.swing.JButton" binding="myConfigureButton" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Configure..."/>
</properties>
</component>
</children>
</grid>
<grid id="17c14" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<card name="empty"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</children>
</grid>
<buttonGroups>
@@ -32,6 +32,7 @@ import com.intellij.ui.ColoredListCellRenderer;
import com.intellij.ui.SortedComboBoxModel;
import com.intellij.util.PathUtil;
import com.intellij.util.ui.RadioButtonEnumModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -52,11 +53,13 @@ public class LibraryOptionsPanel {
private JButton myConfigureButton;
private JComboBox myExistingLibraryComboBox;
private JRadioButton myUseExistingLibraryRadioButton;
private JRadioButton myDoNotCreateRadioButton;
private JPanel myConfigurationPanel;
private ButtonGroup myButtonGroup;
private LibraryCompositionSettings mySettings;
private LibrariesContainer myLibrariesContainer;
private List<Library> myLibraries;
private final LibraryCompositionSettings mySettings;
private final LibrariesContainer myLibrariesContainer;
private final List<Library> myLibraries;
private enum Choice {
USE_EXISTING,
@@ -67,7 +70,9 @@ public class LibraryOptionsPanel {
private RadioButtonEnumModel<Choice> myButtonEnumModel;
public LibraryOptionsPanel(LibraryCompositionSettings settings, LibrariesContainer librariesContainer) {
public LibraryOptionsPanel(@NotNull LibraryCompositionSettings settings,
@NotNull LibrariesContainer librariesContainer,
final boolean showDoNotCreateOption) {
mySettings = settings;
myLibrariesContainer = librariesContainer;
myLibraries = calculateSuitableLibraries();
@@ -81,6 +86,7 @@ public class LibraryOptionsPanel {
});
final boolean librariesFound = !myLibraries.isEmpty();
myDoNotCreateRadioButton.setVisible(showDoNotCreateOption);
myUseExistingLibraryRadioButton.setVisible(librariesFound);
myExistingLibraryComboBox.setVisible(librariesFound);
if (librariesFound) {
@@ -103,14 +109,14 @@ public class LibraryOptionsPanel {
public void actionPerformed(final ActionEvent e) {
switch (myButtonEnumModel.getSelected()) {
case DOWNLOAD:
new DownloadingOptionsDialog(myConfigureButton, mySettings).show();
new DownloadingOptionsDialog(myPanel, mySettings).show();
break;
case PICK_FILES:
if (mySettings.getLibraryEditor() == null) {
VirtualFile[] files = showFileChooser();
mySettings.addFilesToLibrary(files, OrderRootType.CLASSES);
}
EditLibraryDialog dialog = new EditLibraryDialog(myConfigureButton, mySettings);
EditLibraryDialog dialog = new EditLibraryDialog(myPanel, mySettings);
dialog.show();
break;
default:
@@ -142,7 +148,7 @@ public class LibraryOptionsPanel {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
descriptor.setTitle(IdeBundle.message("file.chooser.select.paths.title"));
descriptor.setDescription(IdeBundle.message("file.chooser.multiselect.description"));
return FileChooser.chooseFiles(myConfigureButton, descriptor, getBaseDirectory());
return FileChooser.chooseFiles(myPanel, descriptor, getBaseDirectory());
}
@Nullable
@@ -158,34 +164,18 @@ public class LibraryOptionsPanel {
private void updateState() {
myMessageLabel.setForeground(Color.black);
myMessageLabel.setVisible(true);
myConfigureButton.setVisible(true);
String message = "";
boolean showConfigurePanel = true;
switch (myButtonEnumModel.getSelected()) {
case DOWNLOAD:
final String downloadPath = mySettings.getDirectoryForDownloadedLibrariesPath();
final String basePath = mySettings.getBaseDirectoryForDownloadedFiles();
String path;
if (FileUtil.startsWith(downloadPath, basePath)) {
path = FileUtil.getRelativePath(basePath, downloadPath, File.separatorChar);
}
else {
path = PathUtil.getFileName(downloadPath);
}
message = MessageFormat.format("{0} jar(s) will be downloaded into <b>{1}</b> directory <br>" +
"{2} library <b>{3}</b> will be created",
mySettings.getLibraryInfos().length,
path,
mySettings.getLibraryLevel(),
mySettings.getLibraryName());
message = getDownloadFilesMessage();
break;
case PICK_FILES:
NewLibraryEditor libraryEditor = mySettings.getLibraryEditor();
if (libraryEditor == null) {
myMessageLabel.setForeground(Color.red);
message = "Press Configure button to add classes to the library";
message = "Press 'Configure' button to add classes to the library";
}
else {
message = MessageFormat.format("{0} level library <b>{1}</b>" +
@@ -196,13 +186,33 @@ public class LibraryOptionsPanel {
}
break;
default:
myMessageLabel.setVisible(false);
myConfigureButton.setVisible(false);
//show the longest message on the hidden card to ensure that dialog won't jump if user selects another option
message = getDownloadFilesMessage();
showConfigurePanel = false;
}
((CardLayout)myConfigurationPanel.getLayout()).show(myConfigurationPanel, showConfigurePanel ? "configure" : "empty");
myMessageLabel.setText("<html>" + message + "</html>");
}
private String getDownloadFilesMessage() {
final String downloadPath = mySettings.getDirectoryForDownloadedLibrariesPath();
final String basePath = mySettings.getBaseDirectoryForDownloadedFiles();
String path;
if (FileUtil.startsWith(downloadPath, basePath)) {
path = FileUtil.getRelativePath(basePath, downloadPath, File.separatorChar);
}
else {
path = PathUtil.getFileName(downloadPath);
}
return MessageFormat.format("{0} jar(s) will be downloaded into <b>{1}</b> directory <br>" +
"{2} library <b>{3}</b> will be created",
mySettings.getLibraryInfos().length,
path,
mySettings.getLibraryLevel(),
mySettings.getLibraryName());
}
public LibraryCompositionSettings getSettings() {
return mySettings;
}
@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.facet.impl.ui.libraries.RemoteRepositoryMirrorPanel">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="354" height="27"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9ac48" class="javax.swing.JComboBox" binding="myMirrorComboBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="true"/>
</properties>
</component>
<component id="c19ff" class="javax.swing.JLabel" binding="myFromLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="9ac48"/>
<text resource-bundle="messages/ProjectBundle" key="composing.library.from.repository.label"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -1,57 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.facet.impl.ui.libraries;
import com.intellij.facet.ui.libraries.RemoteRepositoryInfo;
import com.intellij.openapi.project.ProjectBundle;
import javax.swing.*;
/**
* @author nik
*/
public class RemoteRepositoryMirrorPanel {
private JPanel myPanel;
private JComboBox myMirrorComboBox;
private JLabel myFromLabel;
private final RemoteRepositoryInfo myRemoteRepository;
public RemoteRepositoryMirrorPanel(final RemoteRepositoryInfo remoteRepository, final LibraryDownloadingMirrorsMap mirrorsMap) {
myRemoteRepository = remoteRepository;
myFromLabel.setText(ProjectBundle.message("composing.library.from.repository.label", remoteRepository.getPresentableName()));
updateComboBox(mirrorsMap);
}
public void updateComboBox(final LibraryDownloadingMirrorsMap mirrorsMap) {
myMirrorComboBox.removeAllItems();
for (String mirror : myRemoteRepository.getMirrors()) {
myMirrorComboBox.addItem(mirror);
}
myMirrorComboBox.setSelectedItem(mirrorsMap.getSelectedMirror(myRemoteRepository));
}
public JPanel getPanel() {
return myPanel;
}
public RemoteRepositoryInfo getRemoteRepository() {
return myRemoteRepository;
}
public String getSelectedMirror() {
return (String)myMirrorComboBox.getSelectedItem();
}
}
@@ -249,7 +249,7 @@ public class AddSupportForFrameworksPanel implements Disposable {
applyLibraryOptionsForSelected();
List<LibraryCompositionSettings> list = getLibrariesCompositionSettingsList();
for (LibraryCompositionSettings compositionSettings : list) {
if (!compositionSettings.downloadFiles(myMirrorsMap, myLibrariesContainer, myMainPanel, true)) return false;
if (!compositionSettings.downloadFiles(myMirrorsMap, myMainPanel, true)) return false;
}
return true;
}
@@ -80,7 +80,7 @@ public class FrameworkSupportNode extends CheckedTreeNode {
final LibraryCompositionSettings libraryCompositionSettings = getLibraryCompositionSettings();
if (myLibraryCompositionOptionsPanel == null || !myLibraryCompositionOptionsPanel.getSettings().equals(libraryCompositionSettings)) {
if (libraryCompositionSettings != null) {
myLibraryCompositionOptionsPanel = new LibraryOptionsPanel(libraryCompositionSettings, librariesContainer);
myLibraryCompositionOptionsPanel = new LibraryOptionsPanel(libraryCompositionSettings, librariesContainer, true);
}
else {
myLibraryCompositionOptionsPanel = null;
@@ -456,10 +456,6 @@ project.new.wizard.module.file.title=Module &file location:
label.text.please.select.desired.technologies=Please select the desired technologies
label.text.framework.support.description=This will download all needed libraries and create Facets in project configuration
label.text.libraries.will.be.downloaded.by.default=All needed libraries will be downloaded into ''lib'' folder by default
button.text.change.downloading.policy=&Change...
label.text.libraries.are.missing=The following files are missing: {0}.
label.text.all.library.files.found=All needed files found.
file.chooser.directory.for.downloaded.libraries.title=Directory for Downloaded Libraries
file.chooser.directory.for.downloaded.libraries.description=Downloaded libraries will be copied to selected directory
dialog.title.library.downloading.settings=Library Downloading Settings
@@ -467,14 +463,7 @@ directory.roots.copy.label=Copy library content to directory (optional):
combobox.item.global.library=global library
combobox.item.project.library=project library
combobox.item.module.library=module library
dialog.title.select.libraries=Select Libraries
composing.library.use.library.button=Use &Libraries...
composing.library.add.jars.button=&Pick files from disk...
composing.library.level.label=L&evel:
composing.library.name.label=&Name:
composing.library.download.missing.jars.to=&Download missing files to:
composing.liibrary.new.library.label=The following library will be created
composing.library.from.repository.label=&from {0}
dialog.title.add.frameworks.support=Add Frameworks Support
warning.message.some.required.libraries.wasn.t.downloaded=Some required library wasn't downloaded. Do you want to proceed without it?