Search in sources :

Example 1 with TreeContainerInfo

use of alma.acs.gui.loglevel.tree.node.TreeContainerInfo in project ACS by ACS-Community.

the class TreeMouseListener method showLoggingConfigTab.

/**
	 * Show the dialog to read and configure the log level
	 * 
	 * @param path The path of the selected node
	 *
	 */
private void showLoggingConfigTab(TreePath path) {
    if (path == null) {
        throw new IllegalArgumentException("Invalid null path");
    }
    DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) path.getLastPathComponent();
    DefaultMutableTreeNode targetNode = selNode;
    boolean implementsLogging = implementsLoggingConfigurable(selNode);
    if (!implementsLogging) {
        // yatagai: ad hoc implementation
        targetNode = (DefaultMutableTreeNode) selNode.getParent();
        if (targetNode == null || !implementsLoggingConfigurable(targetNode))
            return;
    }
    // Get a reference to the LoggingConfigurable for the 
    // selected item
    LoggingConfigurableOperations logConf = null;
    if (model.isManagerNode(targetNode)) {
        try {
            logConf = getLogConfFromManager();
        } catch (Throwable t) {
            JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    } else if (model.isServiceNode(targetNode)) {
        try {
            logConf = getLogConfFromService(targetNode.getUserObject().toString());
        } catch (Throwable t) {
            JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    } else {
        ContainerInfo cInfo;
        try {
            cInfo = ((TreeContainerInfo) targetNode.getUserObject()).getClientInfo();
        } catch (Throwable t) {
            JOptionPane.showInternalMessageDialog(tree, "Error retrieving ContainerInfo from the node", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        try {
            logConf = getLogConfFromContainer(cInfo);
        } catch (Throwable t) {
            JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    }
    if (logConf == null) {
        JOptionPane.showMessageDialog(tree, "LoggingConfigurable is null", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    try {
        tree.getTabPanel().showTab(targetNode.getUserObject().toString());
    } catch (LogPaneNotFoundException e) {
        // The tab with this name does not exist: create and add a new one
        LogLevelSelectorPanel pnl;
        try {
            pnl = new LogLevelSelectorPanel(logConf, targetNode.getUserObject().toString(), logger);
        //} catch (LogLvlSelNotSupportedException ex) {
        } catch (Exception t) {
            JOptionPane.showMessageDialog(tree, //"<HTML>"+targetNode.getUserObject().toString()+" does not support selection of log levels:<BR>"+ex.getMessage(),
            "<HTML>" + targetNode.getUserObject().toString() + " Error selecting log level panel:<BR>" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        try {
            tree.getTabPanel().addLogSelectorTab(pnl);
        } catch (Throwable t) {
            JOptionPane.showMessageDialog(tree, "<HTML>Error creating the panel for " + targetNode.getUserObject().toString() + ":<BR>" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    }
    // yatagai : Although the mousePressed action for a LoggingConfigurable 
    // folder node, expanding or collapsing, which is set by the JTree UI is not desirable,
    // I could not find a good way to disable it. 
    //
    // Reaching here, a LoggingConfigTab is displayed.
    // If this is a folder node, the following code cancels expanding or collapsing
    // action.
    TreeNode node = (TreeNode) path.getLastPathComponent();
    if (node.isLeaf())
        return;
    else {
        if (tree.isExpanded(path))
            tree.collapsePath(path);
        else
            tree.expandPath(path);
    }
}
Also used : LoggingConfigurableOperations(alma.Logging.LoggingConfigurableOperations) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) LogPaneNotFoundException(alma.acs.gui.loglevel.LogPaneNotFoundException) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeContainerInfo(alma.acs.gui.loglevel.tree.node.TreeContainerInfo) ContainerInfo(si.ijs.maci.ContainerInfo) TreeContainerInfo(alma.acs.gui.loglevel.tree.node.TreeContainerInfo) LogLevelSelectorPanel(alma.acs.gui.loglevel.leveldlg.LogLevelSelectorPanel) LogPaneNotFoundException(alma.acs.gui.loglevel.LogPaneNotFoundException)

Aggregations

LoggingConfigurableOperations (alma.Logging.LoggingConfigurableOperations)1 LogPaneNotFoundException (alma.acs.gui.loglevel.LogPaneNotFoundException)1 LogLevelSelectorPanel (alma.acs.gui.loglevel.leveldlg.LogLevelSelectorPanel)1 TreeContainerInfo (alma.acs.gui.loglevel.tree.node.TreeContainerInfo)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreeNode (javax.swing.tree.TreeNode)1 ContainerInfo (si.ijs.maci.ContainerInfo)1