| 1 | //  Copyright 2004-2007 Jean-Francois Poilpret | 
| 2 | // | 
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
| 4 | // you may not use this file except in compliance with the License. | 
| 5 | // You may obtain a copy of the License at | 
| 6 | // | 
| 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
| 8 | // | 
| 9 | // Unless required by applicable law or agreed to in writing, software | 
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| 12 | // See the License for the specific language governing permissions and | 
| 13 | // limitations under the License. | 
| 14 |   | 
| 15 | package net.sourceforge.hiveboard.docking; | 
| 16 |   | 
| 17 | import javax.swing.JSplitPane; | 
| 18 |   | 
| 19 | import org.flexdock.docking.DockingPort; | 
| 20 | import org.flexdock.view.View; | 
| 21 | import org.jvnet.substance.SubstanceLookAndFeel; | 
| 22 | import org.jvnet.substance.grip.NullGripPainter; | 
| 23 |   | 
| 24 | import net.sourceforge.hiveboard.view.DrawingAreaHolder; | 
| 25 | import net.sourceforge.hiveevents.Channel; | 
| 26 | import net.sourceforge.hivegui.docking.EmptyableViewport; | 
| 27 | import net.sourceforge.hivegui.docking.EmptyableViewportDockingStrategy; | 
| 28 |   | 
| 29 | public class HiveBoardDockingStrategy extends EmptyableViewportDockingStrategy | 
| 30 | { | 
| 31 |         public HiveBoardDockingStrategy(Channel<DrawingAreaHolder> selectedBoardImageChannel) | 
| 32 |         { | 
| 33 |                 _selectedBoardImageChannel = selectedBoardImageChannel; | 
| 34 |         } | 
| 35 |   | 
| 36 |         @Override protected JSplitPane createSplitPaneImpl(DockingPort base, String region) | 
| 37 |         { | 
| 38 |                 JSplitPane split = super.createSplitPaneImpl(base, region); | 
| 39 |                 split.setContinuousLayout(true); | 
| 40 |                 split.putClientProperty(SubstanceLookAndFeel.GRIP_PAINTER, new NullGripPainter()); | 
| 41 |                 return split; | 
| 42 |         } | 
| 43 |   | 
| 44 |         @Override protected EmptyableViewport createViewportImpl() | 
| 45 |         { | 
| 46 |                 return new HiveBoardViewport(); | 
| 47 |         } | 
| 48 |   | 
| 49 |         @Override protected void viewChanged(View view) | 
| 50 |         { | 
| 51 |                 if (view != null) | 
| 52 |                 { | 
| 53 |                         DrawingAreaHolder area = (DrawingAreaHolder) view.getContentPane(); | 
| 54 |                         if (area != null && area.getDrawingArea() != null) | 
| 55 |                         { | 
| 56 |                                 _selectedBoardImageChannel.push(area); | 
| 57 |                         } | 
| 58 |                         else | 
| 59 |                         { | 
| 60 |                                 _selectedBoardImageChannel.push(null); | 
| 61 |                         } | 
| 62 |                 } | 
| 63 |         } | 
| 64 |   | 
| 65 |         private final Channel<DrawingAreaHolder>        _selectedBoardImageChannel; | 
| 66 | } |