Search in sources :

Example 1 with Tab

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);
            }
        }
    }
}
Also used : GameModeFacade(pcgen.facade.core.GameModeFacade) DisplayAwareTab(pcgen.gui2.util.DisplayAwareTab) Tab(pcgen.util.enumeration.Tab) Icon(javax.swing.Icon)

Example 2 with Tab

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());
        }
    }
}
Also used : Tab(pcgen.util.enumeration.Tab) LoadContext(pcgen.rules.context.LoadContext) TabInfo(pcgen.cdom.content.TabInfo)

Example 3 with Tab

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);
    }
}
Also used : DisplayAwareTab(pcgen.gui2.util.DisplayAwareTab) Tab(pcgen.util.enumeration.Tab) JTabbedPane(javax.swing.JTabbedPane) Component(java.awt.Component)

Aggregations

Tab (pcgen.util.enumeration.Tab)3 DisplayAwareTab (pcgen.gui2.util.DisplayAwareTab)2 Component (java.awt.Component)1 Icon (javax.swing.Icon)1 JTabbedPane (javax.swing.JTabbedPane)1 TabInfo (pcgen.cdom.content.TabInfo)1 GameModeFacade (pcgen.facade.core.GameModeFacade)1 LoadContext (pcgen.rules.context.LoadContext)1