use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class CubaPickerField method initLayout.
protected void initLayout() {
container = new CubaCssActionsLayout();
container.setPrimaryStyleName("c-pickerfield-layout");
field.setWidth(100, Unit.PERCENTAGE);
Page current = Page.getCurrent();
if (current != null) {
WebBrowser browser = current.getWebBrowser();
if (browser != null && (browser.isIE() && browser.getBrowserMajorVersion() <= 10 || browser.isSafari())) {
ie9InputWrapper = new CssLayout();
ie9InputWrapper.setWidth(100, Unit.PERCENTAGE);
ie9InputWrapper.setPrimaryStyleName("ie9-input-wrap");
ie9InputWrapper.addComponent(field);
container.addComponent(ie9InputWrapper);
} else {
container.addComponent(field);
}
} else {
container.addComponent(field);
}
if (App.isBound()) {
ThemeConstants theme = App.getInstance().getThemeConstants();
setWidth(theme.get("cuba.web.CubaPickerField.width"));
}
setFocusDelegate(field);
}
use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class Param method createBooleanField.
protected Component createBooleanField(final ValueProperty valueProperty) {
Messages messages = AppBeans.get(Messages.NAME);
ThemeConstants theme = AppBeans.get(ThemeConstantsManager.class).getConstants();
LookupField 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;
}
use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class Param method createEntityLookup.
protected Component createEntityLookup(final ValueProperty valueProperty) {
Metadata metadata = AppBeans.get(Metadata.NAME);
MetaClass metaClass = metadata.getSession().getClassNN(javaClass);
ThemeConstants theme = AppBeans.get(ThemeConstantsManager.class).getConstants();
PersistenceManagerService persistenceManager = AppBeans.get(PersistenceManagerService.NAME);
LookupType type = null;
if (property != null && property.getRange().isClass()) {
type = (LookupType) metadata.getTools().getMetaAnnotationAttributes(property.getAnnotations(), Lookup.class).get("type");
}
boolean useLookupScreen = type != null ? type == LookupType.SCREEN : persistenceManager.useLookupScreen(metaClass.getName());
if (useLookupScreen) {
if (inExpr) {
ListEditor listEditor = componentsFactory.createComponent(ListEditor.class);
listEditor.setItemType(ListEditor.ItemType.ENTITY);
listEditor.setEntityName(metaClass.getName());
initListEditor(listEditor, valueProperty);
return listEditor;
} else {
PickerField picker = componentsFactory.createComponent(PickerField.class);
picker.setMetaClass(metaClass);
picker.setWidth(theme.get("cuba.gui.filter.Param.textComponent.width"));
picker.setFrame(datasource.getDsContext().getFrameContext().getFrame());
picker.addLookupAction();
picker.addClearAction();
picker.addValueChangeListener(e -> _setValue(e.getValue(), valueProperty));
picker.setValue(_getValue(valueProperty));
return picker;
}
} else {
CollectionDatasource<Entity<Object>, Object> optionsDataSource = createOptionsDataSource(metaClass);
if (inExpr) {
ListEditor listEditor = componentsFactory.createComponent(ListEditor.class);
listEditor.setItemType(ListEditor.ItemType.ENTITY);
listEditor.setEntityName(metaClass.getName());
listEditor.setUseLookupField(true);
listEditor.setEntityWhereClause(entityWhere);
initListEditor(listEditor, valueProperty);
return listEditor;
} else {
final LookupPickerField lookup = componentsFactory.createComponent(LookupPickerField.class);
lookup.addClearAction();
lookup.setWidth(theme.get("cuba.gui.filter.Param.textComponent.width"));
lookup.setOptionsDatasource(optionsDataSource);
// noinspection unchecked
optionsDataSource.addCollectionChangeListener(e -> lookup.setValue(null));
lookup.addValueChangeListener(e -> _setValue(e.getValue(), valueProperty));
lookup.setValue(_getValue(valueProperty));
return lookup;
}
}
}
use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class App method initTheme.
protected void initTheme() throws Exception {
DesktopConfig config = configuration.getConfig(DesktopConfig.class);
String themeName = config.getTheme();
DesktopThemeLoader desktopThemeLoader = AppBeans.get(DesktopThemeLoader.NAME);
theme = desktopThemeLoader.loadTheme(themeName);
theme.init();
ThemeConstantsRepository themeRepository = AppBeans.get(ThemeConstantsRepository.NAME);
ThemeConstants uiTheme = themeRepository.getConstants(themeName);
if (uiTheme == null) {
throw new IllegalStateException("Unable to use theme constants '" + themeName + "'");
}
this.themeConstants = uiTheme;
}
use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class PresentationEditor method initLayout.
protected void initLayout() {
ThemeConstants theme = App.getInstance().getThemeConstants();
VerticalLayout root = new VerticalLayout();
root.setWidthUndefined();
root.setSpacing(true);
setContent(root);
messages = AppBeans.get(Messages.class);
nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
nameField.setValue(getPresentationCaption());
root.addComponent(nameField);
autoSaveField = new CheckBox();
autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
root.addComponent(autoSaveField);
defaultField = new CheckBox();
defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
root.addComponent(defaultField);
if (allowGlobalPresentations) {
globalField = new CheckBox();
globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
globalField.setValue(!isNew && presentation.getUser() == null);
root.addComponent(globalField);
}
HorizontalLayout buttons = new HorizontalLayout();
buttons.setSpacing(true);
buttons.setWidthUndefined();
root.addComponent(buttons);
root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);
Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
commitButton.addClickListener(event -> {
if (validate()) {
commit();
close();
}
});
buttons.addComponent(commitButton);
Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
closeButton.addClickListener(event -> {
close();
});
buttons.addComponent(closeButton);
nameField.focus();
}
Aggregations