Esempio n. 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();
    }
  }
Esempio n. 2
0
    @Override
    public void propertyChange(PropertyChangeEvent arg0) {

      DatabaseAdapter.deleteSentencesFromTC(
          ControlerFactoryImpl.getTerminoOntoControler().getCurrentTerminoConcept(),
          sentencesWidget.getSelection());

      updateInformation();
    }
Esempio n. 3
0
  public void updateInformation() {

    currentTerminoConcept =
        ControlerFactoryImpl.getTerminoOntoControler().getCurrentTerminoConcept();

    if (currentTerminoConcept != null) {
      terminoConceptText.setText(currentTerminoConcept.getLabel());
      termsTableViewer.setInput(UtilTools.setToList(currentTerminoConcept.getMappedTerms()));
      termsOtherLgTableViewer.setInput(getTCTranslationAnnotations(currentTerminoConcept));
      sentencesWidget.setInput(getSentences());
    }
  }
Esempio n. 4
0
  private void removeTranslatedTerm() {
    TableItem[] sel = termsOtherLgTableViewer.getTable().getSelection();

    if (sel.length > 0) {

      ITerminoOntoAnnotation selAnnot = (ITerminoOntoAnnotation) (sel[0].getData());

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

      DatabaseAdapter.deleteTCAnnotation(tc, selAnnot);

      updateInformation();
    }
  }
Esempio n. 5
0
  private void addTerm() {

    NewTermDialog dialog = new NewTermDialog(shell, TerminologicalViewPart.this, false);
    dialog.open();

    if (dialog.getReturnCode() == IDialogConstants.OK_ID) {

      if (dialog.getTerm().compareTo("") != 0) { // $NON-NLS-1$

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

        ITerm t =
            org.dafoe.terminology.common.DatabaseAdapter.createTermFromLabel(
                dialog.getTerm(), TERMINO_OBJECT_STATE.VALIDATED, LINGUISTIC_STATUS.TERM);

        DatabaseAdapter.linkTCWithTerm(tc, t);

        updateInformation();
      }
    }
  }
Esempio n. 6
0
  private void addTranslatedTerm() {
    NewTermDialog dialog = new NewTermDialog(shell, TerminologicalViewPart.this, true);
    dialog.open();

    if (dialog.getReturnCode() == IDialogConstants.OK_ID) {

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

      String selLanguage = dialog.getLanguage();
      String databaseAnnotation = DatabaseAdapter.LABEL_EN_ANNOTATION;

      if (selLanguage.compareTo(NewTermDialog.SPANISH) == 0) {
        databaseAnnotation = DatabaseAdapter.LABEL_SP_ANNOTATION;
      } else if (selLanguage.compareTo(NewTermDialog.ENGLISH) == 0) {
        databaseAnnotation = DatabaseAdapter.LABEL_EN_ANNOTATION;
      }

      DatabaseAdapter.createTCAnnotation(tc, databaseAnnotation, dialog.getTerm());

      updateInformation();
    }
  }
Esempio n. 7
0
  @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();
  }