Example usage for com.google.gwt.user.client.ui DisclosurePanel setContent

List of usage examples for com.google.gwt.user.client.ui DisclosurePanel setContent

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui DisclosurePanel setContent.

Prototype

public void setContent(Widget content) 

Source Link

Document

Sets the content widget which can be opened and closed by this panel.

Usage

From source file:com.allen_sauer.gwt.voices.demo.client.ui.DeferredContentDisclosurePanel.java

License:Apache License

public DeferredContentDisclosurePanel(String html, final DeferredContentPanel deferredContentPanel) {
    final DisclosurePanel realDisclosurePanel = new DisclosurePanel(html);
    realDisclosurePanel.setContent(deferredContentPanel);

    openHandlerRegistration = realDisclosurePanel.addOpenHandler(new OpenHandler<DisclosurePanel>() {
        @Override// w ww.j  av a2s  .  c  o m
        public void onOpen(OpenEvent<DisclosurePanel> event) {
            Panel panel = deferredContentPanel.initContent();
            panel.addStyleName(DemoClientBundle.INSTANCE.css().demoContent());
            realDisclosurePanel.setContent(panel);
            openHandlerRegistration.removeHandler();
        }
    });
    initWidget(realDisclosurePanel);
}

From source file:com.allen_sauer.gwt.voices.demo.client.VoicesDemo.java

License:Apache License

public void onModuleLoad2() {
    RootPanel mainPanel = RootPanel.get("demo-main-panel");
    StyleInjector.injectAtStart(DemoClientBundle.INSTANCE.css().getText());

    // text area to log sound events as they are triggered
    final HTML eventTextArea = new HTML();
    RootPanel.get("demo-event-text-area").add(eventTextArea);

    DemoSoundHandler demoSoundHandler = new DemoSoundHandler(eventTextArea);

    DisclosurePanel soundSupportMatrix = new DisclosurePanel("Sound Support Matrix for this browser");
    soundSupportMatrix.setContent(new SupportedMimeTypeSummary());
    mainPanel.add(soundSupportMatrix);// ww w. j  a v a  2 s .c o m

    DisclosurePanel crowdSourceSupportMatrix = new DisclosurePanel(
            "HTML5 MIME Type support in popular browsers");
    Frame crowdSourceFrame = new Frame("https://crowd-source-dot-gwt-voices.appspot.com/?embed=true");
    crowdSourceFrame.setPixelSize(3000, 600);
    crowdSourceFrame.getElement().getStyle().setBorderStyle(BorderStyle.NONE);
    crowdSourceSupportMatrix.setContent(crowdSourceFrame);
    mainPanel.add(crowdSourceSupportMatrix);

    // initialize mimeTypeSoundMap
    for (ThirdPartySound thirdPartySound : thirdPartySounds) {
        String mimeType = thirdPartySound.getMimeType();
        assert MIME_TYPES.contains(mimeType) : "MIME_TYPES must contain '" + mimeType + "'";
        ArrayList<ThirdPartySound> freesoundList = mimeTypeSoundMap.get(mimeType);
        if (freesoundList == null) {
            freesoundList = new ArrayList<ThirdPartySound>();
            mimeTypeSoundMap.put(mimeType, freesoundList);
        }
        freesoundList.add(thirdPartySound);
    }

    // display one panel for each unique MIME type, using the order supplied by
    // MIME_TYPES
    for (String mimeType : MIME_TYPES) {
        ArrayList<ThirdPartySound> soundList = mimeTypeSoundMap.get(mimeType);
        if (soundList != null) {
            SoundController sc = new SoundController();
            for (SoundType soundType : SoundType.values()) {
                maybeShowType(mainPanel, demoSoundHandler, mimeType, soundList, sc, soundType);
            }
        }
    }
    DOM.getElementById("demo-loading").removeFromParent();
}

From source file:com.anzsoft.client.ui.LoginForm.java

License:Open Source License

