Search in sources :

Example 41 with RepositoryException

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

the class JSForm method newField.

/**
 * Creates a new JSField object on the form - including the dataprovider/JSVariable of the JSField object, the "x" and "y" position of the JSField object in pixels, as well as the width and height of the JSField object in pixels.
 *
 * @sample
 * var form = solutionModel.newForm('newForm1', myDatasource, null, true, 800, 600);
 * var variable = form.newVariable('myVar', JSVariable.TEXT);
 * variable.defaultValue = "'This is a default value (with triple quotes)!'";
 * var field = form.newField(variable, JSField.TEXT_FIELD, 100, 100, 200, 200);
 * forms['newForm1'].controller.show();
 *
 * @param dataprovider the specified dataprovider name/JSVariable of the JSField object
 *
 * @param type the display type of the JSField object (see the Solution Model -> JSField node for display types)
 *
 * @param x the horizontal "x" position of the JSField object in pixels
 *
 * @param y the vertical "y" position of the JSField object in pixels
 *
 * @param width the width of the JSField object in pixels
 *
 * @param height the height of the JSField object in pixels
 *
 * @return a new JSField object (of the specified display type)
 */
@JSFunction
public JSField newField(Object dataprovider, int type, int x, int y, int width, int height) {
    checkModification();
    try {
        Field field = getContainer().createNewField(new Point(x, y));
        field.setDisplayType(type);
        CSSPositionUtils.setSize(field, width, height);
        if (dataprovider instanceof String) {
            field.setDataProviderID((String) dataprovider);
        } else if (dataprovider instanceof JSVariable) {
            field.setDataProviderID(((JSVariable) dataprovider).getScriptVariable().getDataProviderID());
        }
        return JSField.createField(this, field, application, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : Field(com.servoy.j2db.persistence.Field) RepositoryException(com.servoy.j2db.persistence.RepositoryException) Point(java.awt.Point) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 42 with RepositoryException

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

the class JSForm method newTabPanel.

/**
 * Creates a new JSTabPanel object on the form - including the name of the JSTabPanel object, the "x" and "y" position of the JSTabPanel object in pixels, as well as the width and height of the JSTabPanel object in pixels.
 *
 * @sample
 * var form = solutionModel.newForm('parentForm','db:/server1/parent_table',null,false,640,480);
 * var childOne = solutionModel.newForm('childOne','db:/server1/child_table',null,false,400,300);
 * childOne.newField('child_table_text', JSField.TEXT_FIELD,10,10,100,20);
 * var parentToChild = solutionModel.newRelation('parentToChild','db:/server1/parent_table','db:/server1/child_table',JSRelation.INNER_JOIN);
 * parentToChild.newRelationItem('parent_table_id','=','child_table_parent_id');
 * var childTwo = solutionModel.newForm('childTwo','db:/server1/my_table',null,false,400,300);
 * childTwo.newField('my_table_image', JSField.IMAGE_MEDIA,10,10,100,100);
 * var tabPanel = form.newTabPanel('tabs',10,10,620,460);
 * tabPanel.newTab('tab1','Child One',childOne,parentToChild);
 * tabPanel.newTab('tab2','Child Two',childTwo);
 * forms['parentForm'].controller.show();
 *
 * @param name the specified name of the JSTabPanel object
 * @param x the horizontal "x" position of the JSTabPanel object in pixels
 * @param y the vertical "y" position of the JSTabPanel object in pixels
 * @param width the width of the JSTabPanel object in pixels
 * @param height the height of the JSTabPanel object in pixels
 *
 * @return a JSTabPanel object
 */
@JSFunction
public JSTabPanel newTabPanel(String name, int x, int y, int width, int height) {
    checkModification();
    try {
        TabPanel tabPanel = getContainer().createNewTabPanel(IdentDocumentValidator.checkName(name));
        CSSPositionUtils.setSize(tabPanel, width, height);
        CSSPositionUtils.setLocation(tabPanel, x, y);
        return new JSTabPanel(this, tabPanel, application, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : TabPanel(com.servoy.j2db.persistence.TabPanel) RepositoryException(com.servoy.j2db.persistence.RepositoryException) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 43 with RepositoryException

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

the class JSForm method newVariable.

/**
 * Creates a new form JSVariable - based on the name of the variable object , the  type  and it's default value , uses the SolutionModel JSVariable constants.
 *
 * This method does not require the form to be destroyed and recreated. Use this method if you want to change the form's model without destroying the runtime form</b>
 *
 * @sample
 * var form = solutionModel.newForm('newForm1', myDatasource, null, true, 800, 600);
 * var variable = form.newVariable('myVar', JSVariable.TEXT , "'This is a default value (with triple quotes)!'");
 * //or variable = form.newVariable('myVar', JSVariable.TEXT)
 * //variable.defaultValue = "'This is a default value (with triple quotes)!'" // setting the default value after the variable is created requires form recreation
 * //variable.defaultValue = "{a:'First letter',b:'Second letter'}"
 * var field = form.newField(variable, JSField.TEXT_FIELD, 100, 100, 200, 200);
 * forms['newForm1'].controller.show();
 *
 * @param name the specified name of the variable
 *
 * @param type the specified type of the variable (see Solution Model -> JSVariable node constants)
 *
 * @param defaultValue the default value as a javascript expression string
 *
 * @return a JSVariable object
 */
@JSFunction
public JSVariable newVariable(String name, int type, String defaultValue) {
    checkModification();
    try {
        ScriptVariable variable = getForm().createNewScriptVariable(new ScriptNameValidator(application.getFlattenedSolution()), name, type);
        variable.setDefaultValue(defaultValue);
        addVariableToScopes(variable);
        return new JSVariable(application, this, variable, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : ScriptVariable(com.servoy.j2db.persistence.ScriptVariable) RepositoryException(com.servoy.j2db.persistence.RepositoryException) ScriptNameValidator(com.servoy.j2db.persistence.ScriptNameValidator) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 44 with RepositoryException

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

the class JSForm method newBean.

/**
 * Creates a new JSBean object on the form - including the name of the JSBean object; the classname the JSBean object is based on, the "x" and "y" position of the JSBean object in pixels, as well as the width and height of the JSBean object in pixels.
 *
 * @sample
 * var form = solutionModel.newForm('newForm1', 'db:/server1/table1', null, true, 800, 600);
 * var bean = form.newBean('bean','com.servoy.extensions.beans.dbtreeview.DBTreeView',200,200,300,300);
 * forms['newForm1'].controller.show();
 *
 * @param name the specified name of the JSBean object
 * @param className the class name of the JSBean object
 * @param x the horizontal "x" position of the JSBean object in pixels
 * @param y the vertical "y" position of the JSBean object in pixels
 * @param width the width of the JSBean object in pixels
 * @param height the height of the JSBean object in pixels
 *
 * @return a JSBean object
 */
@JSFunction
public JSBean newBean(String name, String className, int x, int y, int width, int height) {
    checkModification();
    try {
        Bean bean = getContainer().createNewBean(IdentDocumentValidator.checkName(name), className);
        bean.setSize(new Dimension(width, height));
        bean.setLocation(new Point(x, y));
        return new JSBean(this, bean, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : RepositoryException(com.servoy.j2db.persistence.RepositoryException) Dimension(java.awt.Dimension) Point(java.awt.Point) Bean(com.servoy.j2db.persistence.Bean) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 45 with RepositoryException

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

the class JSForm method newPortal.

/**
 * Creates a new JSPortal object on the form - including the name of the JSPortal object; the relation the JSPortal object is based on, the "x" and "y" position of the JSPortal object in pixels, as well as the width and height of the JSPortal object in pixels.
 *
 * @sample
 * var form = solutionModel.newForm('newForm1', 'db:/server1/table1', null, true, 800, 600);
 * var relation = solutionModel.newRelation('parentToChild','db:/server1/table1','db:/server2/table2',JSRelation.INNER_JOIN);
 * relation.newRelationItem('another_parent_table_id', '=', 'another_child_table_parent_id');
 * var portal = form.newPortal('portal',relation,200,200,300,300);
 * portal.newField('someColumn',JSField.TEXT_FIELD,200,200,120);
 * forms['newForm1'].controller.show();
 *
 * @param name the specified name of the JSPortal object
 * @param relation the relation of the JSPortal object
 * @param x the horizontal "x" position of the JSPortal object in pixels
 * @param y the vertical "y" position of the JSPortal object in pixels
 * @param width the width of the JSPortal object in pixels
 * @param height the height of the JSPortal object in pixels
 *
 * @return a JSPortal object
 */
@JSFunction
public JSPortal newPortal(String name, Object relation, int x, int y, int width, int height) {
    checkModification();
    try {
        Portal portal = getContainer().createNewPortal(IdentDocumentValidator.checkName(name), new Point(x, y));
        CSSPositionUtils.setSize(portal, width, height);
        String relationName = null;
        if (relation instanceof RelatedFoundSet) {
            relationName = ((RelatedFoundSet) relation).getRelationName();
        } else if (relation instanceof String) {
            relationName = (String) relation;
        } else if (relation instanceof JSRelation) {
            relationName = ((JSRelation) relation).getName();
        }
        portal.setRelationName(relationName);
        return new JSPortal(this, portal, application, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : RelatedFoundSet(com.servoy.j2db.dataprocessing.RelatedFoundSet) Portal(com.servoy.j2db.persistence.Portal) RepositoryException(com.servoy.j2db.persistence.RepositoryException) Point(java.awt.Point) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Aggregations

RepositoryException (com.servoy.j2db.persistence.RepositoryException)116 RemoteException (java.rmi.RemoteException)45 QuerySelect (com.servoy.j2db.query.QuerySelect)25 ITable (com.servoy.j2db.persistence.ITable)22 JSFunction (org.mozilla.javascript.annotations.JSFunction)22 ServoyException (com.servoy.j2db.util.ServoyException)21 Column (com.servoy.j2db.persistence.Column)19 ArrayList (java.util.ArrayList)19 BaseQueryTable (com.servoy.base.query.BaseQueryTable)16 Table (com.servoy.j2db.persistence.Table)16 QueryTable (com.servoy.j2db.query.QueryTable)16 FlattenedSolution (com.servoy.j2db.FlattenedSolution)14 Point (java.awt.Point)14 IDataProvider (com.servoy.j2db.persistence.IDataProvider)13 QueryColumn (com.servoy.j2db.query.QueryColumn)13 IColumn (com.servoy.j2db.persistence.IColumn)12 ApplicationException (com.servoy.j2db.ApplicationException)11 ScriptNameValidator (com.servoy.j2db.persistence.ScriptNameValidator)10 SafeArrayList (com.servoy.j2db.util.SafeArrayList)10 FoundSetManager (com.servoy.j2db.dataprocessing.FoundSetManager)8