Kaydet (Commit) 16914553 authored tarafından Lei De Bin's avatar Lei De Bin

#119998# copy the VCLAuto from Symphony code base to AOO trunk.

More info, check here
http://wiki.services.openoffice.org/wiki/QA/vclauto
http://wiki.services.openoffice.org/wiki/Test_Refactor
Copy the testgui/source/org/openoffice/test/vcl to test/testcommon/source/org/openoffice/test/vcl
üst cc4a2b8e
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import org.openoffice.test.vcl.client.SmartId;
/**
*
* The class is used to read an from external files to replace the id in the code.
*/
public class IDList {
private HashMap<String, String> map = new HashMap<String, String>();
private File dir = null;
public IDList(File dir) {
this.dir = dir;
load();
}
private void readFile(File file, HashMap<String, String> map) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String line = null;
while ((line = reader.readLine()) != null ) {
line = line.trim();
if (line.length() == 0 /*|| line.startsWith("//")*/)
continue;
String[] parts = line.split(" ");
if (parts.length != 2)
continue;
map.put(parts[0], parts[1]);
}
} catch (IOException e) {
// for debug
e.printStackTrace();
} finally {
if (reader != null)
try {
reader.close();
} catch (IOException e) {
// ignore
}
}
}
public void load() {
if (dir == null)
return;
map.clear();
ArrayList<File> validFiles = new ArrayList<File>();
File[] files = dir.listFiles();
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".lst")) {
validFiles.add(file);
}
}
// Sort by file name. Maybe the sorting is redundant!?
Collections.sort(validFiles, new Comparator<File>() {
public int compare(File o1, File o2) {
return o1.getName().compareTo(o2.getName());
}
});
for (File file: validFiles) {
readFile(file, map);
}
}
public SmartId getId(String id) {
String value = map.get(id);
if (value == null) {
int i = id.indexOf("_");
if (i >= 0) {
value = map.get(id.substring(++i));
}
}
if (value != null)
//The external definition overwrites the id.
id = value;
try {
//Try to convert ID to number ID for old build.
//From OO3.4 all IDs should be string.
return new SmartId(Long.parseLong(id));
} catch (NumberFormatException e) {
}
return new SmartId(id);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
import org.openoffice.test.vcl.client.VclHook;
import org.openoffice.test.vcl.client.CommandCaller.WinInfoReceiver;
/**
* Use the application to inspect vcl widgets in the openoffice.
*
*/
public class VclInspector extends JFrame implements WinInfoReceiver {
/**
*
*/
private static final long serialVersionUID = 1L;
private JTable winInfoEditor = null;
public VclInspector(){
super("VCL Inspector");
}
private void init() {
try {
UIManager.getInstalledLookAndFeels();
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e1) {
}
setSize(800, 600);
JToolBar toolBar = new JToolBar("Tools");
JButton button = new JButton("Inspect");
button.setToolTipText("Inspect VCL controls.");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
inspect();
}
});
toolBar.add(button);
add(toolBar, BorderLayout.PAGE_START);
String col[] = {"Type", "ID", "ToolTip"};
DefaultTableModel model = new DefaultTableModel(null ,col);
winInfoEditor = new JTable(model);
winInfoEditor.getColumnModel().getColumn(0).setMaxWidth(60);
winInfoEditor.getColumnModel().getColumn(1).setMaxWidth(100);
JScrollPane pane1 = new JScrollPane(winInfoEditor);
add(pane1, BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
VclHook.getCommunicationManager().stop();
System.exit(0);
};
});
}
public void open() {
init();
setVisible(true);
}
public void addWinInfo(final SmartId id, final long type, final String t) {
final String tooltip = t.replaceAll("%.*%.*:", "");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
((DefaultTableModel)winInfoEditor.getModel()).addRow(new Object[]{type, id, tooltip});
}
});
}
public void onStartReceiving() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
((DefaultTableModel)winInfoEditor.getModel()).setRowCount(0);
}
});
}
public void inspect() {
VclHook.invokeCommand(Constant.RC_DisplayHid, new Object[]{Boolean.TRUE});
}
public static void main(String[] args) {
VclInspector inspector = new VclInspector();
VclHook.getCommandCaller().setWinInfoReceiver(inspector);
inspector.open();
}
public void onFinishReceiving() {
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.client;
/**
* Exception that occurs when socket communication has a problem.
*
*/
public class CommunicationException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
public CommunicationException() {
super();
}
public CommunicationException(String message, Throwable cause) {
super(message, cause);
}
public CommunicationException(String message) {
super(message);
}
public CommunicationException(Throwable cause) {
super(cause);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.client;
/**
* Callback when data package is arriving.
*
*/
public interface CommunicationListener {
public void start();
public void received(int headerType, byte[] header, byte[] data);
public void stop();
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.client;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Manage the communication with the automation server.
* It's used to establish the connection, send and receive data package.
* Data package format:
*
* | [Force Multi Channel (0xFFFFFFFF)] | Data Length (32 bits) | Check Byte (8 bits) | Header Length (16 bits) | Header Data | Body Data |
*
* To handle the received data, add a communication listener to the manager.
* The listner will be called back when data package arrives.
*
*/
public class CommunicationManager implements Runnable, Constant{
private static Logger logger = Logger.getLogger("CommunicationManager");
private final static int DEFAULT_PORT = 12479;
private String host = "localhost";
private int port = DEFAULT_PORT;
private Socket socket = null;
private int reconnectInterval = 4000;
private int reconnectCount = 3;
private List<CommunicationListener> listeners = new Vector<CommunicationListener>();
/**
* Create a communication manager with the default host and port.
* The default host is local and the default port is 12479.
*
*/
public CommunicationManager() {
try {
String portValue = System.getProperty("openoffice.automation.port");
if (portValue != null)
port = Integer.parseInt(portValue);
} catch (NumberFormatException e) {
// use default
}
}
/**
* Create a communication manager with the given host and port
* @param host
* @param port
*/
public CommunicationManager(String host, int port) {
this.host = host;
this.port = port;
}
/**
* Get the max count retrying to connect the server
* @return
*/
public int getReconnectCount() {
return reconnectCount;
}
/**
* Set the max count retrying to connect the server
* @param reconnectCount
*/
public void setReconnectCount(int reconnectCount) {
this.reconnectCount = reconnectCount;
}
/**
* Get the interval between retrying to connect the server
* @return
*/
public int getReconnectInterval() {
return reconnectInterval;
}
/**
* Set the interval between retrying to connect the server
* @param reconnectInterval
*/
public void setReconnectInterval(int reconnectInterval) {
this.reconnectInterval = reconnectInterval;
}
/**
* Send a data package to server
* @param headerType the package header type
* @param header the data in the header
* @param data the data in the body
*/
public synchronized void sendPackage(int headerType, byte[] header, byte[] data) throws CommunicationException {
if (socket == null)
start();
try {
if (header == null)
header = new byte[0];
if (data == null)
data = new byte[0];
DataOutputStream os = new DataOutputStream(socket.getOutputStream());
int len = 1 + 2 + 2 + header.length + data.length;
// Total len
os.writeInt(len);
// Check byte
os.writeByte(calcCheckByte(len));
// Header len
os.writeChar(2 + header.length);
// Header
os.writeChar(headerType);
os.write(header);
// Data
os.write(data);
os.flush();
} catch (IOException e) {
stop();
throw new CommunicationException("Failed to send data to automation server!", e);
}
}
/**
* Start a new thread to read the data sent by sever
*/
public void run() {
try {
while (socket != null) {
DataInputStream is = new DataInputStream(socket.getInputStream());
int len = is.readInt();
if (len == 0xFFFFFFFF)
len = is.readInt();
byte checkByte = is.readByte();
if (calcCheckByte(len) != checkByte)
throw new CommunicationException("Bad data package. Wrong check byte.");
int headerLen = is.readUnsignedShort();
int headerType = is.readUnsignedShort();
byte[] header = new byte[headerLen - 2];
is.readFully(header);
byte[] data = new byte[len - headerLen - 3];
is.readFully(data);
for (int i = 0; i < listeners.size(); i++)
((CommunicationListener) listeners.get(i)).received(headerType, header, data);
}
} catch (Exception e) {
logger.log(Level.FINEST, "Failed to receive data!", e);
stop();
}
}
/**
* Add a communication listener
* @param listener
*/
public void addListener(CommunicationListener listener) {
if (listener != null && !listeners.contains(listener))
listeners.add(listener);
}
/**
* Stop the communication manager.
*
*/
public synchronized void stop() {
if (socket == null)
return;
try {
socket.close();
} catch (IOException e) {
//ignore
}
socket = null;
logger.log(Level.CONFIG, "Stop Communication Manager");
for (int i = 0; i < listeners.size(); i++)
((CommunicationListener) listeners.get(i)).stop();
}
public synchronized boolean isConnected() {
return socket != null;
}
public synchronized void connect() throws IOException {
if (socket != null)
return;
try{
socket = new Socket();
socket.setTcpNoDelay(true);
socket.setSoTimeout(240 * 1000); // if in 4 minutes we get nothing from server, an exception will thrown.
socket.connect(new InetSocketAddress(host, port));
Thread thread = new Thread(this);
thread.setDaemon(true);
thread.start();
} catch (IOException e){
socket = null;
throw e;
}
}
/**
* Start the communication manager.
*
*/
public synchronized void start() {
logger.log(Level.CONFIG, "Start Communication Manager");
//connect and retry if fails
for (int i = 0; i < reconnectCount; i++) {
try {
connect();
return;
} catch (IOException e) {
logger.log(Level.FINEST, "Failed to connect! Tried " + i, e);
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
//ignore
}
}
throw new CommunicationException("Failed to connect automation server!");
}
private static byte calcCheckByte(int i) {
int nRes = 0;
int[] bytes = new int[4];
bytes[0] = (i >>> 24) & 0x00FF;
bytes[1] = (i >>> 16) & 0x00FF;
bytes[2] = (i >>> 8) & 0x00FF;
bytes[3] = (i >>> 0) & 0x00FF;
nRes += bytes[0] ^ 0xf0;
nRes += bytes[1] ^ 0x0f;
nRes += bytes[2] ^ 0xf0;
nRes += bytes[3] ^ 0x0f;
nRes ^= (nRes >>> 8);
return (byte) nRes;
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.client;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* The class is used to handle handshake package
*
*/
public class Handshaker implements CommunicationListener, Constant {
private static Logger logger = Logger.getLogger("com.ibm.vclhook");
private CommunicationManager communicationManager = null;
public Handshaker(CommunicationManager communicationManager) {
this.communicationManager = communicationManager;
this.communicationManager.addListener(this);
}
public void received(int headerType, byte[] header, byte[] data) {
if (headerType == CH_Handshake) {
int handshakeType = data[1] + ((data[0] & 255) << 8);
switch (handshakeType) {
case CH_REQUEST_HandshakeAlive:
logger.log(Level.CONFIG, "Receive Handshake - CH_REQUEST_HandshakeAlive");
sendHandshake(CH_RESPONSE_HandshakeAlive);
break;
case CH_REQUEST_ShutdownLink:
logger.log(Level.CONFIG, "Receive Handshake - CH_REQUEST_ShutdownLink");
sendHandshake(CH_ShutdownLink);
break;
case CH_ShutdownLink:
logger.log(Level.CONFIG, "Receive Handshake - CH_ShutdownLink");
communicationManager.stop();
break;
case CH_SetApplication:
//String len
// int len = data[2] + ((data[3] & 255) << 8);
// String app = new String(data, 4, data.length - 4);
logger.log(Level.CONFIG, "Receive Handshake - CH_SetApplication - app");
//sendHandshake(CH_SetApplication);
break;
default:
}
}
}
public void sendHandshake(int handshakeType) {
sendHandshake(handshakeType, new byte[0]);
}
public void sendHandshake(int handshakeType, byte[] data) {
byte[] realData = new byte[data.length + 2];
realData[0] = (byte) ((handshakeType >>> 8) & 0xFF);
realData[1] = (byte) ((handshakeType >>> 0) & 0xFF);
System.arraycopy(data, 0, realData, 2, data.length);
communicationManager.sendPackage(CH_Handshake, null, realData);
}
public void start() {
}
public void stop() {
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.client;
/**
* ID of GUI controls may have two types: number or string.
* From AOO3.4, all IDs should be string.
*/
public class SmartId {
private long id = 0;
private String sid = null;
public SmartId(long id) {
super();
this.id = id;
}
public SmartId(String sid) {
super();
this.sid = sid;
}
public long getId() {
return id;
}
public String getSid() {
return sid;
}
public String toString() {
if (sid == null)
return Long.toString(id);
else
return sid;
}
public int hashCode() {
if (sid == null)
return new Long(id).hashCode();
return sid.hashCode();
}
public boolean equals (Object o) {
if (!(o instanceof SmartId))
return false;
SmartId id2 = (SmartId) o;
return id2.id == this.id && ((this.sid == null && id2.sid == null) || (this.sid != null && this.sid.equals(id2.sid)));
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.client;
import java.io.IOException;
/**
* The entry to remotely invoke the methods supported by the automation server
*
*/
public class VclHook {
private static final String DEFAULT_HOST = "localhost";
private static final int DEFAULT_PORT = 12479;
private static CommunicationManager communicationManager = null;
private static CommandCaller commandCaller = null;
private static Handshaker handshaker = null;
static {
init();
}
private static void init() {
String host = System.getProperty("AutomationServerHost", DEFAULT_HOST);
int port = DEFAULT_PORT;
try {
port = Integer.parseInt(System.getProperty("AutomationServerPort"));
} catch(NumberFormatException e) {
}
communicationManager = new CommunicationManager(host, port);
commandCaller = new CommandCaller(communicationManager);
communicationManager.addListener(commandCaller);
handshaker = new Handshaker(communicationManager);
communicationManager.addListener(handshaker);
}
public static CommandCaller getCommandCaller() {
return commandCaller;
}
public static CommunicationManager getCommunicationManager() {
return communicationManager;
}
public static boolean available() {
try {
communicationManager.connect();
} catch (IOException e) {
return false;
}
return true;
}
public static Object invokeControl(SmartId uid, int methodId, Object[] args) {
return commandCaller.callControl(uid, methodId, args);
}
public static Object invokeControl(SmartId uid, int methodId) {
return commandCaller.callControl(uid, methodId, null);
}
public static Object invokeCommand(int methodId, Object... args) {
return commandCaller.callCommand(methodId, args);
}
public static Object invokeCommand(int methodId) {
return commandCaller.callCommand(methodId, null);
}
public static void invokeUNOSlot(String url) {
commandCaller.callUNOSlot(url);
}
public static void invokeSlot(int id) {
commandCaller.callSlot(id, new Object[]{});
}
public static void invokeSlot(int id, String arg0, Object val0) {
commandCaller.callSlot(id, new Object[]{arg0, val0});
}
public static void invokeSlot(int id, String arg0, Object val0, String arg1, Object val1) {
commandCaller.callSlot(id, new Object[]{arg0, val0, arg1, val1});
}
public static void invokeSlot(int id, String arg0, Object val0, String arg1, Object val1, String arg2, Object val2) {
commandCaller.callSlot(id, new Object[]{arg0, val0, arg1, val1, arg2, val2});
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import java.util.Properties;
import org.openoffice.test.common.FileUtil;
import org.openoffice.test.common.SystemUtil;
import org.openoffice.test.vcl.Tester;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.VclHook;
public class VclApp {
String home = null;
public static final String CMD_KILL_WINDOWS = "taskkill /F /IM soffice.bin /IM soffice.exe";
public static final String CMD_KILL_LINUX = "killall -9 soffice soffice.bin";
String cmdKill = null;
String cmdStart = null;
String versionFile = null;
Properties version = null;
String port = System.getProperty("openoffice.automation.port", "12479");
public VclApp(String appHome) {
setHome(appHome);
}
public VclApp() {
this(null);
}
public void setHome(String home) {
this.home = home;
if (home == null)
home = System.getProperty("openoffice.home");
if (home == null)
home = System.getenv("OPENOFFICE_HOME");
if (home == null)
home = "unkown";
versionFile = "versionrc";
cmdKill = CMD_KILL_LINUX;
cmdStart = "cd \"" + home + "\" ; ./soffice";
if (SystemUtil.isWindows()) {
cmdKill = CMD_KILL_WINDOWS;
cmdStart = "\"" + home + "\\soffice.exe\"";
versionFile = "version.ini";
} else if (SystemUtil.isMac()) {
} else {
}
}
public String getHome() {
return home;
}
public void kill() {
SystemUtil.execScript(cmdKill, false);
}
public int start(String args) {
if (args == null)
args = "";
return SystemUtil.execScript(cmdStart + " -norestore -quickstart=no -nofirststartwizard -enableautomation -automationport=" + port + " " + args, true);
}
public void start() {
start(null);
}
/**
* Activate the document window at the given index
*
* @param i
* @return
*/
public void activateDoc(int i) {
VclHook.invokeCommand(Constant.RC_ActivateDocument,
new Object[] { i + 1 });
}
public void reset() {
VclHook.invokeCommand(Constant.RC_ResetApplication);
}
public boolean existsSysDialog() {
return (Boolean) VclHook.invokeCommand(Constant.RC_ExistsSysDialog);
}
public void closeSysDialog() {
VclHook.invokeCommand(Constant.RC_CloseSysDialog);
}
public String getClipboard() {
return (String) VclHook.invokeCommand(Constant.RC_GetClipboard);
}
public void setClipboard(String content) {
VclHook.invokeCommand(Constant.RC_SetClipboard, content);
}
public boolean exists() {
return VclHook.available();
}
/**
* Check if the control exists in a period of time
*/
public boolean exists(double iTimeout) {
return exists(iTimeout, 1);
}
/**
* Check if the control exists in a period of time
*/
public boolean exists(double iTimeout, double interval) {
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() - startTime < iTimeout * 1000) {
if (exists())
return true;
Tester.sleep(interval);
}
return exists();
}
public void waitForExistence(double iTimeout, double interval) {
if (!exists(iTimeout, interval))
throw new RuntimeException("OpenOffice is not found!");
}
/**
* Get document window count
*
* @return
*/
public int getDocCount() {
return (Integer) VclHook.invokeCommand(Constant.RC_GetDocumentCount);
}
public Properties getVersion() {
if (version == null)
version = FileUtil.loadProperties(home + "/" + versionFile);
return version;
}
public void dispatch(String url) {
VclHook.invokeUNOSlot(url);
}
private static final int CONST_WSTimeout = 701;
// private static final int CONST_WSAborted = 702; // Not used now!
// private static final int CONST_WSFinished = 703; //
public void dispatch(String url, double time) {
VclHook.invokeUNOSlot(url);
int result = (Integer) VclHook.invokeCommand(Constant.RC_WaitSlot, (int) time * 1000);
if (result == CONST_WSTimeout)
throw new RuntimeException("Timeout to execute the dispatch!");
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
*
* Button/CheckBox/RadioBox/TriStateBox
*
*/
public class VclButton extends VclControl {
/**
* Construct the control with its String id
* @param uid
*/
public VclButton(String uid) {
super(uid);
}
public VclButton(SmartId id) {
super(id);
}
/**
*
* Click the check box
*/
public void click() {
invoke(Constant.M_Click);
}
/**
* Check if the check box is tristate
*/
public boolean isTristate() {
return (Boolean)invoke(Constant.M_IsTristate);
}
/**
* Set the check box to triState status
*/
public void triState() {
invoke(Constant.M_TriState);
}
/**
* Check if the check box is checked
*/
public boolean isChecked() {
return (Boolean) invoke(Constant.M_IsChecked);
}
/**
* Set the check box to checked status
*
*/
public void check() {
invoke(Constant.M_Check);
}
/**
* Set the check box to unchecked status
*/
public void uncheck() {
invoke(Constant.M_UnCheck);
}
/**
* Set the status to checked or unchecked
* @param checked
*/
public void setChecked(boolean checked) {
if (checked)
this.check();
else
this.uncheck();
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* Proxy used to access Vcl Combo Box
*
*/
public class VclComboBox extends VclControl {
public VclComboBox(SmartId id) {
super(id);
}
/**
* Define VclComboBox with String id
*
* @param uid
*/
public VclComboBox(String uid) {
super(uid);
}
/**
* Get the item count
*/
public int getItemCount() {
return ((Long) invoke(Constant.M_GetItemCount)).intValue();
}
/**
* Get the text of the index-th item.
* @index The index starts from 0.
*/
public String getItemText(int index) {
return (String) invoke(Constant.M_GetItemText, new Object[] {index + 1});
}
/**
* Get the index of the selected item.
* @index The index starts from 0.
*/
public int getSelIndex() {
int index = ((Long) invoke(Constant.M_GetSelIndex)).intValue();
return index - 1;
}
/**
* Get the text of the selected item.
*/
public String getSelText() {
return (String) invoke(Constant.M_GetSelText);
}
/**
* Get the text in the combo box
*/
public String getText() {
// Fix: Use M_Caption to get the text. M_GetText does not work
return (invoke(Constant.M_Caption)).toString();
}
/**
* Get the text of all items
*/
public String[] getItemsText() {
int count = getItemCount();
String[] res = new String[count];
for (int i = 0; i < count; i++) {
res[i] = getItemText(i);
}
return res;
}
/**
* Select the index-th item.
* @index The index starts from 0.
*/
public void select(int index) {
invoke(Constant.M_Select, new Object[] {index + 1});
}
/**
* Select the item with the given text
*/
public void select(String text) {
invoke(Constant.M_Select, new Object[] {text});
}
/**
* Sets no selection in a list (Sometimes this corresponds to the first
* entry in the list)
*
*/
public void setNoSelection() {
invoke(Constant.M_SetNoSelection);
}
/**
* Set the text of the combo box
*/
public void setText(String text) {
invoke(Constant.M_SetText, new Object[] {text});
}
/**
* Check if the list box has the specified item
* @param str
* @return
*/
public boolean hasItem(String str) {
int len = getItemCount();
for (int i = 0; i < len; i++) {
String text = getItemText(i);
if (str.equals(text))
return true;
}
return false;
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* Proxy to access the VCL dialog
*/
public class VclDialog extends VclWindow {
/**
* Define the dialog with its string ID
* @param id
*/
public VclDialog(String uid) {
super(uid);
}
public VclDialog(SmartId id) {
super(id);
}
/**
* Closes a dialog by pressing the Cancel button.
*/
public void cancel() {
invoke(Constant.M_Cancel);
}
/**
* Closes a dialog with the Default button.
*/
public void restoreDefaults() {
invoke(Constant.M_Default);
}
/**
* Closes a dialog with the OK button.
*/
public void ok() {
invoke(Constant.M_OK);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* Proxy used to access VCL Docking window
*
*/
public class VclDockingWin extends VclWindow {
/**
* Define VCL Docking window
* @param uid the string id
*/
public VclDockingWin(String uid) {
super(uid);
}
public VclDockingWin(SmartId id) {
super(id);
}
/**
* Docks a window on one edge of the desktop.
*/
public void dock() {
if (!isDocked())
invoke(Constant.M_Dock);
}
/**
* Undocks a docking window.
*/
public void undock() {
if (isDocked())
invoke(Constant.M_Undock);
}
/**
* Returns the docking state.
* @return Returns TRUE if the window is docking, otherwise FALSE is
* returned.
*/
public boolean isDocked() {
return (Boolean) invoke(Constant.M_IsDocked);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* Proxy used to access VCL EditField/MultiLineEditField
*
*/
public class VclEditBox extends VclControl {
/**
* Construct the control with its string ID
* @param uid
*/
public VclEditBox(String uid) {
super(uid);
}
public VclEditBox(SmartId smartId) {
super(smartId);
}
/**
* Set the text of edit box
* @param str
*/
public void setText(String str) {
invoke(Constant.M_SetText, new Object[]{str});
}
/**
* Is the edit box writable?
* @return true if it is writable, false otherwise
*/
public boolean isWritable() {
return (Boolean)invoke(Constant.M_IsWritable);
}
/**
* Get the text of edit box
* @return the text of edit box
*/
public String getText(){
return (String) invoke(Constant.M_GetText);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* Proxy used to access all VCL field controls
*
*/
public class VclField extends VclEditBox{
public VclField(SmartId smartId) {
super(smartId);
}
/**
* Construct the field control with its string ID
* @param uid
*/
public VclField(String uid) {
super(uid);
}
/**
* Move one entry higher of Field
*
*/
public void more() {
invoke(Constant.M_More);
}
/**
* Move one entry lower of Field
*
*/
public void less() {
invoke(Constant.M_Less);
}
/**
* Goes to the maximum value of Field
*
*/
public void toMax() {
invoke(Constant.M_ToMax);
}
/**
* Goes to the minimum value of Field
*/
public void toMin() {
invoke(Constant.M_ToMin);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
public class VclListBox extends VclControl {
/**
* Construct the list box with its string ID
* @param uid
*/
public VclListBox(String uid) {
super(uid);
}
public VclListBox(SmartId id) {
super(id);
}
/**
* Returns the number of entries in a TreeListBox.
*
* @return Number of list box entries. Error if the return value is -1.
*/
public int getItemCount() {
return ((Long) invoke(Constant.M_GetItemCount)).intValue();
}
/**
* Get the text of the specified entry in the tree list box Notice:
* index,col starting from 0
*
* @param index
* @param col
* @return
*/
public String getItemText(int index, int col) {
return (String) invoke(Constant.M_GetItemText, new Object[] { new Integer(index + 1), new Integer(col + 1) });
}
/**
* Get the text of the specified node Notice: index starting from 0
*
* @param index
* @return
*/
public String getItemText(int index) {
return getItemText(index, 0);
}
/**
* Returns the number of selected entries in a TreeListbox(you can select
* more than one entry).
*
* @return The number of selected entries. Error is the return value is -1.
*/
public int getSelCount() {
return ((Long) invoke(Constant.M_GetSelCount)).intValue();
}
/**
* Returns the index number of the selected entry in the TreeListBox.
* Notice: index starting from 0
*
* @return The index number of selected entries. Error is the return value
* is -1.
*/
public int getSelIndex() {
return ((Long) invoke(Constant.M_GetSelIndex)).intValue() - 1;
}
/**
* Get the text of the selected item
*/
public String getSelText() {
return (String) invoke(Constant.M_GetSelText);
}
/**
* Select the specified node via its index Notice: index starting from 0
*
* @param index
*/
public void select(int index) {
invoke(Constant.M_Select, new Object[] { new Integer(index + 1) });
}
/**
* Selects the text of an entry.
*
* @param str
* the item string
*/
public void select(String text) {
if (getType() == 324) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
if (text.equals(getItemText(i))) {
select(i);
return;
}
}
throw new RuntimeException(text + " is not found in the list box");
} else {
invoke(Constant.M_Select, new Object[] { text });
}
}
/**
* Append one item to be selected after selected some items.
*
* @param i
* the index of the item
*/
public void multiSelect(int i) {
invoke(Constant.M_MultiSelect, new Object[] { new Integer(i + 1) });
}
/**
* Append one item to be selected after selected some items.
*
* @param text
* the text of the item
*/
public void multiSelect(String text) {
invoke(Constant.M_MultiSelect, new Object[] { text });
}
/**
* get all items'text.
*
*/
public String[] getItemsText() {
int count = getItemCount();
String[] res = new String[count];
for (int i = 0; i < count; i++) {
res[i] = getItemText(i);
}
return res;
}
/**
*
* @param text
* @return
*/
public int getItemIndex(String text) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
if (text.equals(getItemText(i)))
return i;
}
throw new RuntimeException(text + " is not found in the list box");
}
/**
* Check if the list box has the specified item
*
* @param str
* @return
*/
public boolean hasItem(String str) {
int len = getItemCount();
for (int i = 0; i < len; i++) {
String text = getItemText(i);
if (str.equals(text))
return true;
}
return false;
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.VclHook;
/**
* Define VCL menu on a window
*
*/
public class VclMenu {
private VclControl window = null;
/**
* Construct the popup menu
*
*/
public VclMenu() {
}
/**
* Construct the menu on the given window
*
* @param window
*/
public VclMenu(VclControl window) {
this.window = window;
}
/**
* Returns the numbers of menu items (including the menu separators)
*
* @return Number of menu items in a menu . -1 : Return value error
*
*/
public int getItemCount() {
use();
return ((Long) VclHook.invokeCommand(Constant.RC_MenuGetItemCount)).intValue();
}
/**
* Return the menu item at the n-th index
*
* @param index
* @return null when the item is separator
*/
public VclMenuItem getItem(int index) {
use();
long id = ((Long) VclHook.invokeCommand(Constant.RC_MenuGetItemId, new Object[] { new Integer(index + 1) })).intValue();
if (id == 0)
return null;
return new VclMenuItem(this, (int) id);
}
protected void use() {
if (window != null) {
window.useMenu();
}
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.common.SystemUtil;
import org.openoffice.test.vcl.Tester;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.VclHook;
/**
*
*/
public class VclMenuItem {
private int id = -1;
private String[] path = null;
private VclMenu menu = null;
/**
* Construct menu item with its ID
*
* @param id
*/
public VclMenuItem(int id) {
this.id = id;
}
/**
* Construct menu item with its path like
* "RootMenuItem->Level1Item->Level2Item".
*
* @param path
*/
public VclMenuItem(String path) {
this.path = path.split("->");
}
/**
* Vcl Menu Item on menu bar
*
* @param menu
* @param id
*/
public VclMenuItem(VclMenu menu, int id) {
this.id = id;
this.menu = menu;
}
/**
* Vcl Menu Item on menu bar
*
* @param menu
* @param path
*/
public VclMenuItem(VclMenu menu, String path) {
this.path = path.split("->");
this.menu = menu;
}
private Object invoke(int methodId) {
int id = getId();
if (id == -1)
throw new RuntimeException("Menu item '" + path[path.length - 1] + "' can be found!");
return VclHook.invokeCommand(methodId, new Object[] { id });
}
/**
*
* @return
*/
public int getId() {
VclMenu menu = new VclMenu();
if (path != null) {
int count = menu.getItemCount();
for (int i = 0; i < count; i++) {
VclMenuItem item = menu.getItem(i);
if (item == null)
continue;
String itemText = path[path.length - 1];
if (item.getTextWithoutMneumonic().contains(itemText)) {
return item.getId();
}
}
return -1;
}
return this.id;
}
/**
* Select the menu item
*
*/
public void select() {
if (menu != null)
menu.use();
for (int i = 0; i < path.length; i++) {
new VclMenuItem(path[i]).pick();
Tester.sleep(0.5);
}
}
private void pick() {
invoke(Constant.RC_MenuSelect);
}
/**
* Select the parent of the item
*
*/
public void selectParent() {
if (menu != null)
menu.use();
for (int i = 0; i < path.length - 1; i++)
new VclMenuItem(path[i]).pick();
}
/**
* Check if the menu item exists
*
* @return
*/
public boolean exists() {
return getId() != -1;
}
/**
* Check if the menu item is selected!
*
* @return
*/
public boolean isSelected() {
return ((Boolean) invoke(Constant.RC_MenuIsItemChecked)).booleanValue();
}
/**
* Check if the menu item is enabled
*
* @return
*/
public boolean isEnabled() {
return ((Boolean) invoke(Constant.RC_MenuIsItemEnabled)).booleanValue();
}
/**
* Get the menu item position
*
* @return
*/
public int getPosition() {
return ((Long) invoke(Constant.RC_MenuGetItemPos)).intValue();
}
/**
* Get the menu item text
*
* @return
*/
public String getText() {
return (String) invoke(Constant.RC_MenuGetItemText);
}
/**
* Get the command id which is UNO-Slot
*
* @return
*/
public String getCommand() {
return (String) invoke(Constant.RC_MenuGetItemCommand);
}
/**
* Get the accelerator character
*/
public int getAccelerator() {
String text = this.getText();
if (text == null)
return 0;
int index = text.indexOf("~");
return index != -1 && index + 1 < text.length() ? text.charAt(index + 1) : 0;
}
/**
* Get text without mneumonic
*/
public String getTextWithoutMneumonic() {
String text = this.getText();
return text != null ? text.replace("~", "") : text;
}
/**
* Check if the menu item is showing
*/
public boolean isShowing() {
return exists();
}
/**
* Check if the menu item has sub menu
*
* @return
*/
public boolean hasSubMenu() {
return (Boolean) invoke(Constant.RC_MenuHasSubMenu);
}
public String toString() {
return "ID:" + getId() + ", Text:" + getText() + ", Selected:" + isSelected() + ", Enabled:" + isEnabled() + ", Command:" + getCommand()
+ ", Position:" + getPosition();
}
/**
* Check if the widget exists in a period of time
*/
public boolean exists(double iTimeout) {
return exists(iTimeout, 1);
}
/**
* Check if the widget exists in a period of time
*/
public boolean exists(double iTimeout, double interval) {
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() - startTime < iTimeout * 1000) {
if (exists())
return true;
SystemUtil.sleep(interval);
}
return exists();
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
import org.openoffice.test.vcl.client.VclHookException;
/**
* VCL message box proxy.
*
*/
public class VclMessageBox extends VclControl {
private String message = null;
public VclMessageBox(SmartId id) {
super(id);
}
/**
* Construct the active message box with a given message.
* The message can be used to distinguish message boxes.
* @param msg
*/
public VclMessageBox(SmartId id, String msg) {
super(id);
this.message = msg;
}
public VclMessageBox(String id, String msg) {
super(id);
this.message = msg;
}
/**
* Get the message on the message box
* @return
*/
public String getMessage() {
return (String) invoke(Constant.M_GetText);
}
public boolean exists() {
try {
boolean exists = super.exists();
if (!exists)
return false;
if (WINDOW_MESSBOX != getType())
return false;
if (message != null) {
String msg = getMessage();
return msg.contains(message);
}
return true;
} catch (VclHookException e) {
return false;
}
}
/**
* Click the yes button on the message box
*
*/
public void yes(){
invoke(Constant.M_Yes);
}
/**
* Click the no button on the message box
*
*/
public void no(){
invoke(Constant.M_No);
}
/**
* Closes a dialog by pressing the Cancel button.
*/
public void cancel() {
invoke(Constant.M_Cancel);
}
/**
* Closes a dialog with the Close button.
*/
public void close() {
invoke(Constant.M_Close);
}
/**
* Closes a dialog with the Default button.
*/
public void doDefault() {
invoke(Constant.M_Default);
}
/**
* Presses the Help button to open the help topic for the dialog.
*
*/
public void help() {
invoke(Constant.M_Help);
}
/**
* Closes a dialog with the OK button.
*/
public void ok() {
invoke(Constant.M_OK);
}
/**
* Closes a dialog with the OK button.
*/
public void repeat() {
invoke(Constant.M_Repeat);
}
/**
* Get the check box text if it exists
*
* @return the check box text
*/
public String getCheckBoxText() {
return (String) invoke(Constant.M_GetCheckBoxText);
}
/**
* Get the status of check box on the message box
* @return
*/
public boolean isChecked() {
return (Boolean) invoke(Constant.M_IsChecked);
}
/**
* Check the check box on the message box
*
*/
public void check() {
invoke(Constant.M_Check);
}
/**
* Uncheck the check box on the message box
*
*/
public void uncheck() {
invoke(Constant.M_UnCheck);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* VCL status bar proxy
*
*/
public class VclStatusBar extends VclControl {
public VclStatusBar(SmartId id) {
super(id);
}
public VclStatusBar(String uid) {
super(uid);
}
/**
* Get the text of the item with the given ID
* @param id
* @return
*/
public String getItemTextById(int id) {
return (String) invoke(Constant.M_StatusGetText, new Object[]{id});
}
/**
* Get the text of the item at the given index
* @param i
* @return
*/
public String getItemText(int i) {
return getItemTextById(getItemId(i));
}
/**
* Get the item count
* @return
*/
public int getItemCount() {
return ((Long) invoke(Constant.M_StatusGetItemCount)).intValue();
}
/**
* Get the item ID at the given index
* @param i
* @return
*/
public int getItemId(int i) {
return ((Long) invoke(Constant.M_StatusGetItemId, new Object[]{i + 1})).intValue();
}
/**
* Check if the status box is progress box.
* @return
*/
public boolean isProgress() {
return (Boolean) invoke(Constant.M_StatusIsProgress);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* Proxy to access VCL tab control
*
*/
public class VclTabControl extends VclControl {
/**
* Construct the tab folder with its string ID
* @param uid
*/
public VclTabControl(String uid) {
super(uid);
}
public VclTabControl(SmartId id) {
super(id);
}
/**
* Get the current page
* @return
*/
public int getPage() {
return ((Long) invoke(Constant.M_GetPage)).intValue();
}
/**
* Returns the number of tab pages in the TabControl.
* <p>
*
* @return number of tab pages in the dialog. -1 : Return value error
* <p>
*/
public int getPageCount() {
return ((Long) invoke(Constant.M_GetPageCount)).intValue();
}
/**
* Returns the TabpageID of current Tab Page in the Tab dialog. This not the
* UniqueID and is only needed for the SetPageID instruction..
* <p>
*
* @return TabpageID used in SetPageID instruction; -1 : Return value error
* <p>
*/
public int getPageId() {
return ((Long) invoke(Constant.M_GetPageId)).intValue();
}
/**
* Returns the TabpageID of specified Tab page in the Tab dialog. This not
* the UniqueID and is only needed for the SetPageID instruction..
* <p>
*
* @param nTabID :
* Specified Tab Page which order from 1. eg. A tab dialog have
* two Tab pages, nTabID is 2 if you want to get the TabpageID of
* second Tab page
* @return TabpageID used in SetPageID instruction; -1 : Return value error
* <p>
*/
public int getPageId(short nTabID) {
return ((Long) invoke(Constant.M_GetPageId, new Object[] { nTabID }))
.intValue();
}
/**
* Changes to the tab page that has the TabpageID that you specify.
* <p>
*
* @param id
* TabpageID of tab page
*/
public void setPageId(int id) {
invoke(Constant.M_SetPageId, new Object[] { id });
}
/**
* Change to the tab page you specify
* <p>
*
* @param nTabResID
* The resource ID of the specified Tab page in Tab Dialog
*/
public void setPage(long nTabResID) {
invoke(Constant.M_SetPage, new Object[] { nTabResID });
}
/**
* Change to the specified tab page
* @param widget the TabPage widget (Type: 372)
* @throws Exception
*/
public void setPage(VclControl widget) {
setPage(widget.getUID().getId());
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.SmartId;
public class VclTabPage extends VclDialog {
private VclTabControl tabControl = null;
public VclTabPage(SmartId id, VclTabControl tabControl) {
super(id);
this.tabControl = tabControl;
}
public VclTabPage(String uid, VclTabControl tabControl) {
super(uid);
this.tabControl = tabControl;
}
/**
* Selects the tab page to be active.
*
*/
public void select() {
if (tabControl != null)
tabControl.setPage(this.getUID().getId());
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* Proxy to access the VCL tool box
*
* Type: WINDOW_TOOLBOX
*
*/
public class VclToolBox extends VclDockingWin {
public VclToolBox(SmartId id) {
super(id);
}
/**
* Define a vcl tool bar
* @param uid the string id
*/
public VclToolBox(String uid) {
super(uid);
}
/**
* Click the down arrow of tool bar to show the menu
*
*/
public void openMenu() {
invoke(Constant.M_OpenContextMenu);
}
/**
* Returns the count of items in the tool bar
*
* @return the count
*/
public int getItemCount() {
return ((Long) invoke(Constant.M_GetItemCount)).intValue();
}
/**
* Get the text of the index-th item
* @param index
* @return
*/
public String getItemText(int index) {
return (String) invoke(Constant.M_GetItemText2, new Object[] {index + 1});
}
/**
* Get the quick tooltip text of the index-th item
* @param index
* @return
*/
public String getItemQuickToolTipText(int index) {
return (String) invoke(Constant.M_GetItemQuickHelpText, new Object[] {index + 1});
}
/**
* Get the tooltip text of the index-th item
* @param index
* @return
*/
public String getItemToolTipText(int index) {
return (String) invoke(Constant.M_GetItemHelpText, new Object[] {index + 1});
}
/**
* Get the name of the next tool bar
* @return
*/
public String getNextToolBar() {
return (String) invoke(Constant.M_GetNextToolBox);
}
}
/************************************************************************
*
* Licensed Materials - Property of IBM.
* (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
* U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*
************************************************************************/
package org.openoffice.test.vcl.widgets;
import java.awt.Point;
import org.openoffice.test.vcl.client.Constant;
import org.openoffice.test.vcl.client.SmartId;
/**
* Proxy to access a VCL window.
*
*/
public class VclWindow extends VclControl {
/**
* Define a VCL window
* @param uid the string id
*/
public VclWindow(String uid) {
super(uid);
}
public VclWindow(SmartId id) {
super(id);
}
/**
* Get the title of the window
* @return
*/
public String getText() {
return getCaption();
}
/**
* Presses the Help button to open the help topic for the window
*
*/
public void help() {
invoke(Constant.M_Help);
}
/**
* Closes a window with the Close button.
*/
public void close() {
invoke(Constant.M_Close);
}
/**
* Move the window by percent
*
* @param x
* @param y
*/
public void move(int x, int y) {
invoke(Constant.M_Move, new Object[]{new Integer(x), new Integer(y)});
}
/**
* Move the window by pixel
* @param p
*/
public void move(Point p) {
move(p.x, p.y);
}
/**
* Returns the state of the window (maximize or minimize).
* <p>
*
* @return Returns TRUE if the window is maximized, otherwise FALSE is
* returned.
*/
public boolean isMax() {
return (Boolean)invoke(Constant.M_IsMax);
}
/**
* Maximizes a window so that the contents of the window are visible.
*/
public void maximize() {
invoke(Constant.M_Maximize);
}
/**
* Minimizes a window so that only the title bar of the window is visible
*/
public void minimize() {
invoke(Constant.M_Minimize);
}
/**
* Resize the window
* @param x
* @param y
*/
public void resize(int x, int y) {
invoke(Constant.M_Size, new Object[]{new Integer(x), new Integer(y)});
}
/**
* Restore the window
*
*/
public void restore() {
invoke(Constant.M_Restore);
}
/**
* Activate the window
*/
public void activate() {
// focus it
focus();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment