Search in sources :

Example 1 with JmxInstanceEditor

use of com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor in project cuba by cuba-platform.

the class MbeansDisplayWindow method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    objectNameField.addValueChangeListener(new ObjectNameFieldListener());
    mbeansTable.addAction(new RefreshAction(mbeansTable));
    Action inspectAction = new ItemTrackingAction("inspect").withCaption(getMessage("action.inspect")).withHandler(event -> {
        Set<ManagedBeanInfo> selected = mbeansTable.getSelected();
        if (!selected.isEmpty()) {
            ManagedBeanInfo mbi = selected.iterator().next();
            if (mbi.getObjectName() != null) {
                // otherwise it's a fake root node
                Window editor = openEditor("jmxConsoleInspectMbean", mbi, OpenType.THIS_TAB);
                editor.addCloseListener(actionId -> {
                    mbeansTable.requestFocus();
                });
            } else {
                // expand / collapse fake root node
                UUID itemId = mbi.getId();
                if (mbeansTable.isExpanded(itemId)) {
                    mbeansTable.collapse(itemId);
                } else {
                    mbeansTable.expand(itemId);
                }
            }
        }
    });
    mbeansTable.addAction(inspectAction);
    mbeansTable.setItemClickAction(inspectAction);
    localJmxInstance = jmxControlAPI.getLocalInstance();
    jmxInstancesDs.refresh();
    jmxConnectionField.setValue(localJmxInstance);
    jmxConnectionField.setRequired(true);
    jmxConnectionField.addValueChangeListener(e -> {
        JmxInstance jmxInstance = (JmxInstance) e.getValue();
        try {
            mbeanDs.setJmxInstance(jmxInstance);
            mbeanDs.refresh();
        } catch (JmxControlException ex) {
            showNotification(getMessage("unableToConnectToInterface"), NotificationType.WARNING);
            if (jmxInstance != localJmxInstance) {
                jmxConnectionField.setValue(localJmxInstance);
            }
        }
    });
    jmxConnectionField.removeAllActions();
    jmxConnectionField.addAction(new PickerField.LookupAction(jmxConnectionField) {

        @Override
        public void afterCloseLookup(String actionId) {
            jmxInstancesDs.refresh();
        }
    });
    jmxConnectionField.addAction(new BaseAction("actions.Add").withIcon("icons/plus-btn.png").withHandler(event -> {
        JmxInstanceEditor instanceEditor = (JmxInstanceEditor) openEditor(metadata.create(JmxInstance.class), OpenType.DIALOG);
        instanceEditor.addCloseListener(actionId -> {
            if (COMMIT_ACTION_ID.equals(actionId)) {
                jmxInstancesDs.refresh();
                jmxConnectionField.setValue(instanceEditor.getItem());
            }
        });
    }));
    mbeanDs.setJmxInstance(localJmxInstance);
    mbeanDs.refresh();
    localJmxField.setValue(jmxControlAPI.getLocalNodeName());
    localJmxField.setEditable(false);
    mbeansTable.setStyleProvider((entity, property) -> {
        if (entity != null && entity.getObjectName() == null) {
            return "c-jmx-tree-table-domain";
        }
        return null;
    });
}
Also used : JmxControlException(com.haulmont.cuba.web.jmx.JmxControlException) StringUtils(org.apache.commons.lang.StringUtils) RefreshAction(com.haulmont.cuba.gui.components.actions.RefreshAction) ManagedBeanInfoDatasource(com.haulmont.cuba.web.app.ui.jmxcontrol.ds.ManagedBeanInfoDatasource) Resource(javax.annotation.Resource) ParamsMap(com.haulmont.bali.util.ParamsMap) Set(java.util.Set) UUID(java.util.UUID) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance) Metadata(com.haulmont.cuba.core.global.Metadata) Inject(javax.inject.Inject) JmxControlAPI(com.haulmont.cuba.web.jmx.JmxControlAPI) JmxInstanceEditor(com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor) Map(java.util.Map) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) RefreshAction(com.haulmont.cuba.gui.components.actions.RefreshAction) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) JmxInstanceEditor(com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance) RefreshAction(com.haulmont.cuba.gui.components.actions.RefreshAction) JmxControlException(com.haulmont.cuba.web.jmx.JmxControlException) UUID(java.util.UUID)

Example 2 with JmxInstanceEditor

use of com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor in project cuba by cuba-platform.

the class ServerLogWindow method init.

