From fed3c87fa6bc37186e4117f34b6a76c941dd5af3 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Mon, 26 Apr 2010 01:08:56 +0000 Subject: [PATCH] Added row flagging support. Fixed bug in row star change: starring or unstarring one row wasn't undo-able previously. git-svn-id: http://google-refine.googlecode.com/svn/trunk@547 7d457c2a-affb-35e4-300a-418c747d4874 --- LICENSE.txt | 6 ++ src/graphics/star-flag-map.psd | Bin 34416 -> 39103 bytes .../commands/edit/AnnotateOneRowCommand.java | 47 ++++++++- .../commands/edit/AnnotateRowsCommand.java | 8 ++ .../model/changes/RowFlagChange.java | 69 ++++++++++++++ .../model/changes/RowStarChange.java | 7 +- .../operations/OperationRegistry.java | 1 + .../operations/RowFlagOperation.java | 90 ++++++++++++++++++ src/main/webapp/about.html | 2 +- src/main/webapp/images/star-flag-map.png | Bin 778 -> 1619 bytes .../webapp/scripts/views/data-table-view.js | 60 +++++++++++- .../webapp/styles/views/data-table-view.css | 12 ++- 12 files changed, 289 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/metaweb/gridworks/model/changes/RowFlagChange.java create mode 100644 src/main/java/com/metaweb/gridworks/operations/RowFlagOperation.java diff --git a/LICENSE.txt b/LICENSE.txt index 826ed2544..b84cbde1d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -106,3 +106,9 @@ licenses/icu4j.LICENSE.txt licenses/json.LICENSE.txt json + +Others +------ + +Flag icon + http://pixel-mixer.com/category/free-icons/ \ No newline at end of file diff --git a/src/graphics/star-flag-map.psd b/src/graphics/star-flag-map.psd index e40045d48ff41b4a774633e3b36338dfbaff4d8e..e4aac50367cb2208ee4ca21a110c59576243afa7 100644 GIT binary patch delta 4400 zcmcIn3s@A_6}~%w5@98#`4UV`#F(@-sVz?>CN;(g0cG>0{qn}tRAV9_8c~S^b%+m; z@Qf%BQsaZ=5gVm;Q6xS9UsRUYvMkGM*=1SYEDN*9va>sLduDhkB<1VZ&pY4Do&TIO z=ia&hoVn)=#1lmqh-4Q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GDBCnra9Qwsw#OCuu-V@nHjBWFiv10!=sV*_V5Gglk^lFYQp zd%5B_TX4wwnlf29dHS+2F@OLYm}CHp7=YQ#jEsyBzAl*0#=r=qxi?P;UCFP?4OYkl zl3=z55+Er>C{AHu;CTWRm){(h`iDvNYse%|RZW#io?f0RlY;+W{2DU-)Jm1*ua+QF zn^QB{8F_(zHd26jesg8kU3LyW6$S?0AOHVujw^~}-TbkJhiUWo+6iov&3pXhnHccG w$r`=N1l2t2A*_Z7b2ex7hB3-N_>UKE_MZ?=Sdq!(P{NADriC*qJYc{N0RlF~eE changes = new ArrayList(project.rows.size()); + + FilteredRows filteredRows = engine.getAllFilteredRows(false); + filteredRows.accept(project, createRowVisitor(project, changes)); + + return new HistoryEntry( + project, + (_flagged ? "Flag" : "Unflag") + " " + changes.size() + " rows", + this, + new MassChange(changes, false) + ); + } + + protected RowVisitor createRowVisitor(Project project, List changes) throws Exception { + return new RowVisitor() { + List changes; + + public RowVisitor init(List changes) { + this.changes = changes; + return this; + } + + public boolean visit(Project project, int rowIndex, Row row, boolean includeContextual, boolean includeDependent) { + if (row.starred != _flagged) { + RowFlagChange change = new RowFlagChange(rowIndex, _flagged); + + changes.add(change); + } + return false; + } + }.init(changes); + } +} diff --git a/src/main/webapp/about.html b/src/main/webapp/about.html index 70fb668e9..d0aa096bc 100644 --- a/src/main/webapp/about.html +++ b/src/main/webapp/about.html @@ -1 +1 @@ - About Freebase Gridworks

About Freebase Gridworks

Freebase Gridworks is a power tool that allows you to load data, understand it, clean it up, reconcile it internally, and augment it with data coming from Freebase. All with the comfort and privacy of your own computer.

It was originally developed by Metaweb Technologies, Inc.

License

