4 import java
.awt
.Dimension
;
5 import java
.awt
.GridBagLayout
;
6 import java
.awt
.GridBagConstraints
;
8 import java
.awt
.event
.ActionListener
;
9 import java
.awt
.event
.ActionEvent
;
11 import javax
.swing
.JLabel
;
12 import javax
.swing
.JTextField
;
14 import com
.sun
.star
.accessibility
.AccessibleEventId
;
15 import com
.sun
.star
.accessibility
.AccessibleEventObject
;
16 import com
.sun
.star
.accessibility
.XAccessibleContext
;
18 import tools
.NameProvider
;
20 public class ContextView
21 extends ListeningObjectView
22 implements ActionListener
24 static public ObjectView
Create (
25 ObjectViewContainer aContainer
,
26 XAccessibleContext xContext
)
28 System
.out
.println ("ContextView.CreateView");
30 return new ContextView (aContainer
);
35 public ContextView (ObjectViewContainer aContainer
)
38 maNameLabel
= new JLabel ("Name: ");
39 maName
= new JLabel ("");
40 maDescriptionLabel
= new JLabel ("Description: ");
41 maDescription
= new JLabel ("");
42 maRoleLabel
= new JLabel ("Role: ");
43 maRole
= new JLabel ("");
45 // Make the background of name and description white and opaque so
46 // that leading and trailing spaces become visible.
47 maName
.setOpaque (true);
48 maName
.setBackground (Color
.WHITE
);
49 maDescription
.setOpaque (true);
50 maDescription
.setBackground (Color
.WHITE
);
51 maRole
.setOpaque (true);
52 maRole
.setBackground (Color
.WHITE
);
54 GridBagLayout aLayout
= new GridBagLayout();
56 GridBagConstraints constraints
= new GridBagConstraints ();
57 constraints
.gridx
= 0;
58 constraints
.gridy
= 0;
59 constraints
.gridwidth
= 1;
60 constraints
.gridheight
= 1;
61 constraints
.weightx
= 0;
62 constraints
.weighty
= 1;
63 constraints
.anchor
= GridBagConstraints
.WEST
;
64 constraints
.fill
= GridBagConstraints
.NONE
;
65 add (maNameLabel
, constraints
);
66 constraints
.gridy
= 1;
67 add (maDescriptionLabel
, constraints
);
68 constraints
.gridy
= 2;
69 add (maRoleLabel
, constraints
);
70 constraints
.gridy
= 0;
71 constraints
.gridx
= 1;
72 constraints
.weightx
= 2;
73 add (maName
, constraints
);
74 constraints
.gridy
= 1;
75 add (maDescription
, constraints
);
76 constraints
.gridy
= 2;
77 add (maRole
, constraints
);
82 if (mxContext
== null)
84 maName
.setText ("<null object>");
85 maDescription
.setText ("<null object>");
86 maRole
.setText ("<null object>");
90 maName
.setText (mxContext
.getAccessibleName());
91 maDescription
.setText (mxContext
.getAccessibleDescription());
92 maRole
.setText (NameProvider
.getRoleName (mxContext
.getAccessibleRole()));
96 public String
GetTitle ()
101 /** Listen for changes regarding displayed values.
103 public void notifyEvent (AccessibleEventObject aEvent
)
105 switch (aEvent
.EventId
)
107 case AccessibleEventId
.NAME_CHANGED
:
108 case AccessibleEventId
.DESCRIPTION_CHANGED
:
113 public void actionPerformed (ActionEvent aEvent
)