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

Unified Diff: editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/controls/table/TableSource.java

Issue 17431004: New UI for Find command: find-as-you-type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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: editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/controls/table/TableSource.java
===================================================================
--- editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/controls/table/TableSource.java (revision 0)
+++ editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/controls/table/TableSource.java (revision 0)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2008 xored software, Inc. All rights reserved. This program and the accompanying
+ * materials are made available under the terms of the Eclipse Public License v1.0 which accompanies
+ * this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors:
+ * xored software, Inc. - initial API and Implementation (Yuri Strot)
+ *******************************************************************************/
+package com.xored.glance.ui.controls.table;
+
+import java.util.List;
+
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+import com.xored.glance.ui.controls.items.ItemCell;
+import com.xored.glance.ui.controls.items.ItemProvider;
+import com.xored.glance.ui.controls.items.ItemSource;
+import com.xored.glance.ui.sources.SourceSelection;
+
+/**
+ * @author Yuri Strot
+ */
+public class TableSource extends ItemSource {
+
+ public TableSource(Table table) {
+ super(table);
+ table.addSelectionListener(this);
+ }
+
+ @Override
+ public Table getControl() {
+ return (Table) super.getControl();
+ }
+
+ @Override
+ public void dispose() {
+ getControl().removeSelectionListener(this);
+ super.dispose();
+ }
+
+ public SourceSelection getSelection() {
+ TableItem[] items = getControl().getSelection();
+ if (items.length > 0) {
+ List<ItemCell> cells = getCells();
+ for (ItemCell cell : cells) {
+ if (cell.getItem().equals(items[0])) {
+ return new SourceSelection(cell, 0, cell.getText().length());
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void collectCells(List<ItemCell> cells) {
+ Table table = getControl();
+ TableItem[] items = table.getItems();
+ int columns = table.getColumnCount();
+ if (columns == 0)
+ columns = 1;
+ for (int i = 0; i < items.length; i++) {
+ for (int j = 0; j < columns; j++) {
+ cells.add(new ItemCell(items[i], j, getItemProvider()));
+ }
+ }
+ }
+
+ @Override
+ protected ItemProvider getItemProvider() {
+ return TableItemProvider.getInstance();
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698