Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / LegendManager.java @ 12727

History | View | Annotate | Download (21.7 KB)

1
/*
2
 * Created on 08-feb-2005
3
 *
4
 * gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib��ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.cit.gvsig.project.documents.view.legend.gui;
45

    
46
import java.awt.BorderLayout;
47
import java.awt.Component;
48
import java.awt.Dimension;
49
import java.util.ArrayList;
50
import java.util.Enumeration;
51
import java.util.Hashtable;
52

    
53
import javax.swing.JButton;
54
import javax.swing.JCheckBox;
55
import javax.swing.JComboBox;
56
import javax.swing.JLabel;
57
import javax.swing.JOptionPane;
58
import javax.swing.JPanel;
59
import javax.swing.JScrollPane;
60
import javax.swing.JSplitPane;
61
import javax.swing.JTextArea;
62
import javax.swing.JTree;
63
import javax.swing.tree.DefaultMutableTreeNode;
64
import javax.swing.tree.DefaultTreeCellRenderer;
65
import javax.swing.tree.DefaultTreeModel;
66
import javax.swing.tree.TreePath;
67
import javax.swing.tree.TreeSelectionModel;
68

    
69
import com.iver.andami.PluginServices;
70
import com.iver.andami.messages.NotificationManager;
71
import com.iver.cit.gvsig.exceptions.layers.LegendLayerException;
72
import com.iver.cit.gvsig.fmap.layers.FLayer;
73
import com.iver.cit.gvsig.fmap.layers.FLayers;
74
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
75
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable;
76
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial;
77
import com.iver.cit.gvsig.fmap.rendering.IClassifiedVectorialLegend;
78
import com.iver.cit.gvsig.fmap.rendering.ILegend;
79
import com.iver.cit.gvsig.fmap.rendering.IVectorialLegend;
80
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend;
81
import com.iver.cit.gvsig.gui.styling.SymbolPreviewer;
82
/**
83
 *
84
 * @author jaume dominguez faus - jaume.dominguez@iver.es
85
 */
