Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FXMLConstructor.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-15 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * 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, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline;
20 
21 import java.io.IOException;
22 import java.net.MalformedURLException;
23 import java.net.URL;
24 import java.util.logging.Level;
25 import javafx.fxml.FXMLLoader;
26 import javafx.scene.Node;
27 import org.apache.commons.lang3.StringUtils;
30 
47 public class FXMLConstructor {
48 
49  private static final Logger LOGGER = Logger.getLogger(FXMLConstructor.class.getName());
50 
61  static public void construct(Node node, String fxmlFileName) {
62  construct(node, node.getClass(), fxmlFileName);
63  }
64 
77  static public void construct(Node node, Class<? extends Node> clazz, String fxmlFileName) {
78  final String name = "nbres:/" + StringUtils.replace(clazz.getPackage().getName(), ".", "/") + "/" + fxmlFileName; // NON-NLS
79 
80  try {
81  FXMLLoader fxmlLoader = new FXMLLoader(new URL(name));
82  fxmlLoader.setRoot(node);
83  fxmlLoader.setController(node);
84 
85  try {
86  fxmlLoader.load();
87  } catch (IOException exception) {
88  LOGGER.log(Level.SEVERE, "FXMLConstructor was unable to load FXML, falling back on default Class Loader, and trying again.", exception); //NON-NLS
89  try {
90  fxmlLoader.setClassLoader(FXMLLoader.getDefaultClassLoader());
91  fxmlLoader.load();
92  } catch (IOException ex) {
93  LOGGER.log(Level.SEVERE, "FXMLConstructor was unable to load FXML, node initialization may not be complete.", ex); //NON-NLS
94  }
95  }
96  } catch (MalformedURLException ex) {
97  LOGGER.log(Level.SEVERE, "FXMLConstructor was unable to load FXML, node initialization may not be complete.", ex); //NON-NLS
98  }
99  }
100 
101  private FXMLConstructor() {
102  }
103 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static void construct(Node node, String fxmlFileName)

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.