Search in sources :

Example 16 with Pair

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);
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) IFormComponentType(com.servoy.j2db.util.IFormComponentType) Pair(com.servoy.j2db.util.Pair)

Example 17 with Pair

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;
}
Also used : ISupportHTMLToolTipText(com.servoy.j2db.persistence.ISupportHTMLToolTipText) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod) JComponent(javax.swing.JComponent) Component(java.awt.Component) Font(java.awt.Font) Pair(com.servoy.j2db.util.Pair)

Example 18 with Pair

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];
}
Also used : ColumnInfo(com.servoy.j2db.persistence.ColumnInfo) IOException(java.io.IOException) IBaseColumn(com.servoy.base.persistence.IBaseColumn) Column(com.servoy.j2db.persistence.Column) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Pair(com.servoy.j2db.util.Pair)

Example 19 with Pair

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);
}
Also used : ISmartRuntimeWindow(com.servoy.j2db.plugins.ISmartRuntimeWindow) RuntimeWindow(com.servoy.j2db.scripting.RuntimeWindow) Window(java.awt.Window) JSWindow(com.servoy.j2db.scripting.JSWindow) FormWindow(com.servoy.j2db.FormWindow) FormDialog(com.servoy.j2db.gui.FormDialog) IMainContainer(com.servoy.j2db.IMainContainer) Pair(com.servoy.j2db.util.Pair)

Example 20 with Pair

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);
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) ClientInfo(org.apache.wicket.request.ClientInfo) Point(java.awt.Point) Pair(com.servoy.j2db.util.Pair)

Aggregations

Pair (com.servoy.j2db.util.Pair)29 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)11 Map (java.util.Map)8 List (java.util.List)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 SafeArrayList (com.servoy.j2db.util.SafeArrayList)6 Point (java.awt.Point)6 RepositoryException (com.servoy.j2db.persistence.RepositoryException)5 Collectors.toList (java.util.stream.Collectors.toList)5 FlattenedSolution (com.servoy.j2db.FlattenedSolution)4 CalculationDependencyData (com.servoy.j2db.dataprocessing.RowManager.RowFireNotifyChange.CalculationDependencyData)4 ConcurrentMap (java.util.concurrent.ConcurrentMap)4 PropertyDescription (org.sablo.specification.PropertyDescription)4 AbstractActiveSolutionHandler (com.servoy.j2db.AbstractActiveSolutionHandler)2 FormController (com.servoy.j2db.FormController)2 IForm (com.servoy.j2db.IForm)2 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)2 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)2 IRepository (com.servoy.j2db.persistence.IRepository)2