use of pcgen.util.enumeration.Tab in project pcgen by PCGen.
the class InfoTabbedPane method updateTabsForCharacter.
/**
* Update the displayed tabs to reflect the settings of the game mode of the
* character to which we are switching.
*
* @param character The character being displayed.
*/
private void updateTabsForCharacter(CharacterFacade character) {
GameModeFacade gameMode = character.getDataSet().getGameMode();
int tabIndex = 0;
for (CharacterInfoTab charInfoTab : fullTabList) {
TabTitle tabTitle = charInfoTab.getTabTitle();
Tab tab = tabTitle.getTab();
String newName = gameMode.getTabName(tab);
if (!newName.equals(tabTitle.getValue(TabTitle.TITLE))) {
tabTitle.putValue(TabTitle.TITLE, newName);
}
if (gameMode.getTabShown(tab)) {
if (getComponentAt(tabIndex) != charInfoTab) {
String title = (String) tabTitle.getValue(TabTitle.TITLE);
String tooltip = (String) tabTitle.getValue(TabTitle.TOOLTIP);
Icon icon = (Icon) tabTitle.getValue(TabTitle.ICON);
insertTab(title, icon, (Component) charInfoTab, tooltip, tabIndex);
}
tabIndex++;
} else {
if (getComponentAt(tabIndex) == charInfoTab) {
remove(tabIndex);
}
}
}
}
use of pcgen.util.enumeration.Tab in project pcgen by PCGen.
the class GameModeFileLoader method addDefaultTabInfo.
public static void addDefaultTabInfo(GameMode gameMode) {
LoadContext context = gameMode.getModeContext();
for (final Tab aTab : Tab.values()) {
TabInfo ti = context.getReferenceContext().silentlyGetConstructedCDOMObject(TabInfo.class, aTab.toString());
if (ti == null) {
ti = context.getReferenceContext().constructCDOMObject(TabInfo.class, aTab.toString());
ti.setTabName(aTab.label());
}
}
}
use of pcgen.util.enumeration.Tab in project pcgen by PCGen.
the class InfoTabbedPane method switchTabsAndAdviseTodo.
/**
* Switch the current tab to be the one named, possibly including a sub tab
* and then advise the user of the item to be done. generally the tab will
* handle this but a fallback of a dialog will be used if the tab can't do
* the advising.
*
* @param dest An arry of the tab name, the field name and optionally the
* sub tab name.
*/
private void switchTabsAndAdviseTodo(String[] dest) {
Tab tab = Tab.valueOf(dest[0]);
String tabName = currentCharacter.getDataSet().getGameMode().getTabName(tab);
Component selTab = null;
for (int i = 0; i < getTabCount(); i++) {
if (tabName.equals(getTitleAt(i))) {
setSelectedIndex(i);
selTab = getComponent(i);
break;
}
}
if (selTab == null) {
//$NON-NLS-1$
Logging.errorPrint("Failed to find tab " + tabName);
return;
}
if (selTab instanceof JTabbedPane && dest.length > 2) {
JTabbedPane tabPane = (JTabbedPane) selTab;
for (int i = 0; i < tabPane.getTabCount(); i++) {
if (dest[2].equals(tabPane.getTitleAt(i))) {
tabPane.setSelectedIndex(i);
//selTab = tab.getComponent(i);
break;
}
}
}
if (selTab instanceof TodoHandler) {
((TodoHandler) selTab).adviseTodo(dest[1]);
} else {
//$NON-NLS-1$
String message = LanguageBundle.getFormattedString("in_todoUseField", dest[1]);
JOptionPane.showMessageDialog(selTab, message, //$NON-NLS-1$
LanguageBundle.getString("in_tipsString"), JOptionPane.INFORMATION_MESSAGE);
}
}
Aggregations