use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method createComponents.
private void createComponents(final IApplication app, final Form form, final AbstractBase view, final IDataProviderLookup dataProviderLookup, final IScriptExecuter el, final int viewStartY, final int viewEndY, final ItemAdd output) {
List<IPersist> elements = ComponentFactory.sortElementsOnPositionAndGroup(view.getAllObjectsAsList());
int startX = 0;
for (int i = 0; i < elements.size(); i++) {
IPersist element = elements.get(i);
if (element instanceof Field || element instanceof GraphicalComponent || element instanceof Bean) {
if (!isListViewMode()) {
if (element instanceof GraphicalComponent && ((GraphicalComponent) element).getLabelFor() != null) {
if (isInView(cellview, ((GraphicalComponent) element).getLabelFor())) {
labelsFor.put(((GraphicalComponent) element).getLabelFor(), element);
}
continue;
}
}
Point l = ((IFormElement) element).getLocation();
if (l == null) {
// unknown where to add
continue;
}
if (l.y >= viewStartY && l.y < viewEndY) {
IComponent c = ComponentFactory.createComponent(app, form, element, dataProviderLookup, el, false);
if (cellview instanceof Portal && c instanceof IScriptableProvider) {
IScriptable s = ((IScriptableProvider) c).getScriptObject();
if (s instanceof ISupportOnRenderCallback && ((ISupportOnRenderCallback) s).getRenderEventExecutor() != null)
ComponentFactoryHelper.addPortalOnRenderCallback((Portal) cellview, ((ISupportOnRenderCallback) s).getRenderEventExecutor(), element, fc != null ? fc.getScriptExecuter() : null);
}
initializeComponent((Component) c, view, element);
output.add(element, (Component) c);
if (!isListViewMode()) {
// reset location.x as defined in this order, elements are ordered by location.x which is modified in drag-n-drop
Point loc = c.getLocation();
if (loc != null) {
c.setLocation(new Point(startX, loc.y));
}
Dimension csize = c.getSize();
startX += (csize != null) ? csize.width : ((IFormElement) element).getSize().width;
}
}
}
}
}
use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class SortableCellViewHeader method setWidth.
public void setWidth(int width) {
int borderWidth = 0;
Iterator<IPersist> it2 = cellview.getAllObjects();
while (it2.hasNext()) {
IPersist element = it2.next();
if (id.equals(ComponentFactory.getWebID(form, element))) {
GraphicalComponent gc = (GraphicalComponent) view.labelsFor.get(((ISupportName) element).getName());
if (gc != null) {
TextualStyle styleObj = new TextualStyle();
BorderAndPadding ins = TemplateGenerator.applyBaseComponentProperties(gc, view.fc.getForm(), styleObj, (Insets) TemplateGenerator.DEFAULT_LABEL_PADDING.clone(), null, application);
if (ins.border != null)
borderWidth = ins.border.left + ins.border.right;
}
}
}
int headerPadding = TemplateGenerator.SORTABLE_HEADER_PADDING;
// If there is no label-for, we leave place for the default border placed at the right of headers.
if (view.labelsFor.size() == 0) {
int extraWidth = TemplateGenerator.NO_LABELFOR_DEFAULT_BORDER_WIDTH;
String headerBorder = view.getHeaderBorder();
if (headerBorder != null) {
Properties properties = new Properties();
Insets borderIns = ComponentFactoryHelper.createBorderCSSProperties(headerBorder, properties);
extraWidth = borderIns.left + borderIns.right;
headerPadding = 0;
}
borderWidth += extraWidth;
}
// we have only left padding
int clientWidth = width - headerPadding - borderWidth;
// if we have grid_style for the header, then don't change the header width
this.width = (view.labelsFor.size() == 0 && view.getHeaderBorder() != null) ? width : clientWidth;
StyleAppendingModifier widthStyleModifier = new StyleAppendingModifier(new Model<String>() {
@Override
public String getObject() {
// $NON-NLS-1$//$NON-NLS-2$
return "width: " + SortableCellViewHeader.this.width + "px";
}
});
add(widthStyleModifier);
headerColumnTable.add(widthStyleModifier);
labelResolver.setWidth(clientWidth - SortableCellViewHeader.ARROW_WIDTH);
getStylePropertyChanges().setChanged();
}
use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class WebDataRendererFactory method placeElements.
protected Map placeElements(IApplication app, Form form, IScriptExecuter listener, Map emptyDataRenderers, boolean printing, ControllerUndoManager undoManager, TabSequenceHelper<Component> tabSequence) throws Exception {
// $NON-NLS-1$
final boolean useAJAX = Utils.getAsBoolean(app.getRuntimeProperties().get("useAJAX"));
IDataProviderLookup dataProviderLookup = app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), form);
Map listTocomplete = new HashMap();
Map labelForComponents = new HashMap();
String orientation = OrientationApplier.getHTMLContainerOrientation(app.getLocale(), app.getSolution().getTextOrientation());
// $NON-NLS-1$
boolean leftToRight = !"rtl".equalsIgnoreCase(orientation);
// $NON-NLS-1$
boolean isAnchoringEnabled = Utils.getAsBoolean(app.getRuntimeProperties().get("enableAnchors"));
// Insets insets = new Insets(0, 0, 0, 0);
for (IFormElement obj : Utils.iterate(form.getFormElementsSortedByFormIndex())) {
Point l = null;
l = (obj).getLocation();
// unknown where to add
if (l == null)
continue;
if (printing && obj instanceof ISupportPrinting) {
if (!((ISupportPrinting) obj).getPrintable())
continue;
}
Iterator it = emptyDataRenderers.values().iterator();
while (it.hasNext()) {
WebDataRenderer panel = (WebDataRenderer) it.next();
// Border border = panel.getBorder();
// if (border instanceof EmptyBorder)
// {
// insets = ((EmptyBorder)border).getBorderInsets();
// }
int start = panel.getLocation().y;
if (l.y >= start && l.y < start + panel.getSize().height) {
org.apache.wicket.Component comp = (org.apache.wicket.Component) ComponentFactory.createComponent(app, form, obj, dataProviderLookup, listener, printing);
if (comp != null) {
if (obj instanceof Field) {
String name = ((Field) obj).getName();
if (name != null && !"".equals(name)) {
labelForComponents.put(name, comp);
}
} else if (obj instanceof GraphicalComponent && (comp instanceof WebBaseLabel || comp instanceof WebBaseSubmitLink)) {
String labelFor = ((GraphicalComponent) obj).getLabelFor();
if (labelFor != null && !"".equals(labelFor)) {
labelForComponents.put(comp, labelFor);
}
}
if ((obj instanceof ISupportTabSeq) && (tabSequence != null)) {
tabSequence.add(panel, (ISupportTabSeq) obj, comp);
}
org.apache.wicket.Component newComp = comp;
if (newComp instanceof IDisplay) {
panel.addDisplayComponent(obj, (IDisplay) newComp);
} else if (newComp instanceof WebImageBeanHolder) {
WebImageBeanHolder wiBeanHolder = (WebImageBeanHolder) newComp;
Object bean = wiBeanHolder.getDelegate();
if (bean instanceof IServoyAwareBean) {
IServoyAwareBean ourBean = (IServoyAwareBean) bean;
panel.addDisplayComponent(obj, ourBean);
}
}
((IComponent) comp).setLocation(new Point((l.x), (l.y - start)));
if (form.getOnRecordEditStartMethodID() > 0 && comp instanceof IFieldComponent) {
if (useAJAX && comp instanceof IDisplayData && ((IDisplayData) comp).getDataProviderID() != null && !ScopesUtils.isVariableScope(((IDisplayData) comp).getDataProviderID())) {
StartEditOnFocusGainedEventBehavior.addNewBehaviour(comp);
}
}
// - beans
if (isAnchoringEnabled && (((obj instanceof Field) && WebAnchoringHelper.needsWrapperDivForAnchoring((Field) obj)) || (obj instanceof Bean) || ((obj instanceof GraphicalComponent) && ComponentFactory.isButton((GraphicalComponent) obj)))) {
panel.add(WebAnchoringHelper.getWrapperComponent(comp, obj, start, panel.getSize(), leftToRight, false));
} else {
panel.add(comp);
}
}
}
}
}
Iterator it = labelForComponents.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Entry) it.next();
Object key = entry.getKey();
if (key instanceof WebBaseLabel || key instanceof WebBaseSubmitLink) {
IFieldComponent component = (IFieldComponent) labelForComponents.get(entry.getValue());
if (component != null) {
if (key instanceof WebBaseLabel) {
((WebBaseLabel) entry.getKey()).setLabelFor(component);
} else {
((WebBaseSubmitLink) entry.getKey()).setLabelFor(component);
}
(component).addLabelFor((ILabel) entry.getKey());
if (!component.isVisible()) {
component.setComponentVisible(component.isVisible());
}
if (!component.isEnabled()) {
component.setComponentEnabled(component.isEnabled());
}
}
}
}
it = emptyDataRenderers.values().iterator();
while (it.hasNext()) {
WebDataRenderer panel = (WebDataRenderer) it.next();
panel.createDataAdapter(app, dataProviderLookup, listener, undoManager);
}
return listTocomplete;
}
use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class EventCallTest method fillTestSolution.
@Override
protected void fillTestSolution() throws ServoyException {
Form form = solution.createNewForm(validator, null, "test", null, false, new Dimension(600, 400));
form.setNavigatorID(-1);
form.createNewScriptVariable(DummyValidator.INSTANCE, "testVar", IColumnTypes.INTEGER);
GraphicalComponent button = form.createNewGraphicalComponent(new Point(10, 10));
button.setShowClick(true);
button.setShowFocus(true);
ScriptMethod sm = form.createNewScriptMethod(DummyValidator.INSTANCE, "test");
sm.setDeclaration("function test() {testVar = 10}");
button.setOnActionMethodID(sm.getID());
form.createNewScriptVariable(DummyValidator.INSTANCE, "testVar2", IColumnTypes.TEXT);
GraphicalComponent button2 = form.createNewGraphicalComponent(new Point(10, 10));
button2.setName(uuid);
button2.setShowClick(true);
button2.setShowFocus(true);
ScriptMethod sm2 = form.createNewScriptMethod(DummyValidator.INSTANCE, "test2");
sm2.setDeclaration("function test2() {testVar2 = elements['" + uuid + "'].getName()}");
button2.setOnActionMethodID(sm2.getID());
}
use of com.servoy.j2db.persistence.GraphicalComponent in project servoy-client by Servoy.
the class ComponentFactory method createComponentEx.
protected static IComponent createComponentEx(IApplication application, Form form, IPersist meta, IDataProviderLookup dataProviderLookup, IScriptExecuter el, boolean printing) {
IComponent comp = null;
switch(meta.getTypeID()) {
case IRepository.FIELDS:
comp = createField(application, form, (Field) meta, dataProviderLookup, el, printing);
break;
case IRepository.GRAPHICALCOMPONENTS:
comp = createGraphicalComponent(application, form, (GraphicalComponent) meta, el, dataProviderLookup);
break;
case IRepository.RECTSHAPES:
comp = createRectangle(application, form, (RectShape) meta);
break;
case IRepository.PORTALS:
comp = createPortal(application, form, (Portal) meta, dataProviderLookup, el, printing);
break;
case IRepository.PARTS:
comp = createPart(application, (Part) meta);
break;
case IRepository.TABPANELS:
TabPanel tabPanelMeta = (TabPanel) meta;
int orient = tabPanelMeta.getTabOrientation();
if (orient == TabPanel.SPLIT_HORIZONTAL || orient == TabPanel.SPLIT_VERTICAL)
comp = createSplitPane(application, form, tabPanelMeta, el);
else
comp = createTabPanel(application, form, tabPanelMeta, el);
break;
case IRepository.BEANS:
comp = createBean(application, form, (Bean) meta, null);
break;
case IRepository.WEBCOMPONENTS:
comp = createWebComponentPlaceholder(application, form, (WebComponent) meta);
break;
default:
Debug.error("ComponentFactory:unkown type " + meta.getTypeID() + ", uuid: " + meta.getUUID() + ", parent:" + meta.getParent());
IStandardLabel label = application.getItemFactory().createLabel(getWebID(form, meta), "ComponentFactory:unkown type " + meta.getTypeID());
label.setSize(new Dimension(200, 20));
comp = label;
}
if (comp instanceof JComponent) {
((JComponent) comp).putClientProperty("Id", ComponentFactory.getWebID(form, meta));
}
return comp;
}
Aggregations