Take benefits of GC.clipping support added in RAP 3.0 M5
diff --git a/bundles/org.eclipse.rap.draw2d.compatibility/.classpath b/bundles/org.eclipse.rap.draw2d.compatibility/.classpath
index 2fbb7a2..098194c 100644
--- a/bundles/org.eclipse.rap.draw2d.compatibility/.classpath
+++ b/bundles/org.eclipse.rap.draw2d.compatibility/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/bundles/org.eclipse.rap.draw2d.compatibility/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.rap.draw2d.compatibility/.settings/org.eclipse.jdt.core.prefs
index b36bda3..f42de36 100644
--- a/bundles/org.eclipse.rap.draw2d.compatibility/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.rap.draw2d.compatibility/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,7 @@
-#Mon Apr 04 15:59:14 CDT 2011
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/bundles/org.eclipse.rap.draw2d.compatibility/META-INF/MANIFEST.MF b/bundles/org.eclipse.rap.draw2d.compatibility/META-INF/MANIFEST.MF
index 6500f08..18821bf 100644
--- a/bundles/org.eclipse.rap.draw2d.compatibility/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.rap.draw2d.compatibility/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Name: Draw2d RAP Suppliment (Incubation)
Bundle-SymbolicName: org.eclipse.rap.draw2d.compatibility
Bundle-Version: 0.1.0.qualifier
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: intrinsic.flash.text,
org.eclipse.draw2d.rap.swt,
org.eclipse.draw2d.rap.swt.custom,
diff --git a/bundles/org.eclipse.rap.draw2d.compatibility/src/org/eclipse/draw2d/rap/swt/graphics/ColorUtil.java b/bundles/org.eclipse.rap.draw2d.compatibility/src/org/eclipse/draw2d/rap/swt/graphics/ColorUtil.java
new file mode 100644
index 0000000..76a8dc9
--- /dev/null
+++ b/bundles/org.eclipse.rap.draw2d.compatibility/src/org/eclipse/draw2d/rap/swt/graphics/ColorUtil.java
@@ -0,0 +1,29 @@
+package org.eclipse.draw2d.rap.swt.graphics;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+
+
+public class ColorUtil {
+
+ private final static String COLOR_KEY = "DRAW2D_{0}_{1}_{2}"; //$NON-NLS-1$
+
+ public static Color getColor( int red, int green, int blue ) {
+ String key = MessageFormat.format( COLOR_KEY, red, green, blue );
+ ColorRegistry reg = JFaceResources.getColorRegistry();
+ Color color = reg.get( key );
+ if( color == null ) {
+ reg.put( key, new RGB( red, green, blue ) );
+ color = reg.get( key );
+ }
+ return color;
+ }
+
+ public static Color getColor( int rgb ) {
+ return getColor( rgb, rgb, rgb );
+ }
+}
diff --git a/bundles/org.eclipse.rap.draw2d/META-INF/MANIFEST.MF b/bundles/org.eclipse.rap.draw2d/META-INF/MANIFEST.MF
index a212bdd..d9fcdfa 100644
--- a/bundles/org.eclipse.rap.draw2d/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.rap.draw2d/META-INF/MANIFEST.MF
@@ -16,7 +16,7 @@
org.eclipse.draw2d.widgets
Require-Bundle: org.eclipse.core.jobs;bundle-version="3.5.100",
org.eclipse.core.runtime;bundle-version="3.6.100",
- org.eclipse.rap.rwt;bundle-version="[2.0.0,4.0.0)",
+ org.eclipse.rap.rwt;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rap.ui;bundle-version="[2.0.0,4.0.0)",
org.eclipse.rap.draw2d.compatibility;bundle-version="0.1.0"
Bundle-ActivationPolicy: lazy
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ColorConstants.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ColorConstants.java
index b064763..5048642 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ColorConstants.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ColorConstants.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.draw2d;
+import org.eclipse.draw2d.rap.swt.graphics.ColorUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
@@ -136,35 +137,36 @@
/*
* Misc. colors
*/
+ //[RAP AM] remove statics
/** One of the pre-defined colors */
- Color white = new Color(null, 255, 255, 255);
+ Color white = ColorUtil.getColor(255);//new Color(null, 255, 255, 255);
/** One of the pre-defined colors */
- Color lightGray = new Color(null, 192, 192, 192);
+ Color lightGray = ColorUtil.getColor(192);//new Color(null, 192, 192, 192);
/** One of the pre-defined colors */
- Color gray = new Color(null, 128, 128, 128);
+ Color gray = ColorUtil.getColor(128);//new Color(null, 128, 128, 128);
/** One of the pre-defined colors */
- Color darkGray = new Color(null, 64, 64, 64);
+ Color darkGray = ColorUtil.getColor(64);//new Color(null, 64, 64, 64);
/** One of the pre-defined colors */
- Color black = new Color(null, 0, 0, 0);
+ Color black = ColorUtil.getColor(0);//new Color(null, 0, 0, 0);
/** One of the pre-defined colors */
- Color red = new Color(null, 255, 0, 0);
+ Color red = ColorUtil.getColor(255,0,0);//new Color(null, 255, 0, 0);
/** One of the pre-defined colors */
- Color orange = new Color(null, 255, 196, 0);
+ Color orange = ColorUtil.getColor(255,196,0);//new Color(null, 255, 196, 0);
/** One of the pre-defined colors */
- Color yellow = new Color(null, 255, 255, 0);
+ Color yellow = ColorUtil.getColor(255,255,0);//new Color(null, 255, 255, 0);
/** One of the pre-defined colors */
- Color green = new Color(null, 0, 255, 0);
+ Color green = ColorUtil.getColor(0,255,0);//new Color(null, 0, 255, 0);
/** One of the pre-defined colors */
- Color lightGreen = new Color(null, 96, 255, 96);
+ Color lightGreen = ColorUtil.getColor(96,255,96);//new Color(null, 96, 255, 96);
/** One of the pre-defined colors */
- Color darkGreen = new Color(null, 0, 127, 0);
+ Color darkGreen = ColorUtil.getColor(0,127,0);//new Color(null, 0, 127, 0);
/** One of the pre-defined colors */
- Color cyan = new Color(null, 0, 255, 255);
+ Color cyan = ColorUtil.getColor(0,255,255);//new Color(null, 0, 255, 255);
/** One of the pre-defined colors */
- Color lightBlue = new Color(null, 127, 127, 255);
+ Color lightBlue = ColorUtil.getColor(127,127,255);//new Color(null, 127, 127, 255);
/** One of the pre-defined colors */
- Color blue = new Color(null, 0, 0, 255);
+ Color blue = ColorUtil.getColor(0,0,255);//new Color(null, 0, 0, 255);
/** One of the pre-defined colors */
- Color darkBlue = new Color(null, 0, 0, 127);
+ Color darkBlue = ColorUtil.getColor(0,0,127);//new Color(null, 0, 0, 127);
}
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/FigureUtilities.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/FigureUtilities.java
index 7c93557..7857e6e 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/FigureUtilities.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/FigureUtilities.java
@@ -13,13 +13,15 @@
import java.util.ArrayList;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Shell;
-
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw2d.rap.swt.graphics.ColorUtil;
+import org.eclipse.jface.resource.JFaceResources;
/**
* Provides miscellaneous Figure operations.
@@ -30,8 +32,12 @@
private static GC gc;
private static Font appliedFont;
private static FontMetrics metrics;
- private static Color ghostFillColor = new Color(null, 31, 31, 31);
-
+ //[RAP AM] remove static usage
+ //private static Color ghostFillColor = new Color(null, 31, 31, 31);
+ private static Color ghostFillColor() {
+ return ColorUtil.getColor( 31, 31, 31 );
+ }
+
/**
* Returns a new Color the same as the passed color in a darker hue.
*
@@ -212,7 +218,7 @@
* @since 2.0
*/
public static Shape makeGhostShape(Shape s) {
- s.setBackgroundColor(ghostFillColor);
+ s.setBackgroundColor(ghostFillColor());
s.setFillXOR(true);
s.setOutlineXOR(true);
return s;
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/SWTGraphics.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/SWTGraphics.java
index 7faf8a3..04a5031 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/SWTGraphics.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/SWTGraphics.java
@@ -145,10 +145,9 @@
public void setOn(GC gc, int translateX, int translateY) {
int xInt = (int) Math.floor(left);
int yInt = (int) Math.floor(top);
- // UNSUPPORTED - api is not implemented in RAP
- // gc.setClipping(xInt + translateX, yInt + translateY,
- // (int) Math.ceil(right) - xInt, (int) Math.ceil(bottom)
- // - yInt);
+ gc.setClipping(xInt + translateX, yInt + translateY,
+ (int) Math.ceil(right) - xInt, (int) Math.ceil(bottom)
+ - yInt);
}
public void translate(float dx, float dy) {
@@ -1111,8 +1110,7 @@
// it works.
appliedState.graphicHints ^= FILL_RULE_MASK;
}
- // UNSUPPORTED - api is not implemented in RAP
- // gc.setClipping(path);
+ gc.setClipping(path);
appliedState.relativeClip = currentState.relativeClip = null;
}
@@ -1148,8 +1146,7 @@
// loadPath(region, pathData.points, pathData.types);
region.intersect(new org.eclipse.swt.graphics.Rectangle(clipping.x,
clipping.y, clipping.width, clipping.height));
- // UNSUPPORTED - api is not implemented in RAP
- // gc.setClipping(region);
+ gc.setClipping(region.getBounds());
appliedState.relativeClip = currentState.relativeClip = null;
region.dispose();
}
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/SelectionManager.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/SelectionManager.java
index 3a71a6d..383734e 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/SelectionManager.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/SelectionManager.java
@@ -11,6 +11,7 @@
package org.eclipse.gef;
+import java.lang.reflect.Field;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -22,6 +23,8 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.gef.ui.parts.AbstractEditPartViewer;
+
/**
* Manages a viewer's selection model. Selection management includes
* representing a form of selection which is available to clients of a viewer as
@@ -68,8 +71,13 @@
* @since 3.2
*/
public void appendSelection(EditPart editpart) {
- if (editpart != getFocus())
+ if (editpart != getFocus()) {
+ // Fix for 458416: adjust the focus through the viewer only (to give
+ // AbstractEditPartViewer a change to update its focusPart field).
+ // AbstractEditPartViewer#setFocus() should call back setFocus(null)
+ // here, so both focus part values should stay in sync.
viewer.setFocus(null);
+ }
if (!selection.isEmpty()) {
EditPart primary = (EditPart) selection.get(selection.size() - 1);
primary.setSelected(EditPart.SELECTED);
@@ -125,7 +133,11 @@
*/
public void deselectAll() {
EditPart part;
- setFocus(null);
+ // Fix for 458416: adjust the focus through the viewer only (to give
+ // AbstractEditPartViewer a change to update its focusPart field).
+ // AbstractEditPartViewer#setFocus() should call back setFocus(null)
+ // here, so both focus part values should stay in sync.
+ viewer.setFocus(null);
for (int i = 0; i < selection.size(); i++) {
part = (EditPart) selection.get(i);
part.setSelected(EditPart.SELECTED_NONE);
@@ -232,6 +244,25 @@
* @since 3.2
*/
public void setFocus(EditPart part) {
+ // Fix for 458416: AbstractEditPartViewer provides a protected,
+ // deprecated focusPart field, which might get out of sync with the
+ // focusPart here, if this method is called directly (and not though the
+ // EditPartViewer#setFocus() delegation). We need to make sure it stays
+ // synchronized even in this case, so we update the field value
+ // accordingly
+ if (viewer instanceof AbstractEditPartViewer) {
+ try {
+ Field focusPartField = AbstractEditPartViewer.class
+ .getDeclaredField("focusPart"); //$NON-NLS-1$
+ focusPartField.setAccessible(true);
+ if (focusPartField.get(viewer) != part) {
+ focusPartField.set(viewer, part);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(
+ "Workaround for bug #458416 became ineffective"); //$NON-NLS-1$
+ }
+ }
if (focusPart == part)
return;
if (focusPart != null)
@@ -256,7 +287,11 @@
// Convert to HashSet to optimize performance.
Collection hashset = new HashSet(orderedSelection);
- setFocus(null);
+ // Fix for 458416: adjust the focus through the viewer only (to give
+ // AbstractEditPartViewer a change to update its focusPart field).
+ // AbstractEditPartViewer#setFocus() should call back setFocus(null)
+ // here, so both focus part values should stay in sync.
+ viewer.setFocus(null);
for (int i = 0; i < selection.size(); i++) {
EditPart part = (EditPart) selection.get(i);
if (!hashset.contains(part))
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/parts/AbstractEditPartViewer.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/parts/AbstractEditPartViewer.java
index 61beb80..1f54e06 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/parts/AbstractEditPartViewer.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/parts/AbstractEditPartViewer.java
@@ -692,8 +692,8 @@
* @see EditPartViewer#setFocus(EditPart)
*/
public void setFocus(EditPart part) {
- getSelectionManager().setFocus(part);
focusPart = part;
+ getSelectionManager().setFocus(part);
}
/**
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/rulers/RulerComposite.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/rulers/RulerComposite.java
index 8c5328f..069966c 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/rulers/RulerComposite.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/rulers/RulerComposite.java
@@ -568,7 +568,7 @@
protected void handleFocusLost(FocusEvent fe) {
super.handleFocusLost(fe);
if (focusPart == getContents()) {
- focusPart = null;
+ setFocus(null);
}
}
diff --git a/tests/org.eclipse.draw2d.test/README.txt b/tests/org.eclipse.draw2d.test/README.txt
new file mode 100644
index 0000000..dd5e93a
--- /dev/null
+++ b/tests/org.eclipse.draw2d.test/README.txt
@@ -0,0 +1 @@
+11 errors 17 failures currently
\ No newline at end of file
diff --git a/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/AbstractFixtureTestCase.java b/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/AbstractFixtureTestCase.java
index 1480657..db22409 100644
--- a/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/AbstractFixtureTestCase.java
+++ b/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/AbstractFixtureTestCase.java
@@ -2,7 +2,7 @@
import junit.framework.TestCase;
-import org.eclipse.rap.rwt.testfixture.Fixture;
+import org.eclipse.rap.rwt.testfixture.internal.Fixture;
import org.eclipse.swt.widgets.Display;
public abstract class AbstractFixtureTestCase extends TestCase {
diff --git a/tests/org.eclipse.gef.test/src/org/eclipse/gef/test/AbstractFixtureTestCase.java b/tests/org.eclipse.gef.test/src/org/eclipse/gef/test/AbstractFixtureTestCase.java
index 92aa136..9074e5e 100644
--- a/tests/org.eclipse.gef.test/src/org/eclipse/gef/test/AbstractFixtureTestCase.java
+++ b/tests/org.eclipse.gef.test/src/org/eclipse/gef/test/AbstractFixtureTestCase.java
@@ -2,7 +2,7 @@
import junit.framework.TestCase;
-import org.eclipse.rap.rwt.testfixture.Fixture;
+import org.eclipse.rap.rwt.testfixture.internal.Fixture;
import org.eclipse.swt.widgets.Display;
public abstract class AbstractFixtureTestCase extends TestCase {
diff --git a/tests/org.eclipse.zest.tests/src/org/eclipse/zest/tests/AbstractFixtureTestCase.java b/tests/org.eclipse.zest.tests/src/org/eclipse/zest/tests/AbstractFixtureTestCase.java
index 5c44d60..c8c8a2c 100644
--- a/tests/org.eclipse.zest.tests/src/org/eclipse/zest/tests/AbstractFixtureTestCase.java
+++ b/tests/org.eclipse.zest.tests/src/org/eclipse/zest/tests/AbstractFixtureTestCase.java
@@ -2,7 +2,7 @@
import junit.framework.TestCase;
-import org.eclipse.rap.rwt.testfixture.Fixture;
+import org.eclipse.rap.rwt.testfixture.internal.Fixture;
import org.eclipse.swt.widgets.Display;
public abstract class AbstractFixtureTestCase extends TestCase {