You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SplitPane.java 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. package com.dmdirc.addons.ui_swing.components;
  18. import com.dmdirc.addons.ui_swing.UIUtilities;
  19. import com.dmdirc.config.binding.ConfigBinding;
  20. import com.dmdirc.config.provider.AggregateConfigProvider;
  21. import java.awt.Component;
  22. import javax.swing.JSplitPane;
  23. /**
  24. * JSplit pane that snaps around its components preferred size.
  25. */
  26. public class SplitPane extends JSplitPane {
  27. /** A version number for this class. */
  28. private static final long serialVersionUID = 2;
  29. /** Orientation type . */
  30. public enum Orientation {
  31. /** Horizontal orientation. */
  32. HORIZONTAL,
  33. /** Vertical orientation. */
  34. VERTICAL
  35. }
  36. /**
  37. * Instantiates a new snapping split pane. Defaults to using a horizontal split, two null
  38. * components and snapping to the left component.
  39. *
  40. * @param manager Config manager to read values from
  41. * @param orientation Split pane orientation
  42. */
  43. public SplitPane(final AggregateConfigProvider manager, final Orientation orientation) {
  44. this(manager, orientation, null, null);
  45. }
  46. /**
  47. * Instantiates a new snapping split pane. Defaults to using two null components.
  48. *
  49. * @param manager Config manager to read values from
  50. * @param orientation Split pane orientation <code>JSplitPane.HORIZONTAL_SPLIT</code> or
  51. * <code>JSplitPane.VERTICAL_SPLIT</code>
  52. * @param leftComponent left component
  53. * @param rightComponent right component
  54. */
  55. public SplitPane(final AggregateConfigProvider manager, final Orientation orientation,
  56. final Component leftComponent, final Component rightComponent) {
  57. super(orientation == Orientation.HORIZONTAL ? HORIZONTAL_SPLIT : VERTICAL_SPLIT, true,
  58. leftComponent, rightComponent);
  59. setContinuousLayout(true);
  60. getActionMap().setParent(null);
  61. getActionMap().clear();
  62. manager.getBinder().bind(this, SplitPane.class);
  63. }
  64. @ConfigBinding(domain = "ui", key = "useOneTouchExpandable")
  65. public void oneTouchChanged(final boolean value) {
  66. UIUtilities.invokeLater(() -> setOneTouchExpandable(value));
  67. }
  68. }