1 /* 2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.javafx.tools.ant; 27 28 import org.apache.tools.ant.types.DataType; 29 30 /** 31 * Deployment preferences of the application. 32 * 33 * Examples: 34 * <pre> 35 * <fx:preferences id="p1" shortcut="true"> 36 * </pre> 37 * Request to create desktop shortcut. 38 * 39 * <pre> 40 * <fx:preferences shortcut="false" install="true" menu="true"> 41 * </pre> 42 * Request to add reference to the start menu and mark application as installed 43 * (in particular, it will be added to Add/Remove programs). 44 * 45 * <pre> 46 * <fx:resource refid="p1"/> 47 * </pre> 48 * Same as first example - request to create shortcut. 49 * 50 * @ant.type name="preferences" category="javafx" 51 */ 52 public class Preferences extends DataType { 53 private boolean installRequested = false; 54 private Boolean shortcutRequested = null; 55 private Boolean menuRequested = null; 56 private Boolean systemWide = null; 57 private Boolean installdirChooserRequested = null; 58 private Boolean singletonRequested = null; 59 60 Boolean getSystemInstall() { 61 return systemWide; 62 } 63 64 /** 65 * For Web applications "true" is request for app to be installed, 66 * i.e. stay in the cache permanently. 67 * 68 * For native bundles "true" is request to install into system wide location. 69 * Specific bundler may ignore this preference if it is not supported. 70 * 71 * If not specified then default is 72 * - not to install for web apps (i.e. same as "false") 73 * - bundler-specific for native bundlers 74 * 75 * @ant.not-required Default is false. 76 */ 77 public void setInstall(boolean b) { 78 installRequested = b; 79 systemWide = b; 80 } 81 82 /** 83 * If true then application requests desktop shortcut to be created. 84 * 85 * @ant.not-required Default is null. 86 */ 87 public void setShortcut(Boolean b) { 88 shortcutRequested = b; 89 } 90 91 /** 92 * If true then application requests to add entry to the system Start Menu. 93 * 94 * @ant.not-required Default is null. 95 */ 96 public void setMenu(Boolean b) { 97 menuRequested = b; 98 } 99 100 /** 101 * If true then installer adds a dialog to let the user choose a directory 102 * where the product will be installed. 103 * 104 * @ant.not-required Default is null. 105 */ 106 public void setInstalldirChooser(Boolean b) { 107 installdirChooserRequested = b; 108 } 109 110 public void setSingleton(Boolean b) { 111 singletonRequested = b; 112 } 113 114 private Preferences get() { 115 if (isReference()) { 116 return (Preferences) getRefid().getReferencedObject(); 117 } 118 return this; 119 } 120 121 Boolean getMenu() { 122 return get().menuRequested; 123 } 124 125 Boolean getShortcut() { 126 return get().shortcutRequested; 127 } 128 129 boolean getInstall() { 130 return get().installRequested; 131 } 132 133 Boolean getInstalldirChooser() { 134 return get().installdirChooserRequested; 135 } 136 137 Boolean getSingleton() { 138 return get().singletonRequested; 139 } 140 }