use of com.servoy.j2db.persistence.ISupportAnchors in project servoy-client by Servoy.
the class WebForm method getBounds.
public Rectangle getBounds(IComponent component) {
if (// $NON-NLS-1$
component instanceof Component && Utils.getAsBoolean(formController.getApplication().getRuntimeProperties().get("enableAnchors"))) {
IPersist persist = getPersist(((Component) component).getId());
if (persist instanceof ISupportAnchors && ((ISupportAnchors) persist).getAnchors() > 0 && ((ISupportAnchors) persist).getAnchors() != IAnchorConstants.DEFAULT) {
int anchors = ((ISupportAnchors) persist).getAnchors();
IDataRenderer renderer = ((Component) component).findParent(IDataRenderer.class);
int partHeight = 0;
if (renderer != null) {
partHeight = renderer.getSize().height;
}
int designWidth = formController.getForm().getWidth();
int designHeight = 0;
Part part = formController.getForm().getPartAt(((BaseComponent) persist).getLocation().y);
if (part != null) {
int top = formController.getForm().getPartStartYPos(part.getID());
designHeight = part.getHeight() - top;
}
if (partHeight > 0 && formWidth > 0 && designWidth > 0 && designHeight > 0) {
int navid = formController.getForm().getNavigatorID();
int navigatorWidth = 0;
if (navid == Form.NAVIGATOR_DEFAULT && formController.getForm().getView() != FormController.TABLE_VIEW && formController.getForm().getView() != FormController.LOCKED_TABLE_VIEW) {
navigatorWidth = WebDefaultRecordNavigator.DEFAULT_WIDTH;
} else if (navid != Form.NAVIGATOR_NONE) {
ISupportNavigator navigatorSupport = findParent(ISupportNavigator.class);
if (navigatorSupport != null) {
FormController currentNavFC = navigatorSupport.getNavigator();
if (currentNavFC != null) {
navigatorWidth = currentNavFC.getForm().getWidth();
}
}
}
Rectangle bounds = new Rectangle(component.getLocation(), component.getSize());
if ((anchors & IAnchorConstants.EAST) != 0 && (anchors & IAnchorConstants.WEST) == 0) {
bounds.x += formWidth - designWidth - navigatorWidth;
}
if ((anchors & IAnchorConstants.SOUTH) != 0 && (anchors & IAnchorConstants.NORTH) == 0) {
bounds.y += partHeight - designHeight;
}
if ((anchors & IAnchorConstants.EAST) != 0 && (anchors & IAnchorConstants.WEST) != 0 && (formWidth - designWidth - navigatorWidth > 0)) {
bounds.width += formWidth - designWidth - navigatorWidth;
}
if ((anchors & IAnchorConstants.SOUTH) != 0 && (anchors & IAnchorConstants.NORTH) != 0 && (partHeight - designHeight > 0)) {
bounds.height += partHeight - designHeight;
}
return bounds;
}
}
}
return null;
}
use of com.servoy.j2db.persistence.ISupportAnchors in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method distributeExtraSpace.
private void distributeExtraSpace() {
int totalDefaultWidth = 0;
int totalWidthToStretch = 0;
int stretchedElementsCount = 0;
for (IPersist element : elementToColumnIdentifierComponent.keySet()) {
Object scriptobject = elementToColumnIdentifierComponent.get(element);
if (!((Component) scriptobject).isVisible())
continue;
if (scriptobject instanceof IScriptableProvider) {
scriptobject = ((IScriptableProvider) scriptobject).getScriptObject();
}
if (scriptobject instanceof IRuntimeComponent) {
int width = ((IRuntimeComponent) scriptobject).getWidth();
totalDefaultWidth += width;
if (element instanceof ISupportAnchors) {
int anchors = ((ISupportAnchors) element).getAnchors();
if (((anchors & IAnchorConstants.EAST) != 0) && ((anchors & IAnchorConstants.WEST) != 0)) {
totalWidthToStretch += width;
stretchedElementsCount++;
}
}
}
}
boolean shouldFillAllHorizSpace = shouldFillAllHorizontalSpace();
if (shouldFillAllHorizSpace) {
if (stretchedElementsCount > 0) {
int delta = getDisplayBodyWidthHint() - totalDefaultWidth;
distributeExtraSpace(delta, totalWidthToStretch, null, true);
setHeadersWidth();
}
}
}
use of com.servoy.j2db.persistence.ISupportAnchors in project servoy-client by Servoy.
the class SortableCellViewHeaders method isReorderableOrResizable.
private boolean isReorderableOrResizable() {
if (// $NON-NLS-1$
Utils.getAsBoolean(application.getRuntimeProperties().get("useAJAX"))) {
boolean isReorderable = false;
boolean isResizable = false;
Iterator<IPersist> iter = cellview.getAllObjects();
while (iter.hasNext()) {
IPersist element = iter.next();
if (element instanceof ISupportAnchors) {
int anchors = ((ISupportAnchors) element).getAnchors();
isResizable = ((anchors & IAnchorConstants.EAST) == IAnchorConstants.EAST) && ((anchors & IAnchorConstants.WEST) == IAnchorConstants.WEST);
isResizable = isResizable && (!(cellview instanceof Portal) || ((Portal) cellview).getResizable());
if (isResizable)
return true;
isReorderable = !(((anchors & IAnchorConstants.NORTH) == IAnchorConstants.NORTH) && ((anchors & IAnchorConstants.SOUTH) == IAnchorConstants.SOUTH));
isReorderable = isReorderable && (!(cellview instanceof Portal) || ((Portal) cellview).getReorderable());
if (isReorderable)
return true;
}
}
}
return false;
}
use of com.servoy.j2db.persistence.ISupportAnchors in project servoy-client by Servoy.
the class DataRendererFactory method placeElements.
// returns usesSliding
private Map placeElements(Iterator<IFormElement> e1, IApplication app, Form form, IScriptExecuter listner, Map emptyDataRenderers, int width, int XCorrection, int YCorrection, boolean printing, boolean cutDataProviderNames, ControllerUndoManager undoManager, boolean isPortal, TabSequenceHelper<Component> tabSequence) throws Exception {
IDataProviderLookup dataProviderLookup = app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), form);
Map listTocomplete = new HashMap();
Map labelForComponents = new HashMap();
// Insets insets = new Insets(0, 0, 0, 0);
while (e1.hasNext()) {
Point l = null;
IPersist obj = e1.next();
l = ((IFormElement) obj).getLocation();
// unkown 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()) {
DataRenderer panel = (DataRenderer) it.next();
int start = panel.getLocation().y;
if (l.y >= start && l.y < start + panel.getSize().height) {
Component comp = (Component) ComponentFactory.createComponent(app, form, obj, dataProviderLookup, listner, printing);
// Test for a visible bean, then get the real component
if (comp instanceof VisibleBean) {
comp = ((VisibleBean) comp).getDelegate();
}
if (comp != null) {
if (obj instanceof Field && comp instanceof JComponent) {
String name = ((Field) obj).getName();
if (name != null && !"".equals(name)) {
labelForComponents.put(name, comp);
}
} else if (obj instanceof GraphicalComponent && comp instanceof JLabel) {
String labelFor = ((GraphicalComponent) obj).getLabelFor();
if (labelFor != null && !"".equals(labelFor)) {
labelForComponents.put(comp, labelFor);
}
}
if (obj instanceof ISupportTabSeq && comp instanceof JComponent && (tabSequence != null)) {
tabSequence.add(panel, (ISupportTabSeq) obj, comp);
}
Component newComp = comp;
if (newComp instanceof IDisplay) {
// HACK:don;t no other way to do this.........
if (newComp instanceof IDisplayData && cutDataProviderNames) {
IDisplayData da = (IDisplayData) newComp;
String id = da.getDataProviderID();
if (id != null && !ScopesUtils.isVariableScope(id)) {
// only cut first relation (so you can have relation chain inside portal)
int index = id.indexOf('.');
// TODO:check if part before . is same as relation name (objToRender.getRelationID() )
if (index > 0) {
id = id.substring(index + 1);
}
da.setDataProviderID(id);
}
}
panel.addDisplayComponent(obj, (IDisplay) newComp);
}
comp.setLocation((l.x) + XCorrection, (l.y - start) + YCorrection);
int index = 0;
if (!printing && obj instanceof ISupportAnchors) {
panel.add(comp, new Integer(((ISupportAnchors) obj).getAnchors()), index);
} else if (printing) {
if (obj instanceof ISupportPrintSliding && !isPortal) {
int slide = ((ISupportPrintSliding) obj).getPrintSliding();
if (slide != ISupportPrintSliding.NO_SLIDING) {
listTocomplete.put(comp, new Integer(slide));
panel.setUsingSliding(true);
}
}
panel.add(comp, index);
} else {
panel.add(comp, index);
}
}
}
}
}
if (!printing) {
Iterator it = labelForComponents.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Entry) it.next();
if (entry.getKey() instanceof JLabel) {
JComponent component = (JComponent) labelForComponents.get(entry.getValue());
if (component != null) {
((JLabel) entry.getKey()).setLabelFor(component);
if (component instanceof IFieldComponent) {
((IFieldComponent) component).addLabelFor((ILabel) entry.getKey());
if (!((IFieldComponent) component).isVisible()) {
((IFieldComponent) component).setComponentVisible(((IFieldComponent) component).isVisible());
}
if (!((IFieldComponent) component).isEnabled()) {
((IFieldComponent) component).setComponentEnabled(((IFieldComponent) component).isEnabled());
}
}
}
}
}
}
Iterator it = emptyDataRenderers.values().iterator();
while (it.hasNext()) {
DataRenderer panel = (DataRenderer) it.next();
panel.createDataAdapter(app, dataProviderLookup, listner, undoManager);
}
return listTocomplete;
}
use of com.servoy.j2db.persistence.ISupportAnchors in project servoy-client by Servoy.
the class RuntimeWebComponent method isApiFunctionEnabled.
protected boolean isApiFunctionEnabled(String functionName) {
boolean isLocationOrSize = "getLocationX".equals(functionName) || "getLocationY".equals(functionName) || "getWidth".equals(functionName) || "getHeight".equals(functionName);
if (isLocationOrSize) {
// if parent form not visible, don't call api, let it get from the model on the server
Container parent = component.getParent();
while (parent != null) {
if (parent instanceof WebFormUI) {
boolean isFormVisible = false;
IWindow currentWindow = CurrentWindow.safeGet();
if (currentWindow instanceof INGClientWindow) {
isFormVisible = ((INGClientWindow) currentWindow).hasForm(parent.getName());
}
if (isFormVisible) {
// it is reported to be still on the client
// but do check also if it is not about to be hidden, by having
// formVisible already set to false in the controller
isFormVisible = ((WebFormUI) parent).getController().isFormVisible();
}
if (!isFormVisible) {
return false;
}
// if this form is in designer mode then it has to go to the client to get the current size/location
if (((WebFormUI) parent).getController().getDesignModeCallbacks() != null)
return true;
break;
}
parent = parent.getParent();
}
// if it is not table view (it can have columns moved/resize) and not anchored, no need to call api, let it get from the model on the server
FormElement fe = component.getFormElement();
if (fe.isLegacy() && fe.getPersistIfAvailable() instanceof ISupportAnchors && (fe.getForm().getView() != FormController.TABLE_VIEW && fe.getForm().getView() != FormController.LOCKED_TABLE_VIEW)) {
// ((ISupportAnchors)fe.getPersistIfAvailable()).getAnchors();
int anchor = Utils.getAsInteger(component.getProperty(StaticContentSpecLoader.PROPERTY_ANCHORS.getPropertyName()));
if ((anchor == 0 || anchor == (IAnchorConstants.NORTH + IAnchorConstants.WEST))) {
return false;
}
}
}
return true;
}
Aggregations