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 ov;
23 
24 import javax.swing.JPanel;
25 
26 import com.sun.star.accessibility.XAccessibleContext;
27 
28 /** This is the base class for all object views that can be placed inside an
29     object view container.
30 
31     <p>When provided with a new accessible object the container will call
32     the Create method to create a new instance when certain conditions are
33     met.  It then calls SetObject to pass the object to the instance.
34     Finally it calls Update.</p>
35 
36     <p>The SetObject and Update methods may be called for a new object
37     without calling Create first.  In this way an existing instance is
38     recycled.</p>
39 */
40 abstract public class ObjectView
41     extends JPanel
42 {
43     /** This factory method creates a new instance of the (derived) class
44         when the given accessible object supports all necessary features.
45         In the ususal case this will be the support of a specific
46         accessibility interface.
47     */
Create( ObjectViewContainer aContainer, XAccessibleContext xContext)48     static public ObjectView Create (
49         ObjectViewContainer aContainer,
50         XAccessibleContext xContext)
51     {
52         return null;
53     }
54 
ObjectView(ObjectViewContainer aContainer)55     public ObjectView (ObjectViewContainer aContainer)
56     {
57         maContainer = aContainer;
58         mxContext = null;
59     }
60 
61     /** Call this when you want the object to be destroyed.  Release all
62         resources when called.
63     */
Destroy()64     public void Destroy ()
65     {
66     }
67 
68     /** Tell the view to display information for a new accessible object.
69         @param xObject
70             The given object may be null.  A typical behaviour in this case
71             would be to display a blank area.  But is also possible to show
72             information about the last object.
73     */
SetObject(XAccessibleContext xContext)74     public void SetObject (XAccessibleContext xContext)
75     {
76         mxContext = xContext;
77         Update ();
78     }
79 
80 
81     /** This is a request of a repaint with the current state of the current
82         object.  The current object may or may not be the same as the one
83         when Update() was called the last time.
84     */
Update()85     public void Update ()
86     {
87     }
88 
89 
90     /** Return a string that is used as a title of an enclosing frame.
91     */
GetTitle()92     abstract public String GetTitle ();
93 
94     /// Reference to the current object to display information about.
95     protected XAccessibleContext mxContext;
96 
97     protected ObjectViewContainer maContainer;
98 }
99