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
This commit is contained in:
parent
b9308e4034
commit
e0d72c81e9
@ -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());
|
||||
|
@ -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))
|
||||
);
|
||||
}
|
||||
}
|
@ -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 {
|
@ -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<Edit> edits) {
|
||||
public MassEditOperation(JSONObject engineConfig, String columnName, String expression, List<Edit> 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<CellChange> cellChanges) {
|
||||
|
||||
return "Facet-based edit " + cellChanges.size() +
|
||||
return "Mass edit " + cellChanges.size() +
|
||||
" cells in column " + column.getName();
|
||||
}
|
||||
|
@ -35,5 +35,6 @@ public abstract class OperationRegistry {
|
||||
|
||||
register("save-protograph", SaveProtographOperation.class);
|
||||
register("text-transform", TextTransformOperation.class);
|
||||
register("mass-edit", MassEditOperation.class);
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ FacetBasedEditDialog.prototype._apply = function(onDone) {
|
||||
|
||||
if (edits.length > 0) {
|
||||
Gridworks.postProcess(
|
||||
"facet-based-edit",
|
||||
"mass-edit",
|
||||
{},
|
||||
{
|
||||
columnName: this._columnName,
|
||||
|
@ -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(
|
||||
'<textarea class="data-table-cell-edit-editor" bind="textarea" />' +
|
||||
'<table class="data-table-cell-edit-layout">' +
|
||||
'<tr>' +
|
||||
'<td colspan="4">' +
|
||||
'<textarea class="data-table-cell-edit-editor" bind="textarea" />' +
|
||||
'</td>' +
|
||||
'</tr>' +
|
||||
'<tr>' +
|
||||
'<td>' +
|
||||
'<input type="radio" name="data-table-cell-edit-type" value="text" checked /> text ' +
|
||||
'<input type="radio" name="data-table-cell-edit-type" value="number" /> number ' +
|
||||
'<input type="radio" name="data-table-cell-edit-type" value="boolean" /> boolean' +
|
||||
'<input type="radio" name="data-table-cell-edit-type" value="date" /> date' +
|
||||
'<select bind="typeSelect">' +
|
||||
'<option value="text">text</option>' +
|
||||
'<option value="number">number</option>' +
|
||||
'<option value="boolean">boolean</option>' +
|
||||
'<option value="date">date</option>' +
|
||||
'</select>' +
|
||||
'</td>' +
|
||||
'<td width="1%">' +
|
||||
'<input type="checkbox" bind="applyOthersCheckbox" />' +
|
||||
'</td>' +
|
||||
'<td>' +
|
||||
'apply to other cells with<br/>' +
|
||||
'same original content' +
|
||||
'</td>' +
|
||||
'<td width="1%">' +
|
||||
'<button bind="okButton"> OK </button>' +
|
||||
@ -311,7 +326,9 @@ DataTableCellUI.prototype._startEdit = function(elmt) {
|
||||
MenuSystem.positionMenuLeftRight(menu, $(this._td));
|
||||
|
||||
var commit = function() {
|
||||
var type = $('input["data-table-cell-edit-type"]:checked')[0].value;
|
||||
var type = elmts.typeSelect[0].value;
|
||||
var applyOthers = elmts.applyOthersCheckbox[0].checked;
|
||||
|
||||
var text = elmts.textarea[0].value;
|
||||
var value = text;
|
||||
|
||||
@ -334,16 +351,30 @@ DataTableCellUI.prototype._startEdit = function(elmt) {
|
||||
|
||||
MenuSystem.dismissAll();
|
||||
|
||||
var params = {
|
||||
if (applyOthers) {
|
||||
Gridworks.postProcess(
|
||||
"mass-edit",
|
||||
{},
|
||||
{
|
||||
columnName: Gridworks.cellIndexToColumn(self._cellIndex).name,
|
||||
expression: "value",
|
||||
edits: JSON.stringify([{
|
||||
from: [ originalContent ],
|
||||
to: value,
|
||||
type: type
|
||||
}])
|
||||
},
|
||||
{ cellsChanged: true }
|
||||
);
|
||||
} else {
|
||||
Gridworks.postProcess(
|
||||
"edit-one-cell",
|
||||
{
|
||||
row: self._rowIndex,
|
||||
cell: self._cellIndex,
|
||||
value: value,
|
||||
type: type
|
||||
};
|
||||
|
||||
Gridworks.postProcess(
|
||||
"edit-one-cell",
|
||||
params,
|
||||
},
|
||||
null,
|
||||
{},
|
||||
{
|
||||
@ -353,11 +384,12 @@ DataTableCellUI.prototype._startEdit = function(elmt) {
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
elmts.okButton.click(commit);
|
||||
elmts.textarea
|
||||
.text(this._cell == null || ("v" in this._cell && this._cell.v == null) ? "" : this._cell.v)
|
||||
.text(originalContent)
|
||||
.keydown(function(evt) {
|
||||
if (evt.keyCode == 13) {
|
||||
commit();
|
||||
|
@ -433,7 +433,7 @@ DataTableColumnHeaderUI.prototype._doFilterByExpressionPrompt = function(express
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doTextTransform = function(expression, onError, repeat, repeatCount) {
|
||||
Gridworks.postProcess(
|
||||
"do-text-transform",
|
||||
"text-transform",
|
||||
{
|
||||
columnName: this._column.name,
|
||||
expression: expression,
|
||||
|
@ -167,14 +167,20 @@ table.data-table-cell-edit-layout {
|
||||
width: 100%;
|
||||
white-space: pre;
|
||||
}
|
||||
table.data-table-cell-edit-layout td {
|
||||
padding: 5px;
|
||||
table.data-table-cell-edit-layout > tbody > tr > td {
|
||||
padding-right: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
table.data-table-cell-edit-layout > tbody > tr > td:last-child {
|
||||
padding-right: 0px;
|
||||
}
|
||||
table.data-table-cell-edit-layout > tbody > tr:last-child > td {
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
textarea.data-table-cell-edit-editor {
|
||||
display: block;
|
||||
width: 92%;
|
||||
width: 96%;
|
||||
padding: 2%;
|
||||
margin: 2%;
|
||||
height: 3em;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user