예제 #1
0
  @Override
  protected void saveWidgetValues() {
    super.saveWidgetValues();
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {

      settings.put("isDirectory", isDirectory());

      File file = getSourceFile();
      if (file != null) {
        settings.put("source.file", getSourceFile().getAbsolutePath());
      }

      IArtifactExtractor parser = getArtifactParser();
      if (parser != null) {
        settings.put("selected.parser", parser.getClass().getSimpleName());
      }

      Artifact artifact = getDestinationArtifact();
      if (artifact != null) {
        settings.put("destination.artifact.guid", artifact.getGuid());
        settings.put("destination.branch.uuid", artifact.getBranch().getUuid());
      }
      settings.put("is.update.existing.selected", isUpdateExistingSelected());
    }
  }
예제 #2
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>());
      }
    }
  }
  /** Check if widgets are enabled or disabled by a change in the dialog. */
  protected void updateWidgetEnablements() {

    boolean pageComplete = determinePageCompletion();
    setPageComplete(pageComplete);
    if (pageComplete) {
      setMessage(null);
    }
    super.updateWidgetEnablements();
  }