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.kuali.student.common.ui.client.configurable.mvc.multiplicity.RemovableItemWithHeader.java

License:Educational Community License

private Widget generateRemoveWidget() {
    ClickHandler ch = new ClickHandler() {
        public void onClick(ClickEvent event) {
            getRemoveCallback().exec(RemovableItemWithHeader.this);
        }//  ww w .  j ava 2  s .c  o m
    };

    Widget returnWidget;

    if (useDeleteLabel) {
        Label deleteLabel = new Label("Delete");
        deleteLabel.addStyleName("KS-Multiplicity-Link-Label");
        deleteLabel.addClickHandler(ch);
        returnWidget = deleteLabel;
    } else {
        returnWidget = new KSButton("-", ch);
    }

    itemPanel.addStyleName("KS-Multiplicity-Item");

    if (readOnly) {
        returnWidget.setVisible(false);
    } else {
        returnWidget.setVisible(true);
    }

    return returnWidget;
}

From source file:org.onesocialweb.gwt.client.ui.window.ProfileWindow.java

License:Apache License

private void loadFullProfile() {

    // setup layout

    // profile section
    StyledFlowPanel sectionProfile = new StyledFlowPanel("section");
    StyledLabel profileLabel = new StyledLabel("grouplabel", uiText.Profile());
    StyledLabel profileInstruction = new StyledLabel("instruction", "");
    details.add(sectionProfile);/*w  w w .j a va  2 s. co m*/
    sectionProfile.add(profileLabel);
    sectionProfile.add(profileInstruction);
    sectionProfile.add(profile);

    // followers section
    StyledFlowPanel sectionFollowers = new StyledFlowPanel("section");
    StyledLabel followersLabel = new StyledLabel("grouplabel", uiText.Followers());
    final StyledLabel followersInstruction = new StyledLabel("instruction", "");
    details.add(sectionFollowers);
    sectionFollowers.add(followersLabel);
    sectionFollowers.add(followersInstruction);
    sectionFollowers.add(followersPanel);

    // following section
    StyledFlowPanel sectionFollowing = new StyledFlowPanel("section");
    StyledLabel followingLabel = new StyledLabel("grouplabel", uiText.FollowingPeople());
    final StyledLabel followingInstruction = new StyledLabel("instruction", "");
    details.add(sectionFollowing);
    sectionFollowing.add(followingLabel);
    sectionFollowing.add(followingInstruction);
    sectionFollowing.add(followingPanel);

    profileInstruction.setVisible(false);

    if (model != null && model.getFields().size() > 0) {

        // show the profile
        sectionProfile.setVisible(true);

        if (model.hasField(FullNameField.NAME)) {
            String displayname = model.getFullName();
            if (displayname != null && displayname.length() > 0)
                addHTMLLabelRow(profile, uiText.DisplayName(), displayname);
        }

        if (model.hasField(NameField.NAME)) {
            String name = model.getName();
            if (name != null && name.length() > 0)
                addHTMLLabelRow(profile, uiText.FullName(), name);
        }

        if (model.hasField(BirthdayField.NAME)) {
            Date birthday = model.getBirthday();
            if (birthday != null) {
                DateTimeFormat dtf = DateTimeFormat.getFormat("d MMMM yyyy");
                String bday = dtf.format(birthday);
                addHTMLLabelRow(profile, uiText.Birthday(), bday);
            }
        }

        if (model.hasField(GenderField.NAME)) {

            String value = new String("");

            GenderField.Type gender = model.getGender();

            if (gender.equals(GenderField.Type.MALE)) {
                value = uiText.Male();
            } else if (gender.equals(GenderField.Type.FEMALE)) {
                value = uiText.Female();
            } else if (gender.equals(GenderField.Type.NOTKNOWN)) {
                value = uiText.NotKnown();
            } else if (gender.equals(GenderField.Type.NOTAPPLICABLE)) {
                value = uiText.NotApplicable();
            }
            if (gender != null)
                addHTMLLabelRow(profile, uiText.Gender(), value);

        }

        if (model.hasField(NoteField.NAME)) {
            String bio = model.getNote();
            if (bio != null && bio.length() > 0)
                addHTMLLabelRow(profile, uiText.Bio(), bio);
        }

        if (model.hasField(EmailField.NAME)) {
            String email = model.getEmail();
            if (email != null && email.length() > 0)
                addHTMLLabelRow(profile, uiText.Email(), email);
        }

        if (model.hasField(TelField.NAME)) {
            String tel = model.getTel();
            if (tel != null && tel.length() > 0)
                addHTMLLabelRow(profile, uiText.Telephone(), tel);
        }

        if (model.hasField(URLField.NAME)) {
            String url = model.getUrl();
            if (url != null && url.length() > 0)
                addHTMLLabelRow(profile, uiText.Website(), url);
        }

    } else {
        // if there are no results

        // hide the profile table
        profile.setVisible(false);

        // show message
        String msg = uiText.FailedToGetProfile();
        profileInstruction.setText(msg);
        profileInstruction.setVisible(true);

    }

    // get the followers of this person
    final DefaultTaskInfo task1 = new DefaultTaskInfo(uiText.FetchingFollowers(), false);
    TaskMonitor.getInstance().addTask(task1);

    OswServiceFactory.getService().getSubscribers(jid, new RequestCallback<List<String>>() {

        @Override
        public void onFailure() {
            // TODO Auto-generated method stub
            task1.complete("", Status.failure);
        }

        @Override
        public void onSuccess(List<String> result) {

            task1.complete("", Status.succes);

            // see if there are any results
            if (result.size() > 0) {
                // sort the list alphabetically
                Collections.sort(result, new Comparator<String>() {

                    @Override
                    public int compare(String o1, String o2) {
                        return o1.compareToIgnoreCase(o2);
                    }

                });

                // add all the jids to the list
                for (final String jid : result) {

                    Label follower = new Label(jid);
                    follower.addStyleName("link");
                    follower.setTitle(uiText.ViewProfileOf() + " " + jid);
                    followersPanel.add(follower);
                    follower.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {

                            // get the app instance from the session
                            // manager
                            AbstractApplication app = OswClient.getInstance().getCurrentApplication();
                            ProfileWindow profileWindow = (ProfileWindow) app
                                    .addWindow(ProfileWindow.class.toString(), 1);
                            profileWindow.setJID(jid);
                            profileWindow.show();
                        }

                    });
                }
            } else {
                // give a message if there are no followers
                followersInstruction.setText(uiText.NoFollowers());
            }

        }

    });

    // get the people who are being followed by this person
    final DefaultTaskInfo task2 = new DefaultTaskInfo(uiText.FetchingFollowing(), false);
    TaskMonitor.getInstance().addTask(task2);

    OswServiceFactory.getService().getSubscriptions(jid, new RequestCallback<List<String>>() {

        @Override
        public void onFailure() {
            // TODO Auto-generated method stub
            task2.complete("", Status.failure);
        }

        @Override
        public void onSuccess(List<String> result) {

            task2.complete("", Status.succes);

            // see if there are any results
            if (result.size() > 0) {
                // sort the list alphabetically
                Collections.sort(result, new Comparator<String>() {

                    @Override
                    public int compare(String o1, String o2) {
                        return o1.compareToIgnoreCase(o2);
                    }

                });

                // add all the jids to the list
                for (final String jid : result) {

                    Label following = new Label(jid);
                    following.addStyleName("link");
                    following.setTitle(uiText.ViewProfileOf() + " " + jid);
                    followingPanel.add(following);
                    following.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {

                            // get the app instance from the session
                            // manager
                            AbstractApplication app = OswClient.getInstance().getCurrentApplication();
                            ProfileWindow profileWindow = (ProfileWindow) app
                                    .addWindow(ProfileWindow.class.toString(), 1);
                            profileWindow.setJID(jid);
                            profileWindow.show();
                        }

                    });
                }
            } else {
                // give a message if no one is followed
                followingInstruction.setText(uiText.NoFollowing());
            }

        }

    });

}

