Revision 124

View differences:

org.gvsig.educa.batovi/trunk/org.gvsig.educa.batovi.mapviewer/org.gvsig.educa.batovi.mapviewer/src/main/java/org/gvsig/educa/batovi/mapviewer/Main.java
115 115

  
116 116
    private StatusBar statusBar;
117 117

  
118
    private AbstractAction showHideToc;
119

  
118 120
    public static void main(String args[]) {
119 121
        new DefaultLibrariesInitializer().fullInitialize();
120 122

  
......
291 293
        };
292 294
        installThematicMaps.setEnabled(false);
293 295

  
296
        showHideToc = new AbstractAction("Show/Hide Toc") {
297

  
298
            public void actionPerformed(ActionEvent e) {
299
                showHideToc();
300
            }
301

  
302
        };
303
        showHideToc.setEnabled(false);
304

  
294 305
    }
295 306

  
296 307
    /**
308
     *
309
     */
310
    protected void showHideToc() {
311
        curViewer.setTocVisible(!curViewer.isTocVisible());
312
    }
313

  
314
    /**
297 315
     * Creates the menu bar
298 316
     */
299 317
    private void createMenu() {
......
337 355
        toolBar.add(usabManager.createJButton(closeThematicMapAction));
338 356

  
339 357
        toolBar.addSeparator(sepSize);
358
        toolBar.add(usabManager.createJButton(showHideToc));
359

  
360
        toolBar.addSeparator(sepSize);
340 361
        toolBar.add(usabManager.createJButton(setPanToolAction));
341 362
        toolBar.add(usabManager.createJButton(setZoomToolAction));
342 363

  
......
344 365
        toolBar.add(usabManager.createJButton(zoomAllAction));
345 366

  
346 367
        toolBar.add(Box.createHorizontalGlue());
368
        toolBar.add(new JButton(installThematicMaps));
369
        toolBar.addSeparator(sepSize);
347 370
        toolBar.add(new JButton(exitAction));
348 371

  
349 372
        mainFrame.add(toolBar, BorderLayout.PAGE_START);
......
482 505
        createCompilationFromMapAction.setEnabled(curViewer != null);
483 506
        setZoomToolAction.setEnabled(curViewer != null);
484 507
        setPanToolAction.setEnabled(curViewer != null);
508
        showHideToc.setEnabled(curViewer != null);
485 509
        closeThematicMapAction.setEnabled(curViewer != null);
486 510
        zoomAllAction.setEnabled(curViewer != null);
487 511
        installThematicMaps
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.swing/org.gvsig.educa.thematicmap.swing.api/src/main/java/org/gvsig/educa/thematicmap/swing/viewer/ThematicMapViewer.java
77 77
     */
78 78
    MapControl getMapControl();
79 79

  
80
    boolean isTocVisible();
81

  
82
    void setTocVisible(boolean visible);
83

  
80 84
}
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.swing/org.gvsig.educa.thematicmap.swing.impl/src/main/java/org/gvsig/educa/thematicmap/swing/impl/viewer/DefaultThematicMapViewer.java
76 76

  
77 77
    private final ThematicMapSwingManager swingManager;
78 78

  
79
    private final JSplitPane splitPane;
80

  
79 81
    public DefaultThematicMapViewer(ThematicMap thematicMap)
80 82
        throws InvalidThematicMapFormatException, CantLoadContextException,
81 83
        IOException {
......
147 149

  
148 150
        mapControl.setMinimumSize(new Dimension(300, 300));
149 151

  
150
        JSplitPane splitPane =
151
            new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false);
152
        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false);
152 153
        splitPane.setLeftComponent(toc.getSwingComponent());
153 154
        splitPane.setResizeWeight(0);
154 155
        splitPane.setRightComponent(mapControl);
......
218 219
        disposableManager.release(this);
219 220
        mapControl = null;
220 221
    }
222

  
223
    public boolean isTocVisible() {
224
        return splitPane.getDividerLocation() != 0;
225
    }
226

  
227
    public void setTocVisible(boolean visible) {
228
        if (isTocVisible() == visible) {
229
            return;
230
        }
231
        if (visible) {
232
            splitPane.resetToPreferredSizes();
233
        } else {
234
            splitPane.setDividerLocation(0);
235
        }
236

  
237
    }
221 238
}

Also available in: Unified diff