List of usage examples for org.apache.wicket.extensions.markup.html.tabs ITab isVisible
boolean isVisible();
From source file:com.googlecode.wicket.jquery.ui.widget.accordion.AccordionPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); this.add(new Loop("tabs", this.getCountModel()) { private static final long serialVersionUID = 1L; @Override//w w w. j a v a 2 s.c om protected void populateItem(LoopItem item) { int index = item.getIndex(); final ITab tab = AccordionPanel.this.getModelObject().get(index); if (tab.isVisible()) { item.add(AccordionPanel.this.newTitleLabel("title", tab.getTitle())); item.add(tab.getPanel("panel")); } } }); this.add(this.widgetBehavior = this.newWidgetBehavior(JQueryWidget.getSelector(this))); }
From source file:com.googlecode.wicket.jquery.ui.widget.tabs.TabbedPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); final RepeatingView panels = new RepeatingView("panels") { private static final long serialVersionUID = 1L; @Override/* w w w . j ava 2s . co m*/ public String newChildId() { return String.format("tab-%s-%s", this.getMarkupId(), super.newChildId()); //fixes issue #14 } @Override protected void onConfigure() { super.onConfigure(); this.removeAll(); //fixes issue #7 } }; this.add(panels); this.add(new ListView<ITab>("tabs", this.getModelObject()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<ITab> item) { final ITab tab = item.getModelObject(); if (tab.isVisible()) { final String newId = panels.newChildId(); // link (tab) // Label link = TabbedPanel.this.newTitleLabel("link", tab.getTitle()); link.add(AttributeModifier.replace("href", "#" + newId)); item.add(link); // panel // panels.add(tab.getPanel(newId).setMarkupId(newId).setOutputMarkupId(true)); } } }); this.add(this.widgetBehavior = this.newWidgetBehavior(JQueryWidget.getSelector(this))); }
From source file:com.googlecode.wicket.kendo.ui.widget.accordion.AccordionBehavior.java
License:Apache License
/** * Gets a read-only {@link ITab} {@link List} having its visible flag set to true. * * @return a {@link List} of {@link ITab}{@code s} *//*from ww w . ja v a 2s . c o m*/ protected List<ITab> getVisibleTabs() { List<ITab> list = new ArrayList<ITab>(); for (ITab tab : this.getTabs()) { if (tab.isVisible()) { list.add(tab); } } return Collections.unmodifiableList(list); }
From source file:com.googlecode.wicket.kendo.ui.widget.accordion.AccordionPanel.java
License:Apache License
/** * Gets the last <i>visible</i> tab index * * @return the tab index, or -1 if none//from w w w . j a va 2s . c om */ public int getLastTabIndex() { int index = -1; for (ITab tab : this.getModelObject()) { if (tab.isVisible()) { index++; } } return index; }
From source file:com.googlecode.wicket.kendo.ui.widget.accordion.AccordionPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); final WebMarkupContainer root = new WebMarkupContainer("root"); this.add(root); root.add(new Loop("tabs", this.getCountModel()) { private static final long serialVersionUID = 1L; @Override//from ww w .ja v a 2 s .c om protected LoopItem newItem(final int index) { ITab tab = AccordionPanel.this.getModelObject().get(index); LoopItem item = super.newItem(index); item.setVisible(tab.isVisible()); return item; } @Override protected void populateItem(LoopItem item) { int index = item.getIndex(); final ITab tab = AccordionPanel.this.getModelObject().get(index); item.add(AccordionPanel.this.newTitleLabel("title", tab.getTitle())); item.add(tab.getPanel("panel")); } }); this.widgetBehavior = JQueryWidget.newWidgetBehavior(this, root); this.add(this.widgetBehavior); }
From source file:com.googlecode.wicket.kendo.ui.widget.tabs.TabbedPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); final RepeatingView panels = new RepeatingView("panels") { private static final long serialVersionUID = 1L; @Override/*from w w w . j av a 2 s . co m*/ public String newChildId() { return String.format("tab-%s-%s", this.getMarkupId(), super.newChildId()); } @Override protected void onConfigure() { super.onConfigure(); this.removeAll(); } }; this.add(panels); this.add(new ListView<ITab>("tabs", this.getModelObject()) { private static final long serialVersionUID = 1L; @Override protected ListItem<ITab> newItem(int index, IModel<ITab> model) { ListItem<ITab> item = super.newItem(index, model); item.setVisible(model.getObject().isVisible()); return item; } @Override protected void populateItem(ListItem<ITab> item) { final ITab tab = item.getModelObject(); if (tab.isVisible()) { // link (tab) // item.add(TabbedPanel.this.newTitleLabel("title", tab.getTitle())); // panel // final String newId = panels.newChildId(); panels.add(tab.getPanel(newId).setMarkupId(newId).setOutputMarkupId(true)); } } }); this.widgetBehavior = JQueryWidget.newWidgetBehavior(this); this.add(this.widgetBehavior); }
From source file:org.jabylon.rest.ui.wicket.config.SettingsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public SettingsPanel(String id, IModel<T> model, PageParameters pageParameters) { super(id, model); EClass eclass = getEClassToCreate(pageParameters); if (eclass != null) { setModel(new AttachableWritableModel<T>(eclass, getModel())); }//from ww w. j a v a 2 s .c o m T modelObject = getModelObject(); boolean isNew = modelObject.cdoState() == CDOState.NEW || modelObject.cdoState() == CDOState.TRANSIENT; final Preferences preferences = isNew ? new AttachablePreferences() : new DelegatingPreferences(PreferencesUtil.scopeFor(modelObject)); final List<ITab> extensions = loadTabExtensions(preferences); // submit section @SuppressWarnings({ "rawtypes" }) Form form = new Form("form", getModel()) { private static final long serialVersionUID = 1L; String oldName; @Override protected void beforeUpdateFormComponentModels() { super.beforeUpdateFormComponentModels(); IModel model = getModel(); if (model != null && model.getObject() instanceof Resolvable) { //store the original project name in case it gets changed Resolvable resolvable = (Resolvable) model.getObject(); oldName = resolvable.getName(); } } @Override protected void onSubmit() { Preferences prefs = preferences; IModel<T> model = SettingsPanel.this.getModel(); CDOObject object = model.getObject(); CDOView cdoView; if (model instanceof AttachableModel) { // it's a new object that needs attaching AttachableModel<CDOObject> attachable = (AttachableModel) model; attachable.attach(); CDOObject parent = (CDOObject) attachable.getObject().eContainer(); cdoView = parent.cdoView(); } else cdoView = object.cdoView(); if (cdoView instanceof CDOTransaction) { CDOTransaction transaction = (CDOTransaction) cdoView; if (prefs instanceof AttachablePreferences) { // the prefs are not in the tree yet Preferences targetPrefs = PreferencesUtil.scopeFor(object); try { PreferencesUtil.cloneNode(prefs, targetPrefs); prefs = targetPrefs; } catch (BackingStoreException e) { error("Some settings could not be saved: " + e.getMessage()); logger.error("Failed to attach preferences to target path", e); } } if (oldName != null && !oldName .equals(model.getObject().eGet(PropertiesPackage.Literals.RESOLVABLE__NAME))) { renameResolvable(oldName, model); prefs = PreferencesUtil.renamePreferenceNode(preferences, (String) model.getObject().eGet(PropertiesPackage.Literals.RESOLVABLE__NAME)); } commit(prefs, object, transaction); // model.detach(); } else throw new IllegalStateException("not a transaction"); super.onSubmit(); } protected void commit(final Preferences preferences, CDOObject object, CDOTransaction transaction) { for (ConfigSection<?> section : allSections) { section.commit(getModel(), preferences); } try { transaction.commit(); URI uri = resolver.getURI(object); setResponsePage(SettingsPage.class, WicketUtil.buildPageParametersFor(uri)); preferences.flush(); getSession().success(getString("save.success.feedback.message")); } catch (CommitException e) { getSession().error(e.getMessage()); logger.error("failed to commit configuration for " + object, e); } catch (BackingStoreException e) { getSession().error(e.getMessage()); logger.error("failed to commit configuration for " + object, e); } finally { // transaction.close(); } } }; ClientSideTabbedPanel<ITab> tabContainer = new ClientSideTabbedPanel<ITab>("tabs", extensions, false, "settings/" + model.getObject().getClass().getSimpleName()) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { boolean visible = super.isVisible(); List<ITab> tabContents = extensions; for (ITab component : tabContents) { if (component.isVisible()) return visible; } CDOAuthenticatedSession session = (CDOAuthenticatedSession) CDOAuthenticatedSession.get(); User user = session.getUser(); if (user == null || CommonPermissions.USER_ANONYMOUS.equals(user.getName())) // user is not logged in, give him the chance throw new RestartResponseAtInterceptPageException(LoginPage.class); // if no tab is visible, the user has no permission to be here throw new UnauthorizedInstantiationException(SettingsPanel.class); } }; form.add(tabContainer); // form.add(new CustomFeedbackPanel("feedback")); Button submitButton = new Button("submit", new StringResourceModel("submit.button.label", this, null)); form.add(submitButton); // Button cancelButton = new Button("cancel-button", // Model.of("Cancel")); // form.add(cancelButton); add(form); }