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.dataconservancy.dcs.access.client.ui.SeadSimpleSearchWidget.java

License:Apache License

public SeadSimpleSearchWidget(Search.UserField[] userfields, String[] userqueries) {

    advancedPanel = new FlowPanel();
    initWidget(advancedPanel);/*from  ww w  .  j  ava 2 s  .com*/

    final FlexTable table = new FlexTable();
    table.setWidth("100%");
    Label intro = new Label();
    intro.setText(
            "Virtual Archive (SEAD-VA) is a discovery and preservation layer of the SEAD services suite. SEAD-VA federates over multiple institutional repositories and archives and provides a coherent view on published data in sustainability science.");
    intro.setStylePrimaryName("IntroLabel");

    Label lbl = new Label();
    lbl.setText("Search SEAD-VA data registry");
    lbl.setStylePrimaryName("SearchLabel");
    Button add = new Button("Add field");

    if (SeadApp.isHome) {
        advancedPanel.add(intro);
        advancedPanel.add(lbl);
    }

    advancedPanel.add(table);

    // Called to search filled in query

    final ClickHandler searchlistener = new ClickHandler() {

        public void onClick(ClickEvent event) {
            // Build up search history token
            System.out.println("In search");
            String[] data = new String[(table.getRowCount() * 2) + 1 + 1];
            int dataindex = 0;
            boolean emptyquery = true;

            for (int i = 0; i < table.getRowCount(); i++) {
                // ListBox lb = (ListBox) table.getWidget(i, 2);
                TextBox tb = (TextBox) table.getWidget(i, 0);

                /* int sel = lb.getSelectedIndex();
                        
                if (sel != -1) {*/
                String userquery = tb.getText().trim();
                /*  String userfield = Search.UserField.values()[sel]
                .name();*/
                String userfield = "ALL";
                if (userquery.isEmpty()) {
                    userfield = null;
                    userquery = null;
                } else {
                    emptyquery = false;
                }
                System.out.println("UserField: " + userfield);
                System.out.println("UserAuery" + userquery);
                data[dataindex++] = userfield;
                data[dataindex++] = userquery;
                System.out.println("Data.0: " + data[0] + "Data.1: " + data[1]);
                //}
            }

            data[dataindex] = "0";
            data[dataindex + 1] = "0";

            if (!emptyquery) {
                History.newItem(SeadState.SEARCH.toToken(data));
            }
        }
    };

    ClickHandler addlistener = new ClickHandler() {

        public void onClick(ClickEvent event) {
            int row = table.getRowCount();

            final TextBox tb = new TextBox();
            tb.setStyleName("Pad");
            tb.setValue("Type name, date or keyword");
            table.setWidget(row, 0, tb);
            //   table.setWidget(row, 1, new Label("in1"));
            //   table.setWidget(row, 2 , createAdvancedSearchFieldSelector());

            tb.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    // TODO Auto-generated method stub
                    tb.setValue(null);
                }
            });
            tb.addKeyDownHandler(new KeyDownHandler() {

                public void onKeyDown(KeyDownEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                        searchlistener.onClick(null);
                    }
                }
            });

        }
    };

    add.addClickHandler(addlistener);

    if (userfields != null) {
        for (int i = 0; i < userfields.length; i++) {
            if (userfields[i] == null) {
                continue;
            }

            int row = table.getRowCount();
            addlistener.onClick(null);

            //     ListBox lb = (ListBox) table.getWidget(row,2);
            //    lb.setItemSelected(userfields[i].ordinal(), true);
            TextBox tb = (TextBox) table.getWidget(row, 0);
            tb.setText(userqueries[i]);
        }
    } else {
        addlistener.onClick(null);
    }

    Grid grid = new Grid(2, 2);
    advancedPanel.add(grid);
    grid.setWidth("80%");

    FlexTable flexTable = new FlexTable();
    grid.setWidget(0, 0, table);

    Button search = new Button("Search");
    search.setStyleName("SearchButton");
    Label advSearch = new Label();
    advSearch.setText("Advanced Search>>");
    advSearch.setStyleName("PadHyperlink");
    advSearch.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            History.newItem(SeadState.ADVANCED.toToken());
        }
    });
    grid.setWidget(0, 1, search);
    grid.setWidget(1, 0, advSearch);
    // search.setWidth("82px");
    search.addClickHandler(searchlistener);

}

