Commits

Anonymous committed dc322e9

accfixes3: added XAccessibleAction support to the Accessibility Workbench

  • Participants
  • Parent commits 839edb7

Comments (0)

Files changed (8)

accessibility/workben/org/openoffice/accessibility/awb/view/AccessibleActionView.java

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.accessibility.awb.view;
+
+import com.sun.star.lang.IndexOutOfBoundsException;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Dimension;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JScrollPane;
+
+import com.sun.star.accessibility.XAccessibleAction;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.uno.UnoRuntime;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JButton;
+import javax.swing.JList;
+import javax.swing.ListModel;
+import javax.swing.event.ListDataListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+
+
+/** A simple event monitor that shows all events sent to one accessible
+    object.
+*/
+class AccessibleActionView extends ObjectView implements ActionListener, ListSelectionListener
+{
+    static public ObjectView Create (
+        ObjectViewContainer i_viewContainer,
+        XAccessibleContext i_context)
+    {
+        final XAccessibleAction accessibleAction = UnoRuntime.queryInterface( XAccessibleAction.class,
+            i_context );
+        if ( accessibleAction != null )
+            return new AccessibleActionView( i_viewContainer );
+        else
+            return null;
+    }
+
+    public AccessibleActionView( ObjectViewContainer i_viewContainer )
+    {
+        super( i_viewContainer );
+        Layout();
+    }
+
+    public String GetTitle ()
+    {
+        return "Actions";
+    }
+
+    /** Create and arrange the widgets for this view.
+    */
+    private void Layout ()
+    {
+        setLayout( new GridBagLayout() );
+
+        m_actionList = new JList();
+        m_actionList.setFont (GetContainer().GetViewFont());
+
+        maScrollPane = new JScrollPane ( m_actionList,
+            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
+        maScrollPane.setPreferredSize( new Dimension( 200, 50 ) );
+
+        GridBagConstraints aConstraints = new GridBagConstraints ();
+        aConstraints.gridy = 0;
+        aConstraints.weightx = 1;
+        aConstraints.fill = GridBagConstraints.HORIZONTAL;
+        add( maScrollPane, aConstraints );
+
+        m_buttonExecute = new JButton( "execute" );
+        m_buttonExecute.setFont (GetContainer().GetViewFont());
+        aConstraints = new GridBagConstraints ();
+        aConstraints.gridy = 1;
+        aConstraints.fill = GridBagConstraints.NONE;
+        aConstraints.anchor = GridBagConstraints.WEST;
+        add( m_buttonExecute, aConstraints );
+
+        m_actionList.addListSelectionListener( this );
+        m_buttonExecute.addActionListener( this );
+    }
+
+
+    @Override
+    public void SetObject (XAccessibleContext i_object)
+    {
+        m_componentActions = UnoRuntime.queryInterface( XAccessibleAction.class, i_object );
+        super.SetObject( i_object );
+    }
+
+    @Override
+    public void Update ()
+    {
+        m_actionList.setModel( new ActionListModel() );
+        updateButton();
+    }
+
+    @Override
+    synchronized public void Destroy ()
+    {
+        super.Destroy();
+        m_buttonExecute.removeActionListener( this );
+        m_actionList.removeListSelectionListener( this );
+    }
+
+    private void updateButton()
+    {
+        final boolean hasSelection = m_actionList.getSelectedIndex() != -1;
+        m_buttonExecute.setEnabled( hasSelection );
+    }
+
+    synchronized public void valueChanged( ListSelectionEvent i_event )
+    {
+        updateButton();
+    }
+
+    synchronized public void actionPerformed( ActionEvent i_event )
+    {
+        if ( i_event.getActionCommand().equals( "execute" ) )
+        {
+            final int selectedAction = m_actionList.getSelectedIndex();
+            try
+            {
+                m_componentActions.doAccessibleAction( selectedAction );
+            }
+            catch ( IndexOutOfBoundsException ex )
+            {
+                Logger.getLogger( AccessibleActionView.class.getName() ).log( Level.SEVERE, null, ex );
+            }
+        }
+    }
+
+    private final class ActionListModel implements ListModel
+    {
+        public int getSize()
+        {
+            return m_componentActions.getAccessibleActionCount();
+        }
+
+        public Object getElementAt( int index )
+        {
+            try
+            {
+                return m_componentActions.getAccessibleActionDescription( index );
+            }
+            catch ( IndexOutOfBoundsException ex )
+            {
+                Logger.getLogger( AccessibleActionView.class.getName() ).log( Level.SEVERE, null, ex );
+            }
+            return "<error>";
+        }
+
+        public void addListDataListener( ListDataListener l )
+        {
+        }
+
+        public void removeListDataListener( ListDataListener l )
+        {
+        }
+    };
+
+    private JList m_actionList;
+    private JButton m_buttonExecute;
+    private JScrollPane maScrollPane;
+    private XAccessibleAction m_componentActions;
+}

accessibility/workben/org/openoffice/accessibility/awb/view/EventMonitorView.java

 
 package org.openoffice.accessibility.awb.view;
 
-import java.awt.BorderLayout;
 import java.awt.GridBagLayout;
 import java.awt.GridBagConstraints;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Font;
-import java.awt.Graphics;
 import javax.swing.JScrollBar;
 import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
 
-import com.sun.star.accessibility.AccessibleEventId;
 import com.sun.star.accessibility.AccessibleEventObject;
 import com.sun.star.accessibility.XAccessibleContext;
 
     }
 
 