86
public class LegendManager extends AbstractThemeManagerPage {
87
        private static ArrayList legendPool = new ArrayList();
88
    private FLayer layer;
89
    private ILegend legend; // Le asignaremos la leyenda del primer tema activo.
90
    private Hashtable pages = new Hashtable();
91
    private JPanel topPanel = null;
92
    private JLabel jLabel = null;
93
    private JComboBox jComboBox = null;
94
    private JButton jButton = null;
95
    private JButton jButton1 = null;
96
    private JCheckBox jCheckBox = null;
97
    private JTextArea titleArea = null;
98
    private SymbolPreviewer preview = null;
99
    private JScrollPane jTitleScrollPane = null;
100
    private JTree jTreeLegends;
101
    private ILegendPanel activePanel;
102
    private JScrollPane legendTreeScrollPane;
103
    private boolean dirtyTree;
104
    private DefaultMutableTreeNode root = new DefaultMutableTreeNode();
105
    private DefaultTreeModel treeModel;
106
    private JScrollPane jPanelContainer;
107
        private JPanel jCentralPanel;
108
        private JSplitPane jSplitPane;
109
        private boolean isTreeListenerDisabled;
110

    
111
    public LegendManager() {
112
        initialize();
113
    }
114

    
115
    private void initialize() {
116
        setLayout(new BorderLayout());
117
        add(getTopPanel(), BorderLayout.NORTH);
118
        add(getSplitPane(), BorderLayout.CENTER);
119
        setSize(500, 360);
120
        treeModel = new DefaultTreeModel(root);
121
    }
122

    
123
    private JSplitPane getSplitPane() {
124
            if (jSplitPane == null) {
125
                    jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
126
                    JPanel aux = new JPanel(new BorderLayout(0, 5));
127
            aux.add(getLegendTreeScrollPane(), BorderLayout.CENTER);
128
            aux.add(getPreviewPanel(), BorderLayout.SOUTH);
129
                    jSplitPane.setLeftComponent(aux);
130
                    jSplitPane.setRightComponent(getCentralPanel());
131
                       jSplitPane.setDividerLocation(150);
132
            }
133
            return jSplitPane;
134
    }
135

    
136
    private JPanel getCentralPanel() {
137
        if (jCentralPanel == null) {
138
                jCentralPanel = new JPanel(new BorderLayout(0,10));
139
                jCentralPanel.add(getTitleScroll(), BorderLayout.NORTH);
140
                jCentralPanel.add(getJPanelContainer(), BorderLayout.CENTER);
141
        }
142
        return jCentralPanel;
143
    }
144

    
145
    private JScrollPane getJPanelContainer() {
146
        if (jPanelContainer == null) {
147
            jPanelContainer = new JScrollPane();
148
        }
149
        return jPanelContainer;
150
    }
151

    
152
    /**
153
     * This method initializes jPanel
154
     *
155
     * @return javax.swing.JPanel
156
     */
157
    private JPanel getTopPanel() {
158
        if (topPanel == null) {
159
            jLabel = new JLabel();
160
            topPanel = new JPanel();
161
            topPanel.setLayout(null);
162
            topPanel.setPreferredSize(new Dimension(638, 31));
163
            topPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
164
            jLabel.setBounds(6, 4, 68, 22);
165
            jLabel.setText(PluginServices.getText(this,"Leyenda") + ":");
166
            topPanel.add(jLabel, null);
167
            topPanel.add(getJComboBox(), null);
168
            topPanel.add(getJButton(), null);
169
            topPanel.add(getJButton1(), null);
170
            topPanel.add(getJCheckBox(), null);
171
        }
172
        return topPanel;
173
    }
174
    /**
175
     * This method initializes jComboBox
176
     *
177
     * @return javax.swing.JComboBox
178
     */
179
    private JComboBox getJComboBox() {
180
        if (jComboBox == null) {
181
            jComboBox = new JComboBox();
182
            jComboBox.setBounds(78, 5, 250, 22);
183
        }
184
        return jComboBox;
185
    }
186
    /**
187
     * This method initializes jButton
188
     *
189
     * @return javax.swing.JButton
190
     */
191
    private JButton getJButton() {
192
        if (jButton == null) {
193
            jButton = new JButton();
194
            jButton.setBounds(345, 4, 22, 22);
195
            jButton.setEnabled(false);
196
        }
197
        return jButton;
198
    }
199
    /**
200
     * This method initializes jButton1
201
     *
202
     * @return javax.swing.JButton
203
     */
204
    private JButton getJButton1() {
205
        if (jButton1 == null) {
206
            jButton1 = new JButton();
207
            jButton1.setBounds(371, 4, 22, 22);
208
            jButton1.setEnabled(false);
209
        }
210
        return jButton1;
211
    }
212
    /**
213
     * This method initializes jCheckBox
214
     *
215
     * @return javax.swing.JCheckBox
216
     */
217
    private JCheckBox getJCheckBox() {
218
        if (jCheckBox == null) {
219
            jCheckBox = new JCheckBox();
220
            jCheckBox.setBounds(417, 4, 202, 22);
221
            jCheckBox.setText(PluginServices.getText(this,"Leyenda_Por_Defecto"));
222
            jCheckBox.setEnabled(false);
223
        }
224
        return jCheckBox;
225
    }
226

    
227
    /**
228
     * This method initializes jTextArea
229
     *
230
     * @return javax.swing.JTextArea
231
     */
232
    private JTextArea getTitleArea() {
233
        if (titleArea == null) {
234
            titleArea = new JTextArea();
235
            titleArea.setBackground(java.awt.SystemColor.control);
236
            titleArea.setLineWrap(true);
237
            titleArea.setRows(0);
238
            titleArea.setWrapStyleWord(false);
239
            titleArea.setEditable(false);
240
            titleArea.setPreferredSize(new java.awt.Dimension(495,40));
241
        }
242
        return titleArea;
243
    }
244
    /**
245
     * This method initializes jPanel1
246
     *
247
     * @return javax.swing.JPanel
248
     */
249
    private SymbolPreviewer getPreviewPanel() {
250
        if (preview == null) {
251
            preview = new SymbolPreviewer();
252
            preview.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
253
            preview.setBackground(java.awt.SystemColor.text);
254
            preview.setPreferredSize(new Dimension(getSplitPane().getDividerLocation(), 100));
255
        }
256
        return preview;
257
    }
258

    
259
    /**
260
     * @return Returns the renderer.
261
     */
262
    public ILegend getRenderer() {
263
        return activePanel.getLegend();
264
    }
265

    
266

    
267
    /**
268
     * This method initializes jScrollPane
269
     *
270
     * @return javax.swing.JScrollPane
271
     */
272
    private JScrollPane getLegendTreeScrollPane() {
273
        if (legendTreeScrollPane == null) {
274
            legendTreeScrollPane = new JScrollPane();
275
            legendTreeScrollPane.setViewportView(getJTreeLegends());
276
        }
277
        return legendTreeScrollPane;
278
    }
279

    
280
    /**
281
     * <p>Adds a new fully-featured legend panel to the LegendManager.<br></p>
282
     *
283
     * <p><b>CAUTION:</b> Trying to add a child page whose parent hasn't been added yet
284
     * causes the application to fall in an infinite loop. This is a known
285
     * bug, sorry. Just avoid this case or try to fix it (lol).<br></p>
286
     *
287
     * <p><b>Notice</b> that there is no type check so if you add a non-ILegendPanel class,
288
     * you'll have a runtime error later.</p>
289
     * @param page, Class of type ILegendPanel
290
     */
291
    public static void addLegendPage(Class iLegendPanelClass) {
292
            if (!legendPool.contains(iLegendPanelClass)) {
293
                    legendPool.add(iLegendPanelClass);
294
            }
295
    }
296

    
297
    /**
298
     * Causes the component to be autofilled with the legend pages that
299
     * were added through the static method addLegendPage(ILegendPanel page)
300
     */
301
    private void fillDialog() {
302
            for (int i = 0; i < legendPool.size(); i++) {
303
                    Class pageClass = (Class) legendPool.get(i);
304
                    ILegendPanel page;
305
                    try {
306
                            page = (ILegendPanel) pageClass.newInstance();
307
                            if (page.isSuitableFor(layer)) {
308
                                    // this legend can be applied to this layer
309
                                    pages.put(page.getClass(), page);
310

    
311
                                    if (dirtyTree) {
312
                                            // rebuild page tree
313
                                            dirtyTree = false;
314

    
315
                                            ArrayList legList = new ArrayList(pages.values());
316
                                            ArrayList alreadyAdded = new ArrayList();
317
                                            DefaultTreeModel model = new DefaultTreeModel(root);
318
                                            while (legList.size()>0) {
319
                                                    ILegendPanel legend = (ILegendPanel) legList.get(0);
320
                                                    Class parent = legend.getParentClass();
321
                                                    while (parent != null &&
322
                                                                    !alreadyAdded.contains(pages.get(parent))) {
323
                                                            legend = (ILegendPanel) pages.get(parent);
324
                                                    }
325
                                                    doInsertNode(model, legend);
326
                                                    legList.remove(legend);
327
                                                    alreadyAdded.add(legend);
328
                                            }
329
                                            treeModel = model;
330
                                            jTreeLegends.setModel(model);
331
                                    }
332
                                    doInsertNode(treeModel, page);
333

    
334
                            }
335
                            getJTreeLegends().setModel(treeModel);
336

    
337
                    } catch (InstantiationException e) {
338
                            NotificationManager.addError("Trying to instantiate an interface" +
339
                                            " or abstract class + "+pageClass.getName(), e);
340
                    } catch (IllegalAccessException e) {
341
                            NotificationManager.addError("IllegalAccessException: does " +
342
                                            pageClass.getName()        + " class have an anonymous" +
343
                                            " constructor?", e);
344
                    }
345

    
346
            }
347
            getJTreeLegends().repaint();
348

    
349
    }
350

    
351
    private DefaultMutableTreeNode findNode(Class searchID) {
352
            String title;
353
            try {
354
                    title = ((ILegendPanel) Class.forName(searchID.getName()).newInstance()).getTitle();
355
            } catch (Exception e) {
356
                    // this should be impossible, but anyway this case will be treat as the node does not
357
                    // exist.
358
                    return null;
359
            }
360

    
361
        Enumeration e = root.breadthFirstEnumeration();
362
        while (e.hasMoreElements()) {
363
            DefaultMutableTreeNode nodeAux = (DefaultMutableTreeNode) e.nextElement();
364
            if (nodeAux != null) {
365
                ILegendPanel legend = (ILegendPanel) nodeAux.getUserObject();
366
                if (legend == null) continue; // Root node
367
                if (legend.getTitle().equals(title)) {
368
                    return nodeAux;
369
                }
370
            }
371
        }
372
        return null;
373
    }
374

    
375
    private void doInsertNode(DefaultTreeModel treeModel, ILegendPanel page) {
376
        dirtyTree = ((page.getParentClass() != null) && (findNode(page.getParentClass())==null));
377
        if (findNode(page.getClass()) != null) // It is already added
378
            return;
379
        if (page.getParentClass() != null) {
380
            if (pages.containsKey(page.getParentClass())) {
381
                ILegendPanel parent = (ILegendPanel) pages.get(page.getParentClass());
382
                DefaultMutableTreeNode nodeParent = findNode(parent.getClass());
383
                if (nodeParent == null) {
384
                        // the parent is empty
385
                    // Recursively add it
386
                    doInsertNode(treeModel, parent);
387
                } else {
388
                    DefaultMutableTreeNode nodeValue = new DefaultMutableTreeNode(page);
389
                    int children = nodeParent.getChildCount();
390
                    int pos=0;
391
                    for (int i = 0; i < children; i++) {
392
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeModel.getChild(nodeParent, i);
393
                        if (node.getUserObject() instanceof ILegendPanel) {
394
                            String pageTitle = ((ILegendPanel) node.getUserObject()).getTitle();
395
                            if (pageTitle.compareTo(page.getTitle()) < 0) ++pos;
396
                        }
397
                    }
398
                    treeModel.insertNodeInto(nodeValue, nodeParent, pos);
399
                }
400
            }
401
        } else {
402
                // First level node
403
            DefaultMutableTreeNode nodeValue = new DefaultMutableTreeNode(page);
404
            int children = root.getChildCount();
405
            int pos=0;
406
            for (int i = 0; i < children; i++) {
407
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeModel.getChild(root, i);
408
                if (node.getUserObject() instanceof ILegendPanel) {
409
                    String pageTitle = ((ILegendPanel) node.getUserObject()).getTitle();
410
                    if (pageTitle.compareTo(page.getTitle()) < 0) ++pos;
411
                }
412
            }
413
            treeModel.insertNodeInto(nodeValue, root, pos);
414
        }
415
    }
416

    
417
    private JScrollPane getTitleScroll() {
418
        if (jTitleScrollPane == null) {
419
            jTitleScrollPane = new JScrollPane();
420
            jTitleScrollPane.setBounds(2, 2, 498, 42);
421
            jTitleScrollPane.setViewportView(getTitleArea());
422
        }
423
        return jTitleScrollPane;
424
    }
425

    
426
    private JTree getJTreeLegends() {
427
        if (jTreeLegends == null) {
428
            jTreeLegends = new JTree();
429
            jTreeLegends.setRootVisible(false);
430
            MyTreeCellRenderer treeCellRenderer = new MyTreeCellRenderer();
431
            treeCellRenderer.setOpenIcon(null);
432
            treeCellRenderer.setClosedIcon(null);
433
            treeCellRenderer.setLeafIcon(null);
434

    
435
            jTreeLegends.setCellRenderer(treeCellRenderer);
436
            jTreeLegends.setShowsRootHandles(true);
437
            jTreeLegends.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
438
                    public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
439
                            if (isTreeListenerDisabled) return;
440
                            DefaultMutableTreeNode node = (DefaultMutableTreeNode)
441
                            jTreeLegends.getLastSelectedPathComponent();
442

    
443
                            if (node == null) return;
444
                            setActivePage((ILegendPanel) node.getUserObject());
445
                    }
446
            });
