summaryrefslogtreecommitdiff
path: root/toolkit/test/accessibility/ov/ObjectViewContainer.java
diff options
context:
space:
mode:
authorAndre Fischer <af@openoffice.org>2003-05-23 08:20:50 +0000
committerAndre Fischer <af@openoffice.org>2003-05-23 08:20:50 +0000
commite003f69e7c6a06deb9f66d2695eb52e69c93292a (patch)
tree7dea9f68f490635fdf3a80943165cbbb9a5e8829 /toolkit/test/accessibility/ov/ObjectViewContainer.java
parentb2642683044021d6b1c8c833c8d0d3393e84df64 (diff)
Changed registration of object views.
Diffstat (limited to 'toolkit/test/accessibility/ov/ObjectViewContainer.java')
-rw-r--r--toolkit/test/accessibility/ov/ObjectViewContainer.java77
1 files changed, 66 insertions, 11 deletions
diff --git a/toolkit/test/accessibility/ov/ObjectViewContainer.java b/toolkit/test/accessibility/ov/ObjectViewContainer.java
index 7bcfbabb19f3..c0bf6a86736b 100644
--- a/toolkit/test/accessibility/ov/ObjectViewContainer.java
+++ b/toolkit/test/accessibility/ov/ObjectViewContainer.java
@@ -6,6 +6,13 @@ import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
+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 javax.swing.JTree;
import javax.swing.BorderFactory;
@@ -17,13 +24,21 @@ 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 ()
{
+ maViewTemplates = new Vector ();
maViewBorder = BorderFactory.createBevelBorder (BevelBorder.RAISED);
setLayout (new GridBagLayout ());
+
+ System.out.println ("ObjectViewContainer");
+ RegisterView (ContextView.class);
+ // RegisterView (StateSetView.class);
+ RegisterView (FocusView.class);
+ RegisterView (TextView.class);
}
@@ -42,11 +57,29 @@ public class ObjectViewContainer
removeAll ();
// Add new views.
- Add (ContextView.Create(xContext));
- Add (StateSetView.Create(xContext));
- Add (FocusView.Create(xContext));
- Add (SelectionView.Create(xContext));
- Add (TextView.Create(xContext));
+ for (int i=0; i<maViewTemplates.size(); i++)
+ {
+ try
+ {
+ Class aViewClass = (Class)maViewTemplates.elementAt (i);
+ Method aCreateMethod = aViewClass.getDeclaredMethod (
+ "Create", new Class[] {
+ ObjectViewContainer.class,
+ XAccessibleContext.class});
+ if (aCreateMethod != null)
+ {
+ ObjectView aView = (ObjectView)
+ aCreateMethod.invoke (null, new Object[] {this, xContext});
+ Add (aView);
+ }
+ }
+ catch (NoSuchMethodException e)
+ {System.err.println ("Caught exception while creating view " + i + " : " + e);}
+ catch (IllegalAccessException e)
+ {System.err.println ("Caught exception while creating view " + i + " : " + e);}
+ catch (InvocationTargetException e)
+ {System.err.println ("Caught exception while creating view " + i + " : " + e);}
+ }
UpdateLayoutManager ();
@@ -59,12 +92,29 @@ public class ObjectViewContainer
}
+ /** 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)
+ {
+ System.out.println ("registering " + aObjectViewClass);
+ maViewTemplates.addElement (aObjectViewClass);
+ }
+
+ /** Replace one view class with another.
+ */
+ public void ReplaceView (Class aObjectViewClass, Class aSubstitution)
+ {
+ int nIndex = maViewTemplates.indexOf (aObjectViewClass);
+ if (nIndex >= 0)
+ maViewTemplates.setElementAt (aSubstitution, nIndex);
+ }
/** 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)
+ private void Add (ObjectView aView)
{
if (aView != null)
{
@@ -97,15 +147,20 @@ public class ObjectViewContainer
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);
+ if (getComponentCount() > 0)
+ {
+ 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;
+ /// List of view templates which are instantiated when new object is set.
+ private Vector maViewTemplates;
}