Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Getting two distinct editors in the same window
Getting two distinct editors in the same window [message #489206] Thu, 01 October 2009 20:19 Go to next message
Dominic Renaud is currently offline Dominic RenaudFriend
Messages: 16
Registered: July 2009
Junior Member
I've been working on a project that is trying to bridge two EMF-based modeling frameworks, and I was wondering if it was possible make both sides of a split editor window distinct.

At the bottom is the code I use to have two separate editors in the same window. The problem is that they are both treated as a single editor, due to the FMPActionBarContributor linked in the plugin.xml file. This means that when I click on the OWL side, the editor tries and fails to map it to an FMP class. As well, I cannot spawn children of the base OWL class, as all drop down menus run through the FMP editor.

I've been considering possibly using two separate editor Java classes, but I'm not sure how I'd bridge those into one window. It would probably get around the xml-enforced contributor, but I don't know how well it would work. However, this is probably the best solution in the interest of reducing coupling.

Is there any way to have two separate, distinct editors occupying the same window in separate .java files? Am I even going about this the right way?

public void createPages() {
		// Creates the model from the editor input
		//
		createModel();

		// Michal: get project, model, metamodel and metametamodel
		FmpResourceImpl o = (FmpResourceImpl) editingDomain.getResourceSet()
		.getResources().get(0);
		project = (Project) o.getAllContents().next();

		model = project.getModel();
		NodeIdDictionary.INSTANCE.visit(null, model);
		metaModel = project.getMetaModel();
		NodeIdDictionary.INSTANCE.visit(null, metaModel);
		metaMetaModel = project.getMetaMetaModel();
		NodeIdDictionary.INSTANCE.visit(null, metaMetaModel);
		OWLGraph owlgraph = OWLFactoryImpl.eINSTANCE.createOWLGraph();
		Ontology ontology = new OntologyImpl() {};


		// Create a page for the modeling view.
		//
		{
			ViewerPane leftViewPane =
				new ViewerPane(getSite().getPage(), FmpEditor.this) {
				public Viewer createViewer(Composite composite) {

					Tree tree = new Tree(composite, SWT.MULTI);
					TreeViewer newTreeViewer = new TreeViewer(tree);
					return newTreeViewer;
				}
				public void requestActivation() {
					super.requestActivation();
					setCurrentViewerPane(this);
				}
			};

			SplitViewPane rightViewPane = 
				new SplitViewPane(getSite().getPage(), FmpEditor.this) {
				public void requestActivation() {
					super.requestActivation();
					setCurrentViewerPane(this);
				}
			};
			//Composites create a split window. The FMP model is on the
			//left, while the Ontology view will be on the right.
			//			viewerPane.createControl(getContainer());

			SashForm compositeTop = new SashForm(getContainer(), SWT.HORIZONTAL);

			leftViewPane.createControl(compositeTop);
			rightViewPane.createControl(compositeTop);

			modelingViewer = (TreeViewer) leftViewPane.getViewer();
			modelingViewer.setContentProvider(
					new AdapterFactoryContentProvider(adapterFactory));
			modelingViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
			drillDownAdapter = new FmpDrillDownAdapter(modelingViewer, adapterFactory);
			modelingViewer.setInput(new ProxyItemProvider(getAdapterFactory(), project, model));
			leftViewPane.setTitle(model);

			TreeViewer ontologyViewer = (TreeViewer) rightViewPane.getViewer();

			List factories = new ArrayList();
			factories.add(new ResourceItemProviderAdapterFactory());
			//			factories.add(new FmpItemProviderAdapterFactory());
			factories.add(new OWLAdapterFactory());
			factories.add(new ReflectiveItemProviderAdapterFactory());

			ComposedAdapterFactory ontologyAdapter = new ComposedAdapterFactory(factories);
			BasicCommandStack commandStack = new BasicCommandStack();

			AdapterFactoryEditingDomain ontologyDomain = 
				new AdapterFactoryEditingDomain(ontologyAdapter, commandStack, new HashMap());

			rightViewPane.setTitle("Ontology");
			ontologyViewer.setContentProvider(
					new AdapterFactoryContentProvider(ontologyAdapter));
			ontologyViewer.setLabelProvider(
					new AdapterFactoryLabelProvider(ontologyAdapter));
			//			drillDownAdapter = new FmpDrillDownAdapter(ontologyViewer, adapterFactory);
			ontologyViewer.setInput(
					new ProxyItemProvider(ontologyAdapter, owlgraph, ontology));

			new FmpAdapterFactoryTreeEditor(modelingViewer.getTree(),
					adapterFactory, editingDomain, modelingViewer);

			new OwlAdapterFactoryTreeEditor(ontologyViewer.getTree(),
					ontologyAdapter, ontologyDomain, ontologyViewer);

			createContextMenuFor(modelingViewer);
			createContextMenuFor(ontologyViewer);
			addDragAndDropSupport(modelingViewer);
			addDragAndDropSupport(ontologyViewer);

			int pageIndex = addPage(compositeTop);
			setPageText(pageIndex, getString("_UI_ModelingPage_label"));
		}

[Updated on: Thu, 01 October 2009 20:20]

Report message to a moderator

Re: Getting two distinct editors in the same window [message #489286 is a reply to message #489206] Fri, 02 October 2009 08:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Dominic,

Comments below.

Dominic Renaud wrote:
> I've been working on a project that is trying to bridge two EMF-based
> modeling frameworks, and I was wondering if it was possible make both
> sides of a split editor window distinct.
Eclipse itself allows two separate side by side editors using drag and
drop...
>
> At the bottom is the code I use to have two separate editors in the
> same window. The problem is that they are both treated as a single
> editor, due to the FMPActionBarContributor linked in the plugin.xml
> file. This means that when I click on the OWL side, the editor tries
> and fails to map it to an FMP class. As well, I cannot spawn children
> of the base OWL class, as all drop down menus run through the FMP editor.
>
> I've been considering possibly using two separate editor Java classes,
> but I'm not sure how I'd bridge those into one window.
It sounds like Eclipse's support for showing more than one editor in the
same window at the same time will make you happy.
> It would probably get around the xml-enforced contributor, but I don't
> know how well it would work. However, this is probably the best
> solution in the interest of reducing coupling.
>
> Is there any way to have two separate, distinct editors occupying the
> same window in separate .java files? Am I even going about this the
> right way?
>
> public void createPages() {
> // Creates the model from the editor input
> //
> createModel();
>
> // Michal: get project, model, metamodel and metametamodel
> FmpResourceImpl o = (FmpResourceImpl)
> editingDomain.getResourceSet()
> .getResources().get(0);
> project = (Project) o.getAllContents().next();
>
> model = project.getModel();
> NodeIdDictionary.INSTANCE.visit(null, model);
> metaModel = project.getMetaModel();
> NodeIdDictionary.INSTANCE.visit(null, metaModel);
> metaMetaModel = project.getMetaMetaModel();
> NodeIdDictionary.INSTANCE.visit(null, metaMetaModel);
> OWLGraph owlgraph = OWLFactoryImpl.eINSTANCE.createOWLGraph();
> Ontology ontology = new OntologyImpl() {};
>
>
> // Create a page for the modeling view.
> //
> {
> ViewerPane leftViewPane =
> new ViewerPane(getSite().getPage(), FmpEditor.this) {
> public Viewer createViewer(Composite composite) {
>
> Tree tree = new Tree(composite, SWT.MULTI);
> TreeViewer newTreeViewer = new TreeViewer(tree);
> return newTreeViewer;
> }
> public void requestActivation() {
> super.requestActivation();
> setCurrentViewerPane(this);
> }
> };
>
> SplitViewPane rightViewPane = new
> SplitViewPane(getSite().getPage(), FmpEditor.this) {
> public void requestActivation() {
> super.requestActivation();
> setCurrentViewerPane(this);
> }
> };
> //Composites create a split window. The FMP model is on the
> //left, while the Ontology view will be on the right.
> // viewerPane.createControl(getContainer());
>
> SashForm compositeTop = new SashForm(getContainer(),
> SWT.HORIZONTAL);
>
> leftViewPane.createControl(compositeTop);
> rightViewPane.createControl(compositeTop);
>
> modelingViewer = (TreeViewer) leftViewPane.getViewer();
> modelingViewer.setContentProvider(
> new AdapterFactoryContentProvider(adapterFactory));
> modelingViewer.setLabelProvider(new
> AdapterFactoryLabelProvider(adapterFactory));
> drillDownAdapter = new FmpDrillDownAdapter(modelingViewer,
> adapterFactory);
> modelingViewer.setInput(new
> ProxyItemProvider(getAdapterFactory(), project, model));
> leftViewPane.setTitle(model);
>
> TreeViewer ontologyViewer = (TreeViewer)
> rightViewPane.getViewer();
>
> // modelingViewer = (TreeViewer)
> viewerPane.getViewer();
> // modelingViewer.setContentProvider(
> // new
> AdapterFactoryContentProvider(adapterFactory));
> // modelingViewer.setLabelProvider(new
> AdapterFactoryLabelProvider(adapterFactory));
> // drillDownAdapter = new
> FmpDrillDownAdapter(modelingViewer, adapterFactory);
> // modelingViewer.setInput(new
> ProxyItemProvider(getAdapterFactory(), project, model));
> // viewerPane.setTitle(model);
>
> List factories = new ArrayList();
> factories.add(new ResourceItemProviderAdapterFactory());
> // factories.add(new
> FmpItemProviderAdapterFactory());
> factories.add(new OWLAdapterFactory());
> factories.add(new ReflectiveItemProviderAdapterFactory());
>
> ComposedAdapterFactory ontologyAdapter = new
> ComposedAdapterFactory(factories);
> BasicCommandStack commandStack = new BasicCommandStack();
>
> AdapterFactoryEditingDomain ontologyDomain =
> new AdapterFactoryEditingDomain(ontologyAdapter,
> commandStack, new HashMap());
>
> rightViewPane.setTitle("Ontology");
> ontologyViewer.setContentProvider(
> new AdapterFactoryContentProvider(ontologyAdapter));
> ontologyViewer.setLabelProvider(
> new AdapterFactoryLabelProvider(ontologyAdapter));
> // drillDownAdapter = new
> FmpDrillDownAdapter(ontologyViewer, adapterFactory);
> ontologyViewer.setInput(
> new ProxyItemProvider(ontologyAdapter, owlgraph,
> ontology));
>
> new FmpAdapterFactoryTreeEditor(modelingViewer.getTree(),
> adapterFactory, editingDomain, modelingViewer);
>
> new OwlAdapterFactoryTreeEditor(ontologyViewer.getTree(),
> ontologyAdapter, ontologyDomain, ontologyViewer);
>
> createContextMenuFor(modelingViewer);
> createContextMenuFor(ontologyViewer);
> addDragAndDropSupport(modelingViewer);
> addDragAndDropSupport(ontologyViewer);
>
> int pageIndex = addPage(compositeTop);
> setPageText(pageIndex, getString("_UI_ModelingPage_label"));
> }


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting two distinct editors in the same window [message #489982 is a reply to message #489286] Tue, 06 October 2009 18:11 Go to previous messageGo to next message
Dominic Renaud is currently offline Dominic RenaudFriend
Messages: 16
Registered: July 2009
Junior Member
Ed Merks wrote on Fri, 02 October 2009 04:37

Eclipse itself allows two separate side by side editors using drag and
drop...

It sounds like Eclipse's support for showing more than one editor in the
same window at the same time will make you happy.


How exactly do I invoke this? I have looked at drag-and-drop, and it doesn't seem to help much.
Re: Getting two distinct editors in the same window [message #490061 is a reply to message #489982] Wed, 07 October 2009 07:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Dominic,

Click down on the editor's tab (when you have two or more editors open),
and drag to any border until you see a box that fills 1/2 the editor
area. When you release, the dragged editor will fill that box while the
other editors will remain as they were, but smaller in the remaining area.


Dominic Renaud wrote:
> Ed Merks wrote on Fri, 02 October 2009 04:37
>> Eclipse itself allows two separate side by side editors using drag
>> and drop...
>>
>> It sounds like Eclipse's support for showing more than one editor in
>> the same window at the same time will make you happy.
>
>
> How exactly do I invoke this? I have looked at drag-and-drop, and it
> doesn't seem to help much.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting two distinct editors in the same window [message #490459 is a reply to message #490061] Thu, 08 October 2009 17:35 Go to previous messageGo to next message
Dominic Renaud is currently offline Dominic RenaudFriend
Messages: 16
Registered: July 2009
Junior Member
Okay, but is there a way to do that in the code itself, such that it starts out with the double editor?
Re: Getting two distinct editors in the same window [message #490559 is a reply to message #490459] Fri, 09 October 2009 07:25 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Dominic,

I really don't know. Perhaps not. Best to ask on the platform or JFace
newsgroup.


Dominic Renaud wrote:
> Okay, but is there a way to do that in the code itself, such that it
> starts out with the double editor?


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:classic (?) (meta-)modeling problem
Next Topic:How can i get all parameters of an EObject?
Goto Forum:
  


Current Time: Thu Apr 25 04:30:08 GMT 2024

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

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

Back to the top