447
            jTreeLegends.putClientProperty("JTree.linestyle", "Angled");
448
            jTreeLegends.getSelectionModel().
449
                    setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
450
        }
451
        return jTreeLegends;
452
    }
453

    
454
    private void setActivePage(ILegendPanel page) {
455
        if (page.getPanel() == null) {
456
                // this is what happens when the user clicked in a parent node
457
                // which only acts as a folder, and does not manage any legend
458
                // then it expands and selects the first child
459
            DefaultMutableTreeNode node = findNode(page.getClass());
460
            if (treeModel.getChildCount(node)>0) {
461
                DefaultMutableTreeNode dmn = (DefaultMutableTreeNode) treeModel.getChild(node, 0);
462
                page = (ILegendPanel) dmn.getUserObject();
463
                setActivePage(page);
464
                expandAndSelect(page);
465
            }
466
        } else {
467
                // show the page
468
            activePanel = page;
469
            activePanel.setData(layer, legend);
470
            getTitleArea().setText(activePanel.getDescription());
471
            getPreviewPanel().setSymbol(activePanel.getPreviewSymbol());
472
            jPanelContainer.setViewportView(activePanel.getPanel());
473
        }
474
    }
475

    
476

    
477
    private class MyTreeCellRenderer extends DefaultTreeCellRenderer
478
    {
479
        public MyTreeCellRenderer() {
480
        }
481

    
482
        public Component getTreeCellRendererComponent(
483
                            JTree tree,
484
                            Object value,
485
                            boolean sel,
486
                            boolean expanded,
487
                            boolean leaf,
488
                            int row,
489
                            boolean hasFocus) {
490

    
491
            super.getTreeCellRendererComponent(
492
                            tree, value, sel,
493
                            expanded, leaf, row,
494
                            hasFocus);
495
            if (value instanceof DefaultMutableTreeNode)
496
            {
497
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
498
                if (node.getUserObject() instanceof ILegendPanel)
499
                {
500
                    ILegendPanel legend = (ILegendPanel) node.getUserObject();
501
                    this.setText(
502
                            legend.getPanel() == null ? "<html><b>"+legend.getTitle()+"</b></html>":legend.getTitle());
503
                }
504
            }
505
            return this;
506
        }
507

    
508
    }
509

    
510
        private void expandAndSelect(Object node) {
511
                isTreeListenerDisabled = true;
512
            // will expand the tree and select the node
513
            int i = 0;
514
            boolean exit = false;
515

    
516
            TreePath tp = null;
517
            // find the page in the tree
518
            while (i<jTreeLegends.getRowCount() && !exit) {
519
                    //see if this row is the node that we are looking for
520

    
521
                    tp = jTreeLegends.getPathForRow(i);
522
                    Object[] obj = tp.getPath();
523
                    for (int j = 0; j < obj.length && !exit ; j++) {
524
                                Object o = ((DefaultMutableTreeNode) obj[j]).getUserObject();
525

    
526
                                if (o!=null        && o.getClass().equals(node.getClass())        && o.equals(node)) {
527
                                // found it! collapse the tree
528
                                while (i>=0) {
529
                                        jTreeLegends.collapseRow(i);
530
                                        i--;
531
                                }
532
                                exit = true;
533
                        }
534
                        }
535
                    jTreeLegends.expandRow(i);
536
                    i++;
537
            }
538

    
539
            // expand the tree and set the selection
540
            if (tp != null) {
541
                    jTreeLegends.expandPath(tp);
542
                    jTreeLegends.setSelectionPath(tp);
543
            }
544
            isTreeListenerDisabled = false;
545
        }
