/*******************************************************************************
 * 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.FileNotFoundException;
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.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 org.mwc.debrief.pepys.presenter.PepysImportPresenter;

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());
		final DatabaseConfiguration databaseConfiguration = new DatabaseConfiguration();
		try {
			DatabaseConnection.loadDatabaseConfiguration(databaseConfiguration);

			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) {
					if (databaseType.equals(DatabaseConnection.POSTGRES)) {
						new PostgresDatabaseConnection().createInstance(databaseConfiguration);
					} else if (databaseType.equals(DatabaseConnection.SQLITE)) {
						new SqliteDatabaseConnection().createInstance(databaseConfiguration);
					}
				}
			}
		} catch (FileNotFoundException | PropertyVetoException e) {
			// Invalid Database Configuration error
			e.printStackTrace();

			final MessageBox messageBox = new MessageBox(shell, SWT.ERROR | SWT.OK);
			messageBox.setMessage(e.toString());
			messageBox.setText("Error in database configuration file.");
			messageBox.open();
		}

		if (DatabaseConnection.getInstance() != null) {
			new PepysImportPresenter(shell, pepysBridge, getChart().getLayers());

			shell.pack();
			shell.open();
		}
	}

}

@@ -2493,32 +2493,77 @@
 %09%09%09%09
-if (databaseType.equals(
+final DatabaseConnection conn;%0A%09%09%09%09%09switch(databaseType) %7B%0A%09%09%09%09%09case 
 Data
@@ -2585,27 +2585,31 @@
 POSTGRES
-)) %7B
+:
 %0A%09%09%09%09%09%09
+conn = 
 new Post
@@ -2636,84 +2636,33 @@
 on()
-.createInstance(databaseConfiguration);%0A%09%09%09%09%09%7D else if (databaseType.equals(
+;%0A%09%09%09%09%09%09break;%0A%09%09%09%09%09case 
 Data
@@ -2686,19 +2686,28 @@
 LITE
-)) %7B
+:%09%09%09%09%09
 %0A%09%09%09%09%09%09
+conn = 
 new 
@@ -2732,16 +2732,123 @@
 ection()
+;%0A%09%09%09%09%09%09break;%09%09%09%09%09%0A%09%09%09%09%09default:%0A%09%09%09%09%09%09conn = null;%0A%09%09%09%09%09%09break;%0A%09%09%09%09%09%7D%0A%09%09%09%09%09if(conn != null) %7B%0A%09%09%09%09%09%09conn
 .createI

Use switch instead of `if`