Search in sources :

Example 1 with ServoyClientSupport

use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.

the class JSForm method removeButton.

/**
 * Removes a JSButton that has the specified name. Returns true if removal was successful, false otherwise.
 *
 * @sample
 * var form = solutionModel.newForm('newFormX',myDatasource,null,true,800,600);
 * var b1 = form.newButton('This is button1',100,100,200,50,null);
 * b1.name = 'b1';
 * var jsmethod = form.newMethod("function removeMe(event) { var form = solutionModel.getForm('newFormX'); if (form.removeButton('b1') == true) application.output('Button has been removed ok'); else application.output('Button could not be deleted'); forms['newFormX'].controller.recreateUI();}");
 * var b2 = form.newButton('Click here to remove button1',100,230,200,50,jsmethod);
 * b2.name = 'b2';
 * forms['newFormX'].controller.show();
 *
 * @param name the specified name of the JSButton to be removed
 *
 * @return true if the JSButton has been removed; false otherwise
 */
@ServoyClientSupport(mc = true, ng = true, wc = true, sc = true)
@JSFunction
public boolean removeButton(String name) {
    if (name == null)
        return false;
    checkModification();
    Iterator<GraphicalComponent> graphicalComponents = getContainer().getGraphicalComponents();
    while (graphicalComponents.hasNext()) {
        GraphicalComponent button = graphicalComponents.next();
        if (name.equals(button.getName()) && ComponentFactory.isButton(button)) {
            getContainer().removeChild(button);
            return true;
        }
    }
    return false;
}
Also used : GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) JSFunction(org.mozilla.javascript.annotations.JSFunction) ServoyClientSupport(com.servoy.base.scripting.annotations.ServoyClientSupport)

Example 2 with ServoyClientSupport

use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.

the class JSForm method removeBean.

/**
 * Removes a JSBean that has the specified name. Returns true if removal was successful, false otherwise.
 *
 * @sample
 * var form = solutionModel.getForm('myform');
 * form.removeBean('mybean')
 *
 * @param name the specified name of the JSBean to be removed
 *
 * @return true if the JSBean has been removed; false otherwise
 */
@ServoyClientSupport(mc = true, ng = true, wc = true, sc = true)
@JSFunction
public boolean removeBean(String name) {
    if (name == null)
        return false;
    checkModification();
    Iterator<Bean> beans = getContainer().getBeans();
    while (beans.hasNext()) {
        Bean bean = beans.next();
        if (name.equals(bean.getName())) {
            getContainer().removeChild(bean);
            return true;
        }
    }
    return false;
}
Also used : Bean(com.servoy.j2db.persistence.Bean) JSFunction(org.mozilla.javascript.annotations.JSFunction) ServoyClientSupport(com.servoy.base.scripting.annotations.ServoyClientSupport)

Example 3 with ServoyClientSupport

use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.

the class JSForm method js_setOnRecordEditStartMethod.

/**
 * @deprecated As of release 4.1, replaced by setOnRecordEditStart(JSMethod).
 */
@Deprecated
@ServoyClientSupport(ng = false, wc = true, sc = true)
public void js_setOnRecordEditStartMethod(Object functionOrInteger) {
    checkModification();
    if (functionOrInteger instanceof Function) {
        Function function = (Function) functionOrInteger;
        ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
        if (scriptMethod != null) {
            getForm().setOnRecordEditStartMethodID(scriptMethod.getID());
        } else {
            getForm().setOnRecordEditStartMethodID(0);
        }
    } else if (functionOrInteger instanceof Number) {
        getForm().setOnRecordEditStartMethodID(((Number) functionOrInteger).intValue());
    }
}
Also used : JSFunction(org.mozilla.javascript.annotations.JSFunction) Function(org.mozilla.javascript.Function) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod) ServoyClientSupport(com.servoy.base.scripting.annotations.ServoyClientSupport)

Example 4 with ServoyClientSupport

use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.

the class JSForm method removeLabel.

