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