|
Re: [Property View] Shared between model explorer tree, EMF editor and Sirius [message #1738976 is a reply to message #1738855] |
Tue, 26 July 2016 13:13 |
Melanie Bats Messages: 35 Registered: July 2009 |
Member |
|
|
Hello David,
Le 25/07/2016 à 18:18, Daveluy Yannick a écrit :
> I am using Sirius 4.0 and I would like to have the same property view
> (EEF like) between the Model explorer tree, the EMF editor (generated
> from the genmodel) and Sirius.
>
> For the moment the property view of the Model explorer tree and the EMF
> editor are the default ones : table.
>
> Is it possible to add an extension in the Viewpoint specification project ?
For the Model Explorer, we are working on it, it should be
available in the next 4.1.0 release. Have a look to the associated
bugzilla ticket : https://bugs.eclipse.org/bugs/show_bug.cgi?id=489287
For providing the same properties view for the EMF editor than the ones
you defined for Sirius, it would be a little bit more tricky. The Sirius
properties view are based on EEF and so we provide a bridge for Sirius
to convert the Sirius properties view specification into EEF properties
view. This bridge is not extensible and reusable for another editor than
the Sirius one.
So if you want to get the same properties view for your EMF editor you
should have to provide your own custom bridge which would use the
transactional editing domain provided by Sirius.
Have a look to the EEF Tab Descriptor Provider extension point to
provide your own bridge :
http://help.eclipse.org/neon/topic/org.eclipse.eef.documentation/pages/developerguide/extensionpoints.html?cp=17_2_0_1#eeftabdescriptorprovider
Another way to do it, is by associating the Sirius property sheet page
provider to your editor thanks to the
org.eclipse.sirius.ui.siriusPropertySheetPageProvider extension point.
<extension
point="org.eclipse.sirius.ui.siriusPropertySheetPageProvider">
<siriusPropertySheetPageProvider
class="x.x.x.EEFPropertySheetPageProvider"
contributorId="IDX">
</siriusPropertySheetPageProvider>
</extension>
import org.eclipse.eef.properties.ui.api.EEFTabbedPropertySheetPage;
public class EEFPropertySheetPageProvider implements
ISiriusPropertySheetPageProvider {
/**
* Simple constructor
*/
public EEFPropertySheetPageProvider() {
}
@Override
public IPropertySheetPage getPropertySheetPage(Object source,
String contributorId) {
return new EEFTabbedPropertySheetPage(source, contributorId);
}
}
Then in your editor you have to implement
org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor
with:
@Override
public String getContributorId() {
return "IDX"; //$NON-NLS-1$
}
and then overrides:
@Override
public <T> T getAdapter(Class<T> type) {
if (type == IPropertySheetPage.class) {
// Plug this editor into the property view mechanism
contributedPage = new EEFTabbedPropertySheetPage(this,
getContributorId());
if (contributedPage != null) {
return (T) contributedPage;
}
}
return super.getAdapter(type);
}
Finally, you have to add a listener to your viewer to notify
contributedPage that the selection change:
private final class PropertyViewUpdater implements
ISelectionChangedListener {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (contributedPage != null) {
// Only display the property page of semantic element
if (hasSemanticElementSelected(event)) {
contributedPage.selectionChanged(getViewSite().getPart(),
event.getSelection());
} else {
contributedPage.selectionChanged(getViewSite().getPart(),
new StructuredSelection(Collections.emptyList()));
}
}
}
/**
* Returns <code>true</code> if the selection has at least one
semantic element
*
* @param event a {@link SelectionChangedEvent}
* @return <code>true</code> if the selection has at least one
semantic element,<code>false</code> otherwise
*/
private boolean hasSemanticElementSelected(SelectionChangedEvent
event) {
return /* Find the semantic element from the selection */;
}
}
Regards,
Mélanie
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.23426 seconds