use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method removeStyle.
/**
* Removes the specified style.
*
* @sample
* var s = solutionModel.newStyle("smStyle1",'form { background-color: yellow; }');
* var status = solutionModel.removeStyle("smStyle1");
* if (status == false) application.output("Could not remove style.");
* else application.output("Style removed.");
*
* @param name the name of the style to be removed
*
* @return true if the removal was successful, false otherwise
*/
@JSFunction
public boolean removeStyle(String name) {
FlattenedSolution fs = application.getFlattenedSolution();
Style style = fs.getStyle(name);
if (style != null) {
fs.removeStyle(name);
return true;
}
return false;
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method removeMedia.
/**
* Removes the media item specified by name.
*
* @sample
* var bytes1 = plugins.file.readFile('D:/Imgs/image1.png');
* var image1 = solutionModel.newMedia('image1.png', bytes1);
* var bytes2 = plugins.file.readFile('D:/Imgs/image2.jpg');
* var image2 = solutionModel.newMedia('image2.jpg',bytes2);
* var bytes3 = plugins.file.readFile('D:/Imgs/image3.jpg');
* var image3 = solutionModel.newMedia('image3.jpg',bytes3);
*
* var f = solutionModel.newForm("newForm",databaseManager.getDataSource('example_data', 'orders'),null,false,500,350);
* var l = f.newLabel('', 20, 70, 300, 200);
* l.imageMedia = image1;
* l.borderType = solutionModel.createLineBorder(4,'#ff0000');
* forms["newForm"].controller.show();
*
* var status = solutionModel.removeMedia('image1.jpg');
* if (status) application.output("image1.png has been removed");
* else application.output("image1.png has not been removed");
*
* var mediaList = solutionModel.getMediaList();
* for (var i = 0; i < mediaList.length; i++) {
* application.output(mediaList[i].getName() + ":" + mediaList[i].mimeType);
* }
*
* @param name the name of the media item to be removed
*
* @return true if the removal was successful, false otherwise
*/
@JSFunction
public boolean removeMedia(String name) {
FlattenedSolution fs = application.getFlattenedSolution();
Media mediaItem = fs.getMedia(name);
if (mediaItem != null) {
fs.deletePersistCopy(mediaItem, false);
return true;
}
return false;
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method getGlobalVariable.
/**
* Gets an existing global variable by the specified name.
*
* @sample
* var globalVariable = solutionModel.getGlobalVariable('globals', 'globalVariableName');
* application.output(globalVariable.name + " has the default value of " + globalVariable.defaultValue);
*
* @param scopeName the scope in which the variable is searched
* @param name the specified name of the global variable
*
* @return a JSVariable
*/
@JSFunction
public JSVariable getGlobalVariable(String scopeName, String name) {
FlattenedSolution fs = application.getFlattenedSolution();
ScriptVariable variable = fs.getScriptVariable(scopeName, name);
if (variable != null) {
return new JSVariable(application, variable, false);
}
return null;
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method getRelations.
/**
* @clonedesc getRelations(String)
* @sampleas getRelations(String)
* @param servername the specified name of the server for the specified table
* @param tablename the specified name of the table
*
* @return an array of all relations (all elements in the array are of type JSRelation)
*/
@JSFunction
public JSRelation[] getRelations(String servername, String tablename) {
FlattenedSolution fs = application.getFlattenedSolution();
try {
Table primaryTable = null;
if (servername != null && tablename != null) {
IServer primaryServer = fs.getSolution().getServer(servername);
if (primaryServer == null)
throw new RuntimeException("can't list relations, primary server not found: " + servername);
primaryTable = (Table) primaryServer.getTable(tablename);
if (primaryTable == null)
throw new RuntimeException("can't list relations, primary table not found: " + tablename);
}
List<JSRelation> relations = new ArrayList<JSRelation>();
Iterator<Relation> iterator = fs.getRelations(primaryTable, true, true);
while (iterator.hasNext()) {
Relation relation = iterator.next();
if (((primaryTable == null) == relation.isGlobal()) && !relation.isInternal()) {
relations.add(new JSRelation(relation, application, false));
}
}
return relations.toArray(new JSRelation[relations.size()]);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method getForm.
/**
* Gets the specified form object and returns information about the form (see JSForm node).
*
* @sample
* var myForm = solutionModel.getForm('existingFormName');
* //get the style of the form (for all other properties see JSForm node)
* var styleName = myForm.styleName;
*
* @param name the specified name of the form
*
* @return a JSForm
*/
@JSFunction
public JSForm getForm(String name) {
if (name == null)
return null;
Form form = application.getFormManager().getPossibleForm(name);
if (form == null) {
FlattenedSolution fs = application.getFlattenedSolution();
form = fs.getForm(name);
if (form == null) {
// search ignoring case
Iterator<Form> forms = fs.getForms(false);
String lowerCaseName = Utils.toEnglishLocaleLowerCase(name);
Form f;
while (forms.hasNext() && form == null) {
f = forms.next();
if (Utils.toEnglishLocaleLowerCase(f.getName()).equals(lowerCaseName))
form = f;
}
}
}
if (form != null) {
return instantiateForm(form, false);
}
return null;
}
Aggregations