Ejemplo n.º 1
0
  /** @see AbstractIOAdvisor#prepareProvider(IOProvider) */
  @Override
  public void prepareProvider(AlignmentWriter provider) {
    super.prepareProvider(provider);

    AlignmentService as = getService(AlignmentService.class);
    provider.setAlignment(as.getAlignment());

    SchemaService ss = getService(SchemaService.class);
    provider.setSourceSchema(ss.getSchemas(SchemaSpaceID.SOURCE));
    provider.setTargetSchema(ss.getSchemas(SchemaSpaceID.TARGET));
  }
Ejemplo n.º 2
0
    /** Update the feature types selection */
    protected void updateTypesSelection() {
      SchemaSpaceID space = getSchemaSpace();

      TypeDefinition lastSelected = null;
      ISelection lastSelection = typeDefinitions.getSelection();
      if (!lastSelection.isEmpty() && lastSelection instanceof IStructuredSelection) {
        lastSelected = (TypeDefinition) ((IStructuredSelection) lastSelection).getFirstElement();
      }

      DataSet dataset = (space == SchemaSpaceID.SOURCE) ? (DataSet.SOURCE) : (DataSet.TRANSFORMED);
      InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);

      // get instance types
      List<TypeDefinition> filteredTypes =
          new ArrayList<TypeDefinition>(is.getInstanceTypes(dataset));

      if (filteredTypes.isEmpty()) {
        // if there are no instances present, show all types
        SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
        filteredTypes =
            new ArrayList<TypeDefinition>(ss.getSchemas(space).getMappingRelevantTypes());
      }

      typeDefinitions.setInput(filteredTypes);

      // select the previously selected type if possible
      TypeDefinition typeToSelect =
          (filteredTypes.contains(lastSelected)) ? (lastSelected) : (null);

      // fallback selection
      if (typeToSelect == null && !filteredTypes.isEmpty()) {
        typeToSelect = filteredTypes.iterator().next();
      }

      if (typeToSelect != null) {
        typeDefinitions.setSelection(new StructuredSelection(typeToSelect));
      }

      boolean enabled = !filteredTypes.isEmpty();
      typeDefinitions.getControl().setEnabled(enabled);
      count.getControl().setEnabled(enabled);

      layout(true, true);

      updateSelection();
    }