protected void refreshLogFileNames(JmxRemoteLoggingAPI.LoggingHostInfo hostInfo) { // try to keep previously selected file name String selectedFileName = logFileNameField.getValue(); List<String> logFiles = hostInfo.getLogFileNames(); logFileNameField.setValue(null); logFileNameField.setOptionsList(logFiles); autoRefreshCheck.setValue(false); if (selectedFileName != null && logFiles.contains(selectedFileName)) { logFileNameField.setValue(selectedFileName); } logTailLabel.setValue(""); }
private Component createLookupField(List<String> values, String currentValue) { LookupField<String> lookupField = uiComponents.create(LookupField.NAME); lookupField.setOptionsList(values); lookupField.setValue(currentValue); lookupField.addValueChangeListener(e -> { appPropertyDs.getItem().setCurrentValue(e.getValue()); }); return lookupField; }
@Override public Component generateField(Datasource datasource, String propertyId) { formatField = componentsFactory.createComponent(LookupField.class); Map<String, String> options = new HashMap<>(); for (String format : defaultFormats) { options.put(format, format); } formatField.setDatasource(datasource, propertyId); formatField.setOptionsMap(options); formatField.setNewOptionAllowed(true); formatField.setNewOptionHandler(caption -> { addFormatItem(caption); formatField.setValue(caption); }); formatField.setEditable(security.isEntityOpPermitted(ReportValueFormat.class, EntityOp.UPDATE)); return formatField; } });
protected void addFormatItem(String caption) { //noinspection unchecked Map<String, String> optionsMap = new HashMap<>((Map<? extends String, ? extends String>) formatField.getOptionsMap()); optionsMap.put(caption, caption); formatField.setOptionsMap(optionsMap); }
protected void initTemplateFormatLookupField() { wizard.templateFileFormat.setOptionsMap(getAvailableTemplateFormats()); wizard.templateFileFormat.setTextInputAllowed(false); wizard.templateFileFormat.setValue(TemplateFileType.DOCX); }
protected void metaClassValueChanged(MetaClass metaClass) { if (metaClass == null) { entitiesLookup.setValue(null); entitiesLookup.setOptionsList(null); viewLookup.setValue(null); viewLookup.setOptionsList(null); } loadEntities(metaClass); loadViewNames(metaClass); }
protected void initChartPreview() { if (wizard.outputFileFormat.getValue() == ReportOutputType.CHART) { wizard.chartPreviewBox.setVisible(true); wizard.diagramTypeLabel.setVisible(true); wizard.diagramType.setVisible(true); showChart(); wizard.getDialogOptions() .setHeight(wizard.wizardHeight + 400).setHeightUnit(SizeUnit.PIXELS) .center(); wizard.diagramType.setRequired(true); wizard.diagramType.setOptionsList(Arrays.asList(ChartType.values())); wizard.diagramType.setValue(ChartType.SERIAL); wizard.diagramType.addValueChangeListener(e -> { wizard.getItem().setChartType((ChartType) e.getValue()); wizard.chartPreviewBox.removeAll(); showChart(); }); } else { wizard.chartPreviewBox.setVisible(false); wizard.diagramTypeLabel.setVisible(false); wizard.diagramType.setVisible(false); } }
beanNameField.setOptionsList(new ArrayList<>(availableBeans.keySet())); beanNameField.setDatasource(stencilDs, "beanName"); beanNameField.addValueChangeListener(e -> { methodNameField.setValue(null); if (e.getValue() == null) { methodNameField.setOptionsList(Collections.emptyList()); } else { availableMethods = availableBeans.get(e.getValue()); optionsMap.put(availableMethod.getMethodSignature(), availableMethod); methodNameField.setOptionsMap(optionsMap); methodNameField.setRequired(true); methodNameField.setRequiredMessage(getMessage("modelNameRequired")); methodNameField.addValueChangeListener(e -> { if (initialValueSet) return; methodArgsDs.clear();
options.put(datatypeFormatter.formatBoolean(true), true); options.put(datatypeFormatter.formatBoolean(false), false); lookupField.setOptionsMap(options); lookupField.setDatasource(attributeDs, "defaultBoolean"); return lookupField; }); dataTypeField.setWidth(fieldWidth); dataTypeField.setNewOptionAllowed(false); dataTypeField.setRequired(true); dataTypeField.setRequiredMessage(getMessage("dataTypeRequired")); dataTypeField.setOptionsMap(options); dataTypeField.setCaption(getMessage("dataType")); dataTypeField.setFrame(frame); dataTypeField.setDatasource(datasource, propertyId); screenField.setDatasource(datasource, propertyId); screenField.setId("screenField"); screenField.setCaption(getMessage("screen")); screenField.setWidth(fieldWidth); screenField.setRequiredMessage(getMessage("entityScreenRequired")); screenField.setFrame(frame); entityTypeField.setId("entityClass"); entityTypeField.setCaption(getMessage("entityType")); entityTypeField.setRequired(true); entityTypeField.setRequiredMessage(getMessage("entityTypeRequired")); entityTypeField.setWidth(fieldWidth);
field.setCaption(caption); field.setEditable(!readOnly); field.setRequired(required); field.setDatasource(datasource, metaProperty.getName()); field.setOptionsMap(ParamsMap.of( messages.getMainMessage("trueString"), Boolean.TRUE, messages.getMainMessage("falseString"), Boolean.FALSE)); field.setTextInputAllowed(false); field.setValue(value);
entity -> { LookupField<String> lookupField = uiComponents.create(LookupField.NAME); lookupField.setDatasource(targetScreensTable.getItemDatasource(entity), "screen"); lookupField.setOptionsMap(optionsMap); lookupField.setNewOptionAllowed(true); lookupField.setNewOptionHandler((Consumer<String>) caption -> { if (caption != null && !optionsMap.containsKey(caption)) { optionsMap.put(caption, caption); lookupField.setValue(caption); lookupField.setRequired(true); lookupField.setWidth("100%"); return lookupField;
protected void initLocales() { localesSelect.setOptionsMap(globalConfig.getAvailableLocales()); localesSelect.setValue(app.getLocale()); boolean localeSelectVisible = globalConfig.getLocaleSelectVisible(); localesSelect.setVisible(localeSelectVisible); // if old layout is used Component localesSelectLabel = getComponent("localesSelectLabel"); if (localesSelectLabel != null) { localesSelectLabel.setVisible(localeSelectVisible); } localesSelect.addValueChangeListener(e -> { Locale selectedLocale = (Locale) e.getValue(); app.setLocale(selectedLocale); authInfoThreadLocal.set(new AuthInfo(loginField.getValue(), passwordField.getValue(), rememberMeCheckBox.getValue())); try { app.createTopLevelWindow(); } finally { authInfoThreadLocal.set(null); } }); }
protected Component createBooleanField(ValueProperty valueProperty) { Messages messages = AppBeans.get(Messages.NAME); ThemeConstants theme = AppBeans.get(ThemeConstantsManager.class).getConstants(); LookupField<Object> field = componentsFactory.createComponent(LookupField.class); field.setWidth(theme.get("cuba.gui.filter.Param.booleanLookup.width")); Map<String, Object> values = new HashMap<>(); values.put(messages.getMainMessage("filter.param.boolean.true"), Boolean.TRUE); values.put(messages.getMainMessage("filter.param.boolean.false"), Boolean.FALSE); field.setOptionsMap(values); field.addValueChangeListener(e -> _setValue(e.getValue(), valueProperty)); field.setValue(_getValue(valueProperty)); return field; }
appThemeField.setOptionsList(new ArrayList<>(supportedThemes)); appThemeField.setValue(userAppTheme); appThemeField.setEditable(changeThemeEnabled); options.put(entry.getKey(), messages.getTools().localeToString(entry.getValue())); appLangField.setOptionsMap(options); appLangField.setValue(userManagementService.loadOwnLocale());
protected void initLocalesField() { Map<String, Locale> locales = globalConfig.getAvailableLocales(); localesSelect.setOptionsMap(locales); localesSelect.addValueChangeListener(createLocaleSelectValueChangeListener()); localesSelect.setValue(userSessionSource.getLocale()); }
protected void initProcActorsTable() { procActorsTable.addGeneratedColumn("user", entity -> { LookupField<User> lookupField = uiComponents.create(LookupField.NAME); lookupField.setWidth("100%"); lookupField.setOptionsDatasource(usersDs); lookupField.setValue(entity.getUser()); lookupField.addValueChangeListener(e -> { entity.setUser(e.getValue()); }); return lookupField; }); }
protected void initEntityTypeField() { Map<String, MetaClass> metaClasses = new LinkedHashMap<>(); for (MetaClass metaClass : metadata.getTools().getAllPersistentMetaClasses()) { metaClasses.put(metaClass.getName(), metaClass); } entitiesMetaClasses.setOptionsMap(metaClasses); entitiesMetaClasses.addValueChangeListener(e -> { setEntityViewsLookup(); String entitiesMetaClass = ((MetaClass) entitiesMetaClasses.getValue()).getName(); if (entitiesMetaClass != null) { setSimpleQuery(entitiesMetaClass); } }); }
@Override public Component generateField(Datasource datasource, String propertyId) { LookupField lookup = AppConfig.getFactory().createComponent(LookupField.class); lookup.setDatasource(datasource, propertyId); lookup.setRequiredMessage(getMessage("datatypeMsg")); lookup.setRequired(true); lookup.setPageLength(15); Map<String, Object> options = new TreeMap<>(); String mainMessagePack = AppConfig.getMessagesPack(); for (String datatypeId : Datatypes.getIds()) { options.put(messages.getMessage(mainMessagePack, "Datatype." + datatypeId), datatypeId); } lookup.setOptionsMap(options); return lookup; } }
super.initComponents(); typeSelect.addValueChangeListener(e -> { boolean disableTypeCheckBox = ParamType.UNARY.equals(typeSelect.getValue()) || ParamType.BOOLEAN.equals(typeSelect.getValue()); inExprCb.setEnabled(!disableTypeCheckBox); if (disableTypeCheckBox) inExprCb.setValue(false); boolean isEntity = ParamType.ENTITY.equals(typeSelect.getValue()); boolean isEnum = ParamType.ENUM.equals(typeSelect.getValue()); boolean isDate = ParamType.DATE.equals(typeSelect.getValue()); entitySelect.setEnabled(isEntity || isEnum); entitySelect.setRequired(entitySelect.isEnabled()); paramWhereLab.setEnabled(isEntity); entityParamWhereField.setEnabled(isEntity); if ((isEntity || isEnum) && (entitySelect.getValue() == null)) { defaultValueLayout.remove(defaultValueComponent); param.setJavaClass(null); entitySelect.addValueChangeListener(e -> { if (initializing || !defaultValueLayout.isVisibleRecursive()) { return;
@Override public void init(Map<String, Object> params) { entities.addValueChangeListener(e -> buildLayout()); entities.setOptionsMap(getEntitiesLookupFieldOptions()); }