private List<Resource> addEventPort(final SoftPkg spd) throws CoreException { final Descriptor desc = spd.getDescriptor(); if (desc != null) { final SoftwareComponent scd = desc.getComponent(); ComponentFeatures features = scd.getComponentFeatures(); if (features == null) { features = ScdFactory.eINSTANCE.createComponentFeatures(); scd.setComponentFeatures(features); } Ports ports = features.getPorts(); if (ports == null) { ports = ScdFactory.eINSTANCE.createPorts(); features.setPorts(ports); } Interfaces interfaces = scd.getInterfaces(); boolean found = false; if (interfaces != null) { for (final Interface i : interfaces.getInterface()) { if (EventChannelHelper.id().equals(i.getRepid())) { found = true; break; } } } else { interfaces = ScdFactory.eINSTANCE.createInterfaces(); scd.setInterfaces(interfaces); } if (!found) { final Interface i = ScdFactory.eINSTANCE.createInterface(); i.setName("EventChannel"); i.setRepid(EventChannelHelper.id()); interfaces.getInterface().add(i); } final Uses uses = ScdFactory.eINSTANCE.createUses(); ports.getUses().add(uses); uses.setName(Uses.PORT_NAME_PROP_EVENTS); uses.setRepID(EventChannelHelper.id()); final PortTypeContainer ptc = ScdFactory.eINSTANCE.createPortTypeContainer(); ptc.setType(PortType.RESPONSES); uses.getPortType().add(ptc); return Collections.singletonList(scd.eResource()); } else { throw new CoreException( new Status( IStatus.ERROR, ComponentUiPlugin.PLUGIN_ID, "No descriptor, quick fix failed for " + spd.eResource().getURI().path(), null)); } }
/** {@inheritDoc} */ public String generate(Object argument) { final StringBuffer stringBuffer = new StringBuffer(); TemplateParameter templ = (TemplateParameter) argument; ImplementationSettings implSettings = templ.getImplSettings(); Implementation impl = templ.getImpl(); SoftPkg softPkg = (SoftPkg) impl.eContainer(); String PREFIX = gov.redhawk.ide.codegen.util.CodegenFileHelper.getPreferredFilePrefix( softPkg, implSettings); boolean hasSddsPort = false; Date date = new Date(System.currentTimeMillis()); EList<Provides> provides = softPkg.getDescriptor().getComponent().getComponentFeatures().getPorts().getProvides(); for (Provides entry : provides) { if (entry.getRepID().contains("BULKIO/dataSDDS")) { hasSddsPort = true; } } stringBuffer.append(TEXT_1); stringBuffer.append(ModelUtil.getSpdFileName(softPkg)); stringBuffer.append(TEXT_2); stringBuffer.append(date.toString()); String[] output; IProduct product = Platform.getProduct(); if (product != null) { output = product.getProperty("aboutText").split("\n"); stringBuffer.append(TEXT_3); stringBuffer.append(output[0]); stringBuffer.append(TEXT_4); stringBuffer.append(output[1]); stringBuffer.append(TEXT_5); stringBuffer.append(output[2]); } stringBuffer.append(TEXT_6); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_7); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_8); if (!templ.isDevice()) { stringBuffer.append(TEXT_9); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_10); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_11); stringBuffer.append(TEXT_12); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_13); } else { stringBuffer.append(TEXT_14); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_15); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_16); stringBuffer.append(TEXT_17); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_18); stringBuffer.append(TEXT_19); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_20); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_21); stringBuffer.append(TEXT_22); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_23); stringBuffer.append(TEXT_24); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_25); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_26); stringBuffer.append(TEXT_27); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_28); stringBuffer.append(TEXT_29); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_30); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_31); stringBuffer.append(TEXT_32); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_33); } stringBuffer.append(TEXT_34); stringBuffer.append(TEXT_35); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_36); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_37); if (hasSddsPort) { stringBuffer.append(TEXT_38); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_39); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_40); } stringBuffer.append(TEXT_41); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_42); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_43); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_44); stringBuffer.append(TEXT_45); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_46); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_47); stringBuffer.append(TEXT_48); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_49); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_50); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_51); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_52); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_53); stringBuffer.append(PREFIX); stringBuffer.append(TEXT_54); stringBuffer.append(TEXT_55); return stringBuffer.toString(); }