Update ooo320-m1
[ooovba.git] / javaunohelper / com / sun / star / comp / juhtest / SmoketestCommandEnvironment.java
blob7cffca662d08ade0e81678650fb27bea5d3ba7af
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: SmoketestCommandEnvironment.java,v $
10 * $Revision: 1.4 $
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 com.sun.star.comp.juhtest;
32 import com.sun.star.lang.XMultiComponentFactory;
33 import com.sun.star.lib.uno.helper.WeakBase;
34 import com.sun.star.uno.UnoRuntime;
35 import com.sun.star.uno.XComponentContext;
36 import com.sun.star.lang.XServiceInfo;
37 import com.sun.star.ucb.XCommandEnvironment;
39 /** This service is for use by the smoketest which checks the installation of
40 * extensions. The service provides the XCommandEnvironment interface, which
41 * is needed for adding extensions.
43 public class SmoketestCommandEnvironment extends WeakBase
44 implements XServiceInfo, XCommandEnvironment {
46 static private final String __serviceName =
47 "com.sun.star.deployment.test.SmoketestCommandEnvironment";
49 private XComponentContext m_cmpCtx;
50 private XMultiComponentFactory m_xMCF;
53 public SmoketestCommandEnvironment(XComponentContext xCompContext) {
54 try {
55 m_cmpCtx = xCompContext;
56 m_xMCF = m_cmpCtx.getServiceManager();
58 catch( Exception e ) {
59 e.printStackTrace();
63 public static String[] getServiceNames() {
64 String[] sSupportedServiceNames = { __serviceName};
65 return sSupportedServiceNames;
68 //XServiceInfo -------------------------------------------------------------
69 public String[] getSupportedServiceNames() {
70 return getServiceNames();
74 public boolean supportsService( String sServiceName ) {
75 boolean bSupported = false;
76 if (sServiceName.equals(__serviceName))
77 bSupported = true;
78 return bSupported;
81 public String getImplementationName() {
82 return SmoketestCommandEnvironment.class.getName();
85 //XCommandEnvironment ================================================
86 public com.sun.star.task.XInteractionHandler getInteractionHandler()
88 return new InteractionImpl();
91 public com.sun.star.ucb.XProgressHandler getProgressHandler()
93 return new ProgressImpl();
100 class InteractionImpl implements com.sun.star.task.XInteractionHandler
102 public void handle( com.sun.star.task.XInteractionRequest xRequest )
104 Object request = xRequest.getRequest();
106 boolean approve = true;
107 boolean abort = false;
108 // Object install_Exception =
109 // AnyConverter.toObject(
110 // com.sun.star.deployment.InstallException.class, request);
111 // if (install_Exception != null)
112 // {
113 // approve = true;
114 // }
116 com.sun.star.task.XInteractionContinuation[] conts = xRequest.getContinuations();
117 for (int i = 0; i < conts.length; i++)
119 if (approve)
121 com.sun.star.task.XInteractionApprove xApprove =
122 UnoRuntime.queryInterface(com.sun.star.task.XInteractionApprove.class, conts[i]);
123 if (xApprove != null)
124 xApprove.select();
125 //don't query again for ongoing extensions
126 approve = false;
128 else if (abort)
130 com.sun.star.task.XInteractionAbort xAbort =
131 UnoRuntime.queryInterface(com.sun.star.task.XInteractionAbort.class, conts[i]);
132 if (xAbort != null)
133 xAbort.select();
134 //don't query again for ongoing extensions
135 abort = false;
141 class ProgressImpl implements com.sun.star.ucb.XProgressHandler
143 public void push(Object status)
147 public void update(Object status)
151 public void pop()