546

    
547
        public String getName() {
548
                return PluginServices.getText(this,"Simbologia");
549
        }
550

    
551
        public void acceptAction() {
552

    
553

    
554
        }
555

    
556
        public void cancelAction() {
557
                // does nothing
558
        }
559

    
560
        public void applyAction() {
561
                legend = activePanel.getLegend();
562

    
563
                /* try to apply the legend to all the active layers that
564
                 can accept it */
565
                FLayer[] activeLyrs = layer.getMapContext().getLayers().getActives();
566
                for (int i=0; i < activeLyrs.length; i++) {
567
                        FLayer laux=activeLyrs[i];
568

    
569
                        if (activeLyrs[i] instanceof FLayers){
570
                                laux=getFirstActiveLayerVect((FLayers)activeLyrs[i]);
571
                        }
572

    
573
                        if (laux instanceof ClassifiableVectorial) {
574
                                ClassifiableVectorial aux2 = (ClassifiableVectorial) laux;
575
                                try {
576
                                        if (legend instanceof IClassifiedVectorialLegend) {
577
                                                // Es una leyenda que necesita un recordset con un
578
                                                // nombre de campo. Comprobamos que ese recordset
579
                                                // tiene ese nombre de campo y es del tipo esperado
580
                                                IClassifiedVectorialLegend cl = (IClassifiedVectorialLegend) legend;
581

    
582
                                                if (aux2 instanceof AlphanumericData) {
583
//                                                        DataSource rs;
584
//                                                        rs = ((AlphanumericData) aux2).getRecordset();
585
                                                        if (cl.getValues().length==0) {
586
                                                                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"no_es_posible_aplicar_leyenda_vacia"));
587
                                                                return;
588
                                                        }
589
//                                                        int idField = rs.getFieldIndexByName(cl.getFieldNames());
590
//                                                        if (idField != -1) {
591
                                                                //TODO: Aqu� deber�amos comprobar si el tipo de campo
592
                                                                // es el tipo de campo esperado.
593
                                                                /*if (renderer instanceof VectorialUniqueValueLegend){
594
                                                                 ((VectorialUniqueValueLegend)renderer).setLabelHeightField(null);
595
                                                                 ((VectorialUniqueValueLegend)renderer).setLabelRotationField(null);
596
                                                                 }
597
                                                                 */
598
                                                                aux2.setLegend((IVectorialLegend) legend);
599
//                                                        }
600
                                                }
601
                                        }
602
                                        else if (legend instanceof SingleSymbolLegend)
603
                                                aux2.setLegend((IVectorialLegend) legend);
604
//                                } catch (ReadDriverException e) {
605
//                                        NotificationManager.addError(PluginServices.getText(this, "driver_exception")+":"
606
//                                                        +e.getMessage(), e);
607
                                } catch (LegendLayerException e) {
608
                                        NotificationManager.addError(PluginServices.getText(this, "legend_exception"), e);
609
                                }
610
                        }
611
                }
612
        }
613

    
614
        public void setModel(FLayer layer) {
615
                this.layer = layer;
616
                this.legend = ((Classifiable) layer).getLegend();
617
                fillDialog();
618
        Enumeration en = pages.keys();
619
        while (en.hasMoreElements()) {
620
                ILegendPanel page = (ILegendPanel) pages.get(en.nextElement());
621
//                page.setData(layer, legend);
622
                if (legend.getClass().equals(page.getLegendClass())) {
623
                        setActivePage(page);
624
                        expandAndSelect(page);
625
                }
626
        }
627
        }
628
}