InfoDomain.java

Index Score
pcgen.gui.tabs
PCGen

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
EXITSProcedure exits
LOCLines of code
ELOCEffective lines of code
OPERATORSNumber of operators
LINESNumber of lines in the source file
PROGRAM_LENGTHHalstead program length
LOGICAL_LINESNumber of statements
OPERANDSNumber of operands
FUNCTIONSNumber of function declarations
CYCLOMATICCyclomatic complexity
UNIQUE_OPERANDSNumber of unique operands
SIZESize of the file in bytes
RETURNSNumber of return points from functions
BLOCKSNumber of blocks
INTERFACE_COMPLEXITYInterface complexity
PROGRAM_VOCABHalstead program vocabulary
EXEC_COMMENTSComments in executable code
JAVA0145JAVA0145 Tab character used in source file
PARAMSNumber of formal parameter declarations
LINE_COMMENTNumber of line comments
WHITESPACENumber of whitespace lines
COMPARISONSNumber of comparison operators
DECL_COMMENTSComments in declarations
JAVA0233JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
COMMENTSComment lines
JAVA0077JAVA0077 Private field not used in declaring class
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
JAVA0034JAVA0034 Missing braces in if statement
JAVA0043JAVA0043 Inner class does not use outer class
DOC_COMMENTNumber of javadoc comment lines
JAVA0076JAVA0076 Use of magic number
LOOPSNumber of loops
JAVA0136JAVA0136 N methods defined in class (maximum: M)
UNIQUE_OPERATORSNumber of unique operators
JAVA0096JAVA0096 Field in nested class hides outer field
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
JAVA0174JAVA0174 Assigned local variable never used
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0173JAVA0173 Unused method parameter
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0130JAVA0130 Non-static method does not use instance fields
/* * InfoDomain.java * Copyright 2001 (C) Mario Bonassin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Created on April 21, 2001, 2:15 PM * Modified June 5, 2001 by Bryan McRoberts (merton_monk@yahoo.com) * Modified Nov 14, 2002 by David Hibbs * * Current Ver: $Revision: 7352 $ * Last Editor: $Author: thpr $ * Last Edited: $Date: 2008-08-04 23:02:33 -0400 (Mon, 04 Aug 2008) $ * */ package pcgen.gui.tabs; import static pcgen.gui.HTMLUtils.BOLD; import static pcgen.gui.HTMLUtils.BR; import static pcgen.gui.HTMLUtils.END_BOLD; import static pcgen.gui.HTMLUtils.END_FONT; import static pcgen.gui.HTMLUtils.END_HTML; import static pcgen.gui.HTMLUtils.FONT_PLUS_1; import static pcgen.gui.HTMLUtils.HTML; import static pcgen.gui.HTMLUtils.THREE_SPACES; import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TreeSet; import javax.swing.BorderFactory; import javax.swing.DefaultListSelectionModel; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextField; import javax.swing.JTree; import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.ScrollPaneConstants; import javax.swing.SwingUtilities; import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; import javax.swing.tree.TreePath; import pcgen.base.lang.StringUtil; import pcgen.cdom.base.AssociatedPrereqObject; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.Constants; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.enumeration.ObjectKey; import pcgen.cdom.enumeration.StringKey; import pcgen.cdom.inst.PCClassLevel; import pcgen.cdom.reference.CDOMSingleRef; import pcgen.cdom.reference.ReferenceUtilities; import pcgen.core.CharacterDomain; import pcgen.core.Deity; import pcgen.core.Domain; import pcgen.core.GameMode; import pcgen.core.Globals; import pcgen.core.PCAlignment; import pcgen.core.PCClass; import pcgen.core.PlayerCharacter; import pcgen.core.QualifiedObject; import pcgen.core.SettingsHandler; import pcgen.core.WeaponProf; import pcgen.core.prereq.PrereqHandler; import pcgen.core.prereq.Prerequisite; import pcgen.core.prereq.PrerequisiteUtilities; import pcgen.core.utils.MessageType; import pcgen.core.utils.ShowMessageDelegate; import pcgen.gui.CharacterInfo; import pcgen.gui.CharacterInfoTab; import pcgen.gui.GuiConstants; import pcgen.gui.LstEditorMain; import pcgen.gui.PCGen_Frame1; import pcgen.gui.TableColumnManager; import pcgen.gui.TableColumnManagerModel; import pcgen.gui.editor.EditorConstants; import pcgen.gui.filter.FilterAdapterPanel; import pcgen.gui.filter.FilterConstants; import pcgen.gui.filter.FilterFactory; import pcgen.gui.panes.FlippingSplitPane; import pcgen.gui.utils.AbstractTreeTableModel; import pcgen.gui.utils.InfoViewModelBuilder; import pcgen.gui.utils.JComboBoxEx; import pcgen.gui.utils.JLabelPane; import pcgen.gui.utils.JTableEx; import pcgen.gui.utils.JTreeTable; import pcgen.gui.utils.JTreeTableSorter; import pcgen.gui.utils.LabelTreeCellRenderer; import pcgen.gui.utils.PObjectNode; import pcgen.gui.utils.ResizeColumnListener; import pcgen.gui.utils.TableSorter; import pcgen.gui.utils.TreeTableModel; import pcgen.gui.utils.Utility; import pcgen.util.Logging; import pcgen.util.PropertyFactory; import pcgen.util.enumeration.Tab; /** * This class is responsible for drawing the domain related window - including * indicating what deity and domains are available, which ones are selected, * and handling the selection/de-selection of both. * * @author Mario Bonassin * @version $Revision: 7352 $ * modified by Bryan McRoberts (merton_monk@yahoo.com) to connect to * pcgen.core package * modified by David Hibbs to use Deity and Domain objects instead of Strings * and to clean up the code */ public class InfoDomain extends FilterAdapterPanel implements CharacterInfoTab { static final long serialVersionUID = -4223585346813683966L; private static final Tab tab = Tab.DOMAINS; private static List<Domain> selectedDomainList = new ArrayList<Domain>(); private static boolean needsUpdate = true; private static int splitOrientation = JSplitPane.HORIZONTAL_SPLIT; // if you change these, you also have to change // the case statement in the DeityModel declaration private static final int COL_NAME = 0; private static final int COL_ALIGNMENT = 1; private static final int COL_DOMAINS = 2; private static final int COL_SOURCE = 3; // Note these arrays must be set after we have loaded the values of the // properties above. private DeityModel deityModel = null; private DomainModel domainModel = new DomainModel(); private FlippingSplitPane aSplit; private FlippingSplitPane bSplit; private FlippingSplitPane splitPane; private JButton deitySelect; private JButton domainSelect; private JLabel deityName; private JComboBoxEx viewComboBox = new JComboBoxEx(); private JTextField textDeityQFilter = new JTextField(); private JButton clearDeityQFilterButton = new JButton(PropertyFactory.getString("in_clear")); private static Integer saveDeityViewMode = null; private JTextField textDomainQFilter = new JTextField(); private JButton clearDomainQFilterButton = new JButton(PropertyFactory.getString("in_clear")); // author: Thomas Behr 08-02-02 private JLabel domChosen = new JLabel(); private JLabel domSelected; private JLabel domTotal = new JLabel(); private JLabel ofLabel; private JLabelPane deityInfo = new JLabelPane(); private JPanel center = new JPanel(); private JTreeTable deityTable = null; private JTableEx domainTable = null; // sage_sam updated 11/13/2002 to match a change elsewhere in the code private JLabelPane domainInfo = new JLabelPane(); private JTreeTableSorter deitySorter = null; private TableSorter domainSorter = null; private boolean hasBeenSized = false; private int numDomains = 0; private int viewMode = 0; private TreePath selPath; private PlayerCharacter pc; private int serial = 0; private boolean readyForRefresh = false; /** * Default constructor for this tab. * @param pc */ public InfoDomain(PlayerCharacter pc) { this.pc = pc; // we will use the component's name to save // component specific settings setName(tab.toString()); SwingUtilities.invokeLater(new Runnable() { public void run() { initComponents(); initActionListeners(); } }); FilterFactory.restoreFilterSettings(this); } public void setPc(PlayerCharacter pc) { if (this.pc != pc || pc.getSerial() > serial) { this.pc = pc; serial = pc.getSerial(); forceRefresh(); } } public PlayerCharacter getPc() { return pc; } public int getTabOrder() { return SettingsHandler.getPCGenOption(".Panel.Domain.Order", tab .ordinal()); } public void setTabOrder(int order) { SettingsHandler.setPCGenOption(".Panel.Domain.Order", order); } public String getTabName() { GameMode game = SettingsHandler.getGame(); return game.getTabName(tab); } public boolean isShown() { GameMode game = SettingsHandler.getGame(); return game.getTabShown(tab); } /** * Retrieve the list of tasks to be done on the tab. * @return List of task descriptions as Strings. */ public List<String> getToDos() { List<String> toDoList = new ArrayList<String>(); if (pc.getCharacterDomainUsed() < pc.getMaxCharacterDomains()) { toDoList.add(PropertyFactory.getString("in_domTodoDomainsLeft")); //$NON-NLS-1$ } else if (pc.getCharacterDomainUsed() > pc.getMaxCharacterDomains()) { toDoList.add(PropertyFactory.getString("in_domTodoTooManyDomains")); //$NON-NLS-1$ } return toDoList; } public void refresh() { if (pc.getSerial() > serial) { serial = pc.getSerial(); forceRefresh(); } } public void forceRefresh() { if (readyForRefresh) { needsUpdate = true; updateCharacterInfo(); } else { serial = 0; } } public JComponent getView() { return this; } /** * specifies whether the "match any" option should be available * @return true */ @Override public final boolean isMatchAnyEnabled() { return true; } /** * specifies whether the "negate/reverse" option should be available * @return true */ @Override public final boolean isNegateEnabled() { return true; } /** * specifies the filter selection mode * @return FilterConstants.MULTI_MULTI_MODE = 2 */ @Override public final int getSelectionMode() { return FilterConstants.MULTI_MULTI_MODE; } /* * ########################################################## * filter stuff * ########################################################## */ /** * implementation of Filterable interface */ public final void initializeFilters() { FilterFactory.registerAllSourceFilters(this); FilterFactory.registerAllDeityFilters(this); } /** * implementation of Filterable interface */ public final void refreshFiltering() { forceRefresh(); } /** * This method displays the descriptive information about the * selected deity. * @param aDeity */ private void setDeityInfoText(Deity aDeity) { if (aDeity != null) { StringBuffer infoText = new StringBuffer().append(HTML).append(FONT_PLUS_1).append(BOLD).append( aDeity.piSubString()).append(END_BOLD).append(END_FONT); String aString = aDeity.get(StringKey.TITLE); if (aString != null) { infoText.append(THREE_SPACES).append("(").append(aString).append(")"); } infoText.append(BR); infoText.append(PropertyFactory.getFormattedString( "in_InfoDescription", //$NON-NLS-1$ aDeity.piDescString(pc))); List<CDOMReference<WeaponProf>> dwp = aDeity.getListFor( ListKey.DEITYWEAPON); if (dwp != null) { infoText.append(THREE_SPACES); infoText.append(PropertyFactory.getFormattedString( "in_deityFavWeap", //$NON-NLS-1$ ReferenceUtilities.joinLstFormat(dwp, "|"))); } aString = aDeity.get(StringKey.HOLY_ITEM); if (aString != null) { infoText.append(THREE_SPACES); infoText.append(PropertyFactory.getFormattedString( "in_deityHolyIt", //$NON-NLS-1$ aString)); } aString = aDeity.get(StringKey.WORSHIPPERS); if (aString != null) { infoText.append(THREE_SPACES); infoText.append(PropertyFactory.getFormattedString( "in_deityWorshippers", //$NON-NLS-1$ aString)); } aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aDeity.getPrerequisiteList(), false); if (aString.length() != 0) { infoText.append(PropertyFactory.getFormattedString( "in_InfoRequirements", //$NON-NLS-1$ aString)); } aString = aDeity.getDefaultSourceString(); if (aString.length() > 0) { infoText.append(PropertyFactory.getFormattedString( "in_InfoSource", //$NON-NLS-1$ aString)); } infoText.append(END_HTML); deityInfo.setText(infoText.toString()); } else { deityInfo.setText(HTML + END_HTML); } } /** * This method displays the descriptive information about the * selected domain. * @param aDomain */ private void setDomainInfoText(Domain aDomain, List<Prerequisite> prereqs) { StringBuffer infoText = new StringBuffer().append(HTML); if (aDomain != null) { infoText.append(FONT_PLUS_1).append(BOLD).append( aDomain.piSubString()).append(END_BOLD).append(END_FONT); String aString = aDomain.getDescription(getPc()); if (aString.length() != 0) { infoText.append(BR); infoText.append(PropertyFactory.getFormattedString( "in_domainGrant", //$NON-NLS-1$ aString)); } aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aDomain.getPrerequisiteList(), false); if (aString.length() != 0) { infoText.append(PropertyFactory.getFormattedString( "in_InfoRequirements", //$NON-NLS-1$ aString)); } aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, prereqs, false); if (aString.length() != 0) { infoText.append(BR); infoText.append(PropertyFactory.getFormattedString( "in_domainRequirements", //$NON-NLS-1$ aString)); } aString = aDomain.getDefaultSourceString(); if (aString.length() > 0) { infoText.append(PropertyFactory.getFormattedString( "in_InfoSource", //$NON-NLS-1$ aString)); } } infoText.append(END_HTML); domainInfo.setText(infoText.toString()); } /** * This method returns all available domains, without filtering. * * @param pcDeity * Deity selected for the current character * * @return availDomainList */ private final List<QualifiedObject<Domain>> getUnfilteredDomains(final Deity pcDeity) { List<QualifiedObject<Domain>> availDomainList = new ArrayList<QualifiedObject<Domain>>(); if (pcDeity != null) { for (CDOMReference<Domain> domains : pcDeity.getSafeListMods(Deity.DOMAINLIST)) { Collection<AssociatedPrereqObject> assoc = pcDeity.getListAssociations(Deity.DOMAINLIST, domains); for (AssociatedPrereqObject apo : assoc) { for (Domain d : domains.getContainedObjects()) { d = d.clone(); if (!isDomainInList(availDomainList, d)) { availDomainList.add(new QualifiedObject<Domain>(d, apo.getPrerequisiteList())); } } } } } // Loop through the available prestige domains for (PCClass aClass : pc.getClassList()) { /* * Need to do for the class, for compatibility, since level 0 is * loaded into the class itself */ processDomainList(aClass, availDomainList); processAddDomains(aClass, availDomainList); for (int lvl = 0; lvl <= aClass.getLevel(); lvl++) { PCClassLevel cl = aClass.getClassLevel(lvl); processAddDomains(cl, availDomainList); processDomainList(cl, availDomainList); } } return availDomainList; } private void processAddDomains(CDOMObject cdo, final List<QualifiedObject<Domain>> availDomainList) { Collection<CDOMReference<Domain>> domains = cdo.getListMods(PCClass.ALLOWED_DOMAINS); if (domains != null) { for (CDOMReference<Domain> ref : domains) { Collection<AssociatedPrereqObject> assoc = cdo .getListAssociations(PCClass.ALLOWED_DOMAINS, ref); for (AssociatedPrereqObject apo : assoc) { for (Domain d : ref.getContainedObjects()) { /* * TODO This gate produces a rather interesting, and * potentially wrong situation. What if two ADDDOMAINS * exist with different PRE? Doesn't this fail? */ if (!isDomainInList(availDomainList, d)) { availDomainList.add(new QualifiedObject<Domain>(d .clone(), apo.getPrerequisiteList())); } } } } } } private void processDomainList(CDOMObject obj, final List<QualifiedObject<Domain>> availDomainList) { for (QualifiedObject<CDOMSingleRef<Domain>> qo : obj.getSafeListFor(ListKey.DOMAIN)) { CDOMSingleRef<Domain> ref = qo.getObject(null); Domain domain = ref.resolvesTo(); if (!isDomainInList(availDomainList, domain)) { availDomainList.add(new QualifiedObject<Domain>(domain .clone(), qo.getPrerequisiteList())); } } } /** * Check if a domain is a list of domains, irrespective of prerequisites. * * @param qualDomainList The list of domains with their prerequisites. * @param qualDomain The domain to search for. * @return tue if the domain is in the list */ private boolean isDomainInList( List<QualifiedObject<Domain>> qualDomainList, Domain domain) { for (QualifiedObject<Domain> row : qualDomainList) { if (domain.equals(row.getObject(null))) { return true; } } return false; } /** * executed when the component is shown */ private void formComponentShown() { int width; requestFocus(); PCGen_Frame1.setMessageAreaTextWithoutSaving(PropertyFactory .getString("in_statusBarDeity")); refresh(); int splitPaneDividerLocation = splitPane.getDividerLocation(); int bSplitDividerLocation = bSplit.getDividerLocation(); int aSplitDividerLocation = aSplit.getDividerLocation(); if (!hasBeenSized) { hasBeenSized = true; final double thisWidth = this.getSize().getWidth(); splitPaneDividerLocation = SettingsHandler.getPCGenOption("InfoDomain.splitPane", (int) ((thisWidth * 4) / 10)); bSplitDividerLocation = SettingsHandler.getPCGenOption("InfoDomain.bSplit", (int) ((this.getSize().getHeight() * 75) / 100)); aSplitDividerLocation = SettingsHandler.getPCGenOption("InfoDomain.aSplit", (int) ((thisWidth * 5) / 10)); // set the prefered width on deityTable for (int i = 0; i < deityTable.getColumnCount(); i++) { TableColumn sCol = deityTable.getColumnModel().getColumn(i); width = Globals.getCustColumnWidth(PropertyFactory .getString("in_deity"), i); if (width != 0) { sCol.setPreferredWidth(width); } sCol.addPropertyChangeListener(new ResizeColumnListener( deityTable, PropertyFactory.getString("in_deity"), i)); } // set the prefered width on domainTable for (int i = 0; i < domainTable.getColumnCount(); i++) { TableColumn sCol = domainTable.getColumnModel().getColumn(i); width = Globals.getCustColumnWidth(PropertyFactory .getString("in_domains"), i); if (width != 0) { sCol.setPreferredWidth(width); } sCol.addPropertyChangeListener(new ResizeColumnListener( domainTable, PropertyFactory.getString("in_domains"), i)); } } if (splitPaneDividerLocation > 0) { splitPane.setDividerLocation(splitPaneDividerLocation); SettingsHandler.setPCGenOption("InfoDomain.splitPane", splitPaneDividerLocation); } if (bSplitDividerLocation > 0) { bSplit.setDividerLocation(bSplitDividerLocation); SettingsHandler.setPCGenOption("InfoDomain.bSplit", bSplitDividerLocation); } if (aSplitDividerLocation > 0) { aSplit.setDividerLocation(aSplitDividerLocation); SettingsHandler.setPCGenOption("InfoDomain.aSplit", aSplitDividerLocation); } } private void hookupPopupMenu(JTreeTable treeTable) { treeTable.addMouseListener(new DeityPopupListener(treeTable, new DeityPopupMenu())); } private void hookupPopupMenu(JTableEx treeTable) { treeTable.addMouseListener(new DomainPopupListener(treeTable, new DomainPopupMenu(treeTable))); } private final void createTreeTables() { deityTable = new JTreeTable(deityModel); deityTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JTree atree = deityTable.getTree(); atree.setRootVisible(false); atree.setShowsRootHandles(true); atree.setCellRenderer(new LabelTreeCellRenderer()); deityTable.getSelectionModel().addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final int idx = getSelectedIndex(e); if (idx < 0) { return; } final Object temp = atree.getPathForRow(idx).getLastPathComponent(); if (temp == null) { return; } PObjectNode fNode = (PObjectNode) temp; if (fNode.getItem() instanceof Deity) { Deity aDeity = (Deity) fNode.getItem(); setDeityInfoText(aDeity); } } } }); MouseListener aml = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { final int avaRow = atree.getRowForLocation(e.getX(), e.getY()); final TreePath avaPath = atree.getPathForLocation(e.getX(), e.getY()); if (avaRow != -1) { if ((e.getClickCount() == 1) && (avaPath != null)) { atree.setSelectionPath(avaPath); } else if (e.getClickCount() == 2) { selButton(); } } } }; atree.addMouseListener(aml); // create the rightclick popup menus hookupPopupMenu(deityTable); } private static int getSelectedIndex(ListSelectionEvent e) { final DefaultListSelectionModel model = (DefaultListSelectionModel) e.getSource(); if (model == null) { return -1; } return model.getMinSelectionIndex(); } /** * This method builds the GUI components. */ private void initComponents() { readyForRefresh = true; final int iView = SettingsHandler.getDomainTab_ListMode(); if ((iView >= GuiConstants.INFODOMAIN_VIEW_NAME) && (iView <= GuiConstants.INFODOMAIN_VIEW_SOURCE)) { viewMode = iView; } SettingsHandler.setDomainTab_ListMode(viewMode); viewComboBox.addItem(PropertyFactory.getString("in_nameLabel") + " "); viewComboBox.addItem(PropertyFactory.getString("in_alignmentName") + " "); viewComboBox .addItem(PropertyFactory.getString("in_domainName") + " "); viewComboBox.addItem(PropertyFactory.getString("in_pantheonName") + " "); viewComboBox.addItem(PropertyFactory.getString("in_sourceName") + " "); viewComboBox.setSelectedIndex(viewMode); // initialize the deityModel deityModel = new DeityModel(viewMode); // create the tree's from the deityModel createTreeTables(); // Set the tab description Utility .setDescription(this, PropertyFactory.getString("in_tabToolTip")); // Deity table tooltip Utility.setDescription(deityTable, PropertyFactory .getString("in_deityTableTip")); // Domain table Setup domainSorter = new TableSorter(domainModel); domainTable = new JTableEx(domainSorter); domainSorter.addMouseListenerToHeaderInTable(domainTable); domainTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Domain table tooltip Utility.setDescription(domainTable, PropertyFactory .getString("in_domainTableTip")); // Domain table mouse listener final DomainMouseAdapter domainMouse = new DomainMouseAdapter(); domainTable.addMouseListener(domainMouse); center.setLayout(new BorderLayout()); buildTopPane(); JPanel bLeftPane = new JPanel(new BorderLayout()); JPanel bRightPane = new JPanel(new BorderLayout()); TitledBorder title1 = BorderFactory.createTitledBorder(PropertyFactory .getString("in_deityInfo")); title1.setTitleJustification(TitledBorder.CENTER); //deityInfo.setBackground(rightPane.getBackground()); JScrollPane deityScroll = new JScrollPane(deityInfo); deityScroll.setBorder(title1); bLeftPane.add(deityScroll, BorderLayout.CENTER); deityInfo.setBackground(bLeftPane.getBackground()); Utility.setDescription(bLeftPane, PropertyFactory .getString("in_infoScrollTip")); TitledBorder title2 = BorderFactory.createTitledBorder(PropertyFactory .getString("in_domainInfo")); title2.setTitleJustification(TitledBorder.CENTER); JScrollPane domainScroll = new JScrollPane(domainInfo); domainScroll.setBorder(title2); bRightPane.add(domainScroll, BorderLayout.CENTER); domainInfo.setBackground(bRightPane.getBackground()); Utility.setDescription(bRightPane, PropertyFactory .getString("in_infoScrollTip")); aSplit = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, bLeftPane, bRightPane); aSplit.setOneTouchExpandable(true); aSplit.setDividerSize(10); aSplit.setDividerLocation(300); JPanel botPane = new JPanel(); botPane.setLayout(new BorderLayout()); botPane.add(aSplit, BorderLayout.CENTER); bSplit = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, center, botPane); bSplit.setOneTouchExpandable(true); bSplit.setDividerSize(10); bSplit.setDividerLocation(300); this.setLayout(new BorderLayout()); this.add(bSplit, BorderLayout.CENTER); // Make sure it updates when switching tabs this.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent evt) { refresh(); } }); addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent evt) { formComponentShown(); } }); hookupPopupMenu(deityTable); hookupPopupMenu(domainTable); } private void buildTopPane() { JPanel leftPane = new JPanel(); JPanel rightPane = new JPanel(); leftPane.setLayout(new BorderLayout()); splitPane = new FlippingSplitPane(splitOrientation, leftPane, rightPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerSize(10); splitPane.setDividerLocation(350); center.add(splitPane, BorderLayout.CENTER); leftPane.add(InfoTabUtils.createFilterPane(new JLabel(PropertyFactory .getString("in_irSortDeities")), viewComboBox, new JLabel(PropertyFactory.getString("InfoTabs.FilterLabel")), textDeityQFilter, clearDeityQFilterButton), BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(deityTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); JButton columnButton = new JButton(); scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnButton); columnButton.setText(PropertyFactory.getString("in_caretSymbol")); new TableColumnManager(deityTable, columnButton, deityModel); leftPane.add(scrollPane); JPanel leftBottom = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 1)); leftBottom .add(new JLabel(PropertyFactory.getString("in_deity") + ": ")); deityName = new JLabel(PropertyFactory.getString("in_nameLabel")); leftBottom.add(deityName); deitySelect = new JButton(PropertyFactory.getString("in_select")); Utility.setDescription(deitySelect, PropertyFactory .getString("in_deityButTip")); leftBottom.add(deitySelect); leftPane.add(leftBottom, BorderLayout.SOUTH); rightPane.setLayout(new BorderLayout()); rightPane.add(InfoTabUtils.createFilterPane(null, null, new JLabel( PropertyFactory.getString("InfoTabs.FilterLabel")), textDomainQFilter, clearDomainQFilterButton), BorderLayout.NORTH); JPanel rightBottom = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 1)); domSelected = new JLabel(PropertyFactory.getString("in_domainSelected") + ": "); ofLabel = new JLabel(PropertyFactory.getString("in_ofString")); rightBottom.add(domSelected); rightBottom.add(domChosen); rightBottom.add(ofLabel); rightBottom.add(domTotal); domainSelect = new JButton(PropertyFactory.getString("in_select")); Utility.setDescription(domainSelect, PropertyFactory .getString("in_domainButTip")); domainSelect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { final ListSelectionModel lsm = domainTable.getSelectionModel(); final int selectedRow = domainSorter.getRowTranslated(lsm .getMinSelectionIndex()); selectDomainIndex(selectedRow); } }); rightBottom.add(domainSelect); rightPane.add(rightBottom, BorderLayout.SOUTH); JScrollPane scrollPane2 = new JScrollPane(domainTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); JButton columnButton2 = new JButton(); scrollPane2.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnButton2); columnButton2.setText(PropertyFactory.getString("in_caretSymbol")); new TableColumnManager(domainTable, columnButton2, domainModel); rightPane.add(scrollPane2); } private void initActionListeners() { addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent evt) { formComponentShown(); } }); viewComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { viewComboBoxActionPerformed(); } }); deitySelect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { selButton(); } }); FilterFactory.restoreFilterSettings(this); textDeityQFilter.getDocument().addDocumentListener( new DocumentListener() { public void changedUpdate(DocumentEvent evt) { setDeityQFilter(); } public void insertUpdate(DocumentEvent evt) { setDeityQFilter(); } public void removeUpdate(DocumentEvent evt) { setDeityQFilter(); } }); clearDeityQFilterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { clearDeityQFilter(); } }); textDomainQFilter.getDocument().addDocumentListener( new DocumentListener() { public void changedUpdate(DocumentEvent evt) { setDomainQFilter(); } public void insertUpdate(DocumentEvent evt) { setDomainQFilter(); } public void removeUpdate(DocumentEvent evt) { setDomainQFilter(); } }); clearDomainQFilterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { clearDomainQFilter(); } }); } private void viewComboBoxActionPerformed() { final int index = viewComboBox.getSelectedIndex(); if (index != viewMode) { viewMode = index; SettingsHandler.setDomainTab_ListMode(viewMode); createModel(); deityTable.updateUI(); } } /** * creates the DeityModel that will be used **/ private final void createModel() { if (deityModel == null) { deityModel = new DeityModel(viewMode); } else { deityModel.resetModel(viewMode); } if (deitySorter != null) { deitySorter.setRoot((PObjectNode) deityModel.getRoot()); deitySorter.sortNodeOnColumn(); } } /** * This method is called when a deity is selected from the list of displayed * deities. */ private void selButton() { TreePath aPath = deityTable.getTree().getSelectionPath(); if (aPath == null) { return; } Object endComp = aPath.getLastPathComponent(); PObjectNode fNode = (PObjectNode) endComp; if (!(fNode.getItem() instanceof Deity)) { return; } Deity aDeity = (Deity) fNode.getItem(); // Don't do anything if the same deity was selected if ((pc.getDeity() != null) && (aDeity.equals(pc.getDeity()))) { return; } if (!pc.canSelectDeity(aDeity)) { final ListSelectionModel lsm = deityTable.getSelectionModel(); ShowMessageDelegate.showMessageDialog(PropertyFactory .getFormattedString("in_reqMess", aDeity.getDisplayName()), Constants.s_APPNAME, MessageType.INFORMATION); lsm.clearSelection(); return; } List<QualifiedObject<Domain>> potentialDomains = getUnfilteredDomains(aDeity); // Validate that no domains will be lost when changing deities boolean allDomainsAvailable = true; for (Domain domain : selectedDomainList) { if (!isDomainInList(potentialDomains, domain)) { allDomainsAvailable = false; break; } } if (!allDomainsAvailable) { final int areYouSure = JOptionPane.showConfirmDialog(null, PropertyFactory .getFormattedString("in_confDomLost1", aDeity.getDisplayName()) + System.getProperty("line.separator") + PropertyFactory.getString("in_confDomLost2"), Constants.s_APPNAME, JOptionPane.OK_CANCEL_OPTION); if (areYouSure != JOptionPane.OK_OPTION) { return; } } pc.setDeity(aDeity); deityName.setText(aDeity.piString()); buildDomainLists(); //// deityModel.fireTableDataChanged(); } /** * <code>updateCharacterInfo</code> update data for a changed PC */ private final void updateCharacterInfo() { if ((pc != null) && (numDomains != pc.getCharacterDomainList().size())) { needsUpdate = true; numDomains = pc.getCharacterDomainList().size(); } if (needsUpdate || (pc == null)) { if (pc == null) { return; } // Update the list of deities createModel(); deityTable.updateUI(); // Set the displayed deity name if (pc.getDeity() != null) { deityName.setText(pc.getDeity().piString()); } else { deityName.setText(PropertyFactory.getString("in_tempName")); } // Display the deity description setDeityInfoText(pc.getDeity()); // Build the domain lists buildDomainLists(); needsUpdate = false; } } /** * This method builds the lists of domains * The lists built by this method include the list of available * domains and the list of domains currently selected for the PC */ private void buildDomainLists() { // Init the lists selectedDomainList.clear(); // Get all available domains and filter them List<QualifiedObject<Domain>> availDomainList = getUnfilteredDomains(pc.getDeity()); domainModel.setAvailDomainList(availDomainList); // Loop through the character's selected domains for (CharacterDomain aCD : pc.getCharacterDomainList()) { if ((aCD != null) && (aCD.getDomain() != null)) { // Get the selected domain final Domain aCDDomain = aCD.getDomain(); boolean found = false; for (QualifiedObject<Domain> availDomain : availDomainList) { found = availDomain.getObject(null).getKeyName().equals( aCDDomain.getKeyName()); if (found) { break; } } if (!found) { availDomainList.add(new QualifiedObject<Domain>(aCDDomain)); } if (!selectedDomainList.contains(aCDDomain)) { selectedDomainList.add(aCDDomain); } } } // Filter the available domains for (Iterator<QualifiedObject<Domain>> domainIter = availDomainList.iterator(); domainIter .hasNext();) { QualifiedObject<Domain> qualDomain = domainIter.next(); Domain domain = qualDomain.getObject(pc); if (domain != null && !accept(pc, domain) && !selectedDomainList.contains(domain)) { domainIter.remove(); } } // Update the display of available/selected domain counts domTotal.setText(Integer.toString(pc.getMaxCharacterDomains())); // use star (*) to identify which are chosen in the table domChosen.setText(Integer.toString(pc.getCharacterDomainUsed()) + "*"); domainModel.resetModel(); // Notify the table and sorter that the table data has changed domainSorter.tableChanged(null); domainModel.fireTableDataChanged(); } /** * This method is called when a domain is selected * from the list of displayed domains * * @param selectedRow int row in the domain table model for domain */ private final void selectDomainIndex(int selectedRow) { if (selectedRow < 0 || selectedRow >= domainModel.getRowCount()) { return; } if (pc.getMaxCharacterDomains() <= 0) { ShowMessageDelegate.showMessageDialog( PropertyFactory.getString("in_errorNotAllowedToChooseADomain"), Constants.s_APPNAME, MessageType.INFORMATION); return; } final QualifiedObject<Domain> qualDomain = (QualifiedObject<Domain>) domainModel.getValueAt(selectedRow, -1); final Domain addedDomain = qualDomain.getObject(null); if (addedDomain == null) { return; } // Make sure a valid domain was selected if (!PrereqHandler.passesAll(addedDomain.getPrerequisiteList(), pc, addedDomain) || !qualDomain.qualifies(pc)) { ShowMessageDelegate.showMessageDialog(PropertyFactory .getFormattedString("in_qualifyMess", addedDomain.getDisplayName()), Constants.s_APPNAME, MessageType.INFORMATION); return; } CharacterDomain aCD = pc.getCharacterDomainForDomain(addedDomain.getKeyName()); if (aCD == null) { aCD = pc.getNewCharacterDomain(); } if (aCD == null) { Logging.errorPrintLocalised("in_errorNoMoreAllowedDomains"); return; } // If adding a domain already selected, remove the domain final Domain existingDomain = aCD.getDomain(); if ((existingDomain != null) && existingDomain.equals(addedDomain)) { selectedDomainList.remove(existingDomain); pc.removeCharacterDomain(aCD); } // Check selected domains vs Max number allowed if (pc.getCharacterDomainUsed() >= pc.getMaxCharacterDomains()) { ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("in_errorNoMoreDomains"), Constants.s_APPNAME, MessageType.INFORMATION); return; } // space remains for another domain, so add it if (existingDomain == null) { addedDomain.applyDomain(pc); aCD.setDomain(addedDomain, pc); pc.addCharacterDomain(aCD); if (!selectedDomainList.contains(addedDomain)) { selectedDomainList.add(addedDomain); } pc.calcActiveBonuses(); } // Update the displayed domain count, // using star (*) to indicate selected domains domChosen.setText(Integer.toString(pc.getCharacterDomainUsed()) + "*"); domainSorter.tableChanged(null); domainModel.fireTableDataChanged(); forceUpdates(); } private static void createDeityButtonClick() { //new DeityEditorMain(Globals.getRootFrame(), null).show(); LstEditorMain lem = new LstEditorMain(); lem.setVisible(true); lem.editIt(null, EditorConstants.EDIT_DEITY); } private void forceUpdates() { pc.setDirty(true); needsUpdate = true; CharacterInfo pane = PCGen_Frame1.getCharacterPane(); pane.setPaneForUpdate(pane.infoSpells()); pane.setPaneForUpdate(pane.infoAbilities()); pane.refresh(); } private void deleteDeityButtonClick() { TreePath aPath = deityTable.getTree().getSelectionPath(); if (aPath == null) { return; } Object endComp = aPath.getLastPathComponent(); PObjectNode fNode = (PObjectNode) endComp; if (!(fNode.getItem() instanceof Deity)) { return; } Deity aDeity = (Deity) fNode.getItem(); if (aDeity != null) { if (aDeity.isType(Constants.s_CUSTOM)) { final int areYouSure = JOptionPane.showConfirmDialog(null, PropertyFactory .getFormattedString("in_delDeity2", aDeity.getDisplayName()), Constants.s_APPNAME, JOptionPane.OK_CANCEL_OPTION); if (areYouSure != JOptionPane.OK_OPTION) { return; } Globals.getContext().ref.forget(aDeity); } else { ShowMessageDelegate.showMessageDialog(PropertyFactory .getString("in_domIDEr4"), Constants.s_APPNAME, MessageType.ERROR); } } } private void editDeityButtonClick() { TreePath aPath = deityTable.getTree().getSelectionPath(); if (aPath == null) { return; } Object endComp = aPath.getLastPathComponent(); PObjectNode fNode = (PObjectNode) endComp; if (!(fNode.getItem() instanceof Deity)) { return; } Deity aDeity = (Deity) fNode.getItem(); LstEditorMain lem = new LstEditorMain(); lem.setVisible(true); lem.editIt(aDeity, EditorConstants.EDIT_DEITY); } private void clearDeityQFilter() { deityModel.clearQFilter(); if (saveDeityViewMode != null) { viewMode = saveDeityViewMode.intValue(); saveDeityViewMode = null; } deityModel.resetModel(viewMode); clearDeityQFilterButton.setEnabled(false); deityModel.setQFilter(null); textDeityQFilter.setText(null); viewComboBox.setEnabled(true); forceRefresh(); } private void setDeityQFilter() { String filterStr = textDeityQFilter.getText(); if (filterStr.length() == 0) { clearDeityQFilter(); return; } deityModel.setQFilter(filterStr); if (saveDeityViewMode == null) { saveDeityViewMode = Integer.valueOf(viewMode); } viewMode = GuiConstants.INFODOMAIN_VIEW_NAME; clearDeityQFilterButton.setEnabled(true); viewComboBox.setEnabled(false); forceRefresh(); } private void clearDomainQFilter() { domainModel.clearQFilter(); domainModel.resetModel(); clearDomainQFilterButton.setEnabled(false); domainModel.setQFilter(null); textDomainQFilter.setText(null); forceRefresh(); } private void setDomainQFilter() { String filterStr = textDomainQFilter.getText(); if (filterStr.length() == 0) { clearDomainQFilter(); return; } domainModel.setQFilter(filterStr); domainModel.resetModel(); clearDomainQFilterButton.setEnabled(true); forceRefresh(); } private class DeityPopupListener extends MouseAdapter { private JTree tree; private DeityPopupMenu menu; DeityPopupListener(JTreeTable treeTable, DeityPopupMenu aMenu) { tree = treeTable.getTree(); menu = aMenu; KeyListener myKeyListener = new KeyListener() { public void keyTyped(KeyEvent e) { dispatchEvent(e); } public void keyPressed(KeyEvent e) { final int keyCode = e.getKeyCode(); if (keyCode != KeyEvent.VK_UNDEFINED) { final KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e); for (int i = 0; i < menu.getComponentCount(); i++) { final Component menuComponent = menu.getComponent(i); if (menuComponent instanceof JMenuItem) { KeyStroke ks = ((JMenuItem) menuComponent) .getAccelerator(); if ((ks != null) && keyStroke.equals(ks)) { selPath = tree.getSelectionPath(); ((JMenuItem) menuComponent).doClick(2); return; } } } } dispatchEvent(e); } public void keyReleased(KeyEvent e) { dispatchEvent(e); } }; treeTable.addKeyListener(myKeyListener); } @Override public void mousePressed(MouseEvent evt) { maybeShowPopup(evt); } @Override public void mouseReleased(MouseEvent evt) { maybeShowPopup(evt); } private void maybeShowPopup(MouseEvent evt) { if (evt.isPopupTrigger()) { selPath = tree.getClosestPathForLocation(evt.getX(), evt.getY()); if (selPath == null) { return; } tree.setSelectionPath(selPath); menu.show(evt.getComponent(), evt.getX(), evt.getY()); } } } private class DeityPopupMenu extends JPopupMenu { DeityPopupMenu() { DeityPopupMenu.this.add(createAddMenuItem(PropertyFactory .getString("in_select"), "shortcut EQUALS")); this.addSeparator(); DeityPopupMenu.this.add(createEditMenuItem(PropertyFactory .getString("in_editDeity"), "alt E")); DeityPopupMenu.this.add(createCreateMenuItem(PropertyFactory .getString("in_createDeity"), "alt C")); DeityPopupMenu.this.add(createDeleteMenuItem(PropertyFactory .getString("in_delDeity"), "DELETE")); } private JMenuItem createAddMenuItem(String label, String accelerator) { return Utility.createMenuItem(label, new AddDeityActionListener(), PropertyFactory.getString("in_select"), '\0', accelerator, PropertyFactory.getString("in_irSelDeityTip"), "Add16.gif", true); } private JMenuItem createEditMenuItem(String label, String accelerator) { return Utility.createMenuItem(label, new EditDeityActionListener(), PropertyFactory.getString("in_editDeity"), '\0', accelerator, null, null, true); } private JMenuItem createCreateMenuItem(String label, String accelerator) { return Utility.createMenuItem(label, new CreateDeityActionListener(), PropertyFactory .getString("in_createDeity"), '\0', accelerator, null, null, true); } private JMenuItem createDeleteMenuItem(String label, String accelerator) { return Utility.createMenuItem(label, new DeleteDeityActionListener(), PropertyFactory .getString("in_delDeity"), '\0', accelerator, null, null, true); } private class AddDeityActionListener extends DeityActionListener { @Override public void actionPerformed(ActionEvent evt) { selButton(); } } private class EditDeityActionListener extends DeityActionListener { @Override public void actionPerformed(ActionEvent evt) { editDeityButtonClick(); } } private class CreateDeityActionListener extends DeityActionListener { @Override public void actionPerformed(ActionEvent evt) { createDeityButtonClick(); } } private class DeleteDeityActionListener extends DeityActionListener { @Override public void actionPerformed(ActionEvent evt) { deleteDeityButtonClick(); } } private class DeityActionListener implements ActionListener { public void actionPerformed(ActionEvent evt) { // TODO This method currently does nothing? } } } /** * This class is a listener for the pop-up menus on the domain and * deity tables. */ private final class DomainPopupListener extends MouseAdapter { private DomainPopupMenu menu; private JTableEx aTable; DomainPopupListener(JTableEx treeTable, DomainPopupMenu aMenu) { menu = aMenu; aTable = treeTable; KeyListener myKeyListener = new KeyListener() { public void keyTyped(KeyEvent e) { dispatchEvent(e); } public void keyPressed(KeyEvent e) { final int keyCode = e.getKeyCode(); if (keyCode != KeyEvent.VK_UNDEFINED) { final KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e); for (int i = 0; i < menu.getComponentCount(); i++) { final Component menuComponent = menu.getComponent(i); if (menuComponent instanceof JMenuItem) { KeyStroke ks = ((JMenuItem) menuComponent) .getAccelerator(); if ((ks != null) && keyStroke.equals(ks)) { ((JMenuItem) menuComponent).doClick(2); return; } } } } dispatchEvent(e); } public void keyReleased(KeyEvent e) { dispatchEvent(e); } }; treeTable.addKeyListener(myKeyListener); } @Override public void mousePressed(MouseEvent evt) { maybeShowPopup(evt); } @Override public void mouseReleased(MouseEvent evt) { maybeShowPopup(evt); } private void maybeShowPopup(MouseEvent evt) { if (evt.isPopupTrigger()) { int selRow = aTable.getSelectedRow(); if (selRow == -1) { return; } menu.show(evt.getComponent(), evt.getX(), evt.getY()); } } } /** * This class is used as a pop-up menu for the domain and deity tables. */ private final class DomainPopupMenu extends JPopupMenu { static final long serialVersionUID = -4223585346813683966L; DomainPopupMenu(JTableEx treeTable) { /* * jikes says: * "Ambiguous reference to member 'add' inherited from * type 'javax/swing/JPopupMenu' but also declared or * inherited in the enclosing type 'pcgen/gui/InfoInventory'. * Explicit qualification is required." * Well, let's do what jikes wants us to do ;-) * * author: Thomas Behr 08-02-02 * * changed accelerator from "control PLUS" to "control EQUALS" as cannot * get "control PLUS" to function on standard US keyboard with Windows 98 */ DomainPopupMenu.this.add(createRemoveMenuItem(PropertyFactory .getString("in_select"), "shortcut EQUALS")); } private JMenuItem createRemoveMenuItem(String label, String accelerator) { return Utility.createMenuItem(label, new RemoveClassActionListener(), PropertyFactory .getString("in_select"), (char) 0, accelerator, PropertyFactory.getString("in_selDomain"), "Add16.gif", true); } private class ClassActionListener implements ActionListener { public void actionPerformed(ActionEvent evt) { // TODO This method currently does nothing? } } private class RemoveClassActionListener extends ClassActionListener { @Override public void actionPerformed(ActionEvent evt) { InfoDomain.this.domainSelect.doClick(); } } } /** * This is the Model that populates the table for Deities */ private final class DeityModel extends AbstractTreeTableModel implements TableColumnManagerModel { // this is the root node private PObjectNode deityRoot; // list of column names private final String[] deityNameList = {PropertyFactory.getString("in_nameLabel"), PropertyFactory.getString("in_alignLabel"), PropertyFactory.getString("in_domains"), PropertyFactory.getString("in_sourceLabel")}; private final int[] deityColList = {200, 100, 100, 100}; private List<Boolean> displayList = null; private DeityModel(int mode) { super(null); resetModel(mode); displayList = new ArrayList<Boolean>(); int i = 1; displayList.add(Boolean.TRUE); displayList.add(Boolean.valueOf(getColumnViewOption( deityNameList[i++], true))); displayList.add(Boolean.valueOf(getColumnViewOption( deityNameList[i++], true))); displayList.add(Boolean.valueOf(getColumnViewOption( deityNameList[i++], true))); } /** * return the Class for a column * @param column * @return Class **/ @Override public Class<?> getColumnClass(int column) { if (column == COL_NAME) { return TreeTableModel.class; } return String.class; } /** * the number of columns * @return column count **/ public int getColumnCount() { return deityNameList.length; } /** * the name of each column (for the headers) * @param column * @return column name **/ public String getColumnName(int column) { return deityNameList[column]; } /** * return the root node * @return root **/ @Override public Object getRoot() { return super.getRoot(); } /** * return the value of a column * @param node * @param column * @return value **/ public Object getValueAt(Object node, int column) { final PObjectNode fn = (PObjectNode) node; if (fn == null) { Logging .errorPrintLocalised("Errors.TreeTableModel.NoActiveNode",this.getClass().toString()); return null; } switch (column) { case COL_NAME: return getColumnName(fn); case COL_ALIGNMENT: return getColumnAlignment(fn); case COL_DOMAINS: return getColumnDomainList(fn); case COL_SOURCE: return getColumnSource(fn); default: Logging .errorPrint(PropertyFactory.getFormattedString("in_domInTheColumn", String.valueOf(column))); break; } return null; } private Object getColumnName(PObjectNode fn) { return fn.toString(); } private Object getColumnAlignment(PObjectNode fn) { if (fn.getItem() instanceof Deity) { Deity aDeity = (Deity) fn.getItem(); PCAlignment al = aDeity.get(ObjectKey.ALIGNMENT); return al == null ? "" : al.getKeyName(); } return null; } private Object getColumnDomainList(PObjectNode fn) { if (fn.getItem() instanceof Deity) { return getDomainListPIString((Deity) fn.getItem()); } return null; } /** * @return a comma-separated string of the PI-formatted domains this * deity has */ public String getDomainListPIString(Deity aDeity) { Set<String> set = new TreeSet<String>(); for (CDOMReference<Domain> ref : aDeity.getSafeListMods(Deity.DOMAINLIST)) { for (Domain d : ref.getContainedObjects()) { set.add(d.piSubString()); } } final StringBuffer piString = new StringBuffer(100); piString.append("<html>"); piString.append(StringUtil.joinToStringBuffer(set, ",")); piString.append("</html>"); return piString.toString(); } private Object getColumnSource(PObjectNode fn) { if (fn.getItem() instanceof Deity) { Deity aDeity = (Deity) fn.getItem(); return aDeity.getDefaultSourceString(); } return null; } /** * There must be a root node, but we keep it hidden * @param aNode **/ private void setRoot(PObjectNode aNode) { super.setRoot(aNode); } private void resetModel(int mode) { // set the root node deityRoot = new PObjectNode(); setRoot(deityRoot); switch (mode) { // deities by name case GuiConstants.INFODOMAIN_VIEW_NAME: setRoot(InfoViewModelBuilder.buildNameView(InfoDomain.this, pc, Globals.getContext().ref.getConstructedCDOMObjects(Deity.class), getQFilter())); break; // end VIEW_NAME case GuiConstants.INFODOMAIN_VIEW_ALIGNMENT: setRoot(InfoViewModelBuilder.buildAlignmentView(InfoDomain.this, pc, Globals.getContext().ref.getConstructedCDOMObjects(Deity.class))); break; // end VIEW_ALIGNMENT case GuiConstants.INFODOMAIN_VIEW_DOMAIN: setRoot(InfoViewModelBuilder.buildDomainView(InfoDomain.this, pc, Globals.getContext().ref.getConstructedCDOMObjects(Deity.class))); break; // end VIEW_DOMAIN case GuiConstants.INFODOMAIN_VIEW_PANTHEON: setRoot(InfoViewModelBuilder.buildPantheonView(InfoDomain.this, pc, Globals.getContext().ref.getConstructedCDOMObjects(Deity.class))); break; // end VIEW_PANTHEON case GuiConstants.INFODOMAIN_VIEW_SOURCE: setRoot(InfoViewModelBuilder.buildSourceView(InfoDomain.this, pc, Globals.getContext().ref.getConstructedCDOMObjects(Deity.class))); break; // end VIEW_SOURCE default: Logging .errorPrint(PropertyFactory.getFormattedString("in_domInTheMode", String.valueOf(mode))); break; } // end of switch(mode) PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); if (rootAsPObjectNode.getChildCount() > 0) { fireTreeNodesChanged(super.getRoot(), new TreePath(super .getRoot())); } } public List<String> getMColumnList() { List<String> retList = new ArrayList<String>(); for (int i = 1; i < deityNameList.length; i++) { retList.add(deityNameList[i]); } return retList; } public boolean isMColumnDisplayed(int col) { return (displayList.get(col)).booleanValue(); } public void setMColumnDisplayed(int col, boolean disp) { setColumnViewOption(deityNameList[col], disp); displayList.set(col, Boolean.valueOf(disp)); } public int getMColumnOffset() { return 1; } public int getMColumnDefaultWidth(int col) { return SettingsHandler.getPCGenOption("InfoDomain.deity.sizecol." + deityNameList[col], deityColList[col]); } public void setMColumnDefaultWidth(int col, int width) { SettingsHandler.setPCGenOption("InfoDomain.deity.sizecol." + deityNameList[col], width); } private boolean getColumnViewOption(String colName, boolean defaultVal) { return SettingsHandler.getPCGenOption("InfoDomain.deity.viewcol." + colName, defaultVal); } private void setColumnViewOption(String colName, boolean val) { SettingsHandler.setPCGenOption("InfoDomain.deity.viewcol." + colName, val); } public void resetMColumn(int col, TableColumn column) { // TODO Auto-generated method stub } } /** * This is the Model that populate the table for Domains */ private final class DomainModel extends AbstractTableModel implements TableColumnManagerModel { private List<QualifiedObject<Domain>> availDomainList = new ArrayList<QualifiedObject<Domain>>(); private List<QualifiedObject<Domain>> displayDomainList = new ArrayList<QualifiedObject<Domain>>(); private String qFilter = null; private List<Boolean> displayList = null; private final String[] domainColList = new String[]{PropertyFactory.getString("in_domains"), PropertyFactory.getString("in_sourceLabel")}; private final int[] domainWidthList = new int[]{200, 100}; private DomainModel() { displayList = new ArrayList<Boolean>(); displayList.add(Boolean.TRUE); displayList.add(Boolean.valueOf(getColumnViewOption( domainColList[1], true))); } public void setAvailDomainList(List<QualifiedObject<Domain>> dl) { availDomainList = dl; } @Override public Class<?> getColumnClass(int col) { return getValueAt(0, col).getClass(); } public int getColumnCount() { return domainColList.length; } /** * Reset the model */ public void resetModel() { displayDomainList.clear(); for (int i = 0; i < availDomainList.size(); i++) { QualifiedObject<Domain> dom = availDomainList.get(i); //TODO Does anyone know why we don't call //aFN.setIsValid(aFeat.passesPreReqToGain()) here? if (qFilter == null || dom.getObject(null).getDisplayName().toLowerCase().indexOf(qFilter) >= 0) { displayDomainList.add(dom); } } } // The default implementations of these methods in // AbstractTableModel would work, but we can refine them. @Override public String getColumnName(int column) { return domainColList[column]; } public int getRowCount() { return displayDomainList.size(); } public Object getValueAt(int row, int col) { if ((row < 0) || (row >= displayDomainList.size())) { return ""; } final QualifiedObject<Domain> aQualDomain = displayDomainList.get(row); final Domain aDomain = aQualDomain.getObject(null); //Logging.errorPrint("Checking prereq of " + aQualDomain.toString()); if (aDomain == null) { return null; } StringBuffer retVal = new StringBuffer(80); switch (col) { case -1: // return domain object for the row selected return aQualDomain; case 0: // the case where selected domains are // bolded is insufficent becuase it // conflicts with PI-formatting // (bold-italic), so I added an asterisk if (selectedDomainList.contains(displayDomainList.get(row).getObject(null))) { retVal.append("<html><b>") .append(aDomain.piSubString()).append( "*</b></html>"); } else if (!PrereqHandler.passesAll(aDomain.getPrerequisiteList(), pc, aDomain) || !aQualDomain.qualifies(pc)) { retVal.append("<html>").append( SettingsHandler.getPrereqFailColorAsHtmlStart()) .append(aDomain.piSubString()).append( SettingsHandler.getPrereqFailColorAsHtmlEnd()) .append("</html>"); } else { retVal.append(aDomain.piString()); } break; case 1: try { retVal.append(aDomain.getDefaultSourceString()); } catch (Exception exc) { Logging.errorPrint(PropertyFactory .getString("in_errorMess"), exc); } break; default: Logging.errorPrint(PropertyFactory.getFormattedString("in_domInTheColumn2", String.valueOf(col))); break; } return retVal.toString(); } /** * Get the QuickFilter * @return QuickFilter */ public String getQFilter() { return qFilter; } /** * Set theQuickFilter * @param quickFilter */ public void setQFilter(String quickFilter) { if (quickFilter != null) { this.qFilter = quickFilter.toLowerCase(); } else { this.qFilter = null; } } /** * Clear the QuickFilter */ public void clearQFilter() { this.qFilter = null; } public List<String> getMColumnList() { List<String> retList = new ArrayList<String>(); retList.add(domainColList[1]); return retList; } public boolean isMColumnDisplayed(int col) { return (displayList.get(col)).booleanValue(); } public void setMColumnDisplayed(int col, boolean disp) { setColumnViewOption(domainColList[col], disp); displayList.set(col, Boolean.valueOf(disp)); } public int getMColumnOffset() { return 1; } public int getMColumnDefaultWidth(int col) { return SettingsHandler.getPCGenOption("InfoDomain.domain.sizecol." + domainColList[col], domainWidthList[col]); } public void setMColumnDefaultWidth(int col, int width) { SettingsHandler.setPCGenOption("InfoDomain.domain.sizecol." + domainColList[col], width); } private boolean getColumnViewOption(String colName, boolean defaultVal) { return SettingsHandler.getPCGenOption("InfoDomain.domain.viewcol." + colName, defaultVal); } private void setColumnViewOption(String colName, boolean val) { SettingsHandler.setPCGenOption("InfoDomain.domain.viewcol." + colName, val); } public void resetMColumn(int col, TableColumn column) { // TODO Auto-generated method stub } } /** * This class is a MouseAdapter to handle mouse clickes on the domain table. * Double-Clicks select the domain while single clicks simply display the * information about the selected domain. */ private final class DomainMouseAdapter extends MouseAdapter { private final ListSelectionModel lsm = domainTable.getSelectionModel(); @Override public void mouseClicked(MouseEvent f) { final int selectedRow = domainSorter.getRowTranslated(lsm.getMinSelectionIndex()); if (selectedRow < 0) { return; } final int clickCount = f.getClickCount(); switch (clickCount) { case (1): final QualifiedObject<Domain> qualDomain = (QualifiedObject<Domain>) domainModel.getValueAt( selectedRow, -1); final String domainKey = qualDomain.getObject(null).toString(); if (domainKey != null) { final Domain aDomain = Globals.getContext().ref.silentlyGetConstructedCDOMObject(Domain.class, domainKey); setDomainInfoText(aDomain, qualDomain.getPrerequisiteList()); } break; case (2): //No break default: //Assuming that anyone who manages to click more than twice actually meant to click twice. selectDomainIndex(selectedRow); break; } } } }

The table below shows all metrics for InfoDomain.java.

MetricValueDescription
BLOCKS265.00Number of blocks
BLOCK_COMMENT54.00Number of block comment lines
COMMENTS270.00Comment lines
COMMENT_DENSITY 0.21Comment density
COMPARISONS127.00Number of comparison operators
CYCLOMATIC279.00Cyclomatic complexity
DECL_COMMENTS44.00Comments in declarations
DOC_COMMENT154.00Number of javadoc comment lines
ELOC1288.00Effective lines of code
EXEC_COMMENTS49.00Comments in executable code
EXITS281.00Procedure exits
FUNCTIONS132.00Number of function declarations
HALSTEAD_DIFFICULTY106.47Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY284.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 1.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 0.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 3.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 4.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 1.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 8.00JAVA0076 Use of magic number
JAVA0077 4.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 1.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 3.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 1.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 1.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 1.00JAVA0130 Non-static method does not use instance fields
JAVA0131 1.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 2.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA01455709.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 1.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 1.00JAVA0173 Unused method parameter
JAVA0174 1.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 1.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 2.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 2.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 1.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES2488.00Number of lines in the source file
LINE_COMMENT62.00Number of line comments
LOC1870.00Lines of code
LOGICAL_LINES757.00Number of statements
LOOPS 8.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS3478.00Number of operands
OPERATORS6693.00Number of operators
PARAMS110.00Number of formal parameter declarations
PROGRAM_LENGTH10171.00Halstead program length
PROGRAM_VOCAB1040.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS174.00Number of return points from functions
SIZE62509.00Size of the file in bytes
UNIQUE_OPERANDS980.00Number of unique operands
UNIQUE_OPERATORS60.00Number of unique operators
WHITESPACE348.00Number of whitespace lines