package org.callimachusproject.webdriver.pages;

import org.callimachusproject.webdriver.helpers.WebBrowserDriver;
import org.openqa.selenium.By;

public class ClassEdit extends CalliPage {

	public ClassEdit(WebBrowserDriver driver) {
		super(driver);
	}

	public ClassEdit with(String label, String comment) {
		browser.type(By.id("label"), label);
		browser.type(By.id("comment"), comment);
		return this;
	}

	public ClassView create() {
		browser.submit(By.id("create"));
		return page(ClassView.class);
	}

	public CalliPage delete(String conceptLabel) {
		browser.click(By.id("delete"));
		browser.confirm("Are you sure you want to delete " + conceptLabel);
		return page();
	}

	public TextEditor openCreateTemplate() {
		browser.click(By.cssSelector("#create label a"));
		browser.waitForScript();
		browser.focusInFrame("create-template");
		browser.waitForScript();
		final ClassEdit edit = this;
		return new TextEditor("create-template", browser) {
			@Override
			public ClassEdit saveAs(String name) {
				super.saveAs(name);
				browser.focusInTopWindow();
				return edit;
			}
		};
	}

	public TextEditor openViewTemplate() {
		browser.click(By.cssSelector("#view label a"));
		browser.waitForScript();
		browser.focusInFrame("view-template");
		browser.waitForScript();
		final ClassEdit edit = this;
		return new TextEditor("view-template", browser) {
			@Override
			public ClassEdit saveAs(String name) {
				super.saveAs(name);
				browser.focusInTopWindow();
				return edit;
			}
		};
	}

	public TextEditor openEditTemplate() {
		browser.click(By.cssSelector("#edit label a"));
		browser.waitForScript();
		browser.focusInFrame("edit-template");
		browser.waitForScript();
		final ClassEdit edit = this;
		return new TextEditor("edit-template", browser) {
			@Override
			public ClassEdit saveAs(String name) {
				super.saveAs(name);
				browser.focusInTopWindow();
				return edit;
			}
		};
	}

}

@@ -824,31 +824,24 @@
 nFrame(%22
-create-
 template
 %22);%0A%09%09br
@@ -824,32 +824,45 @@
 nFrame(%22template
+-for-creating
 %22);%0A%09%09browser.wa
@@ -936,23 +936,16 @@
 or(%22
-create-
 template
 %22, b
@@ -932,32 +932,45 @@
 Editor(%22template
+-for-creating
 %22, browser) %7B%0A%09%09
@@ -1250,29 +1250,24 @@
 nFrame(%22
-view-
 template
 %22);%0A%09%09br
@@ -1250,32 +1250,44 @@
 nFrame(%22template
+-for-viewing
 %22);%0A%09%09browser.wa
@@ -1361,21 +1361,16 @@
 or(%22
-view-
 template
 %22, b
@@ -1357,32 +1357,44 @@
 Editor(%22template
+-for-viewing
 %22, browser) %7B%0A%09%09
@@ -1674,29 +1674,24 @@
 nFrame(%22
-edit-
 template
 %22);%0A%09%09br
@@ -1682,16 +1682,28 @@
 template
+-for-editing
 %22);%0A%09%09br
@@ -1785,21 +1785,16 @@
 or(%22
-edit-
 template
 %22, b
@@ -1789,16 +1789,28 @@
 template
+-for-editing
 %22, brows

Update dialogue title in tests