Package org.rhq.coregui.client.components.table

Examples of org.rhq.coregui.client.components.table.AbstractTableAction


                }
            }
        });

        addTableAction(MSG.common_button_delete(), MSG.common_msg_areYouSure(), ButtonColor.RED,
            new AbstractTableAction(TableActionEnablement.ANY) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                try {
                    for (ListGridRecord record : selection) {
                        Object doomed = record.getAttributeAsObject(FIELD_OBJECT);
                        CoreGUI.getMessageCenter().getMessages().remove(doomed);
                    }
                    refresh();
                    updateMsgCenterButtonContent();
                } catch (Throwable e) {
                    Log.error("Cannot delete messages", e);
                }
            }
        });

        addTableAction(MSG.common_button_delete_all(), MSG.common_msg_areYouSure(), ButtonColor.RED,
            new AbstractTableAction(TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                try {
                    CoreGUI.getMessageCenter().getMessages().clear();
                    refresh();
                    updateMsgCenterButtonContent();
                } catch (Throwable e) {
                    Log.error("Cannot delete all messages", e);
                }
            }
        });

        LinkedHashMap<String, Integer> maxMessagesMap = new LinkedHashMap<String, Integer>();
        maxMessagesMap.put("10", Integer.valueOf("10"));
        maxMessagesMap.put("25", Integer.valueOf("25"));
        maxMessagesMap.put("50", Integer.valueOf("50"));
        maxMessagesMap.put("100", Integer.valueOf("100"));
        maxMessagesMap.put("200", Integer.valueOf("200"));
        addTableAction(MSG.view_messageCenter_maxMessages(), null, maxMessagesMap, ButtonColor.GRAY,
            new AbstractTableAction(TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                try {
                    Integer maxSize = (Integer) actionValue;
                    CoreGUI.getMessageCenter().setMaxMessages(maxSize.intValue());
View Full Code Here


        super.configureTable();
        addExportAction();
    }

    private void addExportAction() {
        addTableAction("Export", MSG.common_button_reports_export(), ButtonColor.BLUE, new AbstractTableAction() {
            @Override
            public boolean isEnabled(ListGridRecord[] selection) {
                return enableIfRecordsExist(getListGrid());
            }
View Full Code Here

        ListGridField descriptionField = listGrid.getField(AbstractAlertDefinitionsDataSource.FIELD_DESCRIPTION);
        descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());

        final boolean isAuthorized = isAuthorizedToModifyAlertDefinitions();

        addTableAction(MSG.common_button_new(), null, ButtonColor.BLUE, new AbstractTableAction() {
            public boolean isEnabled(ListGridRecord[] selection) {
                return super.isEnabled(selection) && isAuthorized;
            }

            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                newButtonPressed(selection);
            }
        });

        addTableAction(MSG.common_button_enable(), MSG.view_alert_definitions_enable_confirm(),
            new AbstractTableAction(TableActionEnablement.ANY) {
                public boolean isEnabled(ListGridRecord[] selection) {
                    return super.isEnabled(selection) && isAuthorized;
                }

                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    enableButtonPressed(selection);
                    refresh();
                }
            });
        addTableAction(MSG.common_button_disable(), MSG.view_alert_definitions_disable_confirm(),
            new AbstractTableAction(TableActionEnablement.ANY) {
                public boolean isEnabled(ListGridRecord[] selection) {
                    return super.isEnabled(selection) && isAuthorized;
                }

                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    disableButtonPressed(selection);
                    refresh();
                }
            });
        addTableAction(MSG.common_button_delete(), MSG.view_alert_definitions_delete_confirm(), ButtonColor.RED,
            new AbstractTableAction(TableActionEnablement.ANY) {
                public boolean isEnabled(ListGridRecord[] selection) {
                    return super.isEnabled(selection) && isAuthorized;
                }

                public void executeAction(ListGridRecord[] selection, Object actionValue) {
View Full Code Here

        ResourceComposite resourceComposite = titleBar.getResource();
        Set<Permission> resourcePermissions = resourceComposite.getResourcePermission().getPermissions();
        final boolean canModifyResource = resourcePermissions.contains(Permission.MODIFY_RESOURCE);
        addTableAction(MSG.common_button_delete(), MSG.common_msg_areYouSure(), ButtonColor.RED,
            new AbstractTableAction(canModifyResource ? TableActionEnablement.ANY : TableActionEnablement.NEVER) {
            public void executeAction(final ListGridRecord[] selection, Object actionValue) {
                if (selection == null || selection.length == 0) {
                    return;
                }
                int[] resourceErrorIds = new int[selection.length];
View Full Code Here

            }
        });

        boolean hasAuthz = globalPermissions.contains(Permission.MANAGE_BUNDLE_GROUPS);

        addTableAction(MSG.common_button_new(), null, ButtonColor.BLUE, new AbstractTableAction(
            (hasAuthz) ? TableActionEnablement.ALWAYS : TableActionEnablement.NEVER) {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                newDetails();
            }
        });

        addTableAction(MSG.common_button_delete(), MSG.view_bundleGroup_deleteConfirm(), ButtonColor.RED,
            new AbstractTableAction((hasAuthz) ? TableActionEnablement.ANY : TableActionEnablement.NEVER) {
            public void executeAction(ListGridRecord[] selections, Object actionValue) {
                if (selections == null || selections.length == 0) {
                    return;
                }
View Full Code Here

        ListGrid listGrid = getListGrid();
        listGrid.setFields(fieldId, fieldDateCreated, fieldLastUpdated, fieldStatus, fieldUser);

        addTableAction(MSG.common_button_delete(),  MSG.common_msg_areYouSure(), ButtonColor.RED,
            new AbstractTableAction(this.groupPerms.isInventory() ? TableActionEnablement.ANY
                : TableActionEnablement.NEVER) {

                @Override
                public void executeAction(final ListGridRecord[] selection, Object actionValue) {
                    if (selection == null || selection.length == 0) {
                        return;
                    }

                    ConfigurationGWTServiceAsync service = GWTServiceLookup.getConfigurationService();
                    Integer groupId = HistoryGroupResourceConfigurationTable.this.group.getId();
                    Integer[] updateIds = new Integer[selection.length];
                    int i = 0;
                    for (ListGridRecord record : selection) {
                        updateIds[i++] = record.getAttributeAsInt(GroupResourceConfigurationDataSource.Field.ID);
                    }

                    service.deleteGroupResourceConfigurationUpdate(groupId, updateIds, new AsyncCallback<Void>() {
                        @Override
                        public void onSuccess(Void result) {
                            refresh();
                            Message message = new Message(MSG.view_group_resConfig_table_deleteSuccessful(String
                                .valueOf(selection.length)), Message.Severity.Info, EnumSet
                                .of(Message.Option.Transient));
                            CoreGUI.getMessageCenter().notify(message);
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            refreshTableInfo();
                            CoreGUI.getErrorHandler().handleError(MSG.view_group_resConfig_table_deleteFailure(),
                                caught);
                        }
                    });
                }
            });

        addTableAction(MSG.view_group_resConfig_table_viewSettings(), ButtonColor.BLUE, new AbstractTableAction(
            TableActionEnablement.SINGLE) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                CoreGUI.goToView(LinkManager.getGroupResourceConfigurationUpdateHistoryLink(
                    EntityContext.forGroup(HistoryGroupResourceConfigurationTable.this.group), null)
                    + "/" + selection[0].getAttribute(GroupResourceConfigurationDataSource.Field.ID) + "/Settings");
                refreshTableInfo();
            }
        });

        addTableAction(MSG.view_group_resConfig_table_viewMemberHistory(), new AbstractTableAction(
            TableActionEnablement.SINGLE) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                CoreGUI.goToView(LinkManager.getGroupResourceConfigurationUpdateHistoryLink(
                    EntityContext.forGroup(HistoryGroupResourceConfigurationTable.this.group), null)
View Full Code Here

    private void setupTableInteractions() {
        if (canSupportDeleteAndPurgeAll()) {
            TableActionEnablement singleTargetEnablement = hasWriteAccess ? TableActionEnablement.ANY
                : TableActionEnablement.NEVER;
            addTableAction(MSG.common_button_delete(), MSG.common_msg_areYouSure(), ButtonColor.RED,
                new AbstractTableAction(singleTargetEnablement) {
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    deleteButtonPressed(selection);
                }
            });

            TableActionEnablement multipleTargetEnablement = hasWriteAccess ? TableActionEnablement.ALWAYS
                : TableActionEnablement.NEVER;
            addTableAction(MSG.common_button_purgeAll(), MSG.common_msg_areYouSure(), ButtonColor.RED,
                new AbstractTableAction(multipleTargetEnablement) {
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    purgeButtonPressed();
                }
            });
        }
View Full Code Here

        });

        setListGridFields(idField, originField, nameField, descriptionField, expressionField, lastCalculationTimeField,
            nextCalculationTimeField);

        addTableAction(MSG.common_button_delete(), MSG.common_msg_areYouSure(), ButtonColor.RED, new AbstractTableAction(
            TableActionEnablement.ANY) {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                final int[] groupDefinitionIds = TableUtility.getIds(selection);
                ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(60000);
                groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
                    @Override
                    public void onSuccess(Void result) {
                        CoreGUI.getMessageCenter().notify(
                            new Message(MSG.view_dynagroup_deleteSuccessfulSelection(String
                                .valueOf(groupDefinitionIds.length)), Severity.Info));
                        GroupDefinitionListView.this.refresh();
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_deleteFailureSelection(), caught);
                    }
                });
            }
        });

        addTableAction(MSG.common_button_new(), null, ButtonColor.BLUE, new AbstractTableAction() {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                newDetails();
            }
        });

        addTableAction(MSG.view_dynagroup_recalculate(), null, ButtonColor.GRAY, new AbstractTableAction(TableActionEnablement.ANY) {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                final int[] groupDefinitionIds = TableUtility.getIds(selection);
                ResourceGroupGWTServiceAsync resourceGroupManager = GWTServiceLookup.getResourceGroupService();

                resourceGroupManager.recalculateGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
View Full Code Here

    protected void configureTable() {
        List<ListGridField> fields = getDataSource().getListGridFields(this.resourceId == null);
        setListGridFields(true, fields.toArray(new ListGridField[fields.size()])); // true = always show the ID field

        addTableAction(MSG.common_button_delete(), MSG.common_msg_areYouSure(), ButtonColor.RED,
            new AbstractTableAction(hasWritePerm ? TableActionEnablement.ANY : TableActionEnablement.NEVER) {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                if (selection != null && selection.length > 0) {
                    int[] doomedIds = new int[selection.length];
                    int i = 0;
                    for (ListGridRecord selected : selection) {
                        doomedIds[i++] = selected.getAttributeAsInt(AbstractConfigurationHistoryDataSource.Field.ID);
                        if (selected.getAttribute(AbstractConfigurationHistoryDataSource.Field.GROUP_CONFIG_UPDATE_ID) != null) {
                            CoreGUI.getMessageCenter().notify(
                                new Message(MSG.view_configurationHistoryList_cannotDeleteGroupItems(),
                                    Severity.Warning));
                            return; // abort
                        }
                        if (Boolean.parseBoolean(selected
                            .getAttribute(AbstractConfigurationHistoryDataSource.Field.CURRENT_CONFIG))) {
                            CoreGUI.getMessageCenter().notify(
                                new Message(MSG.view_configurationHistoryList_cannotDeleteCurrent(), Severity.Warning));
                            return; // abort
                        }
                    }
                    delete(doomedIds);
                }
            }
        });

        addTableAction(MSG.common_button_compare(), null, ButtonColor.BLUE, new AbstractTableAction(
            TableActionEnablement.MULTIPLE) {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                // The config updates do not have their Configurations fetched, so we need to reload the selected
                // config updates, specifying that their Configurations should be fetched, in order to compare the
                // Configurations.

                List<Integer> updateIds = new ArrayList<Integer>();
                for (ListGridRecord record : selection) {
                    int updateId = record.getAttributeAsInt(AbstractConfigurationHistoryDataSource.Field.ID);
                    updateIds.add(updateId);
                }

                Criteria criteria = new Criteria();
                criteria.addCriteria(AbstractConfigurationHistoryDataSource.CriteriaField.IDS,
                    updateIds.toArray(new Integer[updateIds.size()]));

                DSRequest requestProperties = new DSRequest();
                requestProperties.setAttribute(
                    AbstractConfigurationHistoryDataSource.RequestProperty.FETCH_CONFIGURATION, true);

                getDataSource().fetchData(criteria, new DSCallback() {
                    public void execute(DSResponse response, Object rawData, DSRequest request) {
                        ArrayList<AbstractResourceConfigurationUpdate> updatesWithConfigs = new ArrayList<AbstractResourceConfigurationUpdate>();
                        Record[] records = response.getData();
                        for (Record record : records) {
                            AbstractResourceConfigurationUpdate update = (AbstractResourceConfigurationUpdate) record
                                .getAttributeAsObject(AbstractConfigurationHistoryDataSource.Field.OBJECT);
                            updatesWithConfigs.add(update);
                        }
                        ConfigurationComparisonView.displayComparisonDialog(updatesWithConfigs);
                    }
                }, requestProperties);
            }
        });

        if (getResourceId() != null) {
            addTableAction(MSG.view_configurationHistoryList_rollback(), MSG.common_msg_areYouSure(), ButtonColor.RED,
                new AbstractTableAction(hasWritePerm ? TableActionEnablement.SINGLE : TableActionEnablement.NEVER) {
                    public void executeAction(ListGridRecord[] selection, Object actionValue) {
                        if (selection != null && selection.length == 1) {
                            ListGridRecord record = selection[0];
                            int configHistoryIdToRollbackTo = record
                                .getAttributeAsInt(AbstractConfigurationHistoryDataSource.Field.ID);
View Full Code Here

        super.configureTable();

        Log.debug("MembersView canModifyMembers: " + canModifyMembers);
        if (canModifyMembers) {
            addTableAction(MSG.view_groupInventoryMembers_button_updateMembership(), ButtonColor.BLUE,
                new AbstractTableAction(                TableActionEnablement.ALWAYS) {
                @Override
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    final Window winModal = new Window();
                    winModal.setTitle(MSG.view_groupInventoryMembers_title_updateMembership());
                    winModal.setOverflow(Overflow.VISIBLE);
View Full Code Here

TOP

Related Classes of org.rhq.coregui.client.components.table.AbstractTableAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.