use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class RelatedEntitiesImpl method addNavigationAction.
protected void addNavigationAction(MetaProperty metaProperty) {
// check if browse screen available
PropertyOption propertyOption = propertyOptions.get(metaProperty.getName());
WindowInfo defaultScreen = screensHelper.getDefaultBrowseScreen(metaProperty.getRange().asClass());
if (defaultScreen != null || (propertyOption != null && StringUtils.isNotEmpty(propertyOption.getScreenId()))) {
Action relatedAction = createRelatedAction(metaProperty, defaultScreen, propertyOption);
addAction(relatedAction);
}
}
use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class AbstractWindow method getScreenHashCode.
protected int getScreenHashCode(Screen screen) {
ScreenContext screenContext = UiControllerUtils.getScreenContext(screen);
WindowInfo windowInfo = screenContext.getWindowInfo();
Map<String, Object> params = getFrame().getContext().getParams();
return windowInfo.hashCode() + (params != null ? params.hashCode() : 0);
}
use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class AddAction method actionPerform.
/**
* This method is invoked by action owner component. Don't override it, there are special methods to
* customize behaviour below.
*
* @param component component invoking action
*/
@Override
public void actionPerform(Component component) {
if (beforeActionPerformedHandler != null) {
if (!beforeActionPerformedHandler.beforeActionPerformed()) {
return;
}
}
Map<String, Object> params = prepareWindowParams();
Window.Lookup.Handler handler = getHandler();
Window.Lookup.Handler itemsHandler = handler != null ? handler : new DefaultHandler();
WindowManager wm = (WindowManager) ComponentsHelper.getScreenContext(target.getFrame()).getScreens();
WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo(getWindowId());
Window.Lookup lookupWindow = wm.openLookup(windowInfo, itemsHandler, getOpenType(), params);
if (target instanceof Component.Focusable) {
lookupWindow.addCloseListener(actionId -> {
// move focus to owner
((Component.Focusable) target).focus();
});
}
}
use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class DateInIntervalComponent method createComponent.
public Component createComponent(String dateIntervalDescription) {
HBoxLayout layout = componentsFactory.createComponent(HBoxLayout.class);
layout.setStyleName("jmix-dateintervaleditor");
TextField textField = componentsFactory.createComponent(TextField.class);
value = AppBeans.getPrototype(DateIntervalValue.NAME, dateIntervalDescription);
textField.setValue(value.getLocalizedValue());
textField.setStyleName("jmix-dateintervaleditor-text");
textField.setEditable(false);
layout.add(textField);
Button openEditorBtn = componentsFactory.createComponent(Button.class);
openEditorBtn.setIconFromSet(JmixIcon.ENTITYPICKER_LOOKUP);
openEditorBtn.setStyleName("jmix-dateintervaleditor-button");
openEditorBtn.setCaption("");
openEditorBtn.setAction(new AbstractAction("openEditor") {
@Override
public void actionPerform(Component component) {
WindowManager windowManager = windowManagerProvider.get();
WindowInfo windowInfo = windowConfig.getWindowInfo("date-interval-editor");
DateIntervalEditor editor = (DateIntervalEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, Collections.singletonMap("dateIntervalDescription", value.getDescription()));
editor.addListener(actionId -> {
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
value = editor.getDateIntervalValue();
textField.setValue(value.getLocalizedValue());
fireValueChangeListeners(value);
}
});
}
@Override
public String getCaption() {
return "";
}
});
layout.add(openEditorBtn);
Button clearBtn = componentsFactory.createComponent(Button.class);
clearBtn.setIconFromSet(JmixIcon.VALUEPICKER_CLEAR);
clearBtn.setStyleName("jmix-dateintervaleditor-button");
clearBtn.setCaption("");
clearBtn.setAction(new AbstractAction("clear") {
@Override
public void actionPerform(Component component) {
textField.setValue(null);
fireValueChangeListeners(null);
}
});
layout.add(clearBtn);
layout.expand(textField);
return layout;
}
use of io.jmix.ui.WindowInfo in project jmix by jmix-framework.
the class FrameHelper method createFakeWindowInfo.
@SuppressWarnings("unchecked")
public WindowInfo createFakeWindowInfo(String src, String fragmentId) {
Element screenElement = DocumentHelper.createElement("screen");
screenElement.addAttribute("template", src);
screenElement.addAttribute("id", fragmentId);
Element windowElement = screenXmlLoader.load(src, fragmentId, Collections.emptyMap());
Class<? extends ScreenFragment> fragmentClass;
String className = windowElement.attributeValue("class");
if (StringUtils.isNotEmpty(className)) {
fragmentClass = (Class<? extends ScreenFragment>) classManager.loadClass(className);
} else {
fragmentClass = AbstractFrame.class;
}
return new WindowInfo(fragmentId, new WindowAttributesProvider() {
@Override
public WindowInfo.Type getType(WindowInfo wi) {
return WindowInfo.Type.FRAGMENT;
}
@Override
public String getTemplate(WindowInfo wi) {
return src;
}
@Override
public Class<? extends FrameOwner> getControllerClass(WindowInfo wi) {
return fragmentClass;
}
@Override
public WindowInfo resolve(WindowInfo windowInfo) {
return windowInfo;
}
}, screenElement);
}
Aggregations