use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.
the class JSApplication method js_getPrinters.
/**
* Get all the printer names in an array.
*
* @sample var printersArray = application.getPrinters();
*
* @return All printer names
*/
@ServoyClientSupport(ng = false, wc = true, sc = true)
public String[] js_getPrinters() {
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(flavor, pras);
if (printServices == null)
return new String[0];
String[] retval = new String[printServices.length];
for (int i = 0; i < printServices.length; i++) {
retval[i] = printServices[i].getName();
}
return retval;
}
use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.
the class JSForm method removeField.
/**
* Removes a JSField that has the given name. Returns true if removal was successful, false otherwise.
*
* @sample
* var form = solutionModel.newForm('newFormX',myDatasource,null,true,800,600);
* var jsfield = form.newField(scopes.globals.myGlobalVariable,JSField.TEXT_FIELD,100,300,200,50);
* jsfield.name = 'jsf';
* var jsmethod = form.newMethod("function removeMe(event) { var form = solutionModel.getForm('newFormX');\n if (form.removeComponent('jsf') == true) application.output('Field has been removed ok'); else application.output('Field could not be deleted'); forms['newFormX'].controller.recreateUI();}");
* var removerButton = form.newButton('Click here to remove the field',450,500,250,50,jsmethod);
* removerButton.name = 'remover';
* forms['newFormX'].controller.show();
*
* @param name the specified name of the JSField to remove
*
* @return true is the JSField has been successfully removed; false otherwise
*/
@ServoyClientSupport(mc = true, ng = true, wc = true, sc = true)
@JSFunction
public boolean removeField(String name) {
if (name == null)
return false;
checkModification();
Iterator<Field> fields = getContainer().getFields();
while (fields.hasNext()) {
Field field = fields.next();
if (name.equals(field.getName())) {
getContainer().removeChild(field);
return true;
}
}
return false;
}
use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.
the class JSForm method js_setOnDuplicateRecordCmdMethod.
/**
* @deprecated As of release 4.1, replaced by setOnDuplicateRecordCmd(JSMethod).
*/
@Deprecated
@ServoyClientSupport(ng = false, wc = true, sc = true)
public void js_setOnDuplicateRecordCmdMethod(Object functionOrInteger) {
checkModification();
if (functionOrInteger instanceof Function) {
Function function = (Function) functionOrInteger;
ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
if (scriptMethod != null) {
getForm().setOnDuplicateRecordCmdMethodID(scriptMethod.getID());
} else {
getForm().setOnDuplicateRecordCmdMethodID(0);
}
} else if (functionOrInteger instanceof Number) {
getForm().setOnDuplicateRecordCmdMethodID(((Number) functionOrInteger).intValue());
}
}
use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.
the class JSForm method js_setOnPrintPreviewCmdMethod.
/**
* @deprecated As of release 4.1, replaced by setOnPrintPreviewCmd(JSMethod).
*/
@Deprecated
@ServoyClientSupport(ng = false, wc = true, sc = true)
public void js_setOnPrintPreviewCmdMethod(Object functionOrInteger) {
checkModification();
if (functionOrInteger instanceof Function) {
Function function = (Function) functionOrInteger;
ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
if (scriptMethod != null) {
getForm().setOnPrintPreviewCmdMethodID(scriptMethod.getID());
} else {
getForm().setOnPrintPreviewCmdMethodID(0);
}
} else if (functionOrInteger instanceof Number) {
getForm().setOnPrintPreviewCmdMethodID(((Number) functionOrInteger).intValue());
}
}
use of com.servoy.base.scripting.annotations.ServoyClientSupport in project servoy-client by Servoy.
the class JSBaseContainer method newWebComponent.
/**
* Creates a new JSWebComponent (spec based component) object on the RESPONSIVE form.
*
* @sample
* var form = solutionModel.newForm('newForm1', 'db:/server1/table1', null, true, 800, 600);
* var container = myForm.getLayoutContainer("row1")
* var bean = container.newWebComponent('bean','mypackage-testcomponent',1);
*
* @param name the specified name of the JSWebComponent object
* @param type the webcomponent name as it appears in the spec
* @param position the position of JSWebComponent object in its parent container
*
* @return a JSWebComponent object
*/
@ServoyClientSupport(mc = false, ng = true, wc = false, sc = false)
@JSFunction
public JSWebComponent newWebComponent(String name, String type, int position) {
checkModification();
try {
AbstractContainer container = getContainer();
Form form = (Form) container.getAncestor(IRepository.FORMS);
if (form.isResponsiveLayout()) {
if (name == null) {
String componentName = type;
int index = componentName.indexOf("-");
if (index != -1) {
componentName = componentName.substring(index + 1);
}
// $NON-NLS-1$//$NON-NLS-2$
componentName = componentName.replaceAll("-", "_");
// $NON-NLS-1$
name = componentName + "_" + id.incrementAndGet();
IJSParent<?> parent = this;
while (!(parent instanceof JSForm)) {
parent = parent.getJSParent();
}
if (parent instanceof JSForm) {
while (findComponent((JSForm) parent, name) != null) {
name = componentName + "_" + id.incrementAndGet();
}
}
}
WebComponent webComponent = container.createNewWebComponent(IdentDocumentValidator.checkName(name), type);
webComponent.setLocation(new Point(position, position));
return createWebComponent(this, webComponent, application, true);
} else {
throw new RuntimeException("Form " + form.getName() + " is not responsive. Cannot create component without specifying the location and size.");
}
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
Aggregations