From source file:org.openelis.gwt.widget.CalendarWidget.java

License:Open Source License

public void setHandlers() {
    if (def.getName().equals("Calendar")) {
        ((Label) def.getWidget("MonthDisplay")).setText(form.monthDisplay);
        boolean displayMonth = false;
        Date currDate = new Date();
        if (form.month == currDate.getMonth() && (form.year - 1900) == currDate.getYear())
            displayMonth = true;/*from ww w  .  j a  v a  2 s .c om*/
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 7; j++) {
                Label date = (Label) def.getWidget("cell:" + i + ":" + j);
                date.setStyleName("DateText");
                if (i == 0 && form.cells[i][j] > 7) {
                    date.addStyleName("offMonth");
                    ((IconContainer) date.getParent()).enable(false);
                } else if (i >= 4 && form.cells[i][j] < 14) {
                    date.addStyleName("offMonth");
                    ((IconContainer) date.getParent()).enable(false);
                } else {
                    date.removeStyleName("offMonth");
                    ((IconContainer) date.getParent()).enable(true);
                    if (displayMonth && form.cells[i][j] == form.date.get(Datetime.DAY))
                        date.addStyleName("Current");
                    else
                        date.removeStyleName("Current");
                }
                date.setText(String.valueOf(form.cells[i][j]));
                if (prevMonth == null)
                    date.addClickHandler(this);
            }
        }
        if (prevMonth == null) {
            prevMonth = (org.openelis.gwt.widget.AppButton) def.getWidget("prevMonth");
            prevMonth.addClickHandler(this);
            prevMonth.enable(true);
        }
        if (nextMonth == null) {
            nextMonth = (AppButton) def.getWidget("nextMonth");
            nextMonth.addClickHandler(this);
            nextMonth.enable(true);
        }
        if (monthSelect == null) {
            monthSelect = (AppButton) def.getWidget("monthSelect");
            monthSelect.addClickHandler(this);
            monthSelect.enable(true);
        }
        if (today == null) {
            today = (AppButton) def.getWidget("today");
            today.addClickHandler(this);
            today.enable(true);
        }
        if (form.date.getEndCode() > Datetime.DAY) {
            if (time == null) {
                time = (TextBox<Datetime>) def.getWidget("time");
            }
            time.setFieldValue(Datetime.getInstance(Datetime.HOUR, Datetime.MINUTE, form.date.getDate()));
            def.getWidget("TimeBar").setVisible(true);
        } else
            def.getWidget("TimeBar").setVisible(false);
    } else {
        if (prevDecade == null) {
            prevDecade = (AppButton) def.getWidget("prevDecade");
            prevDecade.addClickHandler(this);
            prevDecade.enable(true);
        }
        if (nextDecade == null) {
            nextDecade = (AppButton) def.getWidget("nextDecade");
            nextDecade.addClickHandler(this);
            nextDecade.enable(true);
        }
        if (ok == null) {
            ok = (AppButton) def.getWidget("ok");
            ok.addClickHandler(this);
            ok.enable(true);
        }
        if (cancel == null) {
            cancel = (AppButton) def.getWidget("cancel");
            cancel.addClickHandler(this);
            cancel.enable(true);
        }
        if (months == null) {
            months = new ArrayList<AppButton>();
            for (int i = 0; i < 12; i++) {
                months.add((AppButton) def.getWidget("month" + i));
                ((AppButton) def.getWidget("month" + i)).addClickHandler(this);
            }
        }
        if (years == null) {
            years = new ArrayList<AppButton>();
            for (int i = 0; i < 10; i++) {
                years.add((AppButton) def.getWidget("year" + i));
                years.get(i).addClickHandler(this);

            }
        }
        int yr = form.year / 10 * 10;
        for (int i = 0; i < 10; i++) {
            Label year = (Label) def.getWidget("year" + i + "Text");
            year.setText(String.valueOf(yr + i));
            if (form.year == yr + i) {
                ((Widget) def.getWidget("year" + i)).addStyleName("Current");
            }
        }
        ((Widget) def.getWidget("month" + form.month)).addStyleName("Current");

    }
}

