1 /* 2 * This file is part of the LibreOffice project. 3 * 4 * This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 * 8 * This file incorporates work covered by the following license notice: 9 * 10 * Licensed to the Apache Software Foundation (ASF) under one or more 11 * contributor license agreements. See the NOTICE file distributed 12 * with this work for additional information regarding copyright 13 * ownership. The ASF licenses this file to you under the Apache 14 * License, Version 2.0 (the "License"); you may not use this file 15 * except in compliance with the License. You may obtain a copy of 16 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 17 */ 18 19 package com.sun.star.wizards.common; 20 21 import com.sun.star.beans.PropertyState; 22 import com.sun.star.beans.PropertyValue; 23 import com.sun.star.beans.XPropertySet; 24 import com.sun.star.configuration.theDefaultProvider; 25 import com.sun.star.lang.Locale; 26 import com.sun.star.lang.XMultiServiceFactory; 27 import com.sun.star.resource.StringResourceWithLocation; 28 import com.sun.star.resource.XStringResourceWithLocation; 29 import com.sun.star.util.XMacroExpander; 30 import com.sun.star.uno.AnyConverter; 31 import com.sun.star.uno.XComponentContext; 32 import com.sun.star.uno.XInterface; 33 import com.sun.star.uno.UnoRuntime; 34 35 public final class Resource 36 { 37 private XStringResourceWithLocation m_xStrResource; 38 39 /** 40 * <p>Load the resource bundle that contains the resource {@code String} 41 * values.</p> 42 */ Resource(XMultiServiceFactory xMSF)43 public Resource(XMultiServiceFactory xMSF) { 44 XComponentContext xContext = Helper.getComponentContext(xMSF); 45 XMacroExpander xExpander = Helper.getMacroExpander(xMSF); 46 String sPath = xExpander.expandMacros("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/wizards/"); 47 Locale locale = Configuration.getUILocale(xMSF); 48 m_xStrResource = StringResourceWithLocation.create(xContext, sPath, true, locale, "resources", "", null); 49 } 50 51 /** 52 * This method returns the corresponding {@code String} given the key. 53 * 54 * @param key Key string for getting the message {@code String}. 55 * @return Message {@code String} corresponding to the key. 56 */ getResText(String key)57 public String getResText(String key) { 58 return m_xStrResource.resolveString(key); 59 } 60 showCommonResourceError(XMultiServiceFactory xMSF)61 public static void showCommonResourceError(XMultiServiceFactory xMSF) 62 { 63 String ProductName = Configuration.getProductName(xMSF); 64 String sError = "The files required could not be found.\nPlease start the %PRODUCTNAME Setup and choose 'Repair'."; 65 sError = JavaTools.replaceSubString(sError, ProductName, "%PRODUCTNAME"); 66 SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sError); 67 } 68 } 69