Java Code Examples for com.smartgwt.client.widgets.IButton#setLayoutAlign()

The following examples show how to use com.smartgwt.client.widgets.IButton#setLayoutAlign() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AllRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
protected Canvas createEditRuleButton(final ListGridRecord ruleRecord) {
    String userID = getLoggedInUser();
    String ruleOwnerID = ruleRecord.getAttribute(OWNERID);
    if (ruleOwnerID.equals(userID)) {
        IButton editButton = new IButton(i18n.edit());
        editButton.setShowDown(false);
        editButton.setShowRollOver(false);
        editButton.setLayoutAlign(Alignment.CENTER);
        editButton.setPrompt(i18n.editThisRule());
        editButton.setHeight(16);
        editButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String name = ruleRecord.getAttribute(NAME);
                EventBus.getMainEventBus().fireEvent(new EditRuleEvent(name));
            }
        });
        return editButton;
    } else {
        return null;
    }
}
 
Example 2
Source File: AllRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
protected Canvas createDeleteRuleButton(final ListGridRecord record) {
    IButton deleteButton = new IButton(i18n.delete());
    deleteButton.setShowDown(false);
    deleteButton.setShowRollOver(false);
    deleteButton.setLayoutAlign(CENTER);
    deleteButton.setPrompt(i18n.deleteThisRule());
    deleteButton.setHeight(16);
    deleteButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            SC.ask(i18n.reallyDeleteRule(), new BooleanCallback() {
                public void execute(Boolean value) {
                    if (value) {
                        String uuid = record.getAttribute(UUID);
                        String userRole = getLoggedInUser();
                        DeleteRuleEvent deleteRuleEvent = new DeleteRuleEvent(currentSession(), uuid, userRole);
                        EventBus.getMainEventBus().fireEvent(deleteRuleEvent);
                    }
                }
            });
        }
    });

    return deleteButton;
}
 
Example 3
Source File: OwnRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createDeleteRuleButtonm(final ListGridRecord ruleRecord) {
    IButton deleteButton = new IButton(i18n.delete());
    deleteButton.setShowDown(false);
    deleteButton.setShowRollOver(false);
    deleteButton.setLayoutAlign(Alignment.CENTER);
    deleteButton.setPrompt(i18n.deleteThisRule());
    deleteButton.setHeight(16);
    deleteButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            SC.ask(i18n.reallyDeleteRule(), new BooleanCallback() {
                public void execute(Boolean value) {
                    if (value) {
                        String uuid = ruleRecord.getAttribute(UUID);
                        String userRole = getLoggedInUserRole();
                        EventBus.getMainEventBus().fireEvent(new DeleteRuleEvent(currentSession(), uuid, userRole));
                    }
                }
            });
        }
    });
    return deleteButton;
}
 
Example 4
Source File: OwnRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createPublishRuleButton(final ListGridRecord ruleRecord) {
    IButton publishButton = new IButton(i18n.publishButton());
    publishButton.setShowDown(false);
    publishButton.setShowRollOver(false);
    publishButton.setLayoutAlign(Alignment.CENTER);
    publishButton.setHeight(16);
    publishButton.setAutoFit(true);

    final boolean published = ruleRecord.getAttributeAsBoolean(PUBLISHED);
    if (published) {
        publishButton.setTitle(i18n.unpublishButton());
        publishButton.setPrompt(i18n.cancelPublication());
    } else {
        publishButton.setTitle(i18n.publishButton());
        publishButton.setPrompt(i18n.publishThisRule());
    }

    publishButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String ruleName = ruleRecord.getAttribute(NAME);
            EventBus.getMainEventBus().fireEvent(new PublishRuleEvent(currentSession(), ruleName, !published, "USER"));
        }
    });

    return publishButton;
}
 
Example 5
Source File: OwnRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createEditRuleButton(final ListGridRecord ruleRecord) {
    // subscribe button
    IButton editButton = new IButton(i18n.edit());
    editButton.setShowDown(false);
    editButton.setShowRollOver(false);
    editButton.setLayoutAlign(Alignment.CENTER);
    editButton.setPrompt(i18n.editThisRule());
    editButton.setHeight(16);
    editButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String name = ruleRecord.getAttribute(NAME);
            EventBus.getMainEventBus().fireEvent(new GetAllPublishedRulesEvent(currentSession(), 1));
            EventBus.getMainEventBus().fireEvent(new EditRuleEvent(name));
        }
    });

    return editButton;
}
 
Example 6
Source File: OtherUserRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {

    if (record != null) {
        String fieldName = this.getFieldName(colNum);

       if (fieldName.equals(EditRulesLayout.EDIT_RULES_COPY)) {
            // Copy button
            IButton copyButton = new IButton(i18n.copy());
            copyButton.setShowDown(false);
            copyButton.setShowRollOver(false);
            copyButton.setHeight(17);
            copyButton.setLayoutAlign(Alignment.CENTER);
            copyButton.setAlign(Alignment.CENTER);
            copyButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    System.out.println("copy " + record.getAttribute("name"));
                    String userID = getLoggedInUserId();
                    EventBus.getMainEventBus().fireEvent(new CopyEvent(userID, record.getAttribute("name")));
                }
            });
            return copyButton;
        }
    return null;
    }
    return null;
}