Search in sources :

Example 1 with LoggingConfigurableOperations

use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.

the class TreeMouseListener method getLogConfFromService.

private LoggingConfigurableOperations getLogConfFromService(final String serviceName) throws Exception {
    System.out.println("Getting LoggingConfigurable out of Manager for service " + serviceName);
    // Manager
    final Manager mgr = model.getManagerRef();
    if (mgr == null) {
        throw new Exception("Invalid manager reference");
    }
    SwingWorker<LoggingConfigurableOperations, Void> worker = new SwingWorker<LoggingConfigurableOperations, Void>() {

        protected LoggingConfigurableOperations doInBackground() throws Exception {
            LoggingConfigurableOperations logConf;
            try {
                logConf = LoggingConfigurableHelper.narrow(mgr.get_service(model.getAdminClient().getHandle(), serviceName, false));
            } catch (Throwable t) {
                throw new Exception("Error getting the LoggingConfigurable out of Manager for service " + serviceName + " :\n" + t.getMessage(), t);
            }
            return logConf;
        }
    };
    worker.execute();
    return worker.get();
}
Also used : LoggingConfigurableOperations(alma.Logging.LoggingConfigurableOperations) SwingWorker(javax.swing.SwingWorker) Manager(si.ijs.maci.Manager) LogPaneNotFoundException(alma.acs.gui.loglevel.LogPaneNotFoundException)

Example 2 with LoggingConfigurableOperations

use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.

the class TreeMouseListener method getLogConfFromContainer.

/**
	 * Get the LoggingConfigurable out of the container
	 * 
	 * @return The LoggingConfigurable for the container
	 */
private LoggingConfigurableOperations getLogConfFromContainer(ContainerInfo info) throws Exception {
    if (info == null) {
        throw new IllegalArgumentException("Invalid null ContainerInfo");
    }
    final Container cnt = info.reference;
    if (cnt == null) {
        throw new Exception("The reference to the container is null in ContainerInfo");
    }
    SwingWorker<LoggingConfigurableOperations, Void> worker = new SwingWorker<LoggingConfigurableOperations, Void>() {

        protected LoggingConfigurableOperations doInBackground() throws Exception {
            LoggingConfigurableOperations logConf;
            try {
                logConf = LoggingConfigurableHelper.narrow(cnt);
            } catch (Throwable t) {
                throw new Exception("Error getting the LoggingConfigurable out of Manager:\n" + t.getMessage(), t);
            }
            return logConf;
        }
    };
    worker.execute();
    return worker.get();
}
Also used : LoggingConfigurableOperations(alma.Logging.LoggingConfigurableOperations) Container(si.ijs.maci.Container) SwingWorker(javax.swing.SwingWorker) LogPaneNotFoundException(alma.acs.gui.loglevel.LogPaneNotFoundException)

Example 3 with LoggingConfigurableOperations

use of alma.Logging.LoggingConfigurableOperations 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)

Example 4 with LoggingConfigurableOperations

use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.

the class TreeMouseListener method getLogConfFromManager.

/**
	 * Get the LoggingConfigurable out of the manager
	 * 
	 * @return The LoggingConfigurable for the manager
	 */
private LoggingConfigurableOperations getLogConfFromManager() throws Exception {
    System.out.println("Getting LoggingConfigurable out of Manager");
    // Manager
    Manager mgr = model.getManagerRef();
    if (mgr == null) {
        throw new Exception("Invalid manager reference");
    }
    SwingWorker<LoggingConfigurableOperations, Void> worker = new SwingWorker<LoggingConfigurableOperations, Void>() {

        protected LoggingConfigurableOperations doInBackground() throws Exception {
            LoggingConfigurableOperations logConf;
            try {
                logConf = LoggingConfigurableHelper.narrow(model.getManagerRef());
            } catch (Throwable t) {
                throw new Exception("Error getting the LoggingConfigurable out of Manager:\n" + t.getMessage(), t);
            }
            return logConf;
        }
    };
    worker.execute();
    return worker.get();
}
Also used : LoggingConfigurableOperations(alma.Logging.LoggingConfigurableOperations) SwingWorker(javax.swing.SwingWorker) Manager(si.ijs.maci.Manager) LogPaneNotFoundException(alma.acs.gui.loglevel.LogPaneNotFoundException)

Example 5 with LoggingConfigurableOperations

use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.

the class ContainerUtil method setContainerLogLevels.

/**
	 * Dynamically configures container log levels, using {@link #getContainerLoggingIF(String)}.
	 * @param containerName
	 * @param defaultConfig
	 * @param namedLoggerConfigs
	 */
public void setContainerLogLevels(String containerName, ContainerLogLevelSpec spec) throws AcsJContainerEx, NoPermissionEx {
    LoggingConfigurableOperations loggingConfigurable = getContainerLoggingIF(containerName);
    spec.configure(loggingConfigurable);
}
Also used : LoggingConfigurableOperations(alma.Logging.LoggingConfigurableOperations)

Aggregations

LoggingConfigurableOperations (alma.Logging.LoggingConfigurableOperations)5 LogPaneNotFoundException (alma.acs.gui.loglevel.LogPaneNotFoundException)4 SwingWorker (javax.swing.SwingWorker)3 Manager (si.ijs.maci.Manager)2 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 Container (si.ijs.maci.Container)1 ContainerInfo (si.ijs.maci.ContainerInfo)1