+    @Override
     public void Update ()
     {
     }
     }
 
 
+    @Override
     public void notifyEvent (AccessibleEventObject aEvent)
     {
         maText.append ((mnLineNo++) + ". " + NameProvider.getEventName (aEvent.EventId) + " : "

accessibility/workben/org/openoffice/accessibility/awb/view/FocusView.java

 
 package org.openoffice.accessibility.awb.view;
 
-import java.awt.Font;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionListener;
         ObjectViewContainer aContainer,
         XAccessibleContext xContext)
     {
-        XAccessibleComponent xComponent = (XAccessibleComponent)UnoRuntime.queryInterface(
-                XAccessibleComponent.class, xContext);
+        XAccessibleComponent xComponent = UnoRuntime.queryInterface( XAccessibleComponent.class, xContext );
         if (xComponent != null)
             return new FocusView (aContainer);
         else
     /** Additionally to the context store a reference to the
         XAccessibleComponent interface.
     */
+    @Override
     public void SetObject (XAccessibleContext xObject)
     {
-        mxComponent = (XAccessibleComponent)UnoRuntime.queryInterface(
-                XAccessibleComponent.class, xObject);
+        mxComponent = UnoRuntime.queryInterface( XAccessibleComponent.class, xObject );
         super.SetObject (xObject);
     }
 
+    @Override
     synchronized public void Destroy ()
     {
         super.Destroy();
         maGrabFocus.removeActionListener (this);
     }
 
+    @Override
     synchronized public void Update ()
     {
         if (mxContext == null)
         }
     }
 
+    @Override
     public void notifyEvent (AccessibleEventObject aEvent)
     {
         System.out.println (aEvent);

accessibility/workben/org/openoffice/accessibility/awb/view/ObjectViewContainer.java

 import java.util.Vector;
 
 import java.lang.reflect.Method;
-import java.lang.NoSuchMethodException;
-import java.lang.IllegalAccessException;
 import java.lang.reflect.InvocationTargetException;
 
 import javax.swing.JPanel;
 
 import com.sun.star.accessibility.AccessibleEventObject;
 import com.sun.star.accessibility.XAccessibleContext;
-import com.sun.star.accessibility.XAccessibleComponent;
-import com.sun.star.accessibility.XAccessibleEventBroadcaster;
 import com.sun.star.accessibility.XAccessibleEventListener;
-import com.sun.star.accessibility.XAccessibleSelection;
 import com.sun.star.lang.EventObject;
-import com.sun.star.uno.UnoRuntime;
-
-import org.openoffice.accessibility.awb.view.ObjectView;
-
 
 
 /** This container of specialized object views displays information about
         RegisterView (ParentView.class);
         RegisterView (StateSetView.class);
         RegisterView (FocusView.class);
+        RegisterView (AccessibleActionView.class);
         RegisterView (TextView.class);
         RegisterView (EditableTextView.class);
         RegisterView (TableView.class);
     /** Add the given class to the list of classes which will be
         instantiated the next time an accessible object is set.
     */
-    public void RegisterView (Class aObjectViewClass)
+    private void RegisterView (Class aObjectViewClass)
     {
         maViewTemplates.addElement (aObjectViewClass);
     }

accessibility/workben/org/openoffice/accessibility/awb/view/SelectionView.java

 
 package org.openoffice.accessibility.awb.view;
 
-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;
         ObjectViewContainer aContainer,
         XAccessibleContext xContext)
     {
-        XAccessibleSelection xSelection = (XAccessibleSelection)UnoRuntime.queryInterface(
-                XAccessibleSelection.class, xContext);
+        XAccessibleSelection xSelection = UnoRuntime.queryInterface( XAccessibleSelection.class, xContext );
         if (xSelection != null)
             return new SelectionView(aContainer);
         else

accessibility/workben/org/openoffice/accessibility/awb/view/ServiceInterfaceView.java

 package org.openoffice.accessibility.awb.view;
 
 import java.awt.GridLayout;
-import java.awt.Color;
 import java.awt.Dimension;
-import java.awt.GridBagLayout;
-import java.awt.GridBagConstraints;
-import java.lang.Integer;
 import javax.swing.JScrollPane;
 import javax.swing.JTree;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 
-import com.sun.star.accessibility.AccessibleEventId;
-import com.sun.star.accessibility.AccessibleEventObject;
-import com.sun.star.accessibility.XAccessible;
 import com.sun.star.accessibility.XAccessibleContext;
-import com.sun.star.lang.IndexOutOfBoundsException;
 import com.sun.star.lang.XServiceInfo;
 import com.sun.star.lang.XTypeProvider;
 import com.sun.star.uno.Type;
 import com.sun.star.uno.UnoRuntime;
 
-import org.openoffice.accessibility.misc.NameProvider;
 
 
 /** Show all supported services and interfaces.

accessibility/workben/org/openoffice/accessibility/awb/view/TextView.java

 
 package org.openoffice.accessibility.awb.view;
 
-import java.awt.Color;
 import java.awt.Dimension;
-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.JComponent;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JSpinner;
 import javax.swing.JTree;
-import javax.swing.tree.TreeNode;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.MutableTreeNode;
 import com.sun.star.accessibility.AccessibleEventId;
 import com.sun.star.accessibility.AccessibleEventObject;
 import com.sun.star.accessibility.AccessibleTextType;
-import com.sun.star.accessibility.AccessibleStateType;
 import com.sun.star.accessibility.TextSegment;
 import com.sun.star.accessibility.XAccessibleText;
 import com.sun.star.accessibility.XAccessibleContext;
 import com.sun.star.accessibility.XAccessibleMultiLineText;
-import com.sun.star.accessibility.XAccessibleStateSet;
 import com.sun.star.awt.Point;
 import com.sun.star.awt.Rectangle;
 import com.sun.star.beans.PropertyValue;

accessibility/workben/org/openoffice/accessibility/awb/view/makefile.common

 	ContextView.java				\
 	EditableTextView.java			\
 	EventMonitorView.java			\
+	AccessibleActionView.java			\
 	FocusView.java					\
 	LayoutManager.java				\
 	ObjectView.java					\