com.talk2object.plum.interaction.WindowInteractionManager Maven / Gradle / Ivy
package com.talk2object.plum.interaction;
import java.util.List;
import com.talk2object.plum.interaction.application.PlumApplicationContextUtils;
import com.talk2object.plum.interaction.rich.field.InteractiveField;
import com.talk2object.plum.interaction.rich.field.ViewMode;
import com.talk2object.plum.interaction.view._abstract.components.containers.window.FormDialog;
import com.talk2object.plum.interaction.viewgeneneration.BuilderMatchPolicy;
import com.talk2object.plum.interaction.viewgeneneration.ViewBuildContext;
import com.talk2object.plum.interaction.viewgeneneration.ViewClass;
import com.talk2object.plum.interaction.viewgeneneration.ViewDetail;
import com.talk2object.plum.interaction.viewgeneneration.ViewFactory;
import com.talk2object.plum.view._abstract.components.containers.window.ConfirmationBox;
import com.talk2object.plum.view._abstract.components.containers.window.MainWindow;
import com.talk2object.plum.view._abstract.components.containers.window.ModalResult;
import com.talk2object.plum.view._abstract.components.containers.window.NotificationBox;
import com.talk2object.plum.view._abstract.components.containers.window.Window;
import com.talk2object.plum.view._abstract.window.UIComponent;
/**
* work with abstract window system, which support window, menu, button, dialog
* box, etc.
*
* for a usually inputModal operation, this class would create a dialog box and
* attach it to the current main view object. A set of abstract view class
* should be pre-defined.
*
* @author jackding
*
*/
public class WindowInteractionManager implements InteractionManager {
/**
* root node of view DOM
*/
private MainWindow mainWindow;
public WindowInteractionManager() {
}
public WindowInteractionManager(MainWindow mainWindow) {
this.mainWindow = mainWindow;
}
@Override
public Form getCurrentForm() {
Window window = mainWindow.getWindowManager().getVisibleFontWindow();
if (window instanceof Form)
return (Form) window;
else
return null;
}
@Override
public Form scan(String title, List inputs) {
// create a window form
FormDialog formDialog = new FormDialog(inputs);
formDialog.setName(title);
formDialog.setTitle(title);
formDialog.showModal(mainWindow);
return formDialog;
}
@Override
public Form scan(List inputs) {
return scan("interaction form", inputs);
}
@Override
public ModalResult inform(String title, Object message) {
ViewFactory factory = PlumApplicationContextUtils.getViewFactory();
UIComponent view = factory.create(message,
BuilderMatchPolicy.SUBCLASS_BEAN_OBJECT,
ViewClass.SHOW.getFullName(), ViewBuildContext.DEFAULT, null);
NotificationBox box = new NotificationBox(view);
box.setName("interaction notification");
box.setTitle(title);
return box.showModal(mainWindow);
}
@Override
public ModalResult inform(Object message) {
return inform("Information", message);
}
@Override
public ModalResult confirm(String message) {
ConfirmationBox box = new ConfirmationBox(message);
box.setName("interaction confirmation");
box.setTitle("Confirmation");
return box.showModal(mainWindow);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy