Author: ayukhovich
Date: 2007-09-05 03:22:28 -0400 (Wed, 05 Sep 2007)
New Revision: 3449
Added:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java
Removed:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/DOMElementUtils.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/ElementPositionAndDimention.java
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeResizer.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-742
Restoring functionality of resizing
Deleted:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/DOMElementUtils.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/DOMElementUtils.java 2007-09-05
07:22:11 UTC (rev 3448)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/DOMElementUtils.java 2007-09-05
07:22:28 UTC (rev 3449)
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.vpe.xulrunner.editor;
-
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNSHTMLElement;
-
-/**
- * @author A. Yukhovich
- */
-public class DOMElementUtils {
-
- /**
- * @param domElement
- * @return
- */
- static public ElementPositionAndDimention getElementPositionAndDimention(nsIDOMElement
domElement) {
- ElementPositionAndDimention elementPositionAndDimention = new
ElementPositionAndDimention();
-
- nsIDOMNSHTMLElement nsElement = (nsIDOMNSHTMLElement)
domElement.queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
-
- if (nsElement != null) {
- elementPositionAndDimention.setWidth(nsElement.getOffsetWidth());
- elementPositionAndDimention.setHeight(nsElement.getOffsetHeight());
- elementPositionAndDimention.setTop(nsElement.getOffsetTop());
- elementPositionAndDimention.setLeft(nsElement.getOffsetLeft());
- }
-
- return elementPositionAndDimention;
- }
-}
Deleted:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/ElementPositionAndDimention.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/ElementPositionAndDimention.java 2007-09-05
07:22:11 UTC (rev 3448)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/ElementPositionAndDimention.java 2007-09-05
07:22:28 UTC (rev 3449)
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.vpe.xulrunner.editor;
-
-/**
- * @author A. Yukhovich
- *
- */
-public class ElementPositionAndDimention {
- private int top;
- private int left;
- private int height;
- private int width;
-
- private int borderLeft;
- private int borderTop;
- private int marginTop;
- private int marginLeft;
-
- /**
- * @return the top
- */
- public int getTop() {
- return top;
- }
- /**
- * @param top the top to set
- */
- public void setTop(int top) {
- this.top = top;
- }
- /**
- * @return the left
- */
- public int getLeft() {
- return left;
- }
- /**
- * @param left the left to set
- */
- public void setLeft(int left) {
- this.left = left;
- }
- /**
- * @return the height
- */
- public int getHeight() {
- return height;
- }
- /**
- * @param height the height to set
- */
- public void setHeight(int height) {
- this.height = height;
- }
- /**
- * @return the width
- */
- public int getWidth() {
- return width;
- }
- /**
- * @param width the width to set
- */
- public void setWidth(int width) {
- this.width = width;
- }
- /**
- * @return the borderLeft
- */
- public int getBorderLeft() {
- return borderLeft;
- }
- /**
- * @param borderLeft the borderLeft to set
- */
- public void setBorderLeft(int borderLeft) {
- this.borderLeft = borderLeft;
- }
- /**
- * @return the borderTop
- */
- public int getBorderTop() {
- return borderTop;
- }
- /**
- * @param borderTop the borderTop to set
- */
- public void setBorderTop(int borderTop) {
- this.borderTop = borderTop;
- }
- /**
- * @return the marginTop
- */
- public int getMarginTop() {
- return marginTop;
- }
- /**
- * @param marginTop the marginTop to set
- */
- public void setMarginTop(int marginTop) {
- this.marginTop = marginTop;
- }
- /**
- * @return the marginLeft
- */
- public int getMarginLeft() {
- return marginLeft;
- }
- /**
- * @param marginLeft the marginLeft to set
- */
- public void setMarginLeft(int marginLeft) {
- this.marginLeft = marginLeft;
- }
-
-}
-
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeResizer.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeResizer.java 2007-09-05
07:22:11 UTC (rev 3448)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeResizer.java 2007-09-05
07:22:28 UTC (rev 3449)
@@ -13,7 +13,7 @@
import java.util.ArrayList;
-
+import org.eclipse.swt.graphics.Rectangle;
import org.mozilla.interfaces.nsIDOMCSSStyleDeclaration;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -93,7 +93,7 @@
private nsIDOMElement activeHandle;
- private ElementPositionAndDimention elementPositionAndDimention;
+ private Rectangle elementBounds;
/** resizer marker top-left */
private nsIDOMElement markerTopLeft = null;
@@ -148,12 +148,12 @@
System.out.println("XulRunnerVpeResizer.show for element: " +
resizingObject.getNodeName() );
- elementPositionAndDimention =
DOMElementUtils.getElementPositionAndDimention(domElement);
+ elementBounds = XulRunnerVpeUtils.getElementBounds(domElement);
- if ((elementPositionAndDimention.getWidth() <= 0) ||
- (elementPositionAndDimention.getWidth() > MAX_SIZE) ||
- (elementPositionAndDimention.getHeight() <= 0) ||
- (elementPositionAndDimention.getHeight() > MAX_SIZE)) return;
+ if ((elementBounds.width <= 0) ||
+ (elementBounds.width > MAX_SIZE) ||
+ (elementBounds.height <= 0) ||
+ (elementBounds.height > MAX_SIZE)) return;
nsIDOMElement bodyElement = getRootElement();
@@ -219,7 +219,7 @@
resizingShadow = createShadow(bodyElement, resizingObject);
- setShadowPosition(resizingShadow, elementPositionAndDimention.getLeft(),
elementPositionAndDimention.getTop());
+ setShadowPosition(resizingShadow, elementBounds.x, elementBounds.y);
}
@@ -492,10 +492,10 @@
resizingShadow.removeAttribute(XulRunnerConstants.HTML_ATTR_CLASS);
// position it
- setShadowPosition(resizingShadow, elementPositionAndDimention.getLeft(),
elementPositionAndDimention.getTop());
+ setShadowPosition(resizingShadow, elementBounds.x, elementBounds.y);
- setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_WIDTH,
elementPositionAndDimention.getWidth() );
- setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_HEIGHT,
elementPositionAndDimention.getTop() );
+ setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_WIDTH,
elementBounds.width );
+ setStylePropertyPixels(resizingShadow, XulRunnerConstants.HTML_ATTR_HEIGHT,
elementBounds.height );
if (mouseMotionListener != null) {
@@ -539,8 +539,8 @@
* @return
*/
private int getNewResizingX(int aX, int aY) {
- int resized = elementPositionAndDimention.getLeft() + getNewResizingIncrement(aX, aY,
COEFFICIENT_TYPE.X) * incrementFactorX;
- int max = elementPositionAndDimention.getLeft() +
elementPositionAndDimention.getWidth();
+ int resized = elementBounds.x+ getNewResizingIncrement(aX, aY, COEFFICIENT_TYPE.X) *
incrementFactorX;
+ int max = elementBounds.x + elementBounds.width;
return Math.min(resized, max);
}
@@ -551,8 +551,8 @@
* @return
*/
private int getNewResizingY(int aX, int aY) {
- int resized = elementPositionAndDimention.getTop() + getNewResizingIncrement(aX, aY,
COEFFICIENT_TYPE.Y) * incrementFactorY;
- int max = elementPositionAndDimention.getTop() +
elementPositionAndDimention.getHeight();
+ int resized = elementBounds.y + getNewResizingIncrement(aX, aY, COEFFICIENT_TYPE.Y) *
incrementFactorY;
+ int max = elementBounds.y + elementBounds.height;
return Math.min(resized, max);
}
@@ -563,7 +563,7 @@
* @return
*/
private int getNewResizingWidth(int aX, int aY) {
- int resized = elementPositionAndDimention.getWidth() + getNewResizingIncrement(aX, aY,
COEFFICIENT_TYPE.WIDTH) * incrementFactorWidth;
+ int resized = elementBounds.width + getNewResizingIncrement(aX, aY,
COEFFICIENT_TYPE.WIDTH) * incrementFactorWidth;
return Math.max(resized, 1);
}
@@ -574,7 +574,7 @@
* @return
*/
private int getNewResizingHeight(int aX, int aY) {
- int resized = elementPositionAndDimention.getHeight() + getNewResizingIncrement(aX, aY,
COEFFICIENT_TYPE.HEIGHT) * incrementFactorHeight;
+ int resized = elementBounds.height + getNewResizingIncrement(aX, aY,
COEFFICIENT_TYPE.HEIGHT) * incrementFactorHeight;
return Math.max(resized, 1);
}
@@ -647,10 +647,10 @@
* Set all positions of resizer's markers
*/
private void setAllResizersPosition() {
- int left = elementPositionAndDimention.getLeft();
- int top = elementPositionAndDimention.getTop();
- int width = elementPositionAndDimention.getWidth();
- int height = elementPositionAndDimention.getHeight();
+ int left = elementBounds.x;
+ int top = elementBounds.y;
+ int width = elementBounds.width;
+ int height = elementBounds.height;
int resizerWidth = 5;
int resizerHeight = 5;
Copied:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java
(from rev 3444,
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/DOMElementUtils.java)
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java 2007-09-05
07:22:28 UTC (rev 3449)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.vpe.xulrunner.editor;
+
+import org.eclipse.swt.graphics.Rectangle;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNSHTMLElement;
+import org.mozilla.xpcom.XPCOMException;
+
+/**
+ * @author A. Yukhovich
+ */
+public class XulRunnerVpeUtils {
+
+ /**
+ * @param domElement
+ * @return
+ */
+ static public Rectangle getElementBounds(nsIDOMElement domElement) {
+ try {
+ nsIDOMNSHTMLElement domNSHTMLElement = (nsIDOMNSHTMLElement)
domElement.queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
+ int offsetLeft = domNSHTMLElement.getOffsetLeft();
+ int offsetTop = domNSHTMLElement.getOffsetTop();
+ int width = domNSHTMLElement.getOffsetWidth();
+ int height = domNSHTMLElement.getOffsetHeight();
+
+ while (true) {
+ try {
+ if (domNSHTMLElement.getOffsetParent() == null) {
+ break;
+ }
+
+ domNSHTMLElement = (nsIDOMNSHTMLElement)
domNSHTMLElement.getOffsetParent().queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
+ offsetLeft += domNSHTMLElement.getOffsetLeft();
+ offsetTop += domNSHTMLElement.getOffsetTop();
+ } catch (XPCOMException ex) {
+ break;
+ }
+ }
+ return new Rectangle(offsetLeft, offsetTop, width, height);
+
+ } catch (XPCOMException xpcomException) {
+ return new Rectangle(0, 0, 0, 0);
+ }
+ }
+}