[jboss-svn-commits] JBL Code SVN: r5342 - in labs/jbosslabs/trunk/portal-extensions: ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client ajax-portal/src/web/WEB-INF forge-tagme/src/java/org/jboss/labs/tagme/gwt/client

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jul 28 09:59:18 EDT 2006


Author: szimano
Date: 2006-07-28 09:59:13 -0400 (Fri, 28 Jul 2006)
New Revision: 5342

Removed:
   labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/web/WEB-INF/tld/
Modified:
   labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/DnDContainer.java
   labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/DnDPanel.java
   labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/PortalAjax.java
   labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java
Log:
removing tld from repo


Modified: labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/DnDContainer.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/DnDContainer.java	2006-07-28 13:31:23 UTC (rev 5341)
+++ labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/DnDContainer.java	2006-07-28 13:59:13 UTC (rev 5342)
@@ -1,15 +1,176 @@
 package org.jboss.labs.ajaxportal.gwt.client;
 
+import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.SourcesTableEvents;
 import com.google.gwt.user.client.ui.TableListener;
+import com.google.gwt.user.client.ui.Widget;
 
-public class DnDContainer extends FlexTable implements TableListener {
+public class DnDContainer extends FlexTable implements TableListener,
+		DnDListener {
 
+	private Label label;
+
+	private int dragStartX, dragStartY;
+
+	private int draggedWidgetRow, draggedWidgetCol;
+
+	public DnDContainer(Label label) {
+		this.label = label;
+	}
+
 	public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
-		
+
 	}
 
-	
+	public void objectDragged(Widget sender, int x, int y) {
+		label.setText("Dragging " + String.valueOf(x) + " " + String.valueOf(y)
+				+ " SX: " + dragStartX + " SY: " + dragStartY);
 
+		for (int i = 0; i < this.getRowCount(); i++) {
+			for (int j = 0; j < this.getCellCount(i); j++) {
+				if (/* this.getWidget(i, j) != null && */sender != this
+						.getWidget(i, j)) {
+					CellCoords cellCoords = getCellSize(i, j);
+
+					if (((DnDPanel) sender).intersects(cellCoords.getX(),
+							cellCoords.getY(), cellCoords.getWidth(),
+							cellCoords.getHeight())) {
+
+						label.setText("x: " + cellCoords.getX() + " y: "
+								+ cellCoords.getY() + " w: "
+								+ cellCoords.getWidth() + " h: "
+								+ cellCoords.getHeight() + " ["+i+","+j+"]");
+
+						// label.setText("Cell: "+i+" "+j);
+
+						/*
+						 * dragStartX = this.getWidget(i, j).getAbsoluteLeft();
+						 * dragStartY = this.getWidget(i, j).getAbsoluteTop();
+						 * 
+						 * for (int k = this.getRowCount() - 1; k >= i; k--) {
+						 * Widget w = this.getWidget(k, j); this.remove(w);
+						 * this.setWidget(k + 1, j, w); }
+						 * 
+						 * this.remove(sender); this.setWidget(i, j, sender);
+						 */
+					}
+				}
+			}
+		}
+	}
+
+	public void objectDropped(Widget sender, int x, int y) {
+		label.setText("Dropped " + String.valueOf(x) + " " + String.valueOf(y));
+		((DnDPanel) sender).setMyPosition(dragStartX, dragStartY);
+
+	}
+
+	public void objectPicked(Widget sender, int x, int y) {
+		dragStartX = DOM.getAbsoluteLeft(sender.getElement());
+		dragStartY = DOM.getAbsoluteTop(sender.getElement());
+
+		draggedWidgetRow = draggedWidgetCol = -1;
+
+		for (int i = 0; draggedWidgetRow == -1 && i < this.getRowCount(); i++) {
+			for (int j = 0; draggedWidgetRow == -1 && j < this.getCellCount(i); j++) {
+				if (this.getWidget(i, j) == sender) {
+					draggedWidgetRow = i;
+					draggedWidgetCol = j;
+				}
+			}
+		}
+
+		label.setText("Picked " + String.valueOf(x) + " " + String.valueOf(y));
+	}
+
+	public CellCoords getCellSize(int row, int cell) {
+		//TODO COORDINATES
+		if (row < 0 || row >= this.getRowCount()
+				|| cell >= this.getCellCount(row))
+			return null;
+
+		boolean xFound = false;
+		boolean yFound = false;
+
+		int x = 0;
+		int y = 0;
+		int width = 0;
+		int height = 0;
+
+		for (int i = 0; !xFound && i < this.getCellCount(row); i++) {
+			if (this.getWidget(row, i) != null
+					&& (draggedWidgetRow != row && draggedWidgetCol != i)) {
+				xFound = true;
+				x = this.getWidget(row, i).getAbsoluteLeft();
+				height = this.getWidget(row, i).getOffsetHeight();
+			}
+		}
+
+		for (int i = 0; !yFound && i < this.getRowCount(); i++) {
+			if (this.getWidget(i, cell) != null
+					&& (draggedWidgetRow != i && draggedWidgetCol != cell)) {
+				yFound = true;
+				y = this.getWidget(i, cell).getAbsoluteTop();
+				width = this.getWidget(i, cell).getOffsetWidth();
+			}
+		}
+
+		// couldn't determine coordinates of cell
+		if (!xFound || !yFound)
+			return null;
+
+		return new CellCoords(x, y, width, height);
+	}
+
 }
