diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsStructureChooser.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsStructureChooser.java
index 0078669cd811..beabcdac4a7d 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsStructureChooser.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsStructureChooser.java
@@ -38,6 +38,7 @@ import com.intellij.openapi.vcs.changes.ui.VirtualFileListCellRenderer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
+import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.PlatformIcons;
@@ -70,22 +71,24 @@ import java.util.List;
public class VcsStructureChooser extends DialogWrapper {
private final static int MAX_FOLDERS = 100;
public static final Border BORDER = IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.LEFT);
- public static final String DEFAULT_TEXT = "Selected:";
public static final String CAN_NOT_ADD_TEXT = "Selected: (You have added " + MAX_FOLDERS + " elements. No more is allowed.)";
+
@NotNull private final Project myProject;
+
private Set myRoots;
private Map myModulesSet;
- private SelectionManager mySelectionManager;
- private DefaultMutableTreeNode myRoot;
- private JBList mySelectedList;
- private JLabel mySelectedLabel;
- private Tree myTree;
+ private final Set mySelectedFiles = new java.util.HashSet();
private final List myInitialRoots;
+ private JLabel mySelectedLabel;
+ private final SelectionManager mySelectionManager;
+ private DefaultMutableTreeNode myRoot;
+ private Tree myTree;
+
public VcsStructureChooser(@NotNull Project project,
- final String title,
- final Collection initialSelection,
- List initialRoots) {
+ String title,
+ Collection initialSelection,
+ @NotNull List initialRoots) {
super(project, true);
myInitialRoots = initialRoots;
setTitle(title);
@@ -128,11 +131,11 @@ public class VcsStructureChooser extends DialogWrapper {
@NotNull
public Collection getSelectedFiles() {
- return ((CollectionListModel) mySelectedList.getModel()).getItems();
+ return mySelectedFiles;
}
private void checkEmptyness() {
- setOKActionEnabled(mySelectedList.getModel().getSize() > 0);
+ setOKActionEnabled(!mySelectedFiles.isEmpty());
}
@Override
@@ -240,37 +243,23 @@ public class VcsStructureChooser extends DialogWrapper {
}
});
- final Splitter splitter = new Splitter(true, 0.7f);
- Disposer.register(this.getDisposable(), new Disposable() {
- public void dispose() {
- splitter.dispose();
- }
- });
- splitter.setFirstComponent(new JBScrollPane(fileSystemTree.getTree()));
- final JPanel wrapper = new JPanel(new BorderLayout());
- mySelectedLabel = new JLabel(DEFAULT_TEXT);
+ JBPanel panel = new JBPanel(new BorderLayout());
+ panel.add(new JBScrollPane(fileSystemTree.getTree()), BorderLayout.CENTER);
+ mySelectedLabel = new JLabel("");
mySelectedLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
- wrapper.add(mySelectedLabel, BorderLayout.NORTH);
- mySelectedList = new JBList(new CollectionListModel(new ArrayList()));
- mySelectedList.setCellRenderer(new WithModulesListCellRenderer(myProject, myModulesSet));
- wrapper.add(ScrollPaneFactory.createScrollPane(mySelectedList), BorderLayout.CENTER);
- splitter.setSecondComponent(wrapper);
+ panel.add(mySelectedLabel, BorderLayout.SOUTH);
mySelectionManager.setSelectionChangeListener(new PlusMinus() {
@Override
public void plus(VirtualFile virtualFile) {
- final CollectionListModel model = (CollectionListModel)mySelectedList.getModel();
- model.add(virtualFile);
- model.sort(FilePathComparator.getInstance());
+ mySelectedFiles.add(virtualFile);
recalculateErrorText();
- mySelectedList.revalidate();
- mySelectedList.repaint();
}
private void recalculateErrorText() {
checkEmptyness();
if (mySelectionManager.canAddSelection()) {
- mySelectedLabel.setText(DEFAULT_TEXT);
+ mySelectedLabel.setText("");
} else {
mySelectedLabel.setText(CAN_NOT_ADD_TEXT);
}
@@ -279,43 +268,11 @@ public class VcsStructureChooser extends DialogWrapper {
@Override
public void minus(VirtualFile virtualFile) {
- final CollectionListModel defaultListModel = (CollectionListModel)mySelectedList.getModel();
- for (int i = 0; i < defaultListModel.getSize(); i++) {
- final VirtualFile elementAt = (VirtualFile)defaultListModel.getElementAt(i);
- if (virtualFile.equals(elementAt)) {
- defaultListModel.remove(i);
- break;
- }
- }
- defaultListModel.sort(FilePathComparator.getInstance());
+ mySelectedFiles.remove(virtualFile);
recalculateErrorText();
- mySelectedList.revalidate();
- mySelectedList.repaint();
}
});
- mySelectedList.addKeyListener(new KeyAdapter() {
- @Override
- public void keyReleased(KeyEvent e) {
- if (e.getModifiers() == 0 && e.getKeyCode() == KeyEvent.VK_DELETE) {
- final int[] idx = mySelectedList.getSelectedIndices();
- if (idx != null && idx.length > 0) {
- final int answer = Messages
- .showYesNoDialog(myProject, "Remove selected paths from filter?", "Remove from filter", Messages.getQuestionIcon());
- if (Messages.YES == answer) {
- Arrays.sort(idx);
- for (int i = idx.length - 1; i >= 0; --i) {
- int i1 = idx[i];
- mySelectionManager.removeSelection((VirtualFile)((CollectionListModel) mySelectedList.getModel()).getElementAt(i1));
- myTree.revalidate();
- myTree.repaint();
- }
- }
- }
- }
- }
- });
-
- return splitter;
+ return panel;
}
@Nullable