private Widget createAdvancedForm() {
    iJabConstants constants = (iJabConstants) GWT.create(iJabConstants.class);
    // Create a table to layout the form options
    FlexTable layout = new FlexTable();
    layout.setCellSpacing(6);//from  w  ww .  jav  a 2s.  c  om
    layout.setWidth("300px");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();

    // Add a title to the form
    /*
    layout.setHTML(0, 0,constants.iJabLogin());
    cellFormatter.setColSpan(0, 0, 2);
    cellFormatter.setHorizontalAlignment(0, 0,
        HasHorizontalAlignment.ALIGN_CENTER);
    */
    // Add some standard form options
    final TextBox userBox = new TextBox();
    userBox.setText("imdev");
    layout.setHTML(0, 0, constants.user());
    layout.setWidget(0, 1, userBox);
    final PasswordTextBox passBox = new PasswordTextBox();
    passBox.setText("imdev631");

    layout.setHTML(1, 0, constants.password());
    layout.setWidget(1, 1, passBox);

    // Create some advanced options
    Grid advancedOptions = new Grid(5, 2);
    advancedOptions.setCellSpacing(6);

    final TextBox hostBox = new TextBox();
    final TextBox portBox = new TextBox();
    final TextBox domainBox = new TextBox();
    final CheckBox authCheck = new CheckBox("SASL");
    authCheck.setChecked(false);

    hostBox.setEnabled(false);
    portBox.setEnabled(false);
    domainBox.setEnabled(false);
    authCheck.setEnabled(false);

    final CheckBox serverConfig = new CheckBox(constants.defineServerConfig());
    advancedOptions.setWidget(0, 0, serverConfig);
    serverConfig.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (serverConfig.isChecked()) {
                hostBox.setEnabled(true);
                portBox.setEnabled(true);
                domainBox.setEnabled(true);
                authCheck.setEnabled(true);
            } else {
                hostBox.setEnabled(false);
                portBox.setEnabled(false);
                domainBox.setEnabled(false);
                authCheck.setEnabled(false);
            }

        }

    });

    serverConfig.setChecked(false);

    advancedOptions.setHTML(1, 0, constants.domain());
    advancedOptions.setWidget(1, 1, hostBox);

    advancedOptions.setHTML(2, 0, constants.host());
    advancedOptions.setWidget(2, 1, portBox);

    advancedOptions.setHTML(3, 0, constants.port());
    advancedOptions.setWidget(3, 1, domainBox);

    advancedOptions.setWidget(4, 0, authCheck);

    // Add advanced options to form in a disclosure panel
    DisclosurePanel advancedDisclosure = new DisclosurePanel(constants.moreOptions());
    advancedDisclosure.setAnimationEnabled(true);
    advancedDisclosure.ensureDebugId("cwDisclosurePanel");
    advancedDisclosure.setContent(advancedOptions);
    layout.setWidget(2, 0, advancedDisclosure);

    Button loginButton = new Button(constants.login());

    layout.setWidget(3, 0, loginButton);
    loginButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
        public void componentSelected(ButtonEvent ce) {
            String user = userBox.getText();
            String pass = passBox.getText();
            String domain = domainBox.getText();
            String host = domainBox.getText();
            boolean sasl = authCheck.isChecked();
            if (serverConfig.isChecked()) {
                int port = Integer.parseInt(portBox.getText());
                //JabberApp.instance().onLogin(host, port, domain, sasl, user, pass);
            } else {
                //JabberApp.instance().onLogin(user, pass);
            }
        }

    });

    cellFormatter.setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_CENTER);

    cellFormatter.setColSpan(3, 0, 2);

    return layout;
}

From source file:com.codenvy.redhat.plugin.quick.start.ide.panel.DocsViewPartImpl.java

License:Open Source License

