harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r454342 - /incubator/harmony/enhanced/classlib/trunk/modules/applet/src/main/java/java/applet/Applet.java
Date Mon, 09 Oct 2006 11:28:21 GMT
Author: mloenko
Date: Mon Oct  9 04:28:20 2006
New Revision: 454342

URL: http://svn.apache.org/viewvc?view=rev&rev=454342
Log:
missed one file (was: moving HARMONY-1609 (Applet, ImageIO and Print modules) files to correct
locations)


Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/applet/src/main/java/java/applet/Applet.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/applet/src/main/java/java/applet/Applet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/applet/src/main/java/java/applet/Applet.java?view=diff&rev=454342&r1=454341&r2=454342
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/applet/src/main/java/java/applet/Applet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/applet/src/main/java/java/applet/Applet.java
Mon Oct  9 04:28:20 2006
@@ -1,38 +1,237 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to you 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.
+ *  Copyright 2005 - 2006 The Apache 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: 1.3 $
+ */  
 package java.applet;
 
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.Image;
 import java.awt.Panel;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Locale;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+import org.apache.harmony.applet.AudioClipImpl;
+import org.apache.harmony.awt.AWTPermissionCollection;
+import org.apache.harmony.awt.FieldsAccessor;
 
-/**
- * This is an empty stub containing only empty methods for compilation purposes.
- * 
- * @author Maxim V. Berkultsev
- * @version $Revision: 1.13.4.2 $
- */
-public class Applet extends Panel {
 
+public class Applet extends Panel {
+    
     private static final long serialVersionUID = -5836846270535785031L;
+
+    private transient AppletStub stub;
     
+    private transient AccessibleContext accessibleContext;
+
+    /**  monitor for applet's private data */
+    private final transient Object appletLock = new Object(); 
+    protected class AccessibleApplet extends Panel.AccessibleAWTPanel {
+
+        private static final long serialVersionUID = 8127374778187708896L;
+        
+        protected AccessibleApplet() {
+            super();
+        }
+        
+        public AccessibleRole getAccessibleRole() {
+            return AccessibleRole.FRAME;
+        }
+        
+        public AccessibleStateSet getAccessibleStateSet() {
+            AccessibleStateSet set = super.getAccessibleStateSet();
+            Window owner = null;
+            for (Component c = Applet.this; c != null; c = c.getParent()) {
+                if (c instanceof Window) {
+                    owner = (Window)c;
+                    break;
+                }
+            }
+            
+            if (owner != null) {
+                if (owner.isActive()) {
+                    set.add(AccessibleState.ACTIVE);
+                }
+            }
+            return set;
+        }
+    }
+
+    public Applet() throws HeadlessException {
+        if (GraphicsEnvironment.isHeadless()) {
+            throw new HeadlessException();
+        }
+    }
+
     public void init() {
+        // do nothing by specefication
+    }
+
+    public void start() {
+        // do nothing by specefication
+    }
+
+    public void destroy() {
+        // do nothing by specefication
+    }
+
+    public void stop() {
+        // do nothing by specefication
+    }
+
+    public void resize(int width, int height) {
+        synchronized(appletLock) {
+            stub.appletResize(width, height);
+        }
+    }
+
+    public void resize(Dimension d) {
+        synchronized(appletLock) {
+            stub.appletResize(d.width, d.height);
+        }
+    }
+
+    public URL getCodeBase() {
+        synchronized(appletLock) {
+            return stub.getCodeBase();
+        }
+    }
+
+    public AccessibleContext getAccessibleContext() {
+        synchronized(appletLock) {
+            if (accessibleContext == null) {
+                accessibleContext = new AccessibleApplet();
+            }
+            return accessibleContext;
+        }
+    }
+
+    public AppletContext getAppletContext() {
+        synchronized(appletLock) {
+            return stub.getAppletContext();
+        }
+    }
+
+    public String getAppletInfo() {
+        // return null by specefication
+        return null;
     }
 
-    public String getParameter(String s) {
+    public AudioClip getAudioClip(URL url, String name) {
+        return getAppletContext().getAudioClip(appendURL(url, name));
+    }
+
+    public AudioClip getAudioClip(URL url) {
+        return getAppletContext().getAudioClip(url);
+    }
+
+    public URL getDocumentBase() {
+        synchronized(appletLock) {
+            return stub.getDocumentBase();
+        }
+    }
+
+    public Image getImage(URL url) {
+        return Toolkit.getDefaultToolkit().getImage(url);
+    }
+
+    public Image getImage(URL url, String name) {
+        return getAppletContext().getImage(appendURL(url, name));
+    }
+
+    public Locale getLocale() {
+        return super.getLocale();
+    }
+
+    public String getParameter(String name) {
+        synchronized(appletLock) {
+            return stub.getParameter(name);
+        }
+    }
+
+    public String[][] getParameterInfo() {
+        // return null by specefication
         return null;
     }
+
+    public boolean isActive() {
+        synchronized(appletLock) {
+            return stub.isActive();
+        }
+    }
+
+    public static final AudioClip newAudioClip(URL url) {
+        return new AudioClipImpl(url);
+    }
+
+    public void play(URL url, String name) {
+        AudioClip clip = newAudioClip(appendURL(url, name));
+        clip.play();
+    }
+
+    public void play(URL url) {
+        AudioClip clip = newAudioClip(url);
+        clip.play();
+    }
+
+    public final void setStub(AppletStub stub) {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(AWTPermissionCollection.SET_APPLET_STUB_PERMISSION);
+        }
+        synchronized(appletLock) {
+            this.stub = stub;
+        }
+    }
+
+    public void showStatus(String msg) {
+        synchronized(appletLock) {
+            stub.getAppletContext().showStatus(msg);
+        }
+    }
+
+    private static URL appendURL(URL url, String name) {
+        try {
+            return new URL(url.toString() + name);
+        } catch (MalformedURLException e) {
+            return null;
+        }
+    }
+
+    private void readObject(ObjectInputStream stream) 
+            throws IOException, ClassNotFoundException {
+
+        stream.defaultReadObject();
+        FieldsAccessor accessor = new FieldsAccessor(Applet.class, this);
+        accessor.set("appletLock", new Object()); 
+    }
+
 }
+



Mime
View raw message