Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / mod / _toolkit / MutableTreeDataModel.java
blob93347a2065ba345e13d9a14a7f54133eb5487a2d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MutableTreeDataModel.java,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package mod._toolkit;
32 import com.sun.star.awt.tree.XMutableTreeDataModel;
33 import com.sun.star.awt.tree.XMutableTreeNode;
34 import com.sun.star.lang.XMultiServiceFactory;
35 import com.sun.star.text.XTextDocument;
36 import com.sun.star.uno.UnoRuntime;
37 import com.sun.star.uno.XInterface;
39 import java.io.PrintWriter;
41 import lib.TestCase;
42 import lib.TestEnvironment;
43 import lib.TestParameters;
45 import util.WriterTools;
46 import util.utils;
49 public class MutableTreeDataModel extends TestCase {
50 private static XTextDocument xTextDoc;
51 private static XInterface oObj = null;
53 /**
54 * Creates StarOffice Writer document.
56 protected void initialize(TestParameters tParam, PrintWriter log) {
57 log.println("creating a textdocument");
58 xTextDoc = WriterTools.createTextDoc(
59 (XMultiServiceFactory) tParam.getMSF());
62 /**
63 * Disposes StarOffice Writer document.
65 protected void cleanup(TestParameters tParam, PrintWriter log) {
66 log.println(" disposing xTextDoc ");
68 util.DesktopTools.closeDoc(xTextDoc);
71 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
72 PrintWriter log) {
74 try {
75 oObj = (XInterface) ((XMultiServiceFactory) Param.getMSF()).createInstance(
76 "com.sun.star.awt.tree.MutableTreeDataModel");
77 } catch (Exception e) {
80 log.println(
81 "creating a new environment for MutableTreeDataModel object");
83 TestEnvironment tEnv = new TestEnvironment(oObj);
85 tEnv.addObjRelation("OBJNAME", "toolkit.MutableTreeDataModel");
86 log.println("ImplementationName: " + utils.getImplName(oObj));
88 tEnv.addObjRelation("XTreeDataModelListenerEvent", new XTreeDataModelListenerEvent());
90 return tEnv;
91 } // finish method getTestEnvironment
93 public class XTreeDataModelListenerEvent implements ifc.awt.tree._XTreeDataModel.XTreeDataModelListenerEvent{
95 public void fireEvent(){
97 XMutableTreeDataModel xModel = (XMutableTreeDataModel) UnoRuntime.queryInterface(XMutableTreeDataModel.class, oObj);
98 XMutableTreeNode node = xModel.createNode("EventNode", true);
99 try {
100 xModel.setRoot(node);
101 } catch (com.sun.star.lang.IllegalArgumentException ex) {
102 log.println("ERROR: could not preform event: " + ex.toString());
103 ex.printStackTrace();
108 } // finish class UnoControlListBoxModel