use of org.apache.pivot.util.Resources in project pivot by apache.
the class RowEditorDemo method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
String language = properties.get(LANGUAGE_KEY);
Locale locale = (language == null) ? Locale.getDefault() : new Locale(language);
Resources resources = new Resources(RESOURCE_NAME, locale);
System.out.println("Loaded Resources from: " + resources.getBaseName() + ", for locale " + locale);
// Search for a font that can support the sample string
String title = (String) resources.get("title");
System.out.println("Title from Resources file is: \"" + title + "\"");
// print if the theme has transitions enabled
System.out.println("Theme has transitions enabled: " + Theme.getTheme().isTransitionEnabled());
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(RowEditorDemo.class.getResource("row_editor_demo.bxml"), resources);
window.open(display);
}
use of org.apache.pivot.util.Resources in project pivot by apache.
the class ParentResourcesTest method before.
@Before
public void before() throws Exception {
parent = new Resources(getClass().getName() + "Parent");
assertNotNull("From parent", parent.get("parentKeyString"));
main = new Resources(parent, getClass().getName(), Locale.ENGLISH);
}
use of org.apache.pivot.util.Resources in project pivot by apache.
the class ScriptApplication method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
// Get the location of the source file
String src = properties.get(SRC_KEY);
if (src == null) {
if (sourceDefault == null) {
throw new IllegalArgumentException(SRC_KEY + " argument is required.");
}
src = sourceDefault;
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL location = classLoader.getResource(src.substring(1));
if (location == null) {
// If the source file isn't in the resources, try finding it as a local file
File localFile = new File(src);
if (localFile.exists() && localFile.isFile() && localFile.canRead()) {
try {
location = localFile.toURI().toURL();
} catch (MalformedURLException mue) {
}
}
}
if (location == null) {
throw new IllegalArgumentException("Cannot find source file \"" + src + "\".");
}
Resources resources;
if (properties.containsKey(RESOURCES_KEY)) {
resources = new Resources(properties.get(RESOURCES_KEY));
} else {
resources = null;
}
if (properties.containsKey(STYLESHEET_KEY)) {
String stylesheet = properties.get(STYLESHEET_KEY);
if (!stylesheet.startsWith("/")) {
throw new IllegalArgumentException("Value for " + STYLESHEET_KEY + " argument must start with a slash character.");
}
ApplicationContext.applyStylesheet(stylesheet);
}
// Load the file and open the window
BXMLSerializer bxmlSerializer = new BXMLSerializer();
Component component = (Component) bxmlSerializer.readObject(location, resources);
if (component instanceof Sheet || component instanceof Palette) {
window = new Window();
window.setMaximized(true);
window.open(display);
Window auxWindow = (Window) component;
auxWindow.open(window);
auxWindow.requestFocus();
} else {
if (component instanceof Window) {
window = (Window) component;
} else {
window = new Window();
window.setContent(component);
}
window.open(display);
Component content = window.getContent();
if (content != null) {
content.requestFocus();
}
}
}
use of org.apache.pivot.util.Resources in project pivot by apache.
the class StockTracker method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
String language = properties.get(LANGUAGE_KEY);
Locale locale = (language == null) ? Locale.getDefault() : new Locale(language);
Resources resources = new Resources(StockTrackerWindow.class.getName(), locale);
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (StockTrackerWindow) bxmlSerializer.readObject(getClass().getResource("stock_tracker_window.bxml"), resources);
window.open(display);
}
Aggregations