<commit_before>/*
 *    Debrief - the Open Source Maritime Analysis Application
 *    http://debrief.info
 *
 *    (C) 2000-2014, PlanetMayo Ltd
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the Eclipse Public License v1.0
 *    (http://www.eclipse.org/legal/epl-v10.html)
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
package org.mwc.cmap.TimeController.wizards;

import java.io.File;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.mwc.cmap.core.CorePlugin;
import org.mwc.debrief.core.preferences.PrefsPage;

import Debrief.ReaderWriter.powerPoint.PlotTracks;

/**
 * @author Ayesha <<EMAIL>>
 *
 */
public class ExportPPTDialog extends Dialog
{

  public static final String PREF_PPT_EXPORT_LOCATION = "pptExportLocation";
  public static final String PREF_PPT_EXPORT_FILENAME = "pptExportFilename";
  public static final String PREF_PPT_EXPORT_FILEFORMAT = "pptExportFormat";
  public static final String PREF_PPT_EXPORT_OPEN_FILE = "pptExportOpenFile";
  public static final String PREF_PPT_EXPORT_VISIBLE_BAR =
      "pptExportVisibleBar";
  public static final String PREF_PPT_EXPORT_UNIT_BAR = "pptExportUnitBar";

  private static final String[] supportedFormats =
  {"PPTX"};
  private static final String[] unitsScaleBar =
  {MWC.GUI.Properties.UnitsPropertyEditor.YDS_UNITS,
      MWC.GUI.Properties.UnitsPropertyEditor.KYD_UNITS,
      MWC.GUI.Properties.UnitsPropertyEditor.NM_UNITS,
      MWC.GUI.Properties.UnitsPropertyEditor.KM_UNITS,
      MWC.GUI.Properties.UnitsPropertyEditor.METRES_UNITS};

  private static String getFileNameStem(final String fileName)
  {
    final String newName;
    if (fileName.indexOf("-") != -1)
    {
      newName = fileName.substring(0, fileName.lastIndexOf("-"));
    }
    else
    {
      newName = fileName;
    }
    return newName;
  }

  private Text txtExportLocation;
  private Text txtFilename;

  private Combo cmbFileFormats;
  private Combo cmbScaleBarUnits;
  private Button checkScaleBarVisible;

  private String fileFormat;
  private String fileName;
  private String scaleBarUnit;

  private String exportLocation;
  private boolean viewOnComplete = true;
  private boolean scaleBarVisible = true;

  private Button viewOnCompleteBtn;

  public ExportPPTDialog(final Shell parentShell)
  {
    super(parentShell);

    // load prefs
    exportLocation = PlatformUI.getPreferenceStore().getString(
        PREF_PPT_EXPORT_LOCATION);
    fileName = PlatformUI.getPreferenceStore().getString(
        PREF_PPT_EXPORT_FILENAME);
    if (fileName == null || fileName.isEmpty())
    {
      fileName = "DebriefExport";
    }
    fileFormat = PlatformUI.getPreferenceStore().getString(
        PREF_PPT_EXPORT_FILEFORMAT);
    viewOnComplete = PlatformUI.getPreferenceStore().getBoolean(
        PREF_PPT_EXPORT_OPEN_FILE);
    scaleBarVisible = PlatformUI.getPreferenceStore().getBoolean(
        PREF_PPT_EXPORT_VISIBLE_BAR);
    scaleBarUnit = PlatformUI.getPreferenceStore().getString(
        PREF_PPT_EXPORT_UNIT_BAR);
  }

  @Override
  protected void configureShell(final Shell newShell)
  {
    super.configureShell(newShell);
    newShell.setText("Debrief export");
    setShellStyle(SWT.RESIZE);
    newShell.setSize(550, 350);
  }

  @Override
  protected void createButtonsForButtonBar(final Composite parent)
  {
    ((GridLayout) parent.getLayout()).numColumns++;
    final Link link = new Link(parent, SWT.NONE);
    link.setText("<a>Click to view PPT template</a>");
    link.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
    link.addSelectionListener(new SelectionAdapter()
    {
      @Override
      public void widgetSelected(final SelectionEvent e)
      {
        final String prefId = "org.mwc.debrief.core.preferences.PrefsPage";
        final PreferenceDialog dialog = PreferencesUtil
            .createPreferenceDialogOn(link.getShell(), prefId, null, null);
        dialog.open();
      }
    });

    // create OK and Cancel buttons by default
    createButton(parent, IDialogConstants.OK_ID, "Export", true);
    createButton(parent, IDialogConstants.CANCEL_ID,
        IDialogConstants.CANCEL_LABEL, false);
    getButton(OK).setEnabled(false);

  }

