Search in sources :

Example 1 with ParameterPage

use of eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage in project hale by halestudio.

the class AbstractGenericFunctionWizard method performFinish.

/**
 * @see Wizard#performFinish()
 */
@Override
public boolean performFinish() {
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    resultCell.setTransformationParameters(parameters);
    // configure cell with all pages
    for (IWizardPage page : getPages()) if (page instanceof FunctionWizardPage)
        ((FunctionWizardPage) page).configureCell(resultCell);
    else if (page instanceof ParameterPage)
        parameters.putAll(((ParameterPage) page).getConfiguration());
    return true;
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) ParameterPage(eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage) GenericParameterPage(eu.esdihumboldt.hale.ui.function.generic.pages.GenericParameterPage) IWizardPage(org.eclipse.jface.wizard.IWizardPage) FunctionWizardPage(eu.esdihumboldt.hale.ui.function.generic.pages.FunctionWizardPage)

Example 2 with ParameterPage

use of eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage in project hale by halestudio.

the class AbstractGenericFunctionWizard method createParameterPages.

/**
 * Create parameter pages.
 *
 * @param initialValues the initial parameter values, may be
 *            <code>null</code>
 * @return the list of parameter pages
 */
protected List<ParameterPage> createParameterPages(@Nullable ListMultimap<String, ParameterValue> initialValues) {
    LinkedList<ParameterPage> parameterPages = new LinkedList<ParameterPage>();
    // create copy of function parameter set
    Set<FunctionParameterDefinition> functionParameters = new LinkedHashSet<>();
    for (FunctionParameterDefinition param : getFunction().getDefinedParameters()) functionParameters.add(param);
    if (initialValues != null)
        initialValues = Multimaps.unmodifiableListMultimap(initialValues);
    // get available parameter pages
    List<ParameterPageFactory> paramPageFactories = ParameterPageExtension.getInstance().getFactories(new FactoryFilter<ParameterPage, ParameterPageFactory>() {

        @Override
        public boolean acceptFactory(ParameterPageFactory factory) {
            return factory.getFunctionId().equals(getFunctionId());
        }

        @Override
        public boolean acceptCollection(ExtensionObjectFactoryCollection<ParameterPage, ParameterPageFactory> collection) {
            return true;
        }
    });
    // use available parameter pages (first come first serve)
    for (ParameterPageFactory paramPageFactory : paramPageFactories) {
        Set<FunctionParameterDefinition> pageFunctionParameters = new HashSet<>();
        for (FunctionParameterDefinition fp : paramPageFactory.getAssociatedParameters()) if (functionParameters.contains(fp))
            pageFunctionParameters.add(fp);
        if (!pageFunctionParameters.isEmpty()) {
            ParameterPage paramPage;
            try {
                paramPage = paramPageFactory.createExtensionObject();
            } catch (Exception e) {
                log.error("Could not creating parameter page " + paramPageFactory.getIdentifier(), e);
                continue;
            }
            functionParameters.removeAll(pageFunctionParameters);
            parameterPages.add(paramPage);
            paramPage.setParameter(pageFunctionParameters, initialValues);
        }
    }
    // use generic parameter page for remaining parameters
    if (!functionParameters.isEmpty()) {
        ParameterPage generic = new GenericParameterPage();
        generic.setParameter(functionParameters, initialValues);
        parameterPages.add(generic);
    }
    return parameterPages;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ParameterPage(eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage) GenericParameterPage(eu.esdihumboldt.hale.ui.function.generic.pages.GenericParameterPage) GenericParameterPage(eu.esdihumboldt.hale.ui.function.generic.pages.GenericParameterPage) FunctionParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionParameterDefinition) LinkedList(java.util.LinkedList) ParameterPageFactory(eu.esdihumboldt.hale.ui.function.extension.ParameterPageFactory) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 3 with ParameterPage

use of eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage in project hale by halestudio.

the class AbstractGenericFunctionWizard method getUnfinishedCell.

/**
 * Returns the cell that would be created if the wizard would be finished
 * now.
 *
 * @return the cell
 */
public Cell getUnfinishedCell() {
    MutableCell current = new DefaultCell();
    current.setTransformationIdentifier(getFunctionId());
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    current.setTransformationParameters(parameters);
    for (IWizardPage page : getPages()) {
        // stop at first uncompleted page
        if (!page.isPageComplete())
            break;
        if (page instanceof FunctionWizardPage)
            ((FunctionWizardPage) page).configureCell(current);
        else if (page instanceof ParameterPage)
            parameters.putAll(((ParameterPage) page).getConfiguration());
    }
    return current;
}
Also used : MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) ParameterPage(eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage) GenericParameterPage(eu.esdihumboldt.hale.ui.function.generic.pages.GenericParameterPage) IWizardPage(org.eclipse.jface.wizard.IWizardPage) FunctionWizardPage(eu.esdihumboldt.hale.ui.function.generic.pages.FunctionWizardPage)

Aggregations

GenericParameterPage (eu.esdihumboldt.hale.ui.function.generic.pages.GenericParameterPage)3 ParameterPage (eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage)3 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)2 FunctionWizardPage (eu.esdihumboldt.hale.ui.function.generic.pages.FunctionWizardPage)2 IWizardPage (org.eclipse.jface.wizard.IWizardPage)2 FunctionParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionParameterDefinition)1 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)1 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)1 ParameterPageFactory (eu.esdihumboldt.hale.ui.function.extension.ParameterPageFactory)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1