Search in sources :

Example 1 with ISwingFoundSet

use of com.servoy.j2db.dataprocessing.ISwingFoundSet in project servoy-client by Servoy.

the class WebAccordionPanel method registerSelectionListeners.

private void registerSelectionListeners(IRecordInternal parentState, String relationName) {
    // $NON-NLS-1$
    String[] parts = relationName.split("\\.");
    IRecordInternal currentRecord = parentState;
    for (int i = 0; currentRecord != null && i < parts.length - 1; i++) {
        IFoundSetInternal fs = currentRecord.getRelatedFoundSet(parts[i]);
        if (fs instanceof ISwingFoundSet) {
            related.add((ISwingFoundSet) fs);
            ((ISwingFoundSet) fs).getSelectionModel().addListSelectionListener(this);
        }
        currentRecord = (fs == null) ? null : fs.getRecord(fs.getSelectedIndex());
    }
}
Also used : IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) Point(java.awt.Point) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet)

Example 2 with ISwingFoundSet

use of com.servoy.j2db.dataprocessing.ISwingFoundSet in project servoy-client by Servoy.

the class ScrollResponseHeaderContainer method setModel.

public void setModel(IFoundSetInternal fs) {
    // if is same changes are seen by model listener
    if (currentData == fs)
        return;
    if (currentData instanceof ISwingFoundSet) {
        ((ISwingFoundSet) currentData).removeTableModelListener(this);
        ((ISwingFoundSet) currentData).getSelectionModel().removeListSelectionListener(this);
    // ListSelectionModel lsm = currentData.getSelectionModel();
    // lsm.removeListSelectionListener(this);
    }
    currentData = fs;
    isCurrentDataChanged = true;
    getStylePropertyChanges().setChanged();
    if (currentData == null) {
        // table.setSelectionModel(new DefaultListSelectionModel());
        // table.setModel(new DefaultTableModel());
        data.setObject(FoundSetListWrapper.EMPTY);
    } else {
        // ListSelectionModel lsm = currentData.getSelectionModel();
        // int selected = currentData.getSelectedIndex();
        // table.setSelectionModel(lsm);
        // table.setModel((TableModel)currentData);
        data.setObject(new FoundSetListWrapper(currentData));
        if (currentData instanceof ISwingFoundSet) {
            ((ISwingFoundSet) currentData).addTableModelListener(this);
            ((ISwingFoundSet) currentData).getSelectionModel().addListSelectionListener(this);
        }
    // lsm.addListSelectionListener(this);
    // valueChanged(null,stopEditing);
    }
    scriptable.setFoundset(currentData);
    for (Object header : getHeaderComponents()) {
        ((SortableCellViewHeader) header).setResizeImage(R_ARROW_OFF);
    }
    if (isScrollMode())
        resetScrollParams();
}
Also used : FoundSetListWrapper(com.servoy.j2db.dataprocessing.FoundSetListWrapper) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet)

Example 3 with ISwingFoundSet

use of com.servoy.j2db.dataprocessing.ISwingFoundSet in project servoy-client by Servoy.

the class ScrollResponseHeaderContainer method destroy.

public void destroy() {
    if (dal != null)
        dal.destroy();
    if (currentData instanceof ISwingFoundSet) {
        ((ISwingFoundSet) currentData).removeTableModelListener(this);
        ((ISwingFoundSet) currentData).getSelectionModel().removeListSelectionListener(this);
    }
    for (Component comp : cellToElement.keySet()) {
        if (comp instanceof IDestroyable) {
            ((IDestroyable) comp).destroy();
        }
    }
    cellToElement.clear();
}
Also used : IDestroyable(com.servoy.j2db.util.IDestroyable) IComponent(com.servoy.j2db.ui.IComponent) AbstractRuntimeBaseComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IPortalComponent(com.servoy.j2db.ui.IPortalComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet)

Example 4 with ISwingFoundSet

use of com.servoy.j2db.dataprocessing.ISwingFoundSet in project servoy-client by Servoy.

