Search in sources :

Example 16 with WindowInfo

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);
    }
}
Also used : Action(io.jmix.ui.action.Action) RelatedAction(io.jmix.ui.action.list.RelatedAction) PropertyOption(io.jmix.ui.sys.PropertyOption) WindowInfo(io.jmix.ui.WindowInfo)

Example 17 with WindowInfo

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);
}
Also used : WindowInfo(io.jmix.ui.WindowInfo)

Example 18 with WindowInfo

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();
        });
    }
}
Also used : WindowConfig(io.jmix.ui.WindowConfig) Window(com.haulmont.cuba.gui.components.Window) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(io.jmix.ui.WindowInfo)

Example 19 with WindowInfo

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;
}
Also used : WindowManager(com.haulmont.cuba.gui.WindowManager) Autowired(org.springframework.beans.factory.annotation.Autowired) AppBeans(com.haulmont.cuba.core.global.AppBeans) Scope(org.springframework.context.annotation.Scope) WindowConfig(io.jmix.ui.WindowConfig) JmixIcon(io.jmix.ui.icon.JmixIcon) ArrayList(java.util.ArrayList) List(java.util.List) ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) WindowInfo(io.jmix.ui.WindowInfo) AbstractAction(io.jmix.ui.action.AbstractAction) WindowManagerProvider(com.haulmont.cuba.gui.WindowManagerProvider) Collections(java.util.Collections) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) io.jmix.ui.component(io.jmix.ui.component) AbstractAction(io.jmix.ui.action.AbstractAction) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(io.jmix.ui.WindowInfo)

Example 20 with WindowInfo

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);
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) WindowAttributesProvider(io.jmix.ui.sys.WindowAttributesProvider) Element(org.dom4j.Element) WindowInfo(io.jmix.ui.WindowInfo)

Aggregations

WindowInfo (io.jmix.ui.WindowInfo)24 WindowManager (com.haulmont.cuba.gui.WindowManager)7 WindowConfig (io.jmix.ui.WindowConfig)7 HashMap (java.util.HashMap)6 Element (org.dom4j.Element)5 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)3 Window (io.jmix.ui.component.Window)3 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 WindowManagerProvider (com.haulmont.cuba.gui.WindowManagerProvider)2 Filter (com.haulmont.cuba.gui.components.Filter)2 Window (com.haulmont.cuba.gui.components.Window)2 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)2 ConditionDescriptorsTreeBuilderAPI (com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI)2 AbstractConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor)2 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)2 Screens (io.jmix.ui.Screens)2 NotFoundScreen (io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen)2 Fragment (io.jmix.ui.component.Fragment)2 FragmentImplementation (io.jmix.ui.component.impl.FragmentImplementation)2 FrameImplementation (io.jmix.ui.component.impl.FrameImplementation)2