"Add Framework Support" UI

This commit is contained in:
Dmitry Avdeev
2010-08-11 14:04:11 +04:00
parent 44d32d4ec9
commit fe7748133f
7 changed files with 172 additions and 136 deletions
@@ -15,7 +15,7 @@
</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"/>
<grid row="1" 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:"/>
@@ -23,68 +23,21 @@
</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"/>
<grid row="5" 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"/>
<grid row="4" 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"/>
<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"/>
@@ -98,7 +51,7 @@
<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"/>
<grid row="3" 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"/>
@@ -128,6 +81,14 @@
</component>
</children>
</grid>
<grid id="f9161" binding="myNameWrappingPanel" layout-manager="BorderLayout" 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"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>
@@ -18,12 +18,10 @@ 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;
@@ -38,13 +36,13 @@ 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 JPanel myNameWrappingPanel;
private final LibraryCompositionSettings mySettings;
private final LibraryNameAndLevelPanel myNameAndLevelPanel;
protected DownloadingOptionsDialog(Component parent, LibraryCompositionSettings settings) {
super(parent, true);
@@ -68,9 +66,10 @@ public class DownloadingOptionsDialog extends DialogWrapper {
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());
myNameAndLevelPanel = new LibraryNameAndLevelPanel();
myNameWrappingPanel.add(myNameAndLevelPanel.getPanel());
myNameAndLevelPanel.reset(settings);
init();
}
@@ -86,8 +85,7 @@ public class DownloadingOptionsDialog extends DialogWrapper {
@Override
protected void doOKAction() {
mySettings.setLibraryName(myLibraryNameField.getText());
mySettings.setLibraryLevel((LibrariesContainer.LibraryLevel)myLevelComboBox.getSelectedItem());
myNameAndLevelPanel.apply(mySettings);
mySettings.setDirectoryForDownloadedLibrariesPath(myDirectoryField.getText());
LibraryInfo[] libraryInfos = mySettings.getLibraryInfos();
for (int i = 0, libraryInfosLength = libraryInfos.length; i < libraryInfosLength; i++) {
@@ -1,6 +1,6 @@
<?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">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" 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"/>
@@ -16,65 +16,13 @@
<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"/>
<grid id="8ed98" binding="myNameAndLevelPanelWrapper" layout-manager="BorderLayout" 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"/>
</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>
<children/>
</grid>
</children>
</grid>
@@ -34,13 +34,15 @@ 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;
private JPanel myNameAndLevelPanelWrapper;
private final LibraryNameAndLevelPanel myNameAndLevelPanel;
private LibraryCompositionSettings mySettings;
protected EditLibraryDialog(Component parent) {
public EditLibraryDialog(Component parent, LibraryCompositionSettings settings) {
super(parent, true);
mySettings = settings;
setTitle("Edit Library");
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
@@ -48,10 +50,17 @@ public class EditLibraryDialog extends DialogWrapper {
myLibrary = myLibraryTable.createLibrary("xxx");
}
});
myNameAndLevelPanel = new LibraryNameAndLevelPanel();
myNameAndLevelPanel.reset(mySettings);
init();
}
public Library getLibrary() {
return myLibrary;
}
@Override
protected JComponent createCenterPanel() {
@@ -78,7 +87,14 @@ public class EditLibraryDialog extends DialogWrapper {
}
}, myLibrary).getComponent();
myEditorPanel.add(editor, BorderLayout.CENTER);
myEditorPanel.add(editor);
myNameAndLevelPanelWrapper.add(myNameAndLevelPanel.getPanel());
return myPanel;
}
@Override
protected void doOKAction() {
myNameAndLevelPanel.apply(mySettings);
super.doOKAction();
}
}
@@ -0,0 +1,55 @@
<?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.LibraryNameAndLevelPanel">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" 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>
<xy x="20" y="20" width="500" height="72"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="da42c" 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="a38e9"/>
<text value="&amp;Name:"/>
</properties>
</component>
<vspacer id="82a6e">
<constraints>
<grid row="1" 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="a38e9" 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="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="2bb99" 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="7ac04"/>
<text value="&amp;Level"/>
</properties>
</component>
<hspacer id="107f7">
<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="7ac04" class="javax.swing.JComboBox" binding="myLevelComboBox">
<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>
</form>
@@ -0,0 +1,46 @@
/*
* 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.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.ui.EnumComboBoxModel;
import javax.swing.*;
/**
* @author Dmitry Avdeev
*/
class LibraryNameAndLevelPanel {
private JTextField myLibraryNameField;
private JComboBox myLevelComboBox;
private JPanel myPanel;
void reset(LibraryCompositionSettings settings) {
myLibraryNameField.setText(settings.getLibraryName());
myLevelComboBox.setModel(new EnumComboBoxModel<LibrariesContainer.LibraryLevel>(LibrariesContainer.LibraryLevel.class));
myLevelComboBox.setSelectedItem(settings.getLibraryLevel());
}
void apply(LibraryCompositionSettings settings) {
settings.setLibraryName(myLibraryNameField.getText());
settings.setLibraryLevel((LibrariesContainer.LibraryLevel)myLevelComboBox.getSelectedItem());
}
public JPanel getPanel() {
return myPanel;
}
}
@@ -18,6 +18,10 @@ 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.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
@@ -56,32 +60,40 @@ public class LibraryOptionsPanel {
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;
EditLibraryDialog dialog = new EditLibraryDialog(myConfigureButton, myLibraryCompositionSettings);
if (myLibraryCompositionSettings.getAddedJars().isEmpty()) {
VirtualFile[] files = showFileChooser();
Library.ModifiableModel modifiableModel = dialog.getLibrary().getModifiableModel();
for (VirtualFile file : files) {
modifiableModel.addRoot(file, OrderRootType.CLASSES);
}
};
dialog.show();
modifiableModel.commit();
}
showDialog(dialog);
}
else {
new DownloadingOptionsDialog(myConfigureButton, myLibraryCompositionSettings) {
@Override
public Point getInitialLocation() {
point.translate(- 50, - getSize().height);
return point;
}
}.show();
DownloadingOptionsDialog dialog = new DownloadingOptionsDialog(myConfigureButton, myLibraryCompositionSettings);
showDialog(dialog);
}
updateState();
}
});
updateState();
}
private void showDialog(final DialogWrapper dialog) {
dialog.setInitialLocationCallback(new Computable<Point>() {
@Override
public Point compute() {
Point point = myConfigureButton.getLocationOnScreen();
point.translate(- 50, - dialog.getSize().height);
return point;
}
});
dialog.show();
}
private VirtualFile[] showFileChooser() {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
@@ -109,7 +121,7 @@ public class LibraryOptionsPanel {
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>",
"{2} library <b>{3}</b> will be created</html>",
myLibraryCompositionSettings.getLibraryInfos().length,
path,
myLibraryCompositionSettings.getLibraryLevel(),