Search in sources :

Example 1 with GenericTypeFunctionWizard

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

the class EditRelationHandler method execute.

/**
 * @see IHandler#execute(ExecutionEvent)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
        Object selected = ((IStructuredSelection) selection).getFirstElement();
        if (selected instanceof Cell) {
            final Cell originalCell = (Cell) selected;
            FunctionWizard wizard = null;
            List<FunctionWizardDescriptor<?>> factories = FunctionWizardExtension.getInstance().getFactories(new FactoryFilter<FunctionWizardFactory, FunctionWizardDescriptor<?>>() {

                @Override
                public boolean acceptFactory(FunctionWizardDescriptor<?> factory) {
                    return factory.getFunctionId().equals(originalCell.getTransformationIdentifier());
                }

                @Override
                public boolean acceptCollection(ExtensionObjectFactoryCollection<FunctionWizardFactory, FunctionWizardDescriptor<?>> collection) {
                    return true;
                }
            });
            if (!factories.isEmpty()) {
                // create registered wizard
                FunctionWizardDescriptor<?> fwd = factories.get(0);
                wizard = fwd.createEditWizard(originalCell);
            }
            if (wizard == null) {
                FunctionDefinition<?> function = FunctionUtil.getFunction(originalCell.getTransformationIdentifier(), HaleUI.getServiceProvider());
                if (function == null) {
                    log.userError(MessageFormat.format("Function with identifier ''{0}'' is unknown.", originalCell.getTransformationIdentifier()));
                    return null;
                }
                // create generic wizard
                if (function instanceof TypeFunction) {
                    wizard = new GenericTypeFunctionWizard(originalCell);
                } else {
                    wizard = new GenericPropertyFunctionWizard(originalCell);
                }
            }
            // initialize wizard
            wizard.init();
            HaleWizardDialog dialog = new HaleWizardDialog(HandlerUtil.getActiveShell(event), wizard);
            if (dialog.open() == WizardDialog.OK) {
                MutableCell cell = wizard.getResult();
                AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
                // remove the original cell
                // and add the new cell
                alignmentService.replaceCell(originalCell, cell);
            }
        }
    }
    return null;
}
Also used : MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) FunctionWizardDescriptor(eu.esdihumboldt.hale.ui.function.extension.FunctionWizardDescriptor) FunctionWizardFactory(eu.esdihumboldt.hale.ui.function.extension.FunctionWizardFactory) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GenericTypeFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizard) GenericPropertyFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizard) FunctionWizard(eu.esdihumboldt.hale.ui.function.FunctionWizard) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) ISelection(org.eclipse.jface.viewers.ISelection) GenericTypeFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizard) Cell(eu.esdihumboldt.hale.common.align.model.Cell) MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) GenericPropertyFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizard) TypeFunction(eu.esdihumboldt.hale.common.align.extension.function.TypeFunction) HaleWizardDialog(eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog)

Example 2 with GenericTypeFunctionWizard

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

the class FunctionWizardNode method createWizard.

/**
 * @see AbstractWizardNode#createWizard()
 */
@Override
protected FunctionWizard createWizard() {
    FunctionWizard result = null;
    List<FunctionWizardDescriptor<?>> factories = FunctionWizardExtension.getInstance().getFactories(new FactoryFilter<FunctionWizardFactory, FunctionWizardDescriptor<?>>() {

        @Override
        public boolean acceptFactory(FunctionWizardDescriptor<?> factory) {
            return factory.getFunctionId().equals(function.getId());
        }

        @Override
        public boolean acceptCollection(ExtensionObjectFactoryCollection<FunctionWizardFactory, FunctionWizardDescriptor<?>> collection) {
            return true;
        }
    });
    if (!factories.isEmpty()) {
        // create registered wizard
        FunctionWizardDescriptor<?> fwd = factories.get(0);
        result = fwd.createNewWizard(initialSelection);
    }
    if (result == null) {
        // create generic wizard
        if (function instanceof TypeFunction) {
            result = new GenericTypeFunctionWizard(initialSelection, function.getId());
        } else {
            result = new GenericPropertyFunctionWizard(initialSelection, function.getId());
        }
    }
    // initialize wizard
    result.init();
    return result;
}
Also used : FunctionWizardDescriptor(eu.esdihumboldt.hale.ui.function.extension.FunctionWizardDescriptor) FunctionWizardFactory(eu.esdihumboldt.hale.ui.function.extension.FunctionWizardFactory) GenericTypeFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizard) GenericPropertyFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizard) GenericTypeFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizard) GenericPropertyFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizard) FunctionWizard(eu.esdihumboldt.hale.ui.function.FunctionWizard) TypeFunction(eu.esdihumboldt.hale.common.align.extension.function.TypeFunction)

Example 3 with GenericTypeFunctionWizard

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

the class JoinTypeStructureTray method createToolItem.

/**
 * Creates a tool item
 *
 * @param bar a toolbar
 * @param page hale wizard page
 * @param schemaSpace schema space
 * @param types type provider
 */
public static void createToolItem(ToolBar bar, final HaleWizardPage<?> page, final SchemaSpaceID schemaSpace, final TypeProvider types) {
    ToolItem item = new ToolItem(bar, SWT.PUSH);
    item.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_SOURCE_SCHEMA));
    item.setToolTipText("Show source structure");
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (page.getContainer() instanceof TrayDialog) {
                TrayDialog dialog = (TrayDialog) page.getContainer();
                // close existing tray
                if (dialog.getTray() != null) {
                    dialog.closeTray();
                }
                ParameterValue param = CellUtil.getFirstParameter(((GenericTypeFunctionWizard) page.getWizard()).getUnfinishedCell(), JoinFunction.PARAMETER_JOIN);
                dialog.openTray(new JoinTypeStructureTray(param, types, schemaSpace));
            } else {
            // TODO show dialog instead?
            }
        }
    });
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GenericTypeFunctionWizard(eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizard) TrayDialog(org.eclipse.jface.dialogs.TrayDialog) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

GenericTypeFunctionWizard (eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizard)3 TypeFunction (eu.esdihumboldt.hale.common.align.extension.function.TypeFunction)2 FunctionWizard (eu.esdihumboldt.hale.ui.function.FunctionWizard)2 FunctionWizardDescriptor (eu.esdihumboldt.hale.ui.function.extension.FunctionWizardDescriptor)2 FunctionWizardFactory (eu.esdihumboldt.hale.ui.function.extension.FunctionWizardFactory)2 GenericPropertyFunctionWizard (eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizard)2 Cell (eu.esdihumboldt.hale.common.align.model.Cell)1 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)1 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)1 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)1 HaleWizardDialog (eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog)1 TrayDialog (org.eclipse.jface.dialogs.TrayDialog)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 ToolItem (org.eclipse.swt.widgets.ToolItem)1