/** Create guide section. */
private Widget createSection(Project project, SectionDto sectionDto) {
    if (sectionDto.getTitle() == null) {
        Widget paragraphsWidget = createParagraphsWidget(project, sectionDto.getParagraphs());
        paragraphsWidget.addStyleName(guideResources.getGuideStyle().chapterWithoutTitle());
        return paragraphsWidget;
    }/*w w  w.  j  a  v a 2 s  .c  o m*/

    // create section with title
    DisclosurePanel advancedDisclosure = new DisclosurePanel(sectionDto.getTitle());
    advancedDisclosure.addStyleName(guideResources.getGuideStyle().fullWidthContainer());
    advancedDisclosure.setContent(createParagraphsWidget(project, sectionDto.getParagraphs()));
    return advancedDisclosure;
}

From source file:com.google.gwt.gwtai.demo.client.CounterAppletTab.java

License:Apache License

public CounterAppletTab() {
    VerticalPanel panelMain = new VerticalPanel();
    panelMain.setWidth("100%");
    panelMain.setSpacing(4);//from   www.  ja v a 2  s  .co  m

    Button buttonInc = new Button("Increment");
    Button buttonDec = new Button("Decrement");
    Button buttonGet = new Button("Get current count");

    final CounterApplet counterApplet = (CounterApplet) GWT.create(CounterApplet.class);

    buttonInc.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            counterApplet.increment();
        }
    });

    buttonDec.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            counterApplet.decrement();
        }
    });

    buttonGet.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Object value = counterApplet.getCurrentValue();

            DialogBox dialogBox = createDialogBox(value);
            dialogBox.center();
            dialogBox.show();
        }
    });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setSpacing(4);
    buttonPanel.add(buttonInc);
    buttonPanel.add(buttonDec);
    buttonPanel.add(buttonGet);

    Widget widgetApplet = AppletJSUtil.createAppletWidget(counterApplet);
    Label labelTitle = new Label(
            "To call a method on an applet object from within your GWT code - a piece of cake!");
    DisclosurePanel panelCode = new DisclosurePanel("View code");
    panelCode.setWidth("100%");
    panelCode.setAnimationEnabled(true);
    panelCode.setContent(createCodeHTML());

    panelMain.add(labelTitle);
    panelMain.add(widgetApplet);
    panelMain.add(buttonPanel);
    panelMain.add(panelCode);

    panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER);

    initWidget(panelMain);
}

From source file:com.google.gwt.gwtai.demo.client.JavaFXDemo.java

License:Apache License

public void onModuleLoad() {
    DecoratedTabPanel tabPanel = new DecoratedTabPanel();
    tabPanel.setWidth("800px");

    tabPanel.getDeckPanel().setAnimationEnabled(true);

    VerticalPanel panelMain = new VerticalPanel();
    panelMain.setWidth("100%");
    panelMain.setSpacing(4);//from   w w  w  .  j  a v a  2  s  .c  o  m

    JavaFXApplet javaFxApplet = (JavaFXApplet) GWT.create(JavaFXApplet.class);

    Widget widgetApplet = AppletJSUtil.createAppletWidget(javaFxApplet);

    panelMain.add(new HTML(
            "This demo is featuring a " + "<a href=\"http://www.sun.com/software/javafx/\">JavaFX</a> applet "
                    + "integrated into a <a href=\"http://code.google.com/webtoolkit/\">Goolge Web"
                    + " Toolkit</a> application using the "
                    + "<a href=\"http://code.google.com/p/gwtai/\">gwtai project</a>."));
    panelMain.add(widgetApplet);
    panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER);

    DisclosurePanel panelCode = new DisclosurePanel("View code");
    panelCode.setWidth("100%");
    panelCode.setAnimationEnabled(true);
    panelCode.setContent(createCodeHTML());

    panelMain.add(panelCode);

    tabPanel.add(panelMain, "JavaFXDemo");

    tabPanel.selectTab(0);

    RootPanel.get().add(tabPanel);
}

From source file:com.google.gwt.gwtai.demo.client.StopWatchAppletTab.java

License:Apache License

