Search in sources :

Example 1 with AlwaysRowSelectedSelectionModel

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);
    }
}
Also used : AlwaysRowSelectedSelectionModel(com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel)

Example 2 with AlwaysRowSelectedSelectionModel

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);
}
Also used : MouseEvent(java.awt.event.MouseEvent) ListSelectionModel(javax.swing.ListSelectionModel) AlwaysRowSelectedSelectionModel(com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel)

Example 3 with AlwaysRowSelectedSelectionModel

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);
}
Also used : MouseEvent(java.awt.event.MouseEvent) ListSelectionModel(javax.swing.ListSelectionModel) Point(java.awt.Point) Point(java.awt.Point) AlwaysRowSelectedSelectionModel(com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel)

Example 4 with AlwaysRowSelectedSelectionModel

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();
    }
}
Also used : AlwaysRowSelectedSelectionModel(com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel)

Example 5 with AlwaysRowSelectedSelectionModel

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;
}
Also used : AlwaysRowSelectedSelectionModel(com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel)

Aggregations

AlwaysRowSelectedSelectionModel (com.servoy.j2db.util.model.AlwaysRowSelectedSelectionModel)9 ListSelectionModel (javax.swing.ListSelectionModel)3 Point (java.awt.Point)2 MouseEvent (java.awt.event.MouseEvent)2 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)1 Rectangle (java.awt.Rectangle)1 TableModel (javax.swing.table.TableModel)1