Search in sources :

Example 16 with FormManager

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

the class WebDataListBox method fireOnRender.

public void fireOnRender(boolean force) {
    if (scriptable != null) {
        boolean isFocused = false;
        IMainContainer currentContainer = ((FormManager) application.getFormManager()).getCurrentContainer();
        if (currentContainer instanceof MainPage) {
            isFocused = this.equals(((MainPage) currentContainer).getFocusedComponent());
        }
        if (force)
            scriptable.getRenderEventExecutor().setRenderStateChanged();
        scriptable.getRenderEventExecutor().fireOnRender(isFocused);
    }
}
Also used : FormManager(com.servoy.j2db.FormManager) IMainContainer(com.servoy.j2db.IMainContainer) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 17 with FormManager

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

the class WebTabFormLookup method getWebForm.

private WebForm getWebForm(boolean removeFromParent) {
    if (webForm != null && webForm.isDestroyed()) {
        webForm = null;
    }
    if (webForm == null) {
        FormManager fm = (FormManager) application.getFormManager();
        FormController fc = fm.getFormController(formName, this);
        if (fc == null) {
            fc = fm.leaseFormPanel(formName);
        }
        if (fc != null) {
            // delegate readOnly, really set it once from the form manager state
            fc.setReadOnly(fm.isFormReadOnly(formName));
            webForm = (WebForm) fc.getFormUI();
            if (removeFromParent && webForm.getParent() != null && webForm.getParent() != parent) {
                webForm.remove();
            }
        }
    }
    return webForm;
}
Also used : FormController(com.servoy.j2db.FormController) FormManager(com.servoy.j2db.FormManager)

Example 18 with FormManager

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

the class ComponentFactory method createBean.

protected static IComponent createBean(IApplication application, Form form, Bean bean, FlattenedSolution flattenedSolution) {
    IComponent c = null;
    try {
        Object obj = getBeanInstanceFromXML(application, bean.getBeanClassName(), bean.getBeanXML());
        if (flattenedSolution != null && obj != null) {
            obj = flattenedSolution.setBeanDesignInstance(bean, obj);
        }
        if (obj instanceof Component) {
            ((Component) obj).setName(bean.getName());
        } else if (obj instanceof IComponent) {
            ((IComponent) obj).setName(bean.getName());
        }
        if (obj instanceof IServoyAwareBean) {
            ((IServoyAwareBean) obj).initialize((IClientPluginAccess) application.getPluginAccess());
        }
        if (obj instanceof IServoyBeanFactory) {
            testReturnTypesForBean(application, obj);
            obj = ((IServoyBeanFactory) obj).getBeanInstance(application.getApplicationType(), (IClientPluginAccess) application.getPluginAccess(), new Object[] { ComponentFactory.getWebID(form, bean), form.getName(), form.getStyleName() });
        }
        testReturnTypesForBean(application, obj);
        if (obj instanceof Applet) {
            ((FormManager) application.getFormManager()).initializeApplet((Applet) obj, bean.getSize());
        }
        if (obj == null) {
            c = application.getItemFactory().createLabel(ComponentFactory.getWebID(form, bean), "bean missing " + bean.getBeanClassName());
        } else if (!(obj instanceof java.awt.Component) && !(obj instanceof IComponent)) {
            c = application.getItemFactory().createInvisibleBean(ComponentFactory.getWebID(form, bean), obj);
        } else if (!(obj instanceof IComponent)) {
            c = application.getItemFactory().createBeanHolder(ComponentFactory.getWebID(form, bean), (Component) obj, bean.getAnchors());
        } else {
            c = (IComponent) obj;
        }
        // beans do not store the transparent property, keep the value from component
        boolean isOpaque = c.isOpaque();
        applyBasicComponentProperties(application, c, bean, null);
        c.setOpaque(isOpaque);
    } catch (// sometimes setting size or location throws exception or even error...create label instead
    Throwable e) {
        Debug.error(e);
        c = application.getItemFactory().createLabel(bean.getName(), "error acessing bean" + bean.getBeanClassName());
        java.awt.Dimension dim = bean.getSize();
        if (dim != null)
            c.setSize(bean.getSize());
    }
    return c;
}
Also used : IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) IServoyBeanFactory(com.servoy.j2db.IServoyBeanFactory) Applet(java.applet.Applet) FormManager(com.servoy.j2db.FormManager) IComponent(com.servoy.j2db.ui.IComponent) IClientPluginAccess(com.servoy.j2db.plugins.IClientPluginAccess) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) Dimension(java.awt.Dimension) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) AbstractRuntimeValuelistComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeValuelistComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) IFormatScriptComponent(com.servoy.j2db.ui.scripting.IFormatScriptComponent) IAnchoredComponent(com.servoy.j2db.ui.IAnchoredComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) WebComponent(com.servoy.j2db.persistence.WebComponent) IPortalComponent(com.servoy.j2db.ui.IPortalComponent) JComponent(javax.swing.JComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent)

