Search in sources :

Example 1 with IDisplayData

use of com.servoy.j2db.dataprocessing.IDisplayData in project servoy-client by Servoy.

the class WebCellAdapter method valueChanged.

public void valueChanged(ModificationEvent e) {
    MainPage mp = view.findParent(MainPage.class);
    if (mp != null)
        mp.touch();
    IRecord record = e.getRecord();
    Iterator iterator = ((MarkupContainer) view.getTable()).iterator();
    while (iterator.hasNext()) {
        Object next = iterator.next();
        if (next instanceof ListItem) {
            ListItem li = (ListItem) next;
            Object modelObject = li.getModelObject();
            if (record == null || modelObject == record) {
                boolean hasOnRender = false;
                Iterator iterator2 = li.iterator();
                while (iterator2.hasNext()) {
                    ArrayList<Object> cellDisplays = new ArrayList<Object>();
                    Object cell = iterator2.next();
                    cell = CellContainer.getContentsForCell((Component) cell);
                    if (cell instanceof WebCellBasedViewListViewItem) {
                        Iterator listItemIte = ((WebCellBasedViewListViewItem) cell).iterator();
                        while (listItemIte.hasNext()) {
                            Object listItemDisplay = listItemIte.next();
                            if (listItemDisplay instanceof WrapperContainer) {
                                listItemDisplay = ((WrapperContainer) listItemDisplay).getDelegate();
                            }
                            cellDisplays.add(listItemDisplay);
                        }
                    } else {
                        cellDisplays.add(cell);
                    }
                    for (Object cellDisplay : cellDisplays) {
                        if (cellDisplay instanceof IProviderStylePropertyChanges && cellDisplay instanceof IDisplayData && ((IDisplayData) cellDisplay).getDataProviderID() == dataprovider) {
                            // only test if it is not already changed
                            view.checkForValueChanges(cellDisplay);
                            // do fire on render on all components for record change
                            if (cellDisplay instanceof ISupportOnRender && cellDisplay instanceof IScriptableProvider) {
                                IScriptable so = ((IScriptableProvider) cellDisplay).getScriptObject();
                                if (so instanceof AbstractRuntimeRendersupportComponent && ((ISupportOnRenderCallback) so).getRenderEventExecutor().hasRenderCallback()) {
                                    String componentDataproviderID = ((AbstractRuntimeRendersupportComponent) so).getDataProviderID();
                                    if (record != null || (e.getName() != null && e.getName().equals(componentDataproviderID))) {
                                        ((ISupportOnRender) cellDisplay).fireOnRender(true);
                                        hasOnRender = true;
                                    }
                                }
                            }
                        }
                    }
                }
                if (record != null || (!hasOnRender && !canChangeValue(e)))
                    break;
            }
        }
    }
}
Also used : MarkupContainer(org.apache.wicket.MarkupContainer) ISupportOnRender(com.servoy.j2db.ui.ISupportOnRender) IRecord(com.servoy.j2db.dataprocessing.IRecord) ArrayList(java.util.ArrayList) AbstractRuntimeRendersupportComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) WebCellBasedViewListViewItem(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView.WebCellBasedViewListViewItem) IScriptable(com.servoy.j2db.scripting.IScriptable) WrapperContainer(com.servoy.j2db.server.headlessclient.WrapperContainer) Iterator(java.util.Iterator) IProviderStylePropertyChanges(com.servoy.j2db.ui.IProviderStylePropertyChanges) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) ListItem(org.apache.wicket.markup.html.list.ListItem) Component(org.apache.wicket.Component) AbstractRuntimeRendersupportComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 2 with IDisplayData

use of com.servoy.j2db.dataprocessing.IDisplayData in project servoy-client by Servoy.

the class ScrollResponseHeaderContainer method initializeComponent.

