1 /* 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. 3 * All rights reserved. Use is subject to license terms. 4 * 5 * This file is available and licensed under the following license: 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * - Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the distribution. 16 * - Neither the name of Oracle Corporation nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 package com.oracle.javafx.scenebuilder.app.template; 33 34 import java.net.URL; 35 import java.util.HashSet; 36 import java.util.Set; 37 38 import com.oracle.javafx.scenebuilder.app.SceneBuilderApp.ApplicationControlAction; 39 40 /** 41 * 42 */ 43 public class FxmlTemplates { 44 45 public static URL getContentURL(ApplicationControlAction action) { 46 final String name = getTemplateFileName(action); 47 return FxmlTemplates.class.getResource(name); 48 } 49 50 public static String getTemplateName(ApplicationControlAction action) { 51 final String name = getTemplateFileName(action); 52 return name.substring(0, name.indexOf(".fxml")); //NOI18N 53 } 54 55 public static String getTemplateFileName(ApplicationControlAction action) { 56 String name; 57 switch (action) { 58 case NEW_ALERT_DIALOG: 59 name = "AlertDialog.fxml"; //NOI18N 60 break; 61 case NEW_ALERT_DIALOG_CSS: 62 name = "AlertDialog_css.fxml"; //NOI18N 63 break; 64 case NEW_ALERT_DIALOG_I18N: 65 name = "AlertDialog_i18n.fxml"; //NOI18N 66 break; 67 case NEW_BASIC_APPLICATION: 68 name = "BasicApplication.fxml"; //NOI18N 69 break; 70 case NEW_BASIC_APPLICATION_CSS: 71 name = "BasicApplication_css.fxml"; //NOI18N 72 break; 73 case NEW_BASIC_APPLICATION_I18N: 74 name = "BasicApplication_i18n.fxml"; //NOI18N 75 break; 76 case NEW_COMPLEX_APPLICATION: 77 name = "ComplexApplication.fxml"; //NOI18N 78 break; 79 case NEW_COMPLEX_APPLICATION_CSS: 80 name = "ComplexApplication_css.fxml"; //NOI18N 81 break; 82 case NEW_COMPLEX_APPLICATION_I18N: 83 name = "ComplexApplication_i18n.fxml"; //NOI18N 84 break; 85 default: 86 name = null; 87 break; 88 } 89 return name; 90 } 91 92 public static Set<String> getResourceFileNames(ApplicationControlAction action) { 93 final Set<String> names = new HashSet<>(); 94 switch (action) { 95 case NEW_ALERT_DIALOG_CSS: 96 names.add("AlertDialog.css"); //NOI18N 97 names.add("AlertDialog.png"); //NOI18N 98 break; 99 case NEW_ALERT_DIALOG_I18N: 100 names.add("AlertDialog.css"); //NOI18N 101 names.add("AlertDialog.png"); //NOI18N 102 names.add("AlertDialog_en.properties"); //NOI18N 103 names.add("AlertDialog_fr.properties"); //NOI18N 104 break; 105 case NEW_BASIC_APPLICATION_CSS: 106 names.add("BasicApplication.css"); //NOI18N 107 break; 108 case NEW_BASIC_APPLICATION_I18N: 109 names.add("BasicApplication.css"); //NOI18N 110 names.add("BasicApplication_en.properties"); //NOI18N 111 names.add("BasicApplication_fr.properties"); //NOI18N 112 break; 113 case NEW_COMPLEX_APPLICATION_CSS: 114 names.add("ComplexApplication.css"); //NOI18N 115 break; 116 case NEW_COMPLEX_APPLICATION_I18N: 117 names.add("ComplexApplication.css"); //NOI18N 118 names.add("ComplexApplication_en.properties"); //NOI18N 119 names.add("ComplexApplication_fr.properties"); //NOI18N 120 break; 121 default: 122 break; 123 } 124 return names; 125 } 126 }