1*cd519653SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*cd519653SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*cd519653SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*cd519653SAndrew Rist * distributed with this work for additional information 6*cd519653SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*cd519653SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*cd519653SAndrew Rist * "License"); you may not use this file except in compliance 9*cd519653SAndrew Rist * with the License. You may obtain a copy of the License at 10*cd519653SAndrew Rist * 11*cd519653SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*cd519653SAndrew Rist * 13*cd519653SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*cd519653SAndrew Rist * software distributed under the License is distributed on an 15*cd519653SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*cd519653SAndrew Rist * KIND, either express or implied. See the License for the 17*cd519653SAndrew Rist * specific language governing permissions and limitations 18*cd519653SAndrew Rist * under the License. 19*cd519653SAndrew Rist * 20*cd519653SAndrew Rist *************************************************************/ 21*cd519653SAndrew Rist 22*cd519653SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package org.openoffice.netbeans.modules.office.options; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import java.util.Hashtable; 27cdf0e10cSrcweir import java.util.Enumeration; 28cdf0e10cSrcweir import java.io.File; 29cdf0e10cSrcweir import java.io.IOException; 30cdf0e10cSrcweir 31cdf0e10cSrcweir import org.openide.options.SystemOption; 32cdf0e10cSrcweir import org.openide.util.HelpCtx; 33cdf0e10cSrcweir import org.openide.util.NbBundle; 34cdf0e10cSrcweir 35cdf0e10cSrcweir import org.openoffice.idesupport.SVersionRCFile; 36cdf0e10cSrcweir import org.openoffice.idesupport.OfficeInstallation; 37cdf0e10cSrcweir 38cdf0e10cSrcweir /** Options for something or other. 39cdf0e10cSrcweir * 40cdf0e10cSrcweir * @author tomaso 41cdf0e10cSrcweir */ 42cdf0e10cSrcweir public class OfficeSettings extends SystemOption { 43cdf0e10cSrcweir 44cdf0e10cSrcweir // private static final long serialVersionUID = ...; 45cdf0e10cSrcweir 46cdf0e10cSrcweir public static final String OFFICE_DIRECTORY = "OfficeDirectory"; 47cdf0e10cSrcweir public static final String WARN_BEFORE_DOC_DEPLOY = "WarnBeforeDocDeploy"; 48cdf0e10cSrcweir public static final String WARN_BEFORE_PARCEL_DELETE = "WarnBeforeParcelDelete"; 49cdf0e10cSrcweir public static final String WARN_AFTER_DIR_DEPLOY = "WarnAfterDirDeploy"; 50cdf0e10cSrcweir public static final String WARN_BEFORE_MOUNT = "WarnBeforeMount"; 51cdf0e10cSrcweir initialize()52cdf0e10cSrcweir protected void initialize() { 53cdf0e10cSrcweir super.initialize(); 54cdf0e10cSrcweir 55cdf0e10cSrcweir setWarnBeforeDocDeploy(true); 56cdf0e10cSrcweir setWarnBeforeParcelDelete(true); 57cdf0e10cSrcweir setWarnAfterDirDeploy(true); 58cdf0e10cSrcweir setWarnBeforeMount(true); 59cdf0e10cSrcweir 60cdf0e10cSrcweir if (getOfficeDirectory() == null) { 61cdf0e10cSrcweir SVersionRCFile sversion = SVersionRCFile.createInstance(); 62cdf0e10cSrcweir 63cdf0e10cSrcweir try { 64cdf0e10cSrcweir Enumeration enum = sversion.getVersions(); 65cdf0e10cSrcweir OfficeInstallation oi; 66cdf0e10cSrcweir 67cdf0e10cSrcweir while (enum.hasMoreElements()) { 68cdf0e10cSrcweir oi = (OfficeInstallation)enum.nextElement(); 69cdf0e10cSrcweir setOfficeDirectory(oi); 70cdf0e10cSrcweir return; 71cdf0e10cSrcweir } 72cdf0e10cSrcweir } 73cdf0e10cSrcweir catch (IOException ioe) { 74cdf0e10cSrcweir } 75cdf0e10cSrcweir } 76cdf0e10cSrcweir } 77cdf0e10cSrcweir displayName()78cdf0e10cSrcweir public String displayName() { 79cdf0e10cSrcweir return "Office Settings"; 80cdf0e10cSrcweir } 81cdf0e10cSrcweir getHelpCtx()82cdf0e10cSrcweir public HelpCtx getHelpCtx() { 83cdf0e10cSrcweir return HelpCtx.DEFAULT_HELP; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir getDefault()86cdf0e10cSrcweir public static OfficeSettings getDefault() { 87cdf0e10cSrcweir return (OfficeSettings)findObject(OfficeSettings.class, true); 88cdf0e10cSrcweir } 89cdf0e10cSrcweir getOfficeDirectory()90cdf0e10cSrcweir public OfficeInstallation getOfficeDirectory() { 91cdf0e10cSrcweir return (OfficeInstallation)getProperty(OFFICE_DIRECTORY); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir setOfficeDirectory(OfficeInstallation oi)94cdf0e10cSrcweir public void setOfficeDirectory(OfficeInstallation oi) { 95cdf0e10cSrcweir putProperty(OFFICE_DIRECTORY, oi, true); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir getWarnBeforeDocDeploy()98cdf0e10cSrcweir public boolean getWarnBeforeDocDeploy() { 99cdf0e10cSrcweir return ((Boolean)getProperty(WARN_BEFORE_DOC_DEPLOY)).booleanValue(); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir setWarnBeforeDocDeploy(boolean value)102cdf0e10cSrcweir public void setWarnBeforeDocDeploy(boolean value) { 103cdf0e10cSrcweir putProperty(WARN_BEFORE_DOC_DEPLOY, new Boolean(value), true); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir getWarnBeforeParcelDelete()106cdf0e10cSrcweir public boolean getWarnBeforeParcelDelete() { 107cdf0e10cSrcweir return ((Boolean)getProperty(WARN_BEFORE_PARCEL_DELETE)).booleanValue(); 108cdf0e10cSrcweir } 109cdf0e10cSrcweir setWarnBeforeParcelDelete(boolean value)110cdf0e10cSrcweir public void setWarnBeforeParcelDelete(boolean value) { 111cdf0e10cSrcweir putProperty(WARN_BEFORE_PARCEL_DELETE, new Boolean(value), true); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir getWarnAfterDirDeploy()114cdf0e10cSrcweir public boolean getWarnAfterDirDeploy() { 115cdf0e10cSrcweir return ((Boolean)getProperty(WARN_AFTER_DIR_DEPLOY)).booleanValue(); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir setWarnAfterDirDeploy(boolean value)118cdf0e10cSrcweir public void setWarnAfterDirDeploy(boolean value) { 119cdf0e10cSrcweir putProperty(WARN_AFTER_DIR_DEPLOY, new Boolean(value), true); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir getWarnBeforeMount()122cdf0e10cSrcweir public boolean getWarnBeforeMount() { 123cdf0e10cSrcweir return ((Boolean)getProperty(WARN_BEFORE_MOUNT)).booleanValue(); 124cdf0e10cSrcweir } 125cdf0e10cSrcweir setWarnBeforeMount(boolean value)126cdf0e10cSrcweir public void setWarnBeforeMount(boolean value) { 127cdf0e10cSrcweir putProperty(WARN_BEFORE_MOUNT, new Boolean(value), true); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir } 130