@SuppressWarnings("nls")
private void initializeComponent(final Component c, AbstractBase view, IPersist element) {
    if (dal != null && dal.isDestroyed()) {
        Debug.error("Trying to initialize a component: " + c + " of " + view + " element: " + element + " that is in a destroyed tableview", new RuntimeException());
        return;
    }
    if (// Don't know any other place for this
    view instanceof Portal && c instanceof IDisplayData) {
        String id = ((IDisplayData) c).getDataProviderID();
        if (id != null && !ScopesUtils.isVariableScope(id) && id.startsWith(((Portal) view).getRelationName() + '.')) {
            ((IDisplayData) c).setDataProviderID(id.substring(((Portal) cellview).getRelationName().length() + 1));
        }
    }
    if (!isListViewMode() && c instanceof WebDataCheckBox) {
        // $NON-NLS-1$
        ((WebDataCheckBox) c).setText("");
    }
    if (element != null) {
        // apply to this cell the state of the columnIdentifier IComponent, do keep the location that is set by the tableview when creating these components the first time.
        // for listview this is the location to use.
        Point loc = ((IComponent) c).getLocation();
        int height = ((IComponent) c).getSize().height;
        PropertyCopy.copyElementProps((IComponent) elementToColumnIdentifierComponent.get(element), (IComponent) c);
        if (!isListViewMode()) {
            ((IComponent) c).setLocation(loc);
            // it shouldn't be possible to change the height
            if (c instanceof IScriptableProvider) {
                IScriptable so = ((IScriptableProvider) c).getScriptObject();
                if (so instanceof IRuntimeComponent) {
                    IRuntimeComponent ic = (IRuntimeComponent) so;
                    if (ic.getHeight() != height) {
                        ic.setSize(ic.getWidth(), height);
                    }
                }
            }
        }
    } else {
        // $NON-NLS-1$
        Debug.log("Cannot find the IPersist element for cell " + c.getMarkupId());
    }
    if (c instanceof IDisplayData) {
        IDisplayData cdd = (IDisplayData) c;
        if (!(dal != null && dal.getFormScope() != null && cdd.getDataProviderID() != null && // skip for form variables
        dal.getFormScope().get(cdd.getDataProviderID()) != Scriptable.NOT_FOUND)) {
            cdd.setValidationEnabled(validationEnabled);
        }
    } else if (c instanceof IDisplayRelatedData) {
        ((IDisplayRelatedData) c).setValidationEnabled(validationEnabled);
    } else if (c instanceof IServoyAwareBean) {
        ((IServoyAwareBean) c).setValidationEnabled(validationEnabled);
    }
    addClassToCellComponent(c);
    if (// the check could be extended against IDelegate<?>
    c instanceof WebDataCompositeTextField) {
        Object delegate = ((WebDataCompositeTextField) c).getDelegate();
        if (delegate instanceof Component) {
            // make sure that this class is added accordingly in TemplateGenerator as a style selector containing relevant properties
            addClassToCellComponent((Component) delegate);
        }
    }
    if (c instanceof ISupportValueList) {
        ISupportValueList idVl = (ISupportValueList) elementToColumnIdentifierComponent.get(element);
        IValueList list;
        if (idVl != null && (list = idVl.getValueList()) != null) {
            ValueList valuelist = application.getFlattenedSolution().getValueList(list.getName());
            if (valuelist != null && valuelist.getValueListType() == IValueListConstants.CUSTOM_VALUES) {
                ((ISupportValueList) c).setValueList(list);
            }
        }
    }
    applyClientProperties(c, element);
}
Also used : ValueList(com.servoy.j2db.persistence.ValueList) DBValueList(com.servoy.j2db.dataprocessing.DBValueList) ISupportValueList(com.servoy.j2db.ui.ISupportValueList) IValueList(com.servoy.j2db.dataprocessing.IValueList) IComponent(com.servoy.j2db.ui.IComponent) ISupportValueList(com.servoy.j2db.ui.ISupportValueList) Point(java.awt.Point) Point(java.awt.Point) IScriptable(com.servoy.j2db.scripting.IScriptable) IDisplayRelatedData(com.servoy.j2db.dataprocessing.IDisplayRelatedData) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) Portal(com.servoy.j2db.persistence.Portal) RuntimePortal(com.servoy.j2db.ui.scripting.RuntimePortal) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IComponent(com.servoy.j2db.ui.IComponent) AbstractRuntimeBaseComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IPortalComponent(com.servoy.j2db.ui.IPortalComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IValueList(com.servoy.j2db.dataprocessing.IValueList)

Example 3 with IDisplayData

use of com.servoy.j2db.dataprocessing.IDisplayData in project servoy-client by Servoy.

the class ChangesRecorder method testChanged.

/**
 *  Helper method to see if the value is changed.
 *
 * @param component
 * @param value
 */
public void testChanged(Component component, Object value) {
    IModel model = component.getInnermostModel();
    if (model instanceof RecordItemModel) {
        Object o = ((RecordItemModel) model).getLastRenderedValue(component);
        Object displayV = value;
        if (component instanceof IResolveObject) {
            displayV = ((IResolveObject) component).resolveDisplayValue(value);
        }
        if (component instanceof IDisplayData && ((IDisplayData) component).getDataProviderID() == null) {
            // we don't have a mechanism to detect if the text has changed
            // both oldvalue and newvalue will always be null
            changed = true;
        } else if (!Utils.equalObjects(o, displayV)) {
            changed = true;
            valueChanged = true;
        }
    }
}
Also used : IModel(org.apache.wicket.model.IModel) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData)

