ngdialog.java

来自「Novocode的 SWT 控件框架 丰富了MDI功能」· Java 代码 · 共 72 行

JAVA
72
字号
/*******************************************************************************
 * Copyright (c) 2004 Stefan Zeiger and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.novocode.com/legal/epl-v10.html
 * 
 * Contributors:
 *     Stefan Zeiger (szeiger@novocode.com) - initial API and implementation
 *******************************************************************************/

package com.novocode.naf.gui;

import com.novocode.naf.app.*;
import com.novocode.naf.data.ModelBinding;
import com.novocode.naf.gui.event.*;
import com.novocode.naf.model.ModelMap;


/**
 * Base class for special system dialogs which take over the SWT event handling thread.
 * 
 * @author Stefan Zeiger (szeiger@novocode.com)
 * @since Dec 7, 2003
 */

public abstract class NGDialog extends NGWindow
{
  protected String[] actionListeners;

  
  protected NGDialog()
  {
    modality = Modality.PRIMARY_MODAL;
  }


  public abstract DialogWindowInstance createWindowInstance(NAFApplication app, ModelMap models, WindowInstance parent) throws NAFException;


  public abstract void openDialog(DialogWindowInstance dialog) throws NAFException;


  protected void notifyActionListeners(String action, WindowInstance dialog)
  {
    if(action == null) return;
    IActionListener actionListener = getModel(action, dialog.models);
    if(actionListener == null) actionListener = getModel("action", dialog.models);
    if(actionListener != null)
    {
      ActionEvent ae = new ActionEvent(this, action, dialog);
      actionListener.performAction(ae);
    }
  }


  protected Object createDefaultModel(ModelBinding mb)
  {
    if("action".equals(mb.type))
      return new DefaultActionBroadcaster(mb.id);
    if(actionListeners != null)
    {
      for(int i=0; i<actionListeners.length; i++)
      {
        if(actionListeners[i].equals(mb.type))
          return new DefaultActionBroadcaster(mb.id);
      }
    }
    return super.createDefaultModel(mb);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?