Revision 42548

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/MDIFrame.java
97 97
import org.gvsig.tools.i18n.I18nManager;
98 98
import org.gvsig.tools.swing.api.ToolsSwingLocator;
99 99
import org.gvsig.tools.swing.icontheme.IconTheme;
100

  
101 100
import org.slf4j.Logger;
102 101
import org.slf4j.LoggerFactory;
103 102

  
......
355 354
            logger.warn("Unable to find icon '" + selectableTool.getIcon() + "'.");
356 355
            image = PluginServices.getIconTheme().get(noIcon);
357 356
        }
358
        
357

  
359 358
        ToggleButtonModel buttonModel = new ToggleButtonModel();
360 359
        JToolBarToggleButton btn = new JToolBarToggleButton(selectableTool.getText(), image);
361 360
        btn.setModel(buttonModel);
......
373 372
            group = new ButtonGroup();
374 373
            buttonGroupMap.put(selectableTool.getGroup(), group);
375 374
        }
376
        
375

  
377 376
        jtb.addButton(group, btn);
378
        
377

  
379 378
        buttonModel.setGroupName(selectableTool.getGroup());
380 379
        if ( selectableTool.getIsDefault() ) {
381 380
            btn.setSelected(true);
......
573 572
            btn.setToolTip(i18nManager.getTranslation(action.getTooltip()));
574 573
            btn.setToolTipKey(action.getTooltip());
575 574
        }
576
        
575

  
577 576
        SelectableToolBar jtb = getToolBar(toolBarName);
578 577
        jtb.addButton(group, btn);
579
        
578

  
580 579
        addControl(btn);
581 580

  
582 581
    }
......
1193 1192
            });
1194 1193
            return;
1195 1194
        }
1195
        logger.info("ENABLE CONTROOOOOLS");
1196
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
1197
        for(int i=0; i<stackTrace.length; i++){
1198
            logger.info(stackTrace[i].toString());
1199
        }
1196 1200

  
1197 1201
        ActionInfoManager actionManager = PluginsLocator.getActionInfoManager();
1198 1202
        ActionInfoStatusCache cache = actionManager.createActionStatusCache();
......
1213 1217
                        DropDownButton dropDownButton = (DropDownButton)control;
1214 1218
                        visible = !dropDownButton.isAllHiden();
1215 1219
                        enabled = !dropDownButton.isAllDisabled();
1220
                        if (visible && enabled){
1221
                            dropDownButton.updateMainButton();
1222
                        }
1216 1223
                    } else if( control instanceof JMenuTraslatable ) {
1217 1224
                        enabled = true;
1218 1225
                        visible = true;
......
1237 1244
                control.setEnabled(enabled);
1238 1245
                control.setVisible(visible);
1239 1246
            } catch (Throwable ex) {
1240
                // Catch exceptins and errors (class not found)
1247
                // Catch exceptions and errors (class not found)
1241 1248
                logger.info("Can't enable/show control '" + actionName + "'.", ex);
1242 1249
                this.message("Can't enable/show control '" + actionName + "'.", JOptionPane.ERROR_MESSAGE);
1243 1250
                try {
......
1322 1329
    }
1323 1330

  
1324 1331
    public synchronized void refreshControls() {
1332
        logger.info("ESTOY AQUIIIIIIIIIII 1");
1325 1333
        if ( !SwingUtilities.isEventDispatchThread() ) {
1326 1334
            SwingUtilities.invokeLater(new Runnable() {
1327 1335
                public void run() {
......
1331 1339
            return;
1332 1340
        }
1333 1341

  
1342
        logger.info("ESTOY AQUIIIIIIIIIII 2");
1334 1343
        if(refreshingControls){
1335 1344
            return;
1336 1345
        }
1337 1346
        try {
1347
//        enableControls();
1338 1348
        refreshingControls = true;
1339 1349
        ActionInfoManager actionManager = PluginsLocator.getActionInfoManager();
1340 1350
        ActionInfoStatusCache cache = actionManager.createActionStatusCache();
......
1364 1374
                }
1365 1375
            }
1366 1376
        }
1377
        logger.info("ESTOY AQUIIIIIIIIIII 3");
1378

  
1367 1379
        enableControls();
1380
        logger.info("ESTOY AQUIIIIIIIIIII 4");
1381
        logger.info("   ");
1382

  
1368 1383
        } finally {
1369 1384
            refreshingControls = false;
1370 1385
        }
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/DropDownButton.java
65 65
    public void add(final Action action) {
66 66
        this.actions.add(action);
67 67
        if (this.actions.size() == 1) {
68
            mainButton.setIcon((Icon) action.getValue(Action.SMALL_ICON));
69
            if (showText) {
70
                mainButton.setText((String) action.getValue(Action.SHORT_DESCRIPTION));
71
            } else {
72
                mainButton.setText("");
68
            setMainButton(action);
69
        }
70
    }
71

  
72
    private void setMainButton(Action action){
73
        mainButton.setIcon((Icon) action.getValue(Action.SMALL_ICON));
74
        if (showText) {
75
            mainButton.setText((String) action.getValue(Action.SHORT_DESCRIPTION));
76
        } else {
77
            mainButton.setText("");
78
        }
79
        currentAction = action;
80
    }
81

  
82
    public void updateMainButton(){
83
        for (Action action : actions) {
84
            if (action.isEnabled()){
85
                setMainButton(action);
86
                return;
73 87
            }
74
            currentAction = action;
75 88
        }
76 89
    }
77 90

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/toc/gui/TOC.java
62 62
import org.gvsig.andami.actioninfo.ActionInfo;
63 63
import org.gvsig.andami.actioninfo.ActionInfoManager;
64 64
import org.gvsig.andami.messages.NotificationManager;
65
import org.gvsig.app.ApplicationLocator;
65 66
import org.gvsig.app.gui.preferencespage.ViewPage;
66 67
import org.gvsig.app.project.documents.view.IContextMenuAction;
67 68
import org.gvsig.app.project.documents.view.toc.DnDJTree;
......
98 99
import org.slf4j.LoggerFactory;
99 100

  
100 101
/**
101
 * 
102
 *
102 103
 * @author fjp
103 104
 */
104 105
public class TOC extends JComponent implements ITocOrderListener,
......
106 107
    ComponentListener, LegendContentsChangedListener {
107 108

  
108 109
    /**
109
     * 
110
     *
110 111
     */
111 112
    private static final long serialVersionUID = 5689047685537359038L;
112 113

  
......
199 200

  
200 201
    /**
201 202
     * Inserta el FMap.
202
     * 
203
     *
203 204
     * @param mc
204 205
     *            FMap.
205 206
     */
......
235 236
                }
236 237
                LayerCollectionEvent[] events = e.getLayerCollectionEvents();
237 238
                for( int i=0; i<events.length ; i++ ) {
238
                   if( events[i].getEventType() == LayerCollectionEvent.LAYER_ADDED ) { 
239
                   if( events[i].getEventType() == LayerCollectionEvent.LAYER_ADDED ) {
239 240
                       if (PluginServices.getMainFrame() != null) {
240 241
                           PluginServices.getMainFrame().enableControls();
241 242
                       }
......
296 297

  
297 298
    /*
298 299
     * (non-Javadoc)
299
     * 
300
     *
300 301
     * @see com.iver.cit.opensig.gui.IToc#refresh()
301 302
     */
302 303
    public void refresh() {
......
391 392
                            m_TreeModel.insertNodeInto(nodeValue, nodeLayer,
392 393
                                nodeLayer.getChildCount());
393 394
                        }
394
                        
395

  
395 396
                        if (legendInfo instanceof IHasImageLegend) {
396 397
                            TocItemLeaf itemLeaf;
397 398
                            IHasImageLegend imageLegend = (IHasImageLegend) legendInfo;
398 399
                            Image image = imageLegend.getImageLegend();
399
                            
400

  
400 401
                            int w = 0;
401 402
                            int h = 0;
402
                            
403

  
403 404
                            if(image != null) {
404 405
                            	w = image.getWidth(null);
405 406
                            	h = image.getHeight(null);
406 407
                            }
407
                            
408

  
408 409
                            if (image != null && w > 0 && h > 0) {
409 410
                                itemLeaf = new TocItemLeaf();
410 411
                                itemLeaf.setImageLegend(image, "", new Dimension(w, h));
......
420 421
                            "Can't add leyend of layer {0} to the TOC.", lyr),
421 422
                            e);
422 423
                    }
423
                } 
424
                }
424 425
            } // if instanceof layers
425 426
        }
426 427
    }
......
445 446

  
446 447
    /*
447 448
     * (non-Javadoc)
448
     * 
449
     *
449 450
     * @see java.awt.event.ComponentListener#componentHidden(java.awt.event.
450 451
     * ComponentEvent)
451 452
     */
......
454 455

  
455 456
    /*
456 457
     * (non-Javadoc)
457
     * 
458
     *
458 459
     * @see
459 460
     * java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent
460 461
     * )
......
464 465

  
465 466
    /*
466 467
     * (non-Javadoc)
467
     * 
468
     *
468 469
     * @see java.awt.event.ComponentListener#componentResized(java.awt.event.
469 470
     * ComponentEvent)
470 471
     */
......
487 488

  
488 489
    /*
489 490
     * (non-Javadoc)
490
     * 
491
     *
491 492
     * @see
492 493
     * java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent
493 494
     * )
......
497 498

  
498 499
    /*
499 500
     * (non-Javadoc)
500
     * 
501
     *
501 502
     * @see
502 503
     * com.iver.cit.gvsig.fmap.layers.LayerListener#legendChanged(com.iver.cit
503 504
     * .gvsig.fmap.rendering.LegendChangedEvent)
......
517 518

  
518 519
    /*
519 520
     * (non-Javadoc)
520
     * 
521
     *
521 522
     * @see
522 523
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdded(com
523 524
     * .iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
......
556 557
    public void legendCleared(LegendClearEvent event) {
557 558
        refresh();
558 559
    }
559
    
560

  
560 561
    /*
561 562
     * (non-Javadoc)
562
     * 
563
     *
563 564
     * @see
564 565
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerMoved(com
565 566
     * .iver.cit.gvsig.fmap.layers.LayerPositionEvent)
......
579 580

  
580 581
    /*
581 582
     * (non-Javadoc)
582
     * 
583
     *
583 584
     * @see
584 585
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerRemoved(com
585 586
     * .iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
......
600 601

  
601 602
    /*
602 603
     * (non-Javadoc)
603
     * 
604
     *
604 605
     * @see
605 606
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdding(com
606 607
     * .iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
......
610 611

  
611 612
    /*
612 613
     * (non-Javadoc)
613
     * 
614
     *
614 615
     * @see
615 616
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerMoving(com
616 617
     * .iver.cit.gvsig.fmap.layers.LayerPositionEvent)
......
620 621

  
621 622
    /*
622 623
     * (non-Javadoc)
623
     * 
624
     *
624 625
     * @see
625 626
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerRemoving(
626 627
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
......
631 632

  
632 633
    /*
633 634
     * (non-Javadoc)
634
     * 
635
     *
635 636
     * @see
636 637
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#activationChanged
637 638
     * (com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
......
643 644

  
644 645
    /*
645 646
     * (non-Javadoc)
646
     * 
647
     *
647 648
     * @see
648 649
     * com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#visibilityChanged
649 650
     * (com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
......
664 665

  
665 666
    /*
666 667
     * (non-Javadoc)
667
     * 
668
     *
668 669
     * @see
669 670
     * javax.swing.event.TreeExpansionListener#treeCollapsed(javax.swing.event
670 671
     * .TreeExpansionEvent)
......
684 685

  
685 686
    /*
686 687
     * (non-Javadoc)
687
     * 
688
     *
688 689
     * @see
689 690
     * javax.swing.event.TreeExpansionListener#treeExpanded(javax.swing.event
690 691
     * .TreeExpansionEvent)
......
704 705

  
705 706
    /**
706 707
     * Obtiene el JScrollPane que contiene el TOC
707
     * 
708
     *
708 709
     * @return JScrollPane que contiene el TOC
709 710
     */
710 711
    public JScrollPane getJScrollPane() {
......
713 714

  
714 715
    /**
715 716
     * DOCUMENT ME!
716
     * 
717
     *
717 718
     * @return DOCUMENT ME!
718 719
     */
719 720
    public DnDJTree getTree() {
......
738 739

  
739 740
        /**
740 741
         * Crea un nuevo NodeSelectionListener.
741
         * 
742
         *
742 743
         * @param tree
743 744
         *            DOCUMENT ME!
744 745
         */
......
748 749

  
749 750
        /**
750 751
         * DOCUMENT ME!
751
         * 
752
         *
752 753
         * @param e
753 754
         *            DOCUMENT ME!
754 755
         */
755 756
        public void mouseClicked(MouseEvent e) {
757
            logger.info("mouse clicked");
756 758
            int x = e.getX();
757 759
            int y = e.getY();
758 760
            int row = tree.getRowForLocation(x, y);
......
818 820
                                        actives[i].setActive(false);
819 821
                                    }
820 822
                                }
821
                                
823

  
822 824
                                // Do nothing if there is a non-available layer
823 825
                                for (int k=0; k<targetLayers.size(); k++) {
824 826
                                    if (!targetLayers.get(k).isAvailable()) {
825 827
                                        return;
826 828
                                    }
827 829
                                }
828
                                
830

  
829 831
                                action.execute(leaf,
830 832
                                    targetLayers.toArray(new FLayer[0]));
831 833
                            }
......
980 982
                    tree.repaint();
981 983
                }
982 984

  
985
                //FIXME Is it really necessary?
983 986
                if (PluginServices.getMainFrame() != null) {
984 987
                    PluginServices.getMainFrame().enableControls();
985 988
                }
