xref: /AOO41X/main/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/SetupDataProvider.java (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
1*9a1eeea9SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9a1eeea9SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9a1eeea9SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9a1eeea9SAndrew Rist  * distributed with this work for additional information
6*9a1eeea9SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9a1eeea9SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9a1eeea9SAndrew Rist  * "License"); you may not use this file except in compliance
9*9a1eeea9SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9a1eeea9SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9a1eeea9SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9a1eeea9SAndrew Rist  * software distributed under the License is distributed on an
15*9a1eeea9SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9a1eeea9SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9a1eeea9SAndrew Rist  * specific language governing permissions and limitations
18*9a1eeea9SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9a1eeea9SAndrew Rist  *************************************************************/
21*9a1eeea9SAndrew Rist 
22*9a1eeea9SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package org.openoffice.setup.SetupData;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import org.openoffice.setup.InstallData;
27cdf0e10cSrcweir import org.openoffice.setup.Installer.Installer;
28cdf0e10cSrcweir import org.openoffice.setup.Installer.InstallerFactory;
29cdf0e10cSrcweir import java.util.Enumeration;
30cdf0e10cSrcweir import java.util.Vector;
31cdf0e10cSrcweir import javax.swing.tree.DefaultMutableTreeNode;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /**
34cdf0e10cSrcweir  *
35cdf0e10cSrcweir  * @author Christof Pintaske
36cdf0e10cSrcweir  */
37cdf0e10cSrcweir public class SetupDataProvider {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     static private PackageDescription packageData;
40cdf0e10cSrcweir     static private ProductDescription productData;
41cdf0e10cSrcweir 
SetupDataProvider()42cdf0e10cSrcweir     private SetupDataProvider() {
43cdf0e10cSrcweir     }
44cdf0e10cSrcweir 
getPackageDescription()45cdf0e10cSrcweir     public static PackageDescription getPackageDescription() {
46cdf0e10cSrcweir         return packageData;
47cdf0e10cSrcweir     }
48cdf0e10cSrcweir 
getProductDescription()49cdf0e10cSrcweir     public static ProductDescription getProductDescription() {
50cdf0e10cSrcweir         return productData;
51cdf0e10cSrcweir     }
52cdf0e10cSrcweir 
replaceMacros(String s)53cdf0e10cSrcweir     public static String replaceMacros(String s) {
54cdf0e10cSrcweir         return productData.replaceMacros(s);
55cdf0e10cSrcweir     }
56cdf0e10cSrcweir 
getString(String key)57cdf0e10cSrcweir     public static String getString(String key) {
58cdf0e10cSrcweir         return productData.get(key);
59cdf0e10cSrcweir     }
60cdf0e10cSrcweir 
setNewMacro(String key, String value)61cdf0e10cSrcweir     public static void setNewMacro(String key, String value) {
62cdf0e10cSrcweir         productData.setNewMacro(key, value);
63cdf0e10cSrcweir     }
64cdf0e10cSrcweir 
dumpMacros()65cdf0e10cSrcweir     public static void dumpMacros() {
66cdf0e10cSrcweir         productData.dumpMacros();
67cdf0e10cSrcweir     }
68cdf0e10cSrcweir 
createTree(PackageDescription data, InstallData installData)69cdf0e10cSrcweir     private static DefaultMutableTreeNode createTree(PackageDescription data, InstallData installData) {
70cdf0e10cSrcweir         DefaultMutableTreeNode node = new DefaultMutableTreeNode();
71cdf0e10cSrcweir 
72cdf0e10cSrcweir         node.setUserObject(new DisplayPackageDescription(data));
73cdf0e10cSrcweir 
74cdf0e10cSrcweir         for (Enumeration e = data.children(); e.hasMoreElements(); ) {
75cdf0e10cSrcweir             PackageDescription child = (PackageDescription) e.nextElement();
76cdf0e10cSrcweir 
77cdf0e10cSrcweir             // Do not display modules with "showinuserinstall" set to false in xpd file
78cdf0e10cSrcweir             // if this is a user installation.
79cdf0e10cSrcweir             if (( installData.isUserInstallation() ) && ( ! child.showInUserInstall() )) {
80cdf0e10cSrcweir                 child.setIsHidden(true);
81cdf0e10cSrcweir                 child.setSelectionState(PackageDescription.IGNORE);
82cdf0e10cSrcweir             }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir             // Only add modules, if they have not display type="hidden" in xpd file
85cdf0e10cSrcweir             if (!child.isHidden()) {
86cdf0e10cSrcweir                 node.add(createTree(child, installData));
87cdf0e10cSrcweir             }
88cdf0e10cSrcweir         }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         return node;
91cdf0e10cSrcweir     }
92cdf0e10cSrcweir 
createTree()93cdf0e10cSrcweir     public static DefaultMutableTreeNode createTree() {
94cdf0e10cSrcweir         InstallData installData = InstallData.getInstance();
95cdf0e10cSrcweir         return createTree(getPackageDescription(), installData);
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     static {
99cdf0e10cSrcweir         XMLPackageDescription rawData = new XMLPackageDescription();
rawData.read()100cdf0e10cSrcweir         rawData.read();
101cdf0e10cSrcweir         // rawData.dump();
102cdf0e10cSrcweir         packageData = new PackageDescription(rawData);
103cdf0e10cSrcweir         productData = new ProductDescription(rawData);
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir }
106