Search in sources :

Example 1 with IForm

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

the class SessionClient method getContext.

private Pair<IRecordInternal, FormScope> getContext(String contextName) {
    try {
        String visibleFormName = contextName;
        String dataContext = null;
        if (contextName != null) {
            // $NON-NLS-1$
            StringTokenizer tk = new StringTokenizer(contextName, ".");
            String token = tk.nextToken();
            if (// $NON-NLS-1$
            token.equals("forms") && tk.hasMoreTokens()) {
                visibleFormName = tk.nextToken();
                if (tk.hasMoreTokens())
                    token = tk.nextToken();
            }
            if (// $NON-NLS-1$
            !token.equals("foundset")) {
                // todo why is this always also assigned to the datacontext?
                // shouldnt the above if be: if (token.equals("foundset") && st.hasMoreTokes()) dataContext == st.nextToken();
                // because now this data context will just be set to a form name if the contextName is just a form. (which in many cases it is defined like that)
                dataContext = token;
            }
        }
        if (visibleFormName == null) {
            IForm tmp = ((FormManager) getFormManager()).getCurrentForm();
            if (tmp != null)
                visibleFormName = tmp.getName();
        }
        if (visibleFormName != null) {
            // just overwrite the above assignment again if the datacontext is really also the form, so it wont be used later on.
            if (Utils.stringSafeEquals(visibleFormName, dataContext)) {
                dataContext = null;
            }
            FormController fp = ((FormManager) getFormManager()).leaseFormPanel(visibleFormName);
            if (!fp.isShowingData()) {
                if (fp.wantEmptyFoundSet()) {
                    if (fp.getFormModel() != null)
                        fp.getFormModel().clear();
                } else {
                    fp.loadAllRecords();
                }
            }
            IFoundSetInternal fs = fp.getFoundSet();
            if (fs != null) {
                int idx = fs.getSelectedIndex();
                if (idx < 0)
                    idx = 0;
                IRecordInternal r = fs.getRecord(idx);
                if (r != null) {
                    if (dataContext != null) {
                        IFoundSetInternal rfs = r.getRelatedFoundSet(dataContext);
                        // rfs can be null because dataContext can just be a anything see above
                        if (rfs != null) {
                            r = rfs.getRecord(rfs.getSelectedIndex());
                        }
                    }
                    return new Pair<IRecordInternal, FormScope>(r, fp.getFormScope());
                }
            }
            return new Pair<IRecordInternal, FormScope>(null, fp.getFormScope());
        }
    } catch (Exception e) {
        Debug.error(e);
    }
    return null;
}
Also used : FormController(com.servoy.j2db.FormController) IFormController(com.servoy.j2db.IFormController) StringTokenizer(java.util.StringTokenizer) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) FormManager(com.servoy.j2db.FormManager) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) IForm(com.servoy.j2db.IForm) ApplicationException(com.servoy.j2db.ApplicationException) RemoteException(java.rmi.RemoteException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ServoyException(com.servoy.j2db.util.ServoyException) IOException(java.io.IOException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) Pair(com.servoy.j2db.util.Pair)

Example 2 with IForm

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

the class FormCssResource method getResourceStream.

/**
 * @see org.apache.wicket.Resource#getResourceStream()
 */
@Override
public IResourceStream getResourceStream() {
    String css = "";
    ValueMap params = getParameters();
    Long time = null;
    if (params.size() == 1) {
        Iterator iterator = params.entrySet().iterator();
        if (iterator.hasNext()) {
            Map.Entry entry = (Entry) iterator.next();
            String solutionName = (String) entry.getKey();
            Pair<String, Long> filterTime = filterTime((String) entry.getValue());
            String formInstanceName = filterTime.getLeft();
            time = filterTime.getRight();
            // $NON-NLS-1$
            String solutionAndForm = solutionName + "/" + formInstanceName;
            // $NON-NLS-1$
            String templateDir = "default";
            IServiceProvider sp = null;
            Solution solution = null;
            Form form = null;
            if (Session.exists()) {
                sp = WebClientSession.get().getWebClient();
                if (sp != null) {
                    IForm fc = ((WebClient) sp).getFormManager().getForm(formInstanceName);
                    if (fc instanceof FormController) {
                        FlattenedSolution clientSolution = sp.getFlattenedSolution();
                        form = clientSolution.getForm(((FormController) fc).getForm().getName());
                    }
                }
                templateDir = WebClientSession.get().getTemplateDirectoryName();
            }
            final String fullpath = "/servoy-webclient/templates/" + templateDir + "/" + solutionAndForm + ".css";
            try {
                URL url = context.getResource(fullpath);
                if (url != null) {
                    return new NullUrlResourceStream(url);
                }
            } catch (Exception e) {
                Debug.error(e);
            }
            try {
                IApplicationServerSingleton as = ApplicationServerRegistry.get();
                RootObjectMetaData sd = as.getLocalRepository().getRootObjectMetaData(solutionName, IRepository.SOLUTIONS);
                if (sd != null) {
                    solution = (Solution) as.getLocalRepository().getActiveRootObject(sd.getRootObjectId());
                    if (form == null) {
                        form = solution.getForm(formInstanceName);
                    }
                }
                if (form != null) {
                    Pair<String, String> formHTMLAndCSS = TemplateGenerator.getFormHTMLAndCSS(solution, form, sp, formInstanceName);
                    css = formHTMLAndCSS.getRight();
                }
            } catch (Exception e) {
                Debug.error(e);
            }
        }
    }
    // $NON-NLS-1$
    StringResourceStream stream = new StringResourceStream(css, "text/css");
    stream.setLastModified(time != null ? Time.valueOf(time.longValue()) : null);
    return stream;
}
Also used : Entry(java.util.Map.Entry) FormController(com.servoy.j2db.FormController) RootObjectMetaData(com.servoy.j2db.persistence.RootObjectMetaData) IApplicationServerSingleton(com.servoy.j2db.server.shared.IApplicationServerSingleton) IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) ValueMap(org.apache.wicket.util.value.ValueMap) FlattenedSolution(com.servoy.j2db.FlattenedSolution) IForm(com.servoy.j2db.IForm) URL(java.net.URL) Entry(java.util.Map.Entry) IServiceProvider(com.servoy.j2db.IServiceProvider) Iterator(java.util.Iterator) StringResourceStream(org.apache.wicket.util.resource.StringResourceStream) Map(java.util.Map) ValueMap(org.apache.wicket.util.value.ValueMap) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Solution(com.servoy.j2db.persistence.Solution)

