diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffElement.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffElement.java index 4c5cc4cd90e0..77673fecef21 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffElement.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffElement.java @@ -49,20 +49,20 @@ public class DirDiffElement { myTargetLength = target == null || target.isContainer() ? -1 : target.getSize(); myName = name; if (type == DType.ERROR) { - myDefaultOperation = DirDiffOperation.NONE; + myDefaultOperation = NONE; } else if (isSource()) { myDefaultOperation = COPY_TO; } else if (isTarget()) { - myDefaultOperation = DirDiffOperation.COPY_FROM; + myDefaultOperation = COPY_FROM; } else if (type == DType.EQUAL) { - myDefaultOperation = DirDiffOperation.EQUAL; + myDefaultOperation = EQUAL; } else if (type == DType.CHANGED) { assert source != null; - myDefaultOperation = DirDiffOperation.MERGE; + myDefaultOperation = MERGE; } } @@ -180,7 +180,7 @@ public class DirDiffElement { } else if (myType == DType.TARGET) { myOperation = op == COPY_FROM ? DELETE : op == DELETE ? NONE : COPY_FROM; } else if (myType == DType.CHANGED) { - myOperation = op == MERGE ? COPY_FROM : op == COPY_FROM ? COPY_TO : op == COPY_TO ? NONE : MERGE; + myOperation = op == MERGE ? COPY_FROM : op == COPY_FROM ? COPY_TO : MERGE; } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffOperation.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffOperation.java index b9a7b9565e00..d9a543f4d952 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffOperation.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffOperation.java @@ -47,6 +47,8 @@ public enum DirDiffOperation { return FileStatus.COLOR_ADDED; case MERGE: return FileStatus.COLOR_MODIFIED; + case DELETE: + return FileStatus.DELETED.getColor(); case EQUAL: case NONE: } diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.form b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.form index e4f768b3e5da..058754e895dd 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.form +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.form @@ -36,23 +36,6 @@ - - - - - - - - - - - - - - - - - @@ -144,6 +127,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java index 8b9f6e4965f4..ec9c59ce7633 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java @@ -68,6 +68,7 @@ public class DirDiffPanel implements Disposable { private JPanel myRootPanel; private JPanel myFilterPanel; private JBLabel myFilterLabel; + private JPanel myFilesPanel; private FilterComponent myFilter; private final DirDiffTableModel myModel; public JLabel myErrorLabel; @@ -95,7 +96,7 @@ public class DirDiffPanel implements Disposable { final DirDiffTableCellRenderer renderer = new DirDiffTableCellRenderer(myTable); myTable.setDefaultRenderer(Object.class, renderer); - myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); final Project project = myModel.getProject(); myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override @@ -106,10 +107,12 @@ public class DirDiffPanel implements Disposable { final DirDiffElement first = myModel.getElementAt(firstIndex); if (last == null || first == null) return; if (last.isSeparator()) { - myTable.getSelectionModel().setLeadSelectionIndex(lastIndex + ((lastIndex < firstIndex) ? 1 : -1)); + final int ind = lastIndex + ((lastIndex < firstIndex) ? 1 : -1); + myTable.getSelectionModel().addSelectionInterval(ind, ind); } else if (first.isSeparator()) { - myTable.getSelectionModel().setLeadSelectionIndex(firstIndex + ((firstIndex < lastIndex) ? 1 : -1)); + final int ind = firstIndex + ((firstIndex < lastIndex) ? 1 : -1); + myTable.getSelectionModel().addSelectionInterval(ind, ind); } else { update(false); @@ -121,7 +124,7 @@ public class DirDiffPanel implements Disposable { new AnAction("Change diff operation") { @Override public void actionPerformed(AnActionEvent e) { - changeOperationForSelectedRow(); + changeOperationForSelection(); } }.registerCustomShortcutSet(CustomShortcutSet.fromString("SPACE"), myTable); myTable.addMouseListener(new MouseAdapter() { @@ -132,7 +135,7 @@ public class DirDiffPanel implements Disposable { final int col = myTable.columnAtPoint(e.getPoint()); if (row != -1 && col == ((myTable.getColumnCount() - 1) / 2)) { - changeOperationForSelectedRow(); + changeOperationForSelection(); } } } @@ -142,9 +145,11 @@ public class DirDiffPanel implements Disposable { @Override public void keyPressed(KeyEvent e) { final int keyCode = e.getKeyCode(); - final int rows = myTable.getRowCount(); - int row = myTable.getSelectedRow(); - if (keyCode == KeyEvent.VK_DOWN && row != rows - 1) { + final int rowCount = myTable.getRowCount(); + int row = myTable.getSelectionModel().getLeadSelectionIndex(); + final int[] rows = myTable.getSelectedRows(); + if (rows.length == 0) return; + if (keyCode == KeyEvent.VK_DOWN && row < rowCount - 1) { row++; final DirDiffElement element = myModel.getElementAt(row); if (element == null) return; @@ -152,7 +157,7 @@ public class DirDiffPanel implements Disposable { row++; } } - else if (keyCode == KeyEvent.VK_UP && row != 0) { + else if (keyCode == KeyEvent.VK_UP && row > 0) { row--; final DirDiffElement element = myModel.getElementAt(row); if (element == null) return; @@ -167,7 +172,7 @@ public class DirDiffPanel implements Disposable { if (element == null) return; if (!element.isSeparator()) { e.consume(); - myTable.changeSelection(row, (myModel.getColumnCount() - 1) / 2, false, false); + myTable.changeSelection(row, (myModel.getColumnCount() - 1) / 2, false, e.isShiftDown()); } } }); @@ -190,9 +195,14 @@ public class DirDiffPanel implements Disposable { final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("DirDiff", actions, true); registerCustomShortcuts(actions, myTable); myToolBarPanel.add(toolbar.getComponent(), BorderLayout.CENTER); + final JBLabel label = new JBLabel("Use Space button or mouse click to change operation for the selected elements. Enter to perform.", SwingConstants.CENTER); + label.setForeground(UIUtil.getInactiveTextColor()); + UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, label); + myFilesPanel.add(label, BorderLayout.SOUTH); final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), wnd.getDisposable()); loadingPanel.addListener(new JBLoadingPanelListener.Adapter() { boolean showHelp = true; + @Override public void onLoadingFinish() { if (showHelp && myModel.isOperationsEnabled() && myModel.getRowCount() > 0) { @@ -200,7 +210,7 @@ public class DirDiffPanel implements Disposable { if (count < 3) { JBPopupFactory.getInstance().createBalloonBuilder(new JLabel(" Use Space button to change operation")) .setFadeoutTime(5000) - .setContentInsets(new Insets(15,15,15,15)) + .setContentInsets(new Insets(15, 15, 15, 15)) .createBalloon().show(new RelativePoint(myTable, new Point(myTable.getWidth() / 2, 0)), Balloon.Position.above); PropertiesComponent.getInstance().setValue("dir.diff.space.button.info", String.valueOf(count + 1)); } @@ -308,13 +318,14 @@ public class DirDiffPanel implements Disposable { } } - private void changeOperationForSelectedRow() { - final int row = myTable.getSelectedRow(); - if (row != -1) { - final DirDiffElement element = myModel.getElementAt(row); - if (element != null) { - element.setNextOperation(); - myModel.fireTableRowsUpdated(row, row); + private void changeOperationForSelection() { + for (int row : myTable.getSelectedRows()) { + if (row != -1) { + final DirDiffElement element = myModel.getElementAt(row); + if (element != null) { + element.setNextOperation(); + myModel.fireTableRowsUpdated(row, row); + } } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java index b3af691dcba4..7dcc9af542d5 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java @@ -109,6 +109,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode case EQUAL: if (!mySettings.showEqual) i.remove(); break; + case ERROR: } }