Example 4 with IDisplayData

use of com.servoy.j2db.dataprocessing.IDisplayData in project servoy-client by Servoy.

the class WebDataRendererFactory method placeElements.

protected Map placeElements(IApplication app, Form form, IScriptExecuter listener, Map emptyDataRenderers, boolean printing, ControllerUndoManager undoManager, TabSequenceHelper<Component> tabSequence) throws Exception {
    // $NON-NLS-1$
    final boolean useAJAX = Utils.getAsBoolean(app.getRuntimeProperties().get("useAJAX"));
    IDataProviderLookup dataProviderLookup = app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), form);
    Map listTocomplete = new HashMap();
    Map labelForComponents = new HashMap();
    String orientation = OrientationApplier.getHTMLContainerOrientation(app.getLocale(), app.getSolution().getTextOrientation());
    // $NON-NLS-1$
    boolean leftToRight = !"rtl".equalsIgnoreCase(orientation);
    // $NON-NLS-1$
    boolean isAnchoringEnabled = Utils.getAsBoolean(app.getRuntimeProperties().get("enableAnchors"));
    // Insets insets = new Insets(0, 0, 0, 0);
    for (IFormElement obj : Utils.iterate(form.getFormElementsSortedByFormIndex())) {
        Point l = null;
        l = (obj).getLocation();
        // unknown where to add
        if (l == null)
            continue;
        if (printing && obj instanceof ISupportPrinting) {
            if (!((ISupportPrinting) obj).getPrintable())
                continue;
        }
        Iterator it = emptyDataRenderers.values().iterator();
        while (it.hasNext()) {
            WebDataRenderer panel = (WebDataRenderer) it.next();
            // Border border = panel.getBorder();
            // if (border instanceof EmptyBorder)
            // {
            // insets = ((EmptyBorder)border).getBorderInsets();
            // }
            int start = panel.getLocation().y;
            if (l.y >= start && l.y < start + panel.getSize().height) {
                org.apache.wicket.Component comp = (org.apache.wicket.Component) ComponentFactory.createComponent(app, form, obj, dataProviderLookup, listener, printing);
                if (comp != null) {
                    if (obj instanceof Field) {
                        String name = ((Field) obj).getName();
                        if (name != null && !"".equals(name)) {
                            labelForComponents.put(name, comp);
                        }
                    } else if (obj instanceof GraphicalComponent && (comp instanceof WebBaseLabel || comp instanceof WebBaseSubmitLink)) {
                        String labelFor = ((GraphicalComponent) obj).getLabelFor();
                        if (labelFor != null && !"".equals(labelFor)) {
                            labelForComponents.put(comp, labelFor);
                        }
                    }
                    if ((obj instanceof ISupportTabSeq) && (tabSequence != null)) {
                        tabSequence.add(panel, (ISupportTabSeq) obj, comp);
                    }
                    org.apache.wicket.Component newComp = comp;
                    if (newComp instanceof IDisplay) {
                        panel.addDisplayComponent(obj, (IDisplay) newComp);
                    } else if (newComp instanceof WebImageBeanHolder) {
                        WebImageBeanHolder wiBeanHolder = (WebImageBeanHolder) newComp;
                        Object bean = wiBeanHolder.getDelegate();
                        if (bean instanceof IServoyAwareBean) {
                            IServoyAwareBean ourBean = (IServoyAwareBean) bean;
                            panel.addDisplayComponent(obj, ourBean);
                        }
                    }
                    ((IComponent) comp).setLocation(new Point((l.x), (l.y - start)));
                    if (form.getOnRecordEditStartMethodID() > 0 && comp instanceof IFieldComponent) {
                        if (useAJAX && comp instanceof IDisplayData && ((IDisplayData) comp).getDataProviderID() != null && !ScopesUtils.isVariableScope(((IDisplayData) comp).getDataProviderID())) {
                            StartEditOnFocusGainedEventBehavior.addNewBehaviour(comp);
                        }
                    }
                    // - beans
                    if (isAnchoringEnabled && (((obj instanceof Field) && WebAnchoringHelper.needsWrapperDivForAnchoring((Field) obj)) || (obj instanceof Bean) || ((obj instanceof GraphicalComponent) && ComponentFactory.isButton((GraphicalComponent) obj)))) {
                        panel.add(WebAnchoringHelper.getWrapperComponent(comp, obj, start, panel.getSize(), leftToRight, false));
                    } else {
                        panel.add(comp);
                    }
                }
            }
        }
    }
    Iterator it = labelForComponents.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Entry) it.next();
        Object key = entry.getKey();
        if (key instanceof WebBaseLabel || key instanceof WebBaseSubmitLink) {
            IFieldComponent component = (IFieldComponent) labelForComponents.get(entry.getValue());
            if (component != null) {
                if (key instanceof WebBaseLabel) {
                    ((WebBaseLabel) entry.getKey()).setLabelFor(component);
                } else {
                    ((WebBaseSubmitLink) entry.getKey()).setLabelFor(component);
                }
                (component).addLabelFor((ILabel) entry.getKey());
                if (!component.isVisible()) {
                    component.setComponentVisible(component.isVisible());
                }
                if (!component.isEnabled()) {
                    component.setComponentEnabled(component.isEnabled());
                }
            }
        }
    }
    it = emptyDataRenderers.values().iterator();
    while (it.hasNext()) {
        WebDataRenderer panel = (WebDataRenderer) it.next();
        panel.createDataAdapter(app, dataProviderLookup, listener, undoManager);
    }
    return listTocomplete;
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) IComponent(com.servoy.j2db.ui.IComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) Bean(com.servoy.j2db.persistence.Bean) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) Field(com.servoy.j2db.persistence.Field) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) Entry(java.util.Map.Entry) Iterator(java.util.Iterator) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IComponent(com.servoy.j2db.ui.IComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) ISupportPrinting(com.servoy.j2db.persistence.ISupportPrinting) Component(org.apache.wicket.Component) IDisplay(com.servoy.j2db.dataprocessing.IDisplay) Point(java.awt.Point) Point(java.awt.Point) IFormElement(com.servoy.j2db.persistence.IFormElement) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) HashMap(java.util.HashMap) Map(java.util.Map) IDataProviderLookup(com.servoy.j2db.persistence.IDataProviderLookup)

