Package org.eclipse.papyrus.infra.core.services

Examples of org.eclipse.papyrus.infra.core.services.ServicesRegistry


   *            The base URI for the Papyrus model
   *            It shall be of the form platform:/resource/SomePath/File (without file extention)
   * @return The ModelSet representing the new Papyrus model
   */
  public static ModelSet createNew(final String baseURI) {
    ServicesRegistry registry = null;
    ModelSet modelSet = null;

    try {
      registry = new ExtensionServicesRegistry(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID);
    } catch (ServiceException ex) {
      //Activator.log.error(ex);
      return null;
    }

    try {
      registry.startServicesByClassKeys(ModelSet.class);
    } catch (ServiceException ex) {
      // ignore at this point
    }

    try {
      modelSet = registry.getService(ModelSet.class);
    } catch (ServiceException ex) {
      //Activator.log.error(ex);
      return null;
    }

    final ModelSet papyrus = modelSet;
    CommandStack stack = modelSet.getTransactionalEditingDomain().getCommandStack();
    stack.execute(new AbstractCommand() {
      @Override
      public boolean canExecute() {
        return true;
      }

      @Override
      public void execute() {
        URI uri = URI.createURI(baseURI);
        papyrus.createModels(uri);
        AbstractBaseModel notation = (AbstractBaseModel) papyrus.getModel(NotationModel.MODEL_ID);
        notation.createModel(uri);
        notation.getResource().getErrors().clear();
        ((GMFResource) notation.getResource()).setUseIDAttributes(true);
      }

      @Override
      public void redo() {
        execute();
      }
    });

    try {
      registry.startRegistry();
      registry.startServicesByClassKeys(ActionBarContributorRegistry.class);
    } catch (ServiceException ex) {
      // ignore at this point
    }

    try {
      registry.getService(IPageManager.class);
    } catch (ServiceException ex) {
      //Activator.log.error(ex);
      return null;
    }

View Full Code Here

TOP

Related Classes of org.eclipse.papyrus.infra.core.services.ServicesRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.