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

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;

import de.ugoe.cs.swe.memos.Utils;

public class searchHandler implements IHandler {
	private static boolean enabled = true;

	public static void setEnabled(boolean state) {
		enabled = state;
	}

	@Override
	public void addHandlerListener(IHandlerListener handlerListener) {

	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		// TODO: Deactivated until Release 2
		/*
		 * if (getMainView().getEmptySearchTab() == null) { TabItem tab =
		 * getMainView().addTabItem("S:"); getMainView().setEmptySearchTab(tab);
		 * }
		 */
		Utils.getMainView().getTabFolder().setSelection(
				Utils.getMainView().getTabFolder().getItems()[0]);

		Utils.getMainView().getSearchField().setFocus();
		return null;
	}

	@Override
	public boolean isEnabled() {
		return enabled;
	}

	@Override
	public boolean isHandled() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public void removeHandlerListener(IHandlerListener handlerListener) {
		// TODO Auto-generated method stub

	}

}
