<commit_before>/*******************************************************************************
 * Debrief - the Open Source Maritime Analysis Application
 * http://debrief.info
 *
 * (C) 2000-2020, Deep Blue C Technology 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.debrief.pepys;

import java.beans.PropertyVetoException;
import java.io.IOException;
import java.util.HashMap;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.mwc.cmap.plotViewer.actions.CoreEditorAction;
import org.mwc.debrief.pepys.controller.PepysImportController;
import org.mwc.debrief.pepys.model.PepysConnectorBridge;
import org.mwc.debrief.pepys.model.db.DatabaseConnection;
import org.mwc.debrief.pepys.model.db.PostgresDatabaseConnection;
import org.mwc.debrief.pepys.model.db.SqliteDatabaseConnection;
import org.mwc.debrief.pepys.model.db.config.DatabaseConfiguration;

import MWC.GUI.Layers;
import MWC.GUI.PlainChart;
import MWC.GenericData.WorldArea;

public class ImportDatabase extends CoreEditorAction {

	@Override
	protected void execute() {
		final PlainChart theChart = getChart();

		final PepysConnectorBridge pepysBridge = new PepysConnectorBridge() {

			@Override
			public WorldArea getCurrentArea() {
				return new WorldArea(theChart.getCanvas().getProjection().getVisibleDataArea());
			}

			@Override
			public Layers getLayers() {
				return theChart.getLayers();
			}
		};

		final Shell shell = new Shell(PlatformUI.getWorkbench().getDisplay(),
				SWT.APPLICATION_MODAL | SWT.MIN | SWT.CLOSE | SWT.RESIZE | SWT.MAX);
		shell.setMinimumSize(600, 450);
		final DatabaseConfiguration databaseConfiguration = new DatabaseConfiguration();
		try {
			DatabaseConnection.loadDatabaseConfiguration(databaseConfiguration,
					DatabaseConnection.DEFAULT_DATABASE_FILE);

			final HashMap<String, String> category = databaseConfiguration
					.getCategory(DatabaseConnection.CONFIGURATION_TAG);
			if (category != null && category.containsKey(DatabaseConnection.CONFIGURATION_DATABASE_TYPE)) {
				final String databaseType = category.get(DatabaseConnection.CONFIGURATION_DATABASE_TYPE);
				if (databaseType != null) {
					final DatabaseConnection conn;
					switch (databaseType) {
					case DatabaseConnection.POSTGRES:
						conn = new PostgresDatabaseConnection();
						break;
					case DatabaseConnection.SQLITE:
						conn = new SqliteDatabaseConnection();<commit_msg>Minimum Size for Windows<commit_after>/*******************************************************************************
 * Debrief - the Open Source Maritime Analysis Application
 * http://debrief.info
 *
 * (C) 2000-2020, Deep Blue C Technology 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.debrief.pepys;

import java.beans.PropertyVetoException;
import java.io.IOException;
import java.util.HashMap;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.mwc.cmap.plotViewer.actions.CoreEditorAction;
import org.mwc.debrief.pepys.controller.PepysImportController;
import org.mwc.debrief.pepys.model.PepysConnectorBridge;
import org.mwc.debrief.pepys.model.db.DatabaseConnection;
import org.mwc.debrief.pepys.model.db.PostgresDatabaseConnection;
import org.mwc.debrief.pepys.model.db.SqliteDatabaseConnection;
import org.mwc.debrief.pepys.model.db.config.DatabaseConfiguration;

import MWC.GUI.Layers;
import MWC.GUI.PlainChart;
import MWC.GenericData.WorldArea;

public class ImportDatabase extends CoreEditorAction {

	@Override
	protected void execute() {
		final PlainChart theChart = getChart();

		final PepysConnectorBridge pepysBridge = new PepysConnectorBridge() {

			@Override
			public WorldArea getCurrentArea() {
				return new WorldArea(theChart.getCanvas().getProjection().getVisibleDataArea());
			}

			@Override
			public Layers getLayers() {
				return theChart.getLayers();
			}
		};

		final Shell shell = new Shell(PlatformUI.getWorkbench().getDisplay(),
				SWT.APPLICATION_MODAL | SWT.MIN | SWT.CLOSE | SWT.RESIZE | SWT.MAX);
		shell.setMinimumSize(1200, 850);
		final DatabaseConfiguration databaseConfiguration = new DatabaseConfiguration();
		try {
			DatabaseConnection.loadDatabaseConfiguration(databaseConfiguration,
					DatabaseConnection.DEFAULT_DATABASE_FILE);

			final HashMap<String, String> category = databaseConfiguration
					.getCategory(DatabaseConnection.CONFIGURATION_TAG);
			if (category != null && category.containsKey(DatabaseConnection.CONFIGURATION_DATABASE_TYPE)) {
				final String databaseType = category.get(DatabaseConnection.CONFIGURATION_DATABASE_TYPE);
				if (databaseType != null) {
					final DatabaseConnection conn;
					switch (databaseType) {
					case DatabaseConnection.POSTGRES:
						conn = new PostgresDatabaseConnection();
						break;
					case DatabaseConnection.SQLITE:
						conn = new SqliteDatabaseConnection();
{'fraction_non_alphanumeric': 0.14177823549605217, 'fraction_numerical': 0.006350841057329214, 'mean_word_length': 5.159619450317125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3439271', 'n_tokens_mistral': 1844, 'n_tokens_neox': 1609, 'n_words': 376}