summaryrefslogtreecommitdiff
path: root/toolkit/test
diff options
context:
space:
mode:
authorAndre Fischer <af@openoffice.org>2003-05-19 08:42:51 +0000
committerAndre Fischer <af@openoffice.org>2003-05-19 08:42:51 +0000
commit1c55c8d8b2d067ba71006d39df513d2a39a58f98 (patch)
tree239b9eba6a66f7dfba4c702c986e6b9dc1fe2dea /toolkit/test
parentbfba3d4536327604e5548310c0424579338e504b (diff)
Added ObjectView package.
Diffstat (limited to 'toolkit/test')
-rw-r--r--toolkit/test/accessibility/ov/ContextView.java121
-rw-r--r--toolkit/test/accessibility/ov/FocusView.java115
-rw-r--r--toolkit/test/accessibility/ov/ListeningObjectView.java55
-rw-r--r--toolkit/test/accessibility/ov/ObjectView.java72
-rw-r--r--toolkit/test/accessibility/ov/ObjectViewContainer.java111
-rw-r--r--toolkit/test/accessibility/ov/SelectionView.java227
-rw-r--r--toolkit/test/accessibility/ov/StateSetView.java71
-rw-r--r--toolkit/test/accessibility/ov/TextView.java119
-rw-r--r--toolkit/test/accessibility/ov/makefile.mk52
9 files changed, 943 insertions, 0 deletions
diff --git a/toolkit/test/accessibility/ov/ContextView.java b/toolkit/test/accessibility/ov/ContextView.java
new file mode 100644
index 000000000000..977f8944cfd5
--- /dev/null
+++ b/toolkit/test/accessibility/ov/ContextView.java
@@ -0,0 +1,121 @@
+package ov;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import com.sun.star.accessibility.AccessibleEventId;
+import com.sun.star.accessibility.AccessibleEventObject;
+import com.sun.star.accessibility.XAccessibleContext;
+
+import tools.NameProvider;
+
+public class ContextView
+ extends ListeningObjectView
+ implements ActionListener
+{
+ static public ObjectView Create (XAccessibleContext xContext)
+ {
+ if (xContext != null)
+ return new ContextView();
+ else
+ return null;
+ }
+
+ public ContextView ()
+ {
+ maNameLabel = new JLabel ("Name: ");
+ maName = new JLabel ("");
+ maDescriptionLabel = new JLabel ("Description: ");
+ maDescription = new JLabel ("");
+ maRoleLabel = new JLabel ("Role: ");
+ maRole = new JLabel ("");
+
+ // Make the background of name and description white and opaque so
+ // that leading and trailing spaces become visible.
+ maName.setOpaque (true);
+ maName.setBackground (Color.WHITE);
+ maDescription.setOpaque (true);
+ maDescription.setBackground (Color.WHITE);
+ maRole.setOpaque (true);
+ maRole.setBackground (Color.WHITE);
+
+ GridBagLayout aLayout = new GridBagLayout();
+ setLayout (aLayout);
+ GridBagConstraints constraints = new GridBagConstraints ();
+ constraints.gridx = 0;
+ constraints.gridy = 0;
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ constraints.weightx = 0;
+ constraints.weighty = 1;
+ constraints.anchor = GridBagConstraints.WEST;
+ constraints.fill = GridBagConstraints.NONE;
+ add (maNameLabel, constraints);
+ constraints.gridy = 1;
+ add (maDescriptionLabel, constraints);
+ constraints.gridy = 2;
+ add (maRoleLabel, constraints);
+ constraints.gridy = 0;
+ constraints.gridx = 1;
+ constraints.weightx = 2;
+ add (maName, constraints);
+ constraints.gridy = 1;
+ add (maDescription, constraints);
+ constraints.gridy = 2;
+ add (maRole, constraints);
+ }
+
+ public void Update ()
+ {
+ if (mxContext == null)
+ {
+ maName.setText ("<null object>");
+ maDescription.setText ("<null object>");
+ maRole.setText ("<null object>");
+ }
+ else
+ {
+ maName.setText (mxContext.getAccessibleName());
+ maDescription.setText (mxContext.getAccessibleDescription());
+ maRole.setText (NameProvider.getRoleName (mxContext.getAccessibleRole()));
+ }
+ }
+
+ public String GetTitle ()
+ {
+ return ("Context");
+ }
+
+ /** Listen for changes regarding displayed values.
+ */
+ public void notifyEvent (AccessibleEventObject aEvent)
+ {
+ switch (aEvent.EventId)
+ {
+ case AccessibleEventId.NAME_CHANGED :
+ case AccessibleEventId.DESCRIPTION_CHANGED :
+ Update ();
+ }
+ }
+
+ public void actionPerformed (ActionEvent aEvent)
+ {
+ }
+
+
+ private JLabel
+ maNameLabel,
+ maName,
+ maDescriptionLabel,
+ maDescription,
+ maRoleLabel,
+ maRole;
+}
diff --git a/toolkit/test/accessibility/ov/FocusView.java b/toolkit/test/accessibility/ov/FocusView.java
new file mode 100644
index 000000000000..e05b7aae259a
--- /dev/null
+++ b/toolkit/test/accessibility/ov/FocusView.java
@@ -0,0 +1,115 @@
+package ov;
+
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+
+import com.sun.star.accessibility.AccessibleEventId;
+import com.sun.star.accessibility.AccessibleEventObject;
+import com.sun.star.accessibility.AccessibleStateType;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleStateSet;
+import com.sun.star.uno.UnoRuntime;
+
+public class FocusView
+ extends ListeningObjectView
+ implements ActionListener
+{
+ /** Create a FocusView when the given object supports the
+ XAccessibleComponent interface.
+ */
+ static public ObjectView Create (XAccessibleContext xContext)
+ {
+ XAccessibleComponent xComponent = (XAccessibleComponent)UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xContext);
+ if (xComponent != null)
+ return new FocusView();
+ else
+ return null;
+ }
+
+ public FocusView ()
+ {
+ setLayout (new GridBagLayout());
+ GridBagConstraints aConstraints = new GridBagConstraints ();
+
+ maFocused = new JLabel ();
+ aConstraints.gridy = 0;
+ aConstraints.weightx = 1;
+ aConstraints.fill = GridBagConstraints.HORIZONTAL;
+ add (maFocused, aConstraints);
+
+ maGrabFocus = new JButton ("grabFocus");
+ aConstraints.gridy = 1;
+ aConstraints.fill = GridBagConstraints.NONE;
+ aConstraints.anchor = GridBagConstraints.WEST;
+ add (maGrabFocus, aConstraints);
+
+ maGrabFocus.addActionListener (this);
+ }
+
+ /** Additionally to the context store a reference to the
+ XAccessibleComponent interface.
+ */
+ public void SetObject (XAccessibleContext xObject)
+ {
+ mxComponent = (XAccessibleComponent)UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xObject);
+ super.SetObject (xObject);
+ }
+
+ synchronized public void Destroy ()
+ {
+ super.Destroy();
+ maGrabFocus.removeActionListener (this);
+ }
+
+ synchronized public void Update ()
+ {
+ if (mxContext == null)
+ {
+ maFocused.setText ("<null object>");
+ maGrabFocus.setEnabled (false);
+ }
+ else
+ {
+ XAccessibleStateSet aStateSet = mxContext.getAccessibleStateSet();
+ if (aStateSet.contains(AccessibleStateType.FOCUSED))
+ maFocused.setText ("focused");
+ else
+ maFocused.setText ("not focused");
+ if (maGrabFocus != null)
+ maGrabFocus.setEnabled (true);
+ }
+ }
+
+ public String GetTitle ()
+ {
+ return ("Focus");
+ }
+
+ synchronized public void actionPerformed (ActionEvent aEvent)
+ {
+ if (aEvent.getActionCommand().equals("grabFocus"))
+ {
+ mxComponent.grabFocus();
+ }
+ }
+
+ public void notifyEvent (AccessibleEventObject aEvent)
+ {
+ System.out.println (aEvent);
+ if (aEvent.EventId == AccessibleEventId.STATE_CHANGED)
+ Update ();
+ }
+
+ private JLabel maFocused;
+ private JButton maGrabFocus;
+ private XAccessibleComponent mxComponent;
+}
diff --git a/toolkit/test/accessibility/ov/ListeningObjectView.java b/toolkit/test/accessibility/ov/ListeningObjectView.java
new file mode 100644
index 000000000000..c01b0e57906a
--- /dev/null
+++ b/toolkit/test/accessibility/ov/ListeningObjectView.java
@@ -0,0 +1,55 @@
+package ov;
+
+import com.sun.star.accessibility.AccessibleEventObject;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleEventBroadcaster;
+import com.sun.star.accessibility.XAccessibleEventListener;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.UnoRuntime;
+
+/** Base class for object views that regsiters as accessibility event
+ listener.
+*/
+abstract class ListeningObjectView
+ extends ObjectView
+ implements XAccessibleEventListener
+{
+ /** Add this object as event listener at the broadcasting
+ accessible object.
+ */
+ public void SetObject (XAccessibleContext xContext)
+ {
+ super.SetObject (xContext);
+ XAccessibleEventBroadcaster xBroadcaster =
+ (XAccessibleEventBroadcaster)UnoRuntime.queryInterface(
+ XAccessibleEventBroadcaster.class, xContext);
+ if (xBroadcaster != null)
+ xBroadcaster.addEventListener (this);
+ }
+
+
+ /** Remove this object as event listener from the broadcasting
+ accessible object.
+ */
+ public void Destroy ()
+ {
+ super.Destroy ();
+ XAccessibleEventBroadcaster xBroadcaster =
+ (XAccessibleEventBroadcaster)UnoRuntime.queryInterface(
+ XAccessibleEventBroadcaster.class, mxContext);
+ if (xBroadcaster != null)
+ xBroadcaster.removeEventListener (this);
+ }
+
+ /** Derived classes have to implement this method to handle incoming
+ events.
+ */
+ abstract public void notifyEvent (AccessibleEventObject aEvent);
+
+ /** The disposing event is ignored per default. If a derived class is
+ interested it can overwrite this method.
+ */
+ public void disposing (EventObject aEvent)
+ {
+ }
+}
diff --git a/toolkit/test/accessibility/ov/ObjectView.java b/toolkit/test/accessibility/ov/ObjectView.java
new file mode 100644
index 000000000000..aa09c88e31d4
--- /dev/null
+++ b/toolkit/test/accessibility/ov/ObjectView.java
@@ -0,0 +1,72 @@
+package ov;
+
+import javax.swing.JPanel;
+
+import com.sun.star.accessibility.XAccessibleContext;
+
+/** This is the base class for all object views that can be placed inside an
+ object view container.
+
+ <p>When provided with a new accessible object the container will call
+ the Create method to create a new instance when certain conditions are
+ met. It then calls SetObject to pass the object to the instance.
+ Finally it calls Update.</p>
+
+ <p>The SetObject and Update methods may be called for a new object
+ without calling Create first. In this way an existing instance is
+ recycled.</p>
+*/
+abstract public class ObjectView
+ extends JPanel
+{
+ /** This factory method creates a new instance of the (derived) class
+ when the given accessible object supports all necessary features.
+ In the ususal case this will be the support of a specific
+ accessibility interface.
+ */
+ static public ObjectView Create (XAccessibleContext xContext)
+ {
+ return null;
+ }
+
+ public ObjectView ()
+ {
+ mxContext = null;
+ }
+
+ /** Call this when you want the object to be destroyed. Release all
+ resources when called.
+ */
+ public void Destroy ()
+ {
+ }
+
+ /** Tell the view to display information for a new accessible object.
+ @param xObject
+ The given object may be null. A typical behaviour in this case
+ would be to display a blank area. But is also possible to show
+ information about the last object.
+ */
+ public void SetObject (XAccessibleContext xContext)
+ {
+ mxContext = xContext;
+ Update ();
+ }
+
+
+ /** This is a request of a repaint with the current state of the current
+ object. The current object may or may not be the same as the one
+ when Update() was called the last time.
+ */
+ public void Update ()
+ {
+ }
+
+
+ /** Return a string that is used as a title of an enclosing frame.
+ */
+ abstract public String GetTitle ();
+
+ /// Reference to the current object to display information about.
+ protected XAccessibleContext mxContext;
+}
diff --git a/toolkit/test/accessibility/ov/ObjectViewContainer.java b/toolkit/test/accessibility/ov/ObjectViewContainer.java
new file mode 100644
index 000000000000..dab84a4afbc0
--- /dev/null
+++ b/toolkit/test/accessibility/ov/ObjectViewContainer.java
@@ -0,0 +1,111 @@
+package ov;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+
+import javax.swing.JPanel;
+import javax.swing.JTree;
+import javax.swing.BorderFactory;
+import javax.swing.border.Border;
+import javax.swing.border.BevelBorder;
+
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleSelection;
+import com.sun.star.uno.UnoRuntime;
+
+public class ObjectViewContainer
+ extends JPanel
+{
+ public ObjectViewContainer ()
+ {
+ maViewBorder = BorderFactory.createBevelBorder (BevelBorder.RAISED);
+ setLayout (new GridBagLayout ());
+ }
+
+
+
+ /** Remove all existing views and create new ones according to the
+ interfaces supported by the given object.
+ */
+ public void SetObject (XAccessibleContext xContext)
+ {
+ // Call Destroy at all views to give them a chance to release their
+ // resources.
+ int n = getComponentCount();
+ for (int i=0; i<n; i++)
+ ((ObjectView)getComponent(i)).Destroy();
+ // Remove existing views.
+ removeAll ();
+
+ // Add new views.
+ Add (ContextView.Create(xContext));
+ // Add (StateSetView.Create(xContext));
+ Add (FocusView.Create(xContext));
+ Add (SelectionView.Create(xContext));
+ Add (TextView.Create(xContext));
+
+ UpdateLayoutManager ();
+
+ // Now set the object at all views.
+ n = getComponentCount();
+ for (int i=0; i<n; i++)
+ ((ObjectView)getComponent(i)).SetObject (xContext);
+
+ setPreferredSize (getLayout().preferredLayoutSize (this));
+ }
+
+
+
+ /** Add an object view and place it below all previously added views.
+ @param aView
+ This argument may be null. In this case nothing happens.
+ */
+ public void Add (ObjectView aView)
+ {
+ if (aView != null)
+ {
+ GridBagConstraints constraints = new GridBagConstraints ();
+ constraints.gridx = 0;
+ constraints.gridy = getComponentCount();
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ constraints.weightx = 1;
+ constraints.weighty = 0;
+ constraints.ipadx = 2;
+ constraints.ipady = 5;
+ constraints.insets = new Insets (5,5,5,5);
+ constraints.anchor = GridBagConstraints.NORTH;
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+
+ aView.setBorder (
+ BorderFactory.createTitledBorder (
+ maViewBorder, aView.GetTitle()));
+
+ add (aView, constraints);
+ }
+ }
+
+ /** Update the layout manager by setting the vertical weight of the
+ bottom entry to 1 and so make it strech to over the available
+ space.
+
+ */
+ private void UpdateLayoutManager ()
+ {
+ // Adapt the layout manager.
+ Component aComponent = getComponent (getComponentCount()-1);
+ GridBagLayout aLayout = (GridBagLayout)getLayout();
+ GridBagConstraints aConstraints = aLayout.getConstraints (aComponent);
+ aConstraints.weighty = 1;
+ aLayout.setConstraints (aComponent, aConstraints);
+ }
+
+ /// Observe this tree for selection changes and notify them to all
+ /// children.
+ private JTree maTree;
+ private Border maViewBorder;
+}
diff --git a/toolkit/test/accessibility/ov/SelectionView.java b/toolkit/test/accessibility/ov/SelectionView.java
new file mode 100644
index 000000000000..40d24f052e3a
--- /dev/null
+++ b/toolkit/test/accessibility/ov/SelectionView.java
@@ -0,0 +1,227 @@
+package ov;
+
+import java.util.Vector;
+
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JOptionPane;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JToggleButton;
+import javax.swing.ListSelectionModel;
+
+
+import com.sun.star.accessibility.AccessibleEventId;
+import com.sun.star.accessibility.AccessibleEventObject;
+import com.sun.star.accessibility.AccessibleStateType;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleSelection;
+import com.sun.star.accessibility.XAccessibleStateSet;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.IndexOutOfBoundsException;
+
+
+/** Display a list of children and select/deselect buttons
+*/
+class SelectionView
+ extends ListeningObjectView
+ implements ActionListener
+{
+ static public ObjectView Create (XAccessibleContext xContext)
+ {
+ XAccessibleSelection xSelection = (XAccessibleSelection)UnoRuntime.queryInterface(
+ XAccessibleSelection.class, xContext);
+ if (xSelection != null)
+ return new SelectionView();
+ else
+ return null;
+ }
+
+ public SelectionView ()
+ {
+ Layout();
+ }
+
+ public String GetTitle ()
+ {
+ return "Selection";
+ }
+
+ /** Create and arrange the widgets for this view.
+ */
+ private void Layout ()
+ {
+ setLayout (new GridBagLayout());
+
+ GridBagConstraints aConstraints = new GridBagConstraints();
+
+ // Label that shows wheter the selection is multi selectable.
+ aConstraints.gridx = 0;
+ aConstraints.gridy = 0;
+ aConstraints.anchor = GridBagConstraints.WEST;
+ maTypeLabel = new JLabel ();
+ add (maTypeLabel, aConstraints);
+
+ // the JListBox
+ maChildrenSelector = new JPanel ();
+ maChildrenSelector.setPreferredSize (new Dimension (100,100));
+ maChildrenSelector.setLayout (new BoxLayout (maChildrenSelector, BoxLayout.Y_AXIS));
+
+ aConstraints.gridx = 0;
+ aConstraints.gridwidth = 4;
+ aConstraints.gridy = 1;
+ aConstraints.fill = GridBagConstraints.HORIZONTAL;
+ add (new JScrollPane (maChildrenSelector,
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
+ aConstraints);
+
+ JButton aButton;
+ aButton = new JButton( "Select all" );
+ aButton.setActionCommand( "Select all" );
+ aButton.addActionListener( this );
+ aConstraints.gridx = 0;
+ aConstraints.gridwidth = 1;
+ aConstraints.gridy = 2;
+ aConstraints.fill = GridBagConstraints.NONE;
+ aConstraints.anchor = GridBagConstraints.WEST;
+ add (aButton, aConstraints);
+
+ aButton = new JButton( "Clear Selection" );
+ aButton.setActionCommand( "Clear Selection" );
+ aButton.addActionListener( this );
+ aConstraints.gridx = 1;
+ aConstraints.gridy = 2;
+ aConstraints.weightx = 1;
+ add (aButton, aConstraints);
+
+ setSize (getPreferredSize());
+ }
+
+
+ public void SetObject (XAccessibleContext xContext)
+ {
+ mxSelection = (XAccessibleSelection)UnoRuntime.queryInterface(
+ XAccessibleSelection.class, xContext);
+ super.SetObject (xContext);
+ }
+
+
+ public void Update ()
+ {
+ maChildrenSelector.removeAll ();
+
+ // Determine whether multi selection is possible.
+ XAccessibleStateSet aStateSet = mxContext.getAccessibleStateSet();
+ boolean bMultiSelectable = false;
+ ButtonGroup aButtonGroup = null;
+ if (aStateSet!=null && aStateSet.contains(AccessibleStateType.MULTI_SELECTABLE))
+ {
+ bMultiSelectable = true;
+ maTypeLabel.setText ("multi selectable");
+ }
+ else
+ {
+ maTypeLabel.setText ("single selectable");
+ aButtonGroup = new ButtonGroup ();
+ }
+
+ int nCount = mxContext.getAccessibleChildCount();
+ for (int i=0; i<nCount; i++)
+ {
+ try
+ {
+ XAccessible xChild = mxContext.getAccessibleChild(i);
+ XAccessibleContext xChildContext = xChild.getAccessibleContext();
+
+ String sName = i + " " + xChildContext.getAccessibleName();
+ JToggleButton aChild;
+ if (bMultiSelectable)
+ aChild = new JCheckBox (sName);
+ else
+ {
+ aChild = new JRadioButton (sName);
+ aButtonGroup.add (aChild);
+ }
+
+ XAccessibleStateSet aChildStateSet = mxContext.getAccessibleStateSet();
+ aChild.setSelected (aChildStateSet!=null
+ && aChildStateSet.contains(AccessibleStateType.SELECTED));
+
+ aChild.addActionListener (this);
+ maChildrenSelector.add (aChild);
+
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ }
+ }
+ }
+
+
+ void SelectAll()
+ {
+ mxSelection.selectAllAccessible();
+ }
+
+ void ClearSelection()
+ {
+ mxSelection.clearAccessibleSelection();
+ }
+
+
+ /** Call the function associated with the pressed button.
+ */
+ public void actionPerformed (ActionEvent aEvent)
+ {
+ String sCommand = aEvent.getActionCommand();
+
+ if (sCommand.equals ("Clear Selection"))
+ ClearSelection();
+ else if (sCommand.equals ("Select all"))
+ SelectAll();
+ else
+ {
+ // Extract the child index from the widget text.
+ String[] aWords = sCommand.split (" ");
+ int nIndex = Integer.parseInt(aWords[0]);
+ try
+ {
+ if (((JToggleButton)aEvent.getSource()).isSelected())
+ mxSelection.selectAccessibleChild (nIndex);
+ else
+ mxSelection.deselectAccessibleChild (nIndex);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ System.err.println ("caught exception while changing selection: " + e);
+ }
+ }
+ }
+
+
+ public void notifyEvent (AccessibleEventObject aEvent)
+ {
+ if (aEvent.EventId == AccessibleEventId.SELECTION_CHANGED)
+ Update ();
+ }
+
+ private JPanel maChildrenSelector;
+ private XAccessibleSelection mxSelection;
+ private JLabel maTypeLabel;
+}
diff --git a/toolkit/test/accessibility/ov/StateSetView.java b/toolkit/test/accessibility/ov/StateSetView.java
new file mode 100644
index 000000000000..70c5b3a96508
--- /dev/null
+++ b/toolkit/test/accessibility/ov/StateSetView.java
@@ -0,0 +1,71 @@
+package ov;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JPanel;
+
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.AccessibleEventObject;
+
+public class StateSetView
+ extends ListeningObjectView
+{
+ /** Create a FocusView when the given object supports the
+ XAccessibleComponent interface.
+ */
+ static public ObjectView Create (XAccessibleContext xContext)
+ {
+ if (xContext != null)
+ return new StateSetView();
+ else
+ return null;
+ }
+
+ public StateSetView ()
+ {
+ mxCanvas = new JPanel();
+ add (mxCanvas, BorderLayout.CENTER);
+ }
+
+ public void paintChildren (Graphics g)
+ {
+ synchronized (g)
+ {
+ System.out.println ("Paint");
+
+ Dimension aSize = mxCanvas.getSize();
+
+ Graphics2D g2 = (Graphics2D)g;
+ Shape aWidgetArea = g.getClip();
+
+ g2.setColor (new Color (250,240,230));
+ g2.fill (aWidgetArea);
+
+ super.paintChildren (g);
+ }
+ }
+
+ synchronized public void Update ()
+ {
+ }
+
+ public String GetTitle ()
+ {
+ return ("StateSet");
+ }
+
+ public void notifyEvent (AccessibleEventObject aEvent)
+ {
+ System.out.println (aEvent);
+ }
+
+ private JPanel mxCanvas;
+}
diff --git a/toolkit/test/accessibility/ov/TextView.java b/toolkit/test/accessibility/ov/TextView.java
new file mode 100644
index 000000000000..6a265f6046c7
--- /dev/null
+++ b/toolkit/test/accessibility/ov/TextView.java
@@ -0,0 +1,119 @@
+package ov;
+
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+
+import com.sun.star.accessibility.AccessibleEventId;
+import com.sun.star.accessibility.AccessibleEventObject;
+import com.sun.star.accessibility.AccessibleStateType;
+import com.sun.star.accessibility.XAccessibleText;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleStateSet;
+import com.sun.star.uno.UnoRuntime;
+
+public class TextView
+ extends ListeningObjectView
+{
+ /** Create a TextView when the given object supports the
+ XAccessibleText interface.
+ */
+ static public ObjectView Create (XAccessibleContext xContext)
+ {
+ XAccessibleText xText = (XAccessibleText)UnoRuntime.queryInterface(
+ XAccessibleText.class, xContext);
+ if (xText != null)
+ return new TextView();
+ else
+ return null;
+ }
+
+
+ public TextView ()
+ {
+ setLayout (new GridBagLayout());
+ GridBagConstraints aConstraints = new GridBagConstraints ();
+
+ JLabel aLabel = new JLabel ("Text:");
+ aConstraints.gridy = 0;
+ aConstraints.weightx = 1;
+ aConstraints.fill = GridBagConstraints.HORIZONTAL;
+ add (aLabel, aConstraints);
+
+ maTextLabel = new JLabel ("");
+ aConstraints.gridx = 1;
+ aConstraints.fill = GridBagConstraints.NONE;
+ aConstraints.anchor = GridBagConstraints.WEST;
+ add (maTextLabel, aConstraints);
+
+ aLabel = new JLabel ("Caret position:");
+ aConstraints.gridx = 0;
+ aConstraints.gridy = 1;
+ aConstraints.weightx = 1;
+ aConstraints.fill = GridBagConstraints.HORIZONTAL;
+ add (aLabel, aConstraints);
+
+ maCaretPositionLabel = new JLabel ("");
+ aConstraints.gridx = 1;
+ aConstraints.fill = GridBagConstraints.NONE;
+ aConstraints.anchor = GridBagConstraints.WEST;
+ add (maCaretPositionLabel, aConstraints);
+ }
+
+
+ /** Additionally to the context store a reference to the
+ XAccessibleText interface.
+ */
+ public void SetObject (XAccessibleContext xObject)
+ {
+ mxText = (XAccessibleText)UnoRuntime.queryInterface(
+ XAccessibleText.class, xObject);
+ super.SetObject (xObject);
+ }
+
+ synchronized public void Destroy ()
+ {
+ super.Destroy();
+ }
+
+ synchronized public void Update ()
+ {
+ if (mxText == null)
+ {
+ maTextLabel.setText ("<null object>");
+ maCaretPositionLabel.setText ("<null object>");
+ }
+ else
+ {
+ maTextLabel.setText (mxText.getText());
+ maCaretPositionLabel.setText (Integer.toString(mxText.getCaretPosition()));
+ }
+ }
+
+ public String GetTitle ()
+ {
+ return ("Text");
+ }
+
+ public void notifyEvent (AccessibleEventObject aEvent)
+ {
+ System.out.println (aEvent);
+ switch (aEvent.EventId)
+ {
+ case AccessibleEventId.TEXT_CHANGED :
+ case AccessibleEventId.CARET_CHANGED :
+ Update ();
+ break;
+ }
+ }
+
+ private JLabel
+ maTextLabel,
+ maCaretPositionLabel;
+ private XAccessibleText mxText;
+}
diff --git a/toolkit/test/accessibility/ov/makefile.mk b/toolkit/test/accessibility/ov/makefile.mk
new file mode 100644
index 000000000000..4dd007bb1b68
--- /dev/null
+++ b/toolkit/test/accessibility/ov/makefile.mk
@@ -0,0 +1,52 @@
+# This is the dmake version.
+
+# copied from settings.mk
+SOLARBINDIR=$(SOLARVERSION)$/$(INPATH)$/bin$(UPDMINOREXT)
+
+# Please modify the following lines to match your environment:
+# If you use the run: target at the end of the file, then adapt port number.
+PORT_NUMBER = 5678
+
+# The following variables probably don't need to be changed.
+JAVAC = javac
+JAVA = java
+# The JAR_PATH points to the jar files of your local office installation.
+JAR_PATH = $(SOLARBINDIR)$/
+
+
+# The rest of this makefile should not need to be touched.
+
+all : ov
+
+JAR_FILES = \
+ unoil.jar \
+ sandbox.jar \
+ ridl.jar \
+ jurt.jar \
+ juh.jar \
+ java_uno.jar
+
+JAVA_FILES = \
+ ov/ObjectViewContainer.java \
+ ov/ObjectView.java \
+ ov/ListeningObjectView.java \
+ ov/ContextView.java \
+ ov/FocusView.java \
+ ov/SelectionView.java \
+ ov/StateSetView.java \
+ ov/TextView.java
+
+
+JAVA_CLASSPATHS := \
+ . .. \
+ $(foreach,i,$(JAR_FILES) $(JAR_PATH)$i) \
+ $(CLASSPATH)
+
+CLASSPATH !:=$(JAVA_CLASSPATHS:t$(PATH_SEPERATOR))
+
+JFLAGS = -deprecation -classpath $(CLASSPATH)
+
+%.class : %.java
+ +$(JAVAC) $(JFLAGS) $<
+
+ov : $(JAVA_FILES:b:+".class")