use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method onBeforeRender.
@Override
protected void onBeforeRender() {
if (dal == null || dal.isDestroyed()) {
// $NON-NLS-1$
Debug.error("Rendering tableview that is already destroyed," + findParent(WebForm.class));
}
isRendering = true;
hasOnRender = null;
IWebFormContainer tabPanel = findParent(IWebFormContainer.class);
Dimension tabSize = null;
if (tabPanel instanceof WebTabPanel) {
tabSize = ((WebTabPanel) tabPanel).getTabSize();
}
boolean canRenderView = true;
if (tableResizeBehavior != null && isAnchored) {
if (!getPath().equals(lastRenderedPath)) {
bodySizeHintSetFromClient = false;
tabSize = null;
lastRenderedPath = getPath();
}
// delay rendering table view (that can be big) if we
// just wait for the size response from the browser
canRenderView = bodySizeHintSetFromClient || tabSize != null;
if (!canRenderView) {
// force to get a response from the browser
bodyHeightHint = -1;
bodyWidthHint = -1;
}
if (headers != null)
headers.setVisible(canRenderView);
table.setVisible(canRenderView);
pagingNavigator.setVisible(canRenderView);
loadingInfo.setVisible(!canRenderView);
}
if (canRenderView) {
ArrayList<Component> oldVisibleColummIdentifierComponents = visibleColummIdentifierComponents;
visibleColummIdentifierComponents = getVisibleColummIdentifierComponents();
if (oldVisibleColummIdentifierComponents != null && !oldVisibleColummIdentifierComponents.equals(visibleColummIdentifierComponents)) {
distributeExtraSpace();
}
if (tabPanel != null) {
if (tabSize != null) {
bodyHeightHint = (int) tabSize.getHeight();
bodyHeightHint -= getOtherFormPartsHeight();
}
} else if (bodyHeightHint == -1) {
bodyHeightHint = ((WebClientInfo) RequestCycle.get().getSession().getClientInfo()).getProperties().getBrowserHeight();
bodyHeightHint -= getOtherFormPartsHeight();
}
if (isCurrentDataChanged) {
if (bodyHeightHint == -1)
bodyHeightHint = sizeHint;
isCurrentDataChanged = false;
}
if (bodyHeightHint != -1) {
int oldRowsPerPage = table.getRowsPerPage();
// if the design height of the BODY part is higher then the actual display area available for the BODY (table/list view)
// then use the design height; this allows a desired behavior (SVY-2943 - small area to display 1-2 rows + scrollbar for 3-4 more and then paging)
// you can still use only the available area and then use paging by designing table view forms with low body height
Pair<Boolean, Pair<Integer, Integer>> rowsCalculation = needsMoreThanOnePage(Math.max(bodyHeightHint, endY - startY));
maxRowsPerPage = rowsCalculation.getRight().getLeft().intValue();
// set headers width according to cell's width
setHeadersWidth();
if (isScrollMode()) {
if (isScrollFirstShow) {
table.setStartIndex(0);
table.setViewSize((int) (NEW_PAGE_MULITPLIER * maxRowsPerPage));
displayNoneUntilAfterRender = true;
isScrollFirstShow = false;
} else {
if (!hasBottomBuffer) {
int newRows = table.getList().size() - (table.getStartIndex() + table.getViewSize());
if (newRows > 0) {
table.setViewSize(table.getViewSize() + newRows);
}
}
}
} else {
table.setRowsPerPage(maxRowsPerPage);
int firstSelectedIndex = 0;
if (currentData != null) {
firstSelectedIndex = currentData.getSelectedIndex();
}
// if rowPerPage changed & the selected was visible, switch to the page so it remain visible
int currentPage = table.getCurrentPage();
if (maxRowsPerPage != oldRowsPerPage && currentPage * oldRowsPerPage <= firstSelectedIndex && (currentPage + 1) * oldRowsPerPage > firstSelectedIndex)
table.setCurrentPage(firstSelectedIndex < 1 ? 0 : firstSelectedIndex / maxRowsPerPage);
}
}
pagingNavigator.setVisible(!isScrollMode() && showPageNavigator && table.getPageCount() > 1);
}
selectedIndexes = null;
updateRowSelection(null);
if (!isListViewMode() && dataRendererOnRenderWrapper.getRenderEventExecutor().hasRenderCallback()) {
dataRendererOnRenderWrapper.getRenderEventExecutor().setRenderState(null, -1, false, false);
dataRendererOnRenderWrapper.getRenderEventExecutor().fireOnRender(false);
}
super.onBeforeRender();
if (isScrollMode()) {
selectionChanged = true;
javascriptForScrollBehaviorRenderHead = new StringBuilder();
scrollViewPort(new JSAppendTarget() {
@Override
public void appendJavascript(String javascript) {
javascriptForScrollBehaviorRenderHead.append(javascript);
}
@Override
public boolean isBeforeRender() {
return true;
}
});
}
}
use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class FlattenedSolution method getScopesPerSolution.
private Map<String, Pair<String, IRootObject>> getScopesPerSolution() {
if (mainSolution == null && loginFlattenedSolution != null) {
return loginFlattenedSolution.getScopesPerSolution();
}
Map<String, Pair<String, IRootObject>> scopes = new HashMap<String, Pair<String, IRootObject>>();
if (mainSolution != null) {
for (String scopeName : mainSolution.getScopeNames()) {
scopes.put(scopeName, new Pair<String, IRootObject>(scopeName, mainSolution));
}
if (modules != null) {
for (Solution s : modules) {
if (s != mainSolution) {
for (String scopeName : s.getScopeNames()) {
if (!scopes.containsKey(scopeName)) {
// TODO: check if same scope exists with different modules
scopes.put(scopeName, new Pair<String, IRootObject>(scopeName, s));
}
}
}
}
}
}
addGlobalsScope(scopes);
return scopes;
}
use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class TemplateGenerator method getStyles.
@SuppressWarnings("unchecked")
public static Pair<String, String>[] getStyles() throws RepositoryException, RemoteException {
List<Pair<String, String>> retval = new ArrayList<Pair<String, String>>();
IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
RootObjectMetaData[] styleMetaDatas = repository.getRootObjectMetaDatasForType(IRepository.STYLES);
if (styleMetaDatas != null) {
for (RootObjectMetaData styleMetaData : styleMetaDatas) {
retval.add(new Pair<String, String>(styleMetaData.getName(), getStyleCSS(styleMetaData.getName())));
}
}
return retval.toArray(new Pair[retval.size()]);
}
use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class TemplateGenerator method applyBaseComponentProperties.
protected static BorderAndPadding applyBaseComponentProperties(BaseComponent component, Form form, TextualStyle styleObj, Insets defaultPadding, Insets defaultBorder, IServiceProvider sp) {
Pair<IStyleSheet, IStyleRule> styleInfo = ComponentFactory.getStyleForBasicComponent(sp, component, form);
Insets insetsBorder = null;
Border designBorder = null;
if (component.getBorderType() != null) {
insetsBorder = ComponentFactoryHelper.createBorderCSSProperties(component.getBorderType(), styleObj);
designBorder = ComponentFactoryHelper.createBorder(component.getBorderType());
}
Insets insetsMargin = null;
if (component instanceof ISupportTextSetup) {
insetsMargin = ((ISupportTextSetup) component).getMargin();
}
if (styleInfo != null) {
IStyleSheet ss = styleInfo.getLeft();
IStyleRule s = styleInfo.getRight();
if (ss != null && s != null) {
List<String> attributeNames = s.getAttributeNames();
for (String s_attr : attributeNames) {
// Skip margin related attributes. Margin is computed separately below, and rendered as padding.
if (s_attr.toLowerCase().contains("margin"))
continue;
// do not add any border attributes if set on component
if (s_attr.toLowerCase().contains("border") && component.getBorderType() != null)
continue;
String val = s.getValue(s_attr);
if (s_attr.equals("font-size")) {
String tmp = val;
if (tmp.endsWith("px")) {
int size = Utils.getAsInteger(tmp.substring(0, tmp.length() - 2));
// 9 should be defined hard. Because 12 (1.33*9) is to big.
if (size == 9) {
size = 11;
} else {
size = (int) (size * (4 / (double) 3));
}
styleObj.setProperty(s_attr, size + "px");
} else {
int size = 0;
if (tmp.endsWith("pt")) {
size = Utils.getAsInteger(tmp.substring(0, tmp.length() - 2));
} else {
size = Utils.getAsInteger(tmp);
}
// 9 should be defined hard. Because 6 (0.75*9) is to small.
if (size == 9) {
size = 7;
} else {
size = (int) (size * (3 / (double) 4));
}
styleObj.setProperty(s_attr, size + "pt");
}
} else {
if (val.toString() != null)
styleObj.setProperty(s_attr, s.getValues(s_attr), false);
}
}
if (component.getBorderType() == null) {
if (ss.hasBorder(s)) {
Border b = ss.getBorder(s);
if (b != null) {
try {
insetsBorder = ComponentFactoryHelper.getBorderInsetsForNoComponent(b);
} catch (Exception e) {
Debug.error("for border " + b + " no insets could be extracted.", e);
}
TextualStyle borderStyle = new TextualStyle();
ComponentFactoryHelper.createBorderCSSProperties(ComponentFactoryHelper.createBorderString(b), borderStyle);
Enumeration<Object> cssAttributes = borderStyle.keys();
while (cssAttributes.hasMoreElements()) {
String att = (String) cssAttributes.nextElement();
// put the default values, if not all specified in css
styleObj.setProperty(att, borderStyle.getProperty(att), false);
}
}
}
}
if (insetsMargin == null) {
if (ss.hasMargin(s)) {
insetsMargin = ss.getMargin(s);
}
}
}
}
if (component.getFontType() != null) {
Pair<String, String>[] props = PersistHelper.createFontCSSProperties(component.getFontType());
if (props != null) {
for (Pair<String, String> element : props) {
if (element == null)
continue;
styleObj.setProperty(element.getLeft(), element.getRight());
}
}
}
if (component.getForeground() != null) {
styleObj.setProperty("color", PersistHelper.createColorString(component.getForeground()));
}
if (component.getTransparent()) {
styleObj.setProperty("background-color", IStyleSheet.COLOR_TRANSPARENT);
} else if (component.getBackground() != null) {
styleObj.setProperty("background-color", PersistHelper.createColorString(component.getBackground()));
}
if (insetsBorder == null)
insetsBorder = defaultBorder;
if (insetsMargin == null && defaultPadding != null)
insetsMargin = defaultPadding;
BorderAndPadding bp = new BorderAndPadding(insetsBorder, insetsMargin);
styleObj.setProperty("padding", (designBorder instanceof EmptyBorder && !(designBorder instanceof MatteBorder)) ? createInsetsText(bp.getSum()) : createInsetsText(bp.getPadding()));
return bp;
}
use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class NGClientWindow method getRealFormURLAndSeeIfItIsACopy.
protected Pair<String, Boolean> getRealFormURLAndSeeIfItIsACopy(Form form, String realFormName) {
FlattenedSolution fs = getSession().getClient().getFlattenedSolution();
Solution sc = fs.getSolutionCopy(false);
String realUrl = getDefaultFormURLStart(form, realFormName);
boolean copy = false;
if (sc != null && sc.getChild(form.getUUID()) != null) {
realUrl = realUrl + "?lm:" + form.getLastModified() + "&clientnr=" + getSession().getSessionKey().getClientnr();
copy = true;
} else if (!form.getName().endsWith(realFormName)) {
realUrl = realUrl + "?lm:" + form.getLastModified() + "&clientnr=" + getSession().getSessionKey().getClientnr();
} else {
realUrl = realUrl + "?clientnr=" + getSession().getSessionKey().getClientnr();
}
return new Pair<String, Boolean>(realUrl, Boolean.valueOf(copy));
}
Aggregations