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;
}
}
}
use of javax.swing.ListSelectionModel in project pcgen by PCGen.
the class DescriptionInfoTab method createModels.
@Override
public ModelMap createModels(CharacterFacade character) {
ModelMap models = new ModelMap();
DefaultListModel listModel = new DefaultListModel();
List<NoteInfoPane> notePaneList = new ArrayList<>();
//$NON-NLS-1$
PageItem firstPage = new PageItem(character, LanguageBundle.getString("in_descBiography"), bioPane);
listModel.addElement(firstPage);
//$NON-NLS-1$
listModel.addElement(new PageItem(character, LanguageBundle.getString("in_portrait"), portraitPane));
//$NON-NLS-1$
listModel.addElement(new PageItem(character, LanguageBundle.getString("in_descCampHist"), histPane));
models.put(ListModel.class, listModel);
models.put(List.class, notePaneList);
models.put(NoteListHandler.class, new NoteListHandler(character, listModel, notePaneList));
ListSelectionModel model = new DefaultListSelectionModel();
model.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
model.setSelectionInterval(0, 0);
models.put(ListSelectionModel.class, model);
models.put(PageHandler.class, new PageHandler(model, firstPage));
models.put(AddAction.class, new AddAction(character));
return models;
}
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 poi by apache.
the class SVSheetTable method setFormulaDisplay.
public void setFormulaDisplay(JTextComponent formulaDisplay) {
ListSelectionModel rowSelMod = getSelectionModel();
ListSelectionModel colSelMod = getColumnModel().getSelectionModel();
if (formulaDisplay == null) {
rowSelMod.removeListSelectionListener(formulaListener);
colSelMod.removeListSelectionListener(formulaListener);
formulaListener = null;
}
if (formulaDisplay != null) {
formulaListener = new FormulaDisplayListener(formulaDisplay);
rowSelMod.addListSelectionListener(formulaListener);
colSelMod.addListSelectionListener(formulaListener);
}
}
Aggregations