[vcs] IDEA-99093 Make the list of unregistered roots scrollable

* Add the list to a JBScrollPane.
* setMinimum and Maximum sizes not to let it shrink to zero because of the GridBagLayout.

Remaining problem: when the dialog is enlarged, at some point the scroll pane dissapears (when the dialog is high enough) and the list of unregistered roots gets bigger.
This commit is contained in:
Kirill Likhodedov
2013-01-16 14:24:25 +04:00
parent fe42580aa6
commit ef428d89aa
@@ -28,6 +28,7 @@ import com.intellij.openapi.vcs.impl.VcsDescriptor;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.*;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
import com.intellij.ui.table.TableView;
@@ -390,7 +391,10 @@ public class VcsDirectoryConfigurationPanel extends PanelWithButtons implements
}
private JComponent createErrorList() {
Box box = Box.createVerticalBox();
final int DEFAULT_HEIGHT = 200;
final JComponent errorPanel = Box.createVerticalBox();
final JBScrollPane pane = new JBScrollPane(errorPanel);
for (Map.Entry<String, VcsRootChecker> entry : myCheckers.entrySet()) {
VcsRootChecker checker = entry.getValue();
for (final String root : checker.getUnregisteredRoots()) {
@@ -401,13 +405,25 @@ public class VcsDirectoryConfigurationPanel extends PanelWithButtons implements
@Override
public void run() {
addMapping(new VcsDirectoryMapping(root, vcs));
vcsRootErrorLabel.setVisible(false);
errorPanel.remove(vcsRootErrorLabel);
if (errorPanel.getComponentCount() == 0) {
pane.setVisible(false);
}
pane.setMinimumSize(new Dimension(-1, calcMinHeight(errorPanel, DEFAULT_HEIGHT)));
validate();
}
});
box.add(vcsRootErrorLabel);
errorPanel.add(vcsRootErrorLabel);
}
}
return box;
pane.setMinimumSize(new Dimension(-1, calcMinHeight(errorPanel, DEFAULT_HEIGHT)));
pane.setMaximumSize(new Dimension(-1, DEFAULT_HEIGHT));
return pane;
}
private static int calcMinHeight(@NotNull JComponent errorPanel, int defaultHeight) {
int height = errorPanel.getPreferredSize().height;
return height > defaultHeight ? defaultHeight : height;
}
private JComponent createProjectMappingDescription() {