当前位置: 首页 > 工具软件 > SmartRCP > 使用案例 >

smartrcp的多窗口管理演示代码

韦叶秋
2023-12-01
<?xml version="1.0" encoding="utf-8"?>
<gui:RCPModule xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:gui="cn.smartinvoke.gui.*"
 xmlns:rcp="cn.smartinvoke.rcp.*"
	layout="vertical" creationComplete="init()" horizontalAlign="center" verticalAlign="middle">
	<mx:Script>
		<![CDATA[
			import cn.smartinvoke.smartrcp.gui.FlashViewer;
			import cn.smartinvoke.smartrcp.gui.control.ViewManager;
			import org.eclipse.swt.widgets.Display;
			import cn.smartinvoke.smartrcp.gui.CMessageDialog;
			import org.eclipse.swt.SWT;
			import cn.smartinvoke.smartrcp.gui.module.CShellEvent;
			import cn.smartinvoke.smartrcp.gui.FlashShell;
			import cn.smartinvoke.RemoteObject;
			import mx.collections.ArrayCollection;
			import mx.controls.Alert;
			import cn.smartinvoke.smartrcp.CApplication;
			import cn.smartinvoke.smartrcp.gui.module.CEvent;
			[Bindable]
			public var listData:ArrayCollection=new ArrayCollection();
			public var swfPath:String="views/ContextMenu_T.swf";
			function init():void{
			   	var baseUrl:String=CApplication.Instance.getBaseFolder();
			   	var moduleFolder:String=baseUrl+"/views";
			   //	Alert.show(moduleFolder);
			    
			}
			private var flashShell:FlashShell;
			function onOpenClick():void{
				 flashShell=new FlashShell(SWT.SHELL_TRIM);
				 flashShell.setSize(800,600);
				 
				 flashShell.setText(swfPath);
				 flashShell.createFlashContainer(swfPath);
				 
				 flashShell.addListener(CShellEvent.Event_Closed,
function (evt:CShellEvent):Boolean{
					//打开信息提示框,提示用户是否退出程序
					var dialog:CMessageDialog=new  CMessageDialog
					    ("信息","是否退出程序?",CMessageDialog.INFORMATION,["关闭","取消"],1);
					//打开对话框
				    dialog.open(function (ret:int):void{
				    	   if(ret==0){//如果用户选择了关闭按钮
				    	     //关闭打开的窗口
				    	     //获取模块对应的appId
				        	 var flashViewers:ArrayCollection=
				        	  ViewManager.Instance.findFlashViewers(this.swfPath);
				        	 if(flashViewers!=null){
				        	 	for each(var flashViewer:FlashViewer in flashViewers){ 
				        	 	//获得FlashViwer的父容器FlashShell并关闭
				        	 	 if(flashViewer!=null){
				        	 	  var parent:RemoteObject=flashViewer.getParent();
				        	 	  if(parent!=null && parent is FlashShell){
				        	 		 (FlashShell(parent)).close();
				        	 	  }
				        	 	 }
				        	 	}//end for
				        	 }
				           }
				    },this);
				    
					return false;
				},this);
				
				
				flashShell.open();
				
			}
			
			function onMainShellSetting():void{
				if(flashShell!=null){
				var mainShell:FlashShell=flashShell;
				 //mainShell.setText("这是主窗体"+new Date().valueOf());
				 mainShell.getShell().asyncCall("setMaximized",[true]);
				 /* mainShell.addListener(CShellEvent.Event_Closed,
function (evt:CShellEvent):Boolean{
					Alert.show("fire close event");
					return false;
				 },this); */
				}
			}
			
		]]>
	</mx:Script>
<mx:Panel title="本模块演示smartrcp对多窗口的支持" cornerRadius="0" paddingLeft="0" 
paddingRight="0"
            styleName="opaquePanel" width="100%" height="100%" layout="vertical" 
horizontalAlign="center" verticalAlign="middle">
	
	<mx:Button label="打开窗口" click="onOpenClick()"/>
	<mx:Button label="最大化主窗体" click="onMainShellSetting()"/>
</mx:Panel>
</gui:RCPModule>
 
 类似资料: