Search in sources :

Example 1 with LookupAction

use of com.haulmont.cuba.gui.components.PickerField.LookupAction in project cuba by cuba-platform.

the class UserEditor method createGroupField.

protected void createGroupField() {
    FieldGroup.FieldConfig groupFc = fieldGroupRight.getFieldNN("group");
    PickerField pickerField = factory.createComponent(PickerField.class);
    pickerField.setDatasource(groupFc.getTargetDatasource(), groupFc.getProperty());
    pickerField.setRequired(true);
    pickerField.setRequiredMessage(getMessage("groupMsg"));
    LookupAction action = LookupAction.create(pickerField);
    action.setLookupScreenOpenType(OpenType.DIALOG);
    action.setLookupScreenParamsSupplier(() -> {
        if (getItem().getGroup() != null) {
            return ParamsMap.of("selectedGroup", getItem().getGroup());
        }
        return Collections.emptyMap();
    });
    pickerField.addAction(action);
    groupFc.setComponent(pickerField);
}
Also used : LookupAction(com.haulmont.cuba.gui.components.PickerField.LookupAction)

Example 2 with LookupAction

use of com.haulmont.cuba.gui.components.PickerField.LookupAction 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)

Aggregations

LookupAction (com.haulmont.cuba.gui.components.PickerField.LookupAction)2 Level (ch.qos.logback.classic.Level)1 ParamsMap (com.haulmont.bali.util.ParamsMap)1 JmxInstance (com.haulmont.cuba.core.entity.JmxInstance)1 Metadata (com.haulmont.cuba.core.global.Metadata)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 LoggingHelper (com.haulmont.cuba.core.sys.logging.LoggingHelper)1 AppConfig (com.haulmont.cuba.gui.AppConfig)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)1 Timer (com.haulmont.cuba.gui.components.Timer)1 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)1 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)1 ExportDisplay (com.haulmont.cuba.gui.export.ExportDisplay)1 Settings (com.haulmont.cuba.gui.settings.Settings)1 JmxInstanceEditor (com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor)1 LogDataProvider (com.haulmont.cuba.web.export.LogDataProvider)1 JmxControlAPI (com.haulmont.cuba.web.jmx.JmxControlAPI)1