GWT FlexTable - drag selection how?

This needs to be improved but it should give you the basic idea. First you need to create a CustomTable that listens to MouseEvents. You can do this by extending composite to wrap a focuspanel and a flextable as such.

This needs to be improved but it should give you the basic idea. First you need to create a CustomTable that listens to MouseEvents. You can do this by extending composite to wrap a focuspanel and a flextable as such : public class CustomTable extends Composite implements MouseDownHandler, MouseMoveHandler, MouseUpHandler{ List widgets = new ArrayList(); FlexTable table = new FlexTable(); FocusPanel focusPanel = new FocusPanel(); boolean selecting= false; Point selectStart,selectEnd; public CustomTable(){ focusPanel.

SetWidget(table); focusPanel. AddMouseDownHandler(this); focusPanel. AddMouseMoveHandler(this); focusPanel.

AddMouseUpHandler(this); initWidget(focusPanel); } public void setWidget(int row, int column, CellWidget widget){ widgets. Add(widget); table. SetWidget(row, column, widget); } @Override public void onMouseUp(MouseUpEvent event) { event.preventDefault(); if (selecting){ selecting=false; DOM.

ReleaseCapture(this.getElement()); selectEnd = new Point(event.getClientX(),event.getClientY()); for (CellWidget widget : widgets){ if (widget. IsIn(selectStart,selectEnd)) widget.say(); } selectStart = selectEnd = null; } } @Override public void onMouseMove(MouseMoveEvent event) { event.preventDefault(); if (selecting){ //do some fancy layout } } @Override public void onMouseDown(MouseDownEvent event) { event.preventDefault(); selecting = true; DOM. SetCapture(this.getElement()); selectStart = new Point(event.getClientX(),event.getClientY()); } } Next you define a CellWidget which basically encapsulates what you would like to add to your cells.

When added to DOM, CellWidget calculates and stores its position later to determine if it is in the selected area : public class CellWidget extends Composite{ Widget content; Point topLeft,topRight,bottomLeft,bottomRight; public CellWidget(Widget w){ this. Content = w; initWidget(w); } @Override protected void onLoad() { topLeft = new Point(getAbsoluteLeft(),getAbsoluteTop()); topRight = new Point(getAbsoluteLeft()+getOffsetWidth(),getAbsoluteTop()); bottomLeft = new Point(getAbsoluteLeft(),getAbsoluteTop()+getOffsetHeight()); bottomRight = new Point(getAbsoluteLeft()+getOffsetWidth(),getAbsoluteTop()+getOffsetHeight()); } public void say(){ Window. Alert(content + " is selected!"); } public boolean isIn(Point start, Point end){ if (topLeft.

IsBetween(start, end) || topRight. IsBetween(start, end) || bottomLeft. IsBetween(start, end) || bottomRight.

IsBetween(start, end)) return true; else return false; } } A simple point implementation to make things easier : public class Point { int x,y; public Point(int x,int y){ this. X=x; this. Y=y; } public int getX() { return x; } public int getY() { return y; } @Override public String toString() { return x+","+y; } public boolean isBetween(Point p1,Point p2){ if (p1.getX() x && p1.getY() y) return true; return false; } } Finally at your EntryPoint module you wrap things up by : public void onModuleLoad() { RootPanel rootPanel = RootPanel.get(); CustomTable table = new CustomTable(); table.

SetWidget(0, 0, new CellWidget(new Label("hello 0,0"))); table. SetWidget(0, 1, new CellWidget(new Label("hello 0,1"))); table. SetWidget(1, 0, new CellWidget(new Label("hello 1,0"))); table.

SetWidget(1, 1, new CellWidget(new Label("hello 1,1"))); rootPanel. Add(table); } I know that the actual logic to determine if the widgets fall within the selected area is incomplete and needs to be improved but I think this solution is clear enough to give the basic idea.Cheers.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions