mirror of
https://gitee.com/jmix/cuba.git
synced 2024-11-30 02:07:41 +08:00
Application property’s edit dialog has incorrect size #1262
This commit is contained in:
parent
c6e55e47f5
commit
cdbfa91dcc
@ -27,10 +27,10 @@ import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Configuration;
|
||||
import com.haulmont.cuba.core.global.Metadata;
|
||||
import com.haulmont.cuba.core.global.UserSessionSource;
|
||||
import com.haulmont.cuba.gui.UiComponents;
|
||||
import com.haulmont.cuba.gui.WindowParam;
|
||||
import com.haulmont.cuba.gui.components.*;
|
||||
import com.haulmont.cuba.gui.data.Datasource;
|
||||
import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -65,7 +65,7 @@ public class AppPropertiesEdit extends AbstractWindow {
|
||||
private FieldGroup fieldGroup;
|
||||
|
||||
@Inject
|
||||
private ComponentsFactory componentsFactory;
|
||||
private UiComponents uiComponents;
|
||||
|
||||
@Inject
|
||||
private UserSessionSource userSessionSource;
|
||||
@ -85,7 +85,7 @@ public class AppPropertiesEdit extends AbstractWindow {
|
||||
|
||||
fieldGroup.addCustomField("currentValue", (datasource, propertyId) -> {
|
||||
if (item.getOverridden()) {
|
||||
TextField textField = componentsFactory.createComponent(TextField.class);
|
||||
TextField<String> textField = uiComponents.create(TextField.NAME);
|
||||
textField.setValue(item.getDisplayedCurrentValue());
|
||||
textField.setEditable(false);
|
||||
return textField;
|
||||
@ -97,14 +97,14 @@ public class AppPropertiesEdit extends AbstractWindow {
|
||||
return createLookupField(Arrays.asList(Boolean.TRUE.toString(), Boolean.FALSE.toString()), item.getCurrentValue());
|
||||
} else {
|
||||
if (Boolean.TRUE.equals(item.getSecret())) {
|
||||
PasswordField passwordField = componentsFactory.createComponent(PasswordField.class);
|
||||
PasswordField passwordField = uiComponents.create(PasswordField.class);
|
||||
passwordField.setValue(item.getCurrentValue());
|
||||
passwordField.addValueChangeListener(e -> {
|
||||
appPropertyDs.getItem().setCurrentValue(e.getValue() == null ? null : e.getValue().toString());
|
||||
appPropertyDs.getItem().setCurrentValue(e.getValue());
|
||||
});
|
||||
return passwordField;
|
||||
} else {
|
||||
TextField<String> textField = componentsFactory.createComponent(TextField.class);
|
||||
TextField<Object> textField = uiComponents.create(TextField.NAME);
|
||||
textField.setValue(item.getCurrentValue());
|
||||
|
||||
try {
|
||||
@ -124,7 +124,7 @@ public class AppPropertiesEdit extends AbstractWindow {
|
||||
}
|
||||
});
|
||||
|
||||
final Function<String, String> defaultValueFormatter = (value) -> {
|
||||
Function<String, String> defaultValueFormatter = (value) -> {
|
||||
if (datatype instanceof BooleanDatatype) {
|
||||
return value;
|
||||
}
|
||||
@ -143,11 +143,11 @@ public class AppPropertiesEdit extends AbstractWindow {
|
||||
}
|
||||
|
||||
private Component createLookupField(List<String> values, String currentValue) {
|
||||
LookupField<String> lookupField = componentsFactory.createComponent(LookupField.class);
|
||||
LookupField<String> lookupField = uiComponents.create(LookupField.NAME);
|
||||
lookupField.setOptionsList(values);
|
||||
lookupField.setValue(currentValue);
|
||||
lookupField.addValueChangeListener(e -> {
|
||||
appPropertyDs.getItem().setCurrentValue((String) e.getValue());
|
||||
appPropertyDs.getItem().setCurrentValue(e.getValue());
|
||||
});
|
||||
return lookupField;
|
||||
}
|
||||
@ -166,4 +166,4 @@ public class AppPropertiesEdit extends AbstractWindow {
|
||||
public void cancel() {
|
||||
close(CLOSE_ACTION_ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,11 +21,14 @@ package com.haulmont.cuba.gui.components;
|
||||
*/
|
||||
public interface DialogWindow extends Window {
|
||||
/**
|
||||
* Name that is used to register a client type specific screen implementation in
|
||||
* {@link com.haulmont.cuba.gui.xml.layout.ComponentsFactory}
|
||||
* Name that is used to register a client type specific screen implementation in {@link com.haulmont.cuba.gui.UiComponents}
|
||||
*/
|
||||
String NAME = "dialogWindow";
|
||||
|
||||
// todo new feature
|
||||
// void setScrollable(boolean scrollable);
|
||||
// boolean isScrollable();
|
||||
|
||||
void setDialogWidth(String dialogWidth);
|
||||
float getDialogWidth();
|
||||
SizeUnit getDialogWidthUnit();
|
||||
|
@ -40,6 +40,7 @@ import com.haulmont.cuba.web.widgets.CubaUI;
|
||||
import com.haulmont.cuba.web.widgets.CubaWindow;
|
||||
import com.vaadin.event.Action;
|
||||
import com.vaadin.event.ShortcutAction;
|
||||
import com.vaadin.server.Sizeable;
|
||||
import com.vaadin.ui.Component;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@ -63,6 +64,7 @@ public class WebDialogWindow extends WebWindow implements DialogWindow, Initiali
|
||||
|
||||
this.dialogWindow.center();
|
||||
this.dialogWindow.setModal(true);
|
||||
dialogWindow.setResizable(false);
|
||||
|
||||
this.dialogWindow.addPreCloseListener(this::onCloseButtonClick);
|
||||
}
|
||||
@ -78,7 +80,11 @@ public class WebDialogWindow extends WebWindow implements DialogWindow, Initiali
|
||||
ThemeConstantsManager themeConstantsManager = beanLocator.get(ThemeConstantsManager.NAME);
|
||||
ThemeConstants theme = themeConstantsManager.getConstants();
|
||||
|
||||
setWidth(theme.get("cuba.web.WebWindowManager.dialog.width"));
|
||||
dialogWindow.setWidth(theme.get("cuba.web.WebWindowManager.dialog.width"));
|
||||
dialogWindow.setHeightUndefined();
|
||||
|
||||
component.setWidth(100, Sizeable.Unit.PERCENTAGE);
|
||||
component.setHeightUndefined();
|
||||
}
|
||||
|
||||
protected void setupContextMenu() {
|
||||
@ -205,6 +211,12 @@ public class WebDialogWindow extends WebWindow implements DialogWindow, Initiali
|
||||
@Override
|
||||
public void setDialogWidth(String dialogWidth) {
|
||||
dialogWindow.setWidth(dialogWidth);
|
||||
|
||||
if (dialogWindow.getWidth() < 0) {
|
||||
component.setWidthUndefined();
|
||||
} else {
|
||||
component.setWidth(100, Sizeable.Unit.PERCENTAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -220,6 +232,12 @@ public class WebDialogWindow extends WebWindow implements DialogWindow, Initiali
|
||||
@Override
|
||||
public void setDialogHeight(String dialogHeight) {
|
||||
dialogWindow.setHeight(dialogHeight);
|
||||
|
||||
if (dialogWindow.getHeight() < 0) {
|
||||
component.setHeightUndefined();
|
||||
} else {
|
||||
component.setHeight(100, Sizeable.Unit.PERCENTAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -324,6 +342,10 @@ public class WebDialogWindow extends WebWindow implements DialogWindow, Initiali
|
||||
return dialogWindow.getPositionY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility layer class.
|
||||
*/
|
||||
@Deprecated
|
||||
protected class WebDialogOptions extends DialogOptions {
|
||||
@Override
|
||||
public Float getWidth() {
|
||||
|
Loading…
Reference in New Issue
Block a user