From source file:org.openmoney.omlets.mobile.client.ui.widgets.AccountRow.java

License:Open Source License

/**
 * Sets the row value adding a custom style
 *//*from www  .j a v  a 2s. c  om*/
public void setValue(String value, String style, ClickHandler clickhandler) {
    Label valueLabel = new Label(value);
    valueLabel.addClickHandler(clickhandler);
    if (StringHelper.isNotEmpty(style)) {
        valueLabel.addStyleName(style);
    }
    rightContainer.add(valueLabel);
}

From source file:org.openmoney.omlets.mobile.client.ui.widgets.AccountRow.java

License:Open Source License

/**
 * Sets the row fourth value adding a custom style and clickhandler
 *//*from  ww  w. j  a  va 2  s.c  om*/

public void setFourthValue(String value, String style, ClickHandler clickhandler) {
    Label valueLabel = new Label(value);

    valueLabel.addClickHandler(clickhandler);
    if (StringHelper.isNotEmpty(style)) {
        valueLabel.addStyleName(style);
    }
    fourthContainer.add(valueLabel);
}

From source file:org.pentaho.mantle.client.solutionbrowser.workspace.WorkspacePanel.java

License:Open Source License

private void buildJobTable(ArrayList<JobDetail> jobDetails, FlexTable jobTable, DisclosurePanel disclosurePanel,
        int tableType) {
    disclosurePanel.setOpen(jobDetails != null && jobDetails.size() > 0);
    for (int row = 0; row < jobDetails.size(); row++) {
        final JobDetail jobDetail = jobDetails.get(row);

        HorizontalPanel actionPanel = new HorizontalPanel();
        if (tableType == COMPLETE) {
            Label viewLabel = new Label(Messages.getString("view")); //$NON-NLS-1$
            viewLabel.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    // PromptDialogBox viewDialog = new PromptDialogBox(jobDetail.name, "Close", null, true, true);
                    // viewDialog.setPixelSize(1024, 600);
                    // viewDialog.center();
                    // // if this iframe is placed above the show/center of the dialog, the browser will
                    // // end up making 2 requests for the url in the iframe (one of which will be terminated and
                    // // we'll see an error on the server about a broken pipe).
                    // Frame iframe = new Frame("GetContent?action=view&id=" + jobDetail.id);
                    // viewDialog.setContent(iframe);
                    // iframe.setPixelSize(1024, 600);
                    SolutionBrowserPerspective.getInstance().getContentTabPanel().showNewURLTab(jobDetail.name,
                            jobDetail.name, "GetContent?action=view&id=" + jobDetail.id, false); //$NON-NLS-1$
                }/*  www.  j a va 2  s.  c  o  m*/
            });
            viewLabel.setStyleName("backgroundContentAction"); //$NON-NLS-1$
            viewLabel.setTitle(Messages.getString("viewContent")); //$NON-NLS-1$
            Label deleteLabel = new Label(Messages.getString("delete")); //$NON-NLS-1$
            deleteLabel.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    deleteContentItem(jobDetail.id);
                }

            });
            deleteLabel.setStyleName("backgroundContentAction"); //$NON-NLS-1$
            deleteLabel.setTitle(Messages.getString("deleteContent")); //$NON-NLS-1$

            actionPanel.add(viewLabel);
            actionPanel.add(new HTML("&nbsp;|&nbsp;")); //$NON-NLS-1$
            actionPanel.add(deleteLabel);
        } else if (tableType == WAITING) {
            Label cancelLabel = new Label(Messages.getString("cancel")); //$NON-NLS-1$
            cancelLabel.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    cancelBackgroundJob(jobDetail.id, jobDetail.group);
                }

            });
            cancelLabel.setStyleName("backgroundContentAction"); //$NON-NLS-1$
            cancelLabel.setTitle(Messages.getString("cancelExecution")); //$NON-NLS-1$
            actionPanel.add(cancelLabel);
        }

        jobTable.setWidget(row + 1, 0, new Label(
                jobDetail.name == null ? (jobDetail.id == null ? "-" : jobDetail.id) : jobDetail.name)); //$NON-NLS-1$
        jobTable.setWidget(row + 1, 1, new Label(jobDetail.timestamp == null ? "-" : jobDetail.timestamp)); //$NON-NLS-1$
        if (tableType == COMPLETE) {
            jobTable.setWidget(row + 1, 2, new Label("" + jobDetail.size)); //$NON-NLS-1$
            jobTable.setWidget(row + 1, 3, new Label(jobDetail.type));
            jobTable.setWidget(row + 1, 4, actionPanel);
            jobTable.getCellFormatter().setStyleName(row + 1, 0, "backgroundContentTableCell"); //$NON-NLS-1$
            jobTable.getCellFormatter().setStyleName(row + 1, 1, "backgroundContentTableCell"); //$NON-NLS-1$
            jobTable.getCellFormatter().setStyleName(row + 1, 2, "backgroundContentTableCell"); //$NON-NLS-1$
            jobTable.getCellFormatter().setHorizontalAlignment(row + 1, 2, HasHorizontalAlignment.ALIGN_RIGHT);
            jobTable.getCellFormatter().setStyleName(row + 1, 3, "backgroundContentTableCell"); //$NON-NLS-1$
            jobTable.getCellFormatter().setStyleName(row + 1, 4, "backgroundContentTableCellRight"); //$NON-NLS-1$
            if (row == jobDetails.size() - 1) {
                // last
                jobTable.getCellFormatter().setStyleName(row + 1, 0, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                jobTable.getCellFormatter().setStyleName(row + 1, 1, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                jobTable.getCellFormatter().setStyleName(row + 1, 2, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                jobTable.getCellFormatter().setHorizontalAlignment(row + 1, 2,
                        HasHorizontalAlignment.ALIGN_RIGHT);
                jobTable.getCellFormatter().setStyleName(row + 1, 3, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                jobTable.getCellFormatter().setStyleName(row + 1, 4, "backgroundContentTableCellBottomRight"); //$NON-NLS-1$
            }
        } else {
            jobTable.setWidget(row + 1, 2, actionPanel);
            jobTable.getCellFormatter().setStyleName(row + 1, 0, "backgroundContentTableCell"); //$NON-NLS-1$
            jobTable.getCellFormatter().setStyleName(row + 1, 1, "backgroundContentTableCell"); //$NON-NLS-1$
            jobTable.getCellFormatter().setStyleName(row + 1, 2, "backgroundContentTableCellRight"); //$NON-NLS-1$
            if (row == jobDetails.size() - 1) {
                // last
                jobTable.getCellFormatter().setStyleName(row + 1, 0, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                jobTable.getCellFormatter().setStyleName(row + 1, 1, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                jobTable.getCellFormatter().setStyleName(row + 1, 2, "backgroundContentTableCellBottomRight"); //$NON-NLS-1$
            }
        }
    }
}

From source file:org.pentaho.mantle.client.solutionbrowser.workspace.WorkspacePanel.java

License:Open Source License

private void buildSubscriptionsTable(final ArrayList<SubscriptionBean> subscriptionsInfo,
        final FlexTable subscrTable, final DisclosurePanel disclosurePanel) {
    disclosurePanel.setOpen(subscriptionsInfo != null && subscriptionsInfo.size() > 0);
    subscrTable.setCellSpacing(2);//from ww w .  j  av  a  2  s  . c om

    int row = 0;
    Iterator<SubscriptionBean> subscrIter = subscriptionsInfo.iterator();
    while (subscrIter.hasNext()) {
        row++;
        final SubscriptionBean currentSubscr = subscrIter.next();
        VerticalPanel namePanel = new VerticalPanel();
        namePanel.add(new Label(currentSubscr.getName()));
        namePanel.add(new Label(currentSubscr.getXactionName()));

        Label scheduleDate = new Label(currentSubscr.getScheduleDate());
        Label size = new Label(currentSubscr.getSize());
        Label type = new Label(currentSubscr.getType());

        HorizontalPanel buttonsPanel = new HorizontalPanel();
        final String subscriptionId = currentSubscr.getId();

        Label lblRunNow = new Label(Messages.getString("run")); //$NON-NLS-1$
        lblRunNow.setStyleName("backgroundContentAction"); //$NON-NLS-1$
        lblRunNow.addClickHandler(new RunSubscriptionClickHandler(currentSubscr));

        Label lblArchive = new Label(Messages.getString("archive")); //$NON-NLS-1$
        lblArchive.setStyleName("backgroundContentAction"); //$NON-NLS-1$
        lblArchive.addClickHandler(new RunAndArchiveClickHandler(subscriptionId));

        Label lblEdit = new Label(Messages.getString("edit")); //$NON-NLS-1$
        lblEdit.setStyleName("backgroundContentAction"); //$NON-NLS-1$
        lblEdit.addClickHandler(new EditSubscriptionClickHandler(currentSubscr));

        Label lblDelete = new Label(Messages.getString("delete")); //$NON-NLS-1$
        lblDelete.setStyleName("backgroundContentAction"); //$NON-NLS-1$
        deleteSubscriptionClickHandler = new DeleteSubscriptionClickHandler(currentSubscr, lblDelete);
        lblDelete.addClickHandler(deleteSubscriptionClickHandler);

        buttonsPanel.add(lblRunNow);
        buttonsPanel.add(new HTML("&nbsp;|&nbsp;")); //$NON-NLS-1$
        buttonsPanel.add(lblArchive);
        buttonsPanel.add(new HTML("&nbsp;|&nbsp;")); //$NON-NLS-1$
        buttonsPanel.add(lblEdit);
        buttonsPanel.add(new HTML("&nbsp;|&nbsp;")); //$NON-NLS-1$
        buttonsPanel.add(lblDelete);

        subscrTable.setWidget(row, 0, namePanel);
        subscrTable.setWidget(row, 1, scheduleDate);
        subscrTable.setWidget(row, 2, size);
        subscrTable.setWidget(row, 3, type);
        subscrTable.setWidget(row, 4, buttonsPanel);

        subscrTable.getCellFormatter().setStyleName(row, 0, "backgroundContentTableCell"); //$NON-NLS-1$
        subscrTable.getCellFormatter().setStyleName(row, 1, "backgroundContentTableCell"); //$NON-NLS-1$
        subscrTable.getCellFormatter().setStyleName(row, 2, "backgroundContentTableCell"); //$NON-NLS-1$
        subscrTable.getCellFormatter().setHorizontalAlignment(row, 2, HasHorizontalAlignment.ALIGN_RIGHT);
        subscrTable.getCellFormatter().setStyleName(row, 3, "backgroundContentTableCell"); //$NON-NLS-1$
        subscrTable.getCellFormatter().setStyleName(row, 4, "backgroundContentTableCellRight"); //$NON-NLS-1$      

        ArrayList<String[]> scheduleList = currentSubscr.getContent();
        if (scheduleList != null) {
            int scheduleSize = scheduleList.size();

            for (int j = 0; j < scheduleSize; j++) {
                row++;
                final String[] currSchedule = scheduleList.get(j);
                subscrTable.setWidget(row, 1, new Label(currSchedule[0]));
                subscrTable.setWidget(row, 2, new Label(currSchedule[1]));
                subscrTable.setWidget(row, 3, new Label(currSchedule[2]));

                HorizontalPanel actionButtonsPanel = new HorizontalPanel();

                final Label lblViewContent = new Label(Messages.getString("view")); //$NON-NLS-1$
                lblViewContent.setStyleName("backgroundContentAction"); //$NON-NLS-1$
                lblViewContent.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        final String fileId = currSchedule[3];
                        final String name = subscriptionId;
                        performActionOnSubscriptionContent("archived", currentSubscr, name, fileId); //$NON-NLS-1$
                    }
                });
                actionButtonsPanel.add(lblViewContent);

                final Label lblDeleteContent = new Label(Messages.getString("delete")); //$NON-NLS-1$
                lblDeleteContent.setStyleName("backgroundContentAction"); //$NON-NLS-1$
                lblDeleteContent.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        doDelete(false, currentSubscr, currSchedule[3]);
                    }
                });

                actionButtonsPanel.add(new HTML("&nbsp;|&nbsp;")); //$NON-NLS-1$
                actionButtonsPanel.add(lblDeleteContent);
                subscrTable.setWidget(row, 4, actionButtonsPanel);

                subscrTable.getCellFormatter().setStyleName(row, 0, "backgroundContentTableCell"); //$NON-NLS-1$
                subscrTable.getCellFormatter().setStyleName(row, 1, "backgroundContentTableCell"); //$NON-NLS-1$
                subscrTable.getCellFormatter().setStyleName(row, 2, "backgroundContentTableCell"); //$NON-NLS-1$
                subscrTable.getCellFormatter().setHorizontalAlignment(row, 2,
                        HasHorizontalAlignment.ALIGN_RIGHT);
                subscrTable.getCellFormatter().setStyleName(row, 3, "backgroundContentTableCell"); //$NON-NLS-1$
                subscrTable.getCellFormatter().setStyleName(row, 4, "backgroundContentTableCellRight"); //$NON-NLS-1$
                if (row == scheduleSize - 1) {
                    // last
                    subscrTable.getCellFormatter().setStyleName(row, 0, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                    subscrTable.getCellFormatter().setStyleName(row, 1, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                    subscrTable.getCellFormatter().setStyleName(row, 2, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                    subscrTable.getCellFormatter().setHorizontalAlignment(row, 2,
                            HasHorizontalAlignment.ALIGN_RIGHT);
                    subscrTable.getCellFormatter().setStyleName(row, 3, "backgroundContentTableCellBottom"); //$NON-NLS-1$
                    subscrTable.getCellFormatter().setStyleName(row, 4,
                            "backgroundContentTableCellBottomRight"); //$NON-NLS-1$
                }

            }
        }
    }
}

From source file:org.pentaho.mantle.client.solutionbrowser.workspace.WorkspacePanel.java

License:Open Source License

private void buildScheduleTable(ArrayList<JobSchedule> scheduleDetails, FlexTable scheduleTable,
        DisclosurePanel disclosurePanel, final int jobSource) {
    disclosurePanel.setOpen(scheduleDetails != null && scheduleDetails.size() > 0);
    for (int row = 0; row < scheduleDetails.size(); row++) {
        final JobSchedule jobSchedule = scheduleDetails.get(row);
        HorizontalPanel actionPanel = new HorizontalPanel();
        Label suspendJobLabel = new Label(Messages.getString("suspend")); //$NON-NLS-1$
        suspendJobLabel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                suspendJob(jobSchedule.jobName, jobSchedule.jobGroup, jobSource);
            }//from  w  ww  .  j  ava  2  s .c o m

        });
        suspendJobLabel.setStyleName("backgroundContentAction"); //$NON-NLS-1$
        suspendJobLabel.setTitle(Messages.getString("suspendThisJob")); //$NON-NLS-1$

        Label resumeJobLabel = new Label(Messages.getString("resume")); //$NON-NLS-1$
        resumeJobLabel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                resumeJob(jobSchedule.jobName, jobSchedule.jobGroup, jobSource);
            }

        });
        resumeJobLabel.setStyleName("backgroundContentAction"); //$NON-NLS-1$
        resumeJobLabel.setTitle(Messages.getString("resumeThisJob")); //$NON-NLS-1$

        Label runJobLabel = new Label(Messages.getString("run")); //$NON-NLS-1$
        runJobLabel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                runJob(jobSchedule.jobName, jobSchedule.jobGroup, jobSource);
            }

        });
        runJobLabel.setStyleName("backgroundContentAction"); //$NON-NLS-1$
        runJobLabel.setTitle(Messages.getString("runThisJob")); //$NON-NLS-1$

        Label deleteJobLabel = new Label(Messages.getString("delete")); //$NON-NLS-1$
        deleteJobLabel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                deleteJob(jobSchedule.jobName, jobSchedule.jobGroup, jobSource);
            }

        });
        deleteJobLabel.setStyleName("backgroundContentAction"); //$NON-NLS-1$
        deleteJobLabel.setTitle(Messages.getString("deleteThisJob")); //$NON-NLS-1$

        if (jobSchedule.triggerState == 0) {
            actionPanel.add(suspendJobLabel);
            actionPanel.add(new HTML("&nbsp;|&nbsp;")); //$NON-NLS-1$
        }
        if (jobSchedule.triggerState == 1) {
            actionPanel.add(resumeJobLabel);
            actionPanel.add(new HTML("&nbsp;|&nbsp;")); //$NON-NLS-1$
        }
        if (jobSchedule.triggerState != 2) {
            actionPanel.add(runJobLabel);
            // actionPanel.add(new HTML("&nbsp;|&nbsp;")); //$NON-NLS-1$
        }
        // actionPanel.add(deleteJobLabel);

        if (actionPanel.getWidgetCount() == 0) {
            actionPanel.add(new HTML("&nbsp;")); //$NON-NLS-1$
        }

        scheduleTable.setWidget(row + 1, 0, new HTML(jobSchedule.jobName));
        scheduleTable.setWidget(row + 1, 1, new HTML(jobSchedule.jobGroup));
        scheduleTable.setWidget(row + 1, 2,
                new HTML(jobSchedule.jobDescription == null || jobSchedule.jobDescription.trim().length() == 0
                        ? "&nbsp;" //$NON-NLS-1$
                        : jobSchedule.jobDescription));
        scheduleTable.setWidget(row + 1, 3,
                new HTML((jobSchedule.previousFireTime == null ? Messages.getString("never") //$NON-NLS-1$
                        : jobSchedule.previousFireTime.toString()) + "<BR>" //$NON-NLS-1$
                        + (jobSchedule.nextFireTime == null ? "-" : jobSchedule.nextFireTime.toString()))); //$NON-NLS-1$
        scheduleTable.setWidget(row + 1, 4, new HTML(getTriggerStateName(jobSchedule.triggerState)));
        scheduleTable.setWidget(row + 1, 5, actionPanel);
        scheduleTable.getCellFormatter().setStyleName(row + 1, 0, "backgroundContentTableCell"); //$NON-NLS-1$
        scheduleTable.getCellFormatter().setStyleName(row + 1, 1, "backgroundContentTableCell"); //$NON-NLS-1$
        scheduleTable.getCellFormatter().setStyleName(row + 1, 2, "backgroundContentTableCell"); //$NON-NLS-1$
        scheduleTable.getCellFormatter().setStyleName(row + 1, 3, "backgroundContentTableCell"); //$NON-NLS-1$
        scheduleTable.getCellFormatter().setStyleName(row + 1, 4, "backgroundContentTableCell"); //$NON-NLS-1$
        scheduleTable.getCellFormatter().setStyleName(row + 1, 5, "backgroundContentTableCellRight"); //$NON-NLS-1$
        if (row == scheduleDetails.size() - 1) {
            // last
            scheduleTable.getCellFormatter().setStyleName(row + 1, 0, "backgroundContentTableCellBottom"); //$NON-NLS-1$
            scheduleTable.getCellFormatter().setStyleName(row + 1, 1, "backgroundContentTableCellBottom"); //$NON-NLS-1$
            scheduleTable.getCellFormatter().setStyleName(row + 1, 2, "backgroundContentTableCellBottom"); //$NON-NLS-1$
            scheduleTable.getCellFormatter().setStyleName(row + 1, 3, "backgroundContentTableCellBottom"); //$NON-NLS-1$
            scheduleTable.getCellFormatter().setStyleName(row + 1, 4, "backgroundContentTableCellBottom"); //$NON-NLS-1$
            scheduleTable.getCellFormatter().setStyleName(row + 1, 5, "backgroundContentTableCellBottomRight"); //$NON-NLS-1$
        }
    }
}

