📄 tabbedpanelpage.java
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.wicket.examples.compref;import java.util.ArrayList;import java.util.List;import org.apache.wicket.AttributeModifier;import org.apache.wicket.examples.WicketExamplePage;import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;import org.apache.wicket.extensions.markup.html.tabs.TabbedPanel;import org.apache.wicket.markup.html.link.Link;import org.apache.wicket.markup.html.panel.Panel;import org.apache.wicket.model.Model;/** * Reference page for TabbedPanel wicket-extensions component * * @see org.apache.wicket.extensions.markup.html.tabs.TabbedPanel * * @author igor * */public class TabbedPanelPage extends WicketExamplePage{ /** * Constructor */ public TabbedPanelPage() { setModel(new Model("tabpanel")); // create links used to switch between css variations addCssSwitchingLinks(); // create a list of ITab objects used to feed the tabbed panel List tabs = new ArrayList(); tabs.add(new AbstractTab(new Model("first tab")) { public Panel getPanel(String panelId) { return new TabPanel1(panelId); } }); tabs.add(new AbstractTab(new Model("second tab")) { public Panel getPanel(String panelId) { return new TabPanel2(panelId); } }); tabs.add(new AbstractTab(new Model("third tab")) { public Panel getPanel(String panelId) { return new TabPanel3(panelId); } }); // add the new tabbed panel, attribute modifier only used to switch // between different css variations add(new TabbedPanel("tabs", tabs).add(new AttributeModifier("class", true, TabbedPanelPage.this.getModel()))); } private void addCssSwitchingLinks() { add(new CssSwitchingLink("var0", "tabpanel")); add(new CssSwitchingLink("var1", "tabpanel1")); add(new CssSwitchingLink("var2", "tabpanel2")); add(new CssSwitchingLink("var3", "tabpanel3")); add(new CssSwitchingLink("var4", "tabpanel4")); } protected class CssSwitchingLink extends Link { private final String clazz; /** * @param id * @param clazz */ public CssSwitchingLink(String id, String clazz) { super(id); this.clazz = clazz; } /** * @see org.apache.wicket.markup.html.link.Link#onClick() */ public void onClick() { TabbedPanelPage.this.setModelObject(clazz); } /** * @see org.apache.wicket.markup.html.link.Link#isEnabled() */ public boolean isEnabled() { return !TabbedPanelPage.this.getModelObjectAsString().equals(clazz); } }; /** * Panel representing the content panel for the first tab * * @author Igor Vaynberg (ivaynberg) * */ private static class TabPanel1 extends Panel { /** * Constructor * * @param id * component id */ public TabPanel1(String id) { super(id); } }; /** * Panel representing the content panel for the second tab * * @author Igor Vaynberg (ivaynberg) * */ private static class TabPanel2 extends Panel { /** * Constructor * * @param id * component id */ public TabPanel2(String id) { super(id); } }; /** * Panel representing the content panel for the third tab * * @author Igor Vaynberg (ivaynberg) * */ private static class TabPanel3 extends Panel { /** * Constructor * * @param id * component id */ public TabPanel3(String id) { super(id); } }; protected void explain() { String html = "<span wicket:id=\"tabs\" class=\"tabpanel\">[tabbed panel will be here]</span>\n"; String code = " List tabs=new ArrayList();<br/>" + " tabs.add(new AbstractTab(new Model(\"first tab\")) {<br/>" + " public Panel getPanel(String panelId) { return new TabPanel1(panelId); }<br/>" + " });<br/>" + " tabs.add(new AbstractTab(new Model(\"second tab\")) {<br/>" + " public Panel getPanel(String panelId) { return new TabPanel2(panelId); }<br/>" + " });<br/>" + " tabs.add(new AbstractTab(new Model(\"third tab\")) {<br/>" + " public Panel getPanel(String panelId) { return new TabPanel3(panelId); }<br/>" + " });<br/>" + " add(new TabbedPanel(\"tabs\", tabs)<br/>"; add(new ExplainPanel(html, code)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -