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; }
@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>()); } } }
public void setDefaultDestinationArtifact(Artifact destinationArtifact) { artifactSelectPanel.setDefaultItem(destinationArtifact); }