List of usage examples for org.apache.wicket Component getParent
@Override public final MarkupContainer getParent()
From source file:org.apache.syncope.client.console.pages.BasePage.java
License:Apache License
public BasePage(final PageParameters parameters) { super(parameters); // Native WebSocket add(new WebSocketBehavior() { private static final long serialVersionUID = 3109256773218160485L; @Override/*from w w w. ja v a2s . co m*/ protected void onConnect(final ConnectedMessage message) { super.onConnect(message); SyncopeConsoleSession.get().scheduleAtFixedRate(new ApprovalsWidget.ApprovalInfoUpdater(message), 0, 30, TimeUnit.SECONDS); if (BasePage.this instanceof Dashboard) { SyncopeConsoleSession.get().scheduleAtFixedRate(new JobWidget.JobInfoUpdater(message), 0, 10, TimeUnit.SECONDS); SyncopeConsoleSession.get().scheduleAtFixedRate( new ReconciliationWidget.ReconciliationJobInfoUpdater(message), 0, 10, TimeUnit.SECONDS); } } }); body = new WebMarkupContainer("body"); Serializable leftMenuCollapse = SyncopeConsoleSession.get() .getAttribute(SyncopeConsoleSession.MENU_COLLAPSE); if ((leftMenuCollapse instanceof Boolean) && ((Boolean) leftMenuCollapse)) { body.add(new AttributeAppender("class", " sidebar-collapse")); } add(body); notificationPanel = new NotificationPanel(Constants.FEEDBACK); body.addOrReplace(notificationPanel.setOutputMarkupId(true)); // header, footer body.add(new Label("version", SyncopeConsoleApplication.get().getVersion())); body.add(new Label("username", SyncopeConsoleSession.get().getSelfTO().getUsername())); body.add(new ApprovalsWidget("approvalsWidget", getPageReference()).setRenderBodyOnly(true)); // right sidebar SystemInfo systemInfo = SyncopeConsoleSession.get().getSystemInfo(); body.add(new Label("hostname", systemInfo.getHostname())); body.add(new Label("processors", systemInfo.getAvailableProcessors())); body.add(new Label("os", systemInfo.getOs())); body.add(new Label("jvm", systemInfo.getJvm())); Link<Void> dbExportLink = new Link<Void>("dbExportLink") { private static final long serialVersionUID = -4331619903296515985L; @Override public void onClick() { try { HttpResourceStream stream = new HttpResourceStream(new ConfigurationRestClient().dbExport()); ResourceStreamRequestHandler rsrh = new ResourceStreamRequestHandler(stream); rsrh.setFileName( stream.getFilename() == null ? SyncopeConsoleSession.get().getDomain() + "Content.xml" : stream.getFilename()); rsrh.setContentDisposition(ContentDisposition.ATTACHMENT); getRequestCycle().scheduleRequestHandlerAfterCurrent(rsrh); } catch (Exception e) { SyncopeConsoleSession.get().error(getString(Constants.ERROR) + ": " + e.getMessage()); } } }; MetaDataRoleAuthorizationStrategy.authorize(dbExportLink, WebPage.ENABLE, StandardEntitlement.CONFIGURATION_EXPORT); body.add(dbExportLink); // menu WebMarkupContainer liContainer = new WebMarkupContainer(getLIContainerId("dashboard")); body.add(liContainer); liContainer.add(BookmarkablePageLinkBuilder.build("dashboard", Dashboard.class)); liContainer = new WebMarkupContainer(getLIContainerId("realms")); body.add(liContainer); BookmarkablePageLink<? extends BasePage> link = BookmarkablePageLinkBuilder.build("realms", Realms.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.REALM_LIST); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("topology")); body.add(liContainer); link = BookmarkablePageLinkBuilder.build("topology", Topology.class); StringBuilder bld = new StringBuilder(); bld.append(StandardEntitlement.CONNECTOR_LIST).append(",").append(StandardEntitlement.RESOURCE_LIST) .append(","); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, bld.toString()); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("reports")); body.add(liContainer); link = BookmarkablePageLinkBuilder.build("reports", Reports.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.REPORT_LIST); liContainer.add(link); WebMarkupContainer confLIContainer = new WebMarkupContainer(getLIContainerId("configuration")); body.add(confLIContainer); WebMarkupContainer confULContainer = new WebMarkupContainer(getULContainerId("configuration")); confLIContainer.add(confULContainer); liContainer = new WebMarkupContainer(getLIContainerId("workflow")); confULContainer.add(liContainer); link = BookmarkablePageLinkBuilder.build("workflow", Workflow.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.WORKFLOW_DEF_READ); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("audit")); confULContainer.add(liContainer); link = BookmarkablePageLinkBuilder.build("audit", Audit.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.AUDIT_LIST); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("logs")); confULContainer.add(liContainer); link = BookmarkablePageLinkBuilder.build("logs", Logs.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.LOG_LIST); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("securityquestions")); confULContainer.add(liContainer); bld = new StringBuilder(); bld.append(StandardEntitlement.SECURITY_QUESTION_CREATE).append(",") .append(StandardEntitlement.SECURITY_QUESTION_DELETE).append(",") .append(StandardEntitlement.SECURITY_QUESTION_UPDATE); link = BookmarkablePageLinkBuilder.build("securityquestions", SecurityQuestions.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, bld.toString()); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("types")); confULContainer.add(liContainer); link = BookmarkablePageLinkBuilder.build("types", Types.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.SCHEMA_LIST); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("roles")); confULContainer.add(liContainer); link = BookmarkablePageLinkBuilder.build("roles", Roles.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.ROLE_LIST); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("policies")); confULContainer.add(liContainer); link = BookmarkablePageLinkBuilder.build("policies", Policies.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.POLICY_LIST); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("notifications")); confULContainer.add(liContainer); link = BookmarkablePageLinkBuilder.build("notifications", Notifications.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.NOTIFICATION_LIST); liContainer.add(link); liContainer = new WebMarkupContainer(getLIContainerId("parameters")); confULContainer.add(liContainer); link = BookmarkablePageLinkBuilder.build("parameters", Parameters.class); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.CONFIGURATION_LIST); liContainer.add(link); body.add(new AjaxLink<Void>("collapse") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { SyncopeConsoleSession.get().setAttribute(SyncopeConsoleSession.MENU_COLLAPSE, SyncopeConsoleSession.get().getAttribute(SyncopeConsoleSession.MENU_COLLAPSE) == null ? true : !(Boolean) SyncopeConsoleSession.get() .getAttribute(SyncopeConsoleSession.MENU_COLLAPSE)); } }); body.add(new Label("domain", SyncopeConsoleSession.get().getDomain())); body.add(new BookmarkablePageLink<Page>("logout", Logout.class)); // set 'active' menu item for everything but extensions // 1. check if current class is set to top-level menu Component containingLI = body.get(getLIContainerId(getClass().getSimpleName().toLowerCase())); // 2. if not, check if it is under 'Configuration' if (containingLI == null) { containingLI = confULContainer.get(getLIContainerId(getClass().getSimpleName().toLowerCase())); } // 3. when found, set CSS coordinates for menu if (containingLI != null) { containingLI.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("class", "active"); } }); if (confULContainer.getId().equals(containingLI.getParent().getId())) { confULContainer.add(new Behavior() { private static final long serialVersionUID = 3109256773218160485L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("class", "treeview-menu menu-open"); tag.put("style", "display: block;"); } }); confLIContainer.add(new Behavior() { private static final long serialVersionUID = 3109256773218160485L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("class", "treeview active"); } }); } } // Extensions ClassPathScanImplementationLookup classPathScanImplementationLookup = (ClassPathScanImplementationLookup) SyncopeConsoleApplication .get().getServletContext().getAttribute(ConsoleInitializer.CLASSPATH_LOOKUP); List<Class<? extends BaseExtPage>> extPageClasses = classPathScanImplementationLookup.getExtPageClasses(); WebMarkupContainer extensionsLI = new WebMarkupContainer(getLIContainerId("extensions")); extensionsLI.setOutputMarkupPlaceholderTag(true); extensionsLI.setVisible(!extPageClasses.isEmpty()); body.add(extensionsLI); ListView<Class<? extends BaseExtPage>> extPages = new ListView<Class<? extends BaseExtPage>>("extPages", extPageClasses) { private static final long serialVersionUID = 4949588177564901031L; @Override protected void populateItem(final ListItem<Class<? extends BaseExtPage>> item) { WebMarkupContainer containingLI = new WebMarkupContainer("extPageLI"); item.add(containingLI); if (item.getModelObject().equals(BasePage.this.getClass())) { containingLI.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("class", "active"); } }); } ExtPage ann = item.getModelObject().getAnnotation(ExtPage.class); BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("extPage", item.getModelObject()); link.add(new Label("extPageLabel", ann.label())); MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, ann.listEntitlement()); containingLI.add(link); Label extPageIcon = new Label("extPageIcon"); extPageIcon.add(new AttributeModifier("class", "fa " + ann.icon())); link.add(extPageIcon); } }; extPages.setOutputMarkupId(true); extensionsLI.add(extPages); if (getPage() instanceof BaseExtPage) { extPages.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("class", "treeview-menu menu-open"); tag.put("style", "display: block;"); } }); extensionsLI.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("class", "treeview active"); } }); } }
From source file:org.artifactory.addon.wicket.disabledaddon.DisabledAddonMenuNode.java
License:Open Source License
@Override public void onNewLink(Component link) { super.onNewLink(link); link.getParent().add(new DisabledAddonBehavior(addon)); }
From source file:org.artifactory.common.wicket.component.links.TitledSubmitLink.java
License:Open Source License
@Override public String getInputName() { // TODO: This is a copy & paste from the FormComponent class. String id = getId();/* w w w.ja v a 2 s.co m*/ final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length()); Component c = this; while (true) { inputName.prepend(id); c = c.getParent(); if (c == null || (c instanceof Form && ((Form) c).isRootForm()) || c instanceof Page) { break; } inputName.prepend(Component.PATH_SEPARATOR); id = c.getId(); } // having input name "submit" causes problems with javascript, so we // create a unique string to replace it by prepending a path separator if ("submit".equals(inputName.toString())) { inputName.prepend(Component.PATH_SEPARATOR); } return inputName.toString(); }
From source file:org.cast.cwm.service.EventService.java
License:Open Source License
@SuppressWarnings("unchecked") protected void gatherEventDataContributions(Event event, Component component) { if (component.getParent() != null) gatherEventDataContributions(event, component.getParent()); if (component instanceof IEventDataContributor) { ((IEventDataContributor) component).contributeEventData(event); }//from w ww .j a va 2 s . c o m }
From source file:org.cipango.ims.hss.web.gba.NafGroupBrowserPage.java
License:Apache License
@SuppressWarnings("unchecked") public NafGroupBrowserPage(PageParameters pageParameters) { IDataProvider<NafGroup> provider = new AbstractListDataProvider<NafGroup>() { @Override/* www . j ava2 s .c om*/ public List<NafGroup> load() { return _dao.getAllGroups(); } public IModel<NafGroup> model(NafGroup nafGroup) { return new CompoundPropertyModel<NafGroup>(new DaoDetachableModel(nafGroup)) { @Override protected String propertyExpression(Component component) { if (component.getParent() instanceof EditableLabel) return component.getParent().getId(); return component.getId(); } }; } }; WebMarkupContainer container = new WebMarkupContainer("browser"); container.setOutputMarkupId(true); add(container); container.add(new DataView<NafGroup>("nafGroup", provider, getItemByPage()) { @Override protected void populateItem(final Item<NafGroup> item) { NafGroup nafGroup = item.getModelObject(); Form form = new Form("form", item.getModel()); item.add(form); form.add(new EditableLabel("name")); form.add(new AjaxFallbackButton("apply", form) { @Override protected void doSubmit(AjaxRequestTarget target, Form<?> form) throws Exception { NafGroup nafGroup = (NafGroup) form.getDefaultModelObject(); _dao.save(nafGroup); EditableLabel name = (EditableLabel) form.get("name"); name.setEditable(false); setVisible(false); if (target != null) target.addComponent(item); } }.setVisible(false)); item.add(new Label("nbUss", String.valueOf(nafGroup.getUssSet().size()))); item.add(new AjaxFallbackLink("editLink") { @Override public void onClick(AjaxRequestTarget target) { EditableLabel name = (EditableLabel) item.get("form:name"); item.get("form:apply").setVisible(true); name.setEditable(true); if (target != null) target.addComponent(item); } }); item.add(new AjaxFallbackLink("deleteLink") { @Override public void onClick(AjaxRequestTarget target) { NafGroup nafGroup = (NafGroup) getParent().getDefaultModelObject(); _dao.delete(nafGroup); if (target != null) target.addComponent(getPage().get("browser")); } }); item.setOutputMarkupId(true); item.add(new OddEvenAttrModifier(item.getIndex())); } }); Form form = new Form("form", new CompoundPropertyModel(new DaoDetachableModel(null))); add(form); form.add(new RequiredTextField("name", String.class)); form.add(new AjaxFallbackButton("submit", form) { @Override protected void doSubmit(AjaxRequestTarget target, Form<?> form) throws Exception { try { _dao.save((NafGroup) form.getDefaultModelObject()); if (target != null) { target.addComponent(getPage().get("browser")); } } catch (Exception e) { __log.debug("Failed to apply edit", e); getSession().error(getString("nafGroup.error.duplicate", getForm().getModel())); } } }); setContextMenu(new ServicesContextPanel()); }
From source file:org.dcm4chee.web.common.behaviours.TooltipBehaviour.java
License:LGPL
private String generateComponentTreePrefix(Component c) { generateComponentTreePrefix = false; StringBuilder sb = new StringBuilder(""); Component parent = c.getParent(); while ((parent != null) && !parent.equals("") && !(parent instanceof BaseForm)) { sb.insert(0, "."); sb.insert(0, parent.getId());/*from ww w . j a va 2 s .c om*/ parent = parent.getParent(); } if ((prefix != null) && (!prefix.equals(""))) sb.insert(0, prefix); return sb.toString(); }
From source file:org.dcm4chee.wizard.common.behavior.TooltipBehavior.java
License:LGPL
private String generateComponentTreePrefix(Component component) { generateComponentTreePrefix = false; StringBuilder sb = new StringBuilder(""); Component parent = component.getParent(); while ((parent != null) && !parent.equals("") && !(parent instanceof ExtendedForm)) { sb.insert(0, "."); sb.insert(0, parent.getId());/*from w ww . jav a 2 s . c o m*/ parent = parent.getParent(); } if ((prefix != null) && (!prefix.equals(""))) sb.insert(0, prefix); return sb.toString(); }
From source file:org.devgateway.eudevfin.ui.common.events.CofinancingField14UpdateBehavior.java
License:Open Source License
@Override protected void onEventExtra(Component component, IEvent<?> event) { if (!component.getParent().getParent().getParent().getParent().isVisibleInHierarchy()) return;/* www . j ava2 s . c o m*/ Field14aChangedEventPayload eventPayload = getEventPayload(event); if (!eventPayload.getField14Code()) { component.setEnabled(false); component.setDefaultModelObject(null); } else component.setEnabled(true); }
From source file:org.devgateway.eudevfin.ui.common.events.DisbursementCurrentYearUpdateBehavior.java
License:Open Source License
@Override protected void onEventExtra(Component component, IEvent<?> event) { if (!component.getParent().isVisibleInHierarchy()) return;// w ww. ja v a 2 s . c om ReportingYearChangedEventPayload eventPayload = getEventPayload(event); if (Calendar.getInstance().get(Calendar.YEAR) == eventPayload.getReportingYear()) { component.setEnabled(false); component.setDefaultModelObject(null); } else component.setEnabled(true); }
From source file:org.devgateway.eudevfin.ui.common.events.LoansField12UpdateBehavior.java
License:Open Source License
@Override protected void onEventExtra(Component component, IEvent<?> event) { if (!component.getParent().getParent().getParent().getParent().isVisibleInHierarchy()) return;/*from ww w . j ava 2s. c o m*/ Field12ChangedEventPayload eventPayload = getEventPayload(event); if (pattern.matcher(eventPayload.getField12Code()).matches()) { component.setEnabled(false); component.setDefaultModelObject(null); } else component.setEnabled(true); }