Search in sources :

Example 1 with IGEFEditorKit

use of org.whole.lang.ui.editor.IGEFEditorKit in project whole by wholeplatform.

the class OutlineUIProvider method getPartDataProvider.

public IOutlineUIProvider getPartDataProvider(IEntity entity) {
    ILanguageKit languageKit = entity.wGetLanguageKit();
    IUITemplate pt = ((IGEFEditorKit) entity.wGetEditorKit()).getUITemplate(languageKit);
    String id = pt.getId();
    IOutlineUIProvider[] data = idPartDataMap.get(id);
    if (data == null) {
        EntityDescriptorEnum types = languageKit.getEntityDescriptorEnum();
        int size = types.size();
        idPartDataMap.put(id, data = new IOutlineUIProvider[size]);
        for (int i = 0; i < data.length; i++) data[i] = DefaultOutlineUIProvider.instance;
        pt.applyOutline(createOutlineBuilder(data));
    }
    int entityOrd = entity.wGetEntityOrd();
    if (data.length <= entityOrd)
        return DefaultOutlineUIProvider.instance;
    return data[entityOrd];
}
Also used : EntityDescriptorEnum(org.whole.lang.reflect.EntityDescriptorEnum) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 2 with IGEFEditorKit

use of org.whole.lang.ui.editor.IGEFEditorKit in project whole by wholeplatform.

the class TextualDragTracker method handleTripleClick.

protected boolean handleTripleClick(int button) {
    ITextualEntityPart textualEntityPart = getTextualEntityPart();
    if (button == 1 && textualEntityPart != null) {
        IGEFEditorKit editorkit = (IGEFEditorKit) textualEntityPart.getModelEntity().wGetEditorKit();
        EditPoint editPoint = new EditPoint(textualEntityPart, textualEntityPart.getCaretPosition());
        IKeyHandler keyHandler = editorkit.getKeyHandler();
        IWholeSelection selection = keyHandler.calculateTripleClickSelection(editPoint);
        performSelectionUpdate(selection, true);
        return true;
    }
    return false;
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) IKeyHandler(org.whole.lang.ui.keys.IKeyHandler)

Example 3 with IGEFEditorKit

use of org.whole.lang.ui.editor.IGEFEditorKit in project whole by wholeplatform.

the class E4NavigationKeyHandler method navigateView.

public boolean navigateView(KeyEvent event, int direction) {
    EditPoint focusPoint = getEditPoint();
    IGEFEditorKit editorKit = (IGEFEditorKit) focusPoint.focus.getModelEntity().wGetEditorKit();
    IKeyHandler keyHandler = editorKit.getKeyHandler();
    // FIXME workaround for a bug in navigation actions
    if (focusPoint.focus instanceof ITextualEntityPart) {
        ITextualEntityPart part = (ITextualEntityPart) focusPoint.focus;
        int start = part.getSelectionStart();
        int end = part.getSelectionEnd();
        if (start != -1 && end != -1) {
            CaretUpdater.sheduleSyncUpdate(part.getViewer(), part.getModelTextEntity(), direction == PositionConstants.WEST ? start : end, true);
            return true;
        } else {
            CaretUpdater.sheduleSyncUpdate(part.getViewer(), part.getModelTextEntity(), part.getCaretPosition(), true);
        }
    }
    editPoint = keyHandler.findNeighbour(this, focusPoint, direction);
    if (editPoint == null)
        return navigateNextSibling(event, direction);
    navigateTo(editPoint.focus, event);
    return true;
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) EditPoint(org.whole.lang.ui.tools.EditPoint) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) IKeyHandler(org.whole.lang.ui.keys.IKeyHandler) Point(org.eclipse.draw2d.geometry.Point) EditPoint(org.whole.lang.ui.tools.EditPoint)

Example 4 with IGEFEditorKit

use of org.whole.lang.ui.editor.IGEFEditorKit in project whole by wholeplatform.

the class EntityAssistCompositeContributionItem method createWrapActions.

