Package org.apache.uima.caseditor.editor

Examples of org.apache.uima.caseditor.editor.FeatureValue


  public void update(ViewerCell cell) {

    Object element = cell.getElement();

    if (element instanceof FeatureValue) {
      FeatureValue featureValue = (FeatureValue) element;

      if (featureValue.getFeature().getRange().isPrimitive()) {
        cell.setText(featureValue.getFeatureStructure().getFeatureValueAsString(
                featureValue.getFeature()));
      }
      else {
        FeatureStructure value = (FeatureStructure) featureValue.getValue();

        if (value == null) {
          cell.setText("null");
        } else {
          cell.setText("[" + value.getType().getShortName() + "]");
View Full Code Here


          if (tableItem != null) {

            if (tableItem.getData() instanceof FeatureValue) {

              // this can fail
              FeatureValue value = (FeatureValue) tableItem.getData();
             
              TypeSystem typeSystem = value.getFeatureStructure().getCAS().getTypeSystem();
             
              Type range = value.getFeature().getRange();

              FeatureStructure dragFeatureStructure = (FeatureStructure) event.data;
             
              if (typeSystem.subsumes(range, dragFeatureStructure.getType())) {

                FeatureStructure target = value.getFeatureStructure();

                target.setFeatureValue(value.getFeature(), dragFeatureStructure);

                document.update(target);

                event.detail = DND.DROP_COPY;
              }
            } else if (tableItem.getData() instanceof ArrayValue) {
              ArrayValue value = (ArrayValue) tableItem.getData();

              if (value.getFeatureStructure() instanceof ArrayFS) {

                ArrayFS array = (ArrayFS) value.getFeatureStructure();

                array.set(value.slot(), (FeatureStructure) event.data);

                document.update(array);

                event.detail = DND.DROP_COPY;
              }
View Full Code Here

    @Override
    protected boolean canEdit(Object element) {

      if (element instanceof FeatureValue) {
        FeatureValue value = (FeatureValue) element;

        return value.getFeature().getRange().isPrimitive();
      }
      else if (element instanceof ArrayValue) {

        ArrayValue value = (ArrayValue) element;

        FeatureStructure arrayFS = value.getFeatureStructure();

        if (arrayFS instanceof ArrayFS) {
          return false;
        }
        else if (arrayFS instanceof CommonArrayFS ||
View Full Code Here

    @Override
    protected CellEditor getCellEditor(Object element) {

      if (element instanceof FeatureValue) {
        FeatureValue value = (FeatureValue) element;

        if (value.getFeature().getRange().isPrimitive()) {

          CellEditor editor;

          if (value.getFeature().getRange().getName().equals(CAS.TYPE_NAME_BOOLEAN)) {
            editor = new ComboBoxCellEditor(viewer.getTree(), new String[]{"false", "true"},
                    SWT.READ_ONLY);
          }
          else {
            editor = new TextCellEditor(viewer.getTree());
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Primitives
                    .getPrimitiveClass(value.getFeature())));
          }

          return editor;
        }
        else {
View Full Code Here

    @Override
    protected Object getValue(Object element) {

      if (element instanceof FeatureValue) {
        FeatureValue featureValue = (FeatureValue) element;

        // if not a boolean return string value,
        // otherwise return boolean number
        if (!featureValue.getFeature().getRange().getName().equals(
                CAS.TYPE_NAME_BOOLEAN)) {
          return featureValue.getFeatureStructure()
            .getFeatureValueAsString(featureValue.getFeature());
        }
        else {
          // for booleans
          return booleanToInt(featureValue.getFeatureStructure().
              getBooleanValue(featureValue.getFeature()));
        }

      }
      else if (element instanceof ArrayValue) {
          ArrayValue value = (ArrayValue) element;
View Full Code Here

      // if value is null, there was an invalid input
      if (value != null) {
        if (element instanceof FeatureValue) {

          FeatureValue featureValue = (FeatureValue) element;

          // for all other than boolean values
          if (!featureValue.getFeature().getRange().getName().equals(
                  CAS.TYPE_NAME_BOOLEAN)) {
            if (featureValue.getFeature().getRange().isPrimitive()) {

              // TODO: try to prevent setting of invalid annotation span values

              featureValue.getFeatureStructure().setFeatureValueFromString(featureValue.getFeature(),
                      (String) value);
            }
          }
          else {
            featureValue.getFeatureStructure().setBooleanValue(featureValue.getFeature(),
                    intToBoolean((Integer) value));
          }
          document.update(featureValue.getFeatureStructure());

          viewer.update(element, null);

        } else if (element instanceof ArrayValue) {
View Full Code Here

* Provide the labels for the given {@link FeatureStructure}s.
*/
public final class FeatureStructureLabelProvider implements ILabelProvider {
  public String getText(Object element) {
    if (element instanceof FeatureValue) {
      FeatureValue featureValue = (FeatureValue) element;
      Object value = featureValue.getValue();

      if (value == null) {
        return featureValue.getFeature().getShortName() + ": null";
      }

      if (featureValue.getFeature().getRange().isPrimitive()) {
        return featureValue.getFeature().getShortName() + " : " + value.toString();
      }

      return featureValue.getFeature().getShortName();
    }
    else if (element instanceof IAdaptable) {

      FeatureStructure structure = null;

View Full Code Here

      FeatureStructure featureStructure;

      if (parentElement instanceof ModelFeatureStructure) {
        featureStructure = ((ModelFeatureStructure) parentElement).getStructre();
      } else if (parentElement instanceof FeatureValue) {
        FeatureValue value = (FeatureValue) parentElement;

        featureStructure = (FeatureStructure) value.getValue();
      } else {
        assert false : "Unexpected element!";

        return new Object[] {};
      }

      Type type = featureStructure.getType();

      for (Feature feature : type.getFeatures()) {
        childs.add(new FeatureValue(mDocument, featureStructure, feature));
      }

      assert childs.size() > 0;

      return childs.toArray();
View Full Code Here

    public boolean hasChildren(Object element) {
      if (element instanceof IAdaptable
              && ((IAdaptable) element).getAdapter(FeatureStructure.class) != null) {
        return true;
      } else if (element instanceof FeatureValue) {
        FeatureValue featureValue = (FeatureValue) element;

        if (featureValue.getFeature().getRange().isPrimitive()) {
          Object value = featureValue.getValue();

          if (value == null) {
            return false;
          }

          if (value instanceof StringArray) {
            StringArray array = (StringArray) featureValue.getValue();

            if (array.size() > 0) {
              return true;
            } else {
              return false;
            }
          }

          return false;
        } else {
          return featureValue.getValue() != null ? true : false;
        }
      } else {
        assert false : "Unexpected element";

        return false;
View Full Code Here

      FeatureStructure featureStructure;

      if (parentElement instanceof ModelFeatureStructure) {
        featureStructure = ((ModelFeatureStructure) parentElement).getStructre();
      } else if (parentElement instanceof FeatureValue) {
        FeatureValue value = (FeatureValue) parentElement;

        featureStructure = (FeatureStructure) value.getValue();
      } else {
        assert false : "Unexpected element!";

        return new Object[] {};
      }

      Type type = featureStructure.getType();

      for (Feature feature : type.getFeatures()) {
        childs.add(new FeatureValue(mDocument, featureStructure, feature));
      }

      assert childs.size() > 0;

      return childs.toArray();
View Full Code Here

TOP

Related Classes of org.apache.uima.caseditor.editor.FeatureValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.