/*******************************************************************************
 * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the LGPL 3.0
 * which accompanies this distribution, and is available at
 * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
 *
 * Contributors:
 *     Faiez Zalila - initial API and implementation and/or initial documentation
 *     Jorge Enrique Gutierrez Zuluaga
 *******************************************************************************/
package com.irtsaintexupery.fiacre.simulator.perspective;

import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class PerspectiveSimulatorFactory implements IPerspectiveFactory {

	@Override
	public void createInitialLayout(IPageLayout layout) {
		defineActions(layout);
		defineLayout(layout);

	}
	
	public void defineActions (IPageLayout layout){
		//Add "new wizards"
		layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");
		layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");
		
		//Add "show views"
		layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
		layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS);
		layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
		layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
		layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
		layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
	}
	
	public void defineLayout(IPageLayout layout) {
		//Editors are placed for free
		String editorArea = layout.getEditorArea();
		
		//Place navigator and outiline to left of editor area.
		IFolderLayout navigator = layout.createFolder("navigator", 
				IPageLayout.LEFT, (float) 0.18, editorArea);
		IFolderLayout instances = layout.createFolder("instances", 
				IPageLayout.RIGHT, (float) 0.75, editorArea);
		IFolderLayout values = layout.createFolder("values", 
				IPageLayout.BOTTOM, (float) 0.75, editorArea);
		IFolderLayout transitions = layout.createFolder("transitions", 
				IPageLayout.BOTTOM, (float) 0.25, "instances");
		IFolderLayout executedAction = layout.createFolder("executedAction", 
				IPageLayout.BOTTOM, (float) 0.5, "transitions");
		IFolderLayout savedStates = layout.createFolder("savedStates", 
				IPageLayout.BOTTOM, (float) 0.4, "executedAction");
		
		navigator.addView("org.eclipse.ui.navigator.ProjectExplorer");
		instances.addView("com.irtsaintexupery.fiacre.simulator.perspective"
				+ ".instancesView");
		transitions.addView("com.irtsaintexupery.fiacre.simulator.perspective"
				+ ".transitionsView");
		values.addView("com.irtsaintexupery.fiacre.simulator.perspective"
				+ ".valuesView");
		executedAction.addView("com.irtsaintexupery.fiacre.simulator.perspective"
				+ ".executedActionView");
		executedAction.addView("com.irtsaintexupery.fiacre.simulator.perspective"
				+ ".savedStatesView");
	}
	
	public interface IPerspectivePlugin {
		//*plugin id
		public final static String PLUGIN_ID = "com.irtsaintexupery.fiacre"
				+ ".simulator.perspective";
		
		//*perspective id
		public final static String TEST_PERSPECTIVE_ID = "com.irtsaintexupery"
				+ ".fiacre.simulator.perspective.fiacreSimulator";
		
	}

}
