Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 80549 invoked from network); 6 Sep 2006 16:08:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Sep 2006 16:08:08 -0000 Received: (qmail 41608 invoked by uid 500); 6 Sep 2006 16:07:53 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 41549 invoked by uid 500); 6 Sep 2006 16:07:53 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 41507 invoked by uid 99); 6 Sep 2006 16:07:53 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Sep 2006 09:07:53 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Sep 2006 09:07:37 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id DBBC71A982B; Wed, 6 Sep 2006 09:06:51 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r440748 [8/25] - in /incubator/harmony/enhanced/classlib/trunk/modules: accessibility/src/main/java/javax/accessibility/ awt/ awt/make/ awt/src/main/java/common/java/awt/ awt/src/main/java/common/java/awt/datatransfer/ awt/src/main/java/com... Date: Wed, 06 Sep 2006 16:06:30 -0000 To: harmony-commits@incubator.apache.org From: mloenko@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060906160651.DBBC71A982B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaArcRasterizer.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaArcRasterizer.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaArcRasterizer.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaArcRasterizer.java Wed Sep 6 09:06:15 2006 @@ -362,31 +362,31 @@ * Rasterizes arc using clippind and dashing style * @param x1 - the x coordinate of the left-upper corner of the arc bounds * @param y1 - the y coordinate of the left-upper corner of the arc bounds - * @param x2 - the width of the arc bounds - * @param y2 - the height of the arc bounds + * @param width - the width of the arc bounds + * @param height - the height of the arc bounds * @param angleStart - the start angle of the arc in degrees * @param angleExtent - the angle extent in degrees * @param clip - the MultiRectArea object of clipping area * @return a MultiRectArea of rasterizer arc */ - public static MultiRectArea rasterize(int x1, int y1, int x2, int y2, double angleStart, double angleExtent, MultiRectArea clip) { + public static MultiRectArea rasterize(int x, int y, int width, int height, double angleStart, double angleExtent, MultiRectArea clip) { - MultiRectArea mra = new MultiRectArea(); + MultiRectArea mra = new MultiRectArea(false); int cx1, cx2, cy1, cy2; - cx1 = cx2 = (x1 + x2) / 2; - cy1 = cy2 = (y1 + y2) / 2; + cx1 = cx2 = x + width / 2; + cy1 = cy2 = y + height / 2; - if ((x2 - x1) % 2 == 0) { + if (width % 2 == 0) { cx2--; } - if ((y2 - y1) % 2 == 0) { + if (height % 2 == 0) { cy2--; } - int a = Math.abs(x2 - x1) / 2; - int b = Math.abs(y2 - y1) / 2; + int a = width / 2; + int b = height / 2; double c = Math.sqrt(a * a + b * b); int xcount, ycount; Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java Wed Sep 6 09:06:15 2006 @@ -156,9 +156,6 @@ int dstX2 = dstW - 1; int dstY2 = dstH - 1; - if(srcX > srcX2 || srcY > srcY2) return; - if(dstX > dstX2 || dstY > dstY2) return; - if(srcX < 0){ width += srcX; srcX = 0; @@ -170,12 +167,17 @@ if(dstX < 0){ width += dstX; + srcX -= dstX; dstX = 0; } if(dstY < 0){ - height += srcY; - srcY = 0; + height += dstY; + srcY -= dstY; + dstY = 0; } + + if(srcX > srcX2 || srcY > srcY2) return; + if(dstX > dstX2 || dstY > dstY2) return; if(srcX + width > srcX2) width = srcX2 - srcX + 1; if(srcY + height > srcY2) height = srcY2 - srcY + 1; Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaLineRasterizer.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaLineRasterizer.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaLineRasterizer.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaLineRasterizer.java Wed Sep 6 09:06:15 2006 @@ -675,7 +675,7 @@ */ public static MultiRectArea rasterize(int x1, int y1, int x2, int y2, MultiRectArea clip, LineDasher dasher, boolean invert) { - MultiRectArea dst = new MultiRectArea(); + MultiRectArea dst = new MultiRectArea(false); int dx = x2 - x1; int dy = y2 - y1; Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaTextRenderer.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaTextRenderer.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaTextRenderer.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaTextRenderer.java Wed Sep 6 09:06:15 2006 @@ -86,6 +86,7 @@ Math.min((int)Math.round(c.getMaxY()), (int)Math.round(rBounds.getMaxY()))); } + /** * * Draws string on specified raster at desired position. @@ -178,7 +179,7 @@ * @param cMinY minimum y of the raster area to draw * @param cMaxX maximum x of the raster area to draw * @param cMaxY maximum y of the raster area to draw - */ + */ public void drawClipString(WritableRaster raster, Object color, String str, FontPeerImpl font, int x, int y, int cMinX, int cMinY, int cMaxX, int cMaxY) { Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java Wed Sep 6 09:06:15 2006 @@ -149,19 +149,25 @@ bltBG(srcX, srcY, srcSurfStruct, srcData, dstX, dstY, dstSurfStruct, dstData, width, height, bgcolor.getRGB(), - compType, alpha, clipRects); + compType, alpha, clipRects, srcSurf.invalidated()); + dstSurf.invalidate(); + srcSurf.validate(); }else{ blt(srcX, srcY, srcSurfStruct, srcData, dstX, dstY, dstSurfStruct, dstData, width, height, compType, alpha, - clipRects); + clipRects, srcSurf.invalidated()); + dstSurf.invalidate(); + srcSurf.validate(); } }else if(comp instanceof XORComposite){ XORComposite xcomp = (XORComposite) comp; xor(srcX, srcY, srcSurfStruct, srcData, dstX, dstY, dstSurfStruct, dstData, width, height, xcomp.getXORColor().getRGB(), - clipRects); + clipRects, srcSurf.invalidated()); + dstSurf.invalidate(); + srcSurf.validate(); }else{ if(srcSurf instanceof ImageSurface){ JavaBlitter.inst.blit(srcX, srcY, srcSurf, dstX, dstY, @@ -181,7 +187,8 @@ blt(0, 0, srcSurfStruct, srcData, 0, 0, tmpSurfStruct, tmpData, w, h, AlphaComposite.SRC_OVER, - 1.0f, tmpClip); + 1.0f, tmpClip, srcSurf.invalidated()); + srcSurf.validate(); JavaBlitter.inst.blit(srcX, srcY, tmpSurf, dstX, dstY, dstSurf, width, height, comp, bgcolor, clip); @@ -194,17 +201,17 @@ private native void bltBG(int srcX, int srcY, long srsSurfDataPtr, Object srcData, int dstX, int dstY, long dstSurfDataPtr, Object dstData, int width, int height, int bgcolor, - int compType, float alpha, int clip[]); + int compType, float alpha, int clip[], boolean invalidated); private native void blt(int srcX, int srcY, long srsSurfDataPtr, Object srcData, int dstX, int dstY, long dstSurfDataPtr, Object dstData, int width, int height, int compType, - float alpha, int clip[]); + float alpha, int clip[], boolean invalidated); private native void xor(int srcX, int srcY, long srsSurfDataPtr, Object srcData, int dstX, int dstY, long dstSurfDataPtr, Object dstData, int width, int height, int xorcolor, - int clip[]); + int clip[], boolean invalidated); } Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/CompositionWindow.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/CompositionWindow.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/CompositionWindow.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/CompositionWindow.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,183 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Dmitry A. Durnev + * @version $Revision$ + */ +package org.apache.harmony.awt.im; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.HeadlessException; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.TextField; +import java.awt.Toolkit; +import java.awt.event.InputMethodEvent; +import java.awt.event.KeyEvent; +import java.awt.font.TextHitInfo; +import java.awt.im.InputMethodRequests; +import java.text.CharacterIterator; + +import javax.swing.text.DefaultCaret; + +import org.apache.harmony.awt.ComponentInternals; +import org.apache.harmony.awt.text.InputMethodListenerImpl; +import org.apache.harmony.awt.text.InputMethodRequestsImpl; +import org.apache.harmony.awt.text.TextKit; + +/** + * Active IM client used to implement "below-the-spot" input style + * with active clients & "root-window" style with passive clients. + */ +class CompositionWindow extends IMWindow { + private class ActiveClient extends TextField { + + private final InputMethodRequestsImpl imRequests; + private final InputMethodListenerImpl imListener; + private final DefaultCaret caret; + + ActiveClient() throws HeadlessException { + // prevent IM invocation on this component + enableInputMethods(false); + ComponentInternals ci = ComponentInternals.getComponentInternals(); + TextKit textKit = ci.getTextKit(this); + caret = (DefaultCaret) textKit.getCaret(); + caret.setBlinkRate(0); + caret.setVisible(true); + imRequests = new InputMethodRequestsImpl(textKit) { + public TextHitInfo getLocationOffset(int x, int y) { + if (!isShowing()) { + return null; + } + return super.getLocationOffset(x, y); + } + }; + imListener = new InputMethodListenerImpl(textKit) { + public void inputMethodTextChanged(InputMethodEvent ime) { + super.inputMethodTextChanged(ime); + // create KEY_TYPED event for each committed char + // and send it to passive client or just + // redirect this event to active client + if (client == null) { + return; + } + InputMethodRequests imr = client.getInputMethodRequests(); + if (imr != null) { + if (IMManager.belowTheSpot()) { + // position window below the spot: + TextHitInfo offset = TextHitInfo.leading(0); + Rectangle textLoc = imr.getTextLocation(offset); + setLocationBelow(textLoc); + } else { + client.dispatchEvent(ime); + return; + } + } + sendCommittedText(ime); + + } + }; + addInputMethodListener(imListener); + } + + private void sendCommittedText(InputMethodEvent ime) { + int n = ime.getCommittedCharacterCount(); + // remove each committed char from text component + if (n > 0) { + setText(getText().substring(n)); + } + char c; + CharacterIterator text = ime.getText(); + if (text != null) { + c = text.first(); + while (n-- > 0) { + sendChar((Component) ime.getSource(), ime.getWhen(), c); + c = text.next(); + } + } + + } + + private void sendChar(Component src, long when, char c) { + KeyEvent ke = new KeyEvent(src, KeyEvent.KEY_TYPED, when, + 0, KeyEvent.VK_UNDEFINED, c); + src.dispatchEvent(ke); + + } + + public InputMethodRequests getInputMethodRequests() { + return imRequests; + } + + public void paint(Graphics g) { + caret.paint(g); + } + + } + + private Component client; + private ActiveClient activeClient; + + public CompositionWindow(Component client) { + setClient(client); + activeClient = new ActiveClient(); + add(activeClient); + setSize(500, 40); + // use root window input style by default: + Dimension screenSize = getScreenSize(); + int x = screenSize.width - getWidth(); + int y = screenSize.height - 3 * getHeight(); + setLocation(x, y); + } + + private Dimension getScreenSize() { + return Toolkit.getDefaultToolkit().getScreenSize(); + } + + public InputMethodRequests getInputMethodRequests() { + return getActiveClient().getInputMethodRequests(); + } + + Component getActiveClient() { + return activeClient; + } + + final void setClient(Component client) { + this.client = client; + } + + boolean isEmpty() { + return (activeClient.getText().length() == 0); + } + + private void setLocationBelow(Rectangle textLoc) { + Point loc = textLoc.getLocation(); + loc.translate(0, textLoc.height); + Dimension screenSize = getScreenSize(); + int h = getHeight(); + int w = getWidth(); + if (loc.y + h > screenSize.height) { + loc.y = textLoc.y - h; + } + if (loc.x + w > screenSize.width) { + loc.x = screenSize.width - w; + } + setLocation(loc); + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMJFrame.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMJFrame.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMJFrame.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMJFrame.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,49 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Dmitry A. Durnev + * @version $Revision$ + */ +package org.apache.harmony.awt.im; + +import java.awt.im.InputContext; + +import javax.swing.JFrame; + +public class IMJFrame extends JFrame { + private final InputContext inputContext; + + IMJFrame(String title, InputContext ic) { + super(title); + inputContext = ic; + } + + IMJFrame() { + this("Input Window", null); + } + + public void addNotify() { + super.addNotify(); + IMManager.makeIMWindow(this); + } + + public InputContext getInputContext() { + if (inputContext != null) { + return inputContext; + } + return super.getInputContext(); + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMManager.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMManager.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMManager.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMManager.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,354 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Dmitry A. Durnev + * @version $Revision$ + */ +package org.apache.harmony.awt.im; + +import java.awt.AWTException; +import java.awt.CheckboxMenuItem; +import java.awt.Component; +import java.awt.HeadlessException; +import java.awt.Menu; +import java.awt.MenuContainer; +import java.awt.MenuItem; +import java.awt.PopupMenu; +import java.awt.Window; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.im.spi.InputMethodDescriptor; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.prefs.Preferences; + +import org.apache.harmony.awt.ComponentInternals; +import org.apache.harmony.awt.ContextStorage; +import org.apache.harmony.awt.wtk.NativeIM; + + +/** + * Helper class which manages resources shared by + * several InputMethodContexts, such as list of + * IM descriptors, IM selection popup, currently visible composition + * window, etc + */ +public class IMManager { + private static final String SEL_KEY_NODE = "java/awt/im/selectionKey"; + private static final String INPUT_STYLE_PROP = "java.awt.im.style"; + private static final String BELOW_THE_SPOT = "below-the-spot"; + private static final String SERVICES = "META-INF/services/"; + + /** + * Input method selection popup menu + */ + private static class IMSelection extends PopupMenu implements ItemListener { + + private class IMenuItem extends CheckboxMenuItem { + private final Locale locale; + + IMenuItem(Locale loc) throws HeadlessException { + super(loc.getDisplayName()); + locale = loc; + } + + private final InputMethodDescriptor getDesc() { + MenuContainer parent = getParent(); + if (parent instanceof IMSubmenu) { + return ((IMSubmenu) parent).getDesc(); + } + return null; + } + + private final Locale getLocale() { + return locale; + } + + public String paramString() { + return super.paramString() + ",desc=" + + getDesc() + ",locale=" + locale; + } + + } + + private class IMSubmenu extends Menu { + private final InputMethodDescriptor desc; + IMSubmenu(InputMethodDescriptor imd) throws HeadlessException { + super(imd.getInputMethodDisplayName(null, null)); + desc = imd; + addLocales(); + } + + private final InputMethodDescriptor getDesc() { + return desc; + } + + public String paramString() { + return super.paramString() + ",desc=" + desc; + } + + private void addLocales() { + try { + Locale[] locs = desc.getAvailableLocales(); + for (int j = 0; j < locs.length; j++) { + addMenuItem(locs[j]); + } + } catch (AWTException e) { + e.printStackTrace(); + } + } + + private void addMenuItem(Locale loc) { + IMenuItem item = new IMenuItem(loc); + item.addItemListener(IMSelection.this); + add(item); + } + + private void checkItems() { + for (int i = 0; i < getItemCount(); i++) { + IMenuItem item = (IMenuItem) getItem(i); + try { + item.setState(item.getLocale().equals(imContext.getLocale())); + // TODO: also check input method descriptor + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + + InputMethodContext imContext; + + public IMSelection() { + Iterator it = getIMDescriptors().iterator(); + // native IM is always first + addNativeIM(it); + while (it.hasNext()) { + addIM(it); + } + } + + private void addIM(Iterator it) { + InputMethodDescriptor desc = (InputMethodDescriptor) it.next(); + IMSubmenu subMenu = new IMSubmenu(desc); + add(subMenu); + } + + private void addNativeIM(Iterator it) { + if (it.hasNext()) { + addIM(it); + } + add(new MenuItem("-")); //separator + } + + public void itemStateChanged(ItemEvent e) { + if (imContext == null) { + return; + } + Object src = e.getSource(); + if (src instanceof IMenuItem) { + IMenuItem item = (IMenuItem) src; + imContext.selectIM(item.getDesc(), item.getLocale()); + } + + } + private void show(Component origin, InputMethodContext imc) { + imContext = imc; + + for (int i = 0; i < getItemCount(); i++) { + MenuItem item = getItem(i); + if (!(item instanceof IMSubmenu)) { + // skip all non-menu elements, such as separators + continue; + } + IMSubmenu subMenu = (IMSubmenu) item; + InputMethodDescriptor desc = subMenu.getDesc(); + if (desc == null) { + continue; + } + if (desc.hasDynamicLocaleList()) { + subMenu.removeAll(); + subMenu.addLocales(); + } + subMenu.checkItems(); + i++; + } + show(origin, 50, 50); + } + } + + private static List imd; // available IM descriptors + private static IMSelection imPopup; // IM selection popup menu + // only 1 composition window is visible even if there're several InputContexts + private static Window curCompositionWindow; + // last InputMethodContext which had an active IM + private static InputMethodContext lastActiveIMC; + + static List getIMDescriptors() { + if (imd == null) { + imd = loadIMDescriptors(); + } + return imd; + } + + /** + * Loads all IM descriptors from + * extension jars(services). + * Does roughly the same as + * Service.providers(InputMethodDescriptor.class) + * @return list of input method descriptors + */ + private static List loadIMDescriptors() { + String nm = SERVICES + InputMethodDescriptor.class.getName(); + Enumeration en; + LinkedList imdList = new LinkedList(); + // first add native IM descriptor(is always present) + NativeIM nativeIM = ContextStorage.getNativeIM(); + if (nativeIM instanceof InputMethodDescriptor) { + imdList.add(nativeIM); + } + try { + en = ClassLoader.getSystemResources(nm); + ClassLoader cl = ClassLoader.getSystemClassLoader(); + while (en.hasMoreElements()) { + URL url = (URL) en.nextElement(); + InputStreamReader isr = new InputStreamReader(url.openStream(), + "UTF-8"); + BufferedReader br = new BufferedReader(isr); + String str = br.readLine(); + + while (str != null) { + str = str.trim(); + int comPos = str.indexOf("#"); + if (comPos >= 0) { + str = str.substring(0, comPos); + } + if (str.length() > 0) { + imdList.add(cl.loadClass(str).newInstance()); + } + str = br.readLine(); + } + + } + } catch (Exception e) { + // just silently ignore exception ? + } + return imdList; + } + + private static void showIMPopup(InputMethodContext imc, Window parent) { + List descriptors = getIMDescriptors(); + if ((descriptors == null) || descriptors.isEmpty()) { + // show menu only if some non-native IMs are present + return; + } + if (imPopup == null) { + imPopup = new IMSelection(); + } + + if (parent != null) { + parent.add(imPopup); + imPopup.show(parent, imc); + } + } + + private static int getPref(String key, int def) { + int pref = getPref(Preferences.userRoot(), key, def); + + if (pref != def) { + return pref; + } + + return getPref(Preferences.systemRoot(), key ,def); + } + + private static int getPref(Preferences root, String key, int def) { + return root.node(SEL_KEY_NODE).getInt(key, def); + } + + static void selectIM(KeyEvent ke, InputMethodContext imc, Window parent) { + int def = KeyEvent.VK_UNDEFINED; + int keyCode = getPref("keyCode", def); + if (keyCode != def) { + int modifiers = getPref("modifiers", 0); + if ((ke.getKeyCode() == keyCode) + && (ke.getModifiers() == modifiers)) { + IMManager.showIMPopup(imc, parent); + + } + } + } + + static void showCompositionWindow(Window w) { + + if (curCompositionWindow != null) { + if (curCompositionWindow != w) { + curCompositionWindow.hide(); + } + } + curCompositionWindow = w; + if ((curCompositionWindow != null) && !curCompositionWindow.isVisible()) { + curCompositionWindow.show(); + } + } + + private static String getInputStyle() { + String propName = INPUT_STYLE_PROP; + String inputStyle = System.getProperty(propName); + if (inputStyle != null) { + return inputStyle; + } + return java.awt.Toolkit.getProperty(propName, null); + } + + static boolean belowTheSpot() { + return BELOW_THE_SPOT.equals(getInputStyle()); + } + + static Window getWindow(Component comp) { + if (comp == null) { + return null; + } + Component parent = comp.getParent(); + while ( (parent != null) && !(parent instanceof Window)) { + parent = parent.getParent(); + } + return (Window) parent; + } + + static void makeIMWindow(Window win) { + win.setFocusableWindowState(false); + win.setAlwaysOnTop(true); + ComponentInternals ci = ComponentInternals.getComponentInternals(); + ci.getNativeWindow(win).setIMStyle(); + } + + public static final InputMethodContext getLastActiveIMC() { + return lastActiveIMC; + } + + static final void setLastActiveIMC(InputMethodContext lastActiveIMC) { + IMManager.lastActiveIMC = lastActiveIMC; + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMWindow.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMWindow.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMWindow.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/IMWindow.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,48 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Dmitry A. Durnev + * @version $Revision$ + */ +package org.apache.harmony.awt.im; + +import java.awt.Frame; +import java.awt.im.InputContext; + +public class IMWindow extends Frame { + private final InputContext inputContext; + + IMWindow(String title, InputContext ic) { + super(title); + inputContext = ic; + } + + IMWindow() { + this("Input Window", null); + } + + public void addNotify() { + super.addNotify(); + IMManager.makeIMWindow(this); + } + + public InputContext getInputContext() { + if (inputContext != null) { + return inputContext; + } + return super.getInputContext(); + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/InputMethodContext.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/InputMethodContext.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/InputMethodContext.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/im/InputMethodContext.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,519 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Dmitry A. Durnev + * @version $Revision$ + */ +package org.apache.harmony.awt.im; + +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.KeyboardFocusManager; +import java.awt.Rectangle; +import java.awt.Window; +import java.awt.event.FocusEvent; +import java.awt.event.InputMethodEvent; +import java.awt.event.KeyEvent; +import java.awt.font.TextHitInfo; +import java.awt.im.InputContext; +import java.awt.im.InputMethodRequests; +import java.awt.im.spi.InputMethod; +import java.awt.im.spi.InputMethodDescriptor; +import java.lang.Character.Subset; +import java.text.AttributedCharacterIterator; +import java.text.AttributedCharacterIterator.Attribute; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import javax.swing.JFrame; + +import org.apache.harmony.awt.wtk.NativeIM; + +/** + * Implementation of InputMethodContext + * interface, also provides all useful + * functionality of InputContext + * + */ +public class InputMethodContext extends InputContext implements + java.awt.im.spi.InputMethodContext { + + private InputMethod inputMethod; // current IM + private Component client; // current "active" client component + private CompositionWindow composeWindow; // composition Window + private Map imInstances; // Map + private Map localeIM; // Map last user-selected IM for locale + private Set notifyIM; // set of IMs to notify of client window bounds changes + /** + * a flag indicating that IM should be notified of client window + * position/visibility changes as soon as it is activated(new client + * appears) + */ + private boolean pendingClientNotify; + private Component nextComp; // component to gain focus after endComposition() + private Set imWindows; // set of all IM windows created by this instance + private final NativeIM nativeIM; + + + public InputMethodContext() { + notifyIM = new HashSet(); + imWindows = new HashSet(); + imInstances = new HashMap(); + localeIM = new HashMap(); + selectInputMethod(Locale.US); // not default? + nativeIM = (NativeIM) inputMethod; + } + + public void dispatchEvent(AWTEvent event) { + int id = event.getID(); + if ((id >= FocusEvent.FOCUS_FIRST) && (id <=FocusEvent.FOCUS_LAST)) { + dispatchFocusEvent((FocusEvent) event); + } else { + // handle special KEY_PRESSED + // event to show IM selection menu + if (id == KeyEvent.KEY_PRESSED) { + KeyEvent ke = (KeyEvent) event; + IMManager.selectIM(ke, this, + IMManager.getWindow(ke.getComponent())); + } + // dispatch all input events to the current IM: + if (inputMethod != null) { + inputMethod.dispatchEvent(event); + } + } + } + + private void dispatchFocusEvent(FocusEvent fe) { + switch (fe.getID()) { + case FocusEvent.FOCUS_LOST: + if (inputMethod != null) { + inputMethod.deactivate(fe.isTemporary()); + } + break; + case FocusEvent.FOCUS_GAINED: + + Component comp = fe.getComponent(); + if (imWindows.contains(comp)) { + // prevent activating when IM windows + // attached to this context gain focus + return; + } + InputMethodContext lastActive = IMManager.getLastActiveIMC(); + if ((lastActive != this) && (lastActive != null)) { + lastActive.hideWindows(); + } + if (inputMethod != null) { + activateIM(inputMethod); + if (!getCompositionWindow().isEmpty()) { + IMManager.showCompositionWindow(composeWindow); + } + if (client == comp) { + if (nextComp != null) { + // temporarily got focus to + // end composition + endComposition(); + + // transfer focus to new client + client = nextComp; + nextComp = null; + client.requestFocusInWindow(); + } + } else if (client != null) { + // temporarily return focus back + // to previous client to be able + // to end composition + nextComp = comp; + client.requestFocusInWindow(); + } else { + client = comp; + } + } + if (pendingClientNotify) { + notifyClientWindowChange(IMManager.getWindow(comp).getBounds()); + } + break; + } + + } + + private void activateIM(InputMethod im) { + im.activate(); + if ((nativeIM != null) && (im != nativeIM)) { + // when Java IM is active + // native input method editor must be + // explicitly disabled + nativeIM.disableIME(); + } + IMManager.setLastActiveIMC(this); + } + + private void hideWindows() { + if (inputMethod != null) { + inputMethod.hideWindows(); + } + if (composeWindow != null) { + composeWindow.hide(); + } + } + + private void createCompositionWindow() { + composeWindow = new CompositionWindow(client); + } + + private CompositionWindow getCompositionWindow() { + if (composeWindow == null) { + createCompositionWindow(); + } + composeWindow.setClient(client); + return composeWindow; + } + + /** + * Gets input method requests for the current client + * irrespective of input style. + * @return input method requests of composition window if + * client is passive, + * otherwise input method requests of client + */ + private InputMethodRequests getIMRequests() { + InputMethodRequests imRequests = null; + + if (client != null) { + imRequests = client.getInputMethodRequests(); + if (imRequests == null) { + imRequests = getCompositionWindow().getInputMethodRequests(); + } + } + + return imRequests; + } + + /** + * Gets input method requests for the current client & input style. + * @return input method requests of composition window if + * input style is "below-the-spot"(or client is passive), + * otherwise client input method requests + */ + private InputMethodRequests getStyleIMRequests() { + if (IMManager.belowTheSpot()) { + return getCompositionWindow().getInputMethodRequests(); + } + return getIMRequests(); + } + + public void dispose() { + if (inputMethod != null) { + closeIM(inputMethod); + inputMethod.dispose(); + } + notifyIM.clear(); + super.dispose(); + } + + public void endComposition() { + if (inputMethod != null) { + inputMethod.endComposition(); + } + super.endComposition(); + } + + public Object getInputMethodControlObject() { + if (inputMethod != null) { + return inputMethod.getControlObject(); + } + return super.getInputMethodControlObject(); + } + + public Locale getLocale() { + if (inputMethod != null) { + return inputMethod.getLocale(); + } + return super.getLocale(); + } + + public boolean isCompositionEnabled() { + if (inputMethod != null) { + return inputMethod.isCompositionEnabled(); + } + return super.isCompositionEnabled(); + } + + public void reconvert() { + if (inputMethod != null) { + inputMethod.reconvert(); + } + super.reconvert(); + } + + public void removeNotify(Component client) { + if ((inputMethod != null) && (client == this.client)) { + inputMethod.removeNotify(); + client = null; + // set flag indicating that IM should be notified + // as soon as it is activated(new client appears) + pendingClientNotify = true; + } + + super.removeNotify(client); + } + + public boolean selectInputMethod(Locale locale) { + + if ((inputMethod != null) && inputMethod.setLocale(locale)) { + return true; + } else { + // first + // take last user-selected IM for locale + InputMethod newIM = (InputMethod) localeIM.get(locale); + + // if not found search through IM descriptors + // and take already created instance if exists + // or create, store new IM instance in descriptor->instance map + if (newIM == null) { + try { + newIM = getIMInstance(IMManager.getIMDescriptors().iterator(), + locale); + } catch (Exception e) { + // ignore exceptions - just return false + } + } + + return switchToIM(locale, newIM); + } + } + + private boolean switchToIM(Locale locale, InputMethod newIM) { + if (newIM != null) { + closeIM(inputMethod); + client = KeyboardFocusManager. + getCurrentKeyboardFocusManager().getFocusOwner(); + initIM(newIM, locale); + inputMethod = newIM; + + return true; + } + return false; + } + + /** + * Is called when IM is selected from UI + */ + void selectIM(InputMethodDescriptor imd, Locale locale) { + try { + switchToIM(locale, getIMInstance(imd)); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Gets input method instance for the given + * locale from the given list of descriptors + * @param descriptors iterator of the list of IM descriptors + * @param locale the locale to be supported by the IM + * @return input method instance + * @throws Exception + */ + private InputMethod getIMInstance(Iterator descriptors, + Locale locale) throws Exception { + while (descriptors.hasNext()) { + InputMethodDescriptor desc = (InputMethodDescriptor) descriptors.next(); + Locale[] locs = desc.getAvailableLocales(); + for (int j = 0; j < locs.length; j++) { + if (locale.equals(locs[j])) { + return getIMInstance(desc); + } + } + } + return null; + } + + private InputMethod getIMInstance(InputMethodDescriptor imd) throws Exception { + InputMethod im = (InputMethod) imInstances.get(imd); + if (im == null) { + im = imd.createInputMethod(); + im.setInputMethodContext(this); + imInstances.put(imd, im); + } + return im; + } + + private void initIM(InputMethod im, Locale locale) { + if (im == null) { + return; + } + im.setLocale(locale); + im.setCharacterSubsets(null); + activateIM(im); + try { + im.setCompositionEnabled(inputMethod != null ? + inputMethod.isCompositionEnabled() : true); + } catch (UnsupportedOperationException uoe) { + + } + + } + + private void closeIM(InputMethod im) { + if (im == null) { + return; + } + if (im.isCompositionEnabled()) { + im.endComposition(); + } + + im.deactivate(true); + im.hideWindows(); + + } + + public void setCharacterSubsets(Subset[] subsets) { + if (inputMethod != null) { + inputMethod.setCharacterSubsets(subsets); + } + super.setCharacterSubsets(subsets); + } + + public void setCompositionEnabled(boolean enable) { + if (inputMethod != null) { + inputMethod.setCompositionEnabled(enable); + } + super.setCompositionEnabled(enable); + } + + public JFrame createInputMethodJFrame(String title, + boolean attachToInputContext) { + JFrame jf = new IMJFrame(title, attachToInputContext ? this : null); + imWindows.add(jf); + return jf; + } + + public Window createInputMethodWindow(String title, + boolean attachToInputContext) { + Window w = new IMWindow(title, attachToInputContext ? this : null); + imWindows.add(w); + return w; + } + + public void dispatchInputMethodEvent(int id, + AttributedCharacterIterator text, + int committedCharacterCount, + TextHitInfo caret, + TextHitInfo visiblePosition) { + if (client == null) { + return; + } + InputMethodEvent ime = new InputMethodEvent(client, id, text, + committedCharacterCount, + caret, visiblePosition); + + if ((client.getInputMethodRequests() != null) && + !IMManager.belowTheSpot()) { + + client.dispatchEvent(ime); + } else { + + // show/hide composition window if necessary + if (committedCharacterCount < text.getEndIndex()) { + IMManager.showCompositionWindow(getCompositionWindow()); + } else { + getCompositionWindow().hide(); + } + composeWindow.getActiveClient().dispatchEvent(ime); + } + + } + + public void enableClientWindowNotification(InputMethod inputMethod, + boolean enable) { + if (enable) { + notifyIM.add(inputMethod); + if (client != null) { + notifyClientWindowChange(IMManager.getWindow(client).getBounds()); + } else { + pendingClientNotify = true; + } + } else { + notifyIM.remove(inputMethod); + } + + + + } + + public AttributedCharacterIterator cancelLatestCommittedText( + Attribute[] attributes) { + return getIMRequests().cancelLatestCommittedText(attributes); + } + + public AttributedCharacterIterator getCommittedText(int beginIndex, + int endIndex, + Attribute[] attributes) { + return getIMRequests().getCommittedText(beginIndex, endIndex, + attributes); + } + + public int getCommittedTextLength() { + return getIMRequests().getCommittedTextLength(); + } + + public int getInsertPositionOffset() { + return getIMRequests().getInsertPositionOffset(); + } + + public TextHitInfo getLocationOffset(int x, int y) { + InputMethodRequests imr = getStyleIMRequests(); + if (imr != null) { + return imr.getLocationOffset(x, y); + } + return null; + } + + public AttributedCharacterIterator getSelectedText(Attribute[] attributes) { + return getIMRequests().getSelectedText(attributes); + } + + public Rectangle getTextLocation(TextHitInfo offset) { + return getStyleIMRequests().getTextLocation(offset); + } + + /** + * To be called by AWT when client Window's bounds/visibility/state + * change + */ + public void notifyClientWindowChange(Rectangle bounds) { + if (notifyIM.contains(inputMethod)) { + inputMethod.notifyClientWindowChange(bounds); + } + pendingClientNotify = false; + } + + public final InputMethod getInputMethod() { + return inputMethod; + } + + public final Component getClient() { + return client; + } + + public final NativeIM getNativeIM() { + return nativeIM; + } +} Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/InputMethodRequestsImpl.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/InputMethodRequestsImpl.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/InputMethodRequestsImpl.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/InputMethodRequestsImpl.java Wed Sep 6 09:06:15 2006 @@ -19,6 +19,7 @@ */ package org.apache.harmony.awt.text; +import java.awt.Component; import java.awt.Point; import java.awt.Rectangle; import java.awt.font.TextHitInfo; @@ -258,8 +259,16 @@ public TextHitInfo getLocationOffset(final int x, final int y) { Point p = new Point(x, y); - Point location = textKit.getComponent().getLocationOnScreen(); + final Component component = textKit.getComponent(); + if (!component.isDisplayable()) { + return null; + } + Point location = component.getLocationOnScreen(); p.translate(-location.x, -location.y); + if (!component.contains(p)) { + // Return null if the location is outside the component. + return null; + } int offset = textKit.viewToModel(p, new Position.Bias[1]); ComposedTextParams composedTextParams = getComposedTextParams(); int lastInsertPosition = composedTextParams.getComposedTextStart(); Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java Wed Sep 6 09:06:15 2006 @@ -1129,12 +1129,10 @@ public static void isPositionValid(final View view, final int pos) throws BadLocationException { - final Element element = view.getElement(); - - if (pos < element.getStartOffset() || pos > element.getEndOffset()) { + if (pos < view.getStartOffset() || pos > view.getEndOffset()) { throw new BadLocationException(pos + " not in range " - + element.getStartOffset() + "," - + element.getEndOffset(), pos); + + view.getStartOffset() + "," + + view.getEndOffset(), pos); } } } Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java Wed Sep 6 09:06:15 2006 @@ -72,8 +72,6 @@ // Font methods FontMetrics getFontMetrics(Font font); FontManager getFontManager(); - FontPeer createFontPeer(Font font); - FontPeer createFontPeer(FontProperty fp, int size); - void freeFontPeer(Font font); + FontPeer getFontPeer(Font font); Font embedFont(String fontFilePath); } Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEvent.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEvent.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEvent.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEvent.java Wed Sep 6 09:06:15 2006 @@ -43,37 +43,32 @@ * Message has no common cross-platform * interpretation and should be skipped. */ - public static final int ID_PLATFORM = -1; + public static final int ID_PLATFORM = 0; /** * Window bounds have changed. */ - public static final int ID_BOUNDS_CHANGED = -2; - - /** - * Special event initiated by Java code. - */ - public static final int ID_JAVA_EVENT = -3; + public static final int ID_BOUNDS_CHANGED = -1; /** * Window decoration size has changed. */ - public static final int ID_INSETS_CHANGED = -4; + public static final int ID_INSETS_CHANGED = -2; /** * Window was just created (WM_CREATE on Windows) */ - public static final int ID_CREATED = -5; + public static final int ID_CREATED = -3; /** * Mouse grab was canceled by the native system */ - public static final int ID_MOUSE_GRAB_CANCELED = -6; + public static final int ID_MOUSE_GRAB_CANCELED = -4; /** * System color scheme or visual theme was changed */ - public static final int ID_THEME_CHANGED = -7; + public static final int ID_THEME_CHANGED = -5; protected long windowId; protected int eventId; @@ -234,14 +229,14 @@ } /** - * Returns the "damaged" area of the window as set of non-intersecting + * Returns the "dirty" area of the window as set of non-intersecting * rectangles. This area is to be painted. * @return non-empty array of null if empty */ public abstract MultiRectArea getClipRects(); /** - * Returns the "damaged" area of the window as one rectangles. + * Returns the "dirty" area of the window as one rectangle. * This area is to be painted. * @return non-null Rectangle */ @@ -268,24 +263,5 @@ */ public int getWheelRotation() { return wheelRotation; - } - - protected void reset() { - windowId = 0; - eventId = 0; - otherWindowId = 0; - - localPos = null; - screenPos = null; - windowRect = null; - - modifiers = 0; - mouseButton = 0; - wheelRotation = 0; - - keyInfo = null; - - windowState = -1; - time = 0; } } Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEventQueue.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEventQueue.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEventQueue.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEventQueue.java Wed Sep 6 09:06:15 2006 @@ -19,6 +19,9 @@ */ package org.apache.harmony.awt.wtk; +import java.util.LinkedList; + + /** * Describes the cross-platform native event queue interface * @@ -26,7 +29,18 @@ * created. All other methods would be called obly from this thread, * except awake(). */ -public interface NativeEventQueue { +public abstract class NativeEventQueue { + + private ShutdownWatchdog shutdownWatchdog; + private final Object eventMonitor = new Object(); + private final LinkedList eventQueue = new LinkedList(); + + public static abstract class Task { + public volatile Object returnValue; + + public abstract void perform(); + } + /** * Blocks current thread until native event queue is not empty * or awaken from other thread by awake(). @@ -36,7 +50,7 @@ * * @return if event loop should be stopped */ - boolean waitEvent(); + public abstract boolean waitEvent(); /** * Determines whether or not the native event queue is empty. @@ -44,45 +58,58 @@ * * @return true if the queue is empty; false otherwise */ - boolean isEmpty(); + public boolean isEmpty() { + synchronized(eventQueue) { + return eventQueue.isEmpty(); + } + } + + public NativeEvent getNextEvent() { + synchronized (eventQueue) { + if (eventQueue.isEmpty()) { + shutdownWatchdog.setNativeQueueEmpty(true); + return null; + } + return (NativeEvent)eventQueue.remove(0); + } + } + + protected void addEvent(NativeEvent event) { + synchronized (eventQueue) { + eventQueue.add(event); + shutdownWatchdog.setNativeQueueEmpty(false); + } + synchronized (eventMonitor) { + eventMonitor.notify(); + } + } + + public final Object getEventMonitor() { + return eventMonitor; + } - /** - * Dispatches latest native event to listener. Should be called on - * the same thread as waitEvent. - * - *

The return value should be ignored in most cases. - * @return result of event dipatching - */ - long dispatchEventToListener(); + public abstract void awake(); /** - * Sets the application provided native event listener. - * Only one listener is allowed simultanously. + * Gets AWT system window ID. * - * @param e - the listener - */ - void setNativeEventListener(NativeEventListener e); - - /** - * Awakes blocked waitEvent from other thread. + * @return AWT system window ID */ - void awake(); + public abstract long getJavaWindow(); /** - * Called at the beginning of each modal loop + * Add NativeEvent to the queue */ - void onModalLoopBegin(); + public abstract void dispatchEvent(); - /** - * Called at the end of each modal loop - */ - void onModalLoopEnd(); + public abstract void performTask(Task task); - /** - * Gets AWT system window ID. - * - * @return AWT system window ID - */ - long getJavaWindow(); + public abstract void performLater(Task task); + + public final void setShutdownWatchdog(ShutdownWatchdog watchdog) { + synchronized (eventQueue) { + shutdownWatchdog = watchdog; + } + } } Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEventThread.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEventThread.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEventThread.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeEventThread.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,76 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Pavel Dolgov + * @version $Revision$ + */ +package org.apache.harmony.awt.wtk; + + +/** + * NativeEventThread + */ +public class NativeEventThread extends Thread { + + public interface Init { + WTK init(); + } + + NativeEventQueue nativeQueue; + Init init; + + private WTK wtk; + + public NativeEventThread() { + super("AWT-NativeEventThread"); + setDaemon(true); + } + + public void run() { + synchronized (this) { + try { + wtk = init.init(); + nativeQueue = wtk.getNativeEventQueue(); + } finally { + notifyAll(); + } + } + + runModalLoop(); + } + + void runModalLoop() { + while (nativeQueue.waitEvent()) { + nativeQueue.dispatchEvent(); + } + } + + public void start(Init init) { + synchronized (this) { + this.init = init; + super.start(); + try { + wait(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + + public WTK getWTK() { + return wtk; + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeIM.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeIM.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeIM.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeIM.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,130 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Dmitry A. Durnev + * @version $Revision$ + */ +package org.apache.harmony.awt.wtk; + +import java.awt.AWTEvent; +import java.awt.AWTException; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.im.spi.InputMethod; +import java.awt.im.spi.InputMethodContext; +import java.awt.im.spi.InputMethodDescriptor; +import java.lang.Character.Subset; +import java.util.Locale; + +import org.apache.harmony.awt.ContextStorage; + +/** + * A cross-platform interface for native input + * method subsysem functionality. + */ +public abstract class NativeIM implements InputMethod, InputMethodDescriptor { + protected InputMethodContext imc; + + public void activate() { + + } + + public void deactivate(boolean isTemporary) { + + } + + public void dispatchEvent(AWTEvent event) { + + } + + public void dispose() { + + } + + public void endComposition() { + + } + + public Object getControlObject() { + return null; + } + + public Locale getLocale() { + return null; + } + + public void hideWindows() { + + } + + public boolean isCompositionEnabled() { + return false; + } + + public void notifyClientWindowChange(Rectangle bounds) { + + } + + public void reconvert() { + + } + + public void removeNotify() { + + } + + public void setCharacterSubsets(Subset[] subsets) { + + } + + public void setCompositionEnabled(boolean enable) { + + } + + public void setInputMethodContext(InputMethodContext context) { + imc = context; + } + + public boolean setLocale(Locale locale) { + return false; + } + + public Locale[] getAvailableLocales() throws AWTException { + return new Locale[]{Locale.getDefault(), Locale.ENGLISH}; + } + + public InputMethod createInputMethod() throws Exception { + return this; + } + + public String getInputMethodDisplayName(Locale inputLocale, + Locale displayLanguage) { + return "System input methods"; + } + + public Image getInputMethodIcon(Locale inputLocale) { + return null; + } + + public boolean hasDynamicLocaleList() { + return false; + } + + public abstract void disableIME(); + +// public abstract void disableIME(long id); + +} Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeWindow.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeWindow.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeWindow.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/NativeWindow.java Wed Sep 6 09:06:15 2006 @@ -205,6 +205,15 @@ * must be resized instead */ void setPacked(boolean packed); + + /** + * Make window an "input method window" by setting + * special window style, e. g. small title bar, no + * close, minimize/maximize buttons. For internal + * use by input method framework. + * + */ + void setIMStyle(); MultiRectArea getObscuredRegion(Rectangle part); } Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/ShutdownThread.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/ShutdownThread.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/ShutdownThread.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/ShutdownThread.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,76 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Michael Danilov, Pavel Dolgov + * @version $Revision$ + */ +package org.apache.harmony.awt.wtk; + +public final class ShutdownThread extends Thread { + + public static final class Watchdog { + } + + public ShutdownThread() { + setName("AWT-Shutdown"); + setDaemon(false); + } + + private boolean shouldStop = false; + + public void run() { + synchronized (this) { + notifyAll(); // synchronize the startup + + while (true) { + try { + wait(); + } catch (InterruptedException e) { + } + + if (shouldStop) { + notifyAll(); // synchronize the shutdown + return; + } + } + } + } + + public void start() { + synchronized (this) { + super.start(); + try { + wait(); + } catch (InterruptedException e) { + throw new RuntimeException( + "Shutdown thread was interrupted while starting"); + } + } + } + + public void shutdown() { + synchronized (this) { + shouldStop = true; + notifyAll(); + try { + wait(); + } catch (InterruptedException e) { + throw new RuntimeException( + "Shutdown thread was interrupted while stopping"); + } + } + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/ShutdownWatchdog.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/ShutdownWatchdog.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/ShutdownWatchdog.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/ShutdownWatchdog.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,85 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Pavel Dolgov + * @version $Revision$ + */ +package org.apache.harmony.awt.wtk; + +/** + * Shutdown Watchdog + */ +public final class ShutdownWatchdog { + + private boolean nativeQueueEmpty = true; + private boolean awtQueueEmpty = true; + private boolean windowListEmpty = true; + + private boolean forcedShutdown = false; + + private ShutdownThread thread; + + public synchronized void setNativeQueueEmpty(boolean empty) { + nativeQueueEmpty = empty; + checkShutdown(); + } + + public synchronized void setAwtQueueEmpty(boolean empty) { + awtQueueEmpty = empty; + checkShutdown(); + } + + public synchronized void setWindowListEmpty(boolean empty) { + windowListEmpty = empty; + checkShutdown(); + } + + public synchronized void forceShutdown() { + forcedShutdown = true; + shutdown(); + } + + public synchronized void start() { + keepAlive(); + } + + private void checkShutdown() { + if (canShutdown()) { + shutdown(); + } else { + keepAlive(); + } + } + + private boolean canShutdown() { + return (nativeQueueEmpty && awtQueueEmpty && windowListEmpty) || + forcedShutdown; + } + + private void keepAlive() { + if (thread == null) { + thread = new ShutdownThread(); + thread.start(); + } + } + + private void shutdown() { + if (thread != null) { + thread.shutdown(); + thread = null; + } + } +} Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/SystemProperties.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/SystemProperties.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/SystemProperties.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/SystemProperties.java Wed Sep 6 09:06:15 2006 @@ -20,6 +20,8 @@ package org.apache.harmony.awt.wtk; import java.awt.Font; +import java.awt.im.InputMethodHighlight; +import java.util.Map; /** * NativeProperties @@ -39,4 +41,17 @@ * @return the font object */ Font getDefaultFont(); + + /** + * Fill the given Map with system properties + */ + void init(Map desktopProperties); + + /** + * Fills the given map with system-dependent visual text + * attributes for the abstract description + * of the given input method highlight + * @see java.awt.Toolkit.mapInputMethodHighlight() + */ + void mapInputMethodHighlight(InputMethodHighlight highlight, Map map); } Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/WTK.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/WTK.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/WTK.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/WTK.java Wed Sep 6 09:06:15 2006 @@ -50,4 +50,11 @@ * @return implementation of NativeRobot */ public abstract NativeRobot getNativeRobot(GraphicsDevice screen); + + /** + * Returns platform specific implementation of the abstract + * class org.apache.harmony.awt.wtk.NativeIM. + * @return implementation of NativeIM + */ + public abstract NativeIM getNativeIM(); } Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDTK.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDTK.java?view=diff&rev=440748&r1=440747&r2=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDTK.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDTK.java Wed Sep 6 09:06:15 2006 @@ -19,7 +19,13 @@ */ package org.apache.harmony.awt.datatransfer.linux; -import org.apache.harmony.awt.datatransfer.*; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.peer.DragSourceContextPeer; +import java.awt.dnd.peer.DropTargetContextPeer; + +import org.apache.harmony.awt.datatransfer.DTK; +import org.apache.harmony.awt.datatransfer.NativeClipboard; public final class LinuxDTK extends DTK { @@ -27,16 +33,27 @@ return new LinuxSelection("CLIPBOARD"); } - protected NativeTextDescriptor newTextDescriptor() { - return new LinuxTextDescriptor(); + protected NativeClipboard newNativeSelection() { + return new LinuxSelection("PRIMARY"); } - protected NativeTranslationManager newTranslationManager() { - return new LinuxTranslationManager(); + public void initDragAndDrop() { } - protected NativeClipboard newNativeSelection() { - return new LinuxSelection("PRIMARY"); + public void runEventLoop() { } + public DropTargetContextPeer createDropTargetContextPeer( + DropTargetContext context) { + return new LinuxDropTarget(this, context); + } + + public DragSourceContextPeer createDragSourceContextPeer( + DragGestureEvent dge) { + return new LinuxDragSource(); + } + + public String getDefaultCharset() { + return "iso-10646-ucs-2"; + } } Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDragSource.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDragSource.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDragSource.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDragSource.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,58 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Pavel Dolgov + * @version $Revision$ + */ +package org.apache.harmony.awt.datatransfer.linux; + +import java.awt.Cursor; +import java.awt.Image; +import java.awt.Point; +import java.awt.dnd.DragSourceContext; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; + +public class LinuxDragSource implements DragSourceContextPeer { + + private Cursor cursor; + private DragSourceContext context; + + public Cursor getCursor() { + synchronized (this) { + return cursor; + } + } + + public void setCursor(Cursor c) throws InvalidDnDOperationException { + synchronized (this) { + cursor = c; + } + } + + public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point ioff) + throws InvalidDnDOperationException { + synchronized (this) { + context = dsc; + cursor = c; + } + + } + + public void transferablesFlavorsChanged() { + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDropTarget.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDropTarget.java?view=auto&rev=440748 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDropTarget.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/datatransfer/linux/LinuxDropTarget.java Wed Sep 6 09:06:15 2006 @@ -0,0 +1,90 @@ +/* + * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @author Pavel Dolgov + * @version $Revision$ + */ +package org.apache.harmony.awt.datatransfer.linux; + +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DropTargetContextPeer; + +import org.apache.harmony.awt.ContextStorage; +import org.apache.harmony.awt.wtk.linux.LinuxEventQueue; + +public class LinuxDropTarget implements DropTargetContextPeer { + + private final LinuxDTK dtk; + private final LinuxEventQueue nativeQueue; + + private final DropTargetContext context; + private Transferable transferable; + + public LinuxDropTarget(LinuxDTK dtk, DropTargetContext context) { + this.dtk = dtk; + this.context = context; + nativeQueue = (LinuxEventQueue)ContextStorage.getNativeEventQueue(); + } + + public void acceptDrag(int dragAction) { + } + + public void acceptDrop(int dropAction) { + } + + public void dropComplete(boolean success) { + } + + public DropTarget getDropTarget() { + return context.getDropTarget(); + } + + public int getTargetActions() { + return context.getDropTarget().getDefaultActions(); + } + + public DataFlavor[] getTransferDataFlavors() { + return (transferable != null) ? + transferable.getTransferDataFlavors() : new DataFlavor[0]; + } + + public Transferable getTransferable() throws InvalidDnDOperationException { + if (transferable == null) { + throw new InvalidDnDOperationException( + "Transfer data is not available"); + } + return transferable; + } + + public boolean isTransferableJVMLocal() { + return false; + } + + public void rejectDrag() { + } + + public void rejectDrop() { + } + + public void setTargetActions(int actions) { + context.getDropTarget().setDefaultActions(actions); + } + +}