From e0d72c81e9292ef485a806e5ff7adbe4afc58fab Mon Sep 17 00:00:00 2001 From: David Huynh Date: Sun, 7 Mar 2010 00:25:00 +0000 Subject: [PATCH] Renamed "facet-based edit" operation and command to "mass edit", because it's not just facet-based. Added option "apply to other cells with same original content" to single cell edit popup, so it can be used like a find&replace operation. Renamed "do-text-transform" operation and command to just "text-transform". git-svn-id: http://google-refine.googlecode.com/svn/trunk@223 7d457c2a-affb-35e4-300a-418c747d4874 --- .../metaweb/gridworks/GridworksServlet.java | 13 +-- ...dEditCommand.java => MassEditCommand.java} | 8 +- ...Command.java => TextTransformCommand.java} | 2 +- ...tOperation.java => MassEditOperation.java} | 21 +++-- .../operations/OperationRegistry.java | 1 + .../dialogs/facet-based-edit-dialog.js | 2 +- .../scripts/views/data-table-cell-ui.js | 82 +++++++++++++------ .../views/data-table-column-header-ui.js | 2 +- .../webapp/styles/views/data-table-view.css | 14 +++- 9 files changed, 97 insertions(+), 48 deletions(-) rename src/main/java/com/metaweb/gridworks/commands/edit/{FacetBasedEditCommand.java => MassEditCommand.java} (71%) rename src/main/java/com/metaweb/gridworks/commands/edit/{DoTextTransformCommand.java => TextTransformCommand.java} (92%) rename src/main/java/com/metaweb/gridworks/operations/{FacetBasedEditOperation.java => MassEditOperation.java} (86%) diff --git a/src/main/java/com/metaweb/gridworks/GridworksServlet.java b/src/main/java/com/metaweb/gridworks/GridworksServlet.java index ab9fdd653..d902c2771 100644 --- a/src/main/java/com/metaweb/gridworks/GridworksServlet.java +++ b/src/main/java/com/metaweb/gridworks/GridworksServlet.java @@ -16,9 +16,9 @@ import com.metaweb.gridworks.commands.edit.AnnotateRowsCommand; import com.metaweb.gridworks.commands.edit.ApplyOperationsCommand; import com.metaweb.gridworks.commands.edit.CreateProjectCommand; import com.metaweb.gridworks.commands.edit.DeleteProjectCommand; -import com.metaweb.gridworks.commands.edit.DoTextTransformCommand; +import com.metaweb.gridworks.commands.edit.TextTransformCommand; import com.metaweb.gridworks.commands.edit.EditOneCellCommand; -import com.metaweb.gridworks.commands.edit.FacetBasedEditCommand; +import com.metaweb.gridworks.commands.edit.MassEditCommand; import com.metaweb.gridworks.commands.edit.JoinMultiValueCellsCommand; import com.metaweb.gridworks.commands.edit.RemoveColumnCommand; import com.metaweb.gridworks.commands.edit.SaveProtographCommand; @@ -76,14 +76,15 @@ public class GridworksServlet extends HttpServlet { _commands.put("compute-facets", new ComputeFacetsCommand()); _commands.put("compute-clusters", new ComputeClustersCommand()); - _commands.put("do-text-transform", new DoTextTransformCommand()); - _commands.put("facet-based-edit", new FacetBasedEditCommand()); + _commands.put("edit-one-cell", new EditOneCellCommand()); + _commands.put("text-transform", new TextTransformCommand()); + _commands.put("mass-edit", new MassEditCommand()); + _commands.put("join-multi-value-cells", new JoinMultiValueCellsCommand()); + _commands.put("split-multi-value-cells", new SplitMultiValueCellsCommand()); _commands.put("add-column", new AddColumnCommand()); _commands.put("remove-column", new RemoveColumnCommand()); - _commands.put("join-multi-value-cells", new JoinMultiValueCellsCommand()); - _commands.put("split-multi-value-cells", new SplitMultiValueCellsCommand()); _commands.put("reconcile", new ReconcileCommand()); _commands.put("recon-match-best-candidates", new ReconMatchBestCandidatesCommand()); diff --git a/src/main/java/com/metaweb/gridworks/commands/edit/FacetBasedEditCommand.java b/src/main/java/com/metaweb/gridworks/commands/edit/MassEditCommand.java similarity index 71% rename from src/main/java/com/metaweb/gridworks/commands/edit/FacetBasedEditCommand.java rename to src/main/java/com/metaweb/gridworks/commands/edit/MassEditCommand.java index 08309ecb9..3714cb4e3 100644 --- a/src/main/java/com/metaweb/gridworks/commands/edit/FacetBasedEditCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/edit/MassEditCommand.java @@ -7,10 +7,10 @@ import org.json.JSONObject; import com.metaweb.gridworks.commands.EngineDependentCommand; import com.metaweb.gridworks.model.AbstractOperation; import com.metaweb.gridworks.model.Project; -import com.metaweb.gridworks.operations.FacetBasedEditOperation; +import com.metaweb.gridworks.operations.MassEditOperation; import com.metaweb.gridworks.util.ParsingUtilities; -public class FacetBasedEditCommand extends EngineDependentCommand { +public class MassEditCommand extends EngineDependentCommand { @Override protected AbstractOperation createOperation(Project project, HttpServletRequest request, JSONObject engineConfig) throws Exception { @@ -19,11 +19,11 @@ public class FacetBasedEditCommand extends EngineDependentCommand { String expression = request.getParameter("expression"); String editsString = request.getParameter("edits"); - return new FacetBasedEditOperation( + return new MassEditOperation( engineConfig, columnName, expression, - FacetBasedEditOperation.reconstructEdits(ParsingUtilities.evaluateJsonStringToArray(editsString)) + MassEditOperation.reconstructEdits(ParsingUtilities.evaluateJsonStringToArray(editsString)) ); } } diff --git a/src/main/java/com/metaweb/gridworks/commands/edit/DoTextTransformCommand.java b/src/main/java/com/metaweb/gridworks/commands/edit/TextTransformCommand.java similarity index 92% rename from src/main/java/com/metaweb/gridworks/commands/edit/DoTextTransformCommand.java rename to src/main/java/com/metaweb/gridworks/commands/edit/TextTransformCommand.java index 79a194b50..2ded3fc09 100644 --- a/src/main/java/com/metaweb/gridworks/commands/edit/DoTextTransformCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/edit/TextTransformCommand.java @@ -9,7 +9,7 @@ import com.metaweb.gridworks.model.AbstractOperation; import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.operations.TextTransformOperation; -public class DoTextTransformCommand extends EngineDependentCommand { +public class TextTransformCommand extends EngineDependentCommand { @Override protected AbstractOperation createOperation(Project project, HttpServletRequest request, JSONObject engineConfig) throws Exception { diff --git a/src/main/java/com/metaweb/gridworks/operations/FacetBasedEditOperation.java b/src/main/java/com/metaweb/gridworks/operations/MassEditOperation.java similarity index 86% rename from src/main/java/com/metaweb/gridworks/operations/FacetBasedEditOperation.java rename to src/main/java/com/metaweb/gridworks/operations/MassEditOperation.java index 738c94178..71d4c9445 100644 --- a/src/main/java/com/metaweb/gridworks/operations/FacetBasedEditOperation.java +++ b/src/main/java/com/metaweb/gridworks/operations/MassEditOperation.java @@ -23,8 +23,9 @@ import com.metaweb.gridworks.model.Column; import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Row; import com.metaweb.gridworks.model.changes.CellChange; +import com.metaweb.gridworks.util.ParsingUtilities; -public class FacetBasedEditOperation extends EngineDependentMassCellOperation { +public class MassEditOperation extends EngineDependentMassCellOperation { private static final long serialVersionUID = -7698202759999537298L; final protected String _expression; @@ -59,7 +60,7 @@ public class FacetBasedEditOperation extends EngineDependentMassCellOperation { static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { JSONObject engineConfig = obj.getJSONObject("engineConfig"); - return new FacetBasedEditOperation( + return new MassEditOperation( engineConfig, obj.getString("columnName"), obj.getString("expression"), @@ -82,13 +83,21 @@ public class FacetBasedEditOperation extends EngineDependentMassCellOperation { from.add(fromA.getString(j)); } - edits.add(new Edit(from, editO.getString("to"))); + Serializable to = (Serializable) editO.get("to"); + if (editO.has("type")) { + String type = editO.getString("type"); + if ("date".equals(type)) { + to = ParsingUtilities.stringToDate((String) to); + } + } + + edits.add(new Edit(from, to)); } return edits; } - public FacetBasedEditOperation(JSONObject engineConfig, String columnName, String expression, List edits) { + public MassEditOperation(JSONObject engineConfig, String columnName, String expression, List edits) { super(engineConfig, columnName, true); _expression = expression; _edits = edits; @@ -113,13 +122,13 @@ public class FacetBasedEditOperation extends EngineDependentMassCellOperation { } protected String getBriefDescription(Project project) { - return "Facet-based edit cells in column " + _columnName; + return "Mass edit cells in column " + _columnName; } protected String createDescription(Column column, List cellChanges) { - return "Facet-based edit " + cellChanges.size() + + return "Mass edit " + cellChanges.size() + " cells in column " + column.getName(); } diff --git a/src/main/java/com/metaweb/gridworks/operations/OperationRegistry.java b/src/main/java/com/metaweb/gridworks/operations/OperationRegistry.java index 1c7bdbd2e..26f3c5ec6 100644 --- a/src/main/java/com/metaweb/gridworks/operations/OperationRegistry.java +++ b/src/main/java/com/metaweb/gridworks/operations/OperationRegistry.java @@ -35,5 +35,6 @@ public abstract class OperationRegistry { register("save-protograph", SaveProtographOperation.class); register("text-transform", TextTransformOperation.class); + register("mass-edit", MassEditOperation.class); } } diff --git a/src/main/webapp/scripts/dialogs/facet-based-edit-dialog.js b/src/main/webapp/scripts/dialogs/facet-based-edit-dialog.js index a646bc68b..963ac65aa 100644 --- a/src/main/webapp/scripts/dialogs/facet-based-edit-dialog.js +++ b/src/main/webapp/scripts/dialogs/facet-based-edit-dialog.js @@ -227,7 +227,7 @@ FacetBasedEditDialog.prototype._apply = function(onDone) { if (edits.length > 0) { Gridworks.postProcess( - "facet-based-edit", + "mass-edit", {}, { columnName: this._columnName, diff --git a/src/main/webapp/scripts/views/data-table-cell-ui.js b/src/main/webapp/scripts/views/data-table-cell-ui.js index 2cd14fec1..6dbcf8c70 100644 --- a/src/main/webapp/scripts/views/data-table-cell-ui.js +++ b/src/main/webapp/scripts/views/data-table-cell-ui.js @@ -288,16 +288,31 @@ DataTableCellUI.prototype._previewCandidateTopic = function(id, elmt) { DataTableCellUI.prototype._startEdit = function(elmt) { self = this; + var originalContent = this._cell == null || ("v" in this._cell && this._cell.v == null) ? "" : this._cell.v; + var menu = MenuSystem.createMenu().width("350px"); menu.html( - '