Example usage for com.google.gwt.user.client.ui ToggleButton ToggleButton

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

Introduction

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

Prototype

public ToggleButton(String upText, String downText, ClickHandler handler) 

Source Link

Document

Constructor for ToggleButton.

Usage

From source file:de.eckhartarnold.client.ControlPanel.java

License:Apache License

/**
 * (Re-)creates the button panel using the images stored in the 
 * <code>icons</code> map as symbols on the buttons.
 */// w  w w .  ja va  2 s.co m
protected void composePanel() {
    VerticalPanel vpanel = new VerticalPanel();
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    // progress bar   
    progress = new ProgressBar(slideshow.size());
    int btnSize;
    if (filmstrip != null)
        btnSize = buttonSize / 2;
    else
        btnSize = buttonSize;
    if (btnSize >= 24)
        progress.setLabelingType(ProgressBar.VALUE_LABEL);
    else
        progress.setLabelingType(ProgressBar.NO_LABEL);
    if (btnSize <= 32)
        progress.getFrame().addStyleDependentName("thin");
    if (btnSize > 48)
        progress.getBar().addStyleDependentName("16px");
    else if (btnSize > 32)
        progress.getBar().addStyleDependentName("12px");
    else if (btnSize >= 28)
        progress.getBar().addStyleDependentName("10px");
    else if (btnSize >= 24)
        progress.getBar().addStyleDependentName("9px");
    else if (btnSize >= 20)
        progress.getBar().addStyleDependentName("4px");
    else
        progress.getBar().addStyleDependentName("3px");
    int value = slideshow.getCurrentSlide();
    if (value >= 0)
        progress.setValue(value + 1);

    // button panel
    //    begin = new PushButton(icons.get("begin"), icons.get("begin_down"), this);
    //    Tooltip.addToWidget(beginTooltip, begin);    
    back = new PushButton(icons.get("back"), icons.get("back_down"), this);
    Tooltip.addToWidget(backTooltip, back);

    if (homeButtonHandler != null) {
        home = new PushButton(icons.get("gallery"), icons.get("gallery_down"), homeButtonHandler);
    } else {
        home = new PushButton(icons.get("gallery"), icons.get("gallery_down"));
    }
    Tooltip.addToWidget(homeTooltip, home);
    play = new ToggleButton(icons.get("play"), icons.get("pause"), this);
    Tooltip.addToWidget(playPauseTooltip, play);
    if (slideshow.isRunning())
        play.setDown(true);

    next = new PushButton(icons.get("next"), icons.get("next_down"), this);
    Tooltip.addToWidget(nextTooltip, next);
    //    end = new PushButton(icons.get("end"), icons.get("end_down"), this);
    //    Tooltip.addToWidget(endTooltip, end);

    // if ((buttonsShown & BEGIN) != 0) buttonPanel.add(begin);
    if ((buttonsShown & BACK) != 0)
        buttonPanel.add(back);
    if ((buttonsShown & HOME) != 0)
        buttonPanel.add(home);
    if (filmstrip != null) {
        filmstrip.setHeight(buttonSize * 2 + "px");
        vpanel.add(filmstrip);
        vpanel.add(progress);
        vpanel.setWidth("100%");
        buttonPanel.add(vpanel);
        buttonPanel.setCellWidth(vpanel, "100%");
        buttonPanel.addStyleName("controlFilmstripBackground");
        addButtonStyles("controlFilmstripButton");
    } else {
        buttonPanel.addStyleName("controlPanelBackground");
        addButtonStyles("controlPanelButton");
    }
    if ((buttonsShown & PLAY) != 0)
        buttonPanel.add(play);
    if ((buttonsShown & NEXT) != 0)
        buttonPanel.add(next);
    // if ((buttonsShown & END) != 0) buttonPanel.add(end);    

    enableOrDisableButtons();
    if (filmstrip != null) {
        wrapper.setWidget(buttonPanel);
    } else {
        vpanel.add(buttonPanel);
        vpanel.add(progress);
        wrapper.setWidget(vpanel);
    }
}

From source file:org.nsesa.editor.gwt.an.amendments.client.ui.document.AkomaNtoso20SourceFileHeaderController.java

License:EUPL

@Inject
public AkomaNtoso20SourceFileHeaderController(DocumentEventBus documentEventBus, SourceFileHeaderView view,
        Constants constants) {/*  w w  w  . j  a  v  a  2  s  .  co m*/
    super(documentEventBus, view);
    this.constants = constants;

    diffingButton = new ToggleButton(constants.documentModeDiffOff(), constants.documentModeDiffOn(),
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    final DiffMode diff = (DiffMode) sourceFileController.getDocumentController()
                            .getMode(DiffMode.KEY);
                    sourceFileController.getDocumentController().applyState(DiffMode.KEY,
                            new ActiveState(!diff.getState().isActive()));
                }
            });
    consolidationButton = new ToggleButton(constants.documentModeConsolidationOff(),
            constants.documentModeConsolidationOn(), new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    final ConsolidationMode consolidationMode = (ConsolidationMode) sourceFileController
                            .getDocumentController().getMode(ConsolidationMode.KEY);
                    sourceFileController.getDocumentController().applyState(ConsolidationMode.KEY,
                            new ActiveState(!consolidationMode.getState().isActive()));
                }
            });

    view.addWidget(diffingButton);
    view.addWidget(consolidationButton);

    registerListeners();
}

From source file:org.nsesa.editor.gwt.an.amendments.client.ui.document.AkomaNtosoSourceFileHeaderController.java

License:EUPL

@Inject
public AkomaNtosoSourceFileHeaderController(DocumentEventBus documentEventBus, SourceFileHeaderView view,
        Constants constants) {/*  ww w .  j  a v a2s  . c o m*/
    super(documentEventBus, view);
    this.constants = constants;

    diffingButton = new ToggleButton(constants.documentModeDiffOff(), constants.documentModeDiffOn(),
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    final DiffMode diff = (DiffMode) sourceFileController.getDocumentController()
                            .getMode(DiffMode.KEY);
                    sourceFileController.getDocumentController().applyState(DiffMode.KEY,
                            new ActiveState(!diff.getState().isActive()));
                }
            });
    consolidationButton = new ToggleButton(constants.documentModeConsolidationOff(),
            constants.documentModeConsolidationOn(), new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    final ConsolidationMode consolidationMode = (ConsolidationMode) sourceFileController
                            .getDocumentController().getMode(ConsolidationMode.KEY);
                    sourceFileController.getDocumentController().applyState(ConsolidationMode.KEY,
                            new ActiveState(!consolidationMode.getState().isActive()));
                }
            });
    columnButton = new ToggleButton("2 Columns", "1 Column", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final ColumnMode columnMode = (ColumnMode) sourceFileController.getDocumentController()
                    .getMode(ColumnMode.KEY);
            sourceFileController.getDocumentController().applyState(ColumnMode.KEY,
                    new ActiveState(!columnMode.getState().isActive()));
        }
    });
    structureButton = new ToggleButton("", "", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final StructureViewMode structureViewMode = (StructureViewMode) sourceFileController
                    .getDocumentController().getMode(StructureViewMode.KEY);
            sourceFileController.getDocumentController().applyState(StructureViewMode.KEY,
                    new ActiveState(!structureViewMode.getState().isActive()));
        }
    });

    view.addWidget(diffingButton);
    view.addWidget(consolidationButton);
    view.addWidget(columnButton);
    view.addWidget(structureButton);
}