Example usage for com.google.gwt.user.client.ui Label addClickHandler

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

Introduction

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

Prototype

public HandlerRegistration addClickHandler(ClickHandler handler) 

Source Link

Usage

From source file:org.bonitasoft.console.client.view.steps.StepEditor.java

License:Open Source License

protected Widget buildSkipStepMenuEntry() {
    final FlowPanel theSkipContainer = new FlowPanel();
    final Image theSkipIcon = new Image(PICTURE_PLACE_HOLDER);
    final Label theSkipLink = new Label(constants.skipStepActionLabel());
    ClickHandler theSkipClickHandler = new ClickHandler() {
        public void onClick(ClickEvent aEvent) {
            myStepDataSource.skipStep(myStep);
        }/*from  w  w  w  .ja  va2 s .  com*/
    };

    theSkipContainer.add(theSkipIcon);
    theSkipContainer.add(theSkipLink);
    // Associate CSS styles
    theSkipIcon.setStylePrimaryName("skip_icon");
    theSkipContainer.setStyleName("inline_block");
    theSkipLink.setStyleName(CSSClassManager.LINK_LABEL);
    // Associate the click handlers
    theSkipIcon.addClickHandler(theSkipClickHandler);
    theSkipLink.addClickHandler(theSkipClickHandler);
    return theSkipContainer;
}

From source file:org.bonitasoft.console.client.view.steps.StepsDefinitionListEditorView.java

License:Open Source License

protected void buildContent() {

    myAddErrorValidationMessage = new Label();

    myItemsList = new Grid(1, 3);
    myItemsList.setWidth("100%");
    myItemsList.setStylePrimaryName("item_list");
    myItemsList.setWidget(0, 0, buildSelectAllSelector());
    myItemsList.setHTML(0, 1, constants.stepLabelLabel());
    myItemsList.setHTML(0, 2, constants.stepNameLabel());
    myItemsList.getRowFormatter().setStylePrimaryName(0, "item_list_content_row_title");

    final FlowPanel theAddBonitaProcessPanel = new FlowPanel();
    theAddBonitaProcessPanel.setStylePrimaryName(CSSClassManager.GROUP_PANEL);
    theAddBonitaProcessPanel.setVisible(false);
    final Label theAddGroupPanelCaption = new Label(constants.addStepGroupPanelCaption());
    theAddGroupPanelCaption.setStylePrimaryName(CSSClassManager.GROUP_PANEL_CAPTION);
    final Label theAddBonitaProcessPanelCloseCaption = new Label();
    theAddBonitaProcessPanelCloseCaption.setTitle(constants.close());
    theAddBonitaProcessPanelCloseCaption.setStylePrimaryName(CSSClassManager.GROUP_PANEL_ACTION_CAPTION);
    theAddBonitaProcessPanelCloseCaption.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent aEvent) {
            myProcessViewerPanel.setItem(null);
            myStepViewerPanel.setItem(null);
            hideStepViewer();/*ww w.ja v a 2  s.  c o m*/
            theAddBonitaProcessPanel.setVisible(false);
        }
    });
    final Grid theAddPanel = new Grid(2, 2);
    theAddPanel.setStylePrimaryName(CSSClassManager.GROUP_PANEL_CONTENT);
    theAddPanel.setWidget(0, 0, new Label(constants.chooseAProcess()));
    theAddPanel.setWidget(0, 1, myProcessViewerPanel);
    myStepViewerLabel = new Label(constants.chooseAStep());
    theAddPanel.setWidget(1, 0, myStepViewerLabel);
    theAddPanel.setWidget(1, 1, myStepViewerPanel);

    hideStepViewer();

    final CustomMenuBar theAddButton = new CustomMenuBar();
    theAddButton.addItem(constants.add(), new Command() {

        public void execute() {
            addItemToList();
            theAddBonitaProcessPanel.setVisible(false);
            myProcessViewerPanel.setItem(null);
            myStepViewerPanel.setItem(null);
            hideStepViewer();
        }
    });

    theAddBonitaProcessPanel.add(theAddBonitaProcessPanelCloseCaption);
    theAddBonitaProcessPanel.add(theAddGroupPanelCaption);
    theAddBonitaProcessPanel.add(myAddErrorValidationMessage);
    theAddBonitaProcessPanel.add(theAddPanel);
    theAddBonitaProcessPanel.add(theAddButton);

    final CustomMenuBar theActionButtons = new CustomMenuBar();
    theActionButtons.addItem(constants.add(), new Command() {

        public void execute() {
            theAddBonitaProcessPanel.setVisible(true);
        }
    });

    theActionButtons.addItem(constants.delete(), new Command() {

        public void execute() {
            removeSelectedItems();
        }
    });

    myOuterPanel.setWidget(0, 0, myItemsList);
    myOuterPanel.setWidget(1, 0, theActionButtons);
    myOuterPanel.setWidget(2, 0, theAddBonitaProcessPanel);

    myItemsErrorMessage = new Label();
    myItemsErrorMessage.setStyleName(CSSClassManager.VALIDATION_ERROR_MESSAGE);
    myOuterPanel.setWidget(3, 0, myItemsErrorMessage);
}