Example 3 with IForm

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

the class TemplateGenerator method getFormHTMLAndCSS.

public static Pair<String, String> getFormHTMLAndCSS(Solution solution, Form form, IServiceProvider sp, String formInstanceName) throws RepositoryException, RemoteException {
    if (form == null)
        return null;
    final IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
    boolean enableAnchoring = sp != null ? Utils.getAsBoolean(sp.getRuntimeProperties().get("enableAnchors")) : Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.webclient.enableAnchors", Boolean.TRUE.toString()));
    String overriddenStyleName = null;
    Pair<String, ArrayList<Pair<String, String>>> retval = formCache.getFormAndCssPair(form, formInstanceName, overriddenStyleName, repository);
    Form f = form;
    FlattenedSolution fsToClose = null;
    try {
        if (retval == null) {
            if (f.getExtendsID() > 0) {
                FlattenedSolution fs = sp == null ? null : sp.getFlattenedSolution();
                if (fs == null) {
                    try {
                        IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
                        fsToClose = fs = new FlattenedSolution(solution.getSolutionMetaData(), new AbstractActiveSolutionHandler(as) {

                            @Override
                            public IRepository getRepository() {
                                return repository;
                            }
                        });
                    } catch (RepositoryException e) {
                        Debug.error("Couldn't create flattened form for the template generator", e);
                    }
                }
                f = fs.getFlattenedForm(f);
                if (f == null) {
                    Debug.log("TemplateGenerator couldn't get a FlattenedForm for " + form + ", solution closed?");
                    f = form;
                }
            }
            StringBuffer html = new StringBuffer();
            TextualCSS css = new TextualCSS();
            IFormLayoutProvider layoutProvider = FormLayoutProviderFactory.getFormLayoutProvider(sp, solution, f, formInstanceName);
            int viewType = layoutProvider.getViewType();
            layoutProvider.renderOpenFormHTML(html, css);
            int startY = 0;
            Iterator<Part> parts = f.getParts();
            while (parts.hasNext()) {
                Part part = parts.next();
                int endY = part.getHeight();
                if (Part.rendersOnlyInPrint(part.getPartType())) {
                    startY = part.getHeight();
                    // is never shown (=printing only)
                    continue;
                }
                Color bgColor = ComponentFactory.getPartBackground(sp, part, f);
                if (part.getPartType() == Part.BODY && (viewType == FormController.TABLE_VIEW || viewType == FormController.LOCKED_TABLE_VIEW || viewType == IForm.LIST_VIEW || viewType == FormController.LOCKED_LIST_VIEW)) {
                    layoutProvider.renderOpenTableViewHTML(html, css, part);
                    // tableview == bodypart
                    createCellBasedView(f, f, html, css, layoutProvider.needsHeaders(), startY, endY, bgColor, sp, viewType, enableAnchoring, startY, endY);
                    layoutProvider.renderCloseTableViewHTML(html);
                } else {
                    layoutProvider.renderOpenPartHTML(html, css, part);
                    placePartElements(f, startY, endY, html, css, bgColor, enableAnchoring, sp);
                    layoutProvider.renderClosePartHTML(html, part);
                }
                startY = part.getHeight();
            }
            layoutProvider.renderCloseFormHTML(html);
            retval = new Pair<String, ArrayList<Pair<String, String>>>(html.toString(), css.getAsSelectorValuePairs());
            formCache.putFormAndCssPair(form, formInstanceName, overriddenStyleName, repository, retval);
        }
        Map<String, String> formIDToMarkupIDMap = null;
        if (sp instanceof IApplication) {
            Map runtimeProps = sp.getRuntimeProperties();
            Map<WebForm, Map<String, String>> clientFormsIDToMarkupIDMap = (Map<WebForm, Map<String, String>>) runtimeProps.get("WebFormIDToMarkupIDCache");
            if (clientFormsIDToMarkupIDMap == null) {
                clientFormsIDToMarkupIDMap = new WeakHashMap<WebForm, Map<String, String>>();
                runtimeProps.put("WebFormIDToMarkupIDCache", clientFormsIDToMarkupIDMap);
            }
            IForm wfc = ((IApplication) sp).getFormManager().getForm(formInstanceName);
            if (wfc instanceof FormController) {
                IFormUIInternal wf = ((FormController) wfc).getFormUI();
                if (wf instanceof WebForm) {
                    if (!((WebForm) wf).isUIRecreated())
                        formIDToMarkupIDMap = clientFormsIDToMarkupIDMap.get(wf);
                    if (formIDToMarkupIDMap == null) {
                        ArrayList<Pair<String, String>> formCSS = retval.getRight();
                        ArrayList<String> selectors = new ArrayList<String>(formCSS.size());
                        for (Pair<String, String> formCSSEntry : formCSS) selectors.add(formCSSEntry.getLeft());
                        formIDToMarkupIDMap = getWebFormIDToMarkupIDMap((WebForm) wf, selectors);
                        clientFormsIDToMarkupIDMap.put((WebForm) wf, formIDToMarkupIDMap);
                    }
                }
            }
        }
        String webFormCSS = getWebFormCSS(retval.getRight(), formIDToMarkupIDMap);
        // string the formcss/solutionname/ out of the url.
        webFormCSS = StripHTMLTagsConverter.convertMediaReferences(webFormCSS, solution.getName(), new ResourceReference("media"), "", false).toString();
        return new Pair<String, String>(retval.getLeft(), webFormCSS);
    } finally {
        if (fsToClose != null) {
            fsToClose.close(null);
        }
    }
}
Also used : IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) WebForm(com.servoy.j2db.server.headlessclient.WebForm) WebForm(com.servoy.j2db.server.headlessclient.WebForm) ArrayList(java.util.ArrayList) FlattenedSolution(com.servoy.j2db.FlattenedSolution) IForm(com.servoy.j2db.IForm) AbstractActiveSolutionHandler(com.servoy.j2db.AbstractActiveSolutionHandler) ResourceReference(org.apache.wicket.ResourceReference) IFormUIInternal(com.servoy.j2db.IFormUIInternal) Pair(com.servoy.j2db.util.Pair) FormController(com.servoy.j2db.FormController) Color(java.awt.Color) IApplicationServer(com.servoy.j2db.server.shared.IApplicationServer) RepositoryException(com.servoy.j2db.persistence.RepositoryException) Point(java.awt.Point) IApplication(com.servoy.j2db.IApplication) Part(com.servoy.j2db.persistence.Part) IRepository(com.servoy.j2db.persistence.IRepository) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) TreeMap(java.util.TreeMap)

