STP Core Infrastructure API [Index] |
---|
The STP Core Infrastructure layer provides standard management of the EMF Resources which contain model elements. These resources are shared appropriately and reference counted as necessary to prevent loading the same resource into memory multiple times. This ensures that various components in the workbench (e.g. an editor and a view) are rendering the same model and that each reflects the changes of the other. |
![]() |
Design Requirements [Top] |
---|
|
Use Cases [Top] |
---|
Acquiring an IEditModelScribbler // a code heavy API approach // The IScribblerDomain describes the resources // that the edit model should be interested in. // Clients may choose the best way for the creation // of these objects. A factory pattern is shown here. IScribblerDomain scribblerDomain = J2EEScribblerDomainFactory.create(J2EEScribblerDomainType.EJB, project, moduleName); // Notice the edit model is generic; and is NOT subclassed IEditModel ejbEditModel = IEditModelFactory.eINSTANCE.getEditModel(project, scribblerDomain.getEditModelLablel()); // The scribbler becomes the focal point for // save(), revert(), discard(), etc; it also // provides an easier way to manage ref counts // (so no more access(), release() calls! IEditModelScribbler scribbler = ejbEditModel.createScribbler(scribblerDomain, readOnly); ... try { scribbler.close(); } catch(EditModelException eme) { // handle exception } |
Acquiring an IEditModelScribbler // a code light API approach IScribblerDomain scribblerDomain = J2EEScribblerDomainFactory(J2EEScribblerDomainType.EJB, moduleName); // The IEditModelFactory can create the edit model under the covers IEditModelScribbler scribbler = IEditModelFactory.eINSTANCE.createScribblerForRead(project, scribblerDomain); ... try { scribbler.close(force); } catch(EditModelException eme) { // handle exception } |
Acquiring an IEditModelScribbler // a code light API approach (different IScribblerDomain) List descriptorsList = new ArrayList(); // collect descriptors of interest ... // IResourceDescriptor describes the resources // it can specify a default location and an // exact location IResourceDescriptor[] descriptors = null; descriptorsList.toArray( (descriptors = new IResourceDescriptor [descriptorsList.size()]) ); IScribblerDomain scribblerDomain = IScribblerDomain.create(descriptors); IEditModelScribbler scribbler = IEditModelFactory.eINSTANCE.createScribblerForRead(project, scribblerDomain); ... try { scribbler.close(); } catch(EditModelException eme) { // handle exception } |
Saving modifications from an Editor try { scribbler.save(true); } catch(EditModelException eme) { // handle exception } |
Saving modifications from an Operation try { scribbler.save(false); } catch(EditModelException eme) { // handle exception } |
Creating an IScribblerDomain // Clients have full control over how their IScribblerDomains // are created; clients may choose to use a Factory Pattern IScribblerDomain technologyDomainForProject = MyCustomScribblerDomainFactory.createDomain(aProject); |
Loading an existing Resource scribbler.getResource(theURI); |
Creating a Resource IResourceDescriptor descriptor = new EclipseResourceDescriptor(anIFile); Resource resource = scribbler.createResource(descriptor); |
This documentation is maintained by Michael D. Elder (mdelder{at}us.ibm.com). Questions or requests for clarifications should be made to the STP Developer mailing list (stp-dev@eclipse.org). See http://www.eclipse.org/mail/index_all.php for details on how to sign up. Copyright (c) 2006 IBM Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html |
[Index] [Top] |
---|