protected List<IAction> createWrapActions(ILanguageKit lk, IEntity targetEntity) {
    List<IAction> wrapActions = new ArrayList<IAction>();
    Set<EntityDescriptor<?>> wrapTypes = new HashSet<EntityDescriptor<?>>();
    IGEFEditorKit editorKit = (IGEFEditorKit) (targetEntity.wGetLanguageKit().equals(lk) ? ReflectionFactory.getEditorKit(targetEntity) : lk.getDefaultEditorKit());
    for (Object[] wrapAction : editorKit.getActionFactory().wrapActions()) {
        EntityDescriptor<?> ed = (EntityDescriptor<?>) wrapAction[1];
        if (isWrappable(targetEntity, ed, (IEnablerPredicate) wrapAction[0])) {
            String label = (String) wrapAction[2];
            IEntityTransformer transformer = (IEntityTransformer) wrapAction[3];
            wrapActions.add(contextProvider.getActionRegistry().getActionFactory().createPerformAction(label, WRAP_ICON_URI, QueriesEntityFactory.instance.createBooleanLiteral(true), getBehavior(ed, transformer)));
            wrapTypes.add(ed);
        }
    }
    for (EntityDescriptor<?> ed : lk.getEntityDescriptorEnum()) if (EntityUtils.isComposite(ed) && !wrapTypes.contains(ed) && isWrappable(targetEntity, ed, EnablerPredicateFactory.instance.assignableTo(ed.getEntityDescriptor(0)))) {
        String label = StringUtils.camelCaseToSpacedWords(ed.getName());
        wrapActions.add(contextProvider.getActionRegistry().getActionFactory().createPerformAction(label, WRAP_ICON_URI, QueriesEntityFactory.instance.createBooleanLiteral(true), getBehavior(ed, DefaultWrapInTransformer.instance)));
    }
    return wrapActions;
}
Also used : EntityDescriptor(org.whole.lang.reflect.EntityDescriptor) IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) IEntityTransformer(org.whole.lang.util.IEntityTransformer) HashSet(java.util.HashSet)

Example 5 with IGEFEditorKit

use of org.whole.lang.ui.editor.IGEFEditorKit in project whole by wholeplatform.

the class EntityAssistCompositeContributionItem method createTextActions.

protected List<IAction> createTextActions(ILanguageKit lk, IEntity targetEntity) {
    List<IAction> textActions = new ArrayList<IAction>();
    IGEFEditorKit editorKit = (IGEFEditorKit) (targetEntity.wGetLanguageKit().equals(lk) ? ReflectionFactory.getEditorKit(targetEntity) : lk.getDefaultEditorKit());
    for (Object[] textAction : E4Utils.textActionsFor(lk, ((IGEFEditorKit) editorKit).getActionFactory().textActions())) {
        EntityDescriptor<?> ed = (EntityDescriptor<?>) textAction[1];
        if (Matcher.matchImpl(ed, targetEntity)) {
            @SuppressWarnings("unchecked") Class<IUpdatableAction> actionClass = (Class<IUpdatableAction>) textAction[2];
            try {
                IUpdatableAction action = actionClass.getConstructor(IEclipseContext.class).newInstance(contextProvider.getContext());
                action.update();
                if (action.isEnabled())
                    textActions.add(action);
            } catch (Exception e) {
            }
        }
    }
    return textActions;
}
Also used : IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) IUpdatableAction(org.whole.lang.ui.actions.IUpdatableAction) MalformedURLException(java.net.MalformedURLException) EntityDescriptor(org.whole.lang.reflect.EntityDescriptor) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit)

Aggregations

IGEFEditorKit (org.whole.lang.ui.editor.IGEFEditorKit)8 ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)3 IKeyHandler (org.whole.lang.ui.keys.IKeyHandler)3 ArrayList (java.util.ArrayList)2 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)2 IAction (org.eclipse.jface.action.IAction)2 EntityDescriptor (org.whole.lang.reflect.EntityDescriptor)2 ILanguageKit (org.whole.lang.reflect.ILanguageKit)2 IUpdatableAction (org.whole.lang.ui.actions.IUpdatableAction)2 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1 Point (org.eclipse.draw2d.geometry.Point)1 EditPart (org.eclipse.gef.EditPart)1 RootEditPart (org.eclipse.gef.RootEditPart)1 KeySequence (org.eclipse.jface.bindings.keys.KeySequence)1 RootFragment (org.whole.lang.commons.model.RootFragment)1 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)1 IEditorKit (org.whole.lang.reflect.IEditorKit)1 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)1 EditPoint (org.whole.lang.ui.tools.EditPoint)1