use of delta.games.lotro.gui.items.essences.SingleEssenceEditionController in project lotro-companion by dmorcellet.
the class AllEssencesEditionPanelController method essenceUpdated.
/**
* Invoked when an essence has been updated.
* @param source Source controller.
*/
@Override
public void essenceUpdated(SingleEssenceEditionController source) {
for (SingleItemEssencesEditionController itemEssences : _editors) {
List<SingleEssenceEditionController> essenceCtrls = itemEssences.getEssenceControllers();
int index = essenceCtrls.indexOf(source);
if (index != -1) {
Item item = itemEssences.getItem();
EssencesSet essences = item.getEssences();
if (essences == null) {
essences = new EssencesSet(essenceCtrls.size());
item.setEssences(essences);
}
essences.setEssence(index, source.getEssence());
refreshToon();
break;
}
}
}
use of delta.games.lotro.gui.items.essences.SingleEssenceEditionController in project lotro-companion by dmorcellet.
the class SingleItemEssencesEditionController method dispose.
/**
* Release all managed resources.
*/
public void dispose() {
// Data
_item = null;
// Controllers
_parent = null;
if (_controllers != null) {
for (SingleEssenceEditionController controller : _controllers) {
controller.dispose();
}
_controllers.clear();
_controllers = null;
}
_iconController = null;
// UI
_itemName = null;
}
use of delta.games.lotro.gui.items.essences.SingleEssenceEditionController in project lotro-companion by dmorcellet.
the class SingleItemEssencesEditionController method setItem.
/**
* Set the managed item.
* @param item Item to set.
*/
public void setItem(Item item) {
_item = item;
_controllers.clear();
String label = "-";
if (item != null) {
// Label
label = item.getName();
// Essences
EssencesSet essences = item.getEssences();
int nbEssences = 0;
if (essences != null) {
nbEssences = essences.getSize();
}
int nbEssenceSlots = item.getEssenceSlots();
int size = Math.max(nbEssences, nbEssenceSlots);
for (int i = 0; i < size; i++) {
SingleEssenceEditionController controller = new SingleEssenceEditionController(_parent, 2);
Item essence = null;
if (essences != null) {
essence = essences.getEssence(i);
}
controller.setEssence(essence);
_controllers.add(controller);
}
}
_iconController.setItem(item);
_icon.setIcon(_iconController.getIcon());
_icon.setToolTipText(_iconController.getTooltip());
_itemName.setText(label, 2);
}
use of delta.games.lotro.gui.items.essences.SingleEssenceEditionController in project lotro-companion by dmorcellet.
the class AllEssencesEditionPanelController method update.
/**
* Update UI.
*/
public void update() {
clearEditors();
initEditors();
_panel.removeAll();
int nbEssencesColumns = getEssencesCount();
// Headers
int nbColumns = nbEssencesColumns + 2;
int columnIndex = 0;
for (int i = 0; i < nbColumns; i++) {
int columnSpan = (i > 1) ? 3 : 1;
GridBagConstraints c = new GridBagConstraints(columnIndex, 0, columnSpan, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
String text = "";
if (i == 1)
text = "Name";
else if (i > 1)
text = "Slot #" + (i - 1);
JLabel label = GuiFactory.buildLabel(text);
_panel.add(label, c);
columnIndex += columnSpan;
}
// Item lines
int rowIndex = 1;
for (SingleItemEssencesEditionController controller : _editors) {
columnIndex = 0;
// Icon
JLabel icon = controller.getItemIcon();
GridBagConstraints c = new GridBagConstraints(columnIndex, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0);
_panel.add(icon, c);
columnIndex++;
// Label
JPanel label = controller.getItemLabel();
c = new GridBagConstraints(columnIndex, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 10), 0, 0);
_panel.add(label, c);
columnIndex++;
// Essences
List<SingleEssenceEditionController> essenceEditors = controller.getEssenceControllers();
int nbEssences = essenceEditors.size();
for (int i = 0; i < nbEssencesColumns; i++) {
if (i < nbEssences) {
SingleEssenceEditionController essenceEditor = essenceEditors.get(i);
essenceEditor.setListener(this);
JButton essenceButton = essenceEditor.getEssenceButton();
c = new GridBagConstraints(columnIndex, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
_panel.add(essenceButton, c);
JPanel essenceLabel = essenceEditor.getEssenceNameLabel();
c = new GridBagConstraints(columnIndex + 1, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
_panel.add(essenceLabel, c);
JButton deleteButton = essenceEditor.getDeleteButton();
c = new GridBagConstraints(columnIndex + 2, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
_panel.add(deleteButton, c);
}
columnIndex += 3;
}
rowIndex++;
}
}
Aggregations