/* $Id: IDATNameInGSTabbedPaneManager.java 125 2011-03-09 09:49:51Z ohura $ */
package smart_gs.swingui;

import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;

import javax.swing.text.html.HTMLDocument.Iterator;

import smart_gs.logical.Spread;
import smart_gs.smleditor.swingui.GSTabbedPane;

public class IDATNameInGSTabbedPaneManager {
	private static Set<GSTabbedPane> gSEditorTabbedPaneMemory = new HashSet<GSTabbedPane>();
	
	public static void registorGSEditorTabbedPane (GSTabbedPane tp) {
		gSEditorTabbedPaneMemory.add(tp);
	}
	
	public static void unregistorGSEditorTabbedPane (GSTabbedPane tp) {
		gSEditorTabbedPaneMemory.remove(tp);
	}
	
	public static void updateTabtitles (){
		GSTabbedPane gstbpane;
		Spread spread;
		Enumeration<GSTabbedPane> enm = Collections.enumeration(gSEditorTabbedPaneMemory);
		while(enm.hasMoreElements()){
			 gstbpane = enm.nextElement();
			 spread = gstbpane.getSpread();
			 gstbpane.setTitleAt(1, spread.getFirstIDATName());
			 gstbpane.setTitleAt(2, spread.getSecondIDATName());
			 gstbpane.setTitleAt(3, spread.getThirdIDATName());			
		}
		
		GSTabbedPane maingstbdpane = WorkspaceWindow.getInstance().getTabbedPane();
		spread = maingstbdpane.getSpread();
		if (spread != null){
			maingstbdpane.setTitleAt(0, spread.getFirstIDATName());
			maingstbdpane.setTitleAt(1, spread.getSecondIDATName());
			maingstbdpane.setTitleAt(2, spread.getThirdIDATName());	
		}
	}
}
