<commit_before>package org.ai4fm.proofprocess.ui.features

import org.ai4fm.proofprocess.{ProofStep, Term}
import org.ai4fm.proofprocess.core.util.PProcessUtil.getAdapter
import org.ai4fm.proofprocess.ui.TermSelectionSourceProvider
import org.ai4fm.proofprocess.ui.internal.PProcessUIPlugin.plugin
import org.ai4fm.proofprocess.ui.util.SWTUtil.{fnToDoubleClickListener, selectionElement}
import org.ai4fm.proofprocess.ui.util.ScalaArrayContentProvider

import org.eclipse.emf.edit.provider.ComposedAdapterFactory
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider
import org.eclipse.jface.dialogs.StatusDialog
import org.eclipse.jface.layout.{GridDataFactory, GridLayoutFactory}
import org.eclipse.jface.resource.{JFaceResources, LocalResourceManager}
import org.eclipse.jface.viewers.{DoubleClickEvent, StructuredSelection, StyledString, TableViewer}
import org.eclipse.swt.SWT
import org.eclipse.swt.custom.StyledText
import org.eclipse.swt.widgets.{Composite, Control, Shell, Text}
import org.eclipse.ui.forms.events.{ExpansionAdapter, ExpansionEvent}
import org.eclipse.ui.forms.widgets.{FormToolkit, Section}
import org.eclipse.ui.forms.widgets.ExpandableComposite.{EXPANDED, NO_TITLE_FOCUS_BOX, TITLE_BAR, TWISTIE}


/**
 * A dialog to select/extract a sub-term from the given term
 * 
 * @author <NAME>
 */
class SubTermSelectionDialog(parent: Shell, term: Term, context: ProofStep) extends StatusDialog(parent) {

  private val adapterFactory =
    new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)

  private val labelProvider = new AdapterFactoryLabelProvider(adapterFactory)

  private var renderedTermField: StyledText = _

  private var subTermsTable: TableViewer = _

  private var schemaTermsTable: TableViewer = _

  setTitle("Select Sub-term")
  setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE)

  override def getDialogBoundsSettings = plugin.dialogSettings("SubTermSelectionDialog")

  /**
   * Create the dialog area.
   *
   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
   */
  override def createDialogArea(parent: Composite): Control = {
    
    val toolkit = new FormToolkit(parent.getDisplay)
    val form = toolkit.createScrolledForm(parent)
    form.setLayoutData(GridDataFactory.fillDefaults.grab(true, true).create)<commit_msg>allow changing OK button label<commit_after>package org.ai4fm.proofprocess.ui.features

import org.ai4fm.proofprocess.{ProofStep, Term}
import org.ai4fm.proofprocess.core.util.PProcessUtil.getAdapter
import org.ai4fm.proofprocess.ui.TermSelectionSourceProvider
import org.ai4fm.proofprocess.ui.internal.PProcessUIPlugin.plugin
import org.ai4fm.proofprocess.ui.util.SWTUtil.{fnToDoubleClickListener, selectionElement}
import org.ai4fm.proofprocess.ui.util.ScalaArrayContentProvider

import org.eclipse.core.runtime.IStatus
import org.eclipse.emf.edit.provider.ComposedAdapterFactory
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider
import org.eclipse.jface.dialogs.{IDialogConstants, StatusDialog}
import org.eclipse.jface.layout.{GridDataFactory, GridLayoutFactory}
import org.eclipse.jface.resource.{JFaceResources, LocalResourceManager}
import org.eclipse.jface.viewers.{DoubleClickEvent, StructuredSelection, StyledString, TableViewer}
import org.eclipse.swt.SWT
import org.eclipse.swt.custom.StyledText
import org.eclipse.swt.widgets.{Button, Composite, Control, Shell, Text}
import org.eclipse.ui.forms.events.{ExpansionAdapter, ExpansionEvent}
import org.eclipse.ui.forms.widgets.{FormToolkit, Section}
import org.eclipse.ui.forms.widgets.ExpandableComposite.{EXPANDED, NO_TITLE_FOCUS_BOX, TITLE_BAR, TWISTIE}


/**
 * A dialog to select/extract a sub-term from the given term
 *
 * @author <NAME>
 */
class SubTermSelectionDialog(parent: Shell,
                             term: Term,
                             context: ProofStep,
                             okButtonLabel: Option[String] = None) extends StatusDialog(parent) {

  private val adapterFactory =
    new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)

  private val labelProvider = new AdapterFactoryLabelProvider(adapterFactory)

  private var renderedTermField: StyledText = _

  private var subTermsTable: TableViewer = _

  private var schemaTermsTable: TableViewer = _

  private var okButton: Button = _

  setTitle("Select Sub-term")
  setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE)

  override def getDialogBoundsSettings = plugin.dialogSettings("SubTermSelectionDialog")

  override protected def createButtonsForButtonBar(parent: Composite) {
    val okLabel = okButtonLabel getOrElse IDialogConstants.OK_LABEL
    okButton = createButton(parent, IDialogConstants.OK_ID, okLabel, true)
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false)
  }

  override protected def updateButtonsEnableState(status: IStatus) =
    Option(okButton) filterNot (_.isDisposed) match {
      case Some(button) => button.setEnabled(!status.matches(IStatus.ERROR))
      case None => // ignore
    }

  /**
   * Create the dialog area.
   *
   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
   */
  override def createDialogArea(parent: Composite): Control = {
    
    val toolkit = new FormToolkit(parent.getDisplay)
    val form = toolkit.createScrolledForm(parent)
    form.setLayoutData(GridDataFactory.fillDefaults.grab(true, true).create)
{'fraction_non_alphanumeric': 0.09255865102639296, 'fraction_numerical': 0.002565982404692082, 'mean_word_length': 5.272413793103448, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1798442', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1617, 'n_words': 298}