From source file:org.psystems.dicom.browser.client.component.StudyCard.java

License:Open Source License

/**
 * ?  ?   .//from  w  w  w.j a  v  a 2  s .  c o  m
 * 
 * @param dcmImage
 */
private void makeFilesPanel() {

    FilesPanel.clear();

    boolean hasRemoved = false;

    for (Iterator<DcmFileProxy> it = proxy.getFiles().iterator(); it.hasNext();) {
        final DcmFileProxy fileProxy = it.next();

        if (fileProxy.getDateRemoved() != null) {
            hasRemoved = true;
            if (!showDeletedDcmFiles)
                continue;
        }

        String html = "<a href='" + "dcm/" + fileProxy.getId() + ".dcm' target='new' title='"
                + fileProxy.getFileName() + "'>  </a>" + " :: <a href='" + "dcmtags/"
                + fileProxy.getId() + ".dcm' target='new' title='" + fileProxy.getFileName()
                + "'> ? </a>";

        VerticalPanel contentPanel = new VerticalPanel();
        contentPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

        //         Button deleteBtn = new Button( fileProxy.getDateRemoved()==null ? "" : "");

        Label l = new Label(fileProxy.getDateRemoved() == null ? "" : "");
        FilesPanel.add(l);
        l.addStyleName("LabelLink");

        l.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {

                Browser.manageStudyService.dcmFileRemoveRestore(fileProxy.getId(),
                        fileProxy.getDateRemoved() == null ? true : false, new AsyncCallback<Void>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                // TODO Auto-generated method stub

                            }

                            @Override
                            public void onSuccess(Void result) {
                                refreshPanel(proxy.getId());
                            }
                        });

            }
        });

        contentPanel.add(l);

        contentPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

        //TODO   fileProxy.getType
        if (fileProxy.haveImage()
                || (fileProxy.getMimeType() != null && fileProxy.getMimeType().equals("image/jpg"))) {
            Image imagePreview = makeItemImage(fileProxy);
            contentPanel.add(imagePreview);
        } else if (fileProxy.getMimeType() != null && fileProxy.getMimeType().equals("application/pdf")
                && fileProxy.getEncapsulatedDocSize() > 0) {

            ImageResource imgRes = resources.logoPDF();
            Image imageLogoPDF = new Image(imgRes);
            imageLogoPDF.addStyleName("Image");
            contentPanel.add(imageLogoPDF);

            imageLogoPDF.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    // TODO Auto-generated method stub
                    Window.open("dcmpdf/" + fileProxy.getId() + ".pdf", "pdf", "_blank");
                }
            });

            String htmlAttach = "<a href='" + "dcmattach/" + fileProxy.getId() + ".dcm' target='new' title='"
                    + fileProxy.getFileName() + "'> PDF </a>";
            //            contentPanel.add(new HTML(htmlAttach));
        } else {
            ImageResource imgRes = resources.logoTXT();
            Image imageLogoTXT = new Image(imgRes);
            imageLogoTXT.addStyleName("Image");
            contentPanel.add(imageLogoTXT);
        }

        contentPanel.add(new HTML(html));

        FilesPanel.add(contentPanel);

    }

    if (hasRemoved) {
        Label l = new Label((!showDeletedDcmFiles ? "" : "")
                + "  ");
        FilesPanel.add(l);
        l.addStyleName("LabelLink");
        l.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                showDeletedDcmFiles = showDeletedDcmFiles ? false : true;
                refreshPanel(proxy.getId());
            }
        });

    }

}

