2 * Copyright 2011, The gwtquery team.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.google.gwt.query.client.plugins.widgets;
18 import static com.google.gwt.query.client.GQuery.$;
20 import com.google.gwt.dom.client.Element;
21 import com.google.gwt.user.client.ui.Button;
22 import com.google.gwt.user.client.ui.DisclosurePanel;
23 import com.google.gwt.user.client.ui.Label;
25 public class DisclosurePanelWidgetFactory implements
26 WidgetFactory<DisclosurePanel> {
29 * Options used to initialize new {@link Button}
32 public static class DisclosurePanelOptions {
34 private String headerSelector;
35 //private String headerTitle;
37 public DisclosurePanelOptions() {
41 public DisclosurePanelOptions(String headerSelector) {
42 this.headerSelector = headerSelector;
46 public String getHeaderSelector() {
47 return headerSelector;
50 /* public String getHeaderTitle() {
54 public void setHeaderSelector(String headerSelector) {
55 this.headerSelector = headerSelector;
58 /* public void setHeaderTitle(String headerTitle) {
59 this.headerTitle = headerTitle;
62 private void initDefault() {
64 headerSelector = "h3";
68 private DisclosurePanelOptions options;
70 public DisclosurePanelWidgetFactory(DisclosurePanelOptions options) {
71 this.options = options;
74 public DisclosurePanel create(Element e) {
76 String headerValue = "";
77 /*if (options.getHeaderTitle() != null){
78 headerValue = options.getHeaderTitle();
80 headerValue = $(options.getHeaderSelector(), e).first().remove().text();
83 DisclosurePanel disclosurePanel = new DisclosurePanel();
84 disclosurePanel.setHeader(new Label(headerValue));
86 WidgetsUtils.replaceOrAppend(e, disclosurePanel);
88 disclosurePanel.add(new WidgetsHtmlPanel(e));
91 return disclosurePanel;