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);
}
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");
}
Aggregations