Home » Modeling » EMF Parsley » Master-Detail Form Editor using Parsley
Master-Detail Form Editor using Parsley [message #1270882] |
Thu, 13 March 2014 18:30  |
Alex Kravets Messages: 561 Registered: November 2009 |
Senior Member |
|
|
Hello,
I am trying to write a Master-Detail FormEditor and using Parsley as the base for communicating with my model. For this I took EmfAbstractEditor and made it extend FormEditor while adding necessary classes as described in Eclipse Forms: Rich UI for the Rich Client (Master/Details block).
The TreeViewer loads into section of the form. However, I am facing an issue that I am not sure what the cause of is. When I chose context menu from root node to add child, child is added successfully, but if I want to add another child nothing happens. I need to close the editor, open it again and only then I am able to add child. Another issue is where my model has constraint on an element of 1, if I add that element and open context menu to add children, that element is not disabled. Now, if I open my file with EmfTreeEditor everything works fine. I am not sure what's going on here so I was hoping to get some help here as someone might have faced the same issue.
Here are what I think the most relevant classes:
ScrolledPropertiesBlock
AbstractChannelComponentEditor
InletEditor (AbstractChannelComponentEditor extender)
Thanks,
Alex
[Updated on: Thu, 13 March 2014 18:31] Report message to a moderator
|
|
|
Re: Master-Detail Form Editor using Parsley [message #1271167 is a reply to message #1270882] |
Fri, 14 March 2014 12:14   |
|
On 13/03/2014 19:30, Alex Kravets wrote:
> Hello,
>
> I am trying to write a Master-Detail FormEditor and using Parsley as the
> base for communicating with my model. For this I took EmfAbstractEditor
> and made it extend FormEditor while adding necessary classes as
> described in https://www.eclipse.org/articles/Article-Forms/article.html
> (Master/Details block).
>
> The TreeViewer loads into section of the form. However, I am facing an
> issue that I am not sure what the cause of is. When I chose context menu
> from root node to add child, child is added successfully, but if I want
> to add another child nothing happens. I need to close the editor, open
> it again and only then I am able to add child. Another issue is where my
> model cast constraint on an element of 1, if I add that element and open
> context menu to add children, that element is not disabled. Now, if I
> open my file with EmfTreeEditor everything works fine. I am not sure
> what's going on here so I was hoping to get some help here as someone
> might have faced the same issue.
Hi Alex
if it works fine with the EmfTreeEditor (thus you can add several
children, but the option is disabled with the constraint of 1), then
probably something is wrong with the injection and the added form editor
part.
We provide a form factory that already takes care of initializing the
form fields and setup databinding.
We still have to implement an editor with the treeviewer and the form;
however, we have a view with the treeviewer and the form (and the view
is saveable, thus it can act as an editor); would you mind try that view
and see if it all works fine?
In the meantime, I'll try to come up with a reusable implementation of
an editor with tree and form.
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| |
Re: Master-Detail Form Editor using Parsley [message #1384541 is a reply to message #1271224] |
Thu, 29 May 2014 09:06   |
|
On 14/03/2014 16:01, Alex Kravets wrote:
> Hi Lorenzo,
>
> Yes, all the views Parsley provides work fine. Incidentally, with
> current attempt at Master-Detail editor I am experiencing the same issue
> when I was using Master-Detail editor page in generated EMF Editor. The
> only way TreeViewer works only if generated EMF viewer was already
> loaded, without it my TreeViewer would not work. I thought there was an
> issue with my implementation, but as I said same thing happens when I
> use Parsley emf editor as base. I've tried to debug the code, but so far
> didn't find anything.
>
> Thanks,
> Alex
Alex, if I remember correctly you posted in another forum that you
solved the issue, right?
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: Master-Detail Form Editor using Parsley [message #1604356 is a reply to message #1384541] |
Fri, 06 February 2015 20:26  |
Alex Kravets Messages: 561 Registered: November 2009 |
Senior Member |
|
|
Hi Lorenzo,
Sorry didn't answer sooner as I didn't get notification that you replied and forgot to check this thread.
Here is my code for ScrolledPropertiesBlock:
// Create a page for the selection tree view.
if (editor.getEditorInput() instanceof InMemoryChannelEditorInput) {
emfTreeViewer = new TreeViewer(tree);
DocumentRootImpl root = (DocumentRootImpl) ChannelFactory.eINSTANCE.createDocumentRoot();
root.setRInlineChannel(((InMemoryChannelEditorInput)editor.getEditorInput()).getChannel());
editor.getViewiInitializer().initialize(emfTreeViewer, root);
} else {
URI resourceURI = EditUIUtil.getURI(editor.getEditorInput());
LoadResourceResponse response = editor.getResourceLoader().getResource(editor.getEditingDomain(), resourceURI);
editor.handleProblems(response);
emfTreeViewer = editor.getTreeViewerFactory().createTreeViewer(tree, resourceURI);
editor.getViewiInitializer().initialize(emfTreeViewer, response.getResource());
enableCellEditing();
}
emfTreeViewer.setContentProvider(new AdapterFactoryContentProvider(editor.getAdapterFactory()));
ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
ChannelValidator channelValidator = ((ChannelEditor)editor).getChannelValidator();
ChannelTreeViewerDecorator labelDecorator = (ChannelTreeViewerDecorator) PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(ChannelTreeViewerDecorator.ID);
labelDecorator.setChannelValidator(channelValidator);
emfTreeViewer.setLabelProvider(new DecoratingStyledCellLabelProvider(new ChannelAdapterFactoryLabelProvider(editor.getAdapterFactory(), tree.getFont(), ((ChannelEditor)editor).getDescriptorUtils()), labelDecorator, null));
editor.setSelectionOnRoot(emfTreeViewer);
new AdapterFactoryTreeEditor(emfTreeViewer.getTree(), editor.getAdapterFactory());
editor.createContextMenuFor(emfTreeViewer);
emfTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
Object selectedObject = ((StructuredSelection)event.getSelection()).getFirstElement();
if (previousSelection != null && previousSelection.equals(selectedObject)) {
return;
}
previousSelection = selectedObject;
managedForm.fireSelectionChanged(spart, event.getSelection());
buttonsStateProvider(event.getSelection());
}
private void buttonsStateProvider(ISelection iSelection) {
EObject object = (EObject) ((StructuredSelection) iSelection).getFirstElement();
// if( object instanceof Inlet
// || object instanceof Route
// || object instanceof Outlet
// || object instanceof Transformer){
//
// List<String> extList = ChannelActivator.instance.getSupportedFileExtensions();
// if(extList.size() > 1){
// importComponentButton.setEnabled(true);
// }
// }
updateUpDownBtnEnablement(object);
btnRemove.setEnabled(true);
}
});
emfTreeViewer.addSelectionChangedListener(editor.createSelectionChangedListener());
emfTreeViewer.expandAll();
emfTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
Object selection = ((StructuredSelection)event.getSelection()).getFirstElement();
if(selection instanceof Reference && ((Reference)selection).getRefId() != null) {
try {
String guid = ((Reference)selection).getRefId();
DependencyType dependencybyGUID = IWResourceManager.getInstance().getDependencybyGUID(((FileEditorInput) editor.getEditorInput()).getFile(), guid);
if (dependencybyGUID != null) {
IResource resource = WorkspaceUtil.getResource(new Path(dependencybyGUID.getPath()));
if (resource != null && resource instanceof IFile) {
WorkspaceUtil.openFileInEditor((IFile) resource);
}
}
} catch (CoreException e) {
return;
}
}
}
});
// set selection on element that was last added to the model
editor.getEditingDomain().getCommandStack().addCommandStackListener(new CommandStackListener() {
@Override
public void commandStackChanged(EventObject event) {
Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
if (mostRecentCommand != null) {
if(mostRecentCommand instanceof CreateChildCommand){
CreateChildCommand command = (CreateChildCommand)mostRecentCommand;
Collection<?> result = command.getResult();
Object next = result.iterator().next();
TreeItem item = new TreeItem(tree.getTopItem(), SWT.NONE);
item.setData(next);
emfTreeViewer.setSelection(new StructuredSelection(next), true);
emfTreeViewer.refresh();
}
}
}
});
Th most relevant code is last EditingDomain listener:
editor.getEditingDomain().getCommandStack().addCommandStackListener(new CommandStackListener() {
|
|
|
Goto Forum:
Current Time: Mon Sep 25 07:43:03 GMT 2023
Powered by FUDForum. Page generated in 0.02788 seconds
|