Example #1
0
  protected ArtifactImportPage(File defaultSourceFile, Artifact defaultDestinationArtifact) {
    super(PAGE_NAME);
    selectedArtifactTypes = new ArrayList<>();
    selectionLatch = new SelectionLatch();
    collector = new RoughArtifactCollector(new RoughArtifact(RoughArtifactKind.PRIMARY));
    artifactSelectPanel = new ArtifactSelectPanel();
    artifactSelectPanel.setDialogTitle("Select Destination Artifact");
    artifactSelectPanel.setDialogMessage(
        "Select a destination artifact. Imported items will be added as children of the selected artifact.");

    artifactSelectPanel.setDefaultItem(defaultDestinationArtifact);

    artifactTypeSelectPanel = new ArtifactTypeSelectPanel();
    artifactTypeSelectPanel.setDialogTitle("Import as Artifact Type");
    artifactTypeSelectPanel.setDialogMessage(
        "Select what artifact type data should be imported as.");

    attributeTypeSelectPanel = new AttributeTypeSelectPanel();
    attributeTypeSelectPanel.setDialogTitle("Select Attribute Types");
    attributeTypeSelectPanel.setDialogMessage(
        "Select which attribute types should be used to match imported and existing artifacts.");

    importContributionManager = new ArtifactExtractorContributionManager();
    parserSelectPanel = new ArtifactExtractorSelectPanel(importContributionManager);

    setTitle("Import artifacts into OSEE");
    setDescription("Import artifacts into Define");
    setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.ARTIFACT_IMPORT_WIZARD));

    operationReportMessages = new StringBuilder();

    this.defaultSourceFile = defaultSourceFile;
  }
Example #2
0
  private void createDestinationArtifactSelectArea(Composite parent) {
    Label selectParentInstructions = new Label(parent, SWT.NONE);
    selectParentInstructions.setText("Select parent artifact:");

    artifactSelectPanel.createControl(parent);
    artifactSelectPanel.addListener(this);
  }
Example #3
0
  @Override
  protected void restoreWidgetValues() {
    super.restoreWidgetValues();
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
      if (getDefaultSourceFile() == null) {
        directoryFileSelector.setDirectorySelected(settings.getBoolean("isDirectory"));
        String file = settings.get("source.file");
        if (Strings.isValid(file)) {
          directoryFileSelector.setText(file);
        }
      }

      String parser = settings.get("selected.parser");
      if (Strings.isValid(parser)) {
        for (IArtifactExtractor item : importContributionManager.getExtractors()) {
          if (parser.equals(item.getClass().getSimpleName())) {
            parserSelectPanel.setArtifactExtractor(item);
          }
        }
      }
      if (getDefaultDestinationArtifact() == null) {
        String guid = settings.get("destination.artifact.guid");
        String branchUuidStr = settings.get("destination.branch.uuid");

        if (GUID.isValid(guid) && Strings.isNumeric(branchUuidStr)) {
          try {
            Long bramchUuid = Long.valueOf(branchUuidStr);
            Artifact artifact =
                ArtifactQuery.getArtifactFromId(guid, BranchManager.getBranchByUuid(bramchUuid));
            artifactSelectPanel.setDefaultItem(artifact);
          } catch (OseeCoreException ex) {
            OseeLog.logf(
                Activator.class,
                Level.SEVERE,
                "Unable to restore destination artifact- guid:[%s] branch uuid:[%d]",
                guid,
                branchUuidStr);
          }
        }
      }

      boolean toUpdate = settings.getBoolean("is.update.existing.selected");
      updateExistingArtifacts.setSelection(toUpdate);
      deleteUnmatchedArtifacts.setEnabled(toUpdate);
      if (toUpdate) {
        try {
          ArtifactType artType = ArtifactTypeManager.getType(getArtifactType());
          attributeTypeSelectPanel.setAllowedAttributeTypes(
              artType.getAttributeTypes(getDestinationArtifact().getFullBranch()));
        } catch (OseeCoreException ex) {
          OseeLog.log(Activator.class, Level.SEVERE, ex);
        }
      } else {
        attributeTypeSelectPanel.setAllowedAttributeTypes(new ArrayList<IAttributeType>());
      }
    }
  }
Example #4
0
 public Artifact getDestinationArtifact() {
   return artifactSelectPanel.getSelected();
 }
Example #5
0
 public Artifact getDefaultDestinationArtifact() {
   return artifactSelectPanel.getDefaultItem();
 }
Example #6
0
 public void setDefaultDestinationArtifact(Artifact destinationArtifact) {
   artifactSelectPanel.setDefaultItem(destinationArtifact);
 }