Multiline text editor in MPS (de.slisson.mps.editor.multiline)

  • 9
  • 44

Hello everyone :).
I'm trying to use multi-line editor as mentioned by MPS Hero Markus Voelter here: http://www.youtube.com/watch?v=Y96HU44FjZ4 .

I installed the relevant MPS plugin.

Now I'm trying to enrich my concept editor with the multi-line editing.

I'm not sure how it should be used...

I've tried through cell provider:

Custom cell:
cell provider (editorContext, node)->AbstractCellProvider {
new MultilineCellProvider(node, editorContext);
}

Nothing new seems to show while actually editing my concept instances.
And how do I specify which property/role it should use?

Any help greatly appreciated!


I also got this exception:

<null>
java.lang.NullPointerException
java.lang.NullPointerException
 at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
 at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:1016)
 at jetbrains.mps.smodel.runtime.base.BaseConstraintsDescriptor.getProperty(BaseConstraintsDescriptor.java:224)
 at jetbrains.mps.smodel.SNodeAccessUtilImpl.getPropertyImpl(SNodeAccessUtilImpl.java:58)
 at org.jetbrains.mps.openapi.model.SNodeAccessUtil.getProperty(SNodeAccessUtil.java:35)
 at jetbrains.mps.nodeEditor.cells.PropertyAccessor$1.compute(PropertyAccessor.java:92)
 at jetbrains.mps.nodeEditor.cells.PropertyAccessor$1.compute(PropertyAccessor.java:86)
 at jetbrains.mps.smodel.NodeReadAccessCasterInEditor.runCleanPropertyAccessAction(NodeReadAccessCasterInEditor.java:115)
 at jetbrains.mps.nodeEditor.cells.PropertyAccessor.doGetValue(PropertyAccessor.java:86)
 at jetbrains.mps.nodeEditor.cells.PropertyAccessor.getText(PropertyAccessor.java:69)
 at de.slisson.mps.editor.multiline.cells.EditorCell_Multiline.<init>(Unknown Source)
 at de.slisson.mps.editor.multiline.cells.EditorCell_Multiline.create(Unknown Source)
 at de.slisson.mps.editor.multiline.cellProviders.MultilineCellProvider.createEditorCell(Unknown Source)
 at ProteinLang.editor.StringField_Editor.createCustom_e1wy3l_d0(StringField_Editor.java:312)
 at ProteinLang.editor.StringField_Editor.createCollection_e1wy3l_a(StringField_Editor.java:35)
 at ProteinLang.editor.StringField_Editor.createEditorCell(StringField_Editor.java:25)
 at jetbrains.mps.nodeEditor.cells.EditorCellFactoryImpl.createEditorCell(EditorCellFactoryImpl.java:75)
 at jetbrains.mps.nodeEditor.EditorManager.createEditorCell_internal(EditorManager.java:417)
 at jetbrains.mps.nodeEditor.EditorManager.createEditorCell(EditorManager.java:374)
 at jetbrains.mps.nodeEditor.EditorContext.createNodeCell(EditorContext.java:161)
 at jetbrains.mps.nodeEditor.EditorContext.createNodeCell(EditorContext.java:202)
 at jetbrains.mps.lang.editor.cellProviders.RefNodeListHandler.createNodeCell(RefNodeListHandler.java:86)
 at jetbrains.mps.lang.editor.cellProviders.RefNodeListHandler.createNodeCell(RefNodeListHandler.java:74)
 at jetbrains.mps.nodeEditor.DefaultEditor$ListHandler.createNodeCell(DefaultEditor.java:478)
 at jetbrains.mps.nodeEditor.cellProviders.AbstractCellListHandler.createInnerCells(AbstractCellListHandler.java:195)
 at jetbrains.mps.nodeEditor.cellProviders.AbstractCellListHandler.createCells(AbstractCellListHandler.java:175)
 at jetbrains.mps.nodeEditor.cellProviders.AbstractCellListHandler.createCells(AbstractCellListHandler.java:158)
 at jetbrains.mps.nodeEditor.DefaultEditor.addChildCellForNonNullConcept(DefaultEditor.java:336)
 at jetbrains.mps.nodeEditor.DefaultEditor.addChildren(DefaultEditor.java:326)
 at jetbrains.mps.nodeEditor.DefaultEditor.addPropertiesAndChildren(DefaultEditor.java:121)
 at jetbrains.mps.nodeEditor.DefaultEditor.createEditorCell(DefaultEditor.java:98)
 at jetbrains.mps.nodeEditor.cells.EditorCellFactoryImpl.createEditorCell(EditorCellFactoryImpl.java:87)
 at jetbrains.mps.nodeEditor.EditorManager.createEditorCell_internal(EditorManager.java:417)
 at jetbrains.mps.nodeEditor.EditorManager.createEditorCell(EditorManager.java:374)
 at jetbrains.mps.nodeEditor.EditorContext.createNodeCell(EditorContext.java:161)
 at jetbrains.mps.nodeEditor.EditorContext.createNodeCell(EditorContext.java:202)
 at jetbrains.mps.nodeEditor.EditorContext.createNodeCell(EditorContext.java:58)
 at jetbrains.mps.lang.editor.cellProviders.RefNodeCellProvider.createRefCell(RefNodeCellProvider.java:36)
 at jetbrains.mps.lang.editor.cellProviders.AbstractReferentCellProvider.createCell_internal(AbstractReferentCellProvider.java:145)
 at jetbrains.mps.lang.editor.cellProviders.AbstractReferentCellProvider.createEditorCell(AbstractReferentCellProvider.java:101)
 at jetbrains.mps.nodeEditor.DefaultEditor.addChildCellForNonNullConcept(DefaultEditor.java:344)
 at jetbrains.mps.nodeEditor.DefaultEditor.addChildren(DefaultEditor.java:326)
 at jetbrains.mps.nodeEditor.DefaultEditor.addPropertiesAndChildren(DefaultEditor.java:121)
 at jetbrains.mps.nodeEditor.DefaultEditor.createEditorCell(DefaultEditor.java:98)
 at jetbrains.mps.nodeEditor.cells.EditorCellFactoryImpl.createEditorCell(EditorCellFactoryImpl.java:87)
 at jetbrains.mps.nodeEditor.EditorManager.createEditorCell_internal(EditorManager.java:417)
 at jetbrains.mps.nodeEditor.EditorManager.createEditorCell(EditorManager.java:374)
 at jetbrains.mps.nodeEditor.EditorManager.createRootCell(EditorManager.java:161)
 at jetbrains.mps.nodeEditor.EditorManager.createRootCell(EditorManager.java:134)
 at jetbrains.mps.nodeEditor.EditorContext.createRootCell(EditorContext.java:167)
 at jetbrains.mps.nodeEditor.NodeEditorComponent.createRootCell(NodeEditorComponent.java:128)
 at jetbrains.mps.nodeEditor.EditorComponent$33$1.run(EditorComponent.java:1902)
 at jetbrains.mps.nodeEditor.EditorComponent.runSwapCellsActions(EditorComponent.java:2863)
 at jetbrains.mps.nodeEditor.EditorComponent.access$3400(EditorComponent.java:219)
 at jetbrains.mps.nodeEditor.EditorComponent$33.run(EditorComponent.java:1898)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess.runReadAction(WorkbenchModelAccess.java:105)
 at jetbrains.mps.project.ProjectRepository$ProjectModelAccess.runReadAction(ProjectRepository.java:99)
 at jetbrains.mps.nodeEditor.EditorComponent.rebuildEditorContent(EditorComponent.java:1880)
 at jetbrains.mps.nodeEditor.EditorComponent.handleEvents(EditorComponent.java:3006)
 at jetbrains.mps.nodeEditor.EditorComponent.access$4600(EditorComponent.java:219)
 at jetbrains.mps.nodeEditor.EditorComponent$MyEventsCollector.eventsHappened(EditorComponent.java:3345)
 at jetbrains.mps.smodel.EventsCollector$2.run(EventsCollector.java:203)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess.runWriteAction(WorkbenchModelAccess.java:148)
 at jetbrains.mps.smodel.EventsCollector.flush(EventsCollector.java:198)
 at jetbrains.mps.smodel.EventsCollector$MyModelAccessAdapter.commandFinished(EventsCollector.java:243)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess.onCommandFinished(WorkbenchModelAccess.java:793)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess.decCommandLevel(WorkbenchModelAccess.java:750)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess.access$2900(WorkbenchModelAccess.java:55)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess$CommandRunnable$1.run(WorkbenchModelAccess.java:833)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess$4.run(WorkbenchModelAccess.java:161)
 at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1013)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess.runWriteAction(WorkbenchModelAccess.java:168)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess$CommandRunnable.run(WorkbenchModelAccess.java:826)
 at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124)
 at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:99)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess.runWriteActionInCommand(WorkbenchModelAccess.java:637)
 at jetbrains.mps.ide.smodel.WorkbenchModelAccess.runWriteActionInCommand(WorkbenchModelAccess.java:632)
 at jetbrains.mps.project.ProjectRepository$ProjectModelAccess.executeCommand(ProjectRepository.java:119)
 at jetbrains.mps.nodeEditor.EditorComponent.executeCommand(EditorComponent.java:2577)
 at jetbrains.mps.nodeEditor.EditorContext.executeCommand(EditorContext.java:447)
 at jetbrains.mps.nodeEditor.actions.ActionHandlerImpl.executeAction(ActionHandlerImpl.java:52)
 at jetbrains.mps.nodeEditor.actions.ActionHandlerImpl.executeAction(ActionHandlerImpl.java:42)
 at jetbrains.mps.ide.editor.actions.EditorActionUtils.callInsertAction(EditorActionUtils.java:78)
 at jetbrains.mps.ide.editor.actions.Insert_Action.doExecute(Insert_Action.java:71)
 at jetbrains.mps.workbench.action.BaseAction.actionPerformed(BaseAction.java:138)
 at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:564)
 at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:611)
 at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:463)
 at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:206)
 at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:480)
 at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:334)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Question is not answered.
