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());
}
}
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();
}
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();
}
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;
}
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());
}
}
Aggregations