use of delta.games.lotro.lore.crafting.Vocation in project lotro-companion by dmorcellet.
the class CraftingWindowController method buildVocationCombo.
private ComboBoxController<Vocation> buildVocationCombo() {
ComboBoxController<Vocation> ret = new ComboBoxController<Vocation>();
ret.addEmptyItem("");
List<Vocation> vocations = Vocations.getInstance().getAll();
for (Vocation vocation : vocations) {
ret.addItem(vocation, vocation.getName());
}
return ret;
}
use of delta.games.lotro.lore.crafting.Vocation in project lotro-companion by dmorcellet.
the class CraftingWindowController method buildFormPanel.
@Override
protected JPanel buildFormPanel() {
JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
// Vocation panel
JPanel vocationPanel = GuiFactory.buildPanel(new FlowLayout());
{
_vocation = buildVocationCombo();
JLabel vocationLabel = GuiFactory.buildLabel("Vocation:");
vocationPanel.add(vocationLabel);
vocationPanel.add(_vocation.getComboBox());
}
// Guild panel
JPanel guildPanel = GuiFactory.buildPanel(new FlowLayout());
{
_guild = new ComboBoxController<Profession>();
JLabel guildLabel = GuiFactory.buildLabel("Guild:");
guildPanel.add(guildLabel);
guildPanel.add(_guild.getComboBox());
}
// Vocation panel
JPanel vocationEditionPanel = _vocationController.getPanel();
// Assembly
JPanel topPanel = GuiFactory.buildPanel(new FlowLayout());
topPanel.add(vocationPanel);
topPanel.add(guildPanel);
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 10, 0, 10), 0, 0);
panel.add(topPanel, c);
GridBagConstraints c2 = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0);
panel.add(vocationEditionPanel, c2);
// Update vocation edition panel
_vocationController.updateUiFromData();
Vocation vocation = _stats.getVocation();
// Init combos
Profession currentGuild = _stats.getGuildStatus().getProfession();
_vocation.selectItem(vocation);
_guild.addEmptyItem("");
updateGuildCombo(vocation);
_guild.selectItem(currentGuild);
// Init vocation combo
ItemSelectionListener<Vocation> vocationListener = new ItemSelectionListener<Vocation>() {
@Override
public void itemSelected(Vocation selectedVocation) {
handleVocationUpdate(selectedVocation);
}
};
_vocation.addListener(vocationListener);
// Init guild combo
ItemSelectionListener<Profession> guildListener = new ItemSelectionListener<Profession>() {
@Override
public void itemSelected(Profession selectedGuild) {
handleGuildUpdate(selectedGuild);
}
};
_guild.addListener(guildListener);
return panel;
}
use of delta.games.lotro.lore.crafting.Vocation in project lotro-companion by dmorcellet.
the class VocationEditionPanelController method updateProfessionsUi.
/**
* Update the UI for professions.
*/
private void updateProfessionsUi() {
Vocation vocation = _status.getVocation();
_vocationPanel.removeAll();
JComponent centerComponent = null;
List<Profession> professions = (vocation != null) ? vocation.getProfessions() : null;
if ((professions != null) && (professions.size() > 0)) {
_tabbedPane = GuiFactory.buildTabbedPane();
// Professions
for (Profession profession : professions) {
ProfessionStatus stats = _status.getProfessionStatus(profession, true);
ProfessionStatusPanelController craftingPanelController = _panels.get(profession);
if (craftingPanelController == null) {
craftingPanelController = new ProfessionStatusPanelController(stats);
_panels.put(profession, craftingPanelController);
}
JPanel craftingPanel = craftingPanelController.getPanel();
_tabbedPane.add(profession.getLabel(), craftingPanel);
}
// Clean other professions
for (Profession profession : Profession.getAll()) {
if (!professions.contains(profession)) {
_panels.remove(profession);
}
}
centerComponent = _tabbedPane;
} else {
JLabel centerLabel = new JLabel("No vocation!");
centerComponent = centerLabel;
_tabbedPane = null;
}
_vocationPanel.add(centerComponent, BorderLayout.CENTER);
_vocationPanel.revalidate();
_vocationPanel.repaint();
}
use of delta.games.lotro.lore.crafting.Vocation in project lotro-companion by dmorcellet.
the class CraftingWindowController method updateVocation.
private boolean updateVocation(Vocation selectedVocation) {
boolean changed = false;
Vocation currentVocation = _stats.getVocation();
if (currentVocation != selectedVocation) {
long now = System.currentTimeMillis();
_stats.changeVocation(selectedVocation, now);
changed = true;
}
return changed;
}
Aggregations