the class WebEventExecutor method setSelectedIndex.

/**
 * @param component
 */
@SuppressWarnings("nls")
public static boolean setSelectedIndex(Component component, AjaxRequestTarget target, int modifiers, boolean bHandleMultiselect) {
    WebForm parentForm = component.findParent(WebForm.class);
    WebCellBasedView tableView = null;
    if (parentForm != null) {
        int parentFormViewType = parentForm.getController().getForm().getView();
        if (parentFormViewType == FormController.TABLE_VIEW || parentFormViewType == FormController.LOCKED_TABLE_VIEW || parentFormViewType == IForm.LIST_VIEW || parentFormViewType == FormController.LOCKED_LIST_VIEW) {
            tableView = component.findParent(WebCellBasedView.class);
            if (tableView == null) {
                // the component is not part of the table view (it is on other form part), so ignore selection change
                return true;
            } else
                tableView.setSelectionMadeByCellAction();
            if (parentFormViewType == IForm.LIST_VIEW || parentFormViewType == FormController.LOCKED_LIST_VIEW) {
                if (component instanceof WebCellBasedViewListViewItem) {
                    ((WebCellBasedViewListViewItem) component).markSelected(target);
                } else {
                    WebCellBasedViewListViewItem listViewItem = component.findParent(WebCellBasedView.WebCellBasedViewListViewItem.class);
                    if (listViewItem != null) {
                        listViewItem.markSelected(target);
                    }
                }
            }
        }
    }
    // search for recordItem model
    Component recordItemModelComponent = component;
    IModel<?> someModel = recordItemModelComponent.getDefaultModel();
    while (!(someModel instanceof RecordItemModel)) {
        recordItemModelComponent = recordItemModelComponent.getParent();
        if (recordItemModelComponent == null)
            break;
        someModel = recordItemModelComponent.getDefaultModel();
    }
    if (someModel instanceof RecordItemModel) {
        if (!(component instanceof WebCellBasedViewListViewItem)) {
            // update the last rendered value for the events component (if updated)
            ((RecordItemModel) someModel).updateRenderedValue(component);
        }
        IRecordInternal rec = (IRecordInternal) someModel.getObject();
        if (rec != null) {
            int index;
            IFoundSetInternal fs = rec.getParentFoundSet();
            if (someModel instanceof FoundsetRecordItemModel) {
                index = ((FoundsetRecordItemModel) someModel).getRowIndex();
            } else {
                // this is used only on "else", because a "plugins.rawSQL.flushAllClientsCache" could result in index = -1 although the record has not changed (but record & underlying row instances changed)
                index = fs.getRecordIndex(rec);
            }
            if (fs instanceof FoundSet && ((FoundSet) fs).isMultiSelect()) {
                // set the selected record
                ClientProperties clp = ((WebClientInfo) Session.get().getClientInfo()).getProperties();
                String navPlatform = clp.getNavigatorPlatform();
                int controlMask = (navPlatform != null && navPlatform.toLowerCase().indexOf("mac") != -1) ? Event.META_MASK : Event.CTRL_MASK;
                boolean toggle = (modifiers != MODIFIERS_UNSPECIFIED) && ((modifiers & controlMask) != 0);
                boolean extend = (modifiers != MODIFIERS_UNSPECIFIED) && ((modifiers & Event.SHIFT_MASK) != 0);
                boolean isRightClick = (modifiers != MODIFIERS_UNSPECIFIED) && ((modifiers & Event.ALT_MASK) != 0);
                if (!isRightClick) {
                    if (!toggle && !extend && tableView != null && tableView.getDragNDropController() != null && Arrays.binarySearch(((FoundSet) fs).getSelectedIndexes(), index) > -1) {
                        return true;
                    }
                    if (toggle || extend) {
                        if (bHandleMultiselect) {
                            if (toggle) {
                                int[] selectedIndexes = ((FoundSet) fs).getSelectedIndexes();
                                ArrayList<Integer> selectedIndexesA = new ArrayList<Integer>();
                                Integer selectedIndex = new Integer(index);
                                for (int selected : selectedIndexes) selectedIndexesA.add(new Integer(selected));
                                if (selectedIndexesA.indexOf(selectedIndex) != -1) {
                                    if (selectedIndexesA.size() > 1) {
                                        ((ISwingFoundSet) fs).getSelectionModel().removeSelectionInterval(selectedIndex, selectedIndex);
                                    }
                                } else {
                                    ((ISwingFoundSet) fs).getSelectionModel().addSelectionInterval(selectedIndex, selectedIndex);
                                }
                            } else if (extend) {
                                int anchor = ((FoundSet) fs).getSelectedIndex();
                                int min = Math.min(anchor, index);
                                int max = Math.max(anchor, index);
                                ((ISwingFoundSet) fs).getSelectionModel().setSelectionInterval(min, max);
                            }
                        }
                    } else if (index != -1 || fs.getSize() == 0) {
                        fs.setSelectedIndex(index);
                    }
                }
            } else if (!isIndexSelected(fs, index))
                fs.setSelectedIndex(index);
            if (!isIndexSelected(fs, index) && !(fs instanceof FoundSet && ((FoundSet) fs).isMultiSelect())) {
                // setSelectedIndex failed, probably due to validation failed, do a blur()
                if (target != null)
                    target.appendJavascript("var toBlur = document.getElementById(\"" + component.getMarkupId() + "\");if (toBlur) toBlur.blur();");
                return false;
            }
        }
    }
    return true;
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) ClientProperties(org.apache.wicket.protocol.http.ClientProperties) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) WebForm(com.servoy.j2db.server.headlessclient.WebForm) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) ArrayList(java.util.ArrayList) IFoundSet(com.servoy.j2db.dataprocessing.IFoundSet) FoundSet(com.servoy.j2db.dataprocessing.FoundSet) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet) WebCellBasedViewListViewItem(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView.WebCellBasedViewListViewItem) Point(java.awt.Point) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet) IComponent(com.servoy.j2db.ui.IComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent)

