You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/06/11 18:34:57 UTC
svn commit: r783834 - in /incubator/pivot/trunk:
core/src/pivot/collections/ArrayList.java
wtk/src/pivot/wtk/ApplicationContext.java
Author: gbrown
Date: Thu Jun 11 16:34:57 2009
New Revision: 783834
URL: http://svn.apache.org/viewvc?rev=783834&view=rev
Log:
Remove some Java 6/OS X workarounds.
Modified:
incubator/pivot/trunk/core/src/pivot/collections/ArrayList.java
incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java
Modified: incubator/pivot/trunk/core/src/pivot/collections/ArrayList.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/pivot/collections/ArrayList.java?rev=783834&r1=783833&r2=783834&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/pivot/collections/ArrayList.java (original)
+++ incubator/pivot/trunk/core/src/pivot/collections/ArrayList.java Thu Jun 11 16:34:57 2009
@@ -452,37 +452,8 @@
throw new IllegalArgumentException();
}
- // TODO Use java.util.Arrays#binarySearch() when Java 6 is available
- // on Mac OS X
- // int index = Arrays.binarySearch((T[])arrayList.items, 0, arrayList.length, item, comparator);
- int index = binarySearch((T[])arrayList.items, arrayList.length, item, comparator);
+ int index = Arrays.binarySearch((T[])arrayList.items, 0, arrayList.length, item, comparator);
return index;
}
-
- // TODO Remove this method when it is no longer needed; see above
- private static <T> int binarySearch(T[] array, int length, T item, Comparator<T> comparator) {
- int low = 0;
- int high = length - 1;
-
- while (low <= high) {
- int mid = (low + high) >> 1;
- T midVal = array[mid];
- int cmp = comparator.compare(midVal, item);
-
- if (cmp < 0) {
- low = mid + 1;
- }
- else if (cmp > 0) {
- high = mid - 1;
- }
- else {
- // Item found
- return mid;
- }
- }
-
- // Item not found
- return -(low + 1);
- }
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java?rev=783834&r1=783833&r2=783834&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java Thu Jun 11 16:34:57 2009
@@ -17,6 +17,7 @@
package pivot.wtk;
import java.awt.AWTEvent;
+import java.awt.Desktop;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
@@ -42,8 +43,6 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URI;
import java.net.URL;
import java.util.Iterator;
import java.util.Timer;
@@ -1242,16 +1241,12 @@
* @param location
*/
public static void open(URL location) {
- // TODO Remove dynamic invocation when Java 6 is fully supported on
- // Mac OS X
+ Desktop desktop = Desktop.getDesktop();
+
try {
- Class<?> desktopClass = Class.forName("java.awt.Desktop");
- Method getDesktopMethod = desktopClass.getMethod("getDesktop", new Class<?>[] {});
- Method browseMethod = desktopClass.getMethod("browse", new Class[] {URI.class});
- Object desktop = getDesktopMethod.invoke(null, (Object[]) null);
- browseMethod.invoke(desktop, location.toURI());
- } catch (Exception exception) {
- System.err.println("Unable to open URL in default browser.");
+ desktop.browse(location.toURI());
+ } catch(Exception exception) {
+ System.out.println("Unable to open URL in default browser.");
}
}