Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / javaunohelper / com / sun / star / comp / juhtest / SmoketestCommandEnvironment.java
blob9e9d3cef59bfb1d089528ff1b0a21089f8db7001
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 package com.sun.star.comp.juhtest;
29 import com.sun.star.lang.XMultiComponentFactory;
30 import com.sun.star.lib.uno.helper.WeakBase;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XComponentContext;
33 import com.sun.star.lang.XServiceInfo;
34 import com.sun.star.ucb.XCommandEnvironment;
36 /** This service is for use by the smoketest which checks the installation of
37 * extensions. The service provides the XCommandEnvironment interface, which
38 * is needed for adding extensions.
40 public class SmoketestCommandEnvironment extends WeakBase
41 implements XServiceInfo, XCommandEnvironment {
43 static private final String __serviceName =
44 "com.sun.star.deployment.test.SmoketestCommandEnvironment";
46 private XComponentContext m_cmpCtx;
47 private XMultiComponentFactory m_xMCF;
50 public SmoketestCommandEnvironment(XComponentContext xCompContext) {
51 try {
52 m_cmpCtx = xCompContext;
53 m_xMCF = m_cmpCtx.getServiceManager();
55 catch( Exception e ) {
56 e.printStackTrace();
60 public static String[] getServiceNames() {
61 String[] sSupportedServiceNames = { __serviceName};
62 return sSupportedServiceNames;
65 //XServiceInfo -------------------------------------------------------------
66 public String[] getSupportedServiceNames() {
67 return getServiceNames();
71 public boolean supportsService( String sServiceName ) {
72 boolean bSupported = false;
73 if (sServiceName.equals(__serviceName))
74 bSupported = true;
75 return bSupported;
78 public String getImplementationName() {
79 return SmoketestCommandEnvironment.class.getName();
82 //XCommandEnvironment ================================================
83 public com.sun.star.task.XInteractionHandler getInteractionHandler()
85 return new InteractionImpl();
88 public com.sun.star.ucb.XProgressHandler getProgressHandler()
90 return new ProgressImpl();
97 class InteractionImpl implements com.sun.star.task.XInteractionHandler
99 public void handle( com.sun.star.task.XInteractionRequest xRequest )
101 Object request = xRequest.getRequest();
103 boolean approve = true;
104 boolean abort = false;
105 // Object install_Exception =
106 // AnyConverter.toObject(
107 // com.sun.star.deployment.InstallException.class, request);
108 // if (install_Exception != null)
109 // {
110 // approve = true;
111 // }
113 com.sun.star.task.XInteractionContinuation[] conts = xRequest.getContinuations();
114 for (int i = 0; i < conts.length; i++)
116 if (approve)
118 com.sun.star.task.XInteractionApprove xApprove =
119 UnoRuntime.queryInterface(com.sun.star.task.XInteractionApprove.class, conts[i]);
120 if (xApprove != null)
121 xApprove.select();
122 //don't query again for ongoing extensions
123 approve = false;
125 else if (abort)
127 com.sun.star.task.XInteractionAbort xAbort =
128 UnoRuntime.queryInterface(com.sun.star.task.XInteractionAbort.class, conts[i]);
129 if (xAbort != null)
130 xAbort.select();
131 //don't query again for ongoing extensions
132 abort = false;
138 class ProgressImpl implements com.sun.star.ucb.XProgressHandler
140 public void push(Object status)
144 public void update(Object status)
148 public void pop()