Example 19 with FormManager

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

the class DataProviderEditor method fillDataProviderList.

protected void fillDataProviderList() {
    try {
        ITable table = null;
        if (definedTable == null) {
            FormManager fm = (FormManager) application.getFormManager();
            FormController fc = fm.getCurrentMainShowingFormController();
            if (fc != null) {
                Form form = fc.getForm();
                table = application.getFlattenedSolution().getTable(form.getDataSource());
            }
        } else {
            if (!showRelatedOptionsOnly)
                table = definedTable;
        }
        DefaultListModel model = (DefaultListModel) list.getModel();
        model.removeAllElements();
        if (showNoneOption)
            model.addElement("-none-");
        if (!showColumnsOnly)
            model.addElement("*columns");
        Object o = relationsComboBox.getSelectedItem();
        if (o != null) {
            if (o instanceof String) {
            // table = form.getTable();
            } else {
                table = application.getFlattenedSolution().getTable(((Relation) o).getForeignDataSource());
            }
            if (table != null) {
                Iterator<Column> it = table.getColumnsSortedByName();
                while (it.hasNext()) {
                    IColumn c = it.next();
                    ColumnInfo ci = c.getColumnInfo();
                    if (ci != null && ci.isExcluded()) {
                        continue;
                    }
                    if (hideMediaColumns) {
                        // use dataprovider type as defined by column converter
                        ComponentFormat componentFormat = ComponentFormat.getComponentFormat(null, c, application);
                        if (componentFormat.dpType == IColumnTypes.MEDIA) {
                            continue;
                        }
                    }
                    model.addElement(c);
                }
            }
        }
        FlattenedSolution s = application.getFlattenedSolution();
        if (table != null && !showColumnsOnly) {
            Iterator it = s.getScriptCalculations(table, true);
            if (it.hasNext()) {
                model.addElement("*calculations");
            }
            while (it.hasNext()) {
                ScriptCalculation sc = (ScriptCalculation) it.next();
                for (int i = 0; i < model.size(); i++) {
                    Object obj = model.elementAt(i);
                    if (obj instanceof IDataProvider) {
                        IDataProvider dp = (IDataProvider) obj;
                        if (dp.getDataProviderID().equals(sc.getDataProviderID())) {
                            // remove the column from the list if use by
                            model.remove(i);
                            // stored calc
                            break;
                        }
                    }
                }
                model.addElement(sc);
            }
            Iterator it2 = s.getScriptVariables(true);
            if (it2.hasNext()) {
                model.addElement("*globals");
            }
            while (it2.hasNext()) {
                model.addElement(it2.next());
            }
            Iterator it3 = s.getAggregateVariables(table, true);
            if (it3.hasNext()) {
                model.addElement("*aggregates");
            }
            while (it3.hasNext()) {
                model.addElement(it3.next());
            }
        }
        if (table != null && showColumnsOnly && showSortableOnly) {
            Iterator it3 = s.getAggregateVariables(table, true);
            while (it3.hasNext()) {
                model.addElement(it3.next());
            }
        }
        if (showGlobalsOption && showColumnsOnly) {
            Iterator it2 = s.getScriptVariables(true);
            if (it2.hasNext()) {
                model.addElement("*globals");
            }
            while (it2.hasNext()) {
                model.addElement(it2.next());
            }
        }
    } catch (Exception ex) {
        Debug.error(ex);
    }
}
Also used : FormController(com.servoy.j2db.FormController) Form(com.servoy.j2db.persistence.Form) DefaultListModel(javax.swing.DefaultListModel) ColumnInfo(com.servoy.j2db.persistence.ColumnInfo) FlattenedSolution(com.servoy.j2db.FlattenedSolution) IDataProvider(com.servoy.j2db.persistence.IDataProvider) ScriptCalculation(com.servoy.j2db.persistence.ScriptCalculation) Relation(com.servoy.j2db.persistence.Relation) FormManager(com.servoy.j2db.FormManager) IColumn(com.servoy.j2db.persistence.IColumn) Column(com.servoy.j2db.persistence.Column) IColumn(com.servoy.j2db.persistence.IColumn) Iterator(java.util.Iterator) ITable(com.servoy.j2db.persistence.ITable) ComponentFormat(com.servoy.j2db.component.ComponentFormat)