/**
 * Removes a JSLabel that has the given name. Returns true if removal successful, false otherwise
 *
 * @sample
 * var form = solutionModel.newForm('newFormX',myDatasource,null,true,1000,750);
 * var jslabel = form.newLabel('JSLabel to delete',100,200,200,50,null);
 * jslabel.name = 'jsl';
 * jslabel.transparent = false;
 * jslabel.background = 'green';
 * var jsmethod = form.newMethod("function removeMe(event) { var form = solutionModel.getForm('newFormX'); if (form.removeComponent('jsl') == true) application.output('Label has been removed'); else application.output('Label could not be deleted'); forms['newFormX'].controller.recreateUI();}");
 * var removerButton = form.newButton('Click here to remove the green label',450,500,250,50,jsmethod);
 * removerButton.name = 'remover';
 * forms['newFormX'].controller.show();
 *
 * @param name the specified name of the JSLabel to be removed
 *
 * @return true if the JSLabel with the given name has successfully been removed; false otherwise
 */
@ServoyClientSupport(mc = true, ng = true, wc = true, sc = true)
@JSFunction
public boolean removeLabel(String name) {
    if (name == null)
        return false;
    checkModification();
    Iterator<GraphicalComponent> graphicalComponents = getContainer().getGraphicalComponents();
    while (graphicalComponents.hasNext()) {
        GraphicalComponent label = graphicalComponents.next();
        if (name.equals(label.getName()) && !ComponentFactory.isButton(label)) {
            getContainer().removeChild(label);
            return true;
        }
    }
    return false;
}
Also used : GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) JSFunction(org.mozilla.javascript.annotations.JSFunction) ServoyClientSupport(com.servoy.base.scripting.annotations.ServoyClientSupport)

Example 5 with ServoyClientSupport

use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.

the class JSBaseContainer method removeWebComponent.

/**
 * Removes a JSWebComponent that has the specified name. Returns true if removal was successful, false otherwise.
 *
 * @sample
 * var form = solutionModel.getForm('myform');
 * form.removeWebComponent('mybean')
 *
 * @param name the specified name of the JSWebComponent to be removed
 *
 * @return true if the JSWebComponent has been removed; false otherwise
 */
@ServoyClientSupport(mc = false, ng = true, wc = false, sc = false)
@JSFunction
public boolean removeWebComponent(String name) {
    if (name == null)
        return false;
    checkModification();
    Iterator<WebComponent> webComponents = getContainer().getWebComponents();
    while (webComponents.hasNext()) {
        WebComponent webComponent = webComponents.next();
        if (name.equals(webComponent.getName())) {
            getContainer().removeChild(webComponent);
            return true;
        }
    }
    return false;
}
Also used : WebComponent(com.servoy.j2db.persistence.WebComponent) JSFunction(org.mozilla.javascript.annotations.JSFunction) ServoyClientSupport(com.servoy.base.scripting.annotations.ServoyClientSupport)

Aggregations

ServoyClientSupport (com.servoy.base.scripting.annotations.ServoyClientSupport)12 JSFunction (org.mozilla.javascript.annotations.JSFunction)11 AbstractContainer (com.servoy.j2db.persistence.AbstractContainer)3 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)3 WebComponent (com.servoy.j2db.persistence.WebComponent)3 Function (org.mozilla.javascript.Function)3 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)2 ArrayList (java.util.ArrayList)2 Bean (com.servoy.j2db.persistence.Bean)1 Field (com.servoy.j2db.persistence.Field)1 Form (com.servoy.j2db.persistence.Form)1 LayoutContainer (com.servoy.j2db.persistence.LayoutContainer)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 Point (java.awt.Point)1 DocFlavor (javax.print.DocFlavor)1 PrintService (javax.print.PrintService)1 HashPrintRequestAttributeSet (javax.print.attribute.HashPrintRequestAttributeSet)1 PrintRequestAttributeSet (javax.print.attribute.PrintRequestAttributeSet)1