use of com.servoy.j2db.ui.IProviderStylePropertyChanges in project servoy-client by Servoy.
the class WebCellAdapter method valueChanged.
public void valueChanged(ModificationEvent e) {
MainPage mp = view.findParent(MainPage.class);
if (mp != null)
mp.touch();
IRecord record = e.getRecord();
Iterator iterator = ((MarkupContainer) view.getTable()).iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof ListItem) {
ListItem li = (ListItem) next;
Object modelObject = li.getModelObject();
if (record == null || modelObject == record) {
boolean hasOnRender = false;
Iterator iterator2 = li.iterator();
while (iterator2.hasNext()) {
ArrayList<Object> cellDisplays = new ArrayList<Object>();
Object cell = iterator2.next();
cell = CellContainer.getContentsForCell((Component) cell);
if (cell instanceof WebCellBasedViewListViewItem) {
Iterator listItemIte = ((WebCellBasedViewListViewItem) cell).iterator();
while (listItemIte.hasNext()) {
Object listItemDisplay = listItemIte.next();
if (listItemDisplay instanceof WrapperContainer) {
listItemDisplay = ((WrapperContainer) listItemDisplay).getDelegate();
}
cellDisplays.add(listItemDisplay);
}
} else {
cellDisplays.add(cell);
}
for (Object cellDisplay : cellDisplays) {
if (cellDisplay instanceof IProviderStylePropertyChanges && cellDisplay instanceof IDisplayData && ((IDisplayData) cellDisplay).getDataProviderID() == dataprovider) {
// only test if it is not already changed
view.checkForValueChanges(cellDisplay);
// do fire on render on all components for record change
if (cellDisplay instanceof ISupportOnRender && cellDisplay instanceof IScriptableProvider) {
IScriptable so = ((IScriptableProvider) cellDisplay).getScriptObject();
if (so instanceof AbstractRuntimeRendersupportComponent && ((ISupportOnRenderCallback) so).getRenderEventExecutor().hasRenderCallback()) {
String componentDataproviderID = ((AbstractRuntimeRendersupportComponent) so).getDataProviderID();
if (record != null || (e.getName() != null && e.getName().equals(componentDataproviderID))) {
((ISupportOnRender) cellDisplay).fireOnRender(true);
hasOnRender = true;
}
}
}
}
}
}
if (record != null || (!hasOnRender && !canChangeValue(e)))
break;
}
}
}
}
use of com.servoy.j2db.ui.IProviderStylePropertyChanges in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method setHeadersWidth.
// set headers width according to cell's width
private void setHeadersWidth() {
Iterator<IPersist> columnPersistIte = elementToColumnIdentifierComponent.keySet().iterator();
IPersist columnPersist;
Component columnHeader, columnCell;
while (columnPersistIte.hasNext()) {
columnPersist = columnPersistIte.next();
columnCell = elementToColumnIdentifierComponent.get(columnPersist);
columnHeader = elementToColumnHeader.get(columnPersist);
if (columnCell instanceof IProviderStylePropertyChanges) {
// $NON-NLS-1$
String width = ((IProviderStylePropertyChanges) columnCell).getStylePropertyChanges().getJSProperty("offsetWidth");
if (columnHeader instanceof SortableCellViewHeader) {
SortableCellViewHeader sortableColumnHeader = (SortableCellViewHeader) columnHeader;
if (width != null)
sortableColumnHeader.setWidth(Integer.parseInt(width.substring(0, width.length() - 2)));
else if (columnPersist instanceof BaseComponent)
sortableColumnHeader.setWidth(((BaseComponent) columnPersist).getSize().width);
}
}
}
}
use of com.servoy.j2db.ui.IProviderStylePropertyChanges in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method resizeColumn.
public void resizeColumn(SortableCellViewHeader headerColumn, int x) {
int totalWidthToStretch = 0;
IPersist resizedPersist = null;
for (IPersist p : elementToColumnHeader.keySet()) {
Component c = elementToColumnIdentifierComponent.get(p);
if (c instanceof IScriptableProvider && ((IScriptableProvider) c).getScriptObject() instanceof IRuntimeComponent) {
IRuntimeComponent ic = (IRuntimeComponent) ((IScriptableProvider) c).getScriptObject();
if (elementToColumnHeader.get(p).equals(headerColumn)) {
int height = ic.getHeight();
Iterator<Component> alreadyAddedComponents = cellToElement.keySet().iterator();
if (alreadyAddedComponents.hasNext()) {
Component firstAddedComponent = alreadyAddedComponents.next();
if ((firstAddedComponent instanceof IComponent))
height = ((IComponent) firstAddedComponent).getSize().height;
}
ic.setSize(ic.getWidth() + x, height);
if (ic instanceof IProviderStylePropertyChanges) {
resizedComponent = c;
// avoid the tableview to render because of this change
((IProviderStylePropertyChanges) ic).getStylePropertyChanges().setRendered();
}
resizedPersist = p;
// set width for all cell of the column
Iterator<Entry<Component, IPersist>> cellToElementIte = cellToElement.entrySet().iterator();
Entry<Component, IPersist> cellToElementEntry;
Component cellComponent;
while (cellToElementIte.hasNext()) {
cellToElementEntry = cellToElementIte.next();
cellComponent = cellToElementEntry.getKey();
if (p.equals(cellToElementEntry.getValue()) && cellComponent instanceof IScriptableProvider && ((IScriptableProvider) cellComponent).getScriptObject() instanceof IRuntimeComponent) {
IRuntimeComponent cellScriptComponent = (IRuntimeComponent) ((IScriptableProvider) cellComponent).getScriptObject();
cellScriptComponent.setSize(cellScriptComponent.getWidth() + x, cellScriptComponent.getHeight());
if (cellComponent instanceof IProviderStylePropertyChanges) {
// avoid the tableview to render because of this change
((IProviderStylePropertyChanges) cellComponent).getStylePropertyChanges().setRendered();
}
}
}
} else {
totalWidthToStretch += ic.getWidth();
}
}
}
if (shouldFillAllHorizontalSpace())
distributeExtraSpace(-x, totalWidthToStretch, resizedPersist, false);
setHeadersWidth();
}
use of com.servoy.j2db.ui.IProviderStylePropertyChanges in project servoy-client by Servoy.
the class TabIndexHelper method setUpTabIndexAttributeModifierInternal.
private static void setUpTabIndexAttributeModifierInternal(Component comp, int newTabIndex) {
TabIndexAttributeModifier modifier = null;
final Component component = comp;
for (Object obeh : component.getBehaviors()) {
IBehavior beh = (IBehavior) obeh;
if (beh instanceof TabIndexAttributeModifier) {
modifier = (TabIndexAttributeModifier) beh;
break;
}
}
boolean componentChanged = true;
boolean changeForClientSide = false;
if (modifier == null) {
if (newTabIndex != ISupportWebTabSeq.DEFAULT && isTabIndexSupported(component))
component.add(new TabIndexAttributeModifier(newTabIndex));
} else if (newTabIndex != ISupportWebTabSeq.DEFAULT) {
if (newTabIndex != modifier.getTabIndex()) {
modifier.setTabIndex(newTabIndex);
if (!(component instanceof IProviderStylePropertyChanges) || !((IProviderStylePropertyChanges) component).getStylePropertyChanges().isChanged()) {
// if is already changed leave it to server side
changeForClientSide = true;
}
} else {
componentChanged = false;
}
} else {
component.remove(modifier);
}
if (componentChanged) {
MainPage page = component.findParent(MainPage.class);
if (changeForClientSide) {
if (page != null) {
page.getPageContributor().addTabIndexChange(component.getMarkupId(), newTabIndex);
} else {
changeForClientSide = false;
}
}
if (!changeForClientSide && component instanceof IProviderStylePropertyChanges) {
IProviderStylePropertyChanges changeable = (IProviderStylePropertyChanges) component;
changeable.getStylePropertyChanges().setChanged();
if (page != null) {
page.getPageContributor().addTabIndexChange(component.getMarkupId(), ISupportWebTabSeq.DEFAULT);
}
}
}
}
use of com.servoy.j2db.ui.IProviderStylePropertyChanges in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method tableChanged.
/**
* @see javax.swing.event.TableModelListener#tableChanged(javax.swing.event.TableModelEvent)
*/
public void tableChanged(TableModelEvent e) {
// as changed, as it will be faster on the client the component replace
if ((e.getType() == TableModelEvent.UPDATE) && (e.getFirstRow() == e.getLastRow()) && (nrUpdatedListItems < 20)) {
Component component = table.get(Integer.toString(e.getFirstRow()));
if (component instanceof ListItem) {
((ListItem) component).visitChildren(IProviderStylePropertyChanges.class, new IVisitor<Component>() {
public Object component(Component comp) {
if ((comp instanceof IDisplayData) || !(comp instanceof ILabel)) {
if (comp instanceof ISupportsNeedEntireState && ((ISupportsNeedEntireState) comp).needEntireState()) {
// it if has tags - mark as changed; it could be enhanced further by also know what was last-rendered on tags, not just simple dataproviders
((IProviderStylePropertyChanges) comp).getStylePropertyChanges().setChanged();
} else {
// try to mark cells as changed only if there was a real value change; otherwise there is no use to replace the whole row...
checkForValueChanges(comp);
}
}
// else labels/buttons that don't display data are not changed
return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
}
});
nrUpdatedListItems++;
IModel<IRecordInternal> newModel = table.getListItemModel(table.getModel(), e.getFirstRow());
IModel oldModel = ((ListItem) component).getModel();
if (newModel != null && oldModel != null && newModel.getObject() != null && !newModel.getObject().equals(oldModel.getObject())) {
// refresh model if it changed
((ListItem) component).setModel(newModel);
}
}
} else {
if (!isRendering && (!isScrollMode() || !(scrollBehavior != null && scrollBehavior.isGettingRows()))) {
if (isScrollMode())
resetScrollParams();
getStylePropertyChanges().setValueChanged();
}
}
// This is just an heuristic for filtering out the sort event from all table changed events that are raised.
if (currentData != null && e.getColumn() == TableModelEvent.ALL_COLUMNS && e.getFirstRow() == 0 && elementToColumnHeader.size() > 0) {
List<SortColumn> sortCols = currentData.getSortColumns();
if (sortCols != null && sortCols.size() > 0) {
Map<String, Boolean> sortMap = new HashMap<String, Boolean>();
for (IPersist persist : elementToColumnHeader.keySet()) {
SortableCellViewHeader sortableCellViewHeader = (SortableCellViewHeader) elementToColumnHeader.get(persist);
sortableCellViewHeader.setResizeImage(R_ARROW_OFF);
}
for (SortColumn sc : sortCols) {
for (IPersist persist : elementToColumnHeader.keySet()) {
Component comp = elementToColumnIdentifierComponent.get(persist);
SortableCellViewHeader sortableCellViewHeader = (SortableCellViewHeader) elementToColumnHeader.get(persist);
if (comp instanceof IDisplayData && ((IDisplayData) comp).getDataProviderID() != null) {
IDisplayData dispComp = (IDisplayData) comp;
List<String> sortingProviders = null;
if (dispComp instanceof ISupportValueList && ((ISupportValueList) dispComp).getValueList() != null) {
try {
sortingProviders = DBValueList.getShowDataproviders(((ISupportValueList) dispComp).getValueList().getValueList(), (Table) currentData.getTable(), dispComp.getDataProviderID(), currentData.getFoundSetManager());
} catch (RepositoryException ex) {
Debug.error(ex);
}
}
if (sortingProviders == null) {
// no related sort, use sort on dataProviderID instead
sortingProviders = Collections.singletonList(dispComp.getDataProviderID());
}
for (String sortingProvider : sortingProviders) {
SortColumn existingSc;
try {
FoundSetManager fsm = (FoundSetManager) currentData.getFoundSetManager();
existingSc = fsm.getSortColumn(currentData.getTable(), sortingProvider, false);
} catch (RepositoryException ex) {
Debug.error(ex);
continue;
}
if (sc.equalsIgnoreSortorder(existingSc)) {
boolean descending = sc.getSortOrder() == SortColumn.DESCENDING;
sortableCellViewHeader.setResizeImage(descending ? R_ARROW_UP : R_ARROW_DOWN);
sortMap.put(sortableCellViewHeader.getId(), Boolean.valueOf(!descending));
}
}
}
}
}
headers.recordSort(sortMap);
}
}
MainPage mp = table.findParent(MainPage.class);
if (mp != null)
mp.triggerBrowserRequestIfNeeded();
}
Aggregations