"Add Framework Support" UI

This commit is contained in:
Dmitry Avdeev
2010-08-11 14:04:10 +04:00
parent 792102d5e7
commit 47ebc178a0
12 changed files with 692 additions and 18 deletions
@@ -0,0 +1,133 @@
<?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.DownloadingOptionsDialog">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="7" 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="500" height="228"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="54e08">
<constraints>
<grid row="6" 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>
<component id="604d3" class="javax.swing.JLabel" binding="myFilesToDownloadLabel">
<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>
<text value="&amp;Files to download:"/>
</properties>
</component>
<component id="dd86" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myDirectoryField">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="85001" class="javax.swing.JLabel" binding="myCopyDownloadedFilesToLabel">
<constraints>
<grid row="3" 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>
<text value="Copy downloaded files &amp;to:"/>
</properties>
</component>
<grid id="f9161" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" 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="523c" class="javax.swing.JLabel">
<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="14ad"/>
<text value="Library &amp;name:"/>
</properties>
</component>
<hspacer id="847ea">
<constraints>
<grid row="0" column="4" 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="14ad" class="javax.swing.JTextField" binding="myLibraryNameField">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="c4c11" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="2" 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="ffb30"/>
<text value="&amp;Level:"/>
</properties>
</component>
<component id="ffb30" class="javax.swing.JComboBox" binding="myLevelComboBox" default-binding="true">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<scrollpane id="117b3" class="com.intellij.ui.components.JBScrollPane">
<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>
<component id="45c8c" class="com.intellij.ui.CheckBoxList" binding="myFilesList">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<grid id="6bec" 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="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="b5e3e" class="javax.swing.JCheckBox" binding="myDownloadSourcesCheckBox" 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>
<focusable value="false"/>
<text value="Download &amp;sources"/>
</properties>
</component>
<hspacer id="598d">
<constraints>
<grid row="0" 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>
<component id="f9d9a" class="javax.swing.JCheckBox" binding="myDownloadJavadocsCheckBox" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<focusable value="false"/>
<text value="Download &amp;javadocs"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>
@@ -0,0 +1,101 @@
/*
* Copyright 2000-2010 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.LibraryInfo;
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.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.ui.CheckBoxList;
import com.intellij.ui.CollectionListModel;
import com.intellij.ui.EnumComboBoxModel;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import javax.swing.*;
import java.awt.*;
/**
* @author Dmitry Avdeev
*/
public class DownloadingOptionsDialog extends DialogWrapper {
private JPanel myPanel;
private CheckBoxList myFilesList;
private TextFieldWithBrowseButton myDirectoryField;
private JTextField myLibraryNameField;
private JComboBox myLevelComboBox;
private JCheckBox myDownloadSourcesCheckBox;
private JLabel myFilesToDownloadLabel;
private JLabel myCopyDownloadedFilesToLabel;
private JCheckBox myDownloadJavadocsCheckBox;
private final LibraryCompositionSettings mySettings;
protected DownloadingOptionsDialog(Component parent, LibraryCompositionSettings settings) {
super(parent, true);
setTitle("Downloading Options");
mySettings = settings;
myFilesList.setModel(new CollectionListModel(ContainerUtil.map2Array(settings.getLibraryInfos(), new Function<LibraryInfo, Object>() {
@Override
public Object fun(LibraryInfo libraryInfo) {
return new JCheckBox(libraryInfo.getPresentableName(), libraryInfo.isSelected());
}
})));
myFilesToDownloadLabel.setLabelFor(myFilesList);
myDirectoryField.addBrowseFolderListener(ProjectBundle.message("file.chooser.directory.for.downloaded.libraries.title"),
ProjectBundle.message("file.chooser.directory.for.downloaded.libraries.description"), null,
FileChooserDescriptorFactory.createSingleFolderDescriptor());
myCopyDownloadedFilesToLabel.setLabelFor(myDirectoryField);
myDirectoryField.setText(settings.getDirectoryForDownloadedLibrariesPath());
myDownloadSourcesCheckBox.setSelected(settings.isDownloadSources());
myDownloadJavadocsCheckBox.setSelected(settings.isDownloadJavadocs());
myLibraryNameField.setText(settings.getLibraryName());
myLevelComboBox.setModel(new EnumComboBoxModel<LibrariesContainer.LibraryLevel>(LibrariesContainer.LibraryLevel.class));
myLevelComboBox.setSelectedItem(settings.getLibraryLevel());
init();
}
@Override
protected JComponent createCenterPanel() {
return myPanel;
}
@Override
public JComponent getPreferredFocusedComponent() {
return myFilesList;
}
@Override
protected void doOKAction() {
mySettings.setLibraryName(myLibraryNameField.getText());
mySettings.setLibraryLevel((LibrariesContainer.LibraryLevel)myLevelComboBox.getSelectedItem());
mySettings.setDirectoryForDownloadedLibrariesPath(myDirectoryField.getText());
LibraryInfo[] libraryInfos = mySettings.getLibraryInfos();
for (int i = 0, libraryInfosLength = libraryInfos.length; i < libraryInfosLength; i++) {
LibraryInfo info = libraryInfos[i];
info.setSelected(myFilesList.isItemSelected(i));
}
mySettings.setDownloadSources(myDownloadSourcesCheckBox.isSelected());
mySettings.setDownloadJavadocs(myDownloadJavadocsCheckBox.isSelected());
super.doOKAction();
}
}
@@ -0,0 +1,81 @@
<?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.EditLibraryDialog">
<grid id="27dc6" binding="myPanel" 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="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="d0dbf" binding="myEditorPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="8ed98" 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="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="da5e2" class="javax.swing.JLabel">
<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>
<text value="Library &amp;name:"/>
</properties>
</component>
<hspacer id="7b679">
<constraints>
<grid row="0" 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>
<component id="4e9fe" class="javax.swing.JTextField" binding="myTextField1" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="e01fd" 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="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="aa25d" class="javax.swing.JLabel">
<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>
<text value="Library &amp;level:"/>
</properties>
</component>
<hspacer id="c2126">
<constraints>
<grid row="0" 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>
<component id="f0316" class="javax.swing.JComboBox" binding="myComboBox1" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</grid>
</form>
@@ -0,0 +1,84 @@
/*
* Copyright 2000-2010 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.openapi.application.ApplicationManager;
import com.intellij.openapi.roots.impl.libraries.ApplicationLibraryTable;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablePresentation;
import com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryTableEditor;
import com.intellij.openapi.ui.DialogWrapper;
import javax.swing.*;
import java.awt.*;
/**
* @author Dmitry Avdeev
*/
public class EditLibraryDialog extends DialogWrapper {
private ApplicationLibraryTable myLibraryTable = new ApplicationLibraryTable();
private Library myLibrary;
private JTextField myTextField1;
private JComboBox myComboBox1;
private JPanel myEditorPanel;
private JPanel myPanel;
protected EditLibraryDialog(Component parent) {
super(parent, true);
setTitle("Edit Library");
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
myLibrary = myLibraryTable.createLibrary("xxx");
}
});
init();
}
@Override
protected JComponent createCenterPanel() {
JComponent editor = LibraryTableEditor.editLibrary(new LibraryTableModifiableModelProvider() {
@Override
public LibraryTable.ModifiableModel getModifiableModel() {
return myLibraryTable.getModifiableModel();
}
@Override
public String getTableLevel() {
return myLibraryTable.getTableLevel();
}
@Override
public LibraryTablePresentation getLibraryTablePresentation() {
return myLibraryTable.getPresentation();
}
@Override
public boolean isLibraryTableEditable() {
return false;
}
}, myLibrary).getComponent();
myEditorPanel.add(editor, BorderLayout.CENTER);
return myPanel;
}
}
@@ -33,7 +33,6 @@ 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.ui.IdeBorderFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -74,14 +73,15 @@ public class LibraryCompositionOptionsPanel {
private final LibraryDownloadingMirrorsMap myMirrorsMap;
private List<RemoteRepositoryMirrorPanel> myMirrorPanelsList;
public LibraryCompositionOptionsPanel(final @NotNull LibrariesContainer librariesContainer, final @NotNull LibraryCompositionSettings libraryCompositionSettings,
public LibraryCompositionOptionsPanel(final @NotNull LibrariesContainer librariesContainer,
final @NotNull LibraryCompositionSettings libraryCompositionSettings,
final @NotNull LibraryDownloadingMirrorsMap mirrorsMap) {
myLibrariesContainer = librariesContainer;
myLibraryCompositionSettings = libraryCompositionSettings;
myMirrorsMap = mirrorsMap;
addMirrorsPanels();
myMainPanel.setBorder(BorderFactory.createCompoundBorder(IdeBorderFactory.createTitledBorder(libraryCompositionSettings.getTitle()), IdeBorderFactory.createEmptyBorder(5,5,5,5)));
myDirectoryField.addBrowseFolderListener(ProjectBundle.message("file.chooser.directory.for.downloaded.libraries.title"),
ProjectBundle.message("file.chooser.directory.for.downloaded.libraries.description"), null,
FileChooserDescriptorFactory.createSingleFolderDescriptor());
@@ -47,6 +47,8 @@ public class LibraryCompositionSettings {
private LibrariesContainer.LibraryLevel myLibraryLevel = LibrariesContainer.LibraryLevel.PROJECT;
private String myLibraryName;
private final Icon myIcon;
private boolean myDownloadSources = true;
private boolean myDownloadJavadocs = true;
public LibraryCompositionSettings(final @NotNull LibraryInfo[] libraryInfos,
final @NotNull String defaultLibraryName,
@@ -191,4 +193,20 @@ public class LibraryCompositionSettings {
}
return library;
}
public boolean isDownloadSources() {
return myDownloadSources;
}
public void setDownloadSources(boolean downloadSources) {
myDownloadSources = downloadSources;
}
public boolean isDownloadJavadocs() {
return myDownloadJavadocs;
}
public void setDownloadJavadocs(boolean downloadJavadocs) {
myDownloadJavadocs = downloadJavadocs;
}
}
@@ -0,0 +1,81 @@
<?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.LibraryOptionsPanel">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" 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>
<xy x="20" y="20" width="584" height="146"/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
<border type="none"/>
<children>
<component id="37d09" class="javax.swing.JLabel" binding="myMessage">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" 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>
<component id="a5b73" class="javax.swing.JRadioButton" binding="myDownloadFromMavenButton">
<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">
<preferred-size width="207" height="22"/>
</grid>
</constraints>
<properties>
<selected value="true"/>
<text value="Download from &amp;Maven repository"/>
</properties>
</component>
<vspacer id="3e4b8">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="207" height="14"/>
</grid>
</constraints>
</vspacer>
<component id="f63e3" class="javax.swing.JRadioButton" binding="myDoNotCreateButton">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="207" height="22"/>
</grid>
</constraints>
<properties>
<text value="Do &amp;not create library"/>
</properties>
</component>
<component id="6cdd8" class="javax.swing.JButton" binding="myConfigureButton" default-binding="true">
<constraints>
<grid row="4" 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>
<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="46359" class="javax.swing.JRadioButton" binding="myLocateOnDiskButton">
<constraints>
<grid row="1" 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>
<text value="Pick up files from &amp;disk"/>
</properties>
</component>
</children>
</grid>
<buttonGroups>
<group name="buttonGroup">
<member id="a5b73"/>
<member id="947c3"/>
<member id="f63e3"/>
<member id="46359"/>
</group>
</buttonGroups>
</form>
@@ -0,0 +1,152 @@
/*
* Copyright 2000-2010 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.IdeBundle;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.MessageFormat;
/**
* @author Dmitry Avdeev
*/
public class LibraryOptionsPanel {
private JLabel myMessage;
private JPanel myPanel;
private JRadioButton myDownloadFromMavenButton;
private JRadioButton myDoNotCreateButton;
private JButton myConfigureButton;
private JRadioButton myLocateOnDiskButton;
private LibraryCompositionSettings myLibraryCompositionSettings;
public LibraryOptionsPanel(LibraryCompositionSettings libraryCompositionSettings) {
myLibraryCompositionSettings = libraryCompositionSettings;
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateState();
}
};
myDownloadFromMavenButton.addActionListener(listener);
myLocateOnDiskButton.addActionListener(listener);
myDoNotCreateButton.addActionListener(listener);
myConfigureButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final Point point = myConfigureButton.getLocationOnScreen();
if (myLocateOnDiskButton.isSelected()) {
EditLibraryDialog dialog = new EditLibraryDialog(myConfigureButton) {
@Override
public Point getInitialLocation() {
point.translate(- 50, - getSize().height);
return point;
}
};
dialog.show();
}
else {
new DownloadingOptionsDialog(myConfigureButton, myLibraryCompositionSettings) {
@Override
public Point getInitialLocation() {
point.translate(- 50, - getSize().height);
return point;
}
}.show();
}
}
});
updateState();
}
private VirtualFile[] 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"));
return FileChooser.chooseFiles(myConfigureButton, descriptor, getBaseDirectory());
}
@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 updateState() {
if (myMessage.isEnabled()) {
myMessage.setForeground(Color.black);
}
myConfigureButton.setEnabled(true);
if (myDownloadFromMavenButton.isSelected()) {
String path = myLibraryCompositionSettings.getDirectoryForDownloadedLibrariesPath().substring(myLibraryCompositionSettings.getBaseDirectoryForDownloadedFiles().length());
String message = MessageFormat.format("<html>{0} jar(s) will be downloaded into <b>{1}</b> directory<br> " +
"{2} level library <b>{3}</b> will be created</html>",
myLibraryCompositionSettings.getLibraryInfos().length,
path,
myLibraryCompositionSettings.getLibraryLevel(),
myLibraryCompositionSettings.getLibraryName());
myMessage.setText(message);
}
else if (myLocateOnDiskButton.isSelected()) {
if (myLibraryCompositionSettings.getAddedJars().isEmpty()) {
myMessage.setForeground(Color.red);
myMessage.setText("Press Configure button to add classes to the library");
}
else {
String message = MessageFormat.format("<html>{0} level library <b>{1}</b><br>" +
"with {2} file(s) will be created</html>",
myLibraryCompositionSettings.getLibraryLevel(),
myLibraryCompositionSettings.getLibraryName(),
myLibraryCompositionSettings.getAddedJars().size());
myMessage.setText(message);
}
}
else {
myMessage.setText("<html>No library will be created<br>" +
"You can add it later manually</html>");
myConfigureButton.setEnabled(false);
}
}
public LibraryCompositionSettings getLibraryCompositionSettings() {
return myLibraryCompositionSettings;
}
public void apply() {
}
public JComponent getMainPanel() {
return myPanel;
}
}
@@ -16,9 +16,9 @@
package com.intellij.ide.util.newProjectWizard;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionOptionsPanel;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings;
import com.intellij.facet.impl.ui.libraries.LibraryDownloadingMirrorsMap;
import com.intellij.facet.impl.ui.libraries.LibraryOptionsPanel;
import com.intellij.facet.ui.FacetBasedFrameworkSupportProvider;
import com.intellij.facet.ui.libraries.LibraryDownloadInfo;
import com.intellij.facet.ui.libraries.LibraryInfo;
@@ -131,10 +131,7 @@ public class AddSupportForFrameworksPanel implements Disposable {
myLastSelectedNode = selectedNode;
if (selectedNode != null) {
final LibraryCompositionOptionsPanel newOptionsPanel = selectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
if (newOptionsPanel != null) {
newOptionsPanel.updateRepositoriesMirrors(myMirrorsMap);
}
selectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
}
}
}
@@ -145,9 +142,8 @@ public class AddSupportForFrameworksPanel implements Disposable {
private void applyLibraryOptionsForSelected() {
if (myLastSelectedNode != null) {
final LibraryCompositionOptionsPanel optionsPanel = myLastSelectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
final LibraryOptionsPanel optionsPanel = myLastSelectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
if (optionsPanel != null) {
optionsPanel.saveSelectedRepositoriesMirrors(myMirrorsMap);
optionsPanel.apply();
}
}
@@ -174,13 +170,17 @@ public class AddSupportForFrameworksPanel implements Disposable {
private void initializeOptionsPanel(final FrameworkSupportNode node) {
final String id = node.getProvider().getId();
if (!myInitializedOptionsPanelIds.contains(id)) {
final JPanel optionsPanel = new JPanel(new VerticalFlowLayout());
VerticalFlowLayout layout = new VerticalFlowLayout();
layout.setVerticalFill(true);
final JPanel optionsPanel = new JPanel(layout);
JComponent separator = SeparatorFactory.createSeparator(node.getTitle() + " Settings", null);
separator.setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 5, 5));
optionsPanel.add(separator);
final FrameworkSupportConfigurable configurable = node.getConfigurable();
optionsPanel.add(configurable.getComponent());
final JPanel librariesOptionsPanelWrapper = new JPanel(new BorderLayout());
optionsPanel.add(librariesOptionsPanelWrapper);
configurable.addListener(new FrameworkSupportConfigurableListener() {
@@ -197,8 +197,11 @@ public class AddSupportForFrameworksPanel implements Disposable {
}
private void addLibrariesOptionsPanel(FrameworkSupportNode node, JPanel librariesOptionsPanelWrapper) {
final LibraryCompositionOptionsPanel libraryOptionsPanel = node.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
final LibraryOptionsPanel libraryOptionsPanel = node.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
if (libraryOptionsPanel != null) {
JComponent separator = SeparatorFactory.createSeparator("Libraries", null);
separator.setBorder(IdeBorderFactory.createEmptyBorder(5, 0, 5, 5));
librariesOptionsPanelWrapper.add(BorderLayout.NORTH, separator);
librariesOptionsPanelWrapper.add(BorderLayout.CENTER, libraryOptionsPanel.getMainPanel());
}
}
@@ -15,9 +15,9 @@
*/
package com.intellij.ide.util.newProjectWizard;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionOptionsPanel;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings;
import com.intellij.facet.impl.ui.libraries.LibraryDownloadingMirrorsMap;
import com.intellij.facet.impl.ui.libraries.LibraryOptionsPanel;
import com.intellij.facet.ui.libraries.LibraryInfo;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider;
@@ -50,7 +50,7 @@ public class FrameworkSupportNode extends CheckedTreeNode {
private final List<FrameworkSupportNode> myChildren = new ArrayList<FrameworkSupportNode>();
private LibraryCompositionSettings myLibraryCompositionSettings;
private final Computable<String> myBaseDirForLibrariesGetter;
private LibraryCompositionOptionsPanel myLibraryCompositionOptionsPanel;
private LibraryOptionsPanel myLibraryCompositionOptionsPanel;
public FrameworkSupportNode(final FrameworkSupportProvider provider, final FrameworkSupportNode parentNode, final FrameworkSupportModelImpl model,
Computable<String> baseDirForLibrariesGetter, Disposable parentDisposable) {
@@ -75,12 +75,12 @@ public class FrameworkSupportNode extends CheckedTreeNode {
}
@Nullable
public LibraryCompositionOptionsPanel getLibraryCompositionOptionsPanel(LibrariesContainer librariesContainer,
public LibraryOptionsPanel getLibraryCompositionOptionsPanel(LibrariesContainer librariesContainer,
LibraryDownloadingMirrorsMap mirrorsMap) {
final LibraryCompositionSettings libraryCompositionSettings = getLibraryCompositionSettings();
if (myLibraryCompositionOptionsPanel == null || !myLibraryCompositionOptionsPanel.getLibraryCompositionSettings().equals(libraryCompositionSettings)) {
if (libraryCompositionSettings != null) {
myLibraryCompositionOptionsPanel = new LibraryCompositionOptionsPanel(librariesContainer, libraryCompositionSettings, mirrorsMap);
myLibraryCompositionOptionsPanel = new LibraryOptionsPanel(libraryCompositionSettings);
}
else {
myLibraryCompositionOptionsPanel = null;
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots.ui.configuration.projectRoot;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -31,7 +32,12 @@ public interface LibrariesContainer {
@Nullable
Project getProject();
enum LibraryLevel {GLOBAL, PROJECT, MODULE}
enum LibraryLevel {GLOBAL, PROJECT, MODULE;
public String toString() {
return StringUtil.capitalize(name().toLowerCase());
}
}
@NotNull
Library[] getLibraries(@NotNull LibraryLevel libraryLevel);
@@ -26,9 +26,11 @@ import java.util.Arrays;
*/
public class LibraryInfo {
public static final LibraryInfo[] EMPTY_ARRAY = new LibraryInfo[0];
private @Nullable final LibraryDownloadInfo myDownloadInfo;
private @NonNls final String myPresentableName;
private @NonNls final String[] myRequiredClasses;
private boolean mySelected = true;
public LibraryInfo(final @NonNls String presentableName, final @Nullable @NonNls String version,
final @Nullable @NonNls String downloadingUrl,
@@ -87,4 +89,17 @@ public class LibraryInfo {
result = 31 * result + Arrays.hashCode(myRequiredClasses);
return result;
}
@Override
public String toString() {
return getPresentableName();
}
public boolean isSelected() {
return mySelected;
}
public void setSelected(boolean selected) {
mySelected = selected;
}
}