From source file:org.sigmah.client.ui.view.project.dashboard.RemindersLabelCellRenderer.java

License:Open Source License

/**
 * {@inheritDoc}//from  w  w w.  ja v  a 2 s.co  m
 */
@Override
public Object render(final D model, final String property, final ColumnData config, final int rowIndex,
        final int colIndex, final ListStore<D> store, final Grid<D> grid) {

    if (!view.getPresenterHandler().isAuthorizedToEditReminder()) {
        return null;
    }

    final String entityLabel;
    final boolean entityCompleted;

    if (model instanceof ReminderDTO) {
        final ReminderDTO reminder = (ReminderDTO) model;
        entityLabel = reminder.getLabel();
        entityCompleted = reminder.isCompleted();

    } else if (model instanceof MonitoredPointDTO) {
        final MonitoredPointDTO monitoredPoint = (MonitoredPointDTO) model;
        entityLabel = monitoredPoint.getLabel();
        entityCompleted = monitoredPoint.isCompleted();

    } else {
        throw new UnsupportedOperationException(
                "Only types 'ReminderDTO' and 'MonitoredPointDTO' are supported.");
    }

    // Create a label with a hyperlink style.
    com.google.gwt.user.client.ui.Label label = new com.google.gwt.user.client.ui.Label(entityLabel);

    if (entityCompleted) {
        // When the monitored point is completed, change the label style.
        label.addStyleName(STYLE_POINTS_COMPLETED);
    }

    if (view.getPresenterHandler().isAuthor(model)) {
        label.addStyleName(STYLE_HYPERLINK_LABEL);

    } else {
        return label;
    }

    // Add a click handler to response a click event.
    label.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {

            view.getPresenterHandler().onLabelClickEvent(model);

        }
    });

    return label;
}