From 9abf1117bfde7b037c2a6d0f60b424e0f6883f10 Mon Sep 17 00:00:00 2001 From: koutsoub Date: Thu, 13 Jan 2011 16:09:07 +0200 Subject: [PATCH] select row on right click --- src/gr/ebs/gss/client/FileList.java | 46 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/gr/ebs/gss/client/FileList.java b/src/gr/ebs/gss/client/FileList.java index 1024ab8..8c0fb79 100644 --- a/src/gr/ebs/gss/client/FileList.java +++ b/src/gr/ebs/gss/client/FileList.java @@ -37,9 +37,14 @@ import java.util.Iterator; import java.util.List; import com.google.gwt.cell.client.ImageResourceCell; +import com.google.gwt.cell.client.Cell.Context; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.RepeatingCommand; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.dom.client.TableCellElement; +import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.http.client.URL; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.resources.client.ClientBundle; @@ -242,7 +247,25 @@ public class FileList extends Composite { } }; - celltable = new CellTable(keyProvider); + final TextColumn nameColumn = new TextColumn() { + + @Override + public String getValue(FileResource object) { + // TODO Auto-generated method stub + return object.getName(); + } + + + }; + celltable = new CellTable(keyProvider){ + @Override + protected void onBrowserEvent2(Event event) { + if (DOM.eventGetType((Event) event) == Event.ONMOUSEDOWN && DOM.eventGetButton((Event) event) == NativeEvent.BUTTON_RIGHT){ + fireClickEvent((Element) event.getEventTarget().cast()); + } + super.onBrowserEvent2(event); + } + }; Column status = new Column(new ImageResourceCell()) { @@ -252,13 +275,7 @@ public class FileList extends Composite { } }; celltable.addColumn(status,""); - TextColumn nameColumn = new TextColumn() { - - @Override - public String getValue(FileResource object) { - // TODO Auto-generated method stub - return object.getName(); - }}; + celltable.addColumn(nameColumn,"Name"); celltable.addColumn(new TextColumn() { @@ -330,7 +347,12 @@ public class FileList extends Composite { sinkEvents(Event.ONDBLCLICK); GSS.preventIESelection(); } - + public native void fireClickEvent(Element element) /*-{ + var evObj = $doc.createEvent('MouseEvents'); + evObj.initEvent('click', true, true); + element.dispatchEvent(evObj); + }-*/; + public List getSelectedFiles() { return new ArrayList(selectionModel.getSelectedSet()); } @@ -491,7 +513,7 @@ public class FileList extends Composite { * * @param newHeight the new height to reach */ - void resizeTableHeight(final int newHeight) { + //void resizeTableHeight(final int newHeight) { /*GWT.log("Panel: " + newHeight + ", parent: " + table.getParent().getOffsetHeight(), null); // Fill the rest with empty slots. if (newHeight > table.getOffsetHeight()) @@ -504,7 +526,7 @@ public class FileList extends Composite { table.resizeRows(table.getRowCount() - 1); GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null); }*/ - } + //} public void updateFileCache(boolean updateSelectedFolder, final boolean clearSelection) { updateFileCache(updateSelectedFolder, clearSelection, null); @@ -814,5 +836,7 @@ public class FileList extends Composite { }*/ return -1; } + + } -- 1.7.10.4