Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: frontend/client/src/autotest/tko/SpreadsheetSelectionManager.java

Issue 1595019: Merge remote branch 'origin/upstream' into tempbranch (Closed)
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: frontend/client/src/autotest/tko/SpreadsheetSelectionManager.java
diff --git a/frontend/client/src/autotest/tko/SpreadsheetSelectionManager.java b/frontend/client/src/autotest/tko/SpreadsheetSelectionManager.java
index 9f8e0347ca33291850440d1df72c49537c5de7bf..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/frontend/client/src/autotest/tko/SpreadsheetSelectionManager.java
+++ b/frontend/client/src/autotest/tko/SpreadsheetSelectionManager.java
@@ -1,91 +0,0 @@
-package autotest.tko;
-
-import autotest.common.Utils;
-import autotest.tko.Spreadsheet.CellInfo;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-
-// TODO: hopefully some of this could be combined with autotest.common.table.SelectionManager using
-// generics
-// TODO: get rid of header selection
-public class SpreadsheetSelectionManager {
- private Spreadsheet spreadsheet;
- private Collection<CellInfo> selectedCells = new HashSet<CellInfo>();
- private SpreadsheetSelectionListener listener;
-
- public static interface SpreadsheetSelectionListener {
- public void onCellsSelected(List<CellInfo> cells);
- public void onCellsDeselected(List<CellInfo> cells);
- }
-
- public SpreadsheetSelectionManager(Spreadsheet spreadsheet,
- SpreadsheetSelectionListener listener) {
- this.spreadsheet = spreadsheet;
- this.listener = listener;
- }
-
- public void toggleSelected(CellInfo cell) {
- if (selectedCells.contains(cell)) {
- deselectCell(cell);
- notifyDeselected(Utils.wrapObjectWithList(cell));
- } else {
- selectCell(cell);
- notifySelected(Utils.wrapObjectWithList(cell));
- }
- }
-
- private void selectCell(CellInfo cell) {
- selectedCells.add(cell);
- spreadsheet.setHighlighted(cell, true);
- }
-
- private void deselectCell(CellInfo cell) {
- selectedCells.remove(cell);
- spreadsheet.setHighlighted(cell, false);
- }
-
- public List<CellInfo> getSelectedCells() {
- return new ArrayList<CellInfo>(selectedCells);
- }
-
- public boolean isEmpty() {
- return selectedCells.isEmpty();
- }
-
- public void clearSelection() {
- List<CellInfo> cells = getSelectedCells();
- for (CellInfo cell : cells) {
- deselectCell(cell);
- }
- notifyDeselected(cells);
- }
-
- public void selectAll() {
- List<CellInfo> selectedCells = new ArrayList<CellInfo>();
- for (CellInfo[] row : spreadsheet.dataCells) {
- for (CellInfo cell : row) {
- if (cell == null || cell.isEmpty()) {
- continue;
- }
- selectCell(cell);
- selectedCells.add(cell);
- }
- }
- notifySelected(selectedCells);
- }
-
- private void notifyDeselected(List<CellInfo> cells) {
- if (listener != null) {
- listener.onCellsDeselected(cells);
- }
- }
-
- private void notifySelected(List<CellInfo> selectedCells) {
- if (listener != null) {
- listener.onCellsSelected(selectedCells);
- }
- }
-}
« no previous file with comments | « frontend/client/src/autotest/tko/SpreadsheetDataProcessor.java ('k') | frontend/client/src/autotest/tko/SpreadsheetView.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698