diff options
author | Kurt Zenker <kz@openoffice.org> | 2004-05-19 11:37:47 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2004-05-19 11:37:47 +0000 |
commit | 0f911d3bee15d13c4c6f888e5b1c3578ddafd8b2 (patch) | |
tree | cc9a0bcf94fa7bfe7448a035a2ac15cc386a5bde /wizards/com | |
parent | 422d0cb5d3d52192e72b5ff01131de77bd282283 (diff) |
INTEGRATION: CWS qwizards1 (1.1.2); FILE ADDED
2004/03/19 17:43:41 rpiterman 1.1.2.10: simplified the standard error method
2004/02/02 11:27:50 tv 1.1.2.9: formatted with autoformatter (indents now use TAB)
2004/01/22 19:45:46 bc 1.1.2.8: #111603# several changes for Querywizard
2003/12/19 17:52:49 rpiterman 1.1.2.7: Bugfix
2003/11/26 09:19:27 bc 1.1.2.6: #111603# Resource file modified
2003/10/17 13:40:41 bc 1.1.2.5: #111603# GetResArray() added
2003/10/09 14:22:27 bc 1.1.2.4: #111603# systemdialog moved from wizards.ui
2003/09/05 09:36:16 rpiterman 1.1.2.3: Added constructor and methods to use also as object, (not only as static)
2003/08/21 16:50:10 tv 1.1.2.2: fixed reorganization related bugs
2003/08/21 16:24:11 tv 1.1.2.1: recommit after reorganization
Diffstat (limited to 'wizards/com')
-rw-r--r-- | wizards/com/sun/star/wizards/common/Resource.java | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/common/Resource.java b/wizards/com/sun/star/wizards/common/Resource.java new file mode 100644 index 000000000000..8a3598cbb3ef --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Resource.java @@ -0,0 +1,133 @@ +/************************************************************************* +* +* $RCSfile: Resource.java,v $ +* +* $Revision: 1.2 $ +* +* last change: $Author: kz $ $Date: 2004-05-19 12:37:47 $ +* +* The Contents of this file are made available subject to the terms of +* either of the following licenses +* +* - GNU Lesser General Public License Version 2.1 +* - Sun Industry Standards Source License Version 1.1 +* +* Sun Microsystems Inc., October, 2000 +* +* GNU Lesser General Public License Version 2.1 +* ============================================= +* Copyright 2000 by Sun Microsystems, Inc. +* 901 San Antonio Road, Palo Alto, CA 94303, USA +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2.1, as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +* +* Sun Industry Standards Source License Version 1.1 +* ================================================= +* The contents of this file are subject to the Sun Industry Standards +* Source License Version 1.1 (the "License"); You may not use this file +* except in compliance with the License. You may obtain a copy of the +* License at http://www.openoffice.org/license.html. +* +* Software provided under this License is provided on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +* See the License for the specific provisions governing your rights and +* obligations concerning the Software. +* +* The Initial Developer of the Original Code is: Sun Microsystems, Inc. +* +* Copyright: 2000 by Sun Microsystems, Inc. +* +* All Rights Reserved. +* +* Contributor(s): _______________________________________ +* +*/ + +package com.sun.star.wizards.common; + +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.script.XInvocation; + +public class Resource { + XInvocation xInvocation; + XMultiServiceFactory xMSF; + String Unit; + String Module; + + /** Creates a new instance of Resource */ + public Resource(XMultiServiceFactory _xMSF, String _Unit, String _Module) { + this.xMSF = _xMSF; + this.Unit = _Unit; + this.Module = _Module; + this.xInvocation = initResources(); + } + + public String getResText(int nID) { + try { + short[][] PointerArray = new short[1][]; + Object[][] DummyArray = new Object[1][]; + Object[] nIDArray = new Object[1]; + nIDArray[0] = new Integer(nID); + String IDString = (String) xInvocation.invoke("getString", nIDArray, PointerArray, DummyArray); + return IDString; + } catch (Exception exception) { + exception.printStackTrace(); + throw new java.lang.IllegalArgumentException("Resource with ID not" + String.valueOf(nID) + "not found"); + } + } + + public String[] getResArray(int nID, int iCount) { + try { + String[] ResArray = new String[iCount]; + for (int i = 0; i < iCount; i++) { + ResArray[i] = getResText(nID + i); + } + return ResArray; + } catch (Exception exception) { + exception.printStackTrace(System.out); + throw new java.lang.IllegalArgumentException("Resource with ID not" + String.valueOf(nID) + "not found"); + } + } + + public XInvocation initResources() { + try { + com.sun.star.uno.XInterface xResource = (com.sun.star.uno.XInterface) xMSF.createInstance("com.sun.star.resource.VclStringResourceLoader"); + if (xResource == null) { + showCommonResourceError(xMSF); + throw new IllegalArgumentException(); + } else { + XInvocation xResInvoke = (XInvocation) com.sun.star.uno.UnoRuntime.queryInterface(XInvocation.class, xResource); + xResInvoke.setValue("FileName", Module); + return xResInvoke; + } + } catch (Exception exception) { + exception.printStackTrace(System.out); + showCommonResourceError(xMSF); + return null; + } + } + + public static void showCommonResourceError(XMultiServiceFactory xMSF) { + String ProductName = Configuration.getProductName(xMSF); + String sError = "The files required could not be found.\\nPlease start the %PRODUCTNAME Setup and choose 'Repair'."; + sError = JavaTools.replaceSubString(sError, ProductName, "%PRODUCTNAME"); + SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sError); + } + +} |