Search in sources :

Example 1 with ButtonTabComponent

use of alma.acs.gui.loglevel.leveldlg.ButtonTabComponent in project ACS by ACS-Community.

the class LogLevelPanel method addLogSelectorTab.

/**
	 * Add a new selector tab.
	 * The name of the new tab is set to be the name of the tab
	 * 
	 *@param tab The panel to show in the new tab
	 *@throws InvalidLogPaneException If the name of the panel is empty or null
	 *@throws LogPaneAlreadyExistException If a tab with the given name already exist
	 */
public void addLogSelectorTab(LogLevelSelectorPanel logTab) throws InvalidLogPaneException, LogPaneAlreadyExistException {
    if (logTab == null) {
        throw new IllegalArgumentException("Invalid null component");
    }
    if (logTab.getName() == null || logTab.getName().isEmpty()) {
        throw new InvalidLogPaneException("Trying to add a panel with no name");
    }
    // Check if a tab with this name already exist
    String name = logTab.getName();
    for (int t = 0; t < getTabCount(); t++) {
        if (getComponentAt(t).getName().equals(name)) {
            throw new LogPaneAlreadyExistException("A log with the name " + name + " is already present");
        }
    }
    // Add the tab
    class TabInserter extends Thread {

        LogLevelSelectorPanel tabContent;

        LogLevelPanel thePane;

        public TabInserter(LogLevelSelectorPanel t, LogLevelPanel pane) {
            tabContent = t;
            thePane = pane;
        }

        public void run() {
            add(tabContent, new JLabel(tabContent.getName()));
            setTabComponentAt(indexOfComponent(tabContent), new ButtonTabComponent(thePane, tabContent));
        }
    }
    SwingUtilities.invokeLater(new TabInserter(logTab, this));
}
Also used : ButtonTabComponent(alma.acs.gui.loglevel.leveldlg.ButtonTabComponent) JLabel(javax.swing.JLabel) LogLevelSelectorPanel(alma.acs.gui.loglevel.leveldlg.LogLevelSelectorPanel)

Aggregations

ButtonTabComponent (alma.acs.gui.loglevel.leveldlg.ButtonTabComponent)1 LogLevelSelectorPanel (alma.acs.gui.loglevel.leveldlg.LogLevelSelectorPanel)1 JLabel (javax.swing.JLabel)1