From b1fca11342cde9dd822c537cadad37c8e6cb0735 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Wed, 10 Mar 2010 08:32:20 +0000 Subject: [PATCH] Made recon use cells from context rows. Fixed bug in menu left-right positioning. git-svn-id: http://google-refine.googlecode.com/svn/trunk@271 7d457c2a-affb-35e4-300a-418c747d4874 --- .../model/recon/HeuristicReconConfig.java | 19 +++++++++++++++---- .../gridworks/model/recon/ReconConfig.java | 2 +- src/main/webapp/scripts/util/menu.js | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/metaweb/gridworks/model/recon/HeuristicReconConfig.java b/src/main/java/com/metaweb/gridworks/model/recon/HeuristicReconConfig.java index b3d55394a..0acd6d985 100644 --- a/src/main/java/com/metaweb/gridworks/model/recon/HeuristicReconConfig.java +++ b/src/main/java/com/metaweb/gridworks/model/recon/HeuristicReconConfig.java @@ -151,9 +151,20 @@ public class HeuristicReconConfig extends ReconConfig { jsonWriter.key("/type/object/type"); jsonWriter.value(typeID); for (ColumnDetail c : columnDetails) { - int cellIndex = project.columnModel.getColumnByName(c.columnName).getCellIndex(); + int detailCellIndex = project.columnModel.getColumnByName(c.columnName).getCellIndex(); - Cell cell2 = row.getCell(cellIndex); + Cell cell2 = row.getCell(detailCellIndex); + if (cell2 == null || !ExpressionUtils.isNonBlankData(cell2.value)) { + int cellIndex = project.columnModel.getColumnByName(columnName).getCellIndex(); + if (cellIndex < row.contextRowSlots.length) { + int contextRowIndex = row.contextRowSlots[cellIndex]; + if (contextRowIndex >= 0 && contextRowIndex < project.rows.size()) { + Row row2 = project.rows.get(contextRowIndex); + + cell2 = row2.getCell(detailCellIndex); + } + } + } if (cell2 != null && ExpressionUtils.isNonBlankData(cell2.value)) { jsonWriter.key(c.property.id); @@ -293,7 +304,7 @@ public class HeuristicReconConfig extends ReconConfig { recon.setFeature(Recon.Feature_typeMatch, false); for (String typeID : candidate.typeIDs) { - if (typeID.equals(typeID)) { + if (this.typeID.equals(typeID)) { recon.setFeature(Recon.Feature_typeMatch, true); if (autoMatch && score >= 100) { recon.match = candidate; @@ -392,7 +403,7 @@ public class HeuristicReconConfig extends ReconConfig { recon.setFeature(Recon.Feature_typeMatch, false); for (String typeID : candidate.typeIDs) { - if (typeID.equals(typeID)) { + if (this.typeID.equals(typeID)) { recon.setFeature(Recon.Feature_typeMatch, true); if (autoMatch && (score > 0.6 || diff --git a/src/main/java/com/metaweb/gridworks/model/recon/ReconConfig.java b/src/main/java/com/metaweb/gridworks/model/recon/ReconConfig.java index 6b3b26e20..09909204b 100644 --- a/src/main/java/com/metaweb/gridworks/model/recon/ReconConfig.java +++ b/src/main/java/com/metaweb/gridworks/model/recon/ReconConfig.java @@ -33,7 +33,7 @@ abstract public class ReconConfig implements Jsonizable { Project project, int rowIndex, Row row, - String columnName, + String columnName, Cell cell ); diff --git a/src/main/webapp/scripts/util/menu.js b/src/main/webapp/scripts/util/menu.js index b8ecee94a..a88ef4e6b 100644 --- a/src/main/webapp/scripts/util/menu.js +++ b/src/main/webapp/scripts/util/menu.js @@ -79,7 +79,7 @@ MenuSystem.positionMenuLeftRight = function(menu, elmt) { } if (offset.left + elmt.outerWidth() - document.body.scrollLeft + menu.outerWidth() > windowWidth - 10) { - menu.css("left", (offset.left - menu.outerWidth()) + "px"); + menu.css("left", Math.max(10, offset.left - menu.outerWidth()) + "px"); } else { menu.css("left", (offset.left + elmt.outerWidth()) + "px"); }