+
+class CellCoords {
+	private int width;
+
+	private int height;
+
+	private int x;
+
+	private int y;
+
+	public CellCoords(int x, int y, int width, int height) {
+		this.width = width;
+		this.height = height;
+		this.x = x;
+		this.y = y;
+	}
+
+	public int getHeight() {
+		return height;
+	}
+
+	public void setHeight(int height) {
+		this.height = height;
+	}
+
+	public int getWidth() {
+		return width;
+	}
+
+	public void setWidth(int width) {
+		this.width = width;
+	}
+
+	public int getX() {
+		return x;
+	}
+
+	public void setX(int x) {
+		this.x = x;
+	}
+
+	public int getY() {
+		return y;
+	}
+
+	public void setY(int y) {
+		this.y = y;
+	}
+}

Modified: labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/DnDPanel.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/DnDPanel.java	2006-07-28 13:31:23 UTC (rev 5341)
+++ labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/DnDPanel.java	2006-07-28 13:59:13 UTC (rev 5342)
@@ -10,25 +10,38 @@
 public class DnDPanel extends SimplePanel implements MouseListener {
 
 	private HTML caption;
-	private DnDContainer container;
+
 	private DockPanel panel = new DockPanel();
+
 	private boolean dragging;
+
 	private Widget child;
-	
-	public DnDPanel(DnDContainer container, String captionText) {
-		this.container = container;
-		
+
+	private DnDListeners listenerBox;
+
+	private int dragStartY;
+
+	private int dragStartX;
+
+	public DnDPanel(String captionText) {
 		caption = new HTML(captionText);
 		caption.addMouseListener(this);
-		
+
 		panel.add(caption, DockPanel.NORTH);
-		
+
+		listenerBox = new DnDListeners();
+
 		super.add(panel);
 	}
-	
+
 	public void onMouseDown(Widget sender, int x, int y) {
-		dragging = true;
-		DOM.releaseCapture(caption.getElement());
+		if (dragging == false) {
+			dragging = true;
+			listenerBox.fireObjectPicked(this, x, y);
+			DOM.setCapture(caption.getElement());
+			dragStartX = x;
+			dragStartY = y;
+		}
 	}
 
 	public void onMouseEnter(Widget sender) {
@@ -43,19 +56,26 @@
 
 	public void onMouseMove(Widget sender, int x, int y) {
 		if (dragging) {
-			setMyPosition(x, y);
+			int absX = x + getAbsoluteLeft();
+			int absY = y + getAbsoluteTop();
+			setMyPosition(absX - dragStartX, absY - dragStartY);
+			listenerBox.fireObjectDragged(this, x, y);
 		}
 	}
 
 	public void onMouseUp(Widget sender, int x, int y) {
-		dragging = false;
+		if (dragging) {
+			dragging = false;
+			listenerBox.fireObjectDropped(this, x, y);
+			DOM.releaseCapture(caption.getElement());
+		}
 	}
 
 	public boolean add(Widget w) {
 		if (child != null) {
 			return false;
 		}
-		
+
 		panel.add(w, DockPanel.CENTER);
 		return true;
 	}
@@ -66,10 +86,10 @@
 			child = null;
 			return true;
 		}
-		
+
 		return false;
 	}
-	
+
 	public void setMyPosition(int left, int top) {
 		DOM.setStyleAttribute(this.getElement(), "position", "absolute");
 		DOM.setStyleAttribute(this.getElement(), "left", String.valueOf(left)
@@ -77,13 +97,38 @@
 		DOM.setStyleAttribute(this.getElement(), "top", String.valueOf(top)
 				+ "px");
 	}
-	
-	public int getLeft() {
-		return DOM.getIntAttribute(this.getElement(), "left");
+
+	public void addDnDListener(DnDListener listener) {
+		listenerBox.addDnDListener(listener);
 	}
-	
-	public int getTop() {
-		return DOM.getIntAttribute(this.getElement(), "left");
+
+	public void removeDnDListener(DnDListener listener) {
+		listenerBox.removeDnDListener(listener);
 	}
 
+	public boolean intersects(int px, int py, int pw, int ph) {
+
+		int tw = this.getOffsetWidth();
+		int th = this.getOffsetHeight();
+
+		if (pw <= 0 || ph <= 0 || tw <= 0 || th <= 0) {
+			return false;
+		}
+
+		int tx = DOM.getAbsoluteLeft(this.getElement());
+		int ty = DOM.getAbsoluteTop(this.getElement());
+
+		pw += px;
+		ph += py;
+		tw += tx;
+		th += ty;
+		// overflow || intersect
+		return ((pw < px || pw > tx) && (ph < py || ph > ty)
+				&& (tw < tx || tw > px) && (th < ty || th > py));
+
+	}
+
+	public String getCaption() {
+		return caption.getText();
+	}
 }

Modified: labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/PortalAjax.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/PortalAjax.java	2006-07-28 13:31:23 UTC (rev 5341)
+++ labs/jbosslabs/trunk/portal-extensions/ajax-portal/src/java/org/jboss/labs/ajaxportal/gwt/client/PortalAjax.java	2006-07-28 13:59:13 UTC (rev 5342)
@@ -26,15 +26,16 @@
 import com.google.gwt.user.client.ui.Button;
 import com.google.gwt.user.client.ui.ClickListener;
 import com.google.gwt.user.client.ui.DockPanel;
+import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.Panel;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.SourcesTableEvents;
 import com.google.gwt.user.client.ui.TableListener;
+import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
 
 public class PortalAjax implements EntryPoint {
 
-
 	/**
 	 * Native method in JScript to access gwt:properties (couldn't find anything
 	 * in the mans for it) You add this on the page with &lt;meta
@@ -67,18 +68,26 @@
 	 * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
 	 */
 	public void onModuleLoad() {
-			DnDContainer container = new DnDContainer();
-			
-			DnDPanel panel = new DnDPanel(container, "panelek");
-			panel.add(new Button("pierwszy baton"));
-			
-			DnDPanel panel2 = new DnDPanel(container, "panelek kolejny");
-			panel2.add(new Button("drugi baton"));
-			
-			container.setWidget(0, 0, panel);
-			container.setWidget(0, 1, panel2);
-			
-			RootPanel.get("ajaxPortal").add(container);
+		Label label = new Label("Listener state:");
+
+		DnDContainer container = new DnDContainer(label);
+
+		for (int i = 0; i < 4; i++) {
+			for (int j = 0; j < 4; j++) {
+				DnDPanel panel = new DnDPanel("panelek nr "+(i*4 + j));
+				panel.addDnDListener(container);
+				panel.add(new Button("kolejniasty panel baton"));
+				
+				container.setWidget(i, j, panel);
+			}
+		}
+
+		VerticalPanel vPanel = new VerticalPanel();
+
+		vPanel.add(label);
+		vPanel.add(container);
+
+		RootPanel.get("ajaxPortal").add(vPanel);
 	}
 
 }

Modified: labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java	2006-07-28 13:31:23 UTC (rev 5341)
+++ labs/jbosslabs/trunk/portal-extensions/forge-tagme/src/java/org/jboss/labs/tagme/gwt/client/TagMeShowPopupListener.java	2006-07-28 13:59:13 UTC (rev 5342)
@@ -39,9 +39,7 @@
 import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.ListBox;
-import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.TabPanel;
-import com.google.gwt.user.client.ui.TextArea;
 import com.google.gwt.user.client.ui.TextBox;
 import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;




More information about the jboss-svn-commits mailing list