Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Problem with Property page
Problem with Property page [message #1424164] Mon, 15 September 2014 15:14 Go to next message
guillen antonio is currently offline guillen antonioFriend
Messages: 6
Registered: July 2013
Junior Member
I am newbie with Eclipse e4 and to build an 100% e4 aplication. I can doa lot but on Property I have a problem:

I have an EMF Model , I generated the Java classes of my model the edit and editor plugins.
In my application I have an explorer, and when I select an object in the explorere I can for example do a graphic represenntaion of it (). But I can't sett it in a "Property Page". I mmust recognize that I havee diffculties to understand the generated code in .editor.

My part Propety is build with 2 columns "Property" and"Value" bu thhe items when Ii selct an object in the explorer, I don't unbeecauauss Igo through

myProperty.handleEntrySelection(ExplorerPart.getTreeViewer().getSelection()); avec la bon objet.


Here is my code:


package galera3D.parts.explorer;

import galera.supports.provider.SupportsItemProviderAdapterFactory;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;

import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.views.properties.IPropertySourceProvider;
import org.eclipse.ui.views.properties.PropertySheetPage;

public class PropertiesEditorPart {

ExtendedPropertySheetPage myProperty;
private AdapterFactoryEditingDomain editingDomain;
ComposedAdapterFactory adapterFactory;
List<PropertySheetPage> propertySheetPages = new ArrayList<PropertySheetPage>();

@PostConstruct
public void createComposite(Composite parent) {
ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);

adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new SupportsItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());

// Create the command stack that will notify this editor as commands are executed.
//
BasicCommandStack commandStack = new BasicCommandStack();


// Create the editing domain with a special command stack.
//
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
parent.setLayout(new FillLayout());
myProperty = new ExtendedPropertySheetPage(editingDomain){
@Override
public void setSelectionToViewer(List<?> selection) {
PropertiesEditorPart.this.setFocus();
}

@Override
public void setActionBars(IActionBars actionBars) {

}
@Override
public void handleEntrySelection(ISelection selection)
{
super.handleEntrySelection(selection);
objectsToSelect.clear();
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection)selection;

if (structuredSelection.size() == 1)
{
Vector<ISelection> v = new Vector<ISelection>();
v.add(selection);
setSelectionToViewer(v);
Object object = structuredSelection.getFirstElement();
addObjectToSelect(object);
}
}
locateValueAction.setEnabled(!objectsToSelect.isEmpty());
}

};

{}
IPropertySourceProvider provider = new AdapterFactoryContentProvider(adapterFactory);
myProperty.setPropertySourceProvider(provider);
myProperty.createControl(parent);
myProperty.getSite().setSelectionProvider(ExplorerPart.getTreeViewer());

}


@Focus
public boolean setFocus() {
if(myProperty != null) return myProperty.getControl().setFocus();
return false;
}

@Inject
public void receiveSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Object o) {
if(o != null) {
if(myProperty != null) {
myProperty.handleEntrySelection(ExplorerPart.getTreeViewer().getSelection());
}
}
setFocus();
}


}
Re: Problem with Property page [message #1425420 is a reply to message #1424164] Wed, 17 September 2014 09:29 Go to previous messageGo to next message
Hussein MHANNA is currently offline Hussein MHANNAFriend
Messages: 45
Registered: February 2014
Location: LAVAL
Member
Hi,

Can you please clarify what is exactly your problem?

FYI, a pure E4 application can't use anything in org.eclipse.ui.*.

Regards,

Hussein


ALL4TEC
Re: Problem with Property page [message #1425578 is a reply to message #1425420] Wed, 17 September 2014 14:03 Go to previous message
guillen antonio is currently offline guillen antonioFriend
Messages: 6
Registered: July 2013
Junior Member
My part Propety is build with 2 columns "Property" and"Value", I create it in Application.e4xmi.

My Explorer work fine, If select an item in it, I go through the method "receiveSelection". In this method I call myProperty.handleEntrySelection(ExplorerPart.getTreeViewer().getSelection()); with the select item. Has I have set SupportsItemProviderAdapterFactory() in my editingDomain. I was thinking that the propertyPage will set all object (attributs, ....) has they are part of SupportsItem. But in my property page I have nothing.

In reality my problem is to try to reuse the .edit features in my application. And I must recognize that this is not clear for me.

Thanks for your help

Antonio
Previous Topic:How to launch CSS Spy for my RCP?
Next Topic:Listening for Activation of new childcontext?
Goto Forum:
  


Current Time: Fri Apr 26 16:41:27 GMT 2024

Powered by FUDForum. Page generated in 0.03261 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top