use of com.servoy.j2db.ui.IDataRenderer in project servoy-client by Servoy.
the class SwingForm method setTabSeqComponents.
public void setTabSeqComponents(List<Component> tabSequence) {
IDataRenderer formEditorRenderer = formController.getDataRenderers()[FormController.FORM_EDITOR];
if (formEditorRenderer instanceof TableView && (tabSequence == null || !tabSequence.contains(formEditorRenderer))) {
// table view should be added to tab sequence
((TableView) formEditorRenderer).setTabSeqComponents(tabSequence);
if (tabSequence != null && tabSequence.size() > 0) {
// this means that we have to identify components that are part of the table view and based on where these are located set the view's tabIndex
// when called from JS tabSequence will only contain table columns, not table view as opposed to initialization when tabSequence only contains the view
int i;
for (i = 0; i < tabSequence.size(); i++) {
if (((TableView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
tabSequence = new ArrayList<Component>(tabSequence);
tabSequence.add(i, (Component) formEditorRenderer);
break;
}
}
i++;
while (i < tabSequence.size()) {
if (((TableView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
tabSequence.remove(i);
} else {
i++;
}
}
}
}
this.tabSeqComponentList = tabSequence;
if (tabSeqComponentList != null) {
if (tabSeqComponentList.size() > 0) {
JComponent lastComponent = (JComponent) tabSeqComponentList.get(tabSeqComponentList.size() - 1);
if (!(lastComponent instanceof SpecialTabPanel)) {
int modifier = 0;
if ((lastComponent instanceof TableView))
modifier = InputEvent.CTRL_DOWN_MASK;
if ((lastComponent instanceof DataComboBox) && ((DataComboBox) lastComponent).isEditable())
lastComponent = (JComponent) ((DataComboBox) lastComponent).getEditor().getEditorComponent();
addJumpOutActionToComponent(lastComponent, KeyStroke.getKeyStroke(KeyEvent.VK_TAB, modifier), ACTION_GO_OUT_TO_NEXT, false);
}
JComponent firstComponent = (JComponent) tabSeqComponentList.get(0);
if (!(firstComponent instanceof SpecialTabPanel)) {
int modifier = 0;
if ((firstComponent instanceof TableView))
modifier = InputEvent.CTRL_DOWN_MASK;
if ((firstComponent instanceof DataComboBox) && ((DataComboBox) firstComponent).isEditable())
firstComponent = (JComponent) ((DataComboBox) firstComponent).getEditor().getEditorComponent();
addJumpOutActionToComponent(firstComponent, KeyStroke.getKeyStroke(KeyEvent.VK_TAB, modifier | InputEvent.SHIFT_DOWN_MASK), ACTION_GO_OUT_TO_PREV, true);
}
}
}
}
use of com.servoy.j2db.ui.IDataRenderer in project servoy-client by Servoy.
the class SwingForm method makeElementsScriptObject.
/**
* @see com.servoy.j2db.IFormUIInternal#makeElementsScriptObject(org.mozilla.javascript.Scriptable)
*/
public ElementScope makeElementsScriptObject(Scriptable fs, Map<String, Object[]> hmChildrenJavaMembers, IDataRenderer[] dataRenderers, IView controller) {
ElementScope es = new ElementScope(fs);
int counter = 0;
for (int i = FormController.FORM_RENDERER + 1; i < dataRenderers.length; i++) {
IDataRenderer dr = dataRenderers[i];
if (dr == null)
continue;
Object[] comps = null;
Object[] compsRenderer = null;
if (dr instanceof DataRenderer) {
comps = ((DataRenderer) dr).getComponents();
if (i == FormController.FORM_EDITOR && dataRenderers[FormController.FORM_RENDERER] != null) {
compsRenderer = ((DataRenderer) dataRenderers[FormController.FORM_RENDERER]).getComponents();
}
} else if (dr instanceof TableView) {
TableView tv = (TableView) dr;
List<CellAdapter> nonViewableColumns = tv.getNonViewableColumns();
int componentCount = tv.getColumnCount() + nonViewableColumns.size();
comps = new Component[componentCount];
compsRenderer = new Component[componentCount];
CellAdapter[] tableCellAdapters = new CellAdapter[componentCount];
for (int j = 0; j < componentCount; j++) {
tableCellAdapters[j] = (j < tv.getColumnCount()) ? (CellAdapter) tv.getCellEditor(0, j) : nonViewableColumns.get(j - tv.getColumnCount());
comps[j] = tableCellAdapters[j].getEditor();
compsRenderer[j] = tableCellAdapters[j].getRenderer();
}
for (int j = 0; j < comps.length; j++) {
if (compsRenderer[j] instanceof Component && !((Component) compsRenderer[j]).isVisible()) {
tv.getColumnModel().removeColumn(tableCellAdapters[j]);
}
}
} else if (dr instanceof WebMarkupContainer) {
comps = new Object[((WebMarkupContainer) dr).size()];
Iterator<?> it = ((WebMarkupContainer) dr).iterator();
int j = 0;
while (it.hasNext()) {
comps[j++] = it.next();
}
}
counter = registerComponentsToScope(fs, es, counter, comps, compsRenderer, (Component) controller, hmChildrenJavaMembers);
}
es.setLocked(true);
return es;
}
use of com.servoy.j2db.ui.IDataRenderer in project servoy-client by Servoy.
the class TabSequenceHelper method fromAbstractToNamed.
public void fromAbstractToNamed() {
T tableViewToInsert = null;
int largestIndexBeforeBody = -1;
T lastComponentBeforeBody = null;
LinkedHashMap<T, String> componentGroupsByTabIndex = new LinkedHashMap<T, String>();
FormController fc = runtimeContainer.getController();
Form f = fc.getForm();
Iterator<Part> parts = f.getParts();
while (parts.hasNext()) {
Part p = parts.next();
IDataRenderer dataRenderer = fc.getDataRenderers()[p.getPartType()];
if (dataRenderer != null) {
// Later we will insert it in the tab sequence.
if ((fc.getViewComponent() instanceof IProvideTabSequence) && (p.getPartType() == Part.BODY)) {
tableViewToInsert = (T) dataRenderer;
} else {
SortedMap<ISupportTabSeq, T> dataRendererComponents = abstractTabSequence.get(dataRenderer);
if (dataRendererComponents != null) {
for (ISupportTabSeq supportTabSeq : dataRendererComponents.keySet()) {
if (supportTabSeq.getTabSeq() >= 0) {
T next = dataRendererComponents.get(supportTabSeq);
String name = null;
if (supportTabSeq instanceof ISupportName)
name = ((ISupportName) supportTabSeq).getName();
componentGroupsByTabIndex.put(next, name);
if ((p.getPartType() == Part.HEADER) || (p.getPartType() == Part.TITLE_HEADER) || (p.getPartType() == Part.LEADING_GRAND_SUMMARY)) {
if (supportTabSeq.getTabSeq() >= largestIndexBeforeBody) {
lastComponentBeforeBody = next;
largestIndexBeforeBody = supportTabSeq.getTabSeq();
}
}
}
}
}
}
}
}
componentsToNames.clear();
if ((lastComponentBeforeBody == null) && (tableViewToInsert != null))
componentsToNames.put(tableViewToInsert, null);
for (T o : componentGroupsByTabIndex.keySet()) {
componentsToNames.put(o, componentGroupsByTabIndex.get(o));
if ((tableViewToInsert != null) && (lastComponentBeforeBody != null) && (o.equals(lastComponentBeforeBody)))
componentsToNames.put(tableViewToInsert, null);
}
revertComponentsToNames();
fromNamedToRuntime();
}
use of com.servoy.j2db.ui.IDataRenderer in project servoy-client by Servoy.
the class DataRendererFactory method createPortalRenderer.
public IDataRenderer createPortalRenderer(IApplication app, Portal objToRender, Form dataProviderLookup, IScriptExecuter listner, boolean printing, ControllerUndoManager undoManager) throws Exception {
List<IPersist> allObjectsAsList = objToRender.getAllObjectsAsList();
List<IFormElement> formElements = new ArrayList<IFormElement>(allObjectsAsList.size());
for (IPersist persist : allObjectsAsList) {
if (persist instanceof IFormElement) {
formElements.add((IFormElement) persist);
}
}
List<IFormElement> children = new SortedList<IFormElement>(new Comparator<IFormElement>() {
public int compare(IFormElement o1, IFormElement o2) {
// reverse order, right order for tab sequence
int result = -PositionComparator.XY_PERSIST_COMPARATOR.compare(o1, o2);
if (result == 0) {
return (o1.getFormIndex() - o2.getFormIndex());
}
return result;
}
}, formElements);
Iterator<IFormElement> e1 = children.iterator();
Map emptyDataRenderers = new LinkedHashMap();
DataRenderer dr = null;
int height = objToRender.getRowHeight();
boolean calculateHeight = (height == 0);
// for safety
if (height == 0)
height = 100;
// int leftBorder = 0;
// int bottomBorder = 0;
// if (objToRender.getShowHorizontalLines())
// {
// bottomBorder = 1;
// }
// if (objToRender.getShowVerticalLines())
// {
// leftBorder = 4;
// }
boolean showSelection = objToRender.getShowVerticalLines();
dr = (DataRenderer) getEmptyDataRenderer(ComponentFactory.getWebID(dataProviderLookup, objToRender), "portal_" + objToRender.getName(), app, showSelection);
setBasicSettings(dr, objToRender.getBackground(), new Dimension(objToRender.getSize().width, height), new Point(0, 0), printing);
// first is dummy saying is portal
emptyDataRenderers.put(new Boolean(true), dr);
dr.setLocation(objToRender.getLocation());
Border b = ComponentFactoryHelper.createBorder(objToRender.getBorderType());
Insets ins = new Insets(0, 0, 0, 0);
if (b != null) {
ins = ComponentFactoryHelper.getBorderInsetsForNoComponent(b);
}
// if (b instanceof EmptyBorder)
// {
// ins = ((EmptyBorder)b).getBorderInsets();
// }
placeElements(e1, app, dataProviderLookup, listner, emptyDataRenderers, objToRender.getSize().width, -(objToRender.getLocation().x + ins.right), -ins.top, printing, true, undoManager, true, null);
int biggest_width = 10;
int biggest_height = calculateHeight ? 0 : height;
Component[] comps = dr.getComponents();
boolean hasRowBGColorCalc = objToRender.getRowBGColorCalculation() != null;
for (Component element : comps) {
int w = element.getLocation().x + element.getSize().width;
if (w > biggest_width)
biggest_width = w;
if (hasRowBGColorCalc && element instanceof JComponent)
((JComponent) element).setOpaque(false);
if (calculateHeight) {
int h = element.getLocation().y + element.getSize().height;
if (h > biggest_height)
biggest_height = h;
}
}
dr.setSize(new Dimension(biggest_width, biggest_height));
dr.setPreferredSize(new Dimension(biggest_width, biggest_height));
if (printing) {
// sliding inside a multiline portal renderer is nor supported, be we have to attach the springs for resizes
addSpringsBetweenComponents(app, dr);
}
return dr;
}
use of com.servoy.j2db.ui.IDataRenderer in project servoy-client by Servoy.
the class DataRendererFactory method setBasicSettings.
private void setBasicSettings(IDataRenderer panel, Color bg, Dimension size, Point location, boolean printing) {
DataRenderer dr = (DataRenderer) panel;
if (dr != null) {
if (bg != null) {
dr.setBackground(bg);
}
if (printing) {
dr.setLayout(new FixedSpringLayout());
} else {
dr.setLayout(new AnchorLayout(size));
dr.setPreferredSize(size);
}
dr.setSize(size);
dr.setLocation(location);
}
}
Aggregations