1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.openoffice.accessibility.awb.view; 23 24 import javax.swing.JPanel; 25 26 import com.sun.star.accessibility.AccessibleEventObject; 27 import com.sun.star.accessibility.XAccessibleContext; 28 29 /** This is the base class for all object views that can be placed inside an 30 object view container. 31 32 <p>When provided with a new accessible object the container will call 33 the Create method to create a new instance when certain conditions are 34 met. It then calls SetObject to pass the object to the instance. 35 Finally it calls Update.</p> 36 37 <p>The SetObject and Update methods may be called for a new object 38 without calling Create first. In this way an existing instance is 39 recycled.</p> 40 */ 41 abstract public class ObjectView 42 extends JPanel 43 { 44 /** This factory method creates a new instance of the (derived) class 45 when the given accessible object supports all necessary features. 46 In the ususal case this will be the support of a specific 47 accessibility interface. 48 */ Create( ObjectViewContainer aContainer, XAccessibleContext xContext)49 static public ObjectView Create ( 50 ObjectViewContainer aContainer, 51 XAccessibleContext xContext) 52 { 53 return null; 54 } 55 ObjectView(ObjectViewContainer aContainer)56 public ObjectView (ObjectViewContainer aContainer) 57 { 58 maContainer = aContainer; 59 mxContext = null; 60 } 61 62 /** Call this when you want the object to be destroyed. Release all 63 resources when called. 64 */ Destroy()65 public void Destroy () 66 { 67 } 68 69 /** Tell the view to display information for a new accessible object. 70 @param xObject 71 The given object may be null. A typical behaviour in this case 72 would be to display a blank area. But is also possible to show 73 information about the last object. 74 */ SetObject(XAccessibleContext xContext)75 public void SetObject (XAccessibleContext xContext) 76 { 77 mxContext = xContext; 78 Update (); 79 } 80 81 82 /** This is a request of a repaint with the current state of the current 83 object. The current object may or may not be the same as the one 84 when Update() was called the last time. 85 */ Update()86 public void Update () 87 { 88 } 89 90 91 /** Return a string that is used as a title of an enclosing frame. 92 */ GetTitle()93 abstract public String GetTitle (); 94 95 GetContainer()96 public ObjectViewContainer GetContainer () 97 { 98 return maContainer; 99 } 100 101 102 /** Implement this method if you are interested in accessible events. 103 */ notifyEvent(AccessibleEventObject aEvent)104 public void notifyEvent (AccessibleEventObject aEvent) 105 {} 106 107 /// Reference to the current object to display information about. 108 protected XAccessibleContext mxContext; 109 110 protected ObjectViewContainer maContainer; 111 } 112