xworker.swt.design.DesignDialog Maven / Gradle / Ivy
package xworker.swt.design;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;
import xworker.swt.ActionContainer;
public class DesignDialog {
Shell shell;
ActionContext actionContext;
ActionContainer actionContainer;
public DesignDialog(){
}
/**
* 显示一个控件设计对话框。
*
* @param control
*/
public void show(Control control){
//如果shell不存在,那么创建
if(actionContainer == null && shell != null){
shell.dispose();
}
if(shell == null || shell.isDisposed()){
Shell parentShell = Designer.getExplorerShell();
actionContext = new ActionContext();
actionContext.put("explorerActions", Designer.getExplorerActions());
actionContext.put("explorerContext", Designer.getExplorerActions().getActionContext());
actionContext.put("parent", parentShell);
actionContext.put("control", control);
Thing shellThing = World.getInstance().getThing("xworker.ide.worldExplorer.swt.designer.DesignerToolbarDialog");
shell = (Shell) shellThing.doAction("create", actionContext);
actionContainer = (ActionContainer) actionContext.get("actions");
}
//初始化Control
actionContext.getScope(0).put("control", control);
actionContainer.doAction("init", actionContext);
//显示窗口
shell.setVisible(true);
}
/**
* 如果设计对话框显示的那么展示Control。
*
* @param control
*/
public void showIfOpened(Control control){
if(shell == null || shell.isDisposed() || !shell.isVisible()){
return;
}
show(control);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy