/*******************************************************************************
 * Copyright (c) 2009 Tasktop Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.sandbox.dev;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.ui.handlers.HandlerUtil;

public class IntrospectObjectHandler extends AbstractHandler {

	public Object execute(ExecutionEvent event) throws ExecutionException {
		ISelection currentSelection = HandlerUtil.getCurrentSelection(event);

		String text = "Current selection: " + currentSelection + "\n";
		text += "Active menu selection: " + HandlerUtil.getActiveMenuSelection(event) + "\n";
		text += "Active menu editor input: " + HandlerUtil.getActiveMenuEditorInput(event) + "\n";
		text += "\n";

		if (currentSelection instanceof StructuredSelection && !currentSelection.isEmpty()) {
			StructuredSelection selection = (StructuredSelection) currentSelection;
			Object object = selection.getFirstElement();

			text += "Object class: " + object.getClass() + "\n\n";

			try {
				AbstractContextStructureBridge bridge = ContextCore.getStructureBridge(object);
				IInteractionElement node = ContextCore.getContextManager().getElement(
						bridge.getHandleIdentifier(object));
				if (node != null) {
					text += "Interest value: " + node.getInterest().getValue() + "\n";
					text += node.getInterest().toString();
				}
			} catch (Throwable t) {
				text += "<no structure bridge>";
			}

			if (object instanceof IAdaptable) {
				Object resourceAdapter = ((IAdaptable) object).getAdapter(IResource.class);
				if (resourceAdapter != null) {
					text += "\nResource adapter: " + ((IResource) resourceAdapter).getFullPath().toOSString();
				}
			}

			if (object instanceof ITask) {

				AbstractTask task = null;
				if (object instanceof ITask) {
					task = (AbstractTask) object;
				}
				if (task != null) {
					TaskRepository repository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(),
							task.getRepositoryUrl());
					text += "\nHandle Identifier: " + task.getHandleIdentifier();
					text += "\nLast time in SYNCHRONIZED state: " + task.getLastReadTimeStamp();
					if (repository != null) {
						text += "\nRepository synch time stamp: " + repository.getSynchronizationTimeStamp();
					} else {
						text += "\nRepository is null (!), url is: " + task.getRepositoryUrl();
					}
					text += "\nSync state: " + task.getSynchronizationState();
					text += "\nParents: " + task.getParentContainers();
					if (task.getChildren() != null && !task.getChildren().isEmpty()) {
						text += "\nChildren: ";
						for (ITask subTask : task.getChildren()) {
							text += "\n" + subTask;
						}
					}
				}
			}
			text += "\n\nNum tasks: " + TasksUiPlugin.getTaskList().getAllTasks().size();
			text += "\nNum queries: " + TasksUiPlugin.getTaskList().getQueries().size();

		}
		MessageDialog.openInformation(null, "Mylyn Sandbox", text);
		return null;
	}

}