Example 5 with ISwingFoundSet

use of com.servoy.j2db.dataprocessing.ISwingFoundSet in project servoy-client by Servoy.

the class WebSplitPane method registerSelectionListeners.

private void registerSelectionListeners(IRecordInternal parentState, String relationName) {
    // $NON-NLS-1$
    String[] parts = relationName.split("\\.");
    IRecordInternal currentRecord = parentState;
    for (int i = 0; currentRecord != null && i < parts.length - 1; i++) {
        IFoundSetInternal fs = currentRecord.getRelatedFoundSet(parts[i]);
        if (fs instanceof ISwingFoundSet) {
            related.add((ISwingFoundSet) fs);
            ((ISwingFoundSet) fs).getSelectionModel().addListSelectionListener(this);
        }
        currentRecord = (fs == null) ? null : fs.getRecord(fs.getSelectedIndex());
    }
}
Also used : IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) Point(java.awt.Point) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet)

Aggregations

ISwingFoundSet (com.servoy.j2db.dataprocessing.ISwingFoundSet)16 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)11 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)10 Point (java.awt.Point)6 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)3 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)3 ServoyException (com.servoy.j2db.util.ServoyException)3 EventObject (java.util.EventObject)3 IApplication (com.servoy.j2db.IApplication)2 FoundSetManager (com.servoy.j2db.dataprocessing.FoundSetManager)2 IFoundSet (com.servoy.j2db.dataprocessing.IFoundSet)2 SortColumn (com.servoy.j2db.dataprocessing.SortColumn)2 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)2 IComponent (com.servoy.j2db.ui.IComponent)2 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)2 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)2 Color (java.awt.Color)2 ArrayList (java.util.ArrayList)2 Component (org.apache.wicket.Component)2 BaseQueryTable (com.servoy.base.query.BaseQueryTable)1