@Override
public void init(Map<String, Object> params) {
    localJmxField.setValue(jmxControlAPI.getLocalNodeName());
    localJmxField.setEditable(false);
    localJmxInstance = jmxControlAPI.getLocalInstance();
    jmxInstancesDs.refresh();
    jmxConnectionField.setValue(localJmxInstance);
    jmxConnectionField.setRequired(true);
    jmxConnectionField.addValueChangeListener(e -> {
        JmxInstance jmxInstance = (JmxInstance) e.getValue();
        try {
            refreshHostInfo();
        } catch (JmxControlException ex) {
            showNotification(getMessage("exception.unableToConnectToInterface"), NotificationType.WARNING);
            if (jmxInstance != localJmxInstance) {
                jmxConnectionField.setValue(localJmxInstance);
            }
        }
    });
    autoRefreshCheck.addValueChangeListener(e -> {
        if (Boolean.TRUE.equals(e.getValue())) {
            updateLogTailTimer.start();
        } else {
            updateLogTailTimer.stop();
        }
    });
    jmxConnectionField.removeAllActions();
    LookupAction action = LookupAction.create(jmxConnectionField);
    action.setAfterLookupCloseHandler((window, actionId) -> {
        jmxInstancesDs.refresh();
    });
    jmxConnectionField.addAction(action);
    jmxConnectionField.addAction(new BaseAction("actions.Add").withIcon("icons/plus-btn.png").withHandler(event -> {
        JmxInstanceEditor instanceEditor = (JmxInstanceEditor) openEditor(metadata.create(JmxInstance.class), OpenType.DIALOG);
        instanceEditor.addCloseListener(actionId -> {
            if (COMMIT_ACTION_ID.equals(actionId)) {
                jmxInstancesDs.refresh();
                jmxConnectionField.setValue(instanceEditor.getItem());
            }
        });
    }));
    logTailLabel.setSizeAuto();
    logTailLabel.setHtmlEnabled(true);
    logTailLabel.setStyleName("c-log-content");
    loggerLevelField.setOptionsList(LoggingHelper.getLevels());
    appenderLevelField.setOptionsList(LoggingHelper.getLevels());
    refreshHostInfo();
    loggerNameField.addValueChangeListener(e -> {
        List<String> currentLoggers = new ArrayList<>(jmxRemoteLoggingAPI.getLoggerNames(getSelectedConnection()));
        Collections.sort(currentLoggers);
        currentLoggers.add(0, getMessage("logger.new"));
        if (e.getValue() != null && e.getValue().equals(currentLoggers.get(0))) {
            openAddLoggerDialog();
        }
    });
    downloadButton.setEnabled(security.isSpecificPermitted("cuba.gui.administration.downloadlogs"));
    ComboBox comboBox = logFileNameField.unwrap(ComboBox.class);
    comboBox.addShortcutListener(new ShortcutListener("", KeyCode.D, new int[] { ModifierKey.CTRL, ModifierKey.SHIFT }) {

        @Override
        public void handleAction(Object sender, Object target) {
            downloadLog();
        }
    });
    comboBox.addShortcutListener(new ShortcutListener("", KeyCode.S, new int[] { ModifierKey.CTRL, ModifierKey.SHIFT }) {

        @Override
        public void handleAction(Object sender, Object target) {
            showLogTail();
        }
    });
    downloadButton.setDescription("CTRL-SHIFT-D");
    showTailButton.setDescription("CTRL-SHIFT-S");
}
Also used : LookupAction(com.haulmont.cuba.gui.components.PickerField.LookupAction) StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) LookupAction(com.haulmont.cuba.gui.components.PickerField.LookupAction) Security(com.haulmont.cuba.core.global.Security) ComboBox(com.vaadin.ui.ComboBox) LoggerFactory(org.slf4j.LoggerFactory) ParamsMap(com.haulmont.bali.util.ParamsMap) Settings(com.haulmont.cuba.gui.settings.Settings) Timer(com.haulmont.cuba.gui.components.Timer) Metadata(com.haulmont.cuba.core.global.Metadata) Inject(javax.inject.Inject) JmxControlAPI(com.haulmont.cuba.web.jmx.JmxControlAPI) KeyCode(com.vaadin.event.ShortcutAction.KeyCode) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) LogArchiver(com.haulmont.cuba.core.sys.logging.LogArchiver) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) JmxControlException(com.haulmont.cuba.web.jmx.JmxControlException) Logger(org.slf4j.Logger) LoggingHelper(com.haulmont.cuba.core.sys.logging.LoggingHelper) LogDataProvider(com.haulmont.cuba.web.export.LogDataProvider) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) IOException(java.io.IOException) JmxRemoteLoggingAPI(com.haulmont.cuba.web.jmx.JmxRemoteLoggingAPI) CubaScrollBoxLayout(com.haulmont.cuba.web.toolkit.ui.CubaScrollBoxLayout) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance) Level(ch.qos.logback.classic.Level) ModifierKey(com.vaadin.event.ShortcutAction.ModifierKey) StringReader(java.io.StringReader) AppConfig(com.haulmont.cuba.gui.AppConfig) JmxInstanceEditor(com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor) ShortcutListener(com.vaadin.event.ShortcutListener) LogControlException(com.haulmont.cuba.core.sys.logging.LogControlException) BufferedReader(java.io.BufferedReader) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) ComboBox(com.vaadin.ui.ComboBox) JmxInstanceEditor(com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance) ShortcutListener(com.vaadin.event.ShortcutListener) JmxControlException(com.haulmont.cuba.web.jmx.JmxControlException)

