Author: yradtsevich
Date: 2011-02-03 07:50:13 -0500 (Thu, 03 Feb 2011)
New Revision: 28967
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java
Log:
https://issues.jboss.org/browse/JBIDE-8115 : Support for multiple selection in visual
part
- minor code beautifying
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2011-02-03
12:33:08 UTC (rev 28966)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2011-02-03
12:50:13 UTC (rev 28967)
@@ -1004,10 +1004,10 @@
*/
public void onReloadWindow() {
detachMozillaEventAdapter();
- xulRunnerEditor.removeResizerListener();
+ xulRunnerEditor.removeResizeListener();
contentArea = findContentArea();
attachMozillaEventAdapter();
- xulRunnerEditor.addResizerListener();
+ xulRunnerEditor.addResizeListener();
controller.reinit();
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java 2011-02-03
12:33:08 UTC (rev 28966)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java 2011-02-03
12:50:13 UTC (rev 28967)
@@ -24,6 +24,7 @@
this.mozillaEditor = mozillaEditor;
}
+ @Override
public void onLoadWindow() {
if (mozillaEditor == null) {
return;
@@ -40,21 +41,25 @@
}
}
+ @Override
public void onElementResize(nsIDOMElement element, int constrains, int top, int left,
int width, int height) {
if (mozillaEditor != null && mozillaEditor.getResizeListener() != null) {
mozillaEditor.getResizeListener().elementResized(element, constrains, top, left,
width, height);
}
}
+ @Override
public void onShowTooltip(int x, int y, String text) {
if (mozillaEditor != null && mozillaEditor.getTooltipListener() != null) {
mozillaEditor.getTooltipListener().onShowTooltip(x, y, text);
}
}
+ @Override
public void onHideTooltip() {
if (mozillaEditor != null && mozillaEditor.getTooltipListener() != null) {
mozillaEditor.getTooltipListener().onHideTooltip();
}
}
+ @Override
public void onDispose() {
if (mozillaEditor != null) {
mozillaEditor.tearDownEditor();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java 2011-02-03
12:33:08 UTC (rev 28966)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java 2011-02-03
12:50:13 UTC (rev 28967)
@@ -23,22 +23,26 @@
this.mozillaPreview = mozillaPreview;
}
+ @Override
public void onLoadWindow() {
super.onLoadWindow();
mozillaPreview.onLoadWindow();
}
+ @Override
public void onShowTooltip(int x, int y, String text) {
if (mozillaPreview != null && mozillaPreview.getTooltipListener() != null) {
mozillaPreview.getTooltipListener().onShowTooltip(x, y, text);
}
}
+ @Override
public void onHideTooltip() {
if (mozillaPreview != null && mozillaPreview.getTooltipListener() != null) {
mozillaPreview.getTooltipListener().onHideTooltip();
}
}
+ @Override
public void onDispose() {
if (mozillaPreview != null) {
mozillaPreview.detachMozillaEventAdapter();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2011-02-03
12:33:08 UTC (rev 28966)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2011-02-03
12:50:13 UTC (rev 28967)
@@ -144,9 +144,9 @@
nsITooltipListener.NS_ITOOLTIPLISTENER_IID);
removeProgressListener(XulRunnerEditor.this);
- if (resizeListener != null)
- getIXulRunnerVpeResizer().removeResizeListener(
- resizeListener);
+ if (resizeListener != null) {
+ getIXulRunnerVpeResizer().removeResizeListener(resizeListener);
+ }
xulRunnerVpeResizer.dispose();
xulRunnerVpeResizer = null;
resizeListener = null;
@@ -206,17 +206,17 @@
}
/**
- * Removes resizer listener
+ * Removes resize listener
*/
- public void removeResizerListener() {
+ public void removeResizeListener() {
if (resizeListener != null)
getIXulRunnerVpeResizer().removeResizeListener(resizeListener);
}
/**
- * Add Resizer Listener
+ * Add Resize Listener
*/
- public void addResizerListener() {
+ public void addResizeListener() {
if (getIXulRunnerVpeResizer() != null) {
getIXulRunnerVpeResizer().init(getDOMDocument());
getIXulRunnerVpeResizer().addResizeListener(resizeListener);
@@ -238,7 +238,7 @@
}
public void onLoadWindow() {
- addResizerListener();
+ addResizeListener();
}
public nsIDOMDocument getDOMDocument() {
@@ -252,8 +252,7 @@
* @return
*/
public nsIDOMElement getLastSelectedElement() {
-
- return getElement(lastSelectedNode);
+ return getSelectedElementForNode(lastSelectedNode);
}
public nsIDOMNode getLastSelectedNode() {
@@ -282,72 +281,13 @@
public void setSelectionRectangle(nsIDOMNode node, int resizerConstrains,
boolean scroll) {
if (getFlasher() == null) {
-
return;
}
- nsIDOMElement element = getElement(node);
+ nsIDOMElement element = getSelectedElementForNode(node);
- // See
https://jira.jboss.org/jira/browse/JBIDE-5117. We make
- // unnecessary redrawing of previously selected component in VE
- // which happens in drawElementOutline(nsIDOMElement domElement)
- // method and call IFlasher.drawElementOutline(nsIDOMElement domElement)
- // twice for different elements without browser repainting. So, for some
- // conflicts in Mozilla browser border above TR element wasn't
- // repainted.
-
- // if (getLastSelectedElement() != null) {
- //
- // scrollRegtangleFlag = scroll && node != null;
- //
- // try {
- // ((nsIBaseWindow) getWebBrowser().queryInterface(
- // nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
- // } catch (XPCOMException ex) {
- // // just ignore its
- // BrowserPlugin.getDefault().logInfo("repaint failed", ex);
//$NON-NLS-1$
- // }
- // if(checkVisability(getLastSelectedElement())){
- //
- // if((getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE)==null)||
- //
(!getLastSelectedElement().getAttribute(VPEFLASHERCOLORATTRIBUTE).equals(flasherHiddentElementColor)))
- // {
- //
- // getIFlasher().setColor(flasherVisialElementColor);
- // } else{
- // getIFlasher().setColor(flasherHiddentElementColor);
- // }
- //
- // drawElementOutline(getLastSelectedElement());
- //
- // }else {
- //
- // getIFlasher().setColor(flasherHiddentElementColor);
- // nsIDOMElement domElement =
- // findVisbleParentElement(getLastSelectedElement());
- //
- // if(domElement!=null) {
- //
- // drawElementOutline(domElement);
- // }
- //
- // }
- // try {
- // ((nsIBaseWindow) getWebBrowser().queryInterface(
- // nsIBaseWindow.NS_IBASEWINDOW_IID)).repaint(true);
- // } catch (XPCOMException ex) {
- // // just ignore its
- // BrowserPlugin.getDefault().logInfo("repaint failed", ex);
//$NON-NLS-1$
- // }
-
- // } else
if (element != null) {
- try {
- XPCOM.queryInterface(getWebBrowser(), nsIBaseWindow.class).repaint(true);
- } catch (XPCOMException ex) {
- // just ignore its
- BrowserPlugin.getDefault().logInfo("repaint failed", ex); //$NON-NLS-1$
- }
+ repaint();
if (scroll) {
scrollToElement(element);
@@ -391,6 +331,20 @@
}
/**
+ * Forcible repaints current XULRunner window.
+ *
+ * If an exception occurs during repaint, it will be logged.
+ */
+ private void repaint() {
+ try {
+ XPCOM.queryInterface(getWebBrowser(), nsIBaseWindow.class).repaint(true);
+ } catch (XPCOMException ex) {
+ // just ignore it
+ BrowserPlugin.getDefault().logInfo("repaint failed", ex); //$NON-NLS-1$
+ }
+ }
+
+ /**
* @return the iFlasher
*/
private Flasher getFlasher() {
@@ -510,7 +464,7 @@
scrollToElement(getLastSelectedElement());
}
- // checks visability of element
+ // checks visibility of element
if (checkVisibility(getLastSelectedElement())) {
if ((getLastSelectedElement().getAttribute(
@@ -562,27 +516,19 @@
}
/**
- * get nsIDomElement from nsIDomNode
+ * Returns the element to be selected for the given {@code node}.
*
- * if node is nsIDomElement - return it
- *
- * if node is text node - return it's
- *
- * parent else return null
- *
- * @param node
- * @return
+ * If node is an element, then returns it as is.
+ * If node is a text node, then returns its parent
+ * Else returns null;
*/
- private nsIDOMElement getElement(nsIDOMNode node) {
-
+ private nsIDOMElement getSelectedElementForNode(nsIDOMNode node) {
if (node != null) {
-
if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
return XPCOM.queryInterface(node, nsIDOMElement.class);
} else if (node.getNodeType() == nsIDOMNode.TEXT_NODE) {
return XPCOM.queryInterface(node.getParentNode(), nsIDOMElement.class);
}
-
}
return null;