use of com.haulmont.cuba.gui.WindowManager in project cuba by cuba-platform.
the class Param method createNumberField.
protected Component createNumberField(final Datatype datatype, final ValueProperty valueProperty) {
if (inExpr) {
ListEditor listEditor = componentsFactory.createComponent(ListEditor.class);
listEditor.setItemType(ListEditorHelper.itemTypeFromDatatype(datatype));
initListEditor(listEditor, valueProperty);
return listEditor;
}
TextField field = componentsFactory.createComponent(TextField.class);
field.addValueChangeListener(e -> {
if (e.getValue() == null || e.getValue() instanceof Number) {
_setValue(e.getValue(), valueProperty);
} else if (e.getValue() instanceof String && !StringUtils.isBlank((String) e.getValue())) {
UserSessionSource userSessionSource1 = AppBeans.get(UserSessionSource.NAME);
Object v;
try {
v = datatype.parse((String) e.getValue(), userSessionSource1.getLocale());
} catch (ParseException ex) {
WindowManager wm = AppBeans.get(WindowManagerProvider.class).get();
wm.showNotification(messages.getMainMessage("filter.param.numberInvalid"), Frame.NotificationType.TRAY);
return;
}
_setValue(v, valueProperty);
} else if (e.getValue() instanceof String && StringUtils.isBlank((String) e.getValue())) {
_setValue(null, valueProperty);
} else {
throw new IllegalStateException("Invalid value: " + e.getValue());
}
});
UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
// noinspection unchecked
field.setValue(datatype.format(_getValue(valueProperty), sessionSource.getLocale()));
return field;
}
use of com.haulmont.cuba.gui.WindowManager in project cuba by cuba-platform.
the class ChangePasswordLauncher method run.
@Override
public void run() {
WindowManager wm = App.getInstance().getMainFrame().getWindowManager();
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo windowInfo = windowConfig.getWindowInfo("sec$User.changePassword");
wm.openWindow(windowInfo, OpenType.DIALOG, ParamsMap.of("currentPasswordRequired", true));
}
use of com.haulmont.cuba.gui.WindowManager in project cuba by cuba-platform.
the class ListEditorDelegateImpl method init.
@PostConstruct
public void init() {
WindowManager windowManager = windowManagerProvider.get();
layout = componentsFactory.createComponent(HBoxLayout.class);
layout.setStyleName("c-listeditor-layout");
layout.setWidth("100%");
displayValuesField = componentsFactory.createComponent(TextField.class);
displayValuesField.setStyleName("c-listeditor-text");
displayValuesField.setEditable(false);
Button openEditorBtn = componentsFactory.createComponent(Button.class);
openEditorBtn.setIconFromSet(CubaIcon.PICKERFIELD_LOOKUP);
openEditorBtn.setStyleName("c-listeditor-button");
openEditorBtn.setCaption("");
openEditorBtn.setAction(new AbstractAction("openEditor") {
@Override
public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
Map<String, Object> params = new HashMap<>();
params.put("itemType", itemType);
params.put("entityName", entityName);
params.put("useLookupField", useLookupField);
params.put("optionsList", optionsList);
params.put("optionsMap", optionsMap);
params.put("enumClass", enumClass);
params.put("lookupScreen", lookupScreen);
params.put("entityJoinClause", entityJoinClause);
params.put("entityWhereClause", entityWhereClause);
params.put("values", getValue());
params.put("editable", editable);
params.put("timeZone", timeZone);
if (editorParamsSupplier != null) {
Map<String, Object> additionalParams = getEditorParamsSupplier().get();
if (additionalParams != null) {
params.putAll(additionalParams);
}
}
ListEditorWindowController listEditorPopup = (ListEditorWindowController) windowManager.openWindow(windowConfig.getWindowInfo(editorWindowId), WindowManager.OpenType.DIALOG, params);
listEditorPopup.addCloseListener(actionId -> {
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
actualField.setValue(listEditorPopup.getValue());
}
ListEditor.EditorCloseEvent editorCloseEvent = new ListEditor.EditorCloseEvent(actionId, listEditorPopup);
getEventRouter().fireEvent(ListEditor.EditorCloseListener.class, ListEditor.EditorCloseListener::editorClosed, editorCloseEvent);
});
}
});
layout.add(displayValuesField);
layout.add(openEditorBtn);
layout.expand(displayValuesField);
}
use of com.haulmont.cuba.gui.WindowManager in project cuba by cuba-platform.
the class WebEntityLinkField method openEntityEditor.
protected void openEntityEditor() {
Object value = getValue();
Entity entity;
if (value instanceof Entity) {
entity = (Entity) value;
} else {
entity = datasource.getItem();
}
if (entity == null) {
return;
}
WindowManager wm;
Window window = ComponentsHelper.getWindow(this);
if (window == null) {
throw new IllegalStateException("Please specify Frame for EntityLinkField");
} else {
wm = window.getWindowManager();
}
if (screenOpenType.getOpenMode() == OpenMode.DIALOG && screenDialogParams != null) {
wm.getDialogParams().copyFrom(screenDialogParams);
}
if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) {
Messages messages = AppBeans.get(Messages.NAME);
wm.showNotification(messages.getMainMessage("OpenAction.objectIsDeleted"), Frame.NotificationType.HUMANIZED);
return;
}
DataSupplier dataSupplier = window.getDsContext().getDataSupplier();
entity = dataSupplier.reload(entity, View.MINIMAL);
String windowAlias = screen;
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
if (windowAlias == null) {
windowAlias = windowConfig.getEditorScreenId(entity.getMetaClass());
}
final Window.Editor editor = wm.openEditor(windowConfig.getWindowInfo(windowAlias), entity, screenOpenType, screenParams != null ? screenParams : Collections.<String, Object>emptyMap());
editor.addCloseListener(actionId -> {
// move focus to component
component.focus();
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
Entity item = editor.getItem();
afterCommitOpenedEntity(item);
}
if (screenCloseListener != null) {
screenCloseListener.windowClosed(editor, actionId);
}
});
}
Aggregations