Index: DefaultJExpressionBuilder.java
===================================================================
--- DefaultJExpressionBuilder.java	(revision 44266)
+++ DefaultJExpressionBuilder.java	(revision 44267)
@@ -2,7 +2,6 @@
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
-import java.awt.Point;
 import java.awt.Toolkit;
 import java.awt.datatransfer.Clipboard;
 import java.awt.datatransfer.StringSelection;
@@ -19,6 +18,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Objects;
 import javax.swing.DefaultListCellRenderer;
 import javax.swing.ImageIcon;
@@ -48,12 +48,9 @@
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.gvsig.expressionevaluator.Bookmark;
-import org.gvsig.expressionevaluator.Bookmarks;
 import org.gvsig.expressionevaluator.Expression;
 import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
 import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
-import org.gvsig.expressionevaluator.History;
 import org.gvsig.expressionevaluator.SymbolTable;
 import org.gvsig.expressionevaluator.swing.Element;
 import org.gvsig.expressionevaluator.swing.Element.GroupElement;
@@ -70,9 +67,6 @@
 import org.gvsig.tools.swing.api.pickercontroller.PickerController;
 import org.gvsig.tools.swing.api.script.ScriptSwingManager;
 import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
-import org.gvsig.tools.swing.api.windowmanager.Dialog;
-import org.gvsig.tools.swing.api.windowmanager.WindowManager;
-import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2;
 import org.gvsig.tools.swing.icontheme.IconTheme;
 
 /**
@@ -95,7 +89,9 @@
     private ImageIcon defaultIconElement;
     private InfoPanel infoPanel;
     private AbstractAutomaticExpressionChecker automaticExpressionChecker;
-    
+    private HistoryController historyController;
+    private BookmarksController bookmarksController;
+
     private static class InfoPanel implements Component {
 
         private final JEditorPane txtDescription;
@@ -382,7 +378,6 @@
         this.lblMsg.setComponentPopupMenu(msgMenu);
 
         this.pnlDescription.setLayout(new BorderLayout());
-//        this.pnlDescription.setBackground(this.txtDescription.getBackground());
         this.txtExpression.addCaretListener(new CaretListener() {
             @Override
             public void caretUpdate(CaretEvent e) {
@@ -396,16 +391,6 @@
                 JLabel component = (JLabel) super.getTreeCellRendererComponent(tree,value, selected, expanded, leaf, row, hasFocus);
                 JLabel text = component;
                 JLabel icon = component;
-
-//                JPanel component = new JPanel();
-//                JLabel text = new JLabel();
-//                JLabel icon = new JLabel();
-//                component.setLayout(new FlowLayout());
-//                component.add(icon);
-//                component.add(text);
-//                component.setLayout(new GridBagLayout());
-//                component.add(icon, new GridBagConstraints(0,0,0,0,0,0,GridBagConstraints.NORTH,GridBagConstraints.BOTH,new Insets(1,1,1,1),1,1));
-//                component.add(text, new GridBagConstraints(1,0,0,0,0,0,GridBagConstraints.NORTH,GridBagConstraints.BOTH,new Insets(1,1,1,1),1,1));
                 
                 if( value instanceof Element ) {
                     Element element = (Element) value;
@@ -628,19 +613,24 @@
     
         this.tabExpressionBuilder.setEnabledAt(0, this.builderConfig.getPreferences().getScriptsEnabled());
         
-        this.btnHistory.addActionListener(new ActionListener() {
+        this.historyController = new HistoryController(btnHistory) {
             @Override
-            public void actionPerformed(ActionEvent e) {
-                doHistory();
+            public void updateExpression(Expression expression) {
+                setExpression(expression);
             }
-        });
+        };
         
-        this.btnBookmarks.addActionListener(new ActionListener() {
+        this.bookmarksController = new BookmarksController(btnBookmarks) {
             @Override
-            public void actionPerformed(ActionEvent e) {
-                doBookmarks();
+            public void updateExpression(Expression expression) {
+                setExpression(expression);
             }
-        });
+
+            @Override
+            public Expression getExpressionWithOutHistory() {
+                    return DefaultJExpressionBuilder.this.getExpressionWithOutHistory();
+            }
+        };
         
         
         this.infoPanel.repaint();
@@ -935,126 +925,19 @@
             }
         }
     }
-    
-    private void doHistory() {
-        I18nManager i18n = ToolsLocator.getI18nManager();
-        ExpressionEvaluatorManager theManager = ExpressionEvaluatorLocator.getManager();
-        JPopupMenu popup = new JPopupMenu();
-        History history = theManager.getHistory();
-        if( !history.isEmpty() ) {
-            for (Expression expression : history) {
-                popup.add(createHistoryMenuItem(expression));
-            }
-            popup.addSeparator();
-        }
-        JMenuItem showAllHistory = new JMenuItem(i18n.getTranslation("_Show_all_history"));
-        showAllHistory.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                doShowHistoryDialog();
-            }
-        });
-        popup.add(showAllHistory);
-        Point p = this.btnHistory.getLocationOnScreen();
-        popup.show(this.btnHistory, 0, this.btnHistory.getHeight());
+
+    @Override
+    public Object getProperty(String name) {
+        return this.builderConfig.getProperty(name);
     }
-    
-    private JMenuItem createHistoryMenuItem(final Expression expression) {
-        JMenuItem item = new JMenuItem(StringUtils.abbreviate(expression.getPhrase(), 45));
-        item.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                setExpression(expression);
-            }
-        });
-        return item;
+
+    @Override
+    public void setProperty(String name, Object value) {
+        this.builderConfig.setProperty(name, value);
     }
-    
-    private void doShowHistoryDialog() {
-        WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
-        final DefaultHistoryPanel panel = new DefaultHistoryPanel();
-        final Dialog dialog = winManager.createDialog(
-                panel,
-                "History",
-                null, 
-                WindowManager_v2.BUTTONS_OK_CANCEL
-        );
-        dialog.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if( dialog.getAction()!=WindowManager_v2.BUTTON_OK ) {
-                    return;
-                }
-                setExpression(panel.getExpression());
-            }
-        });
-        dialog.show(WindowManager.MODE.DIALOG);
-    }
 
-    private void doBookmarks() {
-        I18nManager i18n = ToolsLocator.getI18nManager();
-        ExpressionEvaluatorManager theManager = ExpressionEvaluatorLocator.getManager();
-        JPopupMenu popup = new JPopupMenu();
-        JMenuItem addToBookmarks = new JMenuItem(i18n.getTranslation("_Add_to_bookmarks"));
-        addToBookmarks.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                doShowBookmarksDialog(getExpressionWithOutHistory());
-            }
-        });
-        popup.add(addToBookmarks);
-        Bookmarks bookmarks = theManager.getBookmarks();
-        if( !bookmarks.isEmpty() ) {
-            popup.addSeparator();
-            for (Bookmark bookmark : bookmarks) {
-                popup.add(createBookmarkMenuItem(bookmark));
-            }
-            popup.addSeparator();
-            JMenuItem showAllBookmarks = new JMenuItem(i18n.getTranslation("_Show_all_bookmarks"));
-            showAllBookmarks.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    doShowBookmarksDialog(null);
-                }
-            });
-            popup.add(showAllBookmarks);
-        }
-        Point p = this.btnBookmarks.getLocationOnScreen();
-        popup.show(this.btnBookmarks, 0, this.btnBookmarks.getHeight());
+    @Override
+    public Map<String, Object> getProperties() {
+        return this.builderConfig.getProperties();
     }
-    
-    private JMenuItem createBookmarkMenuItem(final Bookmark bookmark) {
-        JMenuItem item = new JMenuItem(StringUtils.abbreviate(bookmark.getName(), 45));
-        item.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                setExpression(bookmark.getValue());
-            }
-        });
-        return item;
-    }
-    
-    private void doShowBookmarksDialog(Expression expression) {
-        WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
-        final DefaultBookmarksPanel panel = new DefaultBookmarksPanel(expression);
-        final Dialog dialog = winManager.createDialog(
-                panel,
-                "Bookmarks",
-                null, 
-                WindowManager_v2.BUTTONS_OK_CANCEL
-        );
-        dialog.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if( dialog.getAction()!=WindowManager_v2.BUTTON_OK ) {
-                    return;
-                }
-                Bookmark bookmark = panel.getCurrentBookmark();
-                if( bookmark!=null ) {
-                    setExpression(bookmark.getValue());
-                }
-            }
-        });
-        dialog.show(WindowManager.MODE.DIALOG);
-    }
 }
