Esempio n. 1
0
    @Override
    protected void paint(Event event, Object element) {

      ITerminoOntoAnnotation annotation = (ITerminoOntoAnnotation) element;
      ITerminoOntoAnnotationType annotationType = annotation.getTerminoOntoAnnotationType();
      Image img = null;

      if (annotationType.getLabel().compareTo(DatabaseAdapter.LABEL_EN_ANNOTATION) == 0) {
        img =
            org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
                .getImageRegistry()
                .get(org.dafoe.terminoontologiclevel.ui.Activator.US_FLAG_IMG_ID);
      } else if (annotationType.getLabel().compareTo(DatabaseAdapter.LABEL_SP_ANNOTATION) == 0) {
        img =
            org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
                .getImageRegistry()
                .get(org.dafoe.terminoontologiclevel.ui.Activator.SP_FLAG_IMG_ID);
      }

      if (img != null) {
        Rectangle bounds = ((TableItem) event.item).getBounds(event.index);
        Rectangle imgBounds = img.getBounds();
        bounds.width /= 2;
        bounds.width -= imgBounds.width / 2;
        bounds.height /= 2;
        bounds.height -= imgBounds.height / 2;

        int x = bounds.width > 0 ? bounds.x + bounds.width : bounds.x;
        int y = bounds.height > 0 ? bounds.y + bounds.height : bounds.y;

        event.gc.drawImage(img, x, y);
      }
    }
Esempio n. 2
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();
    }
  }
Esempio n. 3
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;
    }
Esempio n. 4
0
  private ITerminoOntoAnnotation getStarTermAnnotation(ITerminoConcept tc) {
    Set<ITerminoOntoAnnotation> annotations = tc.getAnnotations();
    Iterator<ITerminoOntoAnnotation> it = annotations.iterator();

    ITerminoOntoAnnotation starTermAnnotation = null;

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

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

    return starTermAnnotation;
  }
Esempio n. 5
0
  private List<ITerminoOntoAnnotation> getTCTranslationAnnotations(ITerminoConcept tc) {
    Set<ITerminoOntoAnnotation> annotations = tc.getAnnotations();
    Iterator<ITerminoOntoAnnotation> it = annotations.iterator();

    List<ITerminoOntoAnnotation> res = new ArrayList<ITerminoOntoAnnotation>();

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

      if ((tmp.getTerminoOntoAnnotationType()
                  .getLabel()
                  .compareTo(DatabaseAdapter.LABEL_EN_ANNOTATION)
              == 0)
          || (tmp.getTerminoOntoAnnotationType()
                  .getLabel()
                  .compareTo(DatabaseAdapter.LABEL_SP_ANNOTATION)
              == 0)) {
        res.add(tmp);
      }
    }

    return res;
  }
Esempio n. 6
0
    public int compare(Viewer viewer, Object o1, Object o2) {
      int res = 0;

      ITerminoOntoAnnotation annot1 = (ITerminoOntoAnnotation) o1;
      ITerminoOntoAnnotation annot2 = (ITerminoOntoAnnotation) o2;

      switch (col) {
        case TERM_SORT:
          res = annot1.getValue().compareToIgnoreCase(annot2.getValue());
          break;
        case FLAG_SORT:
          res =
              annot1
                  .getTerminoOntoAnnotationType()
                  .getLabel()
                  .compareToIgnoreCase(annot2.getTerminoOntoAnnotationType().getLabel());
          break;
      }

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

      return res;
    }
Esempio n. 7
0
 public String getText(Object element) {
   ITerminoOntoAnnotation annotation = (ITerminoOntoAnnotation) element;
   return annotation.getValue();
 }