Esempio n. 1
0
 /**
  * @return The Configuration element for the given {@link DatatypeDefinition} or null if none is
  *     configured.
  */
 public static ProrPresentationConfiguration getPresentationConfiguration(DatatypeDefinition dd) {
   ReqIF reqif = ReqIF10Util.getReqIF(dd);
   if (reqif == null) return null;
   ProrToolExtension prorToolExtension = getProrToolExtension(reqif);
   if (prorToolExtension == null) return null;
   ProrPresentationConfigurations extensions = prorToolExtension.getPresentationConfigurations();
   if (extensions == null) return null;
   for (ProrPresentationConfiguration config : extensions.getPresentationConfigurations()) {
     if (dd.equals(config.getDatatype())) return config;
   }
   return null;
 }
Esempio n. 2
0
  /**
   * Returns the list of default Label names.
   *
   * @return always a list, sometimes empty.
   */
  public static List<String> getDefaultLabels(ReqIF reqif) {
    ProrToolExtension extension = getProrToolExtension(reqif);
    if (extension == null) {
      return Collections.emptyList();
    }
    ProrGeneralConfiguration generalConfig = extension.getGeneralConfiguration();
    if (generalConfig == null) {
      return Collections.emptyList();
    }

    LabelConfiguration labelConfig = generalConfig.getLabelConfiguration();
    if (labelConfig == null) {
      return Collections.emptyList();
    }

    return labelConfig.getDefaultLabel();
  }
Esempio n. 3
0
  /** If a ReqIF has no labels yet, this method configures some smart defaults. */
  public static void setDefaultLabelsIfNecessary(
      AdapterFactory adapterFactory, EditingDomain editingDomain, ReqIF reqif) {
    CompoundCommand cmd = new CompoundCommand();

    ProrToolExtension extension = createProrToolExtension(reqif, editingDomain);
    ProrGeneralConfiguration generalConfig = extension.getGeneralConfiguration();
    if (generalConfig == null) {
      generalConfig = ConfigurationFactory.eINSTANCE.createProrGeneralConfiguration();
      cmd.append(
          SetCommand.create(
              editingDomain,
              extension,
              ConfigurationPackage.Literals.PROR_TOOL_EXTENSION__GENERAL_CONFIGURATION,
              generalConfig));
    }
    LabelConfiguration labelConfig = generalConfig.getLabelConfiguration();
    if (labelConfig == null) {
      labelConfig = ConfigurationFactory.eINSTANCE.createLabelConfiguration();
      cmd.append(
          SetCommand.create(
              editingDomain,
              generalConfig,
              ConfigurationPackage.Literals.PROR_GENERAL_CONFIGURATION__LABEL_CONFIGURATION,
              labelConfig));
    } else {
      // If there is already a label configuration, we leave it alone.
      return;
    }
    labelConfig.getDefaultLabel().add("ReqIF.ChapterNumber");
    labelConfig.getDefaultLabel().add("ReqIF.ChapterName");
    labelConfig.getDefaultLabel().add("ReqIF.Name");
    labelConfig.getDefaultLabel().add("ReqIF.Text");
    labelConfig.getDefaultLabel().add("ID");
    labelConfig.getDefaultLabel().add("Name");
    labelConfig.getDefaultLabel().add("Description");

    editingDomain.getCommandStack().execute(cmd);
  }
Esempio n. 4
0
 /**
  * @return the {@link ProrPresentationConfigurations} for the given {@link ReqIf} and {@link
  *     EditingDomain}.
  */
 public static ProrPresentationConfigurations getPresentationConfigurations(ReqIF reqif) {
   ProrToolExtension uiExtension = ConfigurationUtil.getProrToolExtension(reqif);
   return uiExtension == null ? null : uiExtension.getPresentationConfigurations();
 }
