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 
23 
24 package org.openoffice.accessibility.awb.view;
25 
26 import java.awt.Color;
27 import java.awt.Dimension;
28 
29 import java.awt.event.ActionListener;
30 import java.awt.event.ActionEvent;
31 
32 import javax.swing.JLabel;
33 import javax.swing.JTextField;
34 
35 import com.sun.star.accessibility.AccessibleEventId;
36 import com.sun.star.accessibility.AccessibleEventObject;
37 import com.sun.star.accessibility.XAccessibleContext;
38 
39 import org.openoffice.accessibility.misc.NameProvider;
40 
41 /** The <type>ContextView</type> class displays information accessible over
42     the <type>XAccessibleContext</type> interface.  This includes name,
43     description, and role.
44 */
45 public class ContextView
46     extends ObjectView
47     implements ActionListener
48 {
Create( ObjectViewContainer aContainer, XAccessibleContext xContext)49     static public ObjectView Create (
50         ObjectViewContainer aContainer,
51         XAccessibleContext xContext)
52     {
53         if (xContext != null)
54             return new ContextView (aContainer);
55         else
56             return null;
57     }
58 
ContextView(ObjectViewContainer aContainer)59     public ContextView (ObjectViewContainer aContainer)
60     {
61         super (aContainer);
62 
63         ViewGridLayout aLayout = new ViewGridLayout (this);
64         maNameLabel = aLayout.AddLabeledString ("Name:");
65         maDescriptionLabel = aLayout.AddLabeledString ("Description:");
66         maRoleLabel = aLayout.AddLabeledEntry ("Role:");
67     }
68 
Update()69     public void Update ()
70     {
71         if (mxContext == null)
72         {
73             maNameLabel.setText ("<null object>");
74             maDescriptionLabel.setText ("<null object>");
75             maRoleLabel.setText ("<null object>");
76         }
77         else
78         {
79             maNameLabel.setText (mxContext.getAccessibleName());
80             maDescriptionLabel.setText (mxContext.getAccessibleDescription());
81             maRoleLabel.setText (NameProvider.getRoleName (mxContext.getAccessibleRole()));
82         }
83     }
84 
GetTitle()85     public String GetTitle ()
86     {
87         return ("Context");
88     }
89 
90     /** Listen for changes regarding displayed values.
91     */
notifyEvent(AccessibleEventObject aEvent)92     public void notifyEvent (AccessibleEventObject aEvent)
93     {
94         switch (aEvent.EventId)
95         {
96             case AccessibleEventId.NAME_CHANGED :
97             case AccessibleEventId.DESCRIPTION_CHANGED :
98                 Update ();
99         }
100     }
101 
actionPerformed(ActionEvent aEvent)102     public void actionPerformed (ActionEvent aEvent)
103     {
104     }
105 
106 
107     private JLabel
108         maNameLabel,
109         maDescriptionLabel,
110         maRoleLabel;
111 }
112