fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / toolkit / test / accessibility / ov / ContextView.java
blob36d03694bbfed1b8a596a15acf355e0e607d2e4f
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ov;
21 import java.awt.Color;
22 import java.awt.GridBagLayout;
23 import java.awt.GridBagConstraints;
25 import java.awt.event.ActionListener;
26 import java.awt.event.ActionEvent;
28 import javax.swing.JLabel;
29 import com.sun.star.accessibility.AccessibleEventId;
30 import com.sun.star.accessibility.AccessibleEventObject;
31 import com.sun.star.accessibility.XAccessibleContext;
33 import tools.NameProvider;
35 public class ContextView
36 extends ListeningObjectView
37 implements ActionListener
39 static public ObjectView Create (
40 ObjectViewContainer aContainer,
41 XAccessibleContext xContext)
43 System.out.println ("ContextView.CreateView");
44 if (xContext != null)
45 return new ContextView (aContainer);
46 else
47 return null;
50 public ContextView (ObjectViewContainer aContainer)
52 super (aContainer);
53 maNameLabel = new JLabel ("Name: ");
54 maName = new JLabel ("");
55 maDescriptionLabel = new JLabel ("Description: ");
56 maDescription = new JLabel ("");
57 maRoleLabel = new JLabel ("Role: ");
58 maRole = new JLabel ("");
60 // Make the background of name and description white and opaque so
61 // that leading and trailing spaces become visible.
62 maName.setOpaque (true);
63 maName.setBackground (Color.WHITE);
64 maDescription.setOpaque (true);
65 maDescription.setBackground (Color.WHITE);
66 maRole.setOpaque (true);
67 maRole.setBackground (Color.WHITE);
69 GridBagLayout aLayout = new GridBagLayout();
70 setLayout (aLayout);
71 GridBagConstraints constraints = new GridBagConstraints ();
72 constraints.gridx = 0;
73 constraints.gridy = 0;
74 constraints.gridwidth = 1;
75 constraints.gridheight = 1;
76 constraints.weightx = 0;
77 constraints.weighty = 1;
78 constraints.anchor = GridBagConstraints.WEST;
79 constraints.fill = GridBagConstraints.NONE;
80 add (maNameLabel, constraints);
81 constraints.gridy = 1;
82 add (maDescriptionLabel, constraints);
83 constraints.gridy = 2;
84 add (maRoleLabel, constraints);
85 constraints.gridy = 0;
86 constraints.gridx = 1;
87 constraints.weightx = 2;
88 add (maName, constraints);
89 constraints.gridy = 1;
90 add (maDescription, constraints);
91 constraints.gridy = 2;
92 add (maRole, constraints);
95 public void Update ()
97 if (mxContext == null)
99 maName.setText ("<null object>");
100 maDescription.setText ("<null object>");
101 maRole.setText ("<null object>");
103 else
105 maName.setText (mxContext.getAccessibleName());
106 maDescription.setText (mxContext.getAccessibleDescription());
107 maRole.setText (NameProvider.getRoleName (mxContext.getAccessibleRole()));
111 public String GetTitle ()
113 return ("Context");
116 /** Listen for changes regarding displayed values.
118 public void notifyEvent (AccessibleEventObject aEvent)
120 switch (aEvent.EventId)
122 case AccessibleEventId.NAME_CHANGED :
123 case AccessibleEventId.DESCRIPTION_CHANGED :
124 Update ();
128 public void actionPerformed (ActionEvent aEvent)
133 private JLabel
134 maNameLabel,
135 maName,
136 maDescriptionLabel,
137 maDescription,
138 maRoleLabel,
139 maRole;