Example 20 with FormManager

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

the class DataProviderEditor method fillRelationsComboBox.

protected void fillRelationsComboBox(Relation[] relations) throws Exception {
    boolean relationsAdded = false;
    String item = null;
    ITable table = null;
    if (definedTable == null) {
        FormManager fm = (FormManager) application.getFormManager();
        FormController fc = fm.getCurrentMainShowingFormController();
        if (fc != null) {
            Form form = fc.getForm();
            table = application.getFlattenedSolution().getTable(form.getDataSource());
        }
    } else {
        table = definedTable;
    // definedTable = null;//clear!
    }
    if (relationsComboBox.getItemCount() > 0)
        relationsComboBox.removeAllItems();
    Iterator it = application.getFlattenedSolution().getRelations(table, true, true);
    while (it.hasNext()) {
        Relation rel = (Relation) it.next();
        if (!showSortableOnly || (showSortableOnly && rel.isUsableInSort())) {
            relationsComboBox.addItem(rel);
            relationsAdded = true;
        }
    }
    if (!showRelatedOptionsOnly) {
        // $NON-NLS-1$
        String tname = "";
        if (table != null)
            tname = table.getName();
        item = "DataProviders for " + tname;
        if (relationsComboBox.getModel().getSize() > 0) {
            relationsComboBox.insertItemAt(item, 0);
        } else {
            relationsComboBox.addItem(item);
        }
    }
    if (relations == null) {
        if (item == null) {
            if (relationsComboBox.getModel().getSize() != 0)
                relationsComboBox.setSelectedIndex(0);
        } else {
            relationsComboBox.setSelectedItem(item);
        }
    } else {
        relationsComboBox.setSelectedItem(relations[0]);
    }
    relationsComboBox.setEnabled(relationsAdded && !showRelatedOptionsOnly);
}
Also used : FormController(com.servoy.j2db.FormController) Relation(com.servoy.j2db.persistence.Relation) FormManager(com.servoy.j2db.FormManager) Form(com.servoy.j2db.persistence.Form) Iterator(java.util.Iterator) ITable(com.servoy.j2db.persistence.ITable)

Aggregations

FormManager (com.servoy.j2db.FormManager)49 IMainContainer (com.servoy.j2db.IMainContainer)21 FormController (com.servoy.j2db.FormController)15 MainPage (com.servoy.j2db.server.headlessclient.MainPage)13 IForm (com.servoy.j2db.IForm)7 Form (com.servoy.j2db.persistence.Form)5 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)4 RepositoryException (com.servoy.j2db.persistence.RepositoryException)4 IComponent (com.servoy.j2db.ui.IComponent)4 Component (java.awt.Component)4 ArrayList (java.util.ArrayList)4 FlattenedSolution (com.servoy.j2db.FlattenedSolution)3 FormWindow (com.servoy.j2db.FormWindow)3 IBasicFormManager (com.servoy.j2db.IBasicFormManager)3 IFormController (com.servoy.j2db.IFormController)3 IFormManager (com.servoy.j2db.IFormManager)3 ITable (com.servoy.j2db.persistence.ITable)3 SwingFormManager (com.servoy.j2db.smart.SwingFormManager)3 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)3 ServoyException (com.servoy.j2db.util.ServoyException)3