public StopWatchAppletTab() {
    VerticalPanel panelMain = new VerticalPanel();
    panelMain.setWidth("100%");
    panelMain.setSpacing(4);//  ww  w .  ja va 2  s.  c  o m

    VerticalPanel panelLaps = new VerticalPanel();
    panelLaps.setWidth("100%");
    panelLaps.setSpacing(4);

    Button buttonStart = new Button("Start");
    Button buttonStop = new Button("Stop");

    final StopWatchApplet stopWatchApplet = (StopWatchApplet) GWT.create(StopWatchApplet.class);

    buttonStart.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            stopWatchApplet.startWatch();
        }
    });

    buttonStop.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            stopWatchApplet.stopWatch();
        }
    });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setSpacing(4);
    buttonPanel.add(buttonStart);
    buttonPanel.add(buttonStop);

    Widget widgetApplet = AppletJSUtil.createAppletWidget(stopWatchApplet);
    AppletJSUtil.registerAppletCallback(stopWatchApplet, new StopWatchCallback(panelLaps));

    Label labelTitle = new Label(
            "Register a callback object to notify GWT of changes from within the Applet code.");
    DisclosurePanel panelCode = new DisclosurePanel("View code");
    panelCode.setWidth("100%");
    panelCode.setAnimationEnabled(true);
    panelCode.setContent(createCodeHTML());

    panelMain.add(labelTitle);
    panelMain.add(widgetApplet);
    panelMain.add(buttonPanel);
    panelMain.add(panelLaps);
    panelMain.add(panelCode);

    panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(panelLaps, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER);

    initWidget(panelMain);
}

From source file:com.google.gwt.gwtai.demo.client.TrayIconAppletTab.java

License:Apache License

public TrayIconAppletTab() {
    VerticalPanel panelMain = new VerticalPanel();
    panelMain.setWidth("100%");
    panelMain.setSpacing(4);/*from  ww  w.  j av a2 s  .c o  m*/

    _trayIconApplet = (TrayIconApplet) GWT.create(TrayIconApplet.class);

    Widget widgetApplet = AppletJSUtil.createAppletWidget(_trayIconApplet);

    Label labelTitle = new Label(
            "Hook into the desktop tray from a GWT application. This is a 'Proof of Concept', the feature is not finished yet.");
    DisclosurePanel panelCode = new DisclosurePanel("View code");
    panelCode.setWidth("100%");
    panelCode.setAnimationEnabled(true);
    panelCode.setContent(createCodeHTML());

    HorizontalPanel panelItems = new HorizontalPanel();
    panelItems.setSpacing(4);

    final TextBox boxCaption = new TextBox();

    final ListBox boxItemType = new ListBox();
    boxItemType.addItem("Text");
    boxItemType.addItem("CheckBox");
    boxItemType.setSelectedIndex(0);

    Button buttonAdd = new Button("Add menu item");

    buttonAdd.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String caption = boxCaption.getText();

            if (null == caption || caption.length() < 1) {
                Window.alert("Caption can not be empty");
            } else {
                String itemType = boxItemType.getItemText(boxItemType.getSelectedIndex());

                if (itemType.equals("CheckBox")) {
                    _trayIconApplet.addCheckBoxItem(caption);
                } else {
                    _trayIconApplet.addTextItem(caption);
                }
            }
        }
    });

    Button buttonSeparator = new Button("Add separator");
    buttonSeparator.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            _trayIconApplet.addSeparator();
        }
    });

    panelItems.add(boxCaption);
    panelItems.add(boxItemType);
    panelItems.add(buttonAdd);
    panelItems.add(buttonSeparator);

    panelMain.add(labelTitle);
    panelMain.add(widgetApplet);
    panelMain.add(panelItems);
    panelMain.add(panelCode);

    panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER);

    initWidget(panelMain);
}

From source file:com.google.gwt.sample.showcase.client.content.panels.CwDisclosurePanel.java

License:Apache License

/**
 * Create a form that contains undisclosed advanced options.
 *//*from  w w w . j  a va 2  s.c  om*/
