public Hashtable<Object, Object> createModels(final CharacterFacade character) { Hashtable<Object, Object> state = new Hashtable<Object, Object>(); state.put(TreeViewModelHandler.class, new TreeViewModelHandler(character)); state.put(AddSpellAction.class, new AddSpellAction(character)); state.put(RemoveSpellAction.class, new RemoveSpellAction(character)); state.put( SpellInfoHandler.class, new SpellInfoHandler(character, availableTable, selectedTable, spellsPane)); state.put( ClassInfoHandler.class, new ClassInfoHandler(character, availableTable, selectedTable, classPane)); final CharacterComboBoxModel<String> defaultSpellBookModel; defaultSpellBookModel = new CharacterComboBoxModel<String>() { @Override public void setSelectedItem(Object anItem) { character.getSpellSupport().setDefaultSpellBook((String) anItem); } }; defaultSpellBookModel.setListFacade(character.getSpellSupport().getSpellbooks()); defaultSpellBookModel.setReference(character.getSpellSupport().getDefaultSpellBookRef()); state.put(Models.DefaultSpellBookModel, defaultSpellBookModel); state.put(QualifiedSpellTreeCellRenderer.class, new QualifiedSpellTreeCellRenderer(character)); return state; }
public void save() { File partyFile = fileRef.getReference(); List<File> characterFiles = new ArrayList<File>(); for (CharacterFacade character : this) { characterFiles.add(character.getFileRef().getReference()); } (new PCGIOHandler()).write(partyFile, characterFiles); }
public TreeViewModelHandler(CharacterFacade character) { availableModel = new SpellTreeViewModel( character.getSpellSupport().getKnownSpellNodes(), false, "SpellBooksAva"); selectedModel = new SpellTreeViewModel( character.getSpellSupport().getBookSpellNodes(), true, "SpellBooksSel"); }
private boolean isCompanionOpen(CompanionFacade companion) { File compFile = companion.getFileRef().getReference(); if (compFile == null) { return true; } for (CharacterFacade character : CharacterManager.getCharacters()) { File charFile = character.getFileRef().getReference(); if (compFile.equals(charFile)) { return true; } } return false; }
public EquippedTableModel(CharacterFacade character) { super(character); ReferenceFacade<EquipmentSetFacade> ref = character.getEquipmentSetRef(); ref.addReferenceListener(this); setEquipmentList(ref.getReference().getEquippedItems()); setEquipmentSet(ref.getReference()); }
@Override public void actionPerformed(ActionEvent e) { CompanionSupportFacade support = character.getCompanionSupport(); if (REMOVE_COMMAND.equals(e.getActionCommand())) { CompanionFacade companion = (CompanionFacade) selectedElement; int ret = JOptionPane.showConfirmDialog( button, LanguageBundle.getFormattedString( "in_companionConfirmRemovalMsg", companion //$NON-NLS-1$ .getNameRef() .getReference()), LanguageBundle.getString("in_companionConfirmRemoval"), // $NON-NLS-1$ JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.YES_OPTION) { support.removeCompanion(companion); } } if (CREATE_COMMAND.equals(e.getActionCommand())) { initDialog(); String type = (String) selectedElement; companionDialog.setCharacter(character); companionDialog.setCompanionType(type); Utility.setDialogRelativeLocation(CompanionInfoTab.this, companionDialog); companionDialog.setVisible(true); CharacterFacade comp = companionDialog.getNewCompanion(); if (comp != null) { selectCompanion(comp); } } cancelCellEditing(); }
@Override public void actionPerformed(ActionEvent e) { if (!"null".equals(e.getActionCommand())) { if ("SELECT".equals(e.getActionCommand()) || (JTreeTable.ACTION_DOUBLECLICK == e.getID())) { newCompanion = CharacterManager.createNewCharacter( character.getUIDelegate(), character.getDataSet()); CompanionStubFacade selected = (CompanionStubFacade) raceTable.getSelectedObject(); newCompanion.setRace(selected.getRaceRef().getReference()); character.getCompanionSupport().addCompanion(newCompanion, companionType); setVisible(false); } else { newCompanion = null; setVisible(false); } } }
public EquipmentModels(CharacterFacade character) { this.character = character; this.unequippedList = new UnequippedList(character); this.fullModel = new EquipmentTableModel(character); fullModel.setEquipmentList(character.getPurchasedEquipment()); fullModel.setEquipmentSet(character.getEquipmentSetRef().getReference()); this.unequippedModel = new EquipmentTableModel(character); unequippedModel.setEquipmentList(unequippedList); unequippedModel.setEquipmentSet(character.getEquipmentSetRef().getReference()); this.equippedModel = new EquippedTableModel(character); selectedModel = fullModel; selectedView = EquipView.UNEQUIPPED; this.viewHandler = new EquipViewHandler(); this.equipAction = new EquipAction(); this.unequipAction = new UnequipAction(); this.filterHandler = new EquipFilterHandler(); }
@Override public void actionPerformed(ActionEvent e) { List<?> data = selectedTable.getSelectedData(); for (Object object : data) { if (object instanceof SpellNode) { SpellNode node = (SpellNode) object; character.getSpellSupport().removeFromSpellBook(node, node.getRootNode().getName()); } } }
@Override public void actionPerformed(ActionEvent e) { List<?> data = availableTable.getSelectedData(); String bookname = getCurrentSpellBookName(character); for (Object object : data) { if (object instanceof SpellNode) { character.getSpellSupport().addToSpellBook((SpellNode) object, bookname); } } }
public NoteHandler(CharacterFacade character) { descFacade = character.getDescriptionFacade(); noteField.setText(note.getValue()); new TextFieldListener(nameField) { @Override protected void textChanged(String text) { descFacade.renameNote(note, text); name = text; } }; new TextFieldListener(noteField) { @Override protected void textChanged(String text) { descFacade.setNote(note, text); } }; removeButton.addActionListener(this); }
public CompanionsModel(CharacterFacade character) { this.support = character.getCompanionSupport(); this.maxMap = support.getMaxCompanionsMap(); this.setRoot(new RootNode()); }
public void setCharacter(CharacterFacade character) { this.character = character; model.setDelegate(character.getCompanionSupport().getAvailableCompanions()); }