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

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


        TableActionEnablement addEnablement = hasWriteAccess ? TableActionEnablement.ALWAYS
            : TableActionEnablement.NEVER;
        TableActionEnablement deleteEnablement = hasWriteAccess ? TableActionEnablement.ANY
            : TableActionEnablement.NEVER;

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

        addTableAction(MSG.common_button_delete(), MSG.view_drift_confirm_deleteTemplate(), ButtonColor.RED, new AbstractTableAction(
            deleteEnablement) {

            boolean result = false;

            @Override
View Full Code Here


    }

    @Override
    protected void configureTable() {
        addTableAction(MSG.common_button_delete(), MSG.view_inventory_resources_deleteConfirm(), ButtonColor.RED,
            new AbstractTableAction(TableActionEnablement.ANY) {

                // only enabled if all selected are a deletable type and if the user has delete permission
                // on the resources.
                public boolean isEnabled(ListGridRecord[] selection) {
                    boolean isEnabled = super.isEnabled(selection);
View Full Code Here

            if (hasCreatableTypes) {
                Map<String, ResourceType> displayNameMap = getDisplayNames(creatableChildTypes);
                LinkedHashMap<String, ResourceType> createTypeValueMap = new LinkedHashMap<String, ResourceType>(
                    displayNameMap);
                removeExistingSingletons(singletonChildren, createTypeValueMap);
                AbstractTableAction createAction = new AbstractTableAction(TableActionEnablement.ALWAYS) {
                    public void executeAction(ListGridRecord[] selection, Object actionValue) {
                        ResourceFactoryCreateWizard.showCreateWizard(parentResource, (ResourceType) actionValue);
                        // we can refresh the table buttons immediately since the wizard is a dialog, the
                        // user can't access enabled buttons anyway.
                        ResourceCompositeSearchView.this.refreshTableInfo();
                    }
                };
                if (override) {
                    updateTableAction(MSG.common_button_create_child(), createTypeValueMap, createAction);
                } else {
                    addTableAction(MSG.common_button_create_child(), null, createTypeValueMap, ButtonColor.BLUE, createAction);
                }
            }

            if (hasImportableTypes) {
                Map<String, ResourceType> displayNameMap = getDisplayNames(importableChildTypes);
                LinkedHashMap<String, ResourceType> importTypeValueMap = new LinkedHashMap<String, ResourceType>(
                    displayNameMap);
                removeExistingSingletons(singletonChildren, importTypeValueMap);
                AbstractTableAction importAction = new AbstractTableAction(TableActionEnablement.ALWAYS) {
                    public void executeAction(ListGridRecord[] selection, Object actionValue) {
                        ResourceFactoryImportWizard.showImportWizard(parentResource, (ResourceType) actionValue);
                        // we can refresh the table buttons immediately since the wizard is a dialog, the
                        // user can't access enabled buttons anyway.
                        ResourceCompositeSearchView.this.refreshTableInfo();
                    }
                };
                if (override) {
                    updateTableAction(MSG.common_button_import(), importTypeValueMap, importAction);
                } else {
                    addTableAction(MSG.common_button_import(), null, importTypeValueMap, ButtonColor.BLUE, importAction);
                }
            }

        } else if (!override) {
            if (!canCreate && hasCreatableTypes) {
                addTableAction(MSG.common_button_create_child(), ButtonColor.BLUE, new AbstractTableAction(
                    TableActionEnablement.NEVER) {
                    public void executeAction(ListGridRecord[] selection, Object actionValue) {
                        // never called
                    }
                });
            }
            if (!canCreate && hasImportableTypes) {
                addTableAction(MSG.common_button_import(), ButtonColor.BLUE, new AbstractTableAction(
                    TableActionEnablement.NEVER) {
                    public void executeAction(ListGridRecord[] selection, Object actionValue) {
                        // never called
                    }
                });
View Full Code Here

        stddev.setWidth("8%");

        getListGrid().setFields(serviceName, methodName, count, slowest, average, fastest, stddev);
        refresh();

        addTableAction(MSG.common_button_delete_all(), MSG.common_msg_areYouSure(), ButtonColor.RED, new AbstractTableAction(
            TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                RemoteServiceStatistics.clearAll();
                refresh();
            }
        });

        addTableAction("Export To CSV", new AbstractTableAction(TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                StringBuilder csv = new StringBuilder();
                csv.append(FIELD_SERVICENAME).append(',') //
                    .append(FIELD_METHODNAME).append(',') //
                    .append(FIELD_COUNT).append(',') //
                    .append(FIELD_SLOWEST).append(',') //
                    .append(FIELD_AVERAGE).append(',') //
                    .append(FIELD_FASTEST).append(',') //
                    .append(FIELD_STDDEV).append('\n');

                RecordList records = getListGrid().getDataAsRecordList();
                int recordsSize = records.getLength();
                for (int i = 0; i < recordsSize; i++) {
                    Record record = records.get(i);
                    csv.append(record.getAttribute(FIELD_SERVICENAME)).append(',') //
                        .append(record.getAttribute(FIELD_METHODNAME)).append(',') //
                        .append(record.getAttribute(FIELD_COUNT)).append(',') //
                        .append(record.getAttribute(FIELD_SLOWEST)).append(',') //
                        .append(record.getAttribute(FIELD_AVERAGE)).append(',') //
                        .append(record.getAttribute(FIELD_FASTEST)).append(',') //
                        .append(record.getAttribute(FIELD_STDDEV)).append('\n');
                }

                new MessageWindow("Export To CSV", "<pre>" + csv.toString() + "</pre>").show();

                refresh();
            }
        });

        addTableAction(MSG.common_button_refresh(), new AbstractTableAction(TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                refresh();
            }
        });

        if (window != null) {
            LinkedHashMap<String, Integer> timerValues = new LinkedHashMap<String, Integer>();
            timerValues.put("Now", Integer.valueOf("-2"));
            timerValues.put(MSG.common_val_never(), Integer.valueOf("-1"));
            timerValues.put("On Page Change", Integer.valueOf("0"));
            timerValues.put("1", Integer.valueOf("1"));
            timerValues.put("5", Integer.valueOf("5"));
            timerValues.put("10", Integer.valueOf("10"));
            timerValues.put("30", Integer.valueOf("30"));
            timerValues.put("60", Integer.valueOf("60"));
            History.addValueChangeHandler(new ValueChangeHandler<String>() {
                @Override
                public void onValueChange(ValueChangeEvent<String> event) {
                    if (refreshOnPageChange) {
                        refresh();
                    }
                }
            });

            addTableAction("Refresh Timer", null, timerValues, ButtonColor.RED, new AbstractTableAction(TableActionEnablement.ALWAYS) {
                @Override
                public void executeAction(ListGridRecord[] selection, Object actionValue) {

                    Integer timeout = (Integer) actionValue;

                    // if being asked to refresh now, just refresh but don't touch our schedules
                    if (timeout == null || timeout.intValue() == -2) {
                        refresh();
                        return;
                    }

                    // cancel everything - will reinstate if user elected to do one of these
                    refreshTimer.cancel();
                    refreshOnPageChange = false;

                    if (timeout.intValue() == -1) {
                        updateTitleCanvas(TABLE_TITLE);
                    } else if (timeout.intValue() == 0) {
                        refreshOnPageChange = true;
                        updateTitleCanvas(TABLE_TITLE + " (refresh on page change)");
                    } else {
                        refreshTimer.scheduleRepeating(timeout.intValue() * 1000);
                        updateTitleCanvas(TABLE_TITLE + " (refresh every " + timeout + "s)");
                    }
                    refreshTableInfo();
                }
            });
        } else { // not in the standalone window
            addTableAction("Show In Window", new AbstractTableAction(TableActionEnablement.ALWAYS) {
                @Override
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    new StatisticsWindow().show();
                    refresh();
                }
View Full Code Here

                add();
            }
        });

        addTableAction(MSG.common_button_delete(), MSG.view_drift_confirm_deleteDefs(), ButtonColor.RED,
            new AbstractTableAction(deleteEnablement) {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                delete(selection);
            }
        });

        addTableAction(MSG.common_button_delete_all(), MSG.view_drift_confirm_deleteAllDefs(), ButtonColor.RED,
            new TableAction() {
            public boolean isEnabled(ListGridRecord[] selection) {
                ListGrid grid = getListGrid();
                ResultSet resultSet = (null != grid) ? grid.getResultSet() : null;
                return (hasWriteAccess && grid != null && resultSet != null && !resultSet.isEmpty());
            }

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

        addTableAction(MSG.view_drift_button_detectNow(), null, ButtonColor.GRAY, new AbstractTableAction(
            detectNowEnablement) {
            @Override
            public boolean isEnabled(ListGridRecord[] selection) {
                if (selection.length == 0 || !hasWriteAccess) {
                    return false;
View Full Code Here

        name.setWidth("45%");

        getListGrid().setFields(id, name, value);
        refresh();

        addTableAction("Export To CSV", ButtonColor.BLUE, new AbstractTableAction(TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                final String s = "~";
                StringBuilder csv = new StringBuilder();
                csv.append(FIELD_ID).append(s).append(FIELD_NAME).append(s).append(FIELD_VALUE).append('\n');
View Full Code Here

    protected void setupTableInteractions(final boolean hasWriteAccess) {
        TableActionEnablement pinEnablement = hasWriteAccess ? TableActionEnablement.ALWAYS
            : TableActionEnablement.NEVER;

        addTableAction(MSG.view_drift_button_pinToDef(), MSG.view_drift_button_pinToDef_confirm(), ButtonColor.BLUE,
            new AbstractTableAction(pinEnablement) {

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

                @Override
                public boolean isEnabled(ListGridRecord[] selection) {
                    return !pinnedToTemplate && super.isEnabled(selection);
                }
            });

        addTableAction(MSG.view_drift_button_pinToTemplate(), MSG.view_drift_button_pinToTemplate_confirm(),
            ButtonColor.BLUE, new AbstractTableAction(pinEnablement) {

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

        endRow.setWidth("10%");

        getListGrid().setFields(timestamp, reqId, status, totalRows, startRow, endRow);
        refresh();

        addTableAction("Toggle On/Off", MSG.common_msg_areYouSure(), ButtonColor.BLUE, new AbstractTableAction(
            TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                boolean toBeEnabled = !DataSourceResponseStatistics.isEnableCollection();
                DataSourceResponseStatistics.setEnableCollection(toBeEnabled);

                if (!toBeEnabled) {
                    // disabling collection - no need to periodically refresh anymore so cancel timers
                    refreshTimer.cancel();
                    refreshOnPageChange = false;
                    timerTitleString = null;
                }

                updateTitleCanvas(getTableTitle());
                if (window != null) {
                    window.setTitle(getTableTitle());
                }
                refresh();
            }
        });

        addTableAction(MSG.common_button_delete_all(), MSG.common_msg_areYouSure(), ButtonColor.RED, new AbstractTableAction(
            TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                DataSourceResponseStatistics.clearAll();
                refresh();
            }
        });

        addTableAction("Export To CSV", new AbstractTableAction(TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                StringBuilder csv = new StringBuilder();
                csv.append(FIELD_TIMESTAMP).append(',') //
                    .append(FIELD_REQUEST_ID).append(',') //
                    .append(FIELD_STATUS).append(',') //
                    .append(FIELD_TOTAL_ROWS).append(',') //
                    .append(FIELD_START_ROW).append(',') //
                    .append(FIELD_END_ROW).append('\n');

                RecordList records = getListGrid().getDataAsRecordList();
                int recordsSize = records.getLength();
                for (int i = 0; i < recordsSize; i++) {
                    Record record = records.get(i);
                    csv.append(record.getAttributeAsDate(FIELD_TIMESTAMP)).append(',') //
                        .append(record.getAttribute(FIELD_REQUEST_ID)).append(',') //
                        .append(record.getAttribute(FIELD_STATUS)).append(',') //
                        .append(record.getAttribute(FIELD_TOTAL_ROWS)).append(',') //
                        .append(record.getAttribute(FIELD_START_ROW)).append(',') //
                        .append(record.getAttribute(FIELD_END_ROW)).append('\n');
                }

                new MessageWindow("Export To CSV", "<pre>" + csv.toString() + "</pre>").show();
                refresh();
            }
        });

        addTableAction(MSG.common_button_refresh(), new AbstractTableAction(TableActionEnablement.ALWAYS) {
            @Override
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                refresh();
            }
        });

        if (window != null) {
            LinkedHashMap<String, Integer> timerValues = new LinkedHashMap<String, Integer>();
            timerValues.put("Now", Integer.valueOf("-2"));
            timerValues.put(MSG.common_val_never(), Integer.valueOf("-1"));
            timerValues.put("On Page Change", Integer.valueOf("0"));
            timerValues.put("1", Integer.valueOf("1"));
            timerValues.put("5", Integer.valueOf("5"));
            timerValues.put("10", Integer.valueOf("10"));
            timerValues.put("30", Integer.valueOf("30"));
            timerValues.put("60", Integer.valueOf("60"));
            History.addValueChangeHandler(new ValueChangeHandler<String>() {
                @Override
                public void onValueChange(ValueChangeEvent<String> event) {
                    if (refreshOnPageChange) {
                        refresh();
                    }
                }
            });

            addTableAction("Refresh Timer", null, timerValues, ButtonColor.GRAY, new AbstractTableAction(
                TableActionEnablement.ALWAYS) {
                @Override
                public void executeAction(ListGridRecord[] selection, Object actionValue) {

                    Integer timeout = (Integer) actionValue;

                    // if being asked to refresh now, just refresh but don't touch our schedules
                    if (timeout == null || timeout.intValue() == -2) {
                        refresh();
                        return;
                    }

                    // cancel everything - will reinstate if user elected to do one of these
                    refreshTimer.cancel();
                    refreshOnPageChange = false;

                    if (timeout.intValue() == -1) {
                        timerTitleString = null;
                    } else if (timeout.intValue() == 0) {
                        refreshOnPageChange = true;
                        timerTitleString = " (refresh on page change)";
                    } else {
                        refreshTimer.scheduleRepeating(timeout.intValue() * 1000);
                        timerTitleString = " (refresh every " + timeout + "s)";
                    }

                    updateTitleCanvas(getTableTitle());
                    if (window != null) {
                        window.setTitle(getTableTitle());
                    }
                    refreshTableInfo();
                }
            });
        } else { // not in the standalone window
            addTableAction("Show In Window", new AbstractTableAction(TableActionEnablement.ALWAYS) {
                @Override
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    new StatisticsWindow().show();
                    refresh();
                }
View Full Code Here

            setDataSource(dataSource);
        }

        @Override
        protected void configureTable() {
            addTableAction(MSG.common_button_add(), null, ButtonColor.BLUE, new AbstractTableAction() {
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    showConditionEditor(null);
                }
            });

            table.addTableAction(MSG.common_button_delete(), MSG
                .view_alert_definition_condition_editor_delete_confirm(), ButtonColor.RED, new AbstractTableAction(
                TableActionEnablement.ANY) {
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    for (ListGridRecord record : selection) {
                        AlertCondition condition = getDataSource().copyValues(record);
                        conditions.remove(condition);
                        modifiedConditions.remove(condition);
                        updated = true;
                    }
                    refresh();
                }
            });

            table.addTableAction(MSG.view_alert_definition_editCondition(), null, ButtonColor.GRAY, new AbstractTableAction(TableActionEnablement.SINGLE) {
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    AlertCondition condition = getDataSource().copyValues(selection[0]);
                    showConditionEditor(condition);
                }
            });
View Full Code Here

                }
            });
        }

        if (this.resourceIdToModify != null) {
            addTableAction(MSG.view_tabs_common_group_membership() + "...", new AbstractTableAction(
                TableActionEnablement.ALWAYS) {
                @Override
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    ResourceResourceGroupsView membershipView = new ResourceResourceGroupsView(
                        ResourceGroupListView.this.resourceIdToModify.intValue());
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.