Example 3 with JmxInstanceEditor

use of com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor in project cuba by cuba-platform.

the class StatisticsWindow method initJMXTable.

protected void initJMXTable() {
    localJmxInstance = jmxControlAPI.getLocalInstance();
    jmxInstancesDs.refresh();
    jmxConnectionField.setValue(localJmxInstance);
    jmxConnectionField.setRequired(true);
    jmxConnectionField.addValueChangeListener(e -> {
        try {
            setNode(jmxConnectionField.getValue());
        } catch (JmxControlException ex) {
            JmxInstance jmxInstance = jmxConnectionField.getValue();
            showNotification(messages.getMessage("com.haulmont.cuba.web.app.ui.jmxcontrol", "unableToConnectToInterface"), NotificationType.WARNING);
            if (jmxInstance != localJmxInstance) {
                jmxConnectionField.setValue(localJmxInstance);
            }
        }
    });
    jmxConnectionField.removeAllActions();
    jmxConnectionField.addAction(new PickerField.LookupAction(jmxConnectionField) {

        @Override
        public void afterCloseLookup(String actionId) {
            jmxInstancesDs.refresh();
        }
    });
    jmxConnectionField.addAction(new BaseAction("actions.Add").withIcon("icons/plus-btn.png").withHandler(event -> {
        JmxInstanceEditor instanceEditor = (JmxInstanceEditor) openEditor(metadata.create(JmxInstance.class), OpenType.DIALOG);
        instanceEditor.addCloseWithCommitListener(() -> {
            jmxInstancesDs.refresh();
            jmxConnectionField.setValue(instanceEditor.getItem());
        });
    }));
    localNodeLab.setValue(jmxControlAPI.getLocalNodeName());
    localNodeLab.setEditable(false);
}
Also used : JmxControlException(com.haulmont.cuba.web.jmx.JmxControlException) ParamsMap(com.haulmont.bali.util.ParamsMap) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) UUID(java.util.UUID) MetaClass(com.haulmont.chile.core.model.MetaClass) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance) Metadata(com.haulmont.cuba.core.global.Metadata) Inject(javax.inject.Inject) JmxControlAPI(com.haulmont.cuba.web.jmx.JmxControlAPI) GroupDatasource(com.haulmont.cuba.gui.data.GroupDatasource) JmxInstanceEditor(com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor) Map(java.util.Map) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) JmxInstanceEditor(com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) JmxControlException(com.haulmont.cuba.web.jmx.JmxControlException) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance)

Aggregations

ParamsMap (com.haulmont.bali.util.ParamsMap)3 JmxInstance (com.haulmont.cuba.core.entity.JmxInstance)3 Metadata (com.haulmont.cuba.core.global.Metadata)3 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)3 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)3 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)3 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)3 JmxInstanceEditor (com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor)3 JmxControlAPI (com.haulmont.cuba.web.jmx.JmxControlAPI)3 JmxControlException (com.haulmont.cuba.web.jmx.JmxControlException)3 Inject (javax.inject.Inject)3 Map (java.util.Map)2 UUID (java.util.UUID)2 StringUtils (org.apache.commons.lang.StringUtils)2 Level (ch.qos.logback.classic.Level)1 MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 Security (com.haulmont.cuba.core.global.Security)1 LogArchiver (com.haulmont.cuba.core.sys.logging.LogArchiver)1 LogControlException (com.haulmont.cuba.core.sys.logging.LogControlException)1