use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class DebugNGClient method refreshPersists.
@Override
public void refreshPersists(Collection<IPersist> changes) {
if (isShutDown())
return;
// flush the solution model cache of the form element helper when there is a solution copy.
// so that FormComponents are recreated with the latest data once.
Solution solutionCopy = getFlattenedSolution().getSolutionCopy(false);
if (solutionCopy != null)
solutionCopy.setRuntimeProperty(FormElementHelper.SOLUTION_MODEL_CACHE, null);
Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
for (IFormController controller : scopesAndFormsToReload[1]) {
if (controller.getForm() instanceof FlattenedForm) {
FlattenedForm ff = (FlattenedForm) controller.getForm();
ff.reload();
}
}
boolean forcePageReload = false;
if (scopesAndFormsToReload[1] == null || scopesAndFormsToReload[1].size() < 1) {
for (IPersist persist : changes) {
// that one, can also have other css included, using the 'import' statement
if (persist instanceof Media && !PersistHelper.getOrderedStyleSheets(getFlattenedSolution()).isEmpty()) {
String name = ((Media) persist).getName().toLowerCase();
if (name.endsWith(".less") || name.endsWith(".css")) {
forcePageReload = true;
break;
}
}
}
}
refreshForms(scopesAndFormsToReload[1], forcePageReload);
for (IFormController controller : scopesAndFormsToReload[0]) {
controller.getFormScope().reload();
}
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class MobileFormLayout method getBodyElementsForRecordView.
public static List<ISupportBounds> getBodyElementsForRecordView(FlattenedSolution editingFlattenedSolution, Form flattenedForm) {
List<ISupportBounds> elements = new ArrayList<ISupportBounds>();
Set<String> groups = new HashSet<String>();
for (IPersist persist : flattenedForm.getAllObjectsAsList()) {
if (persist instanceof ISupportExtendsID && PersistHelper.isOverrideOrphanElement((ISupportExtendsID) persist)) {
// skip orphaned overrides
continue;
}
if (persist instanceof IFormElement && persist instanceof AbstractBase) {
String groupID = ((IFormElement) persist).getGroupID();
if (groupID == null) {
if (persist instanceof Portal && ((Portal) persist).isMobileInsetList()) {
// inset list
elements.add(((Portal) persist));
} else // tabpanel: list elements or navtab
if (((AbstractBase) persist).getCustomMobileProperty(IMobileProperties.HEADER_ITEM.propertyName) == null && ((AbstractBase) persist).getCustomMobileProperty(IMobileProperties.FOOTER_ITEM.propertyName) == null) {
// regular item
elements.add((ISupportBounds) (persist instanceof IFlattenedPersistWrapper ? ((IFlattenedPersistWrapper<?>) persist).getWrappedPersist() : persist));
}
} else if (groups.add(groupID)) {
elements.add(new FormElementGroup(groupID, editingFlattenedSolution, FlattenedForm.getWrappedForm(flattenedForm)));
}
}
}
// sort by y-position
Collections.sort(elements, PositionComparator.YX_BOUNDS_COMPARATOR);
return elements;
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class TemplateGenerator method createTabPanelHTML.
// private static void createTabHTML(Tab meta, StringBuffer html, TextualCSS css)
// {
// }
private static void createTabPanelHTML(TabPanel tabPanel, Form form, StringBuffer html, TextualCSS css, int startY, int endY, boolean enableAnchoring, IServiceProvider sp) {
TextualStyle styleObj = css.addStyle('#' + ComponentFactory.getWebID(form, tabPanel));
BorderAndPadding borderAndPadding = applyBaseComponentProperties(tabPanel, form, styleObj, null, null, sp);
applyLocationAndSize(tabPanel, styleObj, borderAndPadding, startY, endY, form.getSize().width, enableAnchoring, tabPanel.getAnchors(), sp);
boolean isSplitPane = tabPanel.getTabOrientation() == TabPanel.SPLIT_HORIZONTAL || tabPanel.getTabOrientation() == TabPanel.SPLIT_VERTICAL;
// do not apply foreground to the whole tab panel
styleObj.remove("color");
// html.append("<table cellpadding=0 cellspacing=0 ");
html.append("<div ");
html.append(getWicketIDParameter(form, tabPanel));
String tabPanelCssClass = "tabpanel";
if (!tabPanel.getTransparent())
tabPanelCssClass = "opaquecontainer " + tabPanelCssClass;
boolean[] userCssClassAdded = new boolean[] { false };
html.append(getCssClassForElement(tabPanel, userCssClassAdded, tabPanelCssClass));
if (isSplitPane)
html.append(" style='overflow: hidden;' ");
html.append(">\n");
boolean isTabbedTabPanel = false;
// int yoffset = 0;
if (tabPanel.getTabOrientation() != TabPanel.HIDE && tabPanel.getTabOrientation() != TabPanel.ACCORDION_PANEL && !isSplitPane && !(tabPanel.getTabOrientation() == TabPanel.DEFAULT_ORIENTATION && tabPanel.hasOneTab())) {
// yoffset = 20;
// html.append("\t<thead><tr valign='bottom'><th height=20>\n");
isTabbedTabPanel = true;
html.append("\t<div tabholder='true' class='tabs'>\n");
html.append("\t<servoy:remove>\n");
html.append("\t\t<div class='selected_tab'><a href='tab1'>Tab1</a></div>\n");
html.append("\t\t<div><a href='tab1'>Tab2</a></div>\n");
html.append("\t</servoy:remove>\n");
Iterator<IPersist> it = tabPanel.getAllObjects();
if (it.hasNext()) {
Tab tab = (Tab) it.next();
// applyTextProperties(tab, styleObj);
html.append("\t\t<div servoy:id='tablinks'");
html.append("><a servoy:id='tablink' href='tab1' class='tablink'><div servoy:id='icon'></div><span style=\"white-space: nowrap;\" servoy:id='linktext'>");
html.append(getSafeText(tab.getText()));
html.append("</span></a></div>\n");
} else {
html.append("\t\t<div servoy:id='tablinks'");
html.append("><a servoy:id='tablink' href='tab1' class='tablink'><div servoy:id='icon'></div><span style=\"white-space: nowrap;\" servoy:id='linktext'>");
html.append("No tabs");
html.append("</span></a></div>\n");
}
html.append("\t</div>\n");
// html.append("\t</th></tr></thead>\n");
}
// html.append("\t<tbody><tr><td>\n");
// Insets ins = borderAndPadding != null ? borderAndPadding.getSum() : new Insets(0, 0, 0, 0);
// int t_width = tabPanel.getSize().width - (ins.left + ins.right + 2); //not sure why to add 2
// int t_height = (tabPanel.getSize().height - yoffset) - (ins.top + ins.bottom + 4); //not sure why to add 4
TextualStyle style = new TextualStyle();
style.setProperty("overflow", "auto");
style.setProperty("position", "relative");
// style.setProperty("height",t_height+"px");
if (tabPanel.getBorderType() != null) {
ComponentFactoryHelper.createBorderCSSProperties(tabPanel.getBorderType(), styleObj);
}
if (tabPanel.getTabOrientation() == TabPanel.ACCORDION_PANEL) {
for (Attribute att : ServoyStyleSheet.fontAttributes) {
styleObj.remove(att.toString());
}
int alignment = ISupportTextSetup.LEFT;
String styleAlignment = null;
if (tabPanel.getHorizontalAlignment() >= 0) {
alignment = tabPanel.getHorizontalAlignment();
} else if (styleObj.containsKey(CSS.Attribute.TEXT_ALIGN.toString())) {
styleAlignment = (String) styleObj.get(CSS.Attribute.TEXT_ALIGN.toString());
}
if (styleAlignment == null) {
styleAlignment = getHorizontalAlignValue(alignment);
}
styleObj.remove(CSS.Attribute.TEXT_ALIGN.toString());
String tabPanelMarkupId = ComponentFactory.getWebID(form, tabPanel);
Iterator<IPersist> it = tabPanel.getAllObjects();
String text = "";
if (it.hasNext()) {
Tab tab = (Tab) it.next();
text = tab.getText();
}
html.append("\t\t<div id='accordion_").append(tabPanelMarkupId).append("'servoy:id='accordion_").append(tabPanelMarkupId).append("'><div servoy:id='tabs'");
html.append("><h3 style='text-align:");
html.append(styleAlignment);
html.append(";' onclick='this.getElementsByTagName(\"a\")[0].click()'><a servoy:id='tablink' href='#'><div servoy:id='icon'></div><span style=\"white-space: nowrap;\" servoy:id='linktext'>");
html.append(getSafeText(text));
html.append("</span></a></h3><div servoy:id='webform' ");
// html.append(getCSSClassParameter("webform"));
html.append("></div></div></div>\n");
} else if (isSplitPane) {
String tabPanelMarkupId = ComponentFactory.getWebID(form, tabPanel);
StringBuffer leftPanelStyle = new StringBuffer("position: absolute; ");
StringBuffer rightPanelStyle = new StringBuffer("position: absolute; ");
if (tabPanel.getTabOrientation() == TabPanel.SPLIT_HORIZONTAL) {
leftPanelStyle.append("top: 0px; left: 0px; bottom: 0px;");
rightPanelStyle.append("top: 0px; bottom: 0px; right: 0px");
} else {
leftPanelStyle.append("top: 0px; left: 0px; right: 0px;");
rightPanelStyle.append("left: 0px; bottom: 0px; right: 0px;");
}
// $NON-NLS-1$ //$NON-NLS-2$
html.append("\t<div id='splitter_").append(tabPanelMarkupId).append("' servoy:id='splitter' style='").append(leftPanelStyle).append("'><div id='websplit_left_").append(tabPanelMarkupId).append("' servoy:id='websplit_left' style='").append(leftPanelStyle).append(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"' ").append("><div servoy:id='webform'").append(getCSSClassParameter("webform")).append(// $NON-NLS-1$
"></div></div></div>");
// $NON-NLS-1$//$NON-NLS-2$
html.append("<div id='websplit_right_").append(tabPanelMarkupId).append("' servoy:id='websplit_right' style='").append(rightPanelStyle).append(// $NON-NLS-1$
"' ").append("><div servoy:id='webform'").append(getCSSClassParameter("webform")).append(// $NON-NLS-1$
"></div></div>");
} else {
html.append("\t<div servoy:id='webform' ").append(style.toString());
String cssClass = "webform";
boolean tabPanelHasBorder = tabPanel.getBorderType() != null || styleObj.containsKey(CSS.Attribute.BORDER_STYLE.toString());
if (isTabbedTabPanel && !tabPanelHasBorder) {
// apply default border
cssClass = "tabcontainer " + cssClass;
}
html.append(getCSSClassParameter(cssClass));
html.append("></div>");
}
html.append("</div>");
// html.append("</td></tr></tbody></table>");
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class TemplateGenerator method createGraphicalComponentHTML.
private static void createGraphicalComponentHTML(GraphicalComponent label, Form form, StringBuffer html, TextualCSS css, int startY, int endY, boolean enableAnchoring, IServiceProvider sp) {
String styleName = "#";
Insets border = null;
if (ComponentFactory.isButton(label) && !hasHTMLText(label.getText())) {
// styleName = "input.";
border = DEFAULT_BUTTON_BORDER_SIZE;
}
TextualStyle styleObj = css.addStyle(styleName + ComponentFactory.getWebID(form, label));
BorderAndPadding ins = applyBaseComponentProperties(label, form, styleObj, (Insets) DEFAULT_LABEL_PADDING.clone(), border, sp);
// fix the background img, see ComponentFactory.createGraphicalComponent
// background image through css will only be used when repeat or position are set (or linear gradient is used).
// if both are not specified then it is used as the MEDIA of the label/button, so bck_img is removed from the css.
boolean keepBgImageStyle = false;
for (String attribute : ServoyStyleSheet.BACKGROUND_IMAGE_CSS) {
if (attribute.equals(CSS.Attribute.BACKGROUND_IMAGE.toString())) {
if (styleObj.getProperty(attribute) == null) {
keepBgImageStyle = false;
break;
} else if (!styleObj.getProperty(attribute).contains(MediaURLStreamHandler.MEDIA_URL_DEF)) {
keepBgImageStyle = true;
break;
}
} else if (styleObj.getProperty(attribute) != null) {
keepBgImageStyle = true;
break;
}
}
if (!keepBgImageStyle) {
styleObj.remove(CSS.Attribute.BACKGROUND_IMAGE.toString());
}
applyTextProperties(label, styleObj);
Field labelForField = null;
String labelFor = label.getLabelFor();
if (labelFor != null) {
Iterator<IPersist> fields = form.getObjects(IRepository.FIELDS);
while (fields.hasNext()) {
Field fld = (Field) fields.next();
if (labelFor.equals(fld.getName())) {
labelForField = fld;
break;
}
}
}
int labelHAlign = label.getHorizontalAlignment();
int labelVAlign = label.getVerticalAlignment();
Pair<IStyleSheet, IStyleRule> styleInfo = ComponentFactory.getStyleForBasicComponent(sp, label, form);
if (styleInfo != null) {
IStyleSheet ss = styleInfo.getLeft();
IStyleRule s = styleInfo.getRight();
if (labelHAlign == -1)
labelHAlign = ss.getHAlign(s);
if (labelVAlign == -1)
labelVAlign = ss.getVAlign(s);
}
// Defaults are mapped to CENTER (or MIDDLE for vertical) to keep behavior from Smart client.
if (labelHAlign == -1)
labelHAlign = ISupportTextSetup.CENTER;
if (labelVAlign == -1)
labelVAlign = ISupportTextSetup.CENTER;
boolean isButton = ComponentFactory.isButton(label);
boolean[] userCssClassAdded = new boolean[] { false };
TextualStyle wrapperStyle = null;
Properties minSizeStyle = styleObj;
if (isButton && enableAnchoring) {
// Anchoring <button> with { left: 0px; right: 0px; } pair
// or { top: 0px; bottom: 0px; } does not work. Thus we add a dummy wrapper <div>
// which accepts this kind of anchoring, and we place the button inside the <div>
// with { width: 100%; height: 100%; }, which works fine.
String wrapperId = ComponentFactory.getWebID(form, label) + WRAPPER_SUFFIX;
wrapperStyle = css.addStyle(styleName + wrapperId);
minSizeStyle = wrapperStyle;
html.append("<div ");
html.append(getCssClassForElement(label, userCssClassAdded, ""));
html.append(getWicketIDParameter(form, label, "", WRAPPER_SUFFIX));
html.append(getJavaScriptIDParameter(form, label, "", WRAPPER_SUFFIX));
html.append(">");
}
Insets buttonBorder = null;
if (isButton) {
html.append("<button type='submit' ");
html.append(" style=\"white-space: nowrap;\" ");
html.append(getWicketIDParameter(form, label));
html.append(getDataProviderIDParameter(label));
html.append(getCssClassForElement(label, userCssClassAdded, "button"));
html.append(">");
html.append("</button>");
// buttons are border-box by default!!
buttonBorder = ins.getBorder();
ins = null;
} else {
if (labelForField != null) {
html.append("<label ");
// Needed for FF to accept a <div> inside a <label>.
styleObj.setProperty("display", "block");
} else {
html.append("<div ");
}
// we want to wrap only if there is no html content in the label text
if (label.getText() != null && !HtmlUtils.hasUsefulHtmlContent(label.getText())) {
html.append(" style=\"white-space: nowrap;\"");
}
html.append(getWicketIDParameter(form, label));
html.append(getDataProviderIDParameter(label));
html.append(getCssClassForElement(label, userCssClassAdded, "label"));
html.append('>');
boolean hasHtml = hasHTMLText(label.getText());
if (hasHtml && (label.getOnActionMethodID() != 0)) {
html.append("<servoy:remove>");
}
html.append(getSafeText(label.getText()));
if (hasHtml && (label.getOnActionMethodID() != 0)) {
html.append("</servoy:remove>");
}
if (labelForField != null) {
html.append("</label>");
} else {
html.append("</div>");
}
if (label.getOnActionMethodID() > 0)
styleObj.setProperty("cursor", "pointer");
}
Insets borderAndPadding = ins == null ? new Insets(0, 0, 0, 0) : ins.getSum();
WebAnchoringHelper.addMinSize(label.getAnchors(), sp, minSizeStyle, new Dimension(label.getSize().width - borderAndPadding.left - borderAndPadding.right, label.getSize().height - borderAndPadding.top - borderAndPadding.bottom), label);
if (isButton && enableAnchoring) {
html.append("</div>");
styleObj.setProperty("width", "100%");
styleObj.setProperty("height", "100%");
styleObj.setProperty("position", "absolute");
applyLocationAndSize(label, wrapperStyle, ins, startY, endY, form.getSize().width, enableAnchoring, isListViewBodyElement(form, label.getLocation()) ? new Point(-3, 0) : null);
} else {
applyLocationAndSize(label, styleObj, ins, startY, endY, form.getSize().width, enableAnchoring, isListViewBodyElement(form, label.getLocation()) ? new Point(-3, 0) : null);
}
if (label.getRolloverCursor() == Cursor.HAND_CURSOR) {
styleObj.setProperty("cursor", "pointer");
}
int height = label.getSize().height;
// See: http://doctype.com/html-button-tag-renders-strangely-firefox
if (isButton) {
int bottomPadding = 0;
if (labelVAlign != ISupportTextSetup.CENTER) {
bottomPadding = height;
if (buttonBorder != null)
bottomPadding -= buttonBorder.top + buttonBorder.bottom;
}
styleObj.setProperty("padding-bottom", bottomPadding + "px");
}
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class WebCellAdapter method isDBDataprovider.
private boolean isDBDataprovider() {
if (isDBDataproviderObj == null) {
isDBDataproviderObj = Boolean.FALSE;
ITable table = view.getDataAdapterList().getFormController().getTable();
if (table instanceof Table) {
Table tableObj = (Table) table;
Iterator<Column> columns = tableObj.getColumns().iterator();
while (columns.hasNext()) {
Column col = columns.next();
ColumnInfo ci = col.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
if (col.getDataProviderID() == dataprovider) {
isDBDataproviderObj = Boolean.TRUE;
break;
}
}
Iterator<TableNode> tableNodes = view.getDataAdapterList().getApplication().getFlattenedSolution().getTableNodes(table);
while (tableNodes.hasNext()) {
TableNode tableNode = tableNodes.next();
if (tableNode != null) {
Iterator<IPersist> it2 = tableNode.getAllObjects();
while (it2.hasNext()) {
IPersist persist = it2.next();
if (persist instanceof IDataProvider && (((IDataProvider) persist).getDataProviderID() == dataprovider)) {
isDBDataproviderObj = Boolean.FALSE;
}
}
}
}
}
}
return isDBDataproviderObj.booleanValue();
}
Aggregations