Example 4 with IForm

use of com.servoy.j2db.IForm 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)

Example 5 with IForm

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

the class CmdManager method ableFormRelatedBrowseActions.

protected void ableFormRelatedBrowseActions(boolean enable) {
    FormManager fm = (FormManager) application.getFormManager();
    int view = FormController.LOCKED_LIST_VIEW;
    if (enable) {
        IForm formPanel = fm.getCurrentForm();
        if (formPanel != null) {
            view = formPanel.getView();
        }
    }
    // $NON-NLS-1$
    Action cmdviewasform = actions.get("cmdviewasform");
    if (cmdviewasform != null)
        cmdviewasform.setEnabled(view < 3);
    // $NON-NLS-1$
    Action cmdviewaslist = actions.get("cmdviewaslist");
    if (cmdviewaslist != null)
        cmdviewaslist.setEnabled(view < 3);
    if (fm instanceof SwingFormManager) {
        ((SwingFormManager) fm).enableCmds(enable);
    }
    // if plugins have added menus
    if (application.getImportMenu().getMenuComponents().length != 0) {
        // $NON-NLS-1$
        Action a = actions.get("menuimportaction");
        if (a != null)
            a.setEnabled(enable);
    }
    if (application.getExportMenu().getMenuComponents().length != 0) {
        // $NON-NLS-1$
        Action a = actions.get("menuexportaction");
        if (a != null)
            a.setEnabled(enable);
    }
}
Also used : Action(javax.swing.Action) SwingFormManager(com.servoy.j2db.smart.SwingFormManager) FormManager(com.servoy.j2db.FormManager) SwingFormManager(com.servoy.j2db.smart.SwingFormManager) IForm(com.servoy.j2db.IForm)

