Author: svasilyev
Date: 2007-10-01 11:20:10 -0400 (Mon, 01 Oct 2007)
New Revision: 3927
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/ArrowRight.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
Log:
Some code improvement
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2007-10-01
14:32:20 UTC (rev 3926)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2007-10-01
15:20:10 UTC (rev 3927)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe;
+import org.eclipse.core.runtime.Platform;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
import org.jboss.tools.common.reporting.ProblemReportingHelper;
@@ -23,26 +24,13 @@
//The shared instance.
private static VpePlugin plugin;
//Resource bundle.
-// private ResourceBundle resourceBundle;
/**
* The constructor.
*/
public VpePlugin() {
super();
-// final String VPE_PLUGIN_RESOURCE_BUNDLE_ID
-// = "org.jboss.tools.vpe.VpePluginResources";
plugin = this;
-// try {
-// resourceBundle
-// = ResourceBundle.getBundle(VPE_PLUGIN_RESOURCE_BUNDLE_ID);
-// } catch (MissingResourceException x) {
-// LogHelper.logError(VpePlugin.PLUGIN_ID,
-// "ResourceBundle " + VPE_PLUGIN_RESOURCE_BUNDLE_ID
-// + " is missing.",
-// x);
-// resourceBundle = null;
-// }
}
/**
@@ -63,6 +51,11 @@
* Returns the shared instance.
*/
public static VpePlugin getDefault() {
+ if (plugin == null) {
+ // plugin will be initialized in constructor
+ Platform.getBundle(PLUGIN_ID);
+ }
+
return plugin;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-10-01
14:32:20 UTC (rev 3926)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-10-01
15:20:10 UTC (rev 3927)
@@ -1925,25 +1925,37 @@
if (VpeDebug.printVisualInnerDragDropEvent) {
System.out.print("<<<<<< canInnerDrag"); //$NON-NLS-1$
}
+
if (innerDragInfo != null) {
innerDragInfo.Release();
innerDragInfo = null;
}
+
boolean canDrag = false;
VpeVisualInnerDragInfo dragInfo = selectionBuilder.getInnerDragInfo(event);
+
if (dragInfo != null) {
Node dragNode = dragInfo.getNode();
+
if (VpeDebug.printVisualInnerDragDropEvent) {
System.out.print(" dragNode: " + dragNode.getNodeName() + "(" +
MozillaSupports.getAddress(dragNode) + ")"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
}
+
switch (dragNode.getNodeType()) {
case Node.ELEMENT_NODE:
canDrag = visualBuilder.canInnerDrag((Element)dragNode);
+ break;
case Node.TEXT_NODE:
canDrag = visualBuilder.isTextEditable(dragNode);
+ break;
+ default:
+ // Do nothing
+ break;
}
+
if (canDrag) {
VpeSourceInnerDragInfo sourceInnerDragInfo =
visualBuilder.getSourceInnerDragInfo(dragInfo);
+
if (sourceInnerDragInfo.getNode() != null) {
innerDragInfo = dragInfo;
InnerDragBuffer.object = sourceInnerDragInfo.getNode();
@@ -1956,13 +1968,16 @@
canDrag = false;
}
}
+
if (!canDrag) {
dragInfo.Release();
}
}
+
if (VpeDebug.printVisualInnerDragDropEvent) {
System.out.println(" canDrag: " + canDrag); //$NON-NLS-1$
}
+
return canDrag;
}
@@ -2081,6 +2096,7 @@
// if(s.getT()) {
// return new MozillaDropInfo(false, null, 0);
// }
+
onHideTooltip();
if(dropWindow.active) {
@@ -2090,6 +2106,7 @@
return new MozillaDropInfo(false, null, 0);
}
}
+
if(mouseEvent.isAltKey()) {
Node visualNode = mouseEvent.getTargetNode();
Node sourceNode = domMapping.getNearSourceNode(visualNode);
@@ -2109,6 +2126,7 @@
return new MozillaDropInfo(false, null, 0);
}
}
+
boolean canDrop = false;
Node caretParent = null;
int caretOffset = 0;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-10-01
14:32:20 UTC (rev 3926)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-10-01
15:20:10 UTC (rev 3927)
@@ -780,7 +780,7 @@
}
private Node getNextFlatNode (Node node) {
for (Node next = FlatIterator.next(node); next != null; next = FlatIterator.next(next))
{
- if (getVisualNode(next) != null || next.getNodeType() == Node.TEXT_NODE);
+ if (getVisualNode(next) != null || next.getNodeType() == Node.TEXT_NODE)
return next;
}
return null;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/ArrowRight.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/ArrowRight.java 2007-10-01
14:32:20 UTC (rev 3926)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/ArrowRight.java 2007-10-01
15:20:10 UTC (rev 3927)
@@ -33,11 +33,8 @@
}
void paintControl(PaintEvent e) {
- GC gc = e.gc;
- int x = 1;
if (image != null) {
- gc.drawImage(image, x, 1);
- x = image.getBounds().width + 5;
+ e.gc.drawImage(image, image.getBounds().width + 5, 1);
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2007-10-01
14:32:20 UTC (rev 3926)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2007-10-01
15:20:10 UTC (rev 3927)
@@ -338,13 +338,11 @@
}
public static boolean isWhitespace(char sourceString) {
- String visualString = visualText((new Character(sourceString)).toString());
return SPCHARS.indexOf(sourceString) != -1;
}
public static boolean isWhitespaceText(String sourceString) {
if (sourceString != null && sourceString.length() > 0) {
- char[] chars = sourceString.toCharArray();
for (int i = 0; i < sourceString.length(); i++) {
if (!TextUtil.isWhitespace(sourceString.charAt(i)))
return false;
Show replies by date