| import org.eclipse.emf.common.util.URI |
| import org.eclipse.emf.examples.extlibrary.Book |
| import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory |
| import org.eclipse.emf.examples.extlibrary.Library |
| import org.eclipse.emf.examples.extlibrary.Writer |
| import org.eclipse.emf.parsley.examples.firstexample.FirstexampleSaveableTreeFormView |
| import org.eclipse.emf.parsley.edit.IEditingStrategy |
| import org.eclipse.emf.parsley.edit.UndoableEditingStrategy |
| |
| /* org.eclipse.emf.parsley.examples.firstexample EMF Parsley Dsl Module file */ |
| module org.eclipse.emf.parsley.examples.firstexample { |
| |
| parts { |
| viewpart org.eclipse.emf.parsley.examples.firstexample { |
| viewname "My Library Tree Form" |
| viewclass FirstexampleSaveableTreeFormView |
| } |
| } |
| |
| bindings { |
| type IEditingStrategy -> UndoableEditingStrategy |
| value int TreeFormSashStyle -> SWT.HORIZONTAL |
| } |
| |
| configurator { |
| resourceURI { |
| FirstexampleSaveableTreeFormView -> { |
| return URI.createFileURI( System.getProperty("user.home") + "/MyLibrary.library" ); |
| } |
| } |
| } |
| |
| resourceManager { |
| initializeResource { |
| it.getContents += EXTLibraryFactory.eINSTANCE.createLibrary |
| } |
| } |
| |
| featuresProvider { |
| features { |
| Library -> name |
| Writer -> name, address, books |
| Book -> author, title, category |
| } |
| } |
| |
| featureCaptionProvider { |
| text { |
| Book : author -> "Written by:" |
| Writer : name -> "Name:" |
| } |
| } |
| |
| labelProvider { |
| text { |
| Book b -> { '"' + b.title + '"' } |
| Writer w -> { w.name } |
| } |
| } |
| |
| menuBuilder { |
| val factory = EXTLibraryFactory.eINSTANCE |
| |
| emfMenus { |
| Writer w -> #[ |
| actionChange("New book", w.eContainer as Library, |
| [ |
| library | |
| val book = factory.createBook |
| library.books += book |
| book.title = "A new book" |
| book.author = w |
| ] |
| ), |
| // in this variant undo will only unset the book's author, |
| // but it will not remove the added code from the library |
| // since we record changes concerning the writer only |
| actionChange("New book (variant)", w, |
| [ |
| writer | |
| val library = writer.eContainer as Library |
| val book = factory.createBook |
| library.books += book |
| book.title = "A new book" |
| book.author = w |
| ] |
| ) |
| ] |
| Book b -> #[ |
| actionChange("New writer", b.eContainer as Library, |
| [ |
| library | |
| val writer = factory.createWriter |
| library.writers += writer |
| writer.name = "A new writer" |
| writer.books += b |
| ] |
| ), |
| actionAdd("New book (same title)", |
| (b.eContainer as Library).books, |
| factory.createBook, |
| [title = b.title] |
| ) |
| ] |
| } |
| } |
| |
| viewerContentProvider { |
| children { |
| Library -> { |
| writers + books |
| } |
| } |
| } |
| } |