/*
 * Copyright (c) 2010, Metaweb Technologies, Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *  2. Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY METAWEB TECHNOLOGIES AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METAWEB
 * TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

Dependencies Licenses

licenses/apache2.0.LICENSE.txt
    ant (package org.apache.tools.tar)
    bzip2 (package org.apache.tools.bzip2)
    calendar-parser (package com.metaweb.gridworks.expr.util)
    commons-lang
    commons-codec
    jackson
    jdatapath
    jetty
    jetty-util
    log4j
    poi
    poi-ooxml
    poi-ooxml-schemas
    servlet-api
    xmlbeans
 
licenses/secondstring.LICENSE.txt (BSD family)
    secondstring

licenses/dom4j.LICENSE.txt (BSD family)
    dom4j
    
licenses/simile.LICENSE.txt (BSD family)
    vicino (package edu.mit.simile.vicino)

licenses/arithcode.LICENSE.txt (BSD family)
    arithcode
       
licenses/icu4j.LICENSE.txt (MIT family)
    icu4j
   
licenses/slf4j.LICENSE.txt (MIT family)
    slf4j-api
    slf4j-log4j12
    jcl-over-slf4j

licenses/json.LICENSE.txt (MIT family)    
    json
    
licenses/cos.LICENSE.txt
    cos

Credits

Special Thanks

\ No newline at end of file + About Freebase Gridworks

About Freebase Gridworks

Freebase Gridworks is a power tool that allows you to load data, understand it, clean it up, reconcile it internally, and augment it with data coming from Freebase. All with the comfort and privacy of your own computer.

It was originally developed by Metaweb Technologies, Inc.

License

/*
 * Copyright (c) 2010, Metaweb Technologies, Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *  2. Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY METAWEB TECHNOLOGIES AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METAWEB
 * TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

Dependencies Licenses

licenses/apache2.0.LICENSE.txt
    ant (package org.apache.tools.tar)
    bzip2 (package org.apache.tools.bzip2)
    calendar-parser (package com.metaweb.gridworks.expr.util)
    commons-lang
    commons-codec
    jackson
    jdatapath
    jetty
    jetty-util
    log4j
    poi
    poi-ooxml
    poi-ooxml-schemas
    servlet-api
    xmlbeans
 
licenses/secondstring.LICENSE.txt (BSD family)
    secondstring

licenses/dom4j.LICENSE.txt (BSD family)
    dom4j
    
licenses/simile.LICENSE.txt (BSD family)
    vicino (package edu.mit.simile.vicino)

licenses/arithcode.LICENSE.txt (BSD family)
    arithcode
       
licenses/icu4j.LICENSE.txt (MIT family)
    icu4j
   
licenses/slf4j.LICENSE.txt (MIT family)
    slf4j-api
    slf4j-log4j12
    jcl-over-slf4j

licenses/json.LICENSE.txt (MIT family)    
    json
    
licenses/cos.LICENSE.txt
    cos
    
Flag icon, free for commercial reuse
    http://pixel-mixer.com/category/free-icons/

Credits

Special Thanks

\ No newline at end of file diff --git a/src/main/webapp/images/star-flag-map.png b/src/main/webapp/images/star-flag-map.png index d6af94d2f814fe78d00f80813378002f776d3eae..eeb18d212738945e36e6d8fa264fc10cbe69f743 100644 GIT binary patch delta 1566 zcmV+(2I2XN2Gb0XNPh+ONklA-14M zv;>HfJ_yD@LnM}4rMufL@y(N*oSB_7zxn3OIp53@-J*)^&B2D_UoiVY_LZH!=~12?h(GWIRDMEo`1rwtU63 zN*2&KgD8PvfMH?*4WPeS63H1hRIdkGYL*XZ;+PlWiYA($^0llsOg( zCQ`e%pY{3&qt9YaL^zJq!I%fb2!q!cA`HE1Bw(a9h72PP<0Pk7A{pNCLa9_U*6 zO4Gv0?(6_smw&wto8O^c)Gkp?5SjT^4#NY(kR1RFcJTr2e9B%O46mOx_usjoEwks9 zvES;o0e|Eu47bA&M={v^uw_l?dxB_O-Bwp^wuoXhl1gn{*LiB|mZRs{Hd`rd#i&^{ z@3MqphQZ@J8Abp`h;6f#!d8r$MRS(+j&EA7b)H$}$FpV6d=0BCYo56DLh!?mrEDnM z3S`VG7|k%2z-YvN1*ig=kmI6Vz(Qgsj z8K|Y2-&yLfQ;)gx1tF>z5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SGr++&9t_HiTuIP;U+>s8CoBEILfBXbML7gk)7t5C~JfEGPD;+{i6h%?A zfzbuVS}-JzA%n4oF&4pC;uy2V)Y$lE}^V;cYTwS9`bh9)Ao5s%@UQJ^dkbeBw3Kk70OM z%?>7l%mYRUjCEi*bQs^k_y)!lhI8~x)U4S8AH0zpJQ?q4@o5F5`frY+dk6lOPf<>U z8ebd12!dhP3IKx+|IEjeHaiF&+0pqY7I=$xdFfe%7ocMVcYz^SVNiV3YXW+Oh}hwD zc$4Ck<$qGKTpk(DK0SN-!3*kBrclPPDr%UPU?^Zn*tZPE0vHAAQ>IYHuqvu+neki6 zne4Nnd3;;?=10h>YCe8 0) { var tr = table.insertRow(table.rows.length); tr.insertCell(0); // star - tr.insertCell(1); // row index + tr.insertCell(1); // flag + tr.insertCell(2); // row index for (var c = 0; c < columns.length; c++) { var td = tr.insertCell(tr.cells.length); @@ -143,7 +144,8 @@ DataTableView.prototype._renderDataTable = function(table) { if (groups.length > 0) { var tr = table.insertRow(table.rows.length); tr.insertCell(0); // star - tr.insertCell(1); // row index + tr.insertCell(1); // flag + tr.insertCell(2); // row index for (var c = 0; c < columns.length; c++) { var foundGroup = false; @@ -197,7 +199,7 @@ DataTableView.prototype._renderDataTable = function(table) { var trHead = table.insertRow(table.rows.length); DOM.bind( $(trHead.insertCell(trHead.cells.length)) - .attr("colspan", "2") + .attr("colspan", "3") .addClass("column-header") .html( '' + @@ -260,6 +262,27 @@ DataTableView.prototype._renderDataTable = function(table) { "json" ); }); + + var tdFlag = tr.insertCell(tr.cells.length); + var flag = $(' ') + .addClass(row.flagged ? "data-table-flag-on" : "data-table-flag-off") + .appendTo(tdFlag) + .click(function() { + var newFlagged = !row.flagged; + + Gridworks.postProcess( + "annotate-one-row", + { row: row.i, flagged: newFlagged }, + null, + {}, + { onDone: function(o) { + row.flagged = newFlagged; + renderRow(tr, r, row, even); + } + }, + "json" + ); + }); var tdIndex = tr.insertCell(tr.cells.length); if ("j" in row) { @@ -345,6 +368,22 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) { } ); } + }, + { + label: "Facet by Flag", + click: function() { + ui.browsingEngine.addFacet( + "list", + { + "name" : "Flagged Rows", + "columnName" : "", + "expression" : "row.flagged" + }, + { + "scroll" : false + } + ); + } } ] }, @@ -364,7 +403,20 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) { }, {}, { - label: "Remove Matching Rows", + label: "Flag Rows", + click: function() { + Gridworks.postProcess("annotate-rows", { "flagged" : "true" }, null, { rowMetadataChanged: true }); + } + }, + { + label: "Unflag Rows", + click: function() { + Gridworks.postProcess("annotate-rows", { "flagged" : "false" }, null, { rowMetadataChanged: true }); + } + }, + {}, + { + label: "Remove All Matching Rows", click: function() { Gridworks.postProcess("remove-rows", {}, null, { rowMetadataChanged: true }); } diff --git a/src/main/webapp/styles/views/data-table-view.css b/src/main/webapp/styles/views/data-table-view.css index 9eaa4c652..30c3fc7ab 100644 --- a/src/main/webapp/styles/views/data-table-view.css +++ b/src/main/webapp/styles/views/data-table-view.css @@ -200,7 +200,7 @@ a.data-table-recon-match-similar:hover { background-position: 0px -17px; } -a.data-table-star-on, a.data-table-star-off { +a.data-table-star-on, a.data-table-star-off, a.data-table-flag-on, a.data-table-flag-off { display: block; width: 16px; height: 16px; @@ -208,12 +208,18 @@ a.data-table-star-on, a.data-table-star-off { background-repeat: no-repeat; text-decoration: none; } -a.data-table-star-on { +a.data-table-star-on, a.data-table-star-off:hover { background-position: 0px 0px; } -a.data-table-star-off { +a.data-table-star-off, a.data-table-star-on:hover { background-position: -17px 0px; } +a.data-table-flag-on, a.data-table-flag-off:hover { + background-position: 0px -17px; +} +a.data-table-flag-off, a.data-table-flag-on:hover { + background-position: -17px -17px; +} .data-table-cell-editor { border: 1px solid #ccc;