/**
 * 
 */
package org.mwc.debrief.core.ui;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.mwc.cmap.core.CorePlugin;
import org.mwc.debrief.core.preferences.PrefsPage.PreferenceConstants;

import Debrief.ReaderWriter.Word.ImportNarrativeDocument.ImportNarrativeEnum;

/**
 * Dialog popped up from {@link ImportNarrativeHelper}
 * @author Ayesha
 *
 */
public class ImportNarrativeDialog extends Dialog
{
  private Button _btnLoadedTracks;
  private ImportNarrativeEnum userChoice;
  private boolean preference;
  
  private SelectionListener selectionListener = new SelectionAdapter()
  {
    @Override
    public void widgetSelected(SelectionEvent e)
    {
      if(_btnLoadedTracks.getSelection()) {
        userChoice = ImportNarrativeEnum.TRIMMED_DATA;
      }
      else{
        userChoice = ImportNarrativeEnum.ALL_DATA;
      }
    }
  };

  public ImportNarrativeDialog(Shell parentShell)
  {
    super(parentShell);
  }
 
  @Override
  protected void configureShell(Shell newShell)
  {
    newShell.setText("Import Narrative Entries");
    
    super.configureShell(newShell);
  }
  @Override
  protected Control createDialogArea(Composite parent)
  {
    Composite control = (Composite)super.createDialogArea(parent);
    Composite composite = new Composite(control,SWT.NONE);
    composite.setLayout(new GridLayout(1,false));
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    
    _btnLoadedTracks = new Button(composite,SWT.RADIO);
    _btnLoadedTracks.setText("Trim to loaded tracks");
    _btnLoadedTracks.addSelectionListener(selectionListener);
    _btnLoadedTracks.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
     Button _btnAllData = new Button(composite,SWT.RADIO);
    _btnAllData.setText("Load all data");
    _btnAllData.addSelectionListener(selectionListener);
    _btnAllData.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    
    
    new Label(composite,SWT.NONE).setLayoutData(new GridData(GridData.FILL));
    new Label(composite,SWT.NONE).setLayoutData(new GridData(GridData.FILL));
    final Button dontAskAgain = new Button(composite,SWT.CHECK);
    dontAskAgain.setText("Use this mode next time");
    dontAskAgain.addSelectionListener(new SelectionAdapter()
    {
      @Override
      public void widgetSelected(SelectionEvent e)
      {
        preference = dontAskAgain.getSelection();
        CorePlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.REUSE_TRIM_NARRATIVES_DIALOG_CHOICE,preference);
      }
    });
    return control;
  }
  
  public boolean getPreference()
  {
    return preference;
  }

  public ImportNarrativeEnum getUserChoice()
  {
    return userChoice;
  }
  
  @Override
  protected void cancelPressed()
  {
    userChoice = ImportNarrativeEnum.CANCEL;
    super.cancelPressed();
  }
  
 
  

}

@@ -86,16 +86,67 @@
 ialog;%0D%0A
+import org.eclipse.jface.resource.FontDescriptor;%0D%0A
 import o
@@ -166,16 +166,16 @@
 t.SWT;%0D%0A
-
 import o
@@ -1006,24 +1006,55 @@
 m userChoice
+ = ImportNarrativeEnum.ALL_DATA
 ;%0D%0A  private
@@ -1997,32 +1997,674 @@
 _HORIZONTAL));%0D%0A
+%0D%0A%0D%0A    Label title = new Label(composite, SWT.BOLD);%0D%0A    FontDescriptor descriptor = FontDescriptor.createFrom(title.getFont());%0D%0A    // setStyle method returns a new font descriptor for the given style%0D%0A    descriptor = descriptor.setStyle(SWT.BOLD);%0D%0A    title.setFont(descriptor.createFont(title.getDisplay()));%0D%0A    title.setText(%22Loading narrative data.%22);    %0D%0A    %0D%0A    Label intro = new Label(composite, SWT.NONE);%0D%0A    intro.setText(%22Please select whether you wish to trim%5Cn%22%0D%0A        + %22the narrative entries to the period of the %5Cn%22%0D%0A        + %22currently loaded tracks, or whether%5Cn%22%0D%0A        + %22all entries should be loaded%22);%0D%0A
     %0D%0A    _btnLo
@@ -2902,24 +2902,66 @@
 IZONTAL));%0D%0A
+    _btnLoadedTracks.setSelection(true);%0D%0A
      Button 
@@ -3731,16 +3731,30 @@
 etValue(
+%0D%0A            
 Preferen
@@ -3801,16 +3801,30 @@
 _CHOICE,
+%0D%0A            
 preferen

Tidy guidance