private static InputStream getFromStringContext(String path) { if(path.startsWith("classpath:")) { return getStream(path.split("classpath:")[1]); } return null; } }
/** * @{inheritedDoc} */ @Override public URL getMenuConfiguration(IEmaginController context) { return ResourceUtils.getURL(AbstractViewController.class, primaryMenu); }
@Bean @Singleton @Named("ResourceUtils") public ResourceUtils resourceUtils() { return new ResourceUtils(); }
/** * Uses all possible methods to find out this resource. * * @param clazz * @param path * @return */ public static InputStream getStream(Class clazz, String path) { InputStream inputStream = clazz.getResourceAsStream(path); if (inputStream == null) { inputStream = clazz.getClassLoader().getResourceAsStream(path); } if (inputStream == null) { inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path); } if (inputStream == null) { inputStream = getFromStringContext(path); } if (inputStream == null) { System.out.println("Definitly Resource not found : " + path); } return inputStream; }
/** * Uses all possible methods to find out this resource. * * @param clazz * @param path * @return */ public static InputStream getStream(String path) { InputStream inputStream = ResourceUtils.class.getResourceAsStream(path); if (inputStream == null) { inputStream = ResourceUtils.class.getClassLoader().getResourceAsStream(path); } if (inputStream == null) { inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path); } if (inputStream == null) { inputStream = getFromStringContext(path); } if (inputStream == null) { System.out.println("Definitly Resource not found : " + path); } return inputStream; }
/** * Merge views definitions corresponding to this view. View must define at least one * wizardConfiguration. */ @Override public VLViewConfigXML getConfigurationFile(final IEmaginController controller) { VLViewConfigXML finalResult = null; if(debug) { System.out.println("Searching for wiew : " + controller.getViewDefinitions().get(0)); } String file = controller.getViewDefinitions().get(0); if(file.endsWith(".xml")) { throw new RuntimeException("Only Json configurration file is supported, given" + file); } if(debug) { System.out.println("### Searching for wiew : " + file); } Gson gson = new Gson(); InputStream io = ResourceUtils.getStream(controller.getClass(), file); finalResult = gson.fromJson(new InputStreamReader(io), VLViewConfigXML.class); return finalResult; } }
/** * @{inheritedDoc} */ @Override public URL getMenuConfiguration(IEmaginController context) { return ResourceUtils.getURL(AbstractViewController.class, menuDefinitionLocation); }
/** * Get the single instance of icon reolver. When first time loading, it will search for spring bean * nammed 'IconDefinitionFiles", and will load all files inside it. */ public static ModelIconUtils instance() { if (instance == null) { instance = (ModelIconUtils) Services.getBean("ModelIconUtils"); List<String> iconDefinitionFiles = (List<String>) Services.getBean("IconDefinitionFiles"); for (String definition : iconDefinitionFiles) { Properties definitionMapping = new Properties(); try (InputStream is = ResourceUtils.getStream(ModelIconUtils.class, definition)) { definitionMapping.load(is); instance.iconMapping.putAll(definitionMapping); } catch (Exception ex) { ex.printStackTrace(); } } } return instance; }
public void setDefaultTheme(String themePath) { clearCurrentTheme(); loadedStylesheets.add(ResourceUtils.getURL(themePath).toExternalForm()); }
try(InputStream io = ResourceUtils.getStream(getClass(), coreAttributes)){ Gson gson1 = new Gson(); VLViewConfigXML c = gson1.fromJson(new InputStreamReader(io), VLViewConfigXML.class); try(InputStream io = ResourceUtils.getStream(getClass(), coreComp)){ Gson gson = new Gson(); VLViewConfigXML c = gson.fromJson(new InputStreamReader(io), VLViewConfigXML.class); try(InputStream io = ResourceUtils.getStream(getClass(), coreActions)){ Gson gson = new Gson(); VLViewConfigXML c = gson.fromJson(new InputStreamReader(io), VLViewConfigXML.class); try(InputStream io = ResourceUtils.getStream(getClass(), coreActionsModel)){ Gson gson = new Gson(); VLViewConfigXML c = gson.fromJson(new InputStreamReader(io), VLViewConfigXML.class);
URL rul = getURL(path); if(rul == null) { rul = clazz.getResource(path);
/** * @{inheritedDoc} */ @Override public void buildFrom(IEmaginController controller, VLViewComponentXML configuration) { NodeHelper.styleClassAddAll(this, configuration); try (InputStream is = ResourceUtils.getStream("/images/logo/EMAGIN_FX_WHITE.png")) { if(is != null) { final Image img = new Image(is, 200, 102, true, true); final ImageView imgView = new ImageView(img); // getChildren().add(imgView); } } catch (IOException e) { // e.printStackTrace(); } }
try (InputStream is = ResourceUtils.getStream("/images/logo/EMAGIN_FX_DEMOAPP_DARK.png")) { final Image img = new Image(is, 180, 180, true, true); final ImageView imgView = new ImageView(img);