use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class JSNGWebComponent method getPropertyDescriptionAndName.
private Pair<PropertyDescription, String> getPropertyDescriptionAndName(String propertyName, WebObjectSpecification spec) {
if (spec == null)
return new Pair<PropertyDescription, String>(null, propertyName);
String name = propertyName;
PropertyDescription pd = spec.getProperty(name);
if (pd == null) {
int i = name.indexOf('.');
if (i > 0) {
String firstPart = name.substring(0, i);
PropertyDescription property = spec.getProperty(firstPart);
if (property != null && property.getType() instanceof IFormComponentType) {
pd = property;
name = firstPart;
}
}
}
if (pd == null && spec.getHandler(name) != null)
pd = spec.getHandler(name).getAsPropertyDescription();
if (pd == null) {
// now try it if it is a more legacy name where the id is stripped from
pd = spec.getProperty(name + "ID");
if (pd != null)
name = name + "ID";
}
return new Pair<PropertyDescription, String>(pd, name);
}
use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class PropertyListCellRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
int align = LEFT;
Font f = normalFont;
// $NON-NLS-1$
String newvalue = "";
if (value != null)
newvalue = value.toString();
if (value instanceof ScriptMethod) {
newvalue = ((ScriptMethod) value).getDisplayName();
}
if (value instanceof Pair && ((Pair) value).getLeft() != null) {
newvalue = ((Pair) value).getLeft().toString();
}
if (// $NON-NLS-1$
newvalue != null && newvalue.startsWith("*")) {
newvalue = newvalue.substring(1);
f = boldFont;
align = CENTER;
} else {
f = normalFont;
align = LEFT;
}
Component c = super.getListCellRendererComponent(list, newvalue, index, isSelected, cellHasFocus);
if (showToolTips) {
if (value instanceof ISupportHTMLToolTipText) {
String html = ((ISupportHTMLToolTipText) value).toHTML();
if (!html.startsWith("<html>"))
html = "<html>" + html + "</html>";
((JComponent) c).setToolTipText(html);
} else {
((JComponent) c).setToolTipText(null);
}
}
if (normalFont == null) {
normalFont = c.getFont();
boldFont = normalFont.deriveFont(Font.BOLD);
f = normalFont;
}
c.setFont(f);
if (c instanceof JLabel) {
((JLabel) c).setHorizontalAlignment(align);
}
return c;
}
use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class SQLSheet method getColumnValidatorInfo.
public Pair<String, Map<String, String>> getColumnValidatorInfo(int columnIndex) {
if (validatorInfos == null) {
SQLDescription desc = sql.get(SELECT);
List<?> dataProviderIDsDilivery = desc.getDataProviderIDsDilivery();
@SuppressWarnings("unchecked") Pair<String, Map<String, String>>[] vis = new Pair[dataProviderIDsDilivery.size()];
int i = 0;
Iterator<?> it = dataProviderIDsDilivery.iterator();
while (it.hasNext()) {
String cdp = (String) it.next();
Column c = table.getColumn(cdp);
ColumnInfo ci = c.getColumnInfo();
if (ci != null && ci.getValidatorName() != null && ci.getValidatorName().trim().length() != 0) {
Map<String, String> parsedValidatorProperties = null;
try {
parsedValidatorProperties = ComponentFactory.parseJSonProperties(ci.getValidatorProperties());
} catch (IOException e) {
Debug.error(e);
}
vis[i] = new Pair<String, Map<String, String>>(ci.getValidatorName(), parsedValidatorProperties);
}
i++;
}
validatorInfos = vis;
}
return validatorInfos[columnIndex];
}
use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class SwingRuntimeWindow method createAndReparentDialogIfNeeded.
private Pair<Boolean, IMainContainer> createAndReparentDialogIfNeeded(FormManager fm, RuntimeWindow parentJSWindow, boolean windowModal) {
IMainContainer container = fm.getOrCreateMainContainer(windowName);
IMainContainer previousModalContainer = null;
FormDialog sfd = (FormDialog) wrappedWindow;
boolean reparented = false;
Object[] savedStatusForRecreate = null;
// make sure the dialog has the correct owner
if (sfd != null) {
Window formDialogOwner = sfd.getOwner();
Window owner = null;
if (parentJSWindow == null || parentJSWindow.getWrappedObject() == null) {
owner = getApplication().getMainApplicationFrame();
} else {
owner = (Window) parentJSWindow.getWrappedObject();
}
if ((owner != sfd) && !owner.equals(formDialogOwner)) {
// wrong owner... will create a new window and close/dispose old one
savedStatusForRecreate = saveWrappedWindowStatusForRecreate();
hide(true);
sfd.dispose();
sfd = null;
wrappedWindow = null;
reparented = true;
}
}
if (windowModal) {
previousModalContainer = fm.setModalDialogContainer(container);
}
boolean bringToFrontNeeded = false;
if (sfd == null) {
wrappedWindow = sfd = createFormDialog(parentJSWindow != null ? (Window) parentJSWindow.getWrappedObject() : null, windowModal, windowName);
createdNewWindow = true;
sfd.setResizable(resizable);
sfd.setMainContainer(container);
if (reparented) {
restoreWrappedWindowStatusAfterRecreate(savedStatusForRecreate);
}
} else if (sfd.isVisible()) {
bringToFrontNeeded = true;
}
return new Pair<Boolean, IMainContainer>(Boolean.valueOf(bringToFrontNeeded), previousModalContainer);
}
use of com.servoy.j2db.util.Pair in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method needsMoreThanOnePage.
/**
* Estimates if, for a given height, the table will need more than one page
* to display all data (and thus will need a page navigator).
*
* Returns:
* - a flag telling if more than one page is needed;
* - the number of max rows that fit in one page;
* - the total height in pixels used up by the table.
*/
private Pair<Boolean, Pair<Integer, Integer>> needsMoreThanOnePage(int height) {
int reservedHeight = 0;
if (addHeaders) {
// extra 20 == the header
reservedHeight = 20;
} else {
// iphone/mac issue (#185741)
ClientInfo webClientInfo = Session.get().getClientInfo();
if (webClientInfo instanceof WebClientInfo && ((WebClientInfo) webClientInfo).getProperties().isBrowserSafari()) {
reservedHeight = 5;
}
}
int totalRealHeight = reservedHeight + getOtherFormPartsHeight();
int maxRows = Math.max((height - reservedHeight) / maxHeight, 1);
// windows web clients does not return accurately the clientHeight property
if (maxHeight - ((height - reservedHeight) % maxHeight) < 2)
maxRows++;
boolean moreThanOnePage = currentData != null && currentData.getSize() > maxRows;
if (moreThanOnePage) {
// the page navigator
if (!isScrollMode())
reservedHeight += 20;
maxRows = Math.max((height - reservedHeight) / maxHeight, 1);
// windows web clients does not return accurately the clientHeight property
if (maxHeight - ((height - reservedHeight) % maxHeight) < 2)
maxRows++;
}
if (currentData != null)
totalRealHeight += Math.min(currentData.getSize(), maxRows) * maxHeight;
Pair<Integer, Integer> heights = new Pair<Integer, Integer>(new Integer(maxRows), new Integer(totalRealHeight));
return new Pair<Boolean, Pair<Integer, Integer>>(new Boolean(moreThanOnePage), heights);
}
Aggregations