package org.reldb.relui.tools;

import java.util.HashMap;

import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.reldb.relui.tools.TabPanel;

public class ModeTab extends TabPanel {

	private Control displayed = null;
	private HashMap<String, ModeTabContent> modes = new HashMap<String, ModeTabContent>();
	private static int modeNumber = 0;
	
	public void addMode(Image iconImage, String toolTipText, ModeTabContent content) {
		String modeName = String.valueOf(modeNumber++);
		addMode(iconImage, toolTipText, modeName);
		modes.put(modeName, content);
	}
	
	public int countModes() {
		return modes.size();
	}
	
	public void clearModes() {
		super.clearModes();
		for (ModeTabContent content: modes.values())
			content.dispose();
		modes.clear();
	}
	
	public ModeTab(CTabFolder parent, int style) {
		super(parent, style);
	}
	
	public void buildLocationPanel(TopPanel parent) {}
	
	public String getStatus() {return "";}
	
	@Override
	public void notifyModeChange(String modeName) {
		ToolBar toolBar = getToolBar();
		
		for (ToolItem item: toolBar.getItems())
			item.dispose();

		ModeTabContent content = modes.get(modeName);
		displayed = content.getContent(getContentParent());
		setContent(displayed);

		content.getToolBarItems(toolBar);
		
		toolBar.pack();
	}

}

package org.reldb.relui.tools;

import java.util.HashMap;

import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.reldb.relui.tools.TabPanel;

public class ModeTab extends TabPanel {

	private Control displayed = null;
	private HashMap<String, ModeTabContent> modes = new HashMap<String, ModeTabContent>();
	private static int modeNumber = 0;
	
	public void addMode(Image iconImage, String toolTipText, ModeTabContent content) {
		String modeName = String.valueOf(modeNumber++);
		addMode(iconImage, toolTipText, modeName);
		modes.put(modeName, content);
	}
	
	public int countModes() {
		return modes.size();
	}
	
	public void clearModes() {
		super.clearModes();
		clearToolBar();
		for (ModeTabContent content: modes.values())
			content.dispose();
		modes.clear();
	}
	
	public ModeTab(CTabFolder parent, int style) {
		super(parent, style);
	}

	private ToolBar clearToolBar() {
		ToolBar toolBar = getToolBar();
		for (ToolItem item: toolBar.getItems())
			item.dispose();	
		return toolBar;
	}
	
	public void buildLocationPanel(TopPanel parent) {}
	
	public String getStatus() {return "";}
	
	@Override
	public void notifyModeChange(String modeName) {
		ToolBar toolBar = clearToolBar();

		ModeTabContent content = modes.get(modeName);
		displayed = content.getContent(getContentParent());
		setContent(displayed);

		content.getToolBarItems(toolBar);
		
		toolBar.pack();
	}

}

Fix toolbar visibility when failing to load a database.