package de.ugoe.cs.swe.memos.gui.menu;

import java.sql.SQLException;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil;

import de.ugoe.cs.swe.memos.database.Connector;
import de.ugoe.cs.swe.memos.database.DatabaseException;

public class closeHandler extends AbstractHandler {
	
	//public static void setEnabled(boolean state) {
	//	enabled = state;
	//}
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		try {
			Connector.closeConnection();
		} catch (DatabaseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		HandlerUtil.getActiveWorkbenchWindow(event).close();
		return null;
	}
}