  @Override<commit_msg>Fix missing<commit_after>/*
 *    Debrief - the Open Source Maritime Analysis Application
 *    http://debrief.info
 *
 *    (C) 2000-2014, PlanetMayo Ltd
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the Eclipse Public License v1.0
 *    (http://www.eclipse.org/legal/epl-v10.html)
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
package org.mwc.cmap.TimeController.wizards;

import java.io.File;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.mwc.cmap.core.CorePlugin;
import org.mwc.debrief.core.preferences.PrefsPage;

import Debrief.ReaderWriter.powerPoint.PlotTracks;

/**
 * @author Ayesha <<EMAIL>>
 *
 */
public class ExportPPTDialog extends Dialog
{

  public static final String PREF_PPT_EXPORT_LOCATION = "pptExportLocation";
  public static final String PREF_PPT_EXPORT_FILENAME = "pptExportFilename";
  public static final String PREF_PPT_EXPORT_FILEFORMAT = "pptExportFormat";
  public static final String PREF_PPT_EXPORT_OPEN_FILE = "pptExportOpenFile";
  public static final String PREF_PPT_EXPORT_VISIBLE_BAR =
      "pptExportVisibleBar";
  public static final String PREF_PPT_EXPORT_UNIT_BAR = "pptExportUnitBar";

  private static final String[] supportedFormats =
  {"PPTX"};
  private static final String[] unitsScaleBar =
  {MWC.GUI.Properties.UnitsPropertyEditor.YDS_UNITS,
      MWC.GUI.Properties.UnitsPropertyEditor.KYD_UNITS,
      MWC.GUI.Properties.UnitsPropertyEditor.NM_UNITS,
      MWC.GUI.Properties.UnitsPropertyEditor.KM_UNITS,
      MWC.GUI.Properties.UnitsPropertyEditor.METRES_UNITS};

  private static String getFileNameStem(final String fileName)
  {
    final String newName;
    if (fileName.indexOf("-") != -1)
    {
      newName = fileName.substring(0, fileName.lastIndexOf("-"));
    }
    else
    {
      newName = fileName;
    }
    return newName;
  }

  private Text txtExportLocation;
  private Text txtFilename;

  private Combo cmbFileFormats;
  private Combo cmbScaleBarUnits;
  private Button checkScaleBarVisible;

  private String fileFormat;
  private String fileName;
  private String scaleBarUnit;

  private String exportLocation;
  private boolean viewOnComplete = true;
  private boolean scaleBarVisible = true;

  private Button viewOnCompleteBtn;

  public ExportPPTDialog(final Shell parentShell)
  {
    super(parentShell);

    // load prefs
    exportLocation = PlatformUI.getPreferenceStore().getString(
        PREF_PPT_EXPORT_LOCATION);
    fileName = PlatformUI.getPreferenceStore().getString(
        PREF_PPT_EXPORT_FILENAME);
    if (fileName == null || fileName.isEmpty())
    {
      fileName = "DebriefExport";
    }
    fileFormat = PlatformUI.getPreferenceStore().getString(
        PREF_PPT_EXPORT_FILEFORMAT);
    viewOnComplete = PlatformUI.getPreferenceStore().getBoolean(
        PREF_PPT_EXPORT_OPEN_FILE);
    scaleBarVisible = PlatformUI.getPreferenceStore().getBoolean(
        PREF_PPT_EXPORT_VISIBLE_BAR);
    scaleBarUnit = PlatformUI.getPreferenceStore().getString(
        PREF_PPT_EXPORT_UNIT_BAR);
  }

  @Override
  protected void configureShell(final Shell newShell)
  {
    super.configureShell(newShell);
    newShell.setText("Debrief export");
    setShellStyle(SWT.RESIZE);
    newShell.setSize(550, 350);
  }

  @Override
  protected void createButtonsForButtonBar(final Composite parent)
  {
    ((GridLayout) parent.getLayout()).numColumns++;
    final Link link = new Link(parent, SWT.NONE);
    link.setText("<a>Click to view PPT template</a>");
    link.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
    link.addSelectionListener(new SelectionAdapter()
    {
      @Override
      public void widgetSelected(final SelectionEvent e)
      {
        final String prefId = "org.mwc.debrief.core.preferences.PrefsPage";
        final PreferenceDialog dialog = PreferencesUtil
            .createPreferenceDialogOn(link.getShell(), prefId, null, null);
        dialog.open();
      }
    });

    // create OK and Cancel buttons by default
    createButton(parent, IDialogConstants.OK_ID, "Export", true);
    createButton(parent, IDialogConstants.CANCEL_ID,
        IDialogConstants.CANCEL_LABEL, false);
    getButton(OK).setEnabled(isValid());

  }

  @Override
{'fraction_non_alphanumeric': 0.09542557180352455, 'fraction_numerical': 0.0037495313085864268, 'mean_word_length': 4.134263715110683, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5836020', 'n_tokens_mistral': 3366, 'n_tokens_neox': 3274, 'n_words': 686}