Search in sources :

Example 1 with AbstractWizardAction

use of eu.esdihumboldt.hale.ui.function.contribution.internal.AbstractWizardAction in project hale by halestudio.

the class AbstractFunctionWizardContribution method fill.

/**
 * @see ContributionItem#fill(Menu, int)
 */
@Override
public void fill(Menu menu, int index) {
    boolean added = false;
    AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
    List<AbstractWizardAction<?>> augmentationActions = new ArrayList<AbstractWizardAction<?>>();
    for (FunctionWizardDescriptor<?> descriptor : getFunctionWizardDescriptors()) {
        if (!descriptor.getFunction().isAugmentation() || showAugmentations) {
            AbstractWizardAction<?> action = createWizardAction(descriptor, alignmentService);
            if (action.isActive()) {
                if (descriptor.getFunction().isAugmentation()) {
                    augmentationActions.add(action);
                } else {
                    IContributionItem item = new ActionContributionItem(action);
                    item.fill(menu, index++);
                    added = true;
                }
            }
        }
    }
    if (!augmentationActions.isEmpty()) {
        if (added) {
            new Separator().fill(menu, index++);
        }
        // get augmentation target name
        // ISelection selection = selectionService.getSelection();
        // AlignmentInfo info = null;
        // 
        // if (selection instanceof DefaultSchemaSelection) {
        // SchemaSelection schemaSelection = (SchemaSelection) selection;
        // info = new SchemaSelectionInfo(schemaSelection, alignmentService);
        // }
        // else if (selection instanceof CellSelection) {
        // CellSelection cellSelection = (CellSelection) selection;
        // info = new CellSelectionInfo(cellSelection);
        // }
        // 
        String augmentations;
        // if (info != null && info.getTargetItemCount() == 1) {
        // augmentations = MessageFormat.format(Messages.FunctionWizardContribution_0, info.getFirstTargetItem().getName().getLocalPart());
        // }
        // else {
        augmentations = Messages.FunctionWizardContribution_1;
        // }
        // 
        MenuItem augItem = new MenuItem(menu, SWT.PUSH, index++);
        augItem.setText(augmentations);
        augItem.setEnabled(false);
        new Separator().fill(menu, index++);
        for (AbstractWizardAction<?> action : augmentationActions) {
            IContributionItem item = new ActionContributionItem(action);
            item.fill(menu, index++);
            added = true;
        }
    }
    if (!added) {
        MenuItem item = new MenuItem(menu, SWT.PUSH, index++);
        // $NON-NLS-1$
        item.setText(Messages.FunctionWizardContribution_2);
        item.setEnabled(false);
    }
}
Also used : AbstractWizardAction(eu.esdihumboldt.hale.ui.function.contribution.internal.AbstractWizardAction) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) IContributionItem(org.eclipse.jface.action.IContributionItem) ArrayList(java.util.ArrayList) MenuItem(org.eclipse.swt.widgets.MenuItem) Separator(org.eclipse.jface.action.Separator)

Aggregations

AbstractWizardAction (eu.esdihumboldt.hale.ui.function.contribution.internal.AbstractWizardAction)1 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)1 ArrayList (java.util.ArrayList)1 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 Separator (org.eclipse.jface.action.Separator)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1