use of eu.esdihumboldt.hale.ui.io.IOWizard in project hale by halestudio.
the class IOWizardAction method run.
/**
* @see Action#run()
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void run() {
try {
// retrieve action ID
final String actionId = getFactory().getActionID();
// find associated advisor
IOAdvisor<?> advisor = IOAdvisorExtension.getInstance().findAdvisor(actionId, HaleUI.getServiceProvider());
checkState(advisor != null, "No advisor for action found");
// create wizard
IOWizard<?> wizard = getFactory().createExtensionObject();
// set advisor and action ID
((IOWizard) wizard).setAdvisor(advisor, actionId);
Shell shell = Display.getCurrent().getActiveShell();
HaleWizardDialog dialog = new HaleWizardDialog(shell, wizard);
notifyResult(dialog.open() == Window.OK);
} catch (Exception e) {
log.error("Could not launch I/O wizard for advisor " + getFactory().getIdentifier(), e);
}
}
use of eu.esdihumboldt.hale.ui.io.IOWizard in project hale by halestudio.
the class ConfigurationPageExtension method getConfigurationPages.
/**
* Get the configuration pages registered for the given I/O provider
* descriptors
*
* @param
* <P>
* the {@link IOProvider} type used in the wizard
*
* @param descriptors the provider descriptors
* @return the configuration pages in a multimap where the corresponding
* provider identifier is mapped to the configuration page, one page
* (the same instance) might be mapped for multiple identifiers
*/
@SuppressWarnings("unchecked")
public <P extends IOProvider> ListMultimap<String, AbstractConfigurationPage<? extends P, ? extends IOWizard<P>>> getConfigurationPages(Iterable<IOProviderDescriptor> descriptors) {
// collect provider IDs
final Set<String> providerIds = new HashSet<String>();
for (IOProviderDescriptor descriptor : descriptors) {
providerIds.add(descriptor.getIdentifier());
}
// get all factories that support at least one of the providers
List<ConfigurationPageFactory> factories = getFactories(new FactoryFilter<AbstractConfigurationPage<?, ?>, ConfigurationPageFactory>() {
@Override
public boolean acceptFactory(ConfigurationPageFactory factory) {
Set<String> supported = new HashSet<String>(factory.getSupportedProviderIDs());
supported.retainAll(providerIds);
return !supported.isEmpty();
}
@Override
public boolean acceptCollection(ExtensionObjectFactoryCollection<AbstractConfigurationPage<?, ?>, ConfigurationPageFactory> collection) {
return false;
}
});
ListMultimap<String, AbstractConfigurationPage<? extends P, ? extends IOWizard<P>>> result = ArrayListMultimap.create();
// add pages to result map
for (ConfigurationPageFactory factory : factories) {
AbstractConfigurationPage<? extends P, ? extends IOWizard<P>> page = null;
try {
page = (AbstractConfigurationPage<? extends P, ? extends IOWizard<P>>) factory.createExtensionObject();
} catch (Exception e) {
log.error("Error creating configuration page " + factory.getTypeName(), e);
break;
}
if (page != null) {
for (String providerId : factory.getSupportedProviderIDs()) {
if (providerIds.contains(providerId)) {
result.put(providerId, page);
}
}
}
}
return result;
}
Aggregations