Esempio n. 5
0
  /**
   * Retrieves the {@link ProrSpecViewConfiguration} for the given {@link Specification}. If none
   * exists, it is built. The builder collects all attribute names of all SpecObjects and creates
   * corresponding columns.
   */
  public static ProrSpecViewConfiguration createSpecViewConfiguration(
      Specification specification, EditingDomain domain) {
    ProrToolExtension extension =
        createProrToolExtension(ReqIF10Util.getReqIF(specification), domain);

    EList<ProrSpecViewConfiguration> configs = extension.getSpecViewConfigurations();
    for (ProrSpecViewConfiguration config : configs) {
      if (config.getSpecification() != null && config.getSpecification().equals(specification)) {
        return config;
      }
    }

    // None found, let's build a new one that includes all attribute names.
    ProrSpecViewConfiguration specViewConfig =
        ConfigurationFactory.eINSTANCE.createProrSpecViewConfiguration();
    specViewConfig.setSpecification(specification);

    // Collect all Types

    final List<SpecType> types = new ArrayList<SpecType>();
    ReqIF10Switch<SpecHierarchy> visitor =
        new ReqIF10Switch<SpecHierarchy>() {
          @Override
          public SpecHierarchy caseSpecHierarchy(SpecHierarchy specHierarchy) {
            if (specHierarchy.getObject() != null) {
              SpecObjectType type = specHierarchy.getObject().getType();
              if (type != null && !types.contains(type)) {
                types.add(type);
              }
            }
            return specHierarchy;
          }
        };
    int counter = 0;
    for (Iterator<EObject> i = EcoreUtil.getAllContents(specification, true); i.hasNext(); ) {
      visitor.doSwitch(i.next());
      // we only explore the first 50 elements for performance.
      if (counter++ == 50) break;
    }

    // Collect all names from the types.  We use a list to maintain order.
    final List<String> colNames = new ArrayList<String>();
    for (SpecType type : types) {
      for (AttributeDefinition ad : type.getSpecAttributes()) {

        String colName = ad.getLongName();
        if (colName != null && !colNames.contains(colName)) {
          colNames.add(ad.getLongName());
        }
      }
    }

    // Build all Columns from the names
    boolean unifiedColumn = false;
    for (String colName : colNames) {
      Column column = ConfigurationFactory.eINSTANCE.createColumn();

      // See whether we need a unified column or not.
      if (colName.equals("ReqIF.Text") || colName.equals("ReqIF.ChapterName")) {
        if (unifiedColumn) continue;
        column = ConfigurationFactory.eINSTANCE.createUnifiedColumn();
        colName = "Main";
        unifiedColumn = true;
      }

      column.setWidth(100);
      column.setLabel(colName);
      specViewConfig.getColumns().add(column);
    }
    domain
        .getCommandStack()
        .execute(
            AddCommand.create(
                domain,
                extension,
                ConfigurationPackage.Literals.PROR_TOOL_EXTENSION__SPEC_VIEW_CONFIGURATIONS,
                specViewConfig));

    return specViewConfig;
  }
