We need to recompute the row context dependencies after cell and column changes, but not after recon changes.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@56 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-02-06 06:40:17 +00:00
parent bf79b24bf3
commit 2eccab4c71
11 changed files with 40 additions and 10 deletions

View File

@ -43,6 +43,7 @@ public class CreateProjectCommand extends Command {
ProjectManager.singleton.registerProject(project, pm);
project.columnModel.update();
project.recomputeRowContextDependencies();
redirect(response, "/project.html?project=" + project.id);
} catch (Exception e) {

View File

@ -36,6 +36,8 @@ public class ColumnAdditionChange extends ColumnChange {
} catch (Exception e) {
e.printStackTrace();
}
project.columnModel.update();
project.recomputeRowContextDependencies();
}
}
@ -48,6 +50,9 @@ public class ColumnAdditionChange extends ColumnChange {
}
project.columnModel.columns.remove(_columnIndex);
project.columnModel.update();
project.recomputeRowContextDependencies();
}
}

View File

@ -34,6 +34,9 @@ public class ColumnRemovalChange extends ColumnChange {
row.setCell(cellIndex, null);
}
project.columnModel.update();
project.recomputeRowContextDependencies();
}
}
@ -46,6 +49,9 @@ public class ColumnRemovalChange extends ColumnChange {
for (CellAtRow cell : _oldCells) {
project.rows.get(cell.row).cells.set(cellIndex, cell.cell);
}
project.columnModel.update();
project.recomputeRowContextDependencies();
}
}

View File

@ -9,13 +9,16 @@ import com.metaweb.gridworks.model.Row;
public class MassCellChange implements Change {
private static final long serialVersionUID = -933571199802688027L;
protected CellChange[] _cellChanges;
protected int _commonCellIndex;
final protected CellChange[] _cellChanges;
final protected int _commonCellIndex;
final protected boolean _updateRowContextDependencies;
public MassCellChange(List<CellChange> cellChanges, int commonCellIndex) {
public MassCellChange(List<CellChange> cellChanges, int commonCellIndex, boolean updateRowContextDependencies) {
_cellChanges = new CellChange[cellChanges.size()];
_commonCellIndex = commonCellIndex;
cellChanges.toArray(_cellChanges);
_updateRowContextDependencies = updateRowContextDependencies;
}
@Override
@ -30,6 +33,10 @@ public class MassCellChange implements Change {
if (_commonCellIndex >= 0) {
project.columnModel.getColumnByCellIndex(_commonCellIndex).clearPrecomputes();
}
if (_updateRowContextDependencies) {
project.recomputeRowContextDependencies();
}
}
}
@ -45,6 +52,10 @@ public class MassCellChange implements Change {
if (_commonCellIndex >= 0) {
project.columnModel.getColumnByCellIndex(_commonCellIndex).clearPrecomputes();
}
if (_updateRowContextDependencies) {
project.recomputeRowContextDependencies();
}
}
}
}

View File

@ -23,6 +23,8 @@ public class MassRowChange implements Change {
_oldRows = new ArrayList<Row>(project.rows);
project.rows.clear();
project.rows.addAll(_newRows);
project.recomputeRowContextDependencies();
}
}
@ -31,6 +33,8 @@ public class MassRowChange implements Change {
synchronized (project) {
project.rows.clear();
project.rows.addAll(_oldRows);
project.recomputeRowContextDependencies();
}
}

View File

@ -20,7 +20,7 @@ public class ApproveNewReconOperation extends EngineDependentMassCellOperation {
private static final long serialVersionUID = -5205694623711144436L;
public ApproveNewReconOperation(JSONObject engineConfig, int cellIndex) {
super(engineConfig, cellIndex);
super(engineConfig, cellIndex, false);
}
@Override

View File

@ -19,7 +19,7 @@ public class ApproveReconOperation extends EngineDependentMassCellOperation {
private static final long serialVersionUID = 5393888241057341155L;
public ApproveReconOperation(JSONObject engineConfig, int cellIndex) {
super(engineConfig, cellIndex);
super(engineConfig, cellIndex, false);
}
@Override

View File

@ -18,7 +18,7 @@ public class DiscardReconOperation extends EngineDependentMassCellOperation {
private static final long serialVersionUID = 6799029731665369179L;
public DiscardReconOperation(JSONObject engineConfig, int cellIndex) {
super(engineConfig, cellIndex);
super(engineConfig, cellIndex, false);
}
@Override

View File

@ -21,10 +21,13 @@ abstract public class EngineDependentMassCellOperation extends EngineDependentOp
private static final long serialVersionUID = -8962461328087299452L;
final protected int _cellIndex;
final protected boolean _updateRowContextDependencies;
protected EngineDependentMassCellOperation(JSONObject engineConfig, int cellIndex) {
protected EngineDependentMassCellOperation(
JSONObject engineConfig, int cellIndex, boolean updateRowContextDependencies) {
super(engineConfig);
_cellIndex = cellIndex;
_updateRowContextDependencies = updateRowContextDependencies;
}
@Override
@ -43,7 +46,7 @@ abstract public class EngineDependentMassCellOperation extends EngineDependentOp
String description = createDescription(column, cellChanges);
MassCellChange massCellChange = new MassCellChange(cellChanges, _cellIndex);
MassCellChange massCellChange = new MassCellChange(cellChanges, _cellIndex, _updateRowContextDependencies);
HistoryEntry historyEntry = new HistoryEntry(
project, description, this, massCellChange);

View File

@ -160,7 +160,7 @@ public class ReconOperation extends EngineDependentOperation {
}
}
MassCellChange massCellChange = new MassCellChange(cellChanges, _cellIndex);
MassCellChange massCellChange = new MassCellChange(cellChanges, _cellIndex, false);
HistoryEntry historyEntry = new HistoryEntry(
_project,
_description,

View File

@ -23,7 +23,7 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
final protected String _expression;
public TextTransformOperation(JSONObject engineConfig, int cellIndex, String expression) {
super(engineConfig, cellIndex);
super(engineConfig, cellIndex, true);
_expression = expression;
}