Ejemplo n.º 1
0
 /** Creates a simple artifact and adds it to the root artifact default hierarchical relation */
 public static Artifact createSimpleArtifact(
     IArtifactType artifactType, String name, IOseeBranch branch) throws OseeCoreException {
   Artifact softArt = ArtifactTypeManager.addArtifact(artifactType, branch);
   softArt.setName(name);
   softArt.addAttribute(CoreAttributeTypes.Subsystem, "Electrical");
   Artifact rootArtifact = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch);
   rootArtifact.addRelation(CoreRelationTypes.Default_Hierarchical__Child, softArt);
   return softArt;
 }
  /** Create the TableViewer */
  private void okSelected() {
    ArrayList<ArtifactModel> artifactList =
        relationTableViewer.getArtifactList().getArtifactModel();

    for (int i = 0; i < artifactList.size(); i++) {
      ArtifactModel model = artifactList.get(i);

      if (model.isAdd()) {
        Artifact artifact = model.getArtifact();
        descriptor = model.getDescriptor();
        if (artifact == null) {
          if (descriptor != null) {
            try {
              artifact = ArtifactTypeManager.addArtifact(descriptor, branch);
              artifact.setName(model.getName());
              artifact.setSoleAttributeValue(
                  CoreAttributeTypes.ContentUrl, urls.get(names.indexOf(model.getName())));
              artifact.persist(getClass().getSimpleName());
            } catch (Exception ex) {
              OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
            }
          }
        } else {
          artifact = model.getArtifact();
        }

        if (artifact != null) {
          try {
            relationGroup.getArtifact().addRelation(relationGroup, artifact);
          } catch (OseeCoreException ex) {
            OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
          }
        }
      }
    }
    if (persistOnOk) {
      try {
        relationGroup.getArtifact().persist(getClass().getSimpleName());
      } catch (OseeCoreException ex) {
        OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
      }
    }
    shell.dispose();
    viewer.refresh();
  }