소스 검색

added a "file<pattern>" type, which will include a button in the editor to
spawn a new file browser that looks for files which match the pattern
it then automatically fills in the input field
this required to allow AToMPM to spawn multiple pop-up windows

Simon Van Mierlo 8 년 전
부모
커밋
b015b36f28
4개의 변경된 파일64개의 추가작업 그리고 32개의 파일을 삭제
  1. 12 6
      client/behavioursc_dialog.js
  2. 38 4
      client/gui_utils.js
  3. 1 1
      client/window_event.js
  4. 13 21
      client/window_management.js

+ 12 - 6
client/behavioursc_dialog.js

@@ -32,10 +32,9 @@ __dialogBehaviourStatechart = {
 		1:
 			function(event)	
 			{
-				WindowManagement.closeDialog(event); // HUSEYIN-ENTER
-				//WindowManagement.closeDialog();
-			}	
-		},
+				WindowManagement.closeDialog(event);
+			}
+        },
 
 	'__exitActions':{},
 	
@@ -70,9 +69,16 @@ __dialogBehaviourStatechart = {
 			{
 				if( name == __EVENT_KEYUP_ESC ||
 					 name == __EVENT_CANCELED_DIALOG ||
-					 name == __EVENT_KEYUP_ENTER || // HUSEYIN-ENTER
+					 name == __EVENT_KEYUP_ENTER ||
 					 name == __EVENT_OKAYED_DIALOG )
-					this.__T(this.__STATE_CLOSED,event);
+                    // let's not look at this ever again
+                    if (__dialog_stack.length == 1)
+                        this.__T(this.__STATE_CLOSED,event);
+                    else
+                        WindowManagement.closeDialog();
+                    
+				else if( name == __EVENT_SHOW_DIALOG )
+					this.__T(this.__STATE_OPEN,event);
 		
 				else
 					return;

+ 38 - 4
client/gui_utils.js

@@ -345,7 +345,8 @@ GUIUtils = function(){
 				 };
 	
 			var de 	 = defaultEntry( explodeType(type) ),
-				 isMap = type.match(/^map/);
+				 isMap = type.match(/^map/),
+                 matches = undefined;
 			input.focus( 
 					(isMap ?
 						function()	
@@ -393,6 +394,11 @@ GUIUtils = function(){
 		else if( type.match(/^\$/) )
 			return GUIUtils.getInputField(__specialTypes[type],value);
 	
+		else if (matches = type.match("^file<(.*)>")) {
+			var input 	 = GUIUtils.getFileInput(value,matches[1],"code_style string_input",1),
+				 getinput = function(_){return _.val();}
+        }
+	
 		else
 			var input 	 = GUIUtils.getTextInput(value,"code_style string_input",1),
 				 getinput = (type == 'string' ?
@@ -450,6 +456,31 @@ GUIUtils = function(){
 		input.css("width", width || '400px');
 		return input;
 	};
+    
+    this.getFileInput = function(code,pattern,className,rows){
+        var string_input = this.getTextInput(code, className, rows);
+        var extra_el = $('<button>');
+        extra_el.attr("width", 16);
+        extra_el.attr("height", 16);
+        extra_el.html("...");
+        extra_el.click(function(event) {
+            var options = {'extensions':[pattern],
+                           'multipleChoice':false,
+                           'manualInput':false,
+                           'title':'choose a rule model',
+                           'startDir':'model'},
+                callback =
+                    function(fnames)
+                    {
+                        string_input.val(fnames[0]);
+                    };
+            WindowManagement.openDialog(_FILE_BROWSER,options,callback);
+            event.stopPropagation();
+            event.preventDefault();
+        });
+        string_input.extra_el = extra_el;
+        return string_input;
+    }
 	
 	/**
 	 * Constructs a <textarea> element. In this element, Alt + Right Arrow
@@ -573,12 +604,16 @@ GUIUtils = function(){
 	 * button is clicked
 	 */
 	this.setupAndShowDialog = function(elements,getinput,type,title,callback){
-		BehaviorManager.handleUserEvent(__EVENT_CANCELED_DIALOG);
+		// BehaviorManager.handleUserEvent(__EVENT_CANCELED_DIALOG);
 
 		var dialog 	  = $('#div_dialog'),
+             the_id = __dialog_stack.length;
+             dialog = dialog.clone().attr("id", 'div_dialog_'+the_id);
 			 dim_bg 	  = $('#div_dim_bg'),
 			 div_title = $('<div>');
 
+        __dialog_stack.push(dialog);
+        dialog.appendTo(document.body);
 		div_title.attr("class", 'dialog_title');
 		div_title.append(GUIUtils.getTextSpan(title || ''));
 		dialog.append(div_title);
@@ -594,8 +629,7 @@ GUIUtils = function(){
 
 		if( type != __NO_BUTTONS )
 		{
-			//var ok = $('<button>');
-			var ok = $('<button id="okbutton">'); // HUSEYIN-ENTER
+			var ok = $('<button class="okbutton">'); // HUSEYIN-ENTER
 			ok.click( function(ev) {
 				if( getinput == undefined )
 				{

+ 1 - 1
client/window_event.js

@@ -172,7 +172,7 @@ WindowEventHelper = function(){
 		} else if( event.keyCode == KEY_TAB ){
 			processEvent( KEY_TAB, 1, null, event);
 			// Only process the tab event here if the popup dialog is displayed
-			if( $('#div_dialog').css("display") == "block" ){
+			if( __dialog_stack.length ){
 				tabThroughPopupInputs();
 			}
 			

+ 13 - 21
client/window_management.js

@@ -51,6 +51,8 @@ function __closeDialog(){
 //DEPRECATED FUNCTIONS
 ///////////////////////////////////////////////////////////////////////////////
 
+var __dialog_stack = [];
+
 WindowManagement = function(){
 	/**
 	 * Hides the login screen
@@ -713,6 +715,7 @@ WindowManagement = function(){
 	
 				tr.append( $('<td>').append( GUIUtils.getTextSpan(attr)) );
 				tr.append( $('<td>').append(ii.input) );
+				if (ii.input.extra_el) tr.append( $('<td>').append(ii.input.extra_el) );
 				attrs2ii[attr] = ii;
 				
 				table.append( tr );
@@ -910,7 +913,7 @@ WindowManagement = function(){
 	 */
 	this.showDialog = function()
 	{
-		var dialog = $('#div_dialog'),
+		var dialog = __dialog_stack[__dialog_stack.length-1],
 			 dim_bg = $('#div_dim_bg');
 		dim_bg.css("display", 'inline');
 		dialog.css("display", 'block');
@@ -924,19 +927,6 @@ WindowManagement = function(){
 		__setCanvasScrolling(false);
 	};
 	
-	/**
-	 * Closes the modal dialog if it is currently opened
-	 */
-	this.closeDialog = function()
-	{
-		var dialog = $('#div_dialog');
-		dialog.css("display", 'none');
-		$('#div_dim_bg').css("display", 'none');
-		HttpUtils.removeChildren(dialog);
-		__setCanvasScrolling(true);
-	  	BehaviorManager.setActiveBehaviourStatechart(__SC_CANVAS);	
-	};
-	
 	/**
 	 * Closes the modal dialog if it is currently opened (with arg js event)
 	 * Huseyin Ergin
@@ -945,14 +935,16 @@ WindowManagement = function(){
 	this.closeDialog = function(ev)
 	{
 		if(ev!=null && ev.keyCode==13) {
-			$('#okbutton').click();
+			$('#div_dialog_' + (__dialog_stack.length-1).toString() + " .okbutton").click();
 		}
-		var dialog = $('#div_dialog');
-		dialog.css("display", 'none');
-		$('#div_dim_bg').css("display", 'none');
-		HttpUtils.removeChildren(dialog);
-		__setCanvasScrolling(true);
-	  	BehaviorManager.setActiveBehaviourStatechart(__SC_CANVAS);		
+        __dialog_stack.pop()
+		var dialog = $('#div_dialog_'+__dialog_stack.length);
+        dialog.remove();
+		if (!__dialog_stack.length) {
+            __setCanvasScrolling(true);            
+            $('#div_dim_bg').css("display", 'none');
+            BehaviorManager.setActiveBehaviourStatechart(__SC_CANVAS);
+        }
 	};
 	
 	return this;