@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);
      }
    }
    @Override
    protected void paint(Event event, Object element) {

      Image img =
          org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
              .getImageRegistry()
              .get(org.dafoe.terminoontologiclevel.ui.Activator.FR_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);
      }
    }
  private void makeActions() {

    ImageDescriptor imgDesc;

    // remove a relation type => check if it is used in a terminological
    // relation. If not, delete.

    makeStarTermAction =
        new Action() {

          public void run() {

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

            if (sel.length > 0) {

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

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

              ITerminoOntoAnnotation starTermAnnotation = getStarTermAnnotation(tc);

              // this annotation already exists
              if (starTermAnnotation != null) {
                DatabaseAdapter.updateAnnotation(
                    starTermAnnotation, selTerm.getId() + ""); // $NON-NLS-1$
              } else {
                DatabaseAdapter.createTCAnnotation(
                    tc, DatabaseAdapter.STAR_TERM_ANNOTATION, selTerm.getId() + ""); // $NON-NLS-1$
              }

              updateInformation();
            }
          }
        };
    makeStarTermAction.setText(Messages.getString("TerminologicalViewPart.0")); // $NON-NLS-1$
    imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(org.dafoe.terminoontologiclevel.ui.Activator.STAR_IMG_ID);
    makeStarTermAction.setImageDescriptor(imgDesc);
    makeStarTermAction.setEnabled(true);

    //

    addTermAction =
        new Action() {

          public void run() {

            addTerm();
          }
        };
    addTermAction.setText(Messages.getString("TerminologicalViewPart.1")); // $NON-NLS-1$
    imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(org.dafoe.terminoontologiclevel.ui.Activator.NEW_IMG_ID);
    addTermAction.setImageDescriptor(imgDesc);
    addTermAction.setEnabled(true);

    deleteTermAction =
        new Action() {

          public void run() {

            removeTerm();
          }
        };
    deleteTermAction.setText(Messages.getString("TerminologicalViewPart.2")); // $NON-NLS-1$
    imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(org.dafoe.terminoontologiclevel.ui.Activator.REMOVE_IMG_ID);
    deleteTermAction.setImageDescriptor(imgDesc);
    deleteTermAction.setEnabled(true);

    //

    addTranslatedTermAction =
        new Action() {

          public void run() {

            addTranslatedTerm();
          }
        };
    addTranslatedTermAction.setText(Messages.getString("TerminologicalViewPart.3")); // $NON-NLS-1$
    imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(org.dafoe.terminoontologiclevel.ui.Activator.NEW_IMG_ID);
    addTranslatedTermAction.setImageDescriptor(imgDesc);
    addTranslatedTermAction.setEnabled(true);

    //

    deleteTranslatedTermAction =
        new Action() {

          public void run() {

            removeTranslatedTerm();
          }
        };
    deleteTranslatedTermAction.setText(
        Messages.getString("TerminologicalViewPart.4")); // $NON-NLS-1$
    imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(org.dafoe.terminoontologiclevel.ui.Activator.REMOVE_IMG_ID);
    deleteTranslatedTermAction.setImageDescriptor(imgDesc);
    deleteTranslatedTermAction.setEnabled(true);
  }
  @Override
  public void createPartControl(Composite parent) {

    shell = parent.getShell();

    FontRegistry fontRegistry = new FontRegistry(parent.getShell().getDisplay());

    fontRegistry.put(
        "TC", new FontData[] {new FontData("Arial", 10, SWT.BOLD)}); // $NON-NLS-1$ //$NON-NLS-2$

    final Composite comp = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, true);
    layout.horizontalSpacing = 5;
    layout.verticalSpacing = 5;
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    comp.setLayout(layout);

    GridData gd;

    terminoConceptText = new Text(comp, SWT.BORDER | SWT.CENTER | SWT.READ_ONLY);
    terminoConceptText.setEditable(false);
    terminoConceptText.setFont(fontRegistry.get("TC")); // $NON-NLS-1$
    gd = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
    terminoConceptText.setLayoutData(gd);

    // terminologic composite

    Composite terminoComposite = new Composite(comp, SWT.NONE);
    layout = new GridLayout(1, true);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    terminoComposite.setLayout(layout);
    terminoComposite.setLayoutData(gd);
    terminoComposite.setBackground(terminologicColor);

    // terms in current language

    currentLanguageTerms = new Composite(terminoComposite, SWT.NONE);
    layout = new GridLayout(2, false);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    currentLanguageTerms.setLayout(layout);
    currentLanguageTerms.setLayoutData(gd);

    termsTableViewer =
        new TableViewer(
            currentLanguageTerms, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    termsTableViewer.getTable().setLayoutData(gridData);
    termsTableViewer.getTable().setLinesVisible(true);
    termsTableViewer.getTable().setHeaderVisible(true);
    termsTableViewer.setContentProvider(new TermContentProvider());
    termsTableViewer.setSorter(new TermsTableViewerSorter());

    // Columns

    termColumn = new TableViewerColumn(termsTableViewer, SWT.NONE, 0);
    termColumn.getColumn().setText(Messages.getString("TerminologicalViewPart.13")); // $NON-NLS-1$
    termColumn.setLabelProvider(new TermLabelProvider());
    termColumn.getColumn().setAlignment(SWT.CENTER);

    termColumn
        .getColumn()
        .addSelectionListener(
            new SelectionAdapter() {

              public void widgetSelected(SelectionEvent e) {
                TermsTableViewerSorter sorter = new TermsTableViewerSorter();
                termsTableViewer.setSorter(sorter);
                termsTableViewer.getTable().setSortColumn(termColumn.getColumn());
                termsTableViewer.getTable().setSortDirection(directionTerm);
              }
            });

    languageColumn = new TableViewerColumn(termsTableViewer, SWT.CENTER, 1);
    languageColumn
        .getColumn()
        .setText(Messages.getString("TerminologicalViewPart.14")); // $NON-NLS-1$
    languageColumn.getColumn().setAlignment(SWT.CENTER);
    languageColumn.setLabelProvider(new DefaultLanguageLabelProvider());

    currentLanguageTerms.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent e) {
            Rectangle area = currentLanguageTerms.getClientArea();
            Point preferredSize = termsTableViewer.getTable().computeSize(SWT.DEFAULT, SWT.DEFAULT);
            int width = area.width - 2 * termsTableViewer.getTable().getBorderWidth();
            if (preferredSize.y > area.height + termsTableViewer.getTable().getHeaderHeight()) {

              Point vBarSize = termsTableViewer.getTable().getVerticalBar().getSize();
              width -= vBarSize.x;
            }

            Point oldSize = termsTableViewer.getTable().getSize();

            if (oldSize.x > area.width) {
              termColumn.getColumn().setWidth(width * 80 / 100);
              languageColumn.getColumn().setWidth(width * 20 / 100);
              termsTableViewer.getTable().setSize(area.width, area.height);
            } else {

              termsTableViewer.getTable().setSize(area.width, area.height);
              termColumn.getColumn().setWidth(width * 80 / 100);
              languageColumn.getColumn().setWidth(width * 20 / 100);
            }
          }
        });

    Button addTermCurrentLg = new Button(currentLanguageTerms, SWT.PUSH);
    String imageId = org.dafoe.terminoontologiclevel.ui.Activator.NEW_IMG_ID;
    ImageDescriptor imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(imageId);
    Image image = imgDesc.createImage();
    addTermCurrentLg.setImage(image);
    addTermCurrentLg.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));

    addTermCurrentLg.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            addTerm();
          }
        });

    Button removeTermCurrentLg = new Button(currentLanguageTerms, SWT.PUSH);
    imageId = org.dafoe.terminoontologiclevel.ui.Activator.REMOVE_IMG_ID;
    imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(imageId);
    image = imgDesc.createImage();
    removeTermCurrentLg.setImage(image);
    removeTermCurrentLg.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));

    removeTermCurrentLg.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {

            removeTerm();
          }
        });

    // Sentences

    sentencesWidget = new SentenceWidget(comp, SWT.NONE);
    layout = new GridLayout(1, false);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    sentencesWidget.setLayout(layout);
    sentencesWidget.setLayoutData(gd);
    sentencesWidget.setDeletionEventType(TerminologicalViewPart.SENTENCE_DELETED);
    sentencesWidget.addPropertyChangeListener(new SentenceDeletedChangeListener());

    // terms in other languages

    otherLanguageTerms = new Composite(terminoComposite, SWT.NONE);
    layout = new GridLayout(2, false);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    otherLanguageTerms.setLayout(layout);
    otherLanguageTerms.setLayoutData(gd);

    termsOtherLgTableViewer =
        new TableViewer(
            otherLanguageTerms, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    termsOtherLgTableViewer.getTable().setLayoutData(gridData);
    termsOtherLgTableViewer.getTable().setLinesVisible(true);
    termsOtherLgTableViewer.getTable().setHeaderVisible(true);
    termsOtherLgTableViewer.setContentProvider(new TranslatedTermContentProvider());

    // Columns

    termLgColumn = new TableViewerColumn(termsOtherLgTableViewer, SWT.NONE, 0);
    termLgColumn
        .getColumn()
        .setText(Messages.getString("TerminologicalViewPart.17")); // $NON-NLS-1$
    termLgColumn.setLabelProvider(new TranslatedTermLabelProvider());

    termLgColumn
        .getColumn()
        .addSelectionListener(
            new SelectionAdapter() {

              public void widgetSelected(SelectionEvent e) {
                TanslatedTermsTableViewerSorter sorter =
                    new TanslatedTermsTableViewerSorter(TanslatedTermsTableViewerSorter.TERM_SORT);
                termsOtherLgTableViewer.setSorter(sorter);
                termsOtherLgTableViewer.getTable().setSortColumn(termLgColumn.getColumn());
                termsOtherLgTableViewer.getTable().setSortDirection(directionTransTerm);
              }
            });

    languagesColumn = new TableViewerColumn(termsOtherLgTableViewer, SWT.NONE, 1);
    languagesColumn
        .getColumn()
        .setText(Messages.getString("TerminologicalViewPart.18")); // $NON-NLS-1$
    languagesColumn.setLabelProvider(new OtherLanguageLabelProvider());

    languagesColumn
        .getColumn()
        .addSelectionListener(
            new SelectionAdapter() {

              public void widgetSelected(SelectionEvent e) {
                TanslatedTermsTableViewerSorter sorter =
                    new TanslatedTermsTableViewerSorter(TanslatedTermsTableViewerSorter.FLAG_SORT);
                termsOtherLgTableViewer.setSorter(sorter);
                termsOtherLgTableViewer.getTable().setSortColumn(languagesColumn.getColumn());
                termsOtherLgTableViewer.getTable().setSortDirection(directionTransTerm);
              }
            });

    otherLanguageTerms.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent e) {
            Rectangle area = otherLanguageTerms.getClientArea();
            Point preferredSize =
                termsOtherLgTableViewer.getTable().computeSize(SWT.DEFAULT, SWT.DEFAULT);
            int width = area.width - 2 * termsOtherLgTableViewer.getTable().getBorderWidth();
            if (preferredSize.y
                > area.height + termsOtherLgTableViewer.getTable().getHeaderHeight()) {

              Point vBarSize = termsOtherLgTableViewer.getTable().getVerticalBar().getSize();
              width -= vBarSize.x;
            }

            Point oldSize = termsOtherLgTableViewer.getTable().getSize();

            if (oldSize.x > area.width) {

              termLgColumn.getColumn().setWidth(width * 80 / 100);
              languagesColumn.getColumn().setWidth(width * 20 / 100);
              termsOtherLgTableViewer.getTable().setSize(area.width, area.height);
            } else {
              termsOtherLgTableViewer.getTable().setSize(area.width, area.height);
              termLgColumn.getColumn().setWidth(width * 80 / 100);
              languagesColumn.getColumn().setWidth(width * 20 / 100);
            }
          }
        });

    Button addTermOtherLg = new Button(otherLanguageTerms, SWT.PUSH);
    imageId = org.dafoe.terminoontologiclevel.ui.Activator.NEW_IMG_ID;
    imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(imageId);
    image = imgDesc.createImage();
    addTermOtherLg.setImage(image);
    addTermOtherLg.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));

    addTermOtherLg.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {

            addTranslatedTerm();
          }
        });

    Button removeTermOtherLg = new Button(otherLanguageTerms, SWT.PUSH);
    imageId = org.dafoe.terminoontologiclevel.ui.Activator.REMOVE_IMG_ID;
    imgDesc =
        org.dafoe.terminoontologiclevel.ui.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(imageId);
    image = imgDesc.createImage();
    removeTermOtherLg.setImage(image);
    removeTermOtherLg.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));

    removeTermOtherLg.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {

            removeTranslatedTerm();
          }
        });

    //

    ControlerFactoryImpl.getTerminoOntoControler()
        .addPropertyChangeListener(
            ControlerFactoryImpl.currentTerminoConceptEvent,
            new PropertyChangeListener() {
              public void propertyChange(PropertyChangeEvent evt) {

                updateInformation();
              }
            });

    ControlerFactoryImpl.getTerminoOntoControler()
        .addPropertyChangeListener(
            ControlerFactoryImpl.renameTCEvent,
            new PropertyChangeListener() {
              public void propertyChange(PropertyChangeEvent evt) {

                updateInformation();
              }
            });

    makeActions();
    hookPopupMenus();

    updateInformation();
  }