use of javax.swing.ListSelectionModel in project pcgen by PCGen.
the class SkillInfoTab method createModels.
@Override
public ModelMap createModels(final CharacterFacade character) {
ModelMap models = new ModelMap();
ListSelectionModel listModel = new DefaultListSelectionModel();
listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
models.put(ListSelectionModel.class, listModel);
models.put(SkillPointTableModel.class, new SkillPointTableModel(character));
models.put(SkillTreeViewModel.class, new SkillTreeViewModel(character, listModel));
models.put(FilterHandler.class, new FilterHandler(character, listModel));
models.put(InfoHandler.class, new InfoHandler(character));
models.put(LevelSelectionHandler.class, new LevelSelectionHandler(character, listModel));
models.put(SkillRankSpinnerEditor.class, new SkillRankSpinnerEditor(character, listModel));
SkillSheetHandler skillSheetHandler = new SkillSheetHandler(character);
models.put(SkillSheetHandler.class, skillSheetHandler);
models.put(SkillFilterHandler.class, new SkillFilterHandler(character, skillSheetHandler));
return models;
}
use of javax.swing.ListSelectionModel in project adempiere by adempiere.
the class Info method jbInit.
/**
* Static Init
* @throws Exception
*/
protected void jbInit() throws Exception {
this.getContentPane().add(parameterPanel, BorderLayout.NORTH);
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
this.getContentPane().add(southPanel, BorderLayout.SOUTH);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//
AppsAction aa = new AppsAction(ConfirmPanel.A_RESET, null, "reset");
bReset = (CButton) aa.getButton();
bReset.setMargin(ConfirmPanel.s_insets);
bReset.setSize(bReset.getHeight(), bReset.getHeight());
Dimension bSize = bReset.getSize();
bSize.height = bReset.getHeight();
bSize.width = bReset.getHeight();
// Make it square
bReset.setMaximumSize(bSize);
bReset.addActionListener(this);
//
buttonPanel = new CPanel(new FlowLayout(FlowLayout.LEFT));
buttonPanel.add(bReset, FlowLayout.LEFT);
//
// p_criteriaGrid is filled by the subordinate class
p_criteriaGrid.setLayout(new ALayout());
//
parameterPanel.setLayout(new BorderLayout());
parameterPanel.add(buttonPanel, BorderLayout.WEST);
parameterPanel.add(p_criteriaGrid, BorderLayout.CENTER);
//
// Setup the detail panel if used
p_detailTaskPane.setVisible(false);
p_detailTaskPane.setCollapsed(true);
p_detailTaskPane.setLayout(new BorderLayout());
p_detailTaskPane.setUI(new AdempiereTaskPaneUI());
p_detailTaskPane.getContentPane().setBackground(new ColorUIResource(251, 248, 241));
p_detailTaskPane.getContentPane().setForeground(new ColorUIResource(251, 0, 0));
addonPanel.setLayout(new BorderLayout());
// Allow auto resizing of the panel
addonPanel.add(p_detailTaskPane, BorderLayout.CENTER);
southPanel.setLayout(southLayout);
southPanel.add(addonPanel, BorderLayout.NORTH);
southPanel.add(confirmPanel, BorderLayout.CENTER);
southPanel.add(statusBar, BorderLayout.SOUTH);
scrollPane.getViewport().add(p_table, null);
//
confirmPanel.addActionListener(this);
confirmPanel.getResetButton().setVisible(hasReset());
confirmPanel.getCustomizeButton().setVisible(hasCustomize());
confirmPanel.getHistoryButton().setVisible(hasHistory());
confirmPanel.getZoomButton().setVisible(hasZoom());
// Only show the OK button if we intend to save
confirmPanel.setOKVisible(p_saveResults);
//
JButton print = ConfirmPanel.createPrintButton(true);
print.addActionListener(this);
confirmPanel.addButton(print);
//
checkAutoQuery.setText(Msg.getMsg(Env.getCtx(), "AutoRefresh"));
checkAutoQuery.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoRefresh"));
checkAutoQuery.setName("AutoQuery");
checkAutoQuery.setSelected(MSysConfig.getValue(SYSCONFIG_INFO_AUTO_QUERY, "Y", Env.getAD_Client_ID(Env.getCtx())).equals("Y"));
checkAutoQuery.addActionListener(this);
// Index 0 is OK-Cancel on the right
CPanel leftButtons = (CPanel) confirmPanel.getComponent(1);
// Add the check box on the very left before the refresh icon
leftButtons.add(checkAutoQuery, 0);
//
popup.add(zoomMenu);
zoomMenu.setText(Msg.getMsg(Env.getCtx(), "Zoom"));
zoomMenu.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Zoom16.gif")));
zoomMenu.addActionListener(this);
//
popup.add(calcMenu);
calcMenu.setText(Msg.getMsg(Env.getCtx(), "Calculator"));
calcMenu.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Calculator16.gif")));
calcMenu.addActionListener(this);
//
// Table Selection (Invoked before setting column class so that row selection is enabled)
p_table.setKeyColumnIndex(-1);
p_table.setCellSelectionEnabled(false);
p_table.setColumnSelectionAllowed(false);
p_table.setRowSelectionAllowed(true);
// Override the Enter key input and action map
if (p_saveResults) {
p_table.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doDispose");
} else {
p_table.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doNothing");
}
p_table.getActionMap().put("doDispose", doDispose);
// To enable buttons
((ListSelectionModel) p_table.getSelectionModel()).addListSelectionListener(this);
p_table.addMouseListener(this);
// Listen to changes in the table
p_table.addPropertyChangeListener("p_table_update", this);
((ListSelectionModel) p_table.getSelectionModel()).addListSelectionListener(this);
//
// Set default location where focus will go. See property change listener.
m_parentPanel = p_criteriaGrid;
//
enableButtons();
}
use of javax.swing.ListSelectionModel in project adempiere by adempiere.
the class MiniTable method toggleRowChecked.
/**
* Toggles the selection checkbox of the given row. Adds or removes the row from
* the selection accordingly.
* @param row - the row in the view to toggle
*/
private void toggleRowChecked(int row) {
// Range check
int rows = this.getRowCount();
if (this.getShowTotals())
rows = rows - 1;
if (row < 0 || row >= rows)
return;
ListSelectionModel rsm = this.getSelectionModel();
// Toggle
setRowChecked(row, !isRowChecked(row));
if (isRowChecked(row)) {
if (isMultiSelection())
rsm.addSelectionInterval(row, row);
else
rsm.setSelectionInterval(row, row);
} else {
rsm.removeSelectionInterval(row, row);
}
}
use of javax.swing.ListSelectionModel in project adempiere by adempiere.
the class MiniTable method toggleLeadRowChecked.
/**
* Toggles the selection checkbox of the current lead row. Adds or removes the lead row from
* the selection accordingly.
*/
private void toggleLeadRowChecked() {
// Check if the lead row is selected, if not, select it
ListSelectionModel rsm = this.getSelectionModel();
int leadRow = rsm.getLeadSelectionIndex();
if (leadRow == -1)
return;
// Toggle
setRowChecked(leadRow, !isRowChecked(leadRow));
if (isRowChecked(leadRow)) {
if (isMultiSelection())
rsm.addSelectionInterval(leadRow, leadRow);
else
rsm.setSelectionInterval(leadRow, leadRow);
} else {
rsm.removeSelectionInterval(leadRow, leadRow);
rsm.setLeadSelectionIndex(leadRow);
}
}
use of javax.swing.ListSelectionModel in project adempiere by adempiere.
the class MiniTable method toggleRowCheckedRange.
/**
* Toggles the selection checkbox of a range or rows. Adds or removes the rows from
* the selection accordingly.
* @param index0 - one end of the range
* @param index1 - the other end of the range. Can be less than, equal or greater than index0.
*/
private void toggleRowCheckedRange(int index0, int index1) {
if (isMultiSelection()) {
if (getKeyColumnIndex() >= 0) {
int rows = this.getRowCount();
if (this.getShowTotals())
rows = rows - 1;
if (index0 < 0 || index0 >= rows || index1 < 0 || index1 >= rows)
return;
ListSelectionModel rsm = this.getSelectionModel();
int leadRow = rsm.getLeadSelectionIndex();
int low = index0 <= index1 ? index0 : index1;
int high = index0 <= index1 ? index1 : index0;
// Limit the number of row selection events to once per change
m_changingMultipleRows = true;
for (int row = low; row <= high; row++) {
toggleRowChecked(row);
}
// Return the lead to its original location
rsm.setLeadSelectionIndex(leadRow);
fireRowSelectionEvent();
m_changingMultipleRows = false;
}
}
}
Aggregations