@ShowcaseSource
private Widget createAdvancedForm() {
    // Create a table to layout the form options
    FlexTable layout = new FlexTable();
    layout.setCellSpacing(6);
    layout.setWidth("300px");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();

    // Add a title to the form
    layout.setHTML(0, 0, constants.cwDisclosurePanelFormTitle());
    cellFormatter.setColSpan(0, 0, 2);
    cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);

    // Add some standard form options
    layout.setHTML(1, 0, constants.cwDisclosurePanelFormName());
    layout.setWidget(1, 1, new TextBox());
    layout.setHTML(2, 0, constants.cwDisclosurePanelFormDescription());
    layout.setWidget(2, 1, new TextBox());

    // Create some advanced options
    HorizontalPanel genderPanel = new HorizontalPanel();
    String[] genderOptions = constants.cwDisclosurePanelFormGenderOptions();
    for (int i = 0; i < genderOptions.length; i++) {
        genderPanel.add(new RadioButton("gender", genderOptions[i]));
    }
    Grid advancedOptions = new Grid(2, 2);
    advancedOptions.setCellSpacing(6);
    advancedOptions.setHTML(0, 0, constants.cwDisclosurePanelFormLocation());
    advancedOptions.setWidget(0, 1, new TextBox());
    advancedOptions.setHTML(1, 0, constants.cwDisclosurePanelFormGender());
    advancedOptions.setWidget(1, 1, genderPanel);

    // Add advanced options to form in a disclosure panel
    DisclosurePanel advancedDisclosure = new DisclosurePanel(constants.cwDisclosurePanelFormAdvancedCriteria());
    advancedDisclosure.setAnimationEnabled(true);
    advancedDisclosure.ensureDebugId("cwDisclosurePanel");
    advancedDisclosure.setContent(advancedOptions);
    layout.setWidget(3, 0, advancedDisclosure);
    cellFormatter.setColSpan(3, 0, 2);

    // Wrap the contents in a DecoratorPanel
    DecoratorPanel decPanel = new DecoratorPanel();
    decPanel.setWidget(layout);
    return decPanel;
}

From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java

License:Open Source License

private DisclosurePanel createAdminDisclosurePanel(ExperimentDAO experiment) {
    final DisclosurePanel adminPanel = new DisclosurePanel();
    adminPanel.setStyleName("bordered");
    final DisclosurePanelHeader closedHeaderWidget = new DisclosurePanelHeader(false,
            //                                                                               "<b>" +
            myConstants.clickToEditAdministrators()
    //                                                                                   + "</b>"
    );//w w w  .ja v  a  2s . c  om
    closedHeaderWidget.setStyleName("keyLabel");
    final DisclosurePanelHeader openHeaderWidget = new DisclosurePanelHeader(true,
            //                                                                             "<b>" +
            myConstants.clickToCloseAdministratorEditor()
    //                                                                                 + "</b>"
    );
    openHeaderWidget.setStyleName("keyLabel");
    adminPanel.setHeader(closedHeaderWidget);
    adminPanel.addEventHandler(new DisclosureHandler() {
        public void onClose(DisclosureEvent event) {
            adminPanel.setHeader(closedHeaderWidget);
        }

        public void onOpen(DisclosureEvent event) {
            adminPanel.setHeader(openHeaderWidget);
        }
    });
    VerticalPanel adminContentPanel = new VerticalPanel();
    Label instructionlabel = new Label(myConstants.administratorEditorPrompt());
    adminContentPanel.add(instructionlabel);

    adminList = new TextArea();
    adminList.setCharacterWidth(100);
    adminList.setHeight("100");
    String[] adminStrArray = experiment.getAdmins();
    List<String> admins = Lists.newArrayList(adminStrArray);
    String loginEmailLowercase = loginInfo.getEmailAddress().toLowerCase();
    if (!admins.contains(loginEmailLowercase)) {
        admins.add(loginEmailLowercase);
    }
    adminList.setText(toCSVString(admins));

    adminContentPanel.add(adminList);
    adminPanel.setContent(adminContentPanel);
    return adminPanel;
}