public StyleProperty getStyleProperty() { StyleProperty styleProperty = (StyleProperty) EcoreUtil.getObjectByType(getProperties(), PomPackage.eINSTANCE.getStyleProperty()); return styleProperty; }
protected EPackage getPackage() { //FB return (EPackage) super.get(JavaPackage.PACKAGE_ID); // return (EPackage) resource.getEObject(JavaPackage.PACKAGE_ID); //FB //return (EPackage) resource.getEObject(JavaPackage.PACKAGE_ID); //FB return (EPackage)EcoreUtil.getObjectByType(resource.getContents(), EcorePackage.eINSTANCE.getEPackage()); } /**
/** * Obtains the UML metamodel library loaded in the specified resource set, * loading it if necessary. * * @param resourceSet a resource set * @return the UML metamodel */ public static Package getUMLMetamodel(ResourceSet resourceSet) { Package result = null; Resource res = resourceSet.getResource( URI.createURI(UMLResource.UML_METAMODEL_URI), true); if (res != null) { result = (Package) EcoreUtil.getObjectByType( res.getContents(), UMLPackage.Literals.PACKAGE); } return result; }
@Override public String genAdditionalMemberVariablesServer(XMAComponent xmaComponent) { StringBuilder stringBuilder = new StringBuilder(); Model model = getReferencingPomModel(xmaComponent); if (model != null) { Component component = (Component) EcoreUtil.getObjectByType(model.getElements(), PomPackage.eINSTANCE .getComponent()); for (Dependant dependant : component.getDependencies()) { stringBuilder.append(" @org.springframework.beans.factory.annotation.Autowired").append(Config.NL).append(" ").append(getFullyQualifiedName(dependant, false)).append( " ").append(Strings.uncapitalize(getName(dependant, false))).append(";").append(Config.NL); } } return stringBuilder.toString(); }
@Override public String genAdditionalImportsServer(XMAComponent xmaComponent) { Model model = getReferencingPomModel(xmaComponent); if (model != null) { StringBuilder stringBuilder = new StringBuilder(); Component component = (Component) EcoreUtil.getObjectByType(model.getElements(), PomPackage.eINSTANCE .getComponent()); for (Dependant dependant : component.getDependencies()) { stringBuilder.append("import ").append(getFullyQualifiedName(dependant, false)).append(";").append(Config.NL); } return stringBuilder.toString(); } return super.genAdditionalImportsServer(xmaComponent); }
/** * * @modified * @return */ public void addStyle(Style style) { StyleProperty styleProperty = (StyleProperty) EcoreUtil.getObjectByType(getProperties(), PomPackage.eINSTANCE.getStyleProperty()); if (null==styleProperty) { styleProperty = PomFactory.eINSTANCE.createStyleProperty(); getProperties().add(styleProperty); } styleProperty.getStyles().add(style); }
private static ConfigurationType parse ( final URI uri ) { final ResourceSet rs = new ResourceSetImpl (); final Resource resource = rs.createResource ( uri ); try { resource.load ( null ); } catch ( final IOException e ) { logger.error ( "Failed to load configuration from: " + uri, e ); } final ConfigurationType cfg = (ConfigurationType)EcoreUtil.getObjectByType ( resource.getContents (), ConfigurationPackage.Literals.CONFIGURATION_TYPE ); return cfg; }
public XMLResource.XMLMap getXMLMap() { if (xmlMap == null) { try { xmlMap = (XMLResource.XMLMap)EcoreUtil.getObjectByType (new ResourceSetImpl().getResource(URI.createURI(element.getAttribute(ATT_XMLMAP)), true).getContents(), Ecore2XMLPackage.eINSTANCE.getXMLMap()); } catch (Exception e) { throw new WrappedException(e); } } return xmlMap; } }
protected void load () throws Exception { // register model VisualInterfacePackage.eINSTANCE.eClass (); this.symbol = null; final ResourceSet resourceSet = new ResourceSetImpl (); // set resource factory to XMI on extension map resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "vi", FACTORY_INSTANCE ); //$NON-NLS-1$ final Resource resource = resourceSet.getResource ( this.uri, true ); this.symbol = (Symbol)EcoreUtil.getObjectByType ( resource.getContents (), VisualInterfacePackage.Literals.SYMBOL ); } }
/** * * @modified * @return */ public int getWidth() { WidthProperty widthProperty = (WidthProperty) EcoreUtil.getObjectByType(getProperties(), PomPackage.eINSTANCE.getWidthProperty()); return DimensionCalculator.calculateWidth(getElementWithLayoutData(),widthProperty); }
/** * * @modified * @return */ public int getHeight() { HeightProperty heightProperty = (HeightProperty) EcoreUtil.getObjectByType(getProperties(), PomPackage.eINSTANCE.getHeightProperty()); return DimensionCalculator.calculateHeight(getElementWithLayoutData(),heightProperty); }
/** * * @modified * @return */ public void setWidth(int width) { WidthProperty widthProperty = (WidthProperty) EcoreUtil.getObjectByType(getProperties(), PomPackage.eINSTANCE.getWidthProperty()); if (null==widthProperty) { widthProperty = PomFactory.eINSTANCE.createWidthProperty(); getProperties().add(widthProperty); } widthProperty.setWidth(width); }
protected void load () throws Exception { // register model VisualInterfacePackage.eINSTANCE.eClass (); this.symbol = null; final ResourceSet resourceSet = new ResourceSetImpl (); // set resource factory to XMI on extension map resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "vi", FACTORY_INSTANCE ); //$NON-NLS-1$ final Resource resource = resourceSet.getResource ( this.uri, true ); this.symbol = (Symbol)EcoreUtil.getObjectByType ( resource.getContents (), VisualInterfacePackage.Literals.SYMBOL ); } }
/** * Inject the CA bootstrap property to the profile * * @param file * the profile.xml file in the package target * @throws IOException */ protected void patchProfile ( final String appName, final File file ) throws IOException { final ResourceSet rs = new ResourceSetImpl (); final Resource r = rs.createResource ( URI.createFileURI ( file.toString () ) ); r.load ( null ); final Profile profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE ); Profiles.addSystemProperty ( profile, "org.eclipse.scada.ca.file.provisionJsonUrl", "file:///usr/share/eclipsescada/ca.bootstrap/bootstrap." + appName + ".json" ); r.save ( null ); }
/** * Gets the model. * * @param modelPath the model path * @return the model */ public static Model getModel(String modelPath) { URI modelUri = URI.createFileURI(modelPath); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); resourceSet.createResource(modelUri); Resource resource = resourceSet.getResource(modelUri, true); Model m = (Model) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.MODEL); return m; }
private RootType parse ( final URI uri ) throws IOException { final ResourceSet rs = new ResourceSetImpl (); rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () ); final Resource r = rs.createResource ( uri ); r.load ( null ); final DocumentRoot doc = (DocumentRoot)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.DOCUMENT_ROOT ); if ( doc == null ) { return null; } return doc.getRoot (); }
private static RootType parse ( final URI uri ) throws IOException { ConfigurationPackage.eINSTANCE.eClass (); final ResourceSetImpl rs = new ResourceSetImpl (); rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () ); final Resource r = rs.createResource ( uri ); r.load ( null ); return (RootType)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.ROOT_TYPE ); }
/** * Inject the CA bootstrap property to the profile * * @param file * the profile.xml file in the package target * @throws IOException */ protected void patchProfile ( final String appName, final File file ) throws IOException { final ResourceSet rs = new ResourceSetImpl (); final Resource r = rs.createResource ( URI.createFileURI ( file.toString () ) ); r.load ( null ); final Profile profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE ); Profiles.addSystemProperty ( profile, "org.eclipse.scada.ca.file.provisionJsonUrl", "file:///usr/share/eclipsescada/ca.bootstrap/bootstrap." + appName + ".json" ); r.save ( null ); }
private RootType parse ( final URI uri ) throws IOException { final ResourceSet rs = new ResourceSetImpl (); rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () ); final Resource r = rs.createResource ( uri ); r.load ( null ); final DocumentRoot doc = (DocumentRoot)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.DOCUMENT_ROOT ); if ( doc == null ) { return null; } return doc.getRoot (); }
private static RootType parse ( final URI uri ) throws IOException { final ResourceSet rs = new ResourceSetImpl (); rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () ); final Resource r = rs.createResource ( uri ); r.load ( null ); final DocumentRoot doc = (DocumentRoot)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.DOCUMENT_ROOT ); if ( doc == null ) { return null; } else { return doc.getRoot (); } }