From source file:org.bonitasoft.console.client.view.steps.StepsDefinitionListWidget.java

License:Open Source License

@Override
protected FlowPanel buildTopNavBar() {
    final FlowPanel theFirstCell = new FlowPanel();
    final HorizontalPanel theMenuPanel = new HorizontalPanel();

    Label theRefreshLink = new Label(constants.refresh());
    theRefreshLink.setStylePrimaryName(CSSClassManager.LINK_LABEL);
    theRefreshLink.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent aEvent) {
            myBonitaDataSource.reload();
        }//from   w w  w. j a va  2  s. c  o  m
    });

    // Create the Selector Widget
    HorizontalPanel theSelectorWidget = new HorizontalPanel();
    theSelectorWidget.add(new Label(constants.itemSelector()));
    Label theLinkLabel;
    for (final ItemSelector aSelector : ItemSelector.values()) {
        theLinkLabel = new Label(LocaleUtil.translate(aSelector));
        theLinkLabel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent arg0) {
                myItemSelection.select(aSelector);
            }
        });
        theLinkLabel.setStyleName(CSSClassManager.LINK_LABEL);

        theSelectorWidget.add(theLinkLabel);
    }

    theSelectorWidget.setSpacing(3);

    theMenuPanel.add(theRefreshLink);
    DOM.setElementPropertyInt(theMenuPanel.getElement(), "cellPadding", 3);

    theFirstCell.add(theMenuPanel);
    theFirstCell.add(theSelectorWidget);

    return theFirstCell;
}

From source file:org.bonitasoft.console.client.view.UserSettingsEditionView.java

License:Open Source License

protected void initReportingPrefPanel() {

    myReportingPrefInnerTabPanel.setWidget(1, 0, myReportListPanel);
    myReportingPrefInnerTabPanel.getFlexCellFormatter().setColSpan(1, 0, 2);
    final FlowPanel theButtonsPanel = new FlowPanel();
    Label theRefreshLink = new HTML(constants.refreshIcon());
    theRefreshLink.setTitle(constants.refresh());
    theRefreshLink.setStyleName(CSSClassManager.LINK_LABEL);
    theRefreshLink.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent anEvent) {
            updateStats();//from   ww  w.j a  v  a  2 s . c  o m
        }
    });

    theButtonsPanel.add(theRefreshLink);
    theButtonsPanel.add(mySaveButton);
    myReportingPrefInnerTabPanel.setWidget(2, 0, theButtonsPanel);
    myReportingPrefInnerTabPanel.getFlexCellFormatter().setColSpan(2, 0, 2);
    myReportingPrefInnerTabPanel.getCellFormatter().setHorizontalAlignment(2, 0,
            HasHorizontalAlignment.ALIGN_CENTER);
    updateStats();
}

From source file:org.bonitasoft.forms.client.view.widget.TableWidget.java

License:Open Source License

protected void createWidget(final List<String> selectedItems) {

    flexTable = new FlexTable();
    flexTable.setStyleName("bonita_form_table");
    final String tableStyle = widgetData.getTableStyle();
    if (tableStyle != null && tableStyle.length() > 0) {
        flexTable.addStyleName(tableStyle);
    }//from  w  w w. ja v  a2s . com
    int row = 0;
    int column = 0;
    columnCount = 0;
    final List<String> horizontalHeader = widgetData.getHorizontalHeader();
    if (horizontalHeader != null && !horizontalHeader.isEmpty()) {
        if (widgetData.hasTopHeadings()) {
            topHeadings = true;
            final int maxColumNumber = getMaxColumnNumber();
            for (final String header : horizontalHeader) {
                if (column >= maxColumNumber) {
                    break;
                }
                flexTable.setWidget(row, column, getCellContent(header));
                column++;
            }
            row++;
        }
        if (widgetData.hasBottomHeadings()) {
            bottomHeadings = true;
        }
    }
    final List<String> verticalHeader = widgetData.getVerticalHeader();
    if (verticalHeader != null && !verticalHeader.isEmpty()) {
        if (widgetData.hasLeftHeadings()) {
            leftHeadings = true;
        }
        if (widgetData.hasRightHeadings()) {
            rightHeadings = true;
        }
    }
    final List<List<ReducedFormFieldAvailableValue>> tableAvailableValues = getAvailableValuesList();
    if (tableAvailableValues != null) {
        for (final List<ReducedFormFieldAvailableValue> rowAvailableValues : tableAvailableValues) {
            column = 0;
            String header = null;
            if (leftHeadings || rightHeadings) {
                int headerIndex = row;
                if (topHeadings) {
                    headerIndex--;
                }
                if (widgetData.getVerticalHeader().size() > headerIndex) {
                    header = widgetData.getVerticalHeader().get(headerIndex);
                }
            }
            if (leftHeadings) {
                flexTable.setWidget(row, column, getCellContent(header));
                column++;
            }
            for (final ReducedFormFieldAvailableValue availableValue : rowAvailableValues) {
                if (availableValue != null) {
                    flexTable.setWidget(row, column, getCellContent(availableValue.getLabel()));
                }
                column++;
            }
            if (rightHeadings) {
                flexTable.setWidget(row, column, getCellContent(header));
                column++;
            }
            if (column > columnCount) {
                columnCount = column;
            }
            row++;
        }
    }
    if (bottomHeadings) {
        column = 0;
        final int maxColumNumber = getMaxColumnNumber();
        for (final String header : widgetData.getHorizontalHeader()) {
            if (column >= maxColumNumber) {
                break;
            }
            flexTable.setWidget(row, column, getCellContent(header));
            column++;
        }
        row++;
    }
    handleSelection();
    addCellsStyle(flexTable.getRowCount(), columnCount);
    final FlowPanel tableContainer = new FlowPanel();
    tableContainer.setStyleName("bonita_form_table_container");
    tableContainer.add(flexTable);
    flowPanel.add(tableContainer);
    setValue(selectedItems, false);

    if (SelectMode.NONE.equals(widgetData.getSelectMode()) && maxRows > 0) {
        final FlowPanel paginationPanel = new FlowPanel();
        paginationPanel.setStyleName(TABLE_PAGINATION_CONTAINER_STYLE);

        final Label lastPage = new Label(">I");
        lastPage.setStyleName(TABLE_PAGINATION_CONTROL_STYLE);
        lastPage.setTitle(FormsResourceBundle.getMessages().lastPageTitle());
        lastPage.setVisible(false);
        lastPage.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(final ClickEvent event) {
                currentPageIndex = getLastPageIndex();
                flowPanel.clear();
                createWidget(null);
            }
        });
        paginationPanel.add(lastPage);

        final Label nextPage = new Label(">");
        nextPage.setStyleName(TABLE_PAGINATION_CONTROL_STYLE);
        nextPage.setTitle(FormsResourceBundle.getMessages().nextPageTitle());
        nextPage.setVisible(false);
        nextPage.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(final ClickEvent event) {
                if (currentPageIndex < getLastPageIndex()) {
                    currentPageIndex++;
                }
                flowPanel.clear();
                createWidget(null);
            }
        });
        paginationPanel.add(nextPage);

        if (currentPageIndex < getLastPageIndex()) {
            nextPage.setVisible(true);
            lastPage.setVisible(true);
        }

        final int firstItem = currentPageIndex * maxRows + 1;
        final int lastItem = firstItem + tableAvailableValues.size() - 1;
        final Label currentPage = new Label(
                FormsResourceBundle.getMessages().paginationWithinLabel(Integer.toString(firstItem),
                        Integer.toString(lastItem), Integer.toString(availableValues.size())));
        currentPage.setStyleName(TABLE_PAGINATION_TEXT_STYLE);
        paginationPanel.add(currentPage);

        final Label previousPage = new Label("<");
        previousPage.setStyleName(TABLE_PAGINATION_CONTROL_STYLE);
        previousPage.setTitle(FormsResourceBundle.getMessages().previousPageTitle());
        previousPage.setVisible(false);
        previousPage.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(final ClickEvent event) {
                if (currentPageIndex > 0) {
                    currentPageIndex--;
                }
                flowPanel.clear();
                createWidget(null);
            }
        });
        paginationPanel.add(previousPage);

        final Label firstPage = new Label("I<");
        firstPage.setStyleName(TABLE_PAGINATION_CONTROL_STYLE);
        firstPage.setTitle(FormsResourceBundle.getMessages().firstPageTitle());
        firstPage.setVisible(false);
        firstPage.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(final ClickEvent event) {
                currentPageIndex = 0;
                flowPanel.clear();
                createWidget(null);
            }
        });
        paginationPanel.add(firstPage);

        if (currentPageIndex > 0) {
            firstPage.setVisible(true);
            previousPage.setVisible(true);
        }

        flowPanel.add(paginationPanel);
    }
}

