List of usage examples for org.apache.wicket Component configure
public final void configure()
From source file:com.googlecode.ounit.MainPage.java
License:Open Source License
public MainPage(PageParameters parameters) { super(parameters); log.debug("MainPage()"); if (getOunitSession() == null) throw new RuntimeException("No model attached to the page"); if (!getOunitSession().isPrepared()) { throw new RuntimeException("Main page requires a prepared session"); }// w w w . ja v a 2s.co m WebMarkupContainer quizPanel = new WebMarkupContainer("questiondiv"); mainForm.add(quizPanel); quizPanel .add(new QuizStateAttributeModifier(getOunitModel(), "class", "ou-question", "ou-closed-question")); final Component description = new HtmlFile("description"); quizPanel.add(description); quizPanel.add(new AnchorLink("descriptionlink", description)); final Component results = new HtmlFile("resultsFile"); quizPanel.add(results); quizPanel.add(new WebMarkupContainer("resultscaption") { private static final long serialVersionUID = 1L; protected void onConfigure() { super.onConfigure(); results.configure(); setVisible(results.isVisible()); }; }.add(new AnchorLink("resultslink", results))); /* * Generate TextAreas first, because we need editor objects as anchors * for the links */ ListView<ProjectTreeNode> lv = new ListView<ProjectTreeNode>("editors") { private static final long serialVersionUID = 1L; protected void populateItem(ListItem<ProjectTreeNode> item) { ProjectTreeNode node = item.getModelObject(); node.setEditor(item); TextArea<ProjectTreeNode> ta = new TextArea<ProjectTreeNode>("editorarea", new PropertyModel<ProjectTreeNode>(node, "fileContents")); ta.add(AttributeModifier.replace("title", node.getName())); ta.add(new QuizStateAttributeModifier(getOunitModel(), "readonly", null, "readonly")); item.add(ta); item.setOutputMarkupId(true); } }; quizPanel.add(lv); lv.setReuseItems(true); /* Force ListView to populate itself RIGHT NOW so state-less forms can work */ // FIXME: This is an internal function. Maybe implement some hack like this // http://osdir.com/ml/users-wicket.apache.org/2009-02/msg00925.html lv.internalPrepareForRender(false); /* * Populate tab header links */ quizPanel.add(new ListView<ProjectTreeNode>("editorcaptions") { private static final long serialVersionUID = 1L; protected void populateItem(ListItem<ProjectTreeNode> item) { ProjectTreeNode node = item.getModelObject(); item.add(new AnchorLink("editorlink", node.getEditor(), node.getName())); } }.setReuseItems(true)); final Component tree = new ExplorerTreePanel("tree"); quizPanel.add(tree); quizPanel.add(new WebMarkupContainer("treecaption") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); tree.configure(); setVisible(tree.isVisible()); } }); // FIXME: We shouldn't access it directly. Should use model or something quizPanel.add(new QuestionDownloadLink("download")); mainForm.add(new Button("compile") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); setVisible(!getOunitSession().isClosed()); } @Override public void onSubmit() { // FIXME: This is a hack that should go away as soon as sessions // start working properly redirected = true; setResponsePage(MainPage.class); OunitSession sess = getOunitSession(); // Check if student is out of attempts int attempt = sess.getAttempt(); int maxAttempts = sess.getMaxAttempts(); if (maxAttempts > 0) { if (attempt >= maxAttempts) sess.setClosed(true); /* * Skip build if out of attempts. This is a sanity check, it * shouldn't happen under normal circumstances */ if (attempt > maxAttempts) return; } sess.setAttempt(attempt + 1); boolean buildSuccessful = sess.build(); int marks = sess.getMarks(); if (marks == sess.getMaxMarks()) { // Max marks, grade NOW! sess.setClosed(true); } if (!buildSuccessful && !sess.isClosed()) { // Successful build, ask if student wants a partial grade setResponsePage(ConfirmPage.class); } } }); mainForm.add(new Label("attempt")); mainForm.add(new Label("maxAttempts") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); if (getOunitSession().isClosed()) { setVisible(false); } else { setVisible(getOunitSession().getMaxAttempts() > 0); } } }); }
From source file:org.cast.cwm.components.ShyContainer.java
License:Open Source License
private boolean someChildVisible() { Boolean found = this.visitChildren(new IVisitor<Component, Boolean>() { @Override/*from w ww . j ava2 s . c o m*/ public void component(Component component, final IVisit<Boolean> visit) { if (determineVisibility(component)) { visit.stop(true); } else { visit.dontGoDeeper(); } } private boolean determineVisibility(Component component) { component.configure(); return component.determineVisibility(); } }); return (found != null && found); }
From source file:org.devgateway.eudevfin.ui.common.components.VisibilityAwareContainer.java
License:Open Source License
@Override protected void onConfigure() { super.onConfigure(); final Model<Boolean> oneVisibleChild = Model.of(Boolean.FALSE); this.visitChildren(AbstractField.class, new IVisitor<Component, Object>() { @Override//from ww w . ja v a 2s . c om public void component(Component object, IVisit<Object> visit) { object.configure(); //force an early configure on the visited object if (object.determineVisibility()) { //use determineVisibility instead of isVisible, handles all cases! oneVisibleChild.setObject(Boolean.TRUE); visit.stop(); } } }); this.setVisibilityAllowed(oneVisibleChild.getObject()); }