......
1042 1045

  
1043 1046
        /**
1044 1047
         * DOCUMENT ME!
1045
         * 
1048
         *
1046 1049
         * @param lyr
1047 1050
         *            DOCUMENT ME!
1048 1051
         * @param active
......
1055 1058

  
1056 1059
        /**
1057 1060
         * DOCUMENT ME!
1058
         * 
1061
         *
1059 1062
         * @param lyr
1060 1063
         *            DOCUMENT ME!
1061 1064
         */
......
1074 1077

  
1075 1078
        /**
1076 1079
         * Actualiza la visibilidad de la capas.
1077
         * 
1080
         *
1078 1081
         * @param lyr
1079 1082
         *            Capa sobre la que se est? clickando.
1080 1083
         */
......
1089 1092
        /**
1090 1093
         * Actualiza de forma recursiva la visibilidad de los hijos de la capa
1091 1094
         * que se pasa como par?metro.
1092
         * 
1095
         *
1093 1096
         * @param lyr
1094 1097
         *            Capa a actualizar.
1095 1098
         */
......
1109 1112
        /**
1110 1113
         * Actualiza de forma recursiva la visibilidad del padre de la capa que
1111 1114
         * se pasa como par?metro.
1112
         * 
1115
         *
1113 1116
         * @param lyr
1114 1117
         *            Capa a actualizar.
1115 1118
         */
......
1132 1135

  
1133 1136
        /**
1134 1137
         * DOCUMENT ME!
1135
         * 
1138
         *
1136 1139
         * @param arg0
1137 1140
         *            DOCUMENT ME!
1138 1141
         */
......
1141 1144

  
1142 1145
        /**
1143 1146
         * DOCUMENT ME!
1144
         * 
1147
         *
1145 1148
         * @param arg0
1146 1149
         *            DOCUMENT ME!
1147 1150
         */
......
1151 1154

  
1152 1155
        /**
1153 1156
         * DOCUMENT ME!
1154
         * 
1157
         *
1155 1158
         * @param arg0
1156 1159
         *            DOCUMENT ME!
1157 1160
         */
......
1159 1162
            super.mouseEntered(arg0);
1160 1163
        }
1161 1164
    }
1162
    
1165

  
1163 1166
    private boolean invisibilityIsForced() {
1164
        
1167

  
1165 1168
        PluginServices ps = PluginServices.getPluginServices(this);
1166 1169
        XMLEntity xml = ps.getPersistentXML();
1167 1170

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/toc/gui/FPopupMenu.java
36 36
import javax.swing.JPopupMenu;
37 37
import javax.swing.tree.DefaultMutableTreeNode;
38 38

  
39
import org.gvsig.andami.PluginServices;
39 40
import org.gvsig.andami.messages.NotificationManager;
40 41
import org.gvsig.app.project.ProjectManager;
41 42
import org.gvsig.app.project.documents.view.IContextMenuAction;
......
69 70
 * creando una clase derivando de TocMenuEntry, y a?adiendola en
70 71
 * est?tico (o en tiempo de carga de la extensi?n) a FPopupMenu.
71 72
 * (Las entradas actuales est?n hechas de esa manera).
72
 * 
73
 *
73 74
 * @author vcn To change the template for this generated type comment go to
74 75
 *         Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and
75 76
 *         Comments
......
84 85
    private FLayer[] selecteds;
85 86

  
86 87
    public static void registerExtensionPoint() {
87
    	ProjectManager projectManager = ProjectManager.getInstance(); 
88
    	ProjectManager projectManager = ProjectManager.getInstance();
88 89
    	ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME);
89 90

  
90 91
    	viewManager.addTOCContextAction("FSymbolChangeColor", new ChangeSymbolTocMenuEntry());
......
105 106

  
106 107
    /**
107 108
     * Creates a new FPopupMenu object.
108
     * 
109
     *
109 110
     * @param nodo
110 111
     *            DOCUMENT ME!
111 112
     * @param vista
......
173 174
                    NotificationManager.addError(e);
174 175
                }
175 176
                if (action != null ) {
176
                	if( action instanceof AbstractTocContextMenuAction 
177
                	if( action instanceof AbstractTocContextMenuAction
177 178
                		&& !(action instanceof OldTocContextMenuAction)) {
178 179
                		((AbstractTocContextMenuAction)action).setMapContext(this.mapContext);
179 180
                	}
......
246 247
        public void actionPerformed(ActionEvent e) {
247 248
            this.action.execute(FPopupMenu.this.getNodeUserObject(),
248 249
                FPopupMenu.this.selecteds);
250
            if (PluginServices.getMainFrame() != null) {
251
                PluginServices.getMainFrame().enableControls();
252
            }
249 253
        }
250 254
    }
251 255

  

Also available in: Unified diff