use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method getListItemBgColor.
private String getListItemBgColor(ListItem<IRecordInternal> listItem, boolean isSelected, boolean asInlineCssString) {
String color = null;
final IRecordInternal rec = listItem.getModelObject();
String rowBGColorProvider = getRowBGColorScript();
Row rawData = null;
if (rec != null && (rawData = rec.getRawData()) != null) {
color = getStyleAttributeForListItem(listItem, isSelected, ISupportRowStyling.ATTRIBUTE.BGCOLOR, asInlineCssString);
if (rowBGColorProvider != null) {
Object c = color;
// TODO type and name should be get somehow if this is possible, we have to know the specific cell/column for that.
// (renderer instanceof IScriptBaseMethods) ? ((IScriptBaseMethods)renderer).js_getElementType() : null;
String type = null;
// (renderer instanceof IScriptBaseMethods) ? ((IScriptBaseMethods)renderer).js_getName() : null;
String cellName = null;
if (rawData.containsCalculation(rowBGColorProvider)) {
// TODO this should be done better....
// isEdited is always false
Record.VALIDATE_CALCS.set(Boolean.FALSE);
try {
c = rec.getParentFoundSet().getCalculationValue(rec, rowBGColorProvider, Utils.arrayMerge(new Object[] { new Integer(listItem.getIndex()), new Boolean(isSelected), type, cellName, Boolean.FALSE }, Utils.parseJSExpressions(getRowBGColorArgs())), null);
} finally {
Record.VALIDATE_CALCS.set(null);
}
} else {
try {
FormController currentForm = dal.getFormController();
c = currentForm.executeFunction(rowBGColorProvider, Utils.arrayMerge(new Object[] { new Integer(listItem.getIndex()), new Boolean(isSelected), type, cellName, currentForm.getName(), rec, Boolean.FALSE }, Utils.parseJSExpressions(getRowBGColorArgs())), false, null, true, null);
} catch (Exception ex) {
Debug.error(ex);
}
}
if (asInlineCssString) {
String bgColor = null;
if (c instanceof String)
bgColor = (String) c;
else if (c instanceof Color)
bgColor = PersistHelper.createColorString((Color) c);
if (bgColor != null)
color = new StringBuilder(CSS.Attribute.BACKGROUND_COLOR.toString()).append(':').append(color).append(';').toString();
}
}
}
return color;
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method createScriptEvent.
public JSDNDEvent createScriptEvent(EventType type, IComponent dragSource, Point xy, int modifiers) {
JSDNDEvent jsEvent = new JSDNDEvent();
jsEvent.setType(type);
jsEvent.setFormName(getDragFormName());
if (dragSource instanceof IDataRenderer) {
IDataRenderer dr = (IDataRenderer) dragSource;
FormController fct = dr.getDataAdapterList().getFormController();
jsEvent.setSource(fct.getFormScope());
} else {
jsEvent.setSource(dragSource);
if (dragSource != null) {
if (dragSource instanceof Component) {
WebCellBasedViewListItem listItem = ((Component) dragSource).findParent(WebCellBasedViewListItem.class);
if (listItem != null) {
IRecordInternal dragRecord = listItem.getModelObject();
if (dragRecord instanceof Record)
jsEvent.setRecord((Record) dragRecord);
}
}
String dragSourceName = dragSource.getName();
if (dragSourceName == null)
dragSourceName = dragSource.getId();
jsEvent.setElementName(dragSourceName);
}
}
if (xy != null)
jsEvent.setLocation(xy);
jsEvent.setModifiers(modifiers);
return jsEvent;
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class WebForm method getBounds.
public Rectangle getBounds(IComponent component) {
if (// $NON-NLS-1$
component instanceof Component && Utils.getAsBoolean(formController.getApplication().getRuntimeProperties().get("enableAnchors"))) {
IPersist persist = getPersist(((Component) component).getId());
if (persist instanceof ISupportAnchors && ((ISupportAnchors) persist).getAnchors() > 0 && ((ISupportAnchors) persist).getAnchors() != IAnchorConstants.DEFAULT) {
int anchors = ((ISupportAnchors) persist).getAnchors();
IDataRenderer renderer = ((Component) component).findParent(IDataRenderer.class);
int partHeight = 0;
if (renderer != null) {
partHeight = renderer.getSize().height;
}
int designWidth = formController.getForm().getWidth();
int designHeight = 0;
Part part = formController.getForm().getPartAt(((BaseComponent) persist).getLocation().y);
if (part != null) {
int top = formController.getForm().getPartStartYPos(part.getID());
designHeight = part.getHeight() - top;
}
if (partHeight > 0 && formWidth > 0 && designWidth > 0 && designHeight > 0) {
int navid = formController.getForm().getNavigatorID();
int navigatorWidth = 0;
if (navid == Form.NAVIGATOR_DEFAULT && formController.getForm().getView() != FormController.TABLE_VIEW && formController.getForm().getView() != FormController.LOCKED_TABLE_VIEW) {
navigatorWidth = WebDefaultRecordNavigator.DEFAULT_WIDTH;
} else if (navid != Form.NAVIGATOR_NONE) {
ISupportNavigator navigatorSupport = findParent(ISupportNavigator.class);
if (navigatorSupport != null) {
FormController currentNavFC = navigatorSupport.getNavigator();
if (currentNavFC != null) {
navigatorWidth = currentNavFC.getForm().getWidth();
}
}
}
Rectangle bounds = new Rectangle(component.getLocation(), component.getSize());
if ((anchors & IAnchorConstants.EAST) != 0 && (anchors & IAnchorConstants.WEST) == 0) {
bounds.x += formWidth - designWidth - navigatorWidth;
}
if ((anchors & IAnchorConstants.SOUTH) != 0 && (anchors & IAnchorConstants.NORTH) == 0) {
bounds.y += partHeight - designHeight;
}
if ((anchors & IAnchorConstants.EAST) != 0 && (anchors & IAnchorConstants.WEST) != 0 && (formWidth - designWidth - navigatorWidth > 0)) {
bounds.width += formWidth - designWidth - navigatorWidth;
}
if ((anchors & IAnchorConstants.SOUTH) != 0 && (anchors & IAnchorConstants.NORTH) != 0 && (partHeight - designHeight > 0)) {
bounds.height += partHeight - designHeight;
}
return bounds;
}
}
}
return null;
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class WebRuntimeWindow method getSizeAndLocation.
private Rectangle getSizeAndLocation(Rectangle r, IMainContainer container, final FormController fp) {
int navid = fp.getForm().getNavigatorID();
Dimension size = new Dimension(fp.getForm().getSize());
if (navid == Form.NAVIGATOR_DEFAULT && fp.getForm().getView() != FormController.TABLE_VIEW && fp.getForm().getView() != FormController.LOCKED_TABLE_VIEW) {
size.width += WebDefaultRecordNavigator.DEFAULT_WIDTH;
if (size.height < WebDefaultRecordNavigator.DEFAULT_HEIGHT_WEB)
size.height = WebDefaultRecordNavigator.DEFAULT_HEIGHT_WEB;
} else if (navid != Form.NAVIGATOR_NONE) {
FormController currentNavFC = container.getNavigator();
if (currentNavFC != null) {
size.width += currentNavFC.getForm().getSize().width;
int navHeight = currentNavFC.getForm().getSize().height;
if (size.height < navHeight)
size.height = navHeight;
}
}
// "div.wicket-modal div.w_right_1" brings 2px through "border" property (1px from left and 1px from right)
if (!isUndecorated())
size.width += 22;
Border b = fp.getFormUI().getBorder();
if (b != null) {
Insets bIns = ComponentFactoryHelper.getBorderInsetsForNoComponent(b);
size.height = size.height + bIns.top + bIns.bottom;
size.width = size.width + bIns.left + bIns.right;
}
Rectangle r2 = new Rectangle(size);
if (r != null) {
if (r.height > 0) {
r2.height = r.height;
}
if (r.width > 0) {
r2.width = r.width;
}
r2.x = r.x;
r2.y = r.y;
}
return r2;
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class WebDataRenderer method createScriptEvent.
private JSDNDEvent createScriptEvent(EventType type, IComponent dragSource, Point xy, int modifiers) {
JSDNDEvent jsEvent = new JSDNDEvent();
jsEvent.setType(type);
jsEvent.setFormName(getDragFormName());
IRecordInternal dragRecord = getDragRecord(xy);
if (dragRecord instanceof Record)
jsEvent.setRecord((Record) dragRecord);
if (dragSource instanceof IDataRenderer) {
IDataRenderer dr = (IDataRenderer) dragSource;
FormController fct = dr.getDataAdapterList().getFormController();
jsEvent.setSource(fct.getFormScope());
} else {
jsEvent.setSource(dragSource);
if (dragSource != null) {
String dragSourceName = dragSource.getName();
if (dragSourceName == null)
dragSourceName = dragSource.getId();
jsEvent.setElementName(dragSourceName);
}
}
if (xy != null)
jsEvent.setLocation(xy);
jsEvent.setModifiers(modifiers);
return jsEvent;
}
Aggregations