prop.load(str);
str.close();
// Create driver
String driver = prop.getProperty("panel.driver");
PanelProvider p = (PanelProvider) Factory.lookup("org.jboss.dashboard.ui.panel.PanelProvider");
try {
PanelDriver pdriver = (PanelDriver) Factory.lookup(driver);
pdriver = pdriver == null ? (PanelDriver) Class.forName(driver).newInstance() : pdriver;
p.setDriver(pdriver);
}
catch (Throwable e) {
log.error("Error creating instance for driver "+driver+" :", e);
}
// Set attributes
p.setId(prop.getProperty("panel.id"));
p.setBasePanel(ArrayUtils.contains(getBasePanelsIds(), prop.getProperty("panel.id")));
p.setDeprecatedPanel(ArrayUtils.contains(getDeprecatedPanelsIds(), prop.getProperty("panel.id")));
p.setDescription(prop.getProperty("panel.description"));
p.setGroup(prop.getProperty("panel.group"));
p.setStyleSheet(prop.getProperty("stylesheet"));
if(prop.getProperty("panel.thumbnail")== null){
p.setThumbnail(defaultProviderThumbnail);
} else {
p.setThumbnail(prop.getProperty("panel.thumbnail"));
}
// We keep files to import in a array a perform it after the loop to avoid a ConcurrentModificationException
List filesToImport = new ArrayList();
/*
* Iterate over properties
*/
Iterator it = prop.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
String value = prop.getProperty(key).trim();
if (key.startsWith("jsp.")) {
String text = key.substring(4).trim();
p.addPage(text, value);
} else if (key.startsWith("resources.")) {
// Import resource bundles
String bundleName = value;
if (value.endsWith(".properties")) bundleName = value.substring(0, value.length() - 11);
String[] locales = LocaleManager.lookup().getInstalledLocaleIds();
for (int i = 0; i < locales.length; i++) {
String locale = locales[i];
File localeFile = new File(f.getParent() + "/" + bundleName + "_" + locale + ".properties");
if (!localeFile.exists() || !localeFile.isFile()) {
log.error("Bundle file '" + localeFile.getName() + "' not found for the panel provider with id=" + p.getId());
continue;
}
File bundleFile = new File(f.getParent() + "/" + bundleName + ".properties");
p.getBundles().add(bundleFile);
}
}
}
// Add the help page
p.addPage(PanelDriver.PAGE_HELP_MODE, getHelpModePage());
// Make the properties file available to the driver
p.setProperties(prop);
return p;
}