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];
}
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;
}
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;
}
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;
}
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;
}
Aggregations