package org.sagebionetworks.web.client.widget.entity.editor;

import java.util.List;
import java.util.Map;

import org.sagebionetworks.web.client.widget.WidgetEditorPresenter;
import org.sagebionetworks.web.client.widget.entity.dialog.DialogCallback;
import org.sagebionetworks.web.shared.WikiPageKey;

import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;

public class DetailsSummaryConfigEditor implements WidgetEditorPresenter {
	
	private DetailsSummaryConfigView view;
	@Inject
	public DetailsSummaryConfigEditor(DetailsSummaryConfigView view) {
		this.view = view;
		view.initView();
	}		
	@Override
	public void configure(WikiPageKey wikiKey, Map<String, String> widgetDescriptor, DialogCallback dialogCallback) {
		//no way to edit existing
	}
	
	@SuppressWarnings("unchecked")
	public void clearState() {
		view.clear();
	}

	@Override
	public Widget asWidget() {
		return view.asWidget();
	}
	
	@Override
	public void updateDescriptorFromView() {
		//update widget descriptor from the view
		view.checkParams();
	}
	
	@Override
	public String getTextToInsert() {
		return "\n<details>\n\n" + 
				"  <summary>"+view.getSummary()+"</summary>\n\n" +
				view.getDetails() +
				"\n\n</details>\n";
	}
	
	@Override
	public List<String> getNewFileHandleIds() {
		return null;
	}
	@Override
	public List<String> getDeletedFileHandleIds() {
		return null;
	}
}

@@ -1130,10 +1130,8 @@
 %09%09%09%22
-  
 %3Csum

remove a couple of spaces only