vcs: simplify constructor call

This commit is contained in:
Aleksey Pivovarov
2017-09-18 15:20:29 +03:00
parent 8cce8b9863
commit 10e0a7b4f3
2 changed files with 24 additions and 12 deletions
@@ -44,7 +44,6 @@ import javax.swing.event.DocumentEvent;
import javax.swing.tree.DefaultTreeModel;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -128,7 +127,7 @@ public class DirectoryHistoryDialog extends HistoryDialog<DirectoryHistoryDialog
}
private ChangesTreeList<Change> createChangesTree() {
return new ChangesTreeList<Change>(myProject, Collections.emptyList(), false, false, null, null) {
return new ChangesTreeList<Change>(myProject, false, false) {
@Override
protected DefaultTreeModel buildTreeModel(List<Change> cc, ChangeNodeDecorator changeNodeDecorator) {
return TreeModelBuilder.buildFromChanges(myProject, isShowFlatten(), cc, changeNodeDecorator);
@@ -83,28 +83,33 @@ public abstract class ChangesTreeList<T> extends Tree implements TypeSafeDataPro
@NonNls private final static String FLATTEN_OPTION_KEY = "ChangesBrowser.SHOW_FLATTEN";
@Nullable private final Runnable myInclusionListener;
@Nullable private Runnable myInclusionListener;
@Nullable private ChangeNodeDecorator myChangeDecorator;
@NotNull private final CopyProvider myTreeCopyProvider;
private TreeState myNonFlatTreeState;
public ChangesTreeList(@NotNull Project project,
@NotNull Collection<T> initiallyIncluded,
final boolean showCheckboxes,
final boolean highlightProblems,
@Nullable final Runnable inclusionListener,
@Nullable final ChangeNodeDecorator decorator) {
boolean showCheckboxes,
boolean highlightProblems,
@Nullable Runnable inclusionListener,
@Nullable ChangeNodeDecorator decorator) {
this(project, showCheckboxes, highlightProblems);
myIncludedChanges.addAll(initiallyIncluded);
myInclusionListener = inclusionListener;
myChangeDecorator = decorator;
}
public ChangesTreeList(@NotNull Project project,
boolean showCheckboxes,
boolean highlightProblems) {
super(ChangesBrowserNode.createRoot(project));
myProject = project;
myShowCheckboxes = showCheckboxes;
myHighlightProblems = highlightProblems;
myInclusionListener = inclusionListener;
myChangeDecorator = decorator;
myAlwaysExpandList = true;
myCheckboxWidth = new JCheckBox().getPreferredSize().width;
myIncludedChanges.addAll(initiallyIncluded);
setHorizontalAutoScrollingEnabled(false);
setRootVisible(false);
setShowsRootHandles(true);
@@ -192,7 +197,7 @@ public abstract class ChangesTreeList<T> extends Tree implements TypeSafeDataPro
getEmptyText().setText(emptyText);
}
public void addSelectionListener(final Runnable runnable) {
public void addSelectionListener(@NotNull Runnable runnable) {
addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
@@ -201,6 +206,10 @@ public abstract class ChangesTreeList<T> extends Tree implements TypeSafeDataPro
});
}
public void setInclusionListener(@Nullable Runnable runnable) {
myInclusionListener = runnable;
}
public void setChangeDecorator(@Nullable ChangeNodeDecorator changeDecorator) {
myChangeDecorator = changeDecorator;
}
@@ -221,6 +230,10 @@ public abstract class ChangesTreeList<T> extends Tree implements TypeSafeDataPro
return myShowFlatten;
}
public boolean isShowCheckboxes() {
return myShowCheckboxes;
}
/**
* Does nothing as ChangesTreeList is currently not wrapped in JScrollPane by default.
* Left not to break API (used in several plugins).