use of com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel in project servoy-client by Servoy.
the class ViewFoundSet method createSelectionModel.
private void createSelectionModel() {
if (selectionModel == null) {
selectionModel = new AlwaysRowSelectedSelectionModel(this);
addListDataListener(selectionModel);
}
}
use of com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel in project servoy-client by Servoy.
the class FixedJTable method editCellAt.
@Override
public boolean editCellAt(int row, int column, EventObject e) {
// being noted and caried out later
if (cellEditor != null) {
// if the current one is already editing then don't try to stop it.
if (getEditingRow() == row && getEditingColumn() == column)
return true;
if (!cellEditor.stopCellEditing() || cellEditor != null) {
// do edit request after normal removeEditor is finished
editRequest = new Object[] { new Integer(row), new Integer(column), e };
// processed later)
return false;
}
}
// later than the editor, we need other way around
if (!setSelectedRow(row, e)) {
// selected index not actually changed, probably due to validation failed
return false;
}
// if we are in multiselect we only edit when we click in single selected row; otherwise we just select (no edit)
if (e instanceof MouseEvent && ((MouseEvent) e).getID() == MouseEvent.MOUSE_PRESSED && getSelectionModel().getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) {
MouseEvent me = (MouseEvent) e;
if (UIUtils.isCommandKeyDown((MouseEvent) e) || me.isShiftDown()) {
return false;
} else {
ListSelectionModel sm = getSelectionModel();
if (sm instanceof AlwaysRowSelectedSelectionModel) {
AlwaysRowSelectedSelectionModel fsm = (AlwaysRowSelectedSelectionModel) sm;
boolean selectedRow = fsm.setSelectedRow(row);
if (!selectedRow)
return false;
}
}
}
return super.editCellAt(row, column, e);
}
use of com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel in project servoy-client by Servoy.
the class FixedJTable method processMouseEvent.
/**
* @see javax.swing.JComponent#processMouseEvent(java.awt.event.MouseEvent)
*/
@Override
protected void processMouseEvent(MouseEvent e) {
// mouse_released and popup trigger is a special case for windows lnf
boolean changeSelection = e.getID() == MouseEvent.MOUSE_PRESSED || (e.getID() == MouseEvent.MOUSE_RELEASED && e.isPopupTrigger());
if (((changeSelection && getSelectionModel().getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) || (changeSelection && getSelectionModel().getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION && !UIUtils.isCommandKeyDown(e) && !e.isShiftDown())) && isEnabled()) {
Point p = e.getPoint();
int row = rowAtPoint(p);
if (row != -1 && getSelectedRow() != row) {
ListSelectionModel rsm = getSelectionModel();
if (rsm instanceof AlwaysRowSelectedSelectionModel && !((AlwaysRowSelectedSelectionModel) rsm).canChangeSelection())
return;
if (!isEditing() || getCellEditor().stopCellEditing()) {
rsm.setSelectionInterval(row, row);
}
}
}
MouseEvent me = e;
if (e.isAltDown()) {
me = new MouseEvent(e.getComponent(), e.getID(), e.getWhen(), e.getModifiers() | e.getModifiersEx(), e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()) {
@Override
public int getModifiers() {
return (super.getModifiers() | super.getModifiersEx());
}
};
}
super.processMouseEvent(me);
}
use of com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel in project servoy-client by Servoy.
the class FoundsetPropertySelectionListener method valueChanged.
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting() && !ignoreSelectionChanges) {
boolean userSetSelection = false;
Object eventSource = e.getSource();
if (eventSource instanceof AlwaysRowSelectedSelectionModel) {
AlwaysRowSelectedSelectionModel alwaysRowSelectedSelectionModel = (AlwaysRowSelectedSelectionModel) eventSource;
userSetSelection = !alwaysRowSelectedSelectionModel.isFoundsetIsFiringSizeChange();
}
changeMonitor.selectionChanged(userSetSelection);
viewPort.selectionChanged();
}
}
use of com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel in project servoy-client by Servoy.
the class SwingFoundSet method copyCurrentRecordFoundSet.
@Override
public // used for printing current record
IFoundSetInternal copyCurrentRecordFoundSet() throws // used for printing current record
ServoyException {
SwingFoundSet sfs = (SwingFoundSet) super.copyCurrentRecordFoundSet();
if (sfs != null) {
sfs.selectionModel = new AlwaysRowSelectedSelectionModel(this);
sfs.addListDataListener(sfs.selectionModel);
}
return sfs;
}
Aggregations