【问题标题】:How to use an InputDialog inside EMF Commands?如何在 EMF 命令中使用 InputDialog?
【发布时间】:2010-11-17 12:32:16
【问题描述】:

我正在尝试在自定义命令的 execute() 方法中打开 InputDialog。它看起来如下:

public class MyCommand extends CompoundCommand{
   ...
   execute(){
      try {
         ...
         super.execute();
      }catch(Exception e){
         InputDialog myDialog = ...
         myDialog.open();
         ...
         super.execute();
      }
   }
}

它工作正常,但会引发一些异常。它们是:

org.eclipse.core.commands.ExecutionException: While executing the operation, 
an exception occurred

这是由于

java.lang.IllegalStateException: Cannot open an operation while one 
is already open

我在我的 EMF 项目中覆盖了 ItemProvider 的 createSetCommand() 方法。输入对话框是必要的,以便在用户输入错误值时从用户那里获取有效值。

Thanx Alot Before Hand, 堪阿富汗

【问题讨论】:

  • a) 你能告诉我们你是如何创建 InputDialog 的吗? b) 您最好在 createCommand() 中验证用户输入,甚至可能是 CommandWrapper 而不是 CompoundCommand(除非您知道自己在做什么)。
  • 不再相关。我使用了与上面介绍的完全不同的方法,因为这种方法不是正确的方法。
  • 干得好 KanAfghan。您能否自行发布该问题的答案,然后接受该答案以便我们结束该问题?此外,如果他们解决了您的问题,您需要接受之前问题的答案。

标签: java dialog eclipse-emf


【解决方案1】:

我使用了与上面介绍的完全不同的方法,因为这种方法不是正确的方法。

【讨论】:

    猜你喜欢
    • 2012-03-25
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    • 2021-09-22
    • 2013-09-26
    • 1970-01-01
    相关资源
    最近更新 更多