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