Esempio n. 6
0
  /**
   * Create a new model.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  protected EObject createInitialModel() {
    ReqIF root = reqif10Factory.createReqIF();

    ReqIFHeader header = reqif10Factory.createReqIFHeader();
    root.setTheHeader(header);

    XMLGregorianCalendar reqIFLastChange = ReqIF10Util.getReqIFLastChange();

    header.setCreationTime(reqIFLastChange);
    header.setSourceToolId("ProR (http://pror.org)");
    header.setIdentifier("rmf-" + UUID.randomUUID());
    header.setReqIFVersion("1.0.1");
    header.setReqIFToolId("ProR (http://pror.org)");
    header.setComment("Created by: " + System.getProperty("user.name"));

    ReqIFContent content = reqif10Factory.createReqIFContent();
    root.setCoreContent(content);

    // Add a DatatypeDefinition
    DatatypeDefinitionString ddString = reqif10Factory.createDatatypeDefinitionString();
    ddString.setLongName("T_String32k");
    ddString.setMaxLength(new BigInteger("32000"));
    ddString.setLastChange(reqIFLastChange);
    content.getDatatypes().add(ddString);

    // Add a SpecObjectType
    SpecObjectType specObjectType = reqif10Factory.createSpecObjectType();
    specObjectType.setLongName("Requirement Type");
    specObjectType.setLastChange(reqIFLastChange);
    content.getSpecTypes().add(specObjectType);

    // Add an AttributeDefinition
    AttributeDefinitionString ad1 = reqif10Factory.createAttributeDefinitionString();
    ad1.setType(ddString);
    ad1.setLongName("Description");
    ad1.setLastChange(reqIFLastChange);
    specObjectType.getSpecAttributes().add(ad1);

    // Add a SpecificationType
    SpecificationType specificationType = reqif10Factory.createSpecificationType();
    specificationType.setLongName("Specification Type");
    specificationType.setLastChange(reqIFLastChange);
    content.getSpecTypes().add(specificationType);

    // Add an AttributeDefinition
    AttributeDefinitionString ad2 = reqif10Factory.createAttributeDefinitionString();
    ad2.setType(ddString);
    ad2.setLongName("Description");
    ad2.setLastChange(reqIFLastChange);
    specificationType.getSpecAttributes().add(ad2);

    // Add a Specification
    Specification spec = reqif10Factory.createSpecification();
    spec.setLongName("Specification Document");
    spec.setType(specificationType);
    spec.setLastChange(reqIFLastChange);
    AttributeValueString value1 = reqif10Factory.createAttributeValueString();
    value1.setTheValue("Requirements Document");
    value1.setDefinition(ad2);
    spec.getValues().add(value1);

    content.getSpecifications().add(spec);

    // Configure the Specification View
    ProrToolExtension extension = ConfigurationFactory.eINSTANCE.createProrToolExtension();
    ReqIFToolExtensionUtil.addToolExtension(root, extension);
    ProrSpecViewConfiguration prorSpecViewConfiguration =
        ConfigurationFactory.eINSTANCE.createProrSpecViewConfiguration();
    extension.getSpecViewConfigurations().add(prorSpecViewConfiguration);
    prorSpecViewConfiguration.setSpecification(spec);
    Column col = ConfigurationFactory.eINSTANCE.createColumn();
    col.setLabel("Description");
    col.setWidth(400);
    prorSpecViewConfiguration.getColumns().add(col);

    Column leftHeaderColumn = ConfigurationFactory.eINSTANCE.createColumn();
    leftHeaderColumn.setWidth(ConfigurationUtil.DEFAULT_LEFT_HEADER_COLUMN_WIDTH);
    leftHeaderColumn.setLabel(ConfigurationUtil.DEFAULT_LEFT_HEADER_COLUMN_NAME);
    prorSpecViewConfiguration.setLeftHeaderColumn(leftHeaderColumn);

    // Configure the Label configuration
    ProrGeneralConfiguration generalConfig =
        ConfigurationFactory.eINSTANCE.createProrGeneralConfiguration();
    LabelConfiguration labelConfig = ConfigurationFactory.eINSTANCE.createLabelConfiguration();
    labelConfig.getDefaultLabel().add("Description");
    generalConfig.setLabelConfiguration(labelConfig);
    extension.setGeneralConfiguration(generalConfig);

    // Create one Requirement
    SpecObject specObject = reqif10Factory.createSpecObject();
    specObject.setType(specObjectType);
    specObject.setLastChange(reqIFLastChange);
    content.getSpecObjects().add(specObject);
    AttributeValueString value2 = reqif10Factory.createAttributeValueString();
    value2.setTheValue("Start editing here.");
    value2.setDefinition(ad1);
    specObject.getValues().add(value2);

    // Add the requirement to the Specification
    SpecHierarchy specHierarchy = reqif10Factory.createSpecHierarchy();
    specHierarchy.setLastChange(reqIFLastChange);
    spec.getChildren().add(specHierarchy);
    specHierarchy.setObject(specObject);
    return root;
  }