Aggregations

IForm (com.servoy.j2db.IForm)24 IFormManager (com.servoy.j2db.IFormManager)14 FormController (com.servoy.j2db.FormController)7 FormManager (com.servoy.j2db.FormManager)7 RepositoryException (com.servoy.j2db.persistence.RepositoryException)4 FlattenedSolution (com.servoy.j2db.FlattenedSolution)2 IScriptExecuter (com.servoy.j2db.IScriptExecuter)2 AbstractBase (com.servoy.j2db.persistence.AbstractBase)2 Form (com.servoy.j2db.persistence.Form)2 IDataProvider (com.servoy.j2db.persistence.IDataProvider)2 SwingFormManager (com.servoy.j2db.smart.SwingFormManager)2 IDisplayTagText (com.servoy.j2db.ui.IDisplayTagText)2 IStylePropertyChangesRecorder (com.servoy.j2db.ui.IStylePropertyChangesRecorder)2 RenderEventExecutor (com.servoy.j2db.ui.RenderEventExecutor)2 Pair (com.servoy.j2db.util.Pair)2 IOException (java.io.IOException)2 Map (java.util.Map)2 AbstractActiveSolutionHandler (com.servoy.j2db.AbstractActiveSolutionHandler)1 ApplicationException (com.servoy.j2db.ApplicationException)1 BasicFormController (com.servoy.j2db.BasicFormController)1