Index: sandbox/2.5.1-expresso2/prototype/modules/filters/filters.js
===================================================================
--- sandbox/2.5.1-expresso2/prototype/modules/filters/filters.js	(revision 7753)
+++ sandbox/2.5.1-expresso2/prototype/modules/filters/filters.js	(revision 7858)
@@ -603,48 +603,16 @@
  * Lista os filtros para o usuário
  */
-function list_filters(html){
-	outOfficeVerify();
-	for (var index in selectedMessages) {
-		delete selectedMessages[index];
-	}
-	if(html){
-		if( ! $(".filters-windows").length )
-			container = $('.expressomail-module-container').append("<div class='filters-windows'></div>").find(".filters-windows").html( html ).find(".expresso-window-container");
-		list_container = $('.expressomail-module-container').find(".rule-list-container");
-	}
-	list_container = $(".expresso-window-filters").dialog({
-		title: get_lang('Filters'),
-	    width:700,
-	    modal: true,
-		resizable: false,
-	    closeOnEscape:true,
-	    close:function(event, ui) {
-		    event.stopPropagation();
-			if(list_container.find(".cancel").length)
-				list_container.find(".cancel").trigger('click');
-			$(".dialog-head-buttonpane").hide();
-	    },
-		open: function () {
-			$(".ui-dialog .ui-dialog-titlebar")
-			.append('<a href="#" class="ui-dialog-titlebar-minimize ui-corner-all" role="button"><span class="ui-icon ui-icon-minusthick">minimize</span></a>')
-			.find('.ui-dialog-titlebar-minimize').click(function() {
-				$(".ui-dialog-buttonpane, .ui-dialog-content").toggle();
-				$(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin');
-			});
-			$(".dialog-head-buttonpane").show();
-		},
-	    autoOpen: false,
-		buttons: [{
-			text : get_lang("Close"),
-			click : function() {
-				$( this ).dialog( "close" );
-			}
-		}]
-    });
-	$(".ui-dialog-titlebar").after("<div class='dialog-head-buttonpane ui-dialog-buttonpane ui-widget-content ui-helper-clearfix' style='background-color: rgb(224, 238, 238); '><div class='ui-dialog-buttonset header-buttonpane'></div></div>");
-	$(".dialog-head-buttonpane").css("padding", "5px").
-	find(".header-buttonpane").html("<a href='#' class='button add' title='"+get_lang("Add new rule")+"'>"+get_lang("New rule")+"</a>"+(!outoffice ? "<a href='#' class='button add vacation' title='"+get_lang("Add rule out of office")+"'>"+get_lang("Out of office")+"</a>" : "")).find(".button").button();
-
-	$(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE");
+function list_filters(html)
+{
+    outOfficeVerify();
+    for(var index in selectedMessages)
+    {
+        delete selectedMessages[index];
+    }
+
+    initialize_container(html); // Inicializa o container do diálogo de filtros
+
+    list_container = create_filter_dialog(); // Cria a estrutura básica do diálogo
+
 	var list = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true));
 	list_container.html(list).find(".button").button();
@@ -866,39 +834,5 @@
 
 	list_container.parent().find(".button.add:first").click(function(){
-		list_container.parent().find(".dialog-head-buttonpane").addClass("hidden");
-		DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){
-			list_container.html(html);
-			var accord = list_container.find(".rule-details-container").accordion({autoHeight: false});
-			list_container.find(".button").button().filter(".forth").click(function(){
-				accord.accordion('activate',1);
-			}).end().filter(".forth2").click(function(){
-				accord.accordion('activate',2);
-			}).end().filter(".back").click(function(){
-				accord.accordion('activate',0);
-			}).end().filter(".back2").click(function(){
-				accord.accordion('activate',1);
-			}).end().filter(".cancel").click(function(){
-				DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-			}).end().filter(".submit").click(function() {
-				if(valid_save())
-					$(this).submit();
-				else
-					return;
-				DataLayer.commit( 'filter',false,function(){
-					if($('#gbox_fields-search-messages-grid').length > 0 && action != '') {
-						for (var index in selectedMessages) {
-							set_message_flag(index, action, false);
-						}
-					}
-					DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters);
-					getFromAlertRules();
-				});
-			}).end().filter('.button.search').click(function() {
-				if(valid_save())
-					showGridMessages($(this));
-				else
-					return;
-			}); // end function click
-		});	// end DataLayer.render
+        render_new_rule(); // Renderiza a tela de criação de nova regra de filtragem.
 	});
 	list_container.parent().find(".button.add.vacation").click(function(){
@@ -931,4 +865,122 @@
 
 
+/*
+    Inicializa o container do diálogo de gerenciamento de filtros.
+*/
+function initialize_container (html) {
+    if(html)
+    {
+        if(!$(".filters-windows").length) 
+        {
+            container = $('.expressomail-module-container').append("<div class='filters-windows'></div>").find(".filters-windows").html(html).find(".expresso-window-container");
+        }
+    }
+}
+
+/*
+    Cria a estrutura básica do diálogo de gerenciamento de filtros.
+*/
+
+function create_filter_dialog () {
+    var dialog = $(".expresso-window-filters").dialog(
+    {
+        title: get_lang('Filters'),
+        width: 700,
+        modal: true,
+        resizable: false,
+        closeOnEscape: true,
+        close: function(event, ui)
+        {
+            event.stopPropagation();
+            if(list_container.find(".cancel").length) list_container.find(".cancel").trigger('click');
+            $(".dialog-head-buttonpane").hide();
+        },
+        open: function()
+        {
+            $(".ui-dialog .ui-dialog-titlebar").append('<a href="#" class="ui-dialog-titlebar-minimize ui-corner-all" role="button"><span class="ui-icon ui-icon-minusthick">minimize</span></a>').find('.ui-dialog-titlebar-minimize').click(function()
+            {
+                $(".ui-dialog-buttonpane, .ui-dialog-content").toggle();
+                $(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin');
+            });
+            $(".dialog-head-buttonpane").show();
+        },
+        autoOpen: false,
+        buttons: [
+        {
+            text: get_lang("Close"),
+            click: function()
+            {
+                $(this).dialog("close");
+            }
+        }]
+    });
+
+    $(".ui-dialog-titlebar").after("<div class='dialog-head-buttonpane ui-dialog-buttonpane ui-widget-content ui-helper-clearfix' style='background-color: rgb(224, 238, 238); '><div class='ui-dialog-buttonset header-buttonpane'></div></div>");
+    $(".dialog-head-buttonpane").css("padding", "5px").
+    find(".header-buttonpane").html("<a href='#' class='button add' title='" + get_lang("Add new rule") + "'>" + get_lang("New rule") + "</a>" + (!outoffice ? "<a href='#' class='button add vacation' title='" + get_lang("Add rule out of office") + "'>" + get_lang("Out of office") + "</a>" : "")).find(".button").button();
+    $(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE");
+
+    return dialog;
+}
+
+/*
+    Renderiza a tela de adição de uma nova regra de filtragem, 
+    dentro do diálogo de gerenciamento de filtros.
+*/
+function render_new_rule (from, subject) {
+    list_container.parent().find(".dialog-head-buttonpane").addClass("hidden");
+    var data = {
+        folders: DataLayer.get("folder", true),
+        delimiter: cyrus_delimiter,
+        from: from,
+        subject: subject ? html_entities(subject) : subject
+    }
+
+    DataLayer.render(BASE_PATH + 'modules/filters/edit-filter.ejs', data, function(html)
+    {
+        list_container.html(html);
+        var accord = list_container.find(".rule-details-container").accordion(
+        {
+            autoHeight: false
+        });
+        list_container.find(".button").button().filter(".forth").click(function()
+        {
+            accord.accordion('activate', 1);
+        }).end().filter(".forth2").click(function()
+        {
+            accord.accordion('activate', 2);
+        }).end().filter(".back").click(function()
+        {
+            accord.accordion('activate', 0);
+        }).end().filter(".back2").click(function()
+        {
+            accord.accordion('activate', 1);
+        }).end().filter(".cancel").click(function()
+        {
+            DataLayer.render(BASE_PATH + 'modules/filters/init.ejs', {}, list_filters);
+        }).end().filter(".submit").click(function()
+        {
+            if(valid_save()) $(this).submit();
+            else return;
+            DataLayer.commit('filter', false, function()
+            {
+                if($('#gbox_fields-search-messages-grid').length > 0 && action != '')
+                {
+                    for(var index in selectedMessages)
+                    {
+                        set_message_flag(index, action, false);
+                    }
+                }
+                DataLayer.render(BASE_PATH + 'modules/filters/init.ejs', {}, list_filters);
+                getFromAlertRules();
+            });
+        }).end().filter('.button.search').click(function()
+        {
+            if(valid_save()) showGridMessages($(this));
+            else return;
+        }); // end function click
+    }); // end DataLayer.render
+    }
+
 /* Inicializa os filtros e chama o list_filters 
  * Inicia a funcionalidade de filtros de mensagens
Index: sandbox/2.5.1-expresso2/prototype/modules/filters/edit-filter.ejs
===================================================================
--- sandbox/2.5.1-expresso2/prototype/modules/filters/edit-filter.ejs	(revision 7703)
+++ sandbox/2.5.1-expresso2/prototype/modules/filters/edit-filter.ejs	(revision 7858)
@@ -28,5 +28,5 @@
 
 				</select>
-				<input type="text" name="criteriaValue[]" />
+				<input type="text" name="criteriaValue[]" value="<%= data.from %>" />
 				<input type="hidden" name="criteriaType[]" value="from"/>
 			</fieldset>
@@ -53,5 +53,5 @@
 
 				</select>
-				<input type="text" name="criteriaValue[]" />
+				<input type="text" name="criteriaValue[]" value="<%= data.subject %>" />
 				<input type="hidden" name="criteriaType[]" value="subject"/>
 			</fieldset>
