带有编辑器框架的 GWT 弹出窗口

发布于 2024-12-29 08:25:52 字数 551 浏览 1 评论 0原文

在一个简单的库存管理应用程序中,我有一个活动来处理向员工分配设备类型(如果用户签出某些东西)。我想知道的是:

目前我可以拖放设备到可以将设备拖到员工处的位置。我想要的是,一旦拖动设备,就会打开一个弹出窗口,要求用户确认以及他希望分配的金额。这基本上将充当两个实体(equipmentCheckin 和 EquipmentCheckout)的编辑器。

这是我遇到的问题:
1.是否应该在视图中初始化弹出窗口,然后在放置事件上设置可见(这是我计划做的)-在这样做时,您如何正确初始化编辑器(是否应该在放置时调用一个单独的活动- 我不认为会有,但编辑器部分让我感到困惑)

2.是否每个弹出窗口都有自己的类和 ui.xml 文件 - 这是我最初要采用的方式,然后只需在放置事件上调用可见集为 true (我认为这是正确的方式)

我想我在这里问的主要只是验证如何做到这一点,我找不到这个东西的合适例子。

对于任何使用过谷歌音乐的人来说,当你去编辑专辑或歌曲信息时,我想做他们正在做的事情 - 我想象他们在幕后使用带有弹出窗口的编辑器 - 我只是想知道正确的是什么实际做到这一点的方法是在我找到解决方案之前

In a simple inventory management app i have an activity to handle assigning equipment types to employees (if a user checks something out). What i am wondering is this:

Currently i have drag and drop up to where equipment can be dragged over to an employee. What i want to have is, as soon as the equipment is dragged, a popup opens asking the user for confirmation as well as the amount he wishes to assign. This will basically act as an Editor around two entities (equipmentCheckin and equipmentCheckout).

Here's the issues i'm running into:
1. should the popup be initialized in the view and then set visible on the drop event (this is what i planned on doing) - in doing this how do you actually initialize the editor properly (should there be a separate activity called on the drop - i don't imagine there would but the editor part is confusing me)

2. should each popup have its own class and ui.xml file - this is the way i was going to go originally and then just call the set visible to true on the drop event (i think this is the right way to go)

i guess what i'm asking here is mostly just validation on how to do some of this, i can't find a decent example for this stuff.

for anybody that's used google music before i want to do exactly what they're doing when you go to edit album or song info - i imagine behind the scenes they're using an editor with a popup - i just want to know what the correct way to actually do this is before i go hack up a solution

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

(り薆情海 2025-01-05 08:25:52

我认为您走在正确的道路上,使弹出窗口独立,并且如果您可以帮助的话,只保留它的一个实例。

就编辑的细节而言,有什么不合理的地方?一般的想法是,您可以创建一次驱动程序,使用弹出窗口(实现编辑器)对其进行初始化,然后在每次准备好使用新模型显示它时调用驱动程序上的编辑。

我通常会得到类似的结果(假设该类扩展了 Popup,实现了 Editor,并在内部定义了驱动程序)

public MyPopup() {
  //uibinder or other layout
  this.driver = GWT.create(Driver.class);
  driver.initialize(this);
}
public void edit(MyModel model) {
  driver.edit(model);
  show();
}

为了用我自己的方法/偏见来调味这个答案,我喜欢 MVP 设置,其中视图和演示者都是接口,并且演示者实现不知道视图最终将如何绘制。对我来说通常看起来像这样

public interface MyModelEditorView extends Editor<MyModel> {
  // this param is used in a mobile/table situation, where popups aren't as friendly
  void show(AcceptsOneWidget parent);

  // exposes the driver for the presenter * 
  SimpleBeanEditorDriver<MyModel, ?> getDriver();

  void setPresenter(Presenter presenter);

  public interface Presenter {
    // this is the only method that is called externally
    void show(AcceptsOneWidget parent, MyModel model);

    // called by click handlers in the view impl, probably by @UiHandler methods
    void onSaveClicked();
    void onCancelClicked();
  }
}

* Presenter 可能应该控制驱动程序,以便它可以检查错误,如果需要从服务器传递错误,编辑新模型,并刷新结果。

I think you are on the right track, making the popup self-contained, and keeping just a single instance of it if you can help it.

As far as the editor details, what isn't making sense? The general idea is that you can create the driver once, initialize it with the popup (implementing Editor), then call edit on the driver each time you are ready to display it with a new model.

I usually end up with something like (assuming the class extends Popup, implements Editor, and has the driver defined internally)

public MyPopup() {
  //uibinder or other layout
  this.driver = GWT.create(Driver.class);
  driver.initialize(this);
}
public void edit(MyModel model) {
  driver.edit(model);
  show();
}

To flavor this answer with my own approach/biases, I like a MVP setup where the view and presenter are both interfaces, and where the presenter impl doesn't know how the view will end up drawing. Generally looks about like this for me

public interface MyModelEditorView extends Editor<MyModel> {
  // this param is used in a mobile/table situation, where popups aren't as friendly
  void show(AcceptsOneWidget parent);

  // exposes the driver for the presenter * 
  SimpleBeanEditorDriver<MyModel, ?> getDriver();

  void setPresenter(Presenter presenter);

  public interface Presenter {
    // this is the only method that is called externally
    void show(AcceptsOneWidget parent, MyModel model);

    // called by click handlers in the view impl, probably by @UiHandler methods
    void onSaveClicked();
    void onCancelClicked();
  }
}

* Presenter probably should control the driver so it can check for errors, pass in errors from the server if needed, edit new models, and flush out the results.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文