use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class JSHeader method removeComponent.
private boolean removeComponent(MobileProperty<Boolean> property) {
JSForm form = getJSParent();
form.checkModification();
Iterator<GraphicalComponent> graphicalComponents = form.getSupportChild().getGraphicalComponents();
while (graphicalComponents.hasNext()) {
GraphicalComponent button = graphicalComponents.next();
if (Boolean.TRUE.equals(button.getCustomMobileProperty(property.propertyName))) {
form.getSupportChild().removeChild(button);
return true;
}
}
return false;
}
use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class JSPortal method newButton.
/**
* Creates a new button on the portal with the given text, place, size and JSMethod as the onClick action.
*
* @sample
* var clickMethod = form.newMethod('function clickMe() { application.output("I was clicked!"); }');
* var childrenPortal = form.newPortal('pp', 'parent_to_child', 10, 10, 620, 460);
* childrenPortal.newButton('Click me!', 400, 100, 20, clickMethod);
*
* @param text The text to be displayed on the button.
*
* @param x The x coordinate of the button. If the portal does not have the "multiLine" property set, then the x coordinates are used only for determining the order of the columns in the grid. If the portal has the "multiLine" property set, then the components are actually displayed at the specified coordinates.
*
* @param width The width of the button.
*
* @param height The height of the button. In a portal the height of all components is set to the height of the first component, unless the "multiLine" property is set.
*
* @param action The JSMethod object that should be executed when the button is clicked.
*
* @return A JSButton instance representing the newly created button.
*/
@JSFunction
public JSButton newButton(String text, int x, int width, int height, Object action) {
try {
GraphicalComponent gc = getBaseComponent(true).createNewGraphicalComponent(new Point(getX() + x, getY()));
gc.setSize(new Dimension(width, height));
gc.setText(text);
if (action instanceof JSMethod) {
JSButton button = new JSButton(this, gc, application, true);
button.setOnAction((JSMethod) action);
return button;
} else {
int id = JSForm.getMethodId(action, gc, application);
gc.setOnActionMethodID(id);
return new JSButton(this, gc, application, true);
}
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class JSPortal method getButtons.
/**
* Retrieves an array with all buttons in the portal.
*
* @sampleas getButton(String)
*
* @return An array with all buttons in the portal.
*/
@JSFunction
public JSButton[] getButtons() {
ArrayList<JSButton> buttons = new ArrayList<JSButton>();
Iterator<GraphicalComponent> graphicalComponents = getBaseComponent(false).getGraphicalComponents();
while (graphicalComponents.hasNext()) {
GraphicalComponent button = graphicalComponents.next();
if (ComponentFactory.isButton(button)) {
buttons.add(new JSButton(this, button, application, false));
}
}
return buttons.toArray(new JSButton[buttons.size()]);
}
use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class JSPortal method newLabel.
/**
* Creates a new label on the form, with the given text, place, size and an JSMethod as the onClick action.
*
* @sample
* var clickMethod = form.newMethod('function clickMe() { application.output("I was clicked!"); }');
* var childrenPortal = form.newPortal('pp', 'parent_to_my_table', 10, 10, 1180, 780);
* var calLabel = childrenPortal.newLabel('Date', 120, 60, 20);
* // This will result in a button being actually created, because we specify an action.
* var textLabel = childrenPortal.newLabel('Text', 180, 60, 20, clickMethod);
*
* @param text The text that will be displayed in the label.
*
* @param x The x coordinate of the label. If the portal does not have the "multiLine" property set, then the x coordinates are used only for determining the order of the columns in the grid. If the portal has the "multiLine" property set, then the components are actually displayed at the specified coordinates.
*
* @param width The width of the label.
*
* @param height The height of the label. In a portal the height of all components is set to the height of the first component, unless the "multiLine" property is set.
*
* @param action The JSMethod object that should be executed when the label is clicked.
*
* @return A JSLabel instance that represents the newly created label.
*/
@JSFunction
public JSLabel newLabel(String text, int x, int width, int height, Object action) {
try {
GraphicalComponent gc = getBaseComponent(true).createNewGraphicalComponent(new Point(getX() + x, getY()));
gc.setSize(new Dimension(width, height));
gc.setText(text);
if (action instanceof JSMethod) {
JSLabel label = new JSLabel(this, gc, application, true);
label.setOnAction((JSMethod) action);
return label;
} else {
int id = JSForm.getMethodId(action, gc, application);
if (id != -1)
gc.setOnActionMethodID(id);
return new JSLabel(this, gc, application, true);
}
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class JSPortal method getLabels.
/**
* Retrieves all labels from the portal.
*
* @sampleas getLabel(String)
*
* @return An array of JSLabel instances corresponding to all labels in the portal.
*/
@JSFunction
public JSLabel[] getLabels() {
ArrayList<JSLabel> labels = new ArrayList<JSLabel>();
Iterator<GraphicalComponent> graphicalComponents = getBaseComponent(false).getGraphicalComponents();
while (graphicalComponents.hasNext()) {
GraphicalComponent label = graphicalComponents.next();
if (!ComponentFactory.isButton(label)) {
labels.add(new JSLabel(this, label, application, false));
}
}
return labels.toArray(new JSLabel[labels.size()]);
}
Aggregations