コード例 #1
0
ファイル: ConfigurationUtil.java プロジェクト: eclipse/rmf
  /**
   * 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();
  }
コード例 #2
0
ファイル: ConfigurationUtil.java プロジェクト: eclipse/rmf
  /** 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);
  }