Import the multiline language into your editor model (Ctrl+L) and you will find a new entry in the completion menu for each property that look like the normal property but ends with "\n". For example, for a property "name" you will find the entry "{name}\n".

Hallo Sascha.
Thanks for your reply, appreciated!

I have tried again.
I have added all the de.slisson models to my editor's deps just in case.

Here is how the deps look:
2014-03-06_23-43-38_Model_properties_for_TestMultilineEditLanguage.editor.png
- please take a look if they are ok.

I got this exception after adding the deps: http://youtrack.jetbrains.com/issue/MPS-19386 - please take a look.

I don't see the "{name}\n" thingy on the completion list. Please correct me if I'm looking in the wrong place:

2014-03-06_23-43-14_TestMultilineEdit_-_[CUsersKarolDepkaMPSProjectsTestMultilineEdit]_-_nodeTestMul.png


Thanks in advance for further help how to proceed!

Best Wishes,
Karol Depka

In the "Used Languages" tab you need to add the multiline language. You don't need to add any models.
The exception is caused by your custom cell and the wrong usage of the MultilineCellProvider (Don't use it directly. The correct code is generated by the "...\n" cell).

By the way, what type should be the property? Ordinary "string" property? Or something to do with CellModel_Multiline ?

Yes, you can use a normal string property.

Hello Sascha. Thanks a lot!
It worked the way you described.
I'm planning to make a short video tutorial showing this proper process. Unless there is some video like that already?

I've noticed that text selection by shift+arrows does not quite work correctly yet. Although selection by shift + mouse button works good enough, making it a suitable workaround.

Next thing I want to try is your rich text editor (with embedded nodes).
Is it already stable enough for general use?

Best Wishes. – Karol Depka Pradzinski.

In richtext it's the other way around: shift+arrows works but shift+mouse doesn't. We use the richtext plugin in mbeddr and therefore found and closed a lot of issues. So there shouldn't be any big problems, if you want to use it. Just use the latest version from the master branch on github.

Thanks.
Are there binary package releases for the richtext plugin? I see "1.0" "6 months ago" on GitHub.
Better to use this release or compile from sources?
If from sources, then master branch or is there some branch marked as stable?

And what do you think about the tutorial video? Is there such a video already, or is it nice if I make it, to facilitate the usage for people who might wanna try it?

No, there are no binaries for MPS 3.0. The master branch is the most stable version.

A video might be helpful for beginners. I can put a link to the video on the github page if you like.