List of usage examples for org.apache.wicket MarkupContainer getParent
@Override public final MarkupContainer getParent()
From source file:com.eltiland.ui.course.components.tree.ELTDefaultAbstractTree.java
License:Apache License
/** * Creates the indentation element. This element should be placed as first element in the tree * item markup to ensure proper indentation of the tree item. This implementation also takes * care of lines that connect nodes.//from w ww . jav a 2 s.co m * * @param parent The component parent * @param id The component id * @param node The tree node for which to create the indentation element * @param level The current level * @return The indentation component */ protected Component newIndentation(final MarkupContainer parent, final String id, final ELTTreeNode node, final int level) { WebMarkupContainer result = new WebMarkupContainer(id) { private static final long serialVersionUID = 1L; /** * {@inheritDoc} */ @Override public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { Response response = RequestCycle.get().getResponse(); ELTTreeNode parent = node.getParent(); CharSequence urls[] = new CharSequence[level]; for (int i = 0; i < level; ++i) { if (isNodeLast(parent)) { urls[i] = "indent-blank"; } else { urls[i] = "indent-line"; } if (parent != null) { parent = parent.getParent(); } } for (int i = level - 1; i >= 0; --i) { response.write("<span class=\"" + urls[i] + "\"></span>"); } } }; result.setRenderBodyOnly(true); return result; }
From source file:com.servoy.j2db.server.headlessclient.dataui.WebDataRendererFactory.java
License:Open Source License
/** * This method is the real tabIndex calculator for all forms in containers. When a container form is made visible, tabIndexes must be recalculated. * Having the tab sequence tree, the tab sequence order is the preorder traversal of the tree. All elements after modified container in tab sequence order will be recalculated. * A small gap for each container is used, so that chances that tabIndex should be changed when visible tab is different are smaller. * Browsers cannot deal with really big numbers of tabIndex (maximum is around 32k). WebCellBasedView is also a special case, some bigger gap is used for that (it will fill tabIndexes itself). *///ww w .j a v a 2 s. c o m public void reapplyTabSequence(IFormUIInternal containerImpl, int delta) { WebForm wf = (WebForm) containerImpl; WebForm currentForm = wf; IWebFormContainer currentTabPanel = null; boolean ready = false; int counter = delta + 1; do { List<Component> existingTabSequence = currentForm.getTabSeqComponents(); Iterator<Component> iter = existingTabSequence.iterator(); if (!containerImpl.equals(currentForm)) { while (iter.hasNext()) { Component c = iter.next(); if (c.equals(currentTabPanel)) { if (delta >= 0) { counter = getContainerGapIndex(counter, currentTabPanel.getTabSequenceIndex()); } break; } } } while (iter.hasNext()) { Component comp = iter.next(); if (comp instanceof IWebFormContainer) { counter = goDownContainer((IWebFormContainer) comp, delta >= 0 ? counter : ISupportWebTabSeq.SKIP); } else if (comp instanceof WebCellBasedView) { WebCellBasedView tableView = (WebCellBasedView) comp; tableView.setTabSequenceIndex(delta >= 0 ? counter : ISupportWebTabSeq.SKIP); counter += MAXIMUM_TAB_INDEXES_ON_TABLEVIEW; TabIndexHelper.setUpTabIndexAttributeModifier(comp, ISupportWebTabSeq.SKIP); } else { if (delta >= 0) { counter = setMaxTabIndex(comp, counter); } else { TabIndexHelper.setUpTabIndexAttributeModifier(comp, ISupportWebTabSeq.SKIP); } } } if (delta >= 0) { counter = getContainerGapIndex(counter, delta); } MarkupContainer parent = currentForm.getParent(); while ((parent != null) && !(parent instanceof IWebFormContainer)) parent = parent.getParent(); if (parent != null) { if (parent instanceof WebSplitPane) { ((WebSplitPane) parent).setFormLastTabIndex(currentForm, counter - 1); } currentTabPanel = (IWebFormContainer) parent; MarkupContainer tabParent = ((Component) currentTabPanel).getParent(); while ((tabParent != null) && !(tabParent instanceof WebForm)) tabParent = tabParent.getParent(); if (tabParent != null) { currentForm = (WebForm) tabParent; } else { ready = true; } } else { ready = true; } } while (!ready); }
From source file:com.servoy.j2db.server.headlessclient.dataui.WebTabFormLookup.java
License:Open Source License
public boolean isFormReady() { boolean isFormReady = true; WebForm wf = getWebForm(false);/* w w w. j ava 2 s . c om*/ if (wf != null) { MarkupContainer wfParent = wf.getParent(); if (wfParent instanceof WebTabPanel && ((WebTabPanel) wfParent).isVisible() && wfParent.getParent() != null) { boolean isTabPanelVisible = true; Component c = wfParent; WebForm pwf; while ((pwf = c.findParent(WebForm.class)) != null && (isTabPanelVisible = pwf.getController().isFormVisible()) == true) c = pwf; // if the form is current in another visible tabpanel, then it is not ready for this tabpanel isFormReady = !(isTabPanelVisible && wfParent != parent && ((WebTabPanel) wfParent).getCurrentForm() == wf); } } return isFormReady; }
From source file:com.servoy.j2db.server.headlessclient.SessionClient.java
License:Open Source License
@Override public String getFormNameFor(IComponent component) { if (component instanceof Component) { MarkupContainer parent = ((Component) component).getParent(); while (!(parent instanceof WebForm)) { parent = parent.getParent(); }/*ww w. j ava2 s.com*/ return ((WebForm) parent).getController().getName(); } return ""; //$NON-NLS-1$ }
From source file:com.servoy.j2db.server.headlessclient.WebForm.java
License:Open Source License
public JSDataSet getFormContext() { WebForm current = this; ITabPanel currentTabPanel = null;/*from w w w . ja va 2 s . c o m*/ String currentBeanName = null; WebSplitPane currentSplitPane = null; IDataSet set = new BufferedDataSet(new String[] { "containername", "formname", //$NON-NLS-1$//$NON-NLS-2$ "tabpanel/splitpane/accordion/beanname", "tabname", "tabindex", "tabindex1based" }, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ new ArrayList<Object[]>()); set.addRow(new Object[] { null, current.formController.getName(), null, null, null, null }); MarkupContainer parent = getParent(); while (parent != null) { if (parent instanceof WebSplitPane) { currentSplitPane = (WebSplitPane) parent; } else if (parent instanceof ITabPanel) { currentTabPanel = (ITabPanel) parent; } else if (parent instanceof IServoyAwareBean && parent instanceof IComponent) { currentBeanName = ((IComponent) parent).getName(); } else if (parent instanceof WebForm) { if (currentTabPanel != null) { int index = -1; String tabName = null; if (currentTabPanel instanceof WebTabPanel) { index = ((WebTabPanel) currentTabPanel).getTabIndex(current); } else if (currentTabPanel instanceof WebAccordionPanel) { index = ((WebAccordionPanel) currentTabPanel).getTabIndex(current); } if (index != -1) { tabName = currentTabPanel.getTabNameAt(index); // js method so +1 } current = (WebForm) parent; set.addRow(0, new Object[] { null, current.formController.getName(), currentTabPanel.getName(), tabName, new Integer(index), new Integer(index + 1) }); } else if (currentBeanName != null) { current = (WebForm) parent; set.addRow(0, new Object[] { null, current.formController.getName(), currentBeanName, null, null, null }); } else if (currentSplitPane != null) { int idx = currentSplitPane.getLeftForm() != null && current.equals(((WebTabFormLookup) currentSplitPane.getLeftForm()).getWebForm()) ? 0 : 1; current = (WebForm) parent; set.addRow(0, new Object[] { null, current.formController.getName(), currentSplitPane.getName(), currentSplitPane.getTabNameAt(idx), new Integer(idx + 1), new Integer(idx + 1) }); } current = (WebForm) parent; currentTabPanel = null; currentBeanName = null; currentSplitPane = null; } else if (parent instanceof MainPage) { String containerName = ((MainPage) parent).getContainerName(); if (containerName != null) { for (int i = 0; i < set.getRowCount(); i++) { set.getRow(i)[0] = containerName; } } return new JSDataSet(formController.getApplication(), set); } parent = parent.getParent(); } return new JSDataSet(formController.getApplication(), set); }
From source file:com.servoy.j2db.server.headlessclient.WebFormManager.java
License:Open Source License
public void reload(FormController[] fcontrollers) { HashSet<MainPage> mainPages = new HashSet<MainPage>(); for (FormController fc : fcontrollers) { WebForm formUI = (WebForm) fc.getFormUI(); MainPage mp = formUI.findParent(MainPage.class); if (mp != null && mainPages.add(mp)) { mp.setVersioned(false);//from w w w .j a va2 s . c om mp.setMainPageSwitched(); } } String navigatorName = null; Set<MainPage> parents = new HashSet<MainPage>(); for (FormController fp : fcontrollers) { if (fp != null) { boolean formVisible = fp.isFormVisible(); FoundSet foundset = fp.getFormModel(); WebForm wf = (WebForm) fp.getFormUI(); MarkupContainer wfParent = wf.getParent(); boolean refresh = false; //datasource has changed, but foundset has not if (foundset != null && !Utils.equalObjects(foundset.getDataSource(), fp.getDataSource())) { try { foundset = (FoundSet) (getApplication()).getFoundSetManager() .getSharedFoundSet(fp.getDataSource()); foundset.loadAllRecords(); refresh = true; } catch (ServoyException e) { Debug.error("Failed to reload foundset.", e); //$NON-NLS-1$ } } MainPage page = wf.findParent(MainPage.class); try { if (page != null) { page.setTempRemoveMainForm(true); } fp.destroy(); } finally { if (page != null) { page.setTempRemoveMainForm(false); } } while (wfParent != null && !(wfParent instanceof IWebFormContainer) && !(wfParent.getParent() instanceof MainPage) && !(wfParent.getParent() instanceof WebForm)) { wfParent = wfParent.getParent(); } if (wfParent instanceof IWebFormContainer) { if (formVisible) { FormController fc = leaseFormPanel(fp.getName()); if (fc != null) { // form was deleted in developer? fc.loadData(foundset, null); if (refresh) fc.recreateUI(); List<Runnable> runnables = new ArrayList<Runnable>(); ((IWebFormContainer) wfParent).notifyVisible(true, runnables); Utils.invokeLater(getApplication(), runnables); } } } else if (wfParent != null) { WebForm parentWF = wfParent.findParent(WebForm.class); if (parentWF != null) { if (!Arrays.asList(fcontrollers).contains(parentWF.getController())) parentWF.getController().destroy(); } else { MainPage parent = wfParent.findParent(MainPage.class); if (parent != null && !parents.contains(parent)) { parents.add(parent); if (parent.getNavigator() == fp) { navigatorName = fp.getName(); FormController navigator = getFormController(navigatorName, parent); if (navigator != null) { List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(); navigator.notifyVisible(true, invokeLaterRunnables); Utils.invokeLater(getApplication(), invokeLaterRunnables); parent.setNavigator(navigator); //parent.triggerBrowserRequestIfNeeded(); // FIXME: this is needed here but currently does nothing because the request target is not yet set } } FormController previousMainShowingForm = (parent != null ? parent.getController() : null); if (previousMainShowingForm != null) { FormController previousNavigator = parent.getNavigator(); parent.setController(null); // navigator is not re-applied so apply it manually int navigatorID = previousMainShowingForm.getForm().getNavigatorID(); if (navigatorID == Form.NAVIGATOR_IGNORE || (previousNavigator != null && previousNavigator.getForm().getID() == navigatorID)) { parent.setNavigator(previousNavigator); } else if (navigatorID > 0) { Form newNavigator = application.getFlattenedSolution().getForm(navigatorID); if (newNavigator != null) { parent.setNavigator(leaseFormPanel(newNavigator.getName())); } } showFormInMainPanel(previousMainShowingForm.getName(), parent, null, true, null); // parent.triggerBrowserRequestIfNeeded(); // FIXME: this is needed here but currently does nothing because the request target is not yet set } } } } } } for (MainPage mainPage : mainPages) { mainPage.setVersioned(true); } }
From source file:com.swordlord.gozer.components.wicket.graph.GWStackedBarChartPanel.java
License:Open Source License
@Override protected void onClickCallback(AjaxRequestTarget target, ChartEntity entity) { if (gchart.isClickable()) { String subTitle = (String) ((CategoryItemEntity) entity).getRowKey(); String key = _target.get(subTitle); MarkupContainer parent = this; while (!(parent instanceof GWReport)) { parent = parent.getParent(); }/*www. j ava 2 s .c om*/ GWReport report = (GWReport) parent; ((ReportController) getFrameExtension().getGozerController()).replaceDetailsAction(target, report, gchart, key, subTitle); } }
From source file:guru.mmp.application.web.template.components.ExtensibleDialogImplementation.java
License:Apache License
/** * Returns the extensible and reusable modal dialog this implementation is associated with. * * @return the extensible and reusable modal dialog this implementation is associated with *///from w w w. j a va 2s .co m protected final ExtensibleDialog getDialog() { MarkupContainer parent = getParent(); while (parent != null) { if (parent instanceof ExtensibleDialog) { return (ExtensibleDialog) parent; } parent = parent.getParent(); } return null; }
From source file:guru.mmp.application.web.template.components.InputPanel.java
License:Apache License
/** * Returns the form this input panel is associated with. * * @return the form this input panel is associated with *//* w ww . j a va 2 s.c o m*/ public Form<?> getForm() { MarkupContainer parent = getParent(); while (parent != null) { if (parent instanceof Form<?>) { return (Form<?>) parent; } parent = parent.getParent(); } return null; }
From source file:ontopoly.pages.ModalGeoPickerPage.java
License:Apache License
private void findFields() { MarkupContainer container = this; while (!(container instanceof FieldInstancesPanel)) container = container.getParent(); FieldInstancesPanel parent = (FieldInstancesPanel) container; ListView<FieldInstanceModel> listView = parent.getFieldList(); Iterator<? extends ListItem<FieldInstanceModel>> itfim = listView.iterator(); while (itfim.hasNext()) { ListItem<FieldInstanceModel> li = itfim.next(); FieldInstance fi = li.getModelObject().getFieldInstance(); FieldAssignment fa = fi.getFieldAssignment(); FieldDefinition fd = fa.getFieldDefinition(); if (fd.getFieldType() != FieldDefinition.FIELD_TYPE_OCCURRENCE) continue; OccurrenceField of = (OccurrenceField) fd; OccurrenceType ot = of.getOccurrenceType(); if (ot == null) continue; Collection<LocatorIF> psis = ot.getTopicIF().getSubjectIdentifiers(); if (psis.contains(PSI.ON_LATITUDE) || psis.contains(PSI.ON_LONGITUDE)) { Iterator<? extends Component> it = li.iterator(); while (it.hasNext()) { Object component = it.next(); if (component instanceof FieldInstanceOccurrencePanel) { FieldInstanceOccurrencePanel fiop = (FieldInstanceOccurrencePanel) component; if (psis.contains(PSI.ON_LONGITUDE)) lngpan = fiop;/* w ww . j a v a 2 s . co m*/ else latpan = fiop; } } } } }