Java Code Examples for org.apache.uima.resource.metadata.Capability#addInputType()

The following examples show how to use org.apache.uima.resource.metadata.Capability#addInputType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Handle add type.
 *
 * @param selItem the sel item
 * @param itemKind the item kind
 */
private void handleAddType(TreeItem selItem, int itemKind) {
  if (itemKind == LANG || itemKind == TYPE || itemKind == SOFA)
    selItem = selItem.getParentItem();
  else if (itemKind == LANG_ITEM || itemKind == FEAT || itemKind == SOFA_ITEM)
    selItem = selItem.getParentItem().getParentItem();
  Capability c = getCapabilityFromTreeItem(selItem);
  AddCapabilityTypeDialog dialog = new AddCapabilityTypeDialog(this, c);
  if (dialog.open() == Window.CANCEL)
    return;

  for (int i = 0; i < dialog.types.length; i++) {

    if (dialog.inputs[i])
      c.addInputType(dialog.types[i], dialog.inputs[i]);

    if (dialog.outputs[i])
      c.addOutputType(dialog.types[i], dialog.outputs[i]);

    TreeItem item = new TreeItem(selItem, SWT.NONE);
    setGuiTypeName(item, dialog.types[i]);
    item.setText(INPUT_COL, dialog.inputs[i] ? INPUT : "");
    item.setText(OUTPUT_COL, dialog.outputs[i] ? OUTPUT : "");

    TreeItem fItem = new TreeItem(item, SWT.NONE);
    fItem.setData(FEAT_TITLE);
    fItem.setText(NAME_COL, ALL_FEATURES);
    fItem.setText(INPUT_COL, dialog.inputs[i] ? INPUT : "");
    fItem.setText(OUTPUT_COL, dialog.outputs[i] ? OUTPUT : "");

    item.setExpanded(true);
  }
  pack04();
  selItem.setExpanded(true);
  finishAction();
}