From source file:org.bonitasoft.forms.client.view.widget.TodoListTaskWidget.java

License:Open Source License

/**
 * Create task link to assign and redirect user
 * //from   w  ww  . ja  v a2s. c om
 * @param nextTaskName
 * @param nextFormURL
 * @return
 */
private Label createTaskLink(final String nextTaskName, final FormURLComponents nextFormURL) {
    Label link = new Label(nextTaskName);
    link.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            redirectToNextTaskForm(nextFormURL);
        }
    });
    link.setStyleName(AVAILABLE_TASK_LINK_CSS_CLASS);
    return link;
}

From source file:org.cloudcoder.app.client.view.AccordionPanel.java

License:Open Source License

/**
 * Add a widget to the accordion panel./*from   w  w w  . jav  a  2s  .  c om*/
 * 
 * @param widget     the widget to add
 * @param labelText  the text for the widget's label
 */
public void add(IsWidget widget, String labelText) {
    // Create wrapper div
    FlowPanel div = new FlowPanel();
    div.setStyleName("cc-accordionPanelWidget", true);

    // Add to overall FlowPanel
    flowPanel.add(div);

    // Create label for this widget
    Label label = new Label("[-] " + labelText);
    label.setStyleName("cc-accordionPanelWidgetLabel", true);

    // Add label and widget to wrapper div
    div.add(label);
    div.add(widget);

    // Generate a unique id for the widget
    String id = "ccAccordionWidget" + nextId;
    nextId++;
    widget.asWidget().getElement().setId(id);

    // Create a wrapper and add it to the list
    final Wrapper wrapper = new Wrapper(label, widget, id);
    wrapperList.add(wrapper);

    // Add click handler for label
    label.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            onLabelClick(wrapper);
        }
    });

    if (wrapperList.size() == 1) {
        // First widget added, make it the selected one
        this.selected = wrapper;
        wrapper.label.setStyleName("cc-accordionPanelWidgetLabelSelected", true);
        decorateLabel(wrapper.label, "[+]");
    } else {
        // Hide this widget by default: it should become visible
        // when its label is clicked (and the widget is slide toggled)
        wrapper.widget.asWidget().getElement().getStyle().setDisplay(Display.NONE);
        decorateLabel(wrapper.label, "[-]");
    }

}

From source file:org.codesearch.searcher.client.ui.fileview.FileViewImpl.java

License:Open Source License

/**
 * {@inheritDoc}//  w w  w .jav  a 2  s . c  o m
 */
@Override
public void setFileContent(String fileContent, boolean binary) {
    lineNumbersContainer.setVisible(!binary);
    showFocusDiv(false);

    if (!binary) {
        lineCount = fileContent.split("\n").length;

        for (int i = 0; i < lineCount; i++) {
            Label lineNumber = new Label(String.valueOf(i + 1));
            lineNumber.addClickHandler(new LineNumberClickHandler(i + 1));
            lineNumbersContainer.add(lineNumber);
        }
    }

    fileContent = "<pre id='fileContent'>" + fileContent + "</pre>";

    HTML html = new HTML(fileContent);
    fileContentContainer.add(html);
    if (searchTerm != null && !searchTerm.isEmpty()) {
        for (String currentTerm : parseHighlightTerms(searchTerm)) {
            highlight("#fileContent", currentTerm);
        }
    }
}

From source file:org.cruxframework.crux.widgets.client.promobanner.BannerImpl.java

License:Apache License

/**
 * /*from ww w.  ja  va2  s  .  co m*/
 * @param title
 * @param text
 * @param styleName
 * @param buttonLabel
 * @param selectHandler
 * @param panel
 */
