Desktop tool for browsing account info from EVE-Online
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

SkillPage.java 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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.pages;
  23. import java.awt.event.ActionEvent;
  24. import java.awt.event.ActionListener;
  25. import java.util.Collections;
  26. import javax.swing.JSeparator;
  27. import net.miginfocom.swing.MigLayout;
  28. import uk.co.md87.evetool.AccountManager;
  29. import uk.co.md87.evetool.ApiFactory;
  30. import uk.co.md87.evetool.api.wrappers.data.TrainedSkillInfo;
  31. import uk.co.md87.evetool.comparators.skills.TrainingTimeComparator;
  32. import uk.co.md87.evetool.ui.ContentPanel.Page;
  33. import uk.co.md87.evetool.ui.ContextPanel;
  34. import uk.co.md87.evetool.ui.MainWindow;
  35. import uk.co.md87.evetool.ui.components.FilterButton;
  36. import uk.co.md87.evetool.ui.components.HeaderPanel;
  37. import uk.co.md87.evetool.ui.components.ListablePanel;
  38. import uk.co.md87.evetool.ui.data.TrainedSkillInfoSurrogate;
  39. import uk.co.md87.evetool.ui.dialogs.listableconfig.ListableConfigDialog;
  40. import uk.co.md87.evetool.ui.listable.Listable;
  41. import uk.co.md87.evetool.ui.listable.ListableConfig;
  42. import uk.co.md87.evetool.ui.listable.ListableParser;
  43. /**
  44. *
  45. * TODO: Document SkillPage
  46. * @author chris
  47. */
  48. public class SkillPage extends Page implements ActionListener {
  49. /**
  50. * A version number for this class. It should be changed whenever the class
  51. * structure is changed (or anything else that would prevent serialized
  52. * objects being unserialized with the new class).
  53. */
  54. private static final long serialVersionUID = 10;
  55. private final MainWindow window;
  56. private final ApiFactory factory;
  57. private final ListableConfig config;
  58. public SkillPage(final MainWindow window, final AccountManager manager,
  59. final ApiFactory factory) {
  60. this.window = window;
  61. this.factory = factory;
  62. setLayout(new MigLayout("fillx, wrap 1"));
  63. config = new ListableConfig();
  64. config.topLeft = new ListableConfig.BasicConfigElement("name");
  65. config.topRight = new ListableConfig.CompoundConfigElement(
  66. new ListableConfig.BasicConfigElement("trained skillpoints"),
  67. new ListableConfig.LiteralConfigElement("/"),
  68. new ListableConfig.BasicConfigElement("max skillpoints"));
  69. config.bottomLeft = new ListableConfig.BasicConfigElement("group name");
  70. config.bottomRight = new ListableConfig.BasicConfigElement("time to next level");
  71. config.group = new ListableConfig.BasicConfigElement("group name");
  72. }
  73. /** {@inheritDoc} */
  74. @Override
  75. public boolean isReady() {
  76. return character != null && character.getSheet() != null
  77. && character.getSheet().wasSuccessful();
  78. }
  79. /** {@inheritDoc} */
  80. @Override
  81. public void activated(final ContextPanel context) {
  82. final FilterButton button = new FilterButton();
  83. button.addActionListener(this);
  84. context.add(button, "growy, al right");
  85. removeAll();
  86. Collections.sort(character.getSheet().getResult().getSkills(),
  87. new TrainingTimeComparator(true));
  88. final ListableParser parser = new ListableParser(TrainedSkillInfoSurrogate.class);
  89. String lastGroup = null;
  90. boolean first = true;
  91. for (TrainedSkillInfo skill : character.getSheet().getResult().getSkills()) {
  92. final Listable wrapper = new TrainedSkillInfoSurrogate(skill);
  93. if (config.group != null) {
  94. final String thisGroup = config.group.getValue(wrapper, parser);
  95. if (lastGroup == null || !thisGroup.equals(lastGroup)) {
  96. first = true;
  97. lastGroup = thisGroup;
  98. add(new HeaderPanel(lastGroup), "growx, pushx");
  99. }
  100. }
  101. if (first) {
  102. first = false;
  103. } else {
  104. add(new JSeparator(), "growx, pushx");
  105. }
  106. add(new ListablePanel(wrapper, parser, config),
  107. "growx, pushx");
  108. }
  109. }
  110. /** {@inheritDoc} */
  111. @Override
  112. public void actionPerformed(final ActionEvent e) {
  113. new ListableConfigDialog(window, config, new TrainedSkillInfoSurrogate(
  114. character.getSheet().getResult().getSkills().get(0))).setVisible(true);
  115. }
  116. }