17c448b18SAndrew Rist /**************************************************************
27c448b18SAndrew Rist  *
37c448b18SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
47c448b18SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
57c448b18SAndrew Rist  * distributed with this work for additional information
67c448b18SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
77c448b18SAndrew Rist  * to you under the Apache License, Version 2.0 (the
87c448b18SAndrew Rist  * "License"); you may not use this file except in compliance
97c448b18SAndrew Rist  * with the License.  You may obtain a copy of the License at
107c448b18SAndrew Rist  *
117c448b18SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
127c448b18SAndrew Rist  *
137c448b18SAndrew Rist  * Unless required by applicable law or agreed to in writing,
147c448b18SAndrew Rist  * software distributed under the License is distributed on an
157c448b18SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
167c448b18SAndrew Rist  * KIND, either express or implied.  See the License for the
177c448b18SAndrew Rist  * specific language governing permissions and limitations
187c448b18SAndrew Rist  * under the License.
197c448b18SAndrew Rist  *
207c448b18SAndrew Rist  *************************************************************/
217c448b18SAndrew Rist 
227c448b18SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package com.sun.star.comp.test.deployment.active_java;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.awt.MessageBoxButtons;
27*61161268SAriel Constenla-Haile import com.sun.star.awt.MessageBoxType;
28cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
29cdf0e10cSrcweir import com.sun.star.awt.XMessageBox;
30cdf0e10cSrcweir import com.sun.star.awt.XMessageBoxFactory;
31cdf0e10cSrcweir import com.sun.star.awt.XWindowPeer;
32cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
33cdf0e10cSrcweir import com.sun.star.frame.DispatchDescriptor;
34cdf0e10cSrcweir import com.sun.star.frame.XDesktop;
35cdf0e10cSrcweir import com.sun.star.frame.XDispatch;
36cdf0e10cSrcweir import com.sun.star.frame.XStatusListener;
37cdf0e10cSrcweir import com.sun.star.lang.WrappedTargetRuntimeException;
38cdf0e10cSrcweir import com.sun.star.lang.XComponent;
39cdf0e10cSrcweir import com.sun.star.lang.XMultiComponentFactory;
40cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo;
41cdf0e10cSrcweir import com.sun.star.lib.uno.helper.WeakBase;
42cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
43cdf0e10cSrcweir import com.sun.star.uno.XComponentContext;
44cdf0e10cSrcweir import com.sun.star.util.URL;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir public final class Dispatch extends WeakBase implements XServiceInfo, XDispatch
47cdf0e10cSrcweir {
Dispatch(XComponentContext context)48cdf0e10cSrcweir     public Dispatch(XComponentContext context) {
49cdf0e10cSrcweir         this.context = context;
50cdf0e10cSrcweir     }
51cdf0e10cSrcweir 
getImplementationName()52cdf0e10cSrcweir     public String getImplementationName() { return implementationName; }
53cdf0e10cSrcweir 
supportsService(String ServiceName)54cdf0e10cSrcweir     public boolean supportsService(String ServiceName) {
55cdf0e10cSrcweir         return false; //TODO
56cdf0e10cSrcweir     }
57cdf0e10cSrcweir 
getSupportedServiceNames()58cdf0e10cSrcweir     public String[] getSupportedServiceNames() {
59cdf0e10cSrcweir         return serviceNames;
60cdf0e10cSrcweir     }
61cdf0e10cSrcweir 
dispatch(URL URL, PropertyValue[] Arguments)62cdf0e10cSrcweir     public void dispatch(URL URL, PropertyValue[] Arguments) {
63cdf0e10cSrcweir         try {
64cdf0e10cSrcweir             XMultiComponentFactory smgr = UnoRuntime.queryInterface(
65cdf0e10cSrcweir                 XMultiComponentFactory.class, context.getServiceManager());
66cdf0e10cSrcweir             XMessageBox box = UnoRuntime.queryInterface(
67cdf0e10cSrcweir                 XMessageBoxFactory.class,
68cdf0e10cSrcweir                 smgr.createInstanceWithContext(
69cdf0e10cSrcweir                     "com.sun.star.awt.Toolkit", context)).
70cdf0e10cSrcweir                 createMessageBox(
71cdf0e10cSrcweir                     UnoRuntime.queryInterface(
72cdf0e10cSrcweir                         XWindowPeer.class,
73cdf0e10cSrcweir                         (UnoRuntime.queryInterface(
74cdf0e10cSrcweir                             XDesktop.class,
75cdf0e10cSrcweir                             smgr.createInstanceWithContext(
76cdf0e10cSrcweir                                 "com.sun.star.frame.Desktop", context)).
77cdf0e10cSrcweir                          getCurrentFrame().getComponentWindow())),
78*61161268SAriel Constenla-Haile                     MessageBoxType.INFOBOX, MessageBoxButtons.BUTTONS_OK,
79cdf0e10cSrcweir                     "active", "java");
80cdf0e10cSrcweir             box.execute();
81cdf0e10cSrcweir             UnoRuntime.queryInterface(XComponent.class, box).dispose();
82cdf0e10cSrcweir         } catch (com.sun.star.uno.RuntimeException e) {
83cdf0e10cSrcweir             throw e;
84cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception e) {
85cdf0e10cSrcweir             throw new WrappedTargetRuntimeException(
86cdf0e10cSrcweir                 "wrapped: " + e.getMessage(), this, e);
87cdf0e10cSrcweir         }
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir 
addStatusListener(XStatusListener Control, URL URL)90cdf0e10cSrcweir     public void addStatusListener(XStatusListener Control, URL URL) {}
91cdf0e10cSrcweir 
removeStatusListener(XStatusListener Control, URL URL)92cdf0e10cSrcweir     public void removeStatusListener(XStatusListener Control, URL URL) {}
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     private final XComponentContext context;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     static final String implementationName =
97cdf0e10cSrcweir         "com.sun.star.comp.test.deployment.active_java_singleton";
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     static final String[] serviceNames = new String[0];
100cdf0e10cSrcweir }
101