Example 5 with IDisplayData

use of com.servoy.j2db.dataprocessing.IDisplayData in project servoy-client by Servoy.

the class ComponentFactory method createGraphicalComponent.

private static IComponent createGraphicalComponent(IApplication application, Form form, GraphicalComponent label, IScriptExecuter el, IDataProviderLookup dataProviderLookup) {
    int style_halign = -1;
    int style_valign = -1;
    int textTransform = 0;
    int mediaid = 0;
    Pair<IStyleSheet, IStyleRule> styleInfo = getStyleForBasicComponent(application, label, form);
    if (styleInfo != null) {
        IStyleSheet ss = styleInfo.getLeft();
        IStyleRule s = styleInfo.getRight();
        if (ss != null && s != null) {
            style_valign = ss.getVAlign(s);
            style_halign = ss.getHAlign(s);
            boolean parseMedia = true;
            // anything else then then the css through the templategenerator is used. (See TemplateGenerator.createGraphicalComponentHTML)
            if (application.getApplicationType() == IApplication.WEB_CLIENT) {
                parseMedia = s.getValue(CSS.Attribute.BACKGROUND_REPEAT.toString()) == null && s.getValue(CSS.Attribute.BACKGROUND_POSITION.toString()) == null;
            }
            if (parseMedia) {
                Object mediaUrl = s.getValue(CSS.Attribute.BACKGROUND_IMAGE.toString());
                if (mediaUrl != null && mediaUrl.toString() != null) {
                    String mediaUrlString = mediaUrl.toString();
                    int start = mediaUrlString.indexOf(MediaURLStreamHandler.MEDIA_URL_DEF);
                    if (start != -1) {
                        String name = mediaUrlString.substring(start + MediaURLStreamHandler.MEDIA_URL_DEF.length());
                        if (name.endsWith("')") || name.endsWith("\")"))
                            name = name.substring(0, name.length() - 2);
                        if (name.endsWith(")"))
                            name = name.substring(0, name.length() - 1);
                        Media media = application.getFlattenedSolution().getMedia(name);
                        if (media != null) {
                            mediaid = media.getID();
                        }
                    }
                }
            }
            String transform = s.getValue(CSS.Attribute.TEXT_TRANSFORM.toString());
            if (transform != null) {
                if ("uppercase".equals(transform)) {
                    textTransform = ILabel.UPPERCASE;
                } else if ("lowercase".equals(transform)) {
                    textTransform = ILabel.LOWERCASE;
                } else if ("capitalize".equals(transform)) {
                    textTransform = ILabel.CAPITALIZE;
                }
            }
        }
    }
    ILabel l;
    AbstractRuntimeLabel<? extends ILabel> scriptable;
    IStylePropertyChangesRecorder jsChangeRecorder = application.getItemFactory().createChangesRecorder();
    if (ComponentFactory.isButton(label)) {
        IButton button;
        if (label.getDataProviderID() == null && !label.getDisplaysTags()) {
            scriptable = new RuntimeScriptButton(jsChangeRecorder, application);
            button = application.getItemFactory().createScriptButton((RuntimeScriptButton) scriptable, getWebID(form, label));
        } else {
            scriptable = new RuntimeDataButton(jsChangeRecorder, application);
            button = application.getItemFactory().createDataButton((RuntimeDataButton) scriptable, getWebID(form, label));
            IDataProvider dp = null;
            try {
                dp = dataProviderLookup == null ? null : dataProviderLookup.getDataProvider(label.getDataProviderID());
            } catch (RepositoryException e) {
                Debug.error(e);
            }
            ((IDisplayData) button).setDataProviderID(dp == null ? label.getDataProviderID() : dp.getDataProviderID());
            ((IDisplayTagText) button).setTagText(application.getI18NMessageIfPrefixed(label.getText()));
            ((IDisplayData) button).setNeedEntireState(label.getDisplaysTags());
        }
        ((AbstractRuntimeButton<IButton>) scriptable).setComponent(button, label);
        button.setMediaOption(label.getMediaOptions());
        if (label.getRolloverImageMediaID() > 0) {
            try {
                button.setRolloverIcon(label.getRolloverImageMediaID());
                button.setRolloverEnabled(true);
            } catch (Exception ex) {
                Debug.error(ex);
            }
        }
        l = button;
    } else {
        if (label.getDataProviderID() == null && !label.getDisplaysTags()) {
            scriptable = new RuntimeScriptLabel(jsChangeRecorder, application);
            l = application.getItemFactory().createScriptLabel((RuntimeScriptLabel) scriptable, getWebID(form, label), (label.getOnActionMethodID() > 0));
        } else {
            scriptable = new RuntimeDataLabel(jsChangeRecorder, application);
            l = application.getItemFactory().createDataLabel((RuntimeDataLabel) scriptable, getWebID(form, label), (label.getOnActionMethodID() > 0));
            IDataProvider dp = null;
            try {
                dp = dataProviderLookup == null ? null : dataProviderLookup.getDataProvider(label.getDataProviderID());
            } catch (RepositoryException e) {
                Debug.error(e);
            }
            ((IDisplayData) l).setDataProviderID(dp == null ? label.getDataProviderID() : dp.getDataProviderID());
            ((IDisplayTagText) l).setTagText(application.getI18NMessageIfPrefixed(label.getText()));
            ((IDisplayData) l).setNeedEntireState(label.getDisplaysTags());
        }
        ((AbstractHTMLSubmitRuntimeLabel<ILabel>) scriptable).setComponent(l, label);
        l.setMediaOption(label.getMediaOptions());
        if (label.getRolloverImageMediaID() > 0) {
            try {
                l.setRolloverIcon(label.getRolloverImageMediaID());
            } catch (Exception ex) {
                Debug.error(ex);
            }
        }
    }
    String mnemonic = application.getI18NMessageIfPrefixed(label.getMnemonic());
    if (mnemonic != null && mnemonic.length() > 0) {
        l.setDisplayedMnemonic(mnemonic.charAt(0));
    }
    l.setTextTransform(textTransform);
    if (el != null && (label.getOnActionMethodID() > 0 || label.getOnDoubleClickMethodID() > 0 || label.getOnRightClickMethodID() > 0)) {
        l.addScriptExecuter(el);
        if (label.getOnActionMethodID() > 0)
            l.setActionCommand(Integer.toString(label.getOnActionMethodID()), Utils.parseJSExpressions(label.getFlattenedMethodArguments("onActionMethodID")));
        if (label.getOnDoubleClickMethodID() > 0)
            l.setDoubleClickCommand(Integer.toString(label.getOnDoubleClickMethodID()), Utils.parseJSExpressions(label.getFlattenedMethodArguments("onDoubleClickMethodID")));
        if (label.getOnRightClickMethodID() > 0)
            l.setRightClickCommand(Integer.toString(label.getOnRightClickMethodID()), Utils.parseJSExpressions(label.getFlattenedMethodArguments("onRightClickMethodID")));
    }
    if (label.getLabelFor() == null || (form.getView() != FormController.TABLE_VIEW && form.getView() != FormController.LOCKED_TABLE_VIEW)) {
        int onRenderMethodID = label.getOnRenderMethodID();
        AbstractBase onRenderPersist = label;
        if (onRenderMethodID <= 0) {
            onRenderMethodID = form.getOnRenderMethodID();
            onRenderPersist = form;
        }
        if (onRenderMethodID > 0) {
            RenderEventExecutor renderEventExecutor = scriptable.getRenderEventExecutor();
            renderEventExecutor.setRenderCallback(Integer.toString(onRenderMethodID), Utils.parseJSExpressions(onRenderPersist.getFlattenedMethodArguments("onRenderMethodID")));
            IForm rendererForm = application.getFormManager().getForm(form.getName());
            IScriptExecuter rendererScriptExecuter = rendererForm instanceof FormController ? ((FormController) rendererForm).getScriptExecuter() : null;
            renderEventExecutor.setRenderScriptExecuter(rendererScriptExecuter);
        }
    }
    l.setRotation(label.getRotation());
    l.setFocusPainted(label.getShowFocus());
    l.setCursor(Cursor.getPredefinedCursor(label.getRolloverCursor()));
    try {
        int halign = label.getHorizontalAlignment();
        if (halign != -1) {
            l.setHorizontalAlignment(halign);
        } else if (style_halign != -1) {
            l.setHorizontalAlignment(style_halign);
        }
    } catch (RuntimeException e) {
    // just ignore...Debug.error(e);
    }
    int valign = label.getVerticalAlignment();
    if (valign != -1) {
        l.setVerticalAlignment(valign);
    } else if (style_valign != -1) {
        l.setVerticalAlignment(style_valign);
    }
    try {
        if (!label.getDisplaysTags()) {
            l.setText(application.getI18NMessageIfPrefixed(label.getText()));
        }
    } catch (RuntimeException e1) {
    // ignore
    }
    l.setToolTipText(application.getI18NMessageIfPrefixed(label.getToolTipText()));
    if (label.getImageMediaID() > 0) {
        try {
            l.setMediaIcon(label.getImageMediaID());
        } catch (Exception e) {
            Debug.error(e);
        }
    } else if (mediaid > 0) {
        try {
            l.setMediaIcon(mediaid);
        } catch (Exception e) {
            Debug.error(e);
        }
    }
    if (label.getDataProviderID() != null) {
        scriptable.setComponentFormat(ComponentFormat.getComponentFormat(label.getFormat(), label.getDataProviderID(), dataProviderLookup, application));
    }
    applyBasicComponentProperties(application, l, label, styleInfo);
    Border border = null;
    Insets insets = null;
    if (label.getBorderType() != null) {
        border = ComponentFactoryHelper.createBorder(label.getBorderType());
    }
    if (label.getMargin() != null) {
        insets = label.getMargin();
    }
    if (styleInfo != null && (border == null || insets == null)) {
        IStyleSheet ss = styleInfo.getLeft();
        IStyleRule s = styleInfo.getRight();
        if (ss != null && s != null) {
            if (border == null && ss.hasBorder(s)) {
                border = ss.getBorder(s);
            }
            if (insets == null && ss.hasMargin(s)) {
                insets = ss.getMargin(s);
            }
        }
    }
    if (border != null && insets != null) {
        l.setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)));
    } else if (border == null && insets != null && l instanceof IButton) {
        ((IButton) l).setMargin(insets);
    } else // supports setMargin, then fake the margins through empty border. (issue 166391)
    if (border == null && insets != null) {
        l.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right));
    }
    if (l instanceof IAnchoredComponent) {
        ((IAnchoredComponent) l).setAnchors(label.getAnchors());
    }
    return l;
}
Also used : Insets(java.awt.Insets) ILabel(com.servoy.j2db.ui.ILabel) RuntimeDataLabel(com.servoy.j2db.ui.scripting.RuntimeDataLabel) IForm(com.servoy.j2db.IForm) IDataProvider(com.servoy.j2db.persistence.IDataProvider) RuntimeScriptButton(com.servoy.j2db.ui.scripting.RuntimeScriptButton) FormController(com.servoy.j2db.FormController) IStyleSheet(com.servoy.j2db.util.IStyleSheet) IScriptExecuter(com.servoy.j2db.IScriptExecuter) AbstractHTMLSubmitRuntimeLabel(com.servoy.j2db.ui.scripting.AbstractHTMLSubmitRuntimeLabel) RuntimeDataButton(com.servoy.j2db.ui.scripting.RuntimeDataButton) Media(com.servoy.j2db.persistence.Media) AbstractBase(com.servoy.j2db.persistence.AbstractBase) RuntimeScriptLabel(com.servoy.j2db.ui.scripting.RuntimeScriptLabel) RepositoryException(com.servoy.j2db.persistence.RepositoryException) JSONException(org.json.JSONException) IOException(java.io.IOException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) IAnchoredComponent(com.servoy.j2db.ui.IAnchoredComponent) IButton(com.servoy.j2db.ui.IButton) IStyleRule(com.servoy.j2db.util.IStyleRule) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) RenderEventExecutor(com.servoy.j2db.ui.RenderEventExecutor) AbstractRuntimeButton(com.servoy.j2db.ui.scripting.AbstractRuntimeButton) IStylePropertyChangesRecorder(com.servoy.j2db.ui.IStylePropertyChangesRecorder) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder) IDisplayTagText(com.servoy.j2db.ui.IDisplayTagText)

Aggregations

IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)24 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)8 IDisplay (com.servoy.j2db.dataprocessing.IDisplay)7 HashMap (java.util.HashMap)7 JComponent (javax.swing.JComponent)7 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)6 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)6 Point (java.awt.Point)6 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)5 IPersist (com.servoy.j2db.persistence.IPersist)5 IScriptable (com.servoy.j2db.scripting.IScriptable)5 IComponent (com.servoy.j2db.ui.IComponent)5 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)5 Component (java.awt.Component)5 EventObject (java.util.EventObject)5 Iterator (java.util.Iterator)5 Component (org.apache.wicket.Component)5 FindState (com.servoy.j2db.dataprocessing.FindState)4 IDisplayRelatedData (com.servoy.j2db.dataprocessing.IDisplayRelatedData)4 ISwingFoundSet (com.servoy.j2db.dataprocessing.ISwingFoundSet)4