From 367796488ee7d272d0aab0b354421517aa0f012a Mon Sep 17 00:00:00 2001 From: David Huynh Date: Wed, 25 Aug 2010 06:17:08 +0000 Subject: [PATCH] Fixed xml importer: subgroups should now line up properly by rows. Added command to reorder columns using drag and drop. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1227 7d457c2a-affb-35e4-300a-418c747d4874 --- .../column/ReorderColumnsCommand.java | 25 ++++ .../importers/XmlImportUtilities.java | 91 +++++++------- .../gridworks/importers/XmlImporter.java | 6 +- .../google/gridworks/model/RecordModel.java | 2 +- .../model/changes/ColumnReorderChange.java | 114 ++++++++++++++++++ .../column/ColumnReorderOperation.java | 60 +++++++++ .../google/gridworks/util/JSONUtilities.java | 12 ++ .../importers/XmlImportUtilitiesStub.java | 4 +- .../importers/XmlImportUtilitiesTests.java | 12 +- .../webapp/modules/core/MOD-INF/controller.js | 4 + .../dialogs/column-reordering-dialog.html | 17 +++ .../dialogs/column-reordering-dialog.js | 48 ++++++++ .../views/data-table/data-table-view.js | 12 +- .../dialogs/column-reordering-dialog.css | 14 +++ 14 files changed, 359 insertions(+), 62 deletions(-) create mode 100644 main/src/com/google/gridworks/commands/column/ReorderColumnsCommand.java create mode 100644 main/src/com/google/gridworks/model/changes/ColumnReorderChange.java create mode 100644 main/src/com/google/gridworks/operations/column/ColumnReorderOperation.java create mode 100644 main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.html create mode 100644 main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js create mode 100644 main/webapp/modules/core/styles/dialogs/column-reordering-dialog.css diff --git a/main/src/com/google/gridworks/commands/column/ReorderColumnsCommand.java b/main/src/com/google/gridworks/commands/column/ReorderColumnsCommand.java new file mode 100644 index 000000000..2a1a7e55c --- /dev/null +++ b/main/src/com/google/gridworks/commands/column/ReorderColumnsCommand.java @@ -0,0 +1,25 @@ +package com.google.gridworks.commands.column; + +import javax.servlet.http.HttpServletRequest; + +import org.json.JSONObject; + +import com.google.gridworks.commands.EngineDependentCommand; +import com.google.gridworks.model.AbstractOperation; +import com.google.gridworks.model.Project; +import com.google.gridworks.operations.column.ColumnReorderOperation; +import com.google.gridworks.util.JSONUtilities; +import com.google.gridworks.util.ParsingUtilities; + +public class ReorderColumnsCommand extends EngineDependentCommand { + + @Override + protected AbstractOperation createOperation(Project project, + HttpServletRequest request, JSONObject engineConfig) throws Exception { + + String columnNames = request.getParameter("columnNames"); + return new ColumnReorderOperation( + JSONUtilities.toStringList( + ParsingUtilities.evaluateJsonStringToArray(columnNames))); + } +} diff --git a/main/src/com/google/gridworks/importers/XmlImportUtilities.java b/main/src/com/google/gridworks/importers/XmlImportUtilities.java index 5afb35d94..47d0e7e4c 100644 --- a/main/src/com/google/gridworks/importers/XmlImportUtilities.java +++ b/main/src/com/google/gridworks/importers/XmlImportUtilities.java @@ -54,6 +54,7 @@ public class XmlImportUtilities { static public class ImportColumnGroup extends ImportVertical { public Map subgroups = new HashMap(); public Map columns = new HashMap(); + public int nextRowIndex; @Override void tabulate() { @@ -73,11 +74,13 @@ public class XmlImportUtilities { * */ static public class ImportColumn extends ImportVertical { - public int cellIndex; - public boolean blankOnFirstRow; + public int cellIndex; + public int nextRowIndex; + public boolean blankOnFirstRow; - public ImportColumn(){} - public ImportColumn(String name){ //required for testing + public ImportColumn() {} + + public ImportColumn(String name) { //required for testing super.name = name; } @@ -93,7 +96,6 @@ public class XmlImportUtilities { */ static public class ImportRecord { public List> rows = new LinkedList>(); - public List columnEmptyRowIndices = new ArrayList(); } static public String[] detectPathFromTag(InputStream inputStream, String tag) { @@ -319,6 +321,7 @@ public class XmlImportUtilities { } } } catch (Exception e) { + e.printStackTrace(); // silent } } @@ -437,15 +440,19 @@ public class XmlImportUtilities { if (record.rows.size() > 0) { for (List row : record.rows) { Row realRow = new Row(row.size()); + int cellCount = 0; for (int c = 0; c < row.size(); c++) { Cell cell = row.get(c); if (cell != null) { realRow.setCell(c, cell); + cellCount++; } } - - project.rows.add(realRow); + + if (cellCount > 0) { + project.rows.add(realRow); + } } } } @@ -472,16 +479,9 @@ public class XmlImportUtilities { project, columnGroup, composeName(parser.getPrefix(), parser.getLocalName())); - - int commonStartingRowIndex = 0; - for (ImportColumn column : thisColumnGroup.columns.values()) { - if (column.cellIndex < record.columnEmptyRowIndices.size()) { - commonStartingRowIndex = Math.max( - commonStartingRowIndex, - record.columnEmptyRowIndices.get(column.cellIndex)); - } - } - + + thisColumnGroup.nextRowIndex = Math.max(thisColumnGroup.nextRowIndex, columnGroup.nextRowIndex); + int attributeCount = parser.getAttributeCount(); for (int i = 0; i < attributeCount; i++) { String text = parser.getAttributeValue(i).trim(); @@ -491,8 +491,7 @@ public class XmlImportUtilities { thisColumnGroup, record, composeName(parser.getAttributePrefix(i), parser.getAttributeLocalName(i)), - text, - commonStartingRowIndex + text ); } } @@ -515,25 +514,22 @@ public class XmlImportUtilities { thisColumnGroup, record, null, - parser.getText(), - commonStartingRowIndex + parser.getText() ); } } else if (eventType == XMLStreamConstants.END_ELEMENT) { break; } } - - if (commonStartingRowIndex < record.rows.size()) { - List startingRow = record.rows.get(commonStartingRowIndex); - - for (ImportColumn c : thisColumnGroup.columns.values()) { - int cellIndex = c.cellIndex; - if (cellIndex >= startingRow.size() || startingRow.get(cellIndex) == null) { - c.blankOnFirstRow = true; - } - } + + int nextRowIndex = thisColumnGroup.nextRowIndex; + for (ImportColumn column2 : thisColumnGroup.columns.values()) { + nextRowIndex = Math.max(nextRowIndex, column2.nextRowIndex); } + for (ImportColumnGroup columnGroup2 : thisColumnGroup.subgroups.values()) { + nextRowIndex = Math.max(nextRowIndex, columnGroup2.nextRowIndex); + } + thisColumnGroup.nextRowIndex = nextRowIndex; } static protected void addCell( @@ -541,38 +537,32 @@ public class XmlImportUtilities { ImportColumnGroup columnGroup, ImportRecord record, String columnLocalName, - String text, - int commonStartingRowIndex + String text ) { if (text == null || ((String) text).isEmpty()) { return; } - + Serializable value = ImporterUtilities.parseCellValue(text); - + ImportColumn column = getColumn(project, columnGroup, columnLocalName); int cellIndex = column.cellIndex; - - while (cellIndex >= record.columnEmptyRowIndices.size()) { - record.columnEmptyRowIndices.add(commonStartingRowIndex); - } - int rowIndex = record.columnEmptyRowIndices.get(cellIndex); - + + int rowIndex = Math.max(columnGroup.nextRowIndex, column.nextRowIndex); while (rowIndex >= record.rows.size()) { record.rows.add(new ArrayList()); } + List row = record.rows.get(rowIndex); - while (cellIndex >= row.size()) { row.add(null); } - + logger.trace("Adding cell with value : \"" + value + "\" to row : " + rowIndex + " at cell index : " + (cellIndex-1)); - - row.set(cellIndex-1, new Cell(value, null)); - - record.columnEmptyRowIndices.set(cellIndex, rowIndex + 1); - + + row.set(cellIndex, new Cell(value, null)); + + column.nextRowIndex = rowIndex + 1; column.nonBlankCount++; } @@ -604,7 +594,8 @@ public class XmlImportUtilities { (localName == null ? columnGroup.name : (columnGroup.name + " - " + localName)); newColumn.cellIndex = project.columnModel.allocateNewCellIndex(); - + newColumn.nextRowIndex = columnGroup.nextRowIndex; + return newColumn; } @@ -635,6 +626,8 @@ public class XmlImportUtilities { (localName == null ? "Text" : localName) : (localName == null ? columnGroup.name : (columnGroup.name + " - " + localName)); + newGroup.nextRowIndex = columnGroup.nextRowIndex; + return newGroup; } } diff --git a/main/src/com/google/gridworks/importers/XmlImporter.java b/main/src/com/google/gridworks/importers/XmlImporter.java index a96057335..bb1f17bd5 100644 --- a/main/src/com/google/gridworks/importers/XmlImporter.java +++ b/main/src/com/google/gridworks/importers/XmlImporter.java @@ -52,14 +52,14 @@ public class XmlImporter implements StreamImporter { } } - if(recordPath == null) + if (recordPath == null) return; - + ImportColumnGroup rootColumnGroup = new ImportColumnGroup(); XmlImportUtilities.importXml(pis, project, recordPath, rootColumnGroup); XmlImportUtilities.createColumnsFromImport(project, rootColumnGroup); - + project.columnModel.update(); } diff --git a/main/src/com/google/gridworks/model/RecordModel.java b/main/src/com/google/gridworks/model/RecordModel.java index 923c4d281..faa3ce877 100644 --- a/main/src/com/google/gridworks/model/RecordModel.java +++ b/main/src/com/google/gridworks/model/RecordModel.java @@ -164,7 +164,7 @@ public class RecordModel implements Jsonizable { int c = 0; for (int i = 0; i < group.columnSpan; i++) { int columnIndex = group.startColumnIndex + i; - if (columnIndex != group.keyColumnIndex) { + if (columnIndex != group.keyColumnIndex && columnIndex < columnModel.columns.size()) { int cellIndex = columnModel.columns.get(columnIndex).getCellIndex(); keyedGroup.cellIndices[c++] = cellIndex; } diff --git a/main/src/com/google/gridworks/model/changes/ColumnReorderChange.java b/main/src/com/google/gridworks/model/changes/ColumnReorderChange.java new file mode 100644 index 000000000..e414c5db5 --- /dev/null +++ b/main/src/com/google/gridworks/model/changes/ColumnReorderChange.java @@ -0,0 +1,114 @@ +package com.google.gridworks.model.changes; + +import java.io.IOException; +import java.io.LineNumberReader; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import com.google.gridworks.history.Change; +import com.google.gridworks.model.Column; +import com.google.gridworks.model.Project; +import com.google.gridworks.util.Pool; + +public class ColumnReorderChange extends ColumnChange { + final protected List _columnNames; + protected List _oldColumns; + protected List _newColumns; + + public ColumnReorderChange(List columnNames) { + _columnNames = columnNames; + } + + public void apply(Project project) { + synchronized (project) { + if (_newColumns == null) { + _newColumns = new ArrayList(); + _oldColumns = new ArrayList(project.columnModel.columns); + + for (String n : _columnNames) { + Column column = project.columnModel.getColumnByName(n); + if (column != null) { + _newColumns.add(column); + } + } + } + + project.columnModel.columns.clear(); + project.columnModel.columns.addAll(_newColumns); + project.update(); + } + } + + public void revert(Project project) { + synchronized (project) { + project.columnModel.columns.clear(); + project.columnModel.columns.addAll(_oldColumns); + project.update(); + } + } + + public void save(Writer writer, Properties options) throws IOException { + writer.write("columnNameCount="); writer.write(Integer.toString(_columnNames.size())); writer.write('\n'); + for (String n : _columnNames) { + writer.write(n); + writer.write('\n'); + } + writer.write("oldColumnCount="); writer.write(Integer.toString(_oldColumns.size())); writer.write('\n'); + for (Column c : _oldColumns) { + c.save(writer); + writer.write('\n'); + } + writer.write("newColumnCount="); writer.write(Integer.toString(_newColumns.size())); writer.write('\n'); + for (Column c : _newColumns) { + c.save(writer); + writer.write('\n'); + } + writer.write("/ec/\n"); // end of change marker + } + + static public Change load(LineNumberReader reader, Pool pool) throws Exception { + List columnNames = new ArrayList(); + List oldColumns = new ArrayList(); + List newColumns = new ArrayList(); + + String line; + while ((line = reader.readLine()) != null && !"/ec/".equals(line)) { + int equal = line.indexOf('='); + CharSequence field = line.subSequence(0, equal); + + if ("columnNameCount".equals(field)) { + int count = Integer.parseInt(line.substring(equal + 1)); + for (int i = 0; i < count; i++) { + line = reader.readLine(); + if (line != null) { + columnNames.add(line); + } + } + } else if ("oldColumnCount".equals(field)) { + int count = Integer.parseInt(line.substring(equal + 1)); + for (int i = 0; i < count; i++) { + line = reader.readLine(); + if (line != null) { + oldColumns.add(Column.load(line)); + } + } + } else if ("newColumnCount".equals(field)) { + int count = Integer.parseInt(line.substring(equal + 1)); + for (int i = 0; i < count; i++) { + line = reader.readLine(); + if (line != null) { + newColumns.add(Column.load(line)); + } + } + } + } + + ColumnReorderChange change = new ColumnReorderChange(columnNames); + change._oldColumns = oldColumns; + change._newColumns = newColumns; + + return change; + } +} diff --git a/main/src/com/google/gridworks/operations/column/ColumnReorderOperation.java b/main/src/com/google/gridworks/operations/column/ColumnReorderOperation.java new file mode 100644 index 000000000..ae416b878 --- /dev/null +++ b/main/src/com/google/gridworks/operations/column/ColumnReorderOperation.java @@ -0,0 +1,60 @@ +package com.google.gridworks.operations.column; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONWriter; + +import com.google.gridworks.history.HistoryEntry; +import com.google.gridworks.model.AbstractOperation; +import com.google.gridworks.model.Project; +import com.google.gridworks.model.changes.ColumnReorderChange; +import com.google.gridworks.operations.OperationRegistry; +import com.google.gridworks.util.JSONUtilities; + +public class ColumnReorderOperation extends AbstractOperation { + static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { + List columnNames = new ArrayList(); + + JSONUtilities.getStringList(obj, "columnNames", columnNames); + + return new ColumnReorderOperation(columnNames); + } + + final protected List _columnNames; + + public ColumnReorderOperation(List columnNames) { + _columnNames = columnNames; + } + + public void write(JSONWriter writer, Properties options) + throws JSONException { + + writer.object(); + writer.key("op"); writer.value(OperationRegistry.s_opClassToName.get(this.getClass())); + writer.key("description"); writer.value(getBriefDescription(null)); + writer.key("columnNames"); writer.array(); + for (String n : _columnNames) { + writer.value(n); + } + writer.endArray(); + writer.endObject(); + } + + protected String getBriefDescription(Project project) { + return "Reorder columns"; + } + + protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception { + return new HistoryEntry( + historyEntryID, + project, + "Reorder columns", + this, + new ColumnReorderChange(_columnNames) + ); + } +} diff --git a/main/src/com/google/gridworks/util/JSONUtilities.java b/main/src/com/google/gridworks/util/JSONUtilities.java index ca8110816..ef2b56212 100644 --- a/main/src/com/google/gridworks/util/JSONUtilities.java +++ b/main/src/com/google/gridworks/util/JSONUtilities.java @@ -1,5 +1,6 @@ package com.google.gridworks.util; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -140,4 +141,15 @@ public class JSONUtilities { return a2; } + + static public List toStringList(JSONArray a) throws JSONException { + int l = a.length(); + + List list = new ArrayList(); + for (int i = 0; i < l; i++) { + list.add(a.getString(i)); + } + + return list; + } } diff --git a/main/tests/server/src/com/google/gridworks/tests/importers/XmlImportUtilitiesStub.java b/main/tests/server/src/com/google/gridworks/tests/importers/XmlImportUtilitiesStub.java index 463b0c116..802a7f0ea 100644 --- a/main/tests/server/src/com/google/gridworks/tests/importers/XmlImportUtilitiesStub.java +++ b/main/tests/server/src/com/google/gridworks/tests/importers/XmlImportUtilitiesStub.java @@ -26,7 +26,7 @@ public class XmlImportUtilitiesStub extends XmlImportUtilities { super.processRecord(project, parser, rootColumnGroup); } - public void addCellWrapper(Project project, ImportColumnGroup columnGroup, ImportRecord record, String columnLocalName, String text, int commonStartingRowIndex){ - super.addCell(project, columnGroup, record, columnLocalName, text, commonStartingRowIndex); + public void addCellWrapper(Project project, ImportColumnGroup columnGroup, ImportRecord record, String columnLocalName, String text, int commonStartingRowIndex) { + super.addCell(project, columnGroup, record, columnLocalName, text); } } diff --git a/main/tests/server/src/com/google/gridworks/tests/importers/XmlImportUtilitiesTests.java b/main/tests/server/src/com/google/gridworks/tests/importers/XmlImportUtilitiesTests.java index 6352ba30a..615709778 100644 --- a/main/tests/server/src/com/google/gridworks/tests/importers/XmlImportUtilitiesTests.java +++ b/main/tests/server/src/com/google/gridworks/tests/importers/XmlImportUtilitiesTests.java @@ -341,17 +341,17 @@ public class XmlImportUtilitiesTests extends GridworksTest { Assert.assertNotNull(record); Assert.assertNotNull(record.rows); - Assert.assertNotNull(record.columnEmptyRowIndices); + //Assert.assertNotNull(record.columnEmptyRowIndices); Assert.assertEquals(record.rows.size(), 1); - Assert.assertEquals(record.columnEmptyRowIndices.size(), 2); + //Assert.assertEquals(record.columnEmptyRowIndices.size(), 2); Assert.assertNotNull(record.rows.get(0)); - Assert.assertNotNull(record.columnEmptyRowIndices.get(0)); - Assert.assertNotNull(record.columnEmptyRowIndices.get(1)); + //Assert.assertNotNull(record.columnEmptyRowIndices.get(0)); + //Assert.assertNotNull(record.columnEmptyRowIndices.get(1)); Assert.assertEquals(record.rows.get(0).size(), 2); Assert.assertNotNull(record.rows.get(0).get(0)); Assert.assertEquals(record.rows.get(0).get(0).value, "Author1, The"); - Assert.assertEquals(record.columnEmptyRowIndices.get(0).intValue(),0); - Assert.assertEquals(record.columnEmptyRowIndices.get(1).intValue(),1); + //Assert.assertEquals(record.columnEmptyRowIndices.get(0).intValue(),0); + //Assert.assertEquals(record.columnEmptyRowIndices.get(1).intValue(),1); } diff --git a/main/webapp/modules/core/MOD-INF/controller.js b/main/webapp/modules/core/MOD-INF/controller.js index 3a9bafdd5..1278ab796 100644 --- a/main/webapp/modules/core/MOD-INF/controller.js +++ b/main/webapp/modules/core/MOD-INF/controller.js @@ -57,6 +57,7 @@ function registerCommands() { GS.registerCommand(module, "split-column", new Packages.com.google.gridworks.commands.column.SplitColumnCommand()); GS.registerCommand(module, "extend-data", new Packages.com.google.gridworks.commands.column.ExtendDataCommand()); GS.registerCommand(module, "add-column-by-fetching-urls", new Packages.com.google.gridworks.commands.column.AddColumnByFetchingURLsCommand()); + GS.registerCommand(module, "reorder-columns", new Packages.com.google.gridworks.commands.column.ReorderColumnsCommand()); GS.registerCommand(module, "denormalize", new Packages.com.google.gridworks.commands.row.DenormalizeCommand()); @@ -120,6 +121,7 @@ function registerOperations() { OR.registerOperation(module, "column-split", Packages.com.google.gridworks.operations.column.ColumnSplitOperation); OR.registerOperation(module, "extend-data", Packages.com.google.gridworks.operations.column.ExtendDataOperation); OR.registerOperation(module, "column-addition-by-fetching-urls", Packages.com.google.gridworks.operations.column.ColumnAdditionByFetchingURLsOperation); + OR.registerOperation(module, "column-reorder", Packages.com.google.gridworks.operations.column.ColumnReorderOperation); OR.registerOperation(module, "row-removal", Packages.com.google.gridworks.operations.row.RowRemovalOperation); OR.registerOperation(module, "row-star", Packages.com.google.gridworks.operations.row.RowStarOperation); @@ -228,6 +230,7 @@ function init() { "scripts/dialogs/scatterplot-dialog.js", "scripts/dialogs/extend-data-preview-dialog.js", "scripts/dialogs/templating-exporter-dialog.js", + "scripts/dialogs/column-reordering-dialog.js", "scripts/protograph/schema-alignment.js", "scripts/protograph/schema-alignment-ui-node.js", @@ -266,6 +269,7 @@ function init() { "styles/dialogs/scatterplot-dialog.css", "styles/dialogs/freebase-loading-dialog.css", "styles/dialogs/extend-data-preview-dialog.css", + "styles/dialogs/column-reordering-dialog.css", "styles/reconciliation/recon-dialog.css", "styles/reconciliation/standard-service-panel.css", diff --git a/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.html b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.html new file mode 100644 index 000000000..5c80b0f83 --- /dev/null +++ b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.html @@ -0,0 +1,17 @@ +
+
Re-order Columns
+
+ + + + + + + + +
Drag columns to re-orderDrop columns here to remove
+ +
\ No newline at end of file diff --git a/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js new file mode 100644 index 000000000..3e938223a --- /dev/null +++ b/main/webapp/modules/core/scripts/dialogs/column-reordering-dialog.js @@ -0,0 +1,48 @@ +function ColumnReorderingDialog() { + this._createDialog(); +} + +ColumnReorderingDialog.prototype._createDialog = function() { + var self = this; + var dialog = $(DOM.loadHTML("core", "scripts/dialogs/column-reordering-dialog.html")); + this._elmts = DOM.bind(dialog); + this._elmts.cancelButton.click(function() { self._dismiss(); }); + this._elmts.okButton.click(function() { self._commit(); }); + + this._level = DialogSystem.showDialog(dialog); + + for (var i = 0; i < theProject.columnModel.columns.length; i++) { + var column = theProject.columnModel.columns[i]; + var name = column.name; + + $('
') + .addClass("column-reordering-dialog-column") + .text(name) + .attr("column", name) + .appendTo(this._elmts.columnContainer); + } + + dialog.find('.column-reordering-dialog-column-container') + .sortable({ + connectWith: '.column-reordering-dialog-column-container' + }) + .disableSelection(); +}; + +ColumnReorderingDialog.prototype._dismiss = function() { + DialogSystem.dismissUntil(this._level - 1); +}; + +ColumnReorderingDialog.prototype._commit = function() { + var columnNames = this._elmts.columnContainer.find('div').map(function() { return this.getAttribute("column"); }).get(); + + Gridworks.postCoreProcess( + "reorder-columns", + null, + { "columnNames" : JSON.stringify(columnNames) }, + { modelsChanged: true }, + { includeEngine: false } + ); + + this._dismiss(); +}; diff --git a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js index 7c34151c2..20b860072 100644 --- a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js +++ b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js @@ -502,6 +502,16 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) { } ] }, + { label: "Edit Columns", + submenu: [ + { + label: "Re-order Columns", + click: function() { + new ColumnReorderingDialog(); + } + } + ] + }, { label: "View", submenu: [ { @@ -522,7 +532,7 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) { } ] } - ], elmt, { width: "80px", horizontal: false }); + ], elmt, { width: "120px", horizontal: false }); }; DataTableView.prototype._createSortingMenu = function(elmt) { diff --git a/main/webapp/modules/core/styles/dialogs/column-reordering-dialog.css b/main/webapp/modules/core/styles/dialogs/column-reordering-dialog.css new file mode 100644 index 000000000..c61491eb1 --- /dev/null +++ b/main/webapp/modules/core/styles/dialogs/column-reordering-dialog.css @@ -0,0 +1,14 @@ +.column-reordering-dialog-column { + border: 1px solid #aaa; + background: #eee; + padding: 3px; + margin: 2px; + cursor: move; +} + +.column-reordering-dialog-column-container { + height: 500px; + border: 1px solid #eee; + padding: 10px; + overflow: auto; +} \ No newline at end of file