use of pcgen.gui2.tabs.ability.AbilityTreeTableModel in project pcgen by PCGen.
the class AbilityTreeTableModel method initializeTreeTable.
/**
* Initialise a tree table that will be backed by an AbilityTreeTableModel.
* @param treeTable The tree table to be initialized.
*/
public static void initializeTreeTable(JTreeTable treeTable) {
//$NON-NLS-1$ //$NON-NLS-2$
treeTable.getTree().putClientProperty("JTree.lineStyle", "Horizontal");
treeTable.setAutoCreateColumnsFromModel(false);
DefaultTableColumnModel model = new DefaultTableColumnModel();
TableCellRenderer headerRenderer = treeTable.getTableHeader().getDefaultRenderer();
model.addColumn(Utilities.createTableColumn(0, "in_featSelectedAbilities", headerRenderer, //$NON-NLS-1$
true));
model.addColumn(//$NON-NLS-1$
Utilities.createTableColumn(//$NON-NLS-1$
1, //$NON-NLS-1$
"in_featChoices", headerRenderer, true));
treeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
treeTable.setColumnModel(model);
treeTable.setDefaultRenderer(String.class, new TableCellUtilities.AlignRenderer(SwingConstants.LEFT, true));
}
use of pcgen.gui2.tabs.ability.AbilityTreeTableModel in project pcgen by PCGen.
the class AbilityChooserTab method createState.
//
// private final class AbilityTransferHandler extends TransferHandler
// {
//
// private CharacterFacade character;
//
// public AbilityTransferHandler(CharacterFacade character)
// {
// this.character = character;
// }
//
// private final DataFlavor abilityFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType +
// ";class=" +
// AbilityFacade.class.getName(),
// null);
//
// @Override
// public int getSourceActions(JComponent c)
// {
// if (selectedAbility != null)
// {
// if (selectedTreeViewPanel.isAncestorOf(c))
// {
// return MOVE;
// }
// if (selectedAbility.isMult())
// {
// return COPY;
// }
// if (!character.hasAbility(selectedCatagory, selectedAbility))
// {
// return MOVE;
// }
// }
// return NONE;
// }
//
// @Override
// protected Transferable createTransferable(JComponent c)
// {
// final AbilityFacade transferAbility = selectedAbility;
// return new Transferable()
// {
//
// public DataFlavor[] getTransferDataFlavors()
// {
// return new DataFlavor[]
// {
// abilityFlavor
// };
// }
//
// public boolean isDataFlavorSupported(DataFlavor flavor)
// {
// return abilityFlavor == flavor;
// }
//
// public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
// {
// if (!isDataFlavorSupported(flavor))
// {
// throw new UnsupportedFlavorException(flavor);
// }
// return transferAbility;
// }
//
// };
// }
//
// @Override
// public boolean canImport(JComponent comp, DataFlavor[] transferFlavors)
// {
// return transferFlavors[0] == abilityFlavor;
// }
//
// @Override
// public boolean importData(JComponent comp, Transferable t)
// {
// if (selectedTreeViewPanel.isAncestorOf(comp))
// {
// try
// {
// AbilityFacade ability = (AbilityFacade) t.getTransferData(abilityFlavor);
// // TODO: add some extra logic
// character.addAbility(selectedCatagory, ability);
// return true;
// }
// catch (UnsupportedFlavorException ex)
// {
// Logger.getLogger(AbilityChooserTab.class.getName()).log(Level.SEVERE,
// null,
// ex);
// }
// catch (IOException ex)
// {
// Logger.getLogger(AbilityChooserTab.class.getName()).log(Level.SEVERE,
// null,
// ex);
// }
// return false;
// }
// return true;
// }
//
// @Override
// protected void exportDone(JComponent source, Transferable data,
// int action)
// {
// if (action == COPY)
// {
// return;
// }
// }
//
// }
public Hashtable<Object, Object> createState(CharacterFacade character, ListFacade<AbilityCategoryFacade> categories, ListFacade<AbilityCategoryFacade> fullCategoryList, String title) {
Hashtable<Object, Object> state = new Hashtable<>();
CategoryTableModel categoryTableModel = new CategoryTableModel(character, fullCategoryList, categoryBar, categoryTable);
state.put(CategoryTableModel.class, categoryTableModel);
ListSelectionModel listModel = new DefaultListSelectionModel();
listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
state.put(ListSelectionModel.class, listModel);
state.put(AbilityTreeTableModel.class, new AbilityTreeTableModel(character, categories));
state.put(AvailableAbilityTreeViewModel.class, new AvailableAbilityTreeViewModel(character, fullCategoryList, listModel, title));
//state.put(AbilityTransferHandler.class, new AbilityTransferHandler(character));
state.put(InfoHandler.class, new InfoHandler(character, categories));
state.put(TreeRendererHandler.class, new TreeRendererHandler(character));
state.put(AddAction.class, new AddAction(character));
state.put(RemoveAction.class, new RemoveAction(character));
state.put(AbilityFilterHandler.class, new AbilityFilterHandler(character));
state.put(CategoryFilterHandler.class, new CategoryFilterHandler(categoryTableModel));
return state;
}
Aggregations