mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make filters work
This commit is contained in:
@@ -32,6 +32,7 @@ public class DirDiffDialog extends DialogWrapper {
|
||||
|
||||
public DirDiffDialog(Project project, DirDiffTableModel model, DirDiffSettings settings) {
|
||||
super(project);
|
||||
setModal(false);
|
||||
myModel = model;
|
||||
mySettings = settings;
|
||||
setSize(600, 600);
|
||||
|
||||
@@ -50,6 +50,9 @@ public class DirDiffElement {
|
||||
else if (isTarget()) {
|
||||
myOperation = DirDiffOperation.COPY_FROM;
|
||||
}
|
||||
else if (type == DType.EQUAL) {
|
||||
myOperation = DirDiffOperation.EQUAL;
|
||||
}
|
||||
else if (type == DType.CHANGED) {
|
||||
assert source != null;
|
||||
myOperation = source.getFileType().isBinary() ? NONE : DirDiffOperation.MERGE;
|
||||
@@ -106,7 +109,7 @@ public class DirDiffElement {
|
||||
|
||||
@Nullable
|
||||
public String getSourceName() {
|
||||
return myType == DType.CHANGED || myType == DType.SOURCE
|
||||
return myType == DType.CHANGED || myType == DType.SOURCE || myType == DType.EQUAL
|
||||
? mySource.getName() : null;
|
||||
}
|
||||
|
||||
@@ -117,7 +120,7 @@ public class DirDiffElement {
|
||||
|
||||
@Nullable
|
||||
public String getTargetName() {
|
||||
return myType == DType.CHANGED || myType == DType.TARGET
|
||||
return myType == DType.CHANGED || myType == DType.TARGET || myType == DType.EQUAL
|
||||
? myTarget.getName() : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.swing.*;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public enum DirDiffOperation {
|
||||
COPY_TO, COPY_FROM, REMOVE, MERGE, NONE;
|
||||
COPY_TO, COPY_FROM, REMOVE, MERGE, NONE, EQUAL;
|
||||
|
||||
public Icon getIcon() {
|
||||
switch (this) {
|
||||
@@ -32,6 +32,7 @@ public enum DirDiffOperation {
|
||||
case COPY_FROM: return IconLoader.getIcon("/vcs/arrow_left.png");
|
||||
case REMOVE: return IconLoader.getIcon("/vcs/remove.png");
|
||||
case MERGE: return IconLoader.getIcon("/vcs/merge.png");
|
||||
case EQUAL: return IconLoader.getIcon("/vcs/equal.png");
|
||||
case NONE: return EmptyIcon.create(12);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -76,6 +76,7 @@ public class DirDiffPanel {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
final DirDiffElement last = myModel.getElementAt(e.getLastIndex());
|
||||
final DirDiffElement first = myModel.getElementAt(e.getFirstIndex());
|
||||
if (last == null || first == null) return;
|
||||
if (last.isSeparator()) {
|
||||
myTable.getSelectionModel().setLeadSelectionIndex(e.getFirstIndex());
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
private DiffElement mySrc;
|
||||
private DiffElement myTrg;
|
||||
final List<DirDiffElement> myElements = new ArrayList<DirDiffElement>();
|
||||
private boolean myUpdating = false;
|
||||
|
||||
public DirDiffTableModel(Project project, DiffElement src, DiffElement trg, ProgressIndicator indicator, DirDiffSettings settings) {
|
||||
myProject = project;
|
||||
@@ -48,6 +49,8 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
public void reloadModel(ProgressIndicator indicator) {
|
||||
myUpdating = true;
|
||||
clear();
|
||||
final DTree tree = new DTree(null, "", true);
|
||||
scan(mySrc, tree, true);
|
||||
scan(myTrg, tree, false);
|
||||
@@ -59,6 +62,8 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
|
||||
myElements.clear();
|
||||
fillElements(tree);
|
||||
fireTableDataChanged();
|
||||
myUpdating = false;
|
||||
}
|
||||
|
||||
private void fillElements(DTree tree) {
|
||||
@@ -91,6 +96,14 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (!myElements.isEmpty()) {
|
||||
final int size = myElements.size();
|
||||
myElements.clear();
|
||||
fireTableRowsDeleted(0, size - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void scan(DiffElement element, DTree root, boolean source) {
|
||||
if (element.isContainer()) {
|
||||
try {
|
||||
@@ -108,7 +121,7 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
public DirDiffElement getElementAt(int index) {
|
||||
return myElements.get(index);
|
||||
return 0 <= index && index < myElements.size() ? myElements.get(index) : null;
|
||||
}
|
||||
|
||||
public DiffElement getSourceDir() {
|
||||
@@ -202,4 +215,8 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
public void setShowNewOnTarget(boolean show) {
|
||||
mySettings.showNewOnTarget = show;
|
||||
}
|
||||
|
||||
public boolean isUpdating() {
|
||||
return myUpdating;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.diff.impl.dir.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffIcons;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
|
||||
@@ -35,4 +36,18 @@ public abstract class DirDiffAction extends ToggleAction implements DirDiffIcons
|
||||
public DirDiffTableModel getModel() {
|
||||
return myModel;
|
||||
}
|
||||
|
||||
protected abstract void updateState(boolean state);
|
||||
|
||||
@Override
|
||||
public final void setSelected(AnActionEvent e, boolean state) {
|
||||
updateState(state);
|
||||
getModel().reloadModel(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setEnabled(!getModel().isUpdating());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ public class EnableEqual extends DirDiffAction {
|
||||
return getModel().isShowEqual();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
public void updateState(boolean state) {
|
||||
getModel().setShowEqual(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ public class EnableLeft extends DirDiffAction {
|
||||
return getModel().isShowNewOnSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
public void updateState(boolean state) {
|
||||
getModel().setShowNewOnSource(state);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -31,8 +31,7 @@ public class EnableNotEqual extends DirDiffAction {
|
||||
return getModel().isShowDifferent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
public void updateState(boolean state) {
|
||||
getModel().setShowDifferent(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ public class EnableRight extends DirDiffAction {
|
||||
return getModel().isShowNewOnTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
public void updateState(boolean state) {
|
||||
getModel().setShowNewOnTarget(state);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -33,7 +33,6 @@ public class RefreshDirDiffAction extends DirDiffAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
//TODO getModel().refresh();
|
||||
protected void updateState(boolean state) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user