Desktop tool for browsing account info from EVE-Online
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.

ContentPanel.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2009 Chris Smith
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package uk.co.md87.evetool.ui;
  23. import java.awt.CardLayout;
  24. import java.util.Map;
  25. import javax.swing.BorderFactory;
  26. import javax.swing.JPanel;
  27. import javax.swing.JScrollPane;
  28. import uk.co.md87.evetool.AccountManager;
  29. import uk.co.md87.evetool.ApiFactory;
  30. import uk.co.md87.evetool.ui.data.AccountChar;
  31. /**
  32. *
  33. * TODO: Document ContentPanel
  34. * @author chris
  35. */
  36. public class ContentPanel extends JPanel {
  37. /**
  38. * A version number for this class. It should be changed whenever the class
  39. * structure is changed (or anything else that would prevent serialized
  40. * objects being unserialized with the new class).
  41. */
  42. private static final long serialVersionUID = 10;
  43. public ContentPanel(final MainWindow window, final AccountManager manager,
  44. final ApiFactory factory, final Map<String, Page> pages) {
  45. super(new CardLayout());
  46. for (Map.Entry<String, Page> page : pages.entrySet()) {
  47. final JScrollPane scrollPane = new JScrollPane(page.getValue());
  48. scrollPane.setBorder(BorderFactory.createEmptyBorder());
  49. scrollPane.getVerticalScrollBar().setUnitIncrement(20);
  50. add(scrollPane, page.getKey());
  51. }
  52. }
  53. public void show(final String page) {
  54. ((CardLayout) getLayout()).show(this, page);
  55. }
  56. public static abstract class Page extends JPanel {
  57. protected AccountChar character;
  58. public boolean isReady() {
  59. return false;
  60. }
  61. public void setActiveChar(final AccountChar ac) {
  62. character = ac;
  63. }
  64. public void activated(final ContextPanel context) {
  65. // Do nothing by default
  66. }
  67. }
  68. }