private void doAddBanner(String title, String text, String styleName, String buttonLabel,
        final SelectHandler selectHandler, SimplePanel panel) {
    if (styleName != null) {
        panel.setStyleName(styleName);
    }

    panel.setHeight(getBannersHeight());
    panel.setWidth("100%");

    boolean hasTitle = !StringUtils.isEmpty(title);
    boolean hasText = !StringUtils.isEmpty(text);
    boolean hasButtonLabel = !StringUtils.isEmpty(buttonLabel);
    if (hasTitle || hasText || hasButtonLabel || selectHandler != null) {
        VerticalPanel messagePanel = createMessagePanel(title, text, buttonLabel, selectHandler, hasTitle,
                hasText, hasButtonLabel);
        panel.add(messagePanel);
    }
    doAddBanner(panel);

    Label bullet = new Label();
    final int targetIndex = getBannersCount() - 1;
    bullet.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            showBanner(targetIndex);
        }
    });
    bullet.setStyleName("bullet");
    bullets.add(bullet);

    if (!hasVisibleBanner()) {
        showBanner(0);
    }
}

From source file:org.dataconservancy.dcs.access.client.model.JsCoreMetadata.java

License:Apache License

public Widget display(final String entityId, final CellTree tree) {
    //final Grid grid = //new Grid(7,2);
    final FlexTable grid = Util.createTable("Title:", "", "Contact:", "Subjects:", "Type:", "Rights:");
    grid.setWidth("90%");
    grid.getCellFormatter().setStyleName(1, 1, "PaddedCell");

    final HorizontalPanel hp = new HorizontalPanel();

    hp.setSpacing(5);//from   w  w  w .j  av  a  2 s  .  co m

    final Image image = new Image("images/wait.gif");
    final Label delete = Util.label("Delete [X]", "SimplerButton");
    final Label title = Util.label(getTitle(), "HeadingField");

    final Label expand = new Label("[+]");
    expand.setStyleName("Expand");

    final Label collapse = new Label("[-]");
    collapse.setStyleName("Collapse");
    final ScrollPanel treePanel = getTree(tree);

    delete.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            depositService.deleteCollection(entityId, SeadApp.accessurl, new AsyncCallback<Boolean>() {

                @Override
                public void onSuccess(Boolean result) {
                    Window.alert("The collection was deleted.");
                    History.newItem(SeadState.HOME.toToken());
                }

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Sorry, the collection could not be deleted.");
                    History.newItem(SeadState.HOME.toToken());
                }
            });

        }
    });

    expand.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            hp.remove(expand);
            hp.remove(title);
            int del = 0;
            if (delete.isAttached()) {
                hp.remove(delete);
                del = 1;
            }
            hp.add(collapse);
            hp.add(title);
            if (del == 1)
                hp.add(delete);
            if (tree != null) {
                //grid.setWidget(1, 0, new Label("Contains"));
                grid.setWidget(1, 1, treePanel);
            } else {
                History.newItem("related;" + entityId);
            }
        }
    });

    collapse.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            grid.remove(treePanel);
            hp.remove(collapse);
            hp.remove(title);
            int del = 0;
            if (delete.isAttached()) {
                hp.remove(delete);
                del = 1;
            }
            hp.add(expand);
            hp.add(title);
            if (del == 1)
                hp.add(delete);
        }
    });
    //TODO:Loading of related files takes too much time
    if (tree == null) {

        hp.add(expand);
    } else {

        hp.add(collapse);
        //hp.add(collapse);
    }
    hp.add(title);

    hp.add(image);
    final AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() {

        public void onSuccess(final UserSession result) {
            if (image.isAttached())
                hp.remove(image);
            if (getSubmitter().getSubmitterId().equals(result.getEmail())) {
                hp.add(delete);
            }
        }

        public void onFailure(Throwable error) {
            Window.alert("Failed to login: " + error.getMessage());

        }
    };

    SeadApp.userService.checkSession(null, cb);

    grid.setWidget(0, 1, hp);
    grid.setWidget(2, 1, new Label(getContact()));
    grid.setWidget(3, 1, new Label(toString(getSubjects())));
    grid.setWidget(4, 1, new Label(getType()));
    grid.setWidget(5, 1, new Label(getRights()));

    if (tree != null)
        grid.setWidget(1, 1, treePanel);

    return grid;
}