use of com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter in project cuba by cuba-platform.
the class DeclarativeTrackingAction method actionPerform.
@Override
public void actionPerform(Component component) {
if (StringUtils.isEmpty(methodName)) {
return;
}
FrameOwner controller = frame.getFrameOwner();
if (controller instanceof LegacyFragmentAdapter) {
controller = ((LegacyFragmentAdapter) controller).getRealScreen();
}
Method method;
try {
method = controller.getClass().getMethod(methodName, Component.class);
} catch (NoSuchMethodException e) {
try {
method = controller.getClass().getMethod(methodName);
} catch (NoSuchMethodException e1) {
throw new IllegalStateException(String.format("No suitable methods named %s for action %s", methodName, id));
}
}
try {
if (method.getParameterCount() == 1) {
method.invoke(controller, component);
} else {
method.invoke(controller);
}
} catch (Exception e) {
throw new RuntimeException("Exception on action handling", e);
}
}
use of com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter in project cuba by cuba-platform.
the class TimerFacetProvider method addInitTimerMethodTask.
// for compatibility only
@Deprecated
protected void addInitTimerMethodTask(Timer timer, String timerMethodName, ComponentContext context) {
FrameOwner controller = context.getFrame().getFrameOwner();
if (controller instanceof LegacyFragmentAdapter) {
controller = ((LegacyFragmentAdapter) controller).getRealScreen();
}
Class<? extends FrameOwner> windowClass = controller.getClass();
Method timerMethod;
try {
timerMethod = windowClass.getMethod(timerMethodName, Timer.class);
} catch (NoSuchMethodException e) {
throw new GuiDevelopmentException("Unable to find invoke method for timer", context, ParamsMap.of("Timer Id", timer.getId(), "Method name", timerMethodName));
}
timer.addTimerActionListener(new DeclarativeTimerActionHandler(timerMethod, controller));
}
use of com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter in project cuba by cuba-platform.
the class LinkCellClickListener method callControllerInvoke.
protected void callControllerInvoke(Entity rowItem, String columnId, String invokeMethodName) {
FrameOwner controller = table.getFrame().getFrameOwner();
if (controller instanceof LegacyFragmentAdapter) {
controller = ((LegacyFragmentAdapter) controller).getRealScreen();
}
Method method;
method = findLinkInvokeMethod(controller.getClass(), invokeMethodName);
if (method != null) {
try {
method.invoke(controller, rowItem, columnId);
} catch (Exception e) {
throw new RuntimeException("Unable to cal linkInvoke method for table column", e);
}
} else {
try {
method = controller.getClass().getMethod(invokeMethodName);
try {
method.invoke(controller);
} catch (Exception e1) {
throw new RuntimeException("Unable to call linkInvoke method for table column", e1);
}
} catch (NoSuchMethodException e1) {
throw new IllegalStateException(String.format("No suitable methods named %s for invoke", invokeMethodName));
}
}
}
use of com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter in project cuba by cuba-platform.
the class WebScreens method openFrame.
@SuppressWarnings({ "deprecation", "IncorrectCreateGuiComponent" })
@Override
public Frame openFrame(Frame parentFrame, com.haulmont.cuba.gui.components.Component parent, @Nullable String id, WindowInfo windowInfo, Map<String, Object> params) {
ScreenFragment screenFragment;
Fragments fragments = ui.getFragments();
if (params != null && !params.isEmpty()) {
screenFragment = fragments.create(parentFrame.getFrameOwner(), windowInfo.getId(), new MapScreenOptions(params));
} else {
screenFragment = fragments.create(parentFrame.getFrameOwner(), windowInfo.getId());
}
if (id != null) {
screenFragment.getFragment().setId(id);
}
fragments.init(screenFragment);
if (parent instanceof ComponentContainer) {
ComponentContainer container = (ComponentContainer) parent;
for (com.haulmont.cuba.gui.components.Component c : container.getComponents()) {
if (c instanceof com.haulmont.cuba.gui.components.Component.Disposable) {
com.haulmont.cuba.gui.components.Component.Disposable disposable = (com.haulmont.cuba.gui.components.Component.Disposable) c;
if (!disposable.isDisposed()) {
disposable.dispose();
}
}
container.remove(c);
}
container.add(screenFragment.getFragment());
}
if (screenFragment instanceof LegacyFragmentAdapter) {
return ((LegacyFragmentAdapter) screenFragment).getRealScreen();
}
return screenFragment instanceof Frame ? (Frame) screenFragment : new ScreenFragmentWrapper(screenFragment);
}
Aggregations