use of com.servoy.j2db.ui.ITabPanel in project servoy-client by Servoy.
the class ComponentFactory method createComponent.
/**
* Create a component
*
* @param meta the definition
* @param el the event listener such as action,mouse event listeners, can be null (Example:makes possible for button to call script)
*/
public static IComponent createComponent(IApplication application, Form form, IPersist meta, IDataProviderLookup dataProviderLookup, IScriptExecuter el, boolean printing) {
IComponent c = createComponentEx(application, form, meta, dataProviderLookup, el, printing);
// set groupID property
if (meta instanceof IFormElement && ((IFormElement) meta).getGroupID() != null) {
String groupId = ((IFormElement) meta).getGroupID();
if (groupId != null) {
setComponentProperty(application, c, GROUPID_COMPONENT_PROPERTY, groupId);
}
}
// Extra call so that focusable is user set...
if (c instanceof Component) {
Component comp = (Component) c;
if (comp.isFocusable())
comp.setFocusable(true);
OrientationApplier.setOrientationToAWTComponent(comp, application.getLocale(), application.getSolution().getTextOrientation());
}
int access = application.getFlattenedSolution().getSecurityAccess(meta.getUUID(), form.getImplicitSecurityNoRights() ? IRepository.IMPLICIT_FORM_NO_ACCESS : IRepository.IMPLICIT_FORM_ACCESS);
if (access != -1) {
boolean b_visible = ((access & IRepository.VIEWABLE) != 0);
if (!b_visible) {
if (c instanceof ISupportSecuritySettings) {
((ISupportSecuritySettings) c).setViewable(false);
} else {
c.setComponentVisible(false);
}
}
if (c instanceof ISupportSecuritySettings) {
boolean b_accessible = ((access & IRepository.ACCESSIBLE) != 0);
if (!b_accessible)
((ISupportSecuritySettings) c).setAccessible(false);
}
}
// special case requested by ayton (have own security interface)
if (c instanceof ITabPanel && meta instanceof TabPanel) {
try {
int i = 0;
Iterator<IPersist> it = ((TabPanel) meta).getTabs();
while (it.hasNext()) {
Tab t = (Tab) it.next();
int access1 = application.getFlattenedSolution().getSecurityAccess(t.getUUID(), form.getImplicitSecurityNoRights() ? IRepository.IMPLICIT_FORM_NO_ACCESS : IRepository.IMPLICIT_FORM_ACCESS);
if (access1 != -1) {
boolean b_accessible = ((access1 & IRepository.ACCESSIBLE) != 0);
boolean b_visible = ((access & IRepository.VIEWABLE) != 0);
if (!b_accessible || !b_visible)
((ITabPanel) c).setTabEnabledAt(i, false);
}
i++;
}
} catch (Exception e) {
Debug.error(e);
}
}
return c;
}
Aggregations