From source file:org.dataconservancy.dcs.access.ui.client.Application.java

License:Apache License

public void onModuleLoad() {
    accessurl_tb = new TextBox();

    accessurl = Window.Location.getParameter("accessurl");

    if (accessurl != null) {
        updateAccessServiceUrl();/*from w  w  w  .j a  v  a  2 s . c o m*/
    } else {
        // load config

        HttpGet.request(GWT.getModuleBaseURL() + "Config.properties", new HttpGet.Callback<String>() {

            public void failure(String error) {
                Window.alert("Failed to load config: " + error);
            }

            public void success(String result) {
                String[] pairs = result.trim().split("\\w*(\n|\\=)\\w*");

                for (int i = 0; i + 1 < pairs.length;) {
                    String name = pairs[i++].trim();
                    String value = pairs[i++].trim();

                    if (name.equals("accessServiceURL")) {
                        accessurl = value;
                        updateAccessServiceUrl();
                    }
                }
            }
        });
    }

    DockLayoutPanel main = new DockLayoutPanel(Unit.PX);
    main.setStylePrimaryName("Main");

    content = new FlowPanel();
    content.setStylePrimaryName("Content");

    Panel header = new FlowPanel();
    header.setStylePrimaryName("TopHeader");

    Panel footer = new FlowPanel();
    footer.setStylePrimaryName("Footer");

    main.addNorth(header, 110);
    main.addSouth(footer, 40);

    main.add(new ScrollPanel(content));

    Image logo = new Image(GWT.getModuleBaseURL() + "simply_modern_logo.png");

    ClickHandler gohome = new ClickHandler() {
        public void onClick(ClickEvent event) {
            History.newItem(State.HOME.toToken());
        }
    };

    logo.addClickHandler(gohome);

    header.add(logo);
    Label toptext = Util.label("Access User Interface", "TopHeaderText");

    toptext.addClickHandler(gohome);

    header.add(toptext);

    footer.add(createAccessServiceUrlEditor());
    footer.add(new HTML("<a href='http://dataconservancy.org/'>http://dataconservancy.org/</a>"));

    RootLayoutPanel.get().add(main);

    History.addValueChangeHandler(new ValueChangeHandler<String>() {

        public void onValueChange(ValueChangeEvent<String> event) {
            historyChanged(event.getValue());
        }
    });

    History.fireCurrentHistoryState();
}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.EnumDropDownLabel.java

License:Apache License

private Label createTextLabel() {
    Label label = new Label();
    label.setStyleName("form-field");
    if (enabled) {
        label.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                showPopup();//from ww  w .j  a  v  a 2s . c  o m
            }
        });
    }
    return label;
}

From source file:org.drools.guvnor.client.common.LazyStackPanelHeader.java

License:Apache License

public LazyStackPanelHeader(String headerText, ImageResource headerIcon) {
    this();//from  ww  w .  j av  a2 s . co m
    Image titleIcon = new Image(headerIcon);
    container.add(titleIcon);
    Label titleLabel = new Label(headerText);
    titleLabel.setStyleName("guvnor-cursor");
    titleLabel.addClickHandler(expandClickHandler);
    container.add(titleLabel);
}

From source file:org.drools.guvnor.client.common.LazyStackPanelHeader.java

License:Apache License

public LazyStackPanelHeader(String headerText) {
    this();//from  www .j a  va  2s  . com
    Label titleLabel = new Label(headerText);
    titleLabel.setStyleName("guvnor-cursor");
    titleLabel.addClickHandler(expandClickHandler);
    container.add(titleLabel);
}

From source file:org.drools.guvnor.client.modeldriven.ui.EnumDropDownLabel.java

License:Apache License

private Label getTextLabel() {
    Label label = new Label();
    label.setStyleName("x-form-field");
    label.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            showPopup();//from  w w w  .  j a v a 2 s.  co m

        }
    });
    if (label.getText() == null && "".equals(label.getText())) {
        label.setText(constants.Value());
    }

    return label;
}

From source file:org.drools.guvnor.client.util.LazyStackPanelHeader.java

License:Apache License

public LazyStackPanelHeader(String headerText, Image headerIcon) {
    this();/*from  w w  w . j a  v a 2 s  .c o  m*/
    Image titleIcon = headerIcon;
    container.add(titleIcon);
    Label titleLabel = new Label(headerText);
    titleLabel.setStyleName("guvnor-cursor");
    titleLabel.addClickHandler(expandClickHandler);
    container.add(titleLabel);
}

From source file:org.eclipse.che.ide.command.toolbar.processes.EmptyListWidget.java

License:Open Source License

@Inject
private void init(CommandResources resources, ToolbarMessages messages) {
    // initialize widget for the state when there's no process
    final Label commandNameLabel = new InlineHTML("Ready");
    commandNameLabel.addStyleName(resources.commandToolbarCss().processWidgetText());
    commandNameLabel.addStyleName(resources.commandToolbarCss().processWidgetCommandNameLabel());

    final Label machineNameLabel = new InlineHTML("&nbsp; - start command");
    machineNameLabel.addStyleName(resources.commandToolbarCss().processWidgetText());
    machineNameLabel.addStyleName(resources.commandToolbarCss().processWidgetMachineNameLabel());

    noProcessWidget = new FlowPanel();
    noProcessWidget.addStyleName(resources.commandToolbarCss().processWidgetText());
    noProcessWidget.add(commandNameLabel);
    noProcessWidget.add(machineNameLabel);

    // initialize widget for the state when there's no command
    final Label hintLabel = new InlineHTML(messages.guideItemLabel());
    hintLabel.addStyleName(resources.commandToolbarCss().processWidgetText());
    hintLabel.addStyleName(resources.commandToolbarCss().processWidgetCommandNameLabel());
    hintLabel.addClickHandler(event -> commandCreationGuide.guide());

    noCommandWidget = new FlowPanel();
    noCommandWidget.addStyleName(resources.commandToolbarCss().processWidgetText());
    noCommandWidget.add(hintLabel);//  w  ww . ja  v  a2s. c o  m
}

From source file:org.eclipse.che.ide.ext.git.client.action.StatusBarBranchPointer.java

License:Open Source License

@Override
public void update(ActionEvent e) {
    panel.clear();/* w  ww  .jav  a2  s.  c  o m*/

    Project project = appContext.getRootProject();
    if (project != null && project.getAttributes().containsKey(GIT_CURRENT_HEAD_NAME)) {
        Label projectNameLabel = new Label(project.getName());
        projectNameLabel.ensureDebugId("statusBarProjectBranchRepositoryName");
        projectNameLabel.getElement().getStyle().setMarginLeft(5., Unit.PX);
        panel.add(projectNameLabel);

        SVGImage branchIcon = new SVGImage(resources.checkoutReference());
        branchIcon.getSvgElement().getStyle().setMarginLeft(5., Unit.PX);
        panel.add(branchIcon);

        Label headLabel = new Label(project.getAttribute(GIT_CURRENT_HEAD_NAME));
        headLabel.ensureDebugId("statusBarProjectBranchName");
        headLabel.setTitle(constant.branchesControlTitle());
        Style headLabelStyle = headLabel.getElement().getStyle();
        headLabelStyle.setCursor(Cursor.POINTER);
        headLabelStyle.setMarginLeft(5., Unit.PX);
        headLabel.addClickHandler(event -> branchPresenter.showBranches(project));
        panel.add(headLabel);
    }
}

From source file:org.eclipse.che.ide.ext.java.client.organizeimports.OrganizeImportsViewImpl.java

License:Open Source License

/** {@inheritDoc} */
@Override//www . j  av  a 2  s. c o  m
public void show(ConflictImportDTO match) {
    container.clear();
    List<String> matches = match.getTypeMatches();
    for (String fqn : matches) {
        final Label label = new Label(fqn);
        if (fqn.equals(selectedImport)) {
            selectedLabel = label;
            selectedLabel.getElement().getStyle().setBackgroundColor(getEditorSelectionColor());
        }
        label.getElement().getStyle().setColor(getMainFontColor());
        label.getElement().getStyle().setCursor(POINTER);
        label.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent clickEvent) {
                selectedLabel.getElement().getStyle().setBackgroundColor("initial");
                selectedLabel = label;
                label.getElement().getStyle().setBackgroundColor(getEditorSelectionColor());
            }
        });

        container.add(label);
    }

    super.show();
}