예제 #1
0
  private void removeTerm() {

    TableItem[] sel = termsTableViewer.getTable().getSelection();

    if (sel.length > 0) {

      ITerm selTerm = (ITerm) (sel[0].getData());

      ITerminoConcept tc =
          ControlerFactoryImpl.getTerminoOntoControler().getCurrentTerminoConcept();

      ITerminoOntoAnnotation starTermAnnotation = getStarTermAnnotation(tc);

      if (starTermAnnotation != null) {

        if (starTermAnnotation.getValue().compareTo(selTerm.getId() + "") == 0) { // $NON-NLS-1$

          DatabaseAdapter.deleteTCAnnotation(tc, starTermAnnotation);
        }
      }

      List<ITerminoConcept> tcs = new ArrayList<ITerminoConcept>();
      tcs.add(tc);
      DatabaseAdapter.unlinkTerm(tcs, selTerm);

      updateInformation();
    }
  }
예제 #2
0
    @Override
    public Color getBackground(Object element) {
      ITerm term = (ITerm) element;
      Color starTermColor = null;

      if (currentTerminoConcept != null) {

        Set<ITerminoOntoAnnotation> annotations = currentTerminoConcept.getAnnotations();
        Iterator<ITerminoOntoAnnotation> it = annotations.iterator();
        ITerminoOntoAnnotation annotation = null;

        while (it.hasNext()) {
          ITerminoOntoAnnotation tmp = it.next();

          if (tmp.getTerminoOntoAnnotationType()
                  .getLabel()
                  .compareTo(DatabaseAdapter.STAR_TERM_ANNOTATION)
              == 0) {
            annotation = tmp;
          }
        }

        if (annotation != null) {

          if (annotation.getValue().compareTo(term.getId() + "") == 0) { // $NON-NLS-1$

            starTermColor = shell.getDisplay().getSystemColor(SWT.COLOR_YELLOW);
          }
        }
      }
      return starTermColor;
    }
예제 #3
0
    public int compare(Viewer viewer, Object o1, Object o2) {
      int res = 0;
      ITerm t1 = (ITerm) o1;
      ITerm t2 = (ITerm) o2;

      res = t1.getLabel().compareToIgnoreCase(t2.getLabel());

      if (directionTerm == SWT.DOWN) res = -res;

      return res;
    }
  /**
   * Returns an array of Strings within the input array that match the input test string
   *
   * @param items the String array of possible completions
   * @param prefix the incomplete String to try and match
   * @return the array of possible completions to the input string
   */
  private List<ITerm> matches(List<ITerm> items, String prefix) {
    List<ITerm> matches = new ArrayList<ITerm>();

    if (items != null) {
      Iterator<ITerm> it = items.iterator();

      while (it.hasNext()) {
        ITerm term = it.next();
        if (startsWithIgnoreCase(term.getLabel(), prefix)) {
          matches.add(term);
        }
      }
    }

    return matches;
  }
예제 #5
0
 public String getText(Object element) {
   ITerm term = (ITerm) element;
   return term.getLabel();
 }