Search in sources :

Example 6 with IGEFEditorKit

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

the class ActionRegistry method registerKeyActions.

public void registerKeyActions(AbstractKeyHandler keyHandler) {
    keyHandler.put(KeySequence.getInstance(KeyStroke.getInstance(SWT.F2)), true, actionFactory.createDirectEditAction());
    for (IEditorKit editorKit : ReflectionFactory.getEditorKits()) {
        for (ILanguageKit lk : ReflectionFactory.getLanguageKits(false)) {
            if (!editorKit.canApply(lk))
                continue;
            for (Object[] textAction : E4Utils.textActionsFor(lk, ((IGEFEditorKit) editorKit).getActionFactory().textActions())) {
                KeySequence keySequence = (KeySequence) textAction[0];
                Class<IUpdatableAction> actionClass = (Class<IUpdatableAction>) textAction[2];
                try {
                    IUpdatableAction action = actionClass.getConstructor(IEclipseContext.class).newInstance(context);
                    keyHandler.put(editorKit, keySequence, true, action);
                } catch (Exception e) {
                }
            }
        }
    }
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) IEditorKit(org.whole.lang.reflect.IEditorKit) IUpdatableAction(org.whole.lang.ui.actions.IUpdatableAction) KeySequence(org.eclipse.jface.bindings.keys.KeySequence) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 7 with IGEFEditorKit

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

the class ClipboardUtils method createEditPart.

public static IEntityPart createEditPart(EditPartFactory factory, IEntity entity) {
    IGEFEditorKit commonsEditorKit = (IGEFEditorKit) ReflectionFactory.getEditorKit("org.whole.lang.commons.ui.CommonsEditorKit");
    RootFragment rootFragment = CommonsEntityFactory.instance.createRootFragment(entity.wGetAdapter(CommonsEntityDescriptorEnum.Any));
    EditPart rootFragmentPart = commonsEditorKit.getPartFactory().createEditPart(null, rootFragment);
    IEntityPart entityPart = (IEntityPart) factory.createEditPart(rootFragmentPart, entity);
    EntityUtils.remove(entity);
    return entityPart;
}
Also used : RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) RootFragment(org.whole.lang.commons.model.RootFragment) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 8 with IGEFEditorKit

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

the class TextualDragTracker method handleDoubleClick.

@Override
protected boolean handleDoubleClick(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.calculateDoubleClickSelection(editPoint);
        performSelectionUpdate(selection, true);
        return true;
    }
    return super.handleDoubleClick(button);
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) IKeyHandler(org.whole.lang.ui.keys.IKeyHandler)

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