use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method getMediaList.
/**
* Gets the list of all media objects.
*
* @sample
* var mediaList = solutionModel.getMediaList();
* if (mediaList.length != 0 && mediaList != null) {
* for (var x in mediaList) {
* application.output(mediaList[x]);
* }
* }
*
* @return a list with all the media objects.
*/
@JSFunction
public JSMedia[] getMediaList() {
FlattenedSolution fs = application.getFlattenedSolution();
ArrayList<JSMedia> lst = new ArrayList<JSMedia>();
Iterator<Media> media = fs.getMedias(true);
while (media.hasNext()) {
lst.add(new JSMedia(media.next(), application.getFlattenedSolution(), false));
}
return lst.toArray(new JSMedia[lst.size()]);
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method removeValueList.
/**
* Removes the specified valuelist.
*
* @sample
* var vlName = "customValueList";
* var vl = solutionModel.newValueList(vlName,JSValueList.CUSTOM_VALUES);
* vl.customValues = "customvalue1\ncustomvalue2";
*
* var status = solutionModel.removeValueList(vlName);
* if (status) application.output("Removal has been done.");
* else application.output("ValueList not removed.");
*
* var vls = solutionModel.getValueLists();
* if (vls != null) {
* for (var i = 0; i < vls.length; i++) {
* application.output(vls[i]);
* }
* application.output("");
* }
*
* @param name name of the valuelist to be removed
*
* @return true if the removal was successful, false otherwise
*/
@JSFunction
public boolean removeValueList(String name) {
FlattenedSolution fs = application.getFlattenedSolution();
ValueList valueList = fs.getValueList(name);
if (valueList != null) {
fs.deletePersistCopy(valueList, false);
return true;
}
return false;
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method removeGlobalVariable.
/**
* Removes the specified global variable.
*
* @sample
* var v1 = solutionModel.newGlobalVariable('globals', 'globalVar1', JSVariable.INTEGER);
* var v2 = solutionModel.newGlobalVariable('globals', 'globalVar2', JSVariable.TEXT);
*
* var success = solutionModel.removeGlobalVariable('globals', 'globalVar1');
* if (success == false) application.output('!!! globalVar1 could not be removed !!!');
*
* var list = solutionModel.getGlobalVariables('globals');
* for (var i = 0; i < list.length; i++) {
* application.output(list[i].name + '[ ' + list[i].variableType + ']: ' + list[i].variableType);
* }
*
* @param scopeName the scope in which the variable is declared
* @param name the name of the global variable to be removed
* @return true if the removal was successful, false otherwise
*/
@JSFunction
public boolean removeGlobalVariable(String scopeName, String name) {
FlattenedSolution fs = application.getFlattenedSolution();
ScriptVariable sv = fs.getScriptVariable(scopeName, name);
if (sv != null) {
fs.deletePersistCopy(sv, false);
return true;
}
return false;
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method newMedia.
/**
* Creates a new media object that can be assigned to a label or a button.
*
* @sample
* var myMedia = solutionModel.newMedia('button01.gif',bytes)
* //now set the imageMedia property of your label or button
* //myButton.imageMedia = myMedia
* // OR
* //myLabel.imageMedia = myMedia
*
* @param name The name of the new media
*
* @param bytes The content
*
* @return a JSMedia object
*/
@JSFunction
public JSMedia newMedia(String name, byte[] bytes) {
FlattenedSolution fs = application.getFlattenedSolution();
try {
Media media = fs.getSolutionCopy().createNewMedia(new ScriptNameValidator(fs), name);
media.setPermMediaData(bytes);
media.setMimeType(MimeTypes.getContentType(bytes));
return new JSMedia(media, application.getFlattenedSolution(), true);
} catch (RepositoryException e) {
throw new RuntimeException("error createing new media with name " + name, e);
}
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method getValueList.
/**
* Gets an existing valuelist by the specified name and returns a JSValueList Object that can be assigned to a field.
*
* NOTE: Changes to valuelist should be done before showing any form that has component using the valuelist.
*
* @sample
* var myValueList = solutionModel.getValueList('myValueListHere')
* //now set the valueList property of your field
* //myField.valuelist = myValueList
*
* @param name the specified name of the valuelist
*
* @return a JSValueList object
*/
@JSFunction
public JSValueList getValueList(String name) {
FlattenedSolution fs = application.getFlattenedSolution();
ValueList valuelist = fs.getValueList(name);
if (valuelist != null) {
return new JSValueList(valuelist, application, false);
}
return null;
}
Aggregations