use of org.openecard.addon.manifest.AppExtensionSpecification in project open-ecard by ecsec.
the class AndroidMarshaller method parseAppExtensionSpecification.
private AppExtensionSpecification parseAppExtensionSpecification(XmlPullParser parser) throws XmlPullParserException, IOException {
AppExtensionSpecification appExtensionActionDescription = new AppExtensionSpecification();
int eventType;
do {
parser.next();
eventType = parser.getEventType();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("ClassName")) {
appExtensionActionDescription.setClassName(parser.nextText());
} else if (parser.getName().equals("LocalizedName")) {
LocalizedString localizedString = new LocalizedString();
localizedString.setLang(parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang"));
localizedString.setValue(parser.nextText());
appExtensionActionDescription.getLocalizedName().add(localizedString);
} else if (parser.getName().equals("LocalizedDescription")) {
LocalizedString localizedString = new LocalizedString();
localizedString.setLang(parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang"));
localizedString.setValue(parser.nextText());
appExtensionActionDescription.getLocalizedDescription().add(localizedString);
} else if (parser.getName().equals("ID")) {
appExtensionActionDescription.setId(parser.nextText());
} else if (parser.getName().equals("ConfigDescription")) {
appExtensionActionDescription.setConfigDescription(parseConfigDescription(parser));
} else {
throw new IllegalArgumentException("Unexpected Tag found: " + parser.getName());
}
}
} while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals("AppExtensionSpecification")));
return appExtensionActionDescription;
}
use of org.openecard.addon.manifest.AppExtensionSpecification in project open-ecard by ecsec.
the class AddonManager method getAppExtensionAction.
/**
* Get a specific AppExtensionAction.
*
* @param addonSpec {@link AddonSpecification} which contains the description of the {@link AppExtensionAction}.
* @param actionId The {@link AppExtensionSpecification#id} to identify the requested AppExtensionAction.
* @return The AppExtensionAction which corresponds the given {@code actionId} or NULL if no AppExtensionAction with
* the given {@code actionId} exists.
*/
public AppExtensionAction getAppExtensionAction(@Nonnull AddonSpecification addonSpec, @Nonnull String actionId) {
// get extension from cache
AppExtensionAction appExtAction = cache.getAppExtensionAction(addonSpec, actionId);
if (appExtAction != null) {
// AppExtensionAction cached so return it
return appExtAction;
}
AppExtensionSpecification protoSpec = addonSpec.searchByActionId(actionId);
if (protoSpec == null) {
LOG.error("Requested Extension {} does not exist in Add-on {}.", actionId, addonSpec.getId());
} else {
String className = protoSpec.getClassName();
try {
ClassLoader cl = registry.downloadAddon(addonSpec);
AppExtensionActionProxy protoFactory = new AppExtensionActionProxy(className, cl);
Context aCtx = createContext(addonSpec);
protoFactory.init(aCtx);
cache.addAppExtensionAction(addonSpec, actionId, protoFactory);
return protoFactory;
} catch (ActionInitializationException e) {
LOG.error("Initialization of AppExtensionAction failed", e);
} catch (AddonException ex) {
LOG.error("Failed to download Add-on.", ex);
}
}
return null;
}
use of org.openecard.addon.manifest.AppExtensionSpecification in project open-ecard by ecsec.
the class ManagementDialog method createAddonPaneFromAddonSpec.
private void createAddonPaneFromAddonSpec(AddonSpecification desc, AddonSelectionModel model, boolean coreAddon) {
String description = desc.getLocalizedDescription(LANGUAGE_CODE);
String name = desc.getLocalizedName(LANGUAGE_CODE);
Image logo;
if (coreAddon) {
logo = loadLogo(null, desc.getLogo());
} else {
try {
ClassLoader loader = manager.getRegistry().downloadAddon(desc);
logo = loadLogo(loader, "META-INF/" + desc.getLogo());
} catch (AddonException ex) {
logger.error("Failed to load logo from Add-on bundle.");
logo = null;
}
}
// setup about panel but just if we don't have a core addon
String about = desc.getAbout(LANGUAGE_CODE);
String licenseText = desc.getLicenseText(LANGUAGE_CODE);
AboutPanel aboutPanel = null;
if ((!about.equals("") || !licenseText.equals("")) && !coreAddon) {
aboutPanel = new AboutPanel(desc, coreAddon, manager, this);
}
// inital setup of settings panel if the addon has general settings in the non protocol/action specific
// declaration
DefaultSettingsPanel settingsPanel = null;
ArrayList<DefaultSettingsGroup> settingsGroups = new ArrayList<>();
AddonProperties addonProps = new AddonProperties(desc);
Settings settings = SettingsFactory.getInstance(addonProps);
if (desc.getConfigDescription() != null && !desc.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(lang.translationForKey("addon.settings.general"), settings, desc.getConfigDescription().getEntries());
settingsGroups.add(group);
}
// AppExtensionActions
if (!desc.getApplicationActions().isEmpty()) {
for (AppExtensionSpecification appExtSpec : desc.getApplicationActions()) {
if (appExtSpec.getConfigDescription() != null && !appExtSpec.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(appExtSpec.getLocalizedName(LANGUAGE_CODE) + " " + lang.translationForKey("addon.settings.settings"), settings, appExtSpec.getConfigDescription().getEntries());
settingsGroups.add(group);
}
}
}
// Binding actions
if (!desc.getBindingActions().isEmpty()) {
for (AppPluginSpecification appPluginSpec : desc.getBindingActions()) {
if (appPluginSpec.getConfigDescription() != null && !appPluginSpec.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(appPluginSpec.getLocalizedName(LANGUAGE_CODE) + " " + lang.translationForKey("addon.settings.settings"), settings, appPluginSpec.getConfigDescription().getEntries());
settingsGroups.add(group);
}
}
}
// IFD Actions
if (!desc.getIfdActions().isEmpty()) {
for (ProtocolPluginSpecification protPluginSpec : desc.getIfdActions()) {
if (protPluginSpec.getConfigDescription() != null && !protPluginSpec.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(protPluginSpec.getLocalizedName(LANGUAGE_CODE) + " " + lang.translationForKey("addon.settings.settings"), settings, protPluginSpec.getConfigDescription().getEntries());
settingsGroups.add(group);
}
}
}
// SAL Actions
if (!desc.getSalActions().isEmpty()) {
for (ProtocolPluginSpecification protPluginSpec : desc.getSalActions()) {
if (protPluginSpec.getConfigDescription() != null && !protPluginSpec.getConfigDescription().getEntries().isEmpty()) {
DefaultSettingsGroup group = new DefaultSettingsGroup(protPluginSpec.getLocalizedName(LANGUAGE_CODE) + " " + lang.translationForKey("addon.settings.settings"), settings, protPluginSpec.getConfigDescription().getEntries());
settingsGroups.add(group);
}
}
}
if (!settingsGroups.isEmpty()) {
settingsPanel = new DefaultSettingsPanel(settingsGroups.toArray(new DefaultSettingsGroup[settingsGroups.size()]));
}
// create the actions panel
ActionPanel actionPanel = null;
if (!desc.getApplicationActions().isEmpty()) {
actionPanel = new ActionPanel();
for (AppExtensionSpecification appExtSpec : desc.getApplicationActions()) {
ActionEntryPanel entry = new ActionEntryPanel(desc, appExtSpec, manager);
actionPanel.addActionEntry(entry);
}
}
AddonPanel nextPanel = null;
// check whether to use a tabbed pane or not
if (actionPanel != null && settingsPanel == null && aboutPanel == null) {
nextPanel = new AddonPanel(actionPanel, name, description, logo);
} else if (actionPanel == null && settingsPanel != null && aboutPanel == null) {
nextPanel = new AddonPanel(settingsPanel, name, description, logo);
} else if (actionPanel == null && settingsPanel == null && aboutPanel != null) {
nextPanel = new AddonPanel(aboutPanel, name, description, logo);
} else if (actionPanel != null || settingsPanel != null || aboutPanel != null) {
nextPanel = new AddonPanel(actionPanel, settingsPanel, aboutPanel, name, description, logo);
}
if (nextPanel != null) {
model.addElement(name, nextPanel);
}
}
Aggregations