.classpath | 2 etc/cli-scripts/measurement_utils.js | 134 + etc/eclipse-tools/maven/RHQ | 13 modules/common/jboss-as/pom.xml | 6 modules/common/jboss-as/src/main/java/org/jboss/on/common/jbossas/JmxConnectionHelper.java | 262 +++ modules/core/dbutils/pom.xml | 2 modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml | 2 modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml | 2 modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 25 modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java | 55 modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java | 34 modules/core/domain/src/main/java/org/rhq/core/domain/common/EntityContext.java | 186 ++ modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java | 6 modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java | 12 modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java | 8 modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java | 56 modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java | 54 modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java | 16 modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java | 10 modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java | 9 modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java | 14 modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java | 5 modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java | 13 modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java | 48 modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java | 10 modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java | 9 modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java | 1 modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java | 51 modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java | 52 modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java | 74 modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java | 58 modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java | 59 modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java | 53 modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java | 7 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java | 4 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java | 8 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java | 1 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java | 18 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java | 4 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java | 8 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java | 4 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java | 4 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java | 23 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java | 11 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java | 10 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java | 5 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java | 12 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java | 6 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java | 83 - modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java | 12 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java | 7 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java | 22 modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java | 18 modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java | 3 modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 16 modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java | 4 modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java | 16 modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java | 6 modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java | 12 modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java | 21 modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/GroupDefinition.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java | 11 modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java | 8 modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java | 20 modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java | 7 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java | 48 modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 7 modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java | 15 modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java | 7 modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java | 7 modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java | 25 modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java | 47 modules/enterprise/gui/coregui/pom.xml | 36 modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java | 103 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java | 12 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 67 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 39 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 67 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 58 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java | 51 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java | 277 +-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java | 100 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java | 10 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 44 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 14 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java | 126 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java | 154 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 113 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 17 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java | 234 ++- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 167 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java | 5 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 24 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 28 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java | 36 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 174 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java | 36 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java | 17 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 39 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 755 ++++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java | 181 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 11 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 166 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 19 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java | 17 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 40 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java | 11 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java | 11 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 10 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java | 24 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnumSelectItem.java | 81 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java | 34 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java | 13 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java | 213 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java | 27 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java | 22 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java | 53 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 395 +++-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 85 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 53 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 119 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 601 +++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java | 170 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java | 136 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 326 ++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 178 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java | 37 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java | 31 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java | 23 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java | 17 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 225 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java | 147 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java | 141 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 178 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java | 13 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 28 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 138 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 120 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java | 417 +++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 401 ++--- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java | 27 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java | 43 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 127 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java | 133 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java | 52 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java | 78 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java | 50 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java | 17 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java | 104 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 48 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 379 +---- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java | 23 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java | 217 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 91 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDatasource.java | 134 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDetailsView.java | 99 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventHistoryView.java | 79 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupSelector.java | 50 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupsView.java | 125 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java | 14 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java | 120 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java | 61 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 26 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java | 24 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java | 58 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java | 209 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java | 92 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 11 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java | 45 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 55 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 53 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 144 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 46 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java | 46 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/HighlightingDatasourceTextField.java | 47 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java | 117 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 58 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java | 41 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TableUtility.java | 44 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java | 69 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java | 190 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/effects/ColoringUtility.java | 92 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java | 27 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java | 46 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java | 26 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java | 30 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java | 79 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java | 47 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 10 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 17 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java | 116 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java | 13 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 5 modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 27 modules/enterprise/gui/coregui/src/main/webapp/images/types/GroupDefinition_16.png |binary modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java | 8 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java | 15 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java | 28 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java | 4 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java | 14 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java | 13 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java | 3 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java | 2 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml | 2 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp | 2 modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml | 9 modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml | 8 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 7 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 89 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/common/EntityContext.java | 140 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 8 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java | 58 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java | 8 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java | 12 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java | 5 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 69 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java | 45 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 80 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java | 42 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 14 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java | 2 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java | 16 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java | 85 + modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java | 2 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java | 30 modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy | 2 modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy | 3 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 103 - modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java | 3 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java | 4 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JmxConnectionHelper.java | 264 --- modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 15 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java | 8 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java | 2 modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java | 19 modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java | 36 pom.xml | 171 +- 334 files changed, 10573 insertions(+), 4780 deletions(-)
New commits: commit cd04ddb727b3bf81c85a328eb680e6a12185170b Author: Heiko W. Rupp hwr@redhat.com Date: Thu Sep 23 10:22:28 2010 +0200
Check that the timing is linear
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java index a306679..aecb6f2 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java @@ -55,6 +55,7 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest { AvailabilityManagerLocal availabilityManager; AgentManagerLocal agentManager; private static final int MILLIS_APART = 2000; + private static final String ROUND__FORMAT = "Round %6d";
@BeforeMethod public void beforeMethod() { @@ -90,7 +91,7 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
for ( int j = 0; j < ROUNDS.length; j++) { int MULTI = ROUNDS[j]; - String round = "Round " + String.format("%6d",MULTI); + String round = String.format(ROUND__FORMAT,MULTI);
long t1 = System.currentTimeMillis() - (MULTI * MILLIS_APART); for ( int i = 0 ; i < MULTI ; i++ ) { @@ -105,9 +106,19 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest { availabilityManager.mergeAvailabilityReport(report); endTiming(round); } + + + + }
- + long timing1000 = getTiming(String.format(ROUND__FORMAT,1000)); + long timing2000 = getTiming(String.format(ROUND__FORMAT,2000)); + long timing3000 = getTiming(String.format(ROUND__FORMAT,3000)); + + assertCirca(timing1000,timing2000,2); + assertCirca(timing1000,timing3000,3); +
commitTimings();
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java index 94a04f0..96ecf27 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java @@ -24,8 +24,6 @@ import org.apache.commons.logging.LogFactory; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet;
/** * Helper that introduces timing functionality on top of the Abstract EJB tests. @@ -75,6 +73,18 @@ public class AbstractEJB3PerformanceTest extends AbstractEJB3Test { endTiming(DEFAULT); }
+ protected long getTiming(String name) { + if (timings.containsKey(name)) { + return timings.get(name); + } + else + return -1; + } + + protected long getTiming() { + return getTiming(DEFAULT); + } +
protected void commitTimings() {
@@ -102,4 +112,20 @@ public class AbstractEJB3PerformanceTest extends AbstractEJB3Test { protected void assertTiming(long maxDuration) { assertTiming(DEFAULT,maxDuration); } + + /** + * Make sure the passed value is within a band of <code>[0.9* x, 1.1*x]</code> with + * <code>x = ( ref * multiplier )</code>. + * @param ref base value to calculate the reference from + * @param value value to compare to the band + * @param multiplier multiplier for the base value of the band. + */ + protected void assertCirca(long ref,long value, double multiplier ) { + long low = (long) (ref * multiplier * 0.9); + long hi = (long) (ref * multiplier * 1.1); + + assert value >= low : "[low] Val2 (" + value + ") is not > " + low; + assert value <= hi : "[hi] Val2 (" + value + ") is not < " + hi; + } + }
commit 8bfe9b3d3834edb92db26feb59d8532b2c2ce018 Author: Heiko W. Rupp hwr@redhat.com Date: Thu Sep 23 09:31:39 2010 +0200
Feed availability reports into the system and record timings.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java index 36c29c8..a306679 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java @@ -18,9 +18,26 @@ */ package org.rhq.enterprise.server.performance.test;
+import java.util.Date; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.rhq.core.domain.discovery.AvailabilityReport; +import org.rhq.core.domain.measurement.Availability; +import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.domain.resource.Agent; +import org.rhq.core.domain.resource.Resource; +import org.rhq.enterprise.server.core.AgentManagerLocal; +import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal; +import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.test.AbstractEJB3PerformanceTest; +import org.rhq.enterprise.server.util.LookupUtil; import org.rhq.helpers.perftest.support.testng.DatabaseSetupInterceptor; import org.rhq.helpers.perftest.support.testng.DatabaseState; + +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Listeners; import org.testng.annotations.Test;
@@ -34,13 +51,63 @@ import org.testng.annotations.Test; @Listeners({ DatabaseSetupInterceptor.class }) public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
+ ResourceManagerLocal resourceManager; + AvailabilityManagerLocal availabilityManager; + AgentManagerLocal agentManager; + private static final int MILLIS_APART = 2000; + + @BeforeMethod + public void beforeMethod() { + try { + this.availabilityManager = LookupUtil.getAvailabilityManager(); + this.resourceManager = LookupUtil.getResourceManager(); + this.agentManager = LookupUtil.getAgentManager(); + } catch (Throwable t) { + // Catch RuntimeExceptions and Errors and dump their stack trace, because Surefire will completely swallow them + // and throw a cryptic NPE (see http://jira.codehaus.org/browse/SUREFIRE-157)! + t.printStackTrace(); + throw new RuntimeException(t); + } + } + @DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94") public void testOne() throws Exception { - startTiming();
- Thread.sleep(1234); + final int[] ROUNDS = {500,1000,1500,2000,2500,3000}; + + EntityManager em = getEntityManager(); + Query q = em.createQuery("SELECT r FROM Resource r"); + List<Resource> resources = q.getResultList(); + Resource res = resources.get(0); + Agent agent = agentManager.getAgentByResourceId(res.getId()); + + q = em.createQuery("SELECT COUNT(a) FROM Availability a "); + Object o = q.getSingleResult(); + Long l = (Long)o; + if (l!=0) { + throw new IllegalStateException("Availabilities table is not empty"); + } + + for ( int j = 0; j < ROUNDS.length; j++) { + int MULTI = ROUNDS[j]; + String round = "Round " + String.format("%6d",MULTI); + + long t1 = System.currentTimeMillis() - (MULTI * MILLIS_APART); + for ( int i = 0 ; i < MULTI ; i++ ) { + + AvailabilityReport report = new AvailabilityReport(agent.getName()); + for (Resource r : resources) { + AvailabilityType at = (i%2==0) ? AvailabilityType.UP : AvailabilityType.DOWN; + Availability a = new Availability(r,new Date(t1 + i * MILLIS_APART), at); + report.addAvailability(a); + } + startTiming(round); + availabilityManager.mergeAvailabilityReport(report); + endTiming(round); + } + }
- endTiming(); +
commitTimings();
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java index 05b3495..94a04f0 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java @@ -24,6 +24,8 @@ import org.apache.commons.logging.LogFactory; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet;
/** * Helper that introduces timing functionality on top of the Abstract EJB tests. @@ -79,6 +81,8 @@ public class AbstractEJB3PerformanceTest extends AbstractEJB3Test { Set<Map.Entry<String,Long>> data = timings.entrySet(); for (Map.Entry<String,Long> item : data) { log.info(":| " + item.getKey() + " => " + item.getValue()); + System.out.println(":| " + item.getKey() + " => " + item.getValue()); + } timings.clear(); startTime.clear();
commit 372335368eea236b1a1e3e25efc83fa6903543b5 Merge: c30cc1e... ff9f820... Author: Heiko W. Rupp hwr@redhat.com Date: Wed Sep 22 15:16:54 2010 +0200
Merge branch 'master' into perftest
Conflicts: modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
diff --cc modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java index 7347f1a,fdd5f6a..36c29c8 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java @@@ -28,15 -43,24 +28,14 @@@ import org.testng.annotations.Test * Performance test the availabilities subsystem * * @author Heiko W. Rupp + * @author Lukas Krejci */ -@Test(groups = "PERF", enabled = false) +@Test(groups = "PERF") +@Listeners({ DatabaseSetupInterceptor.class }) - //@JdbcConnectionProviderMethod("getConnection") //defined in AbstractEJB3Test public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
- private final Log log = LogFactory.getLog(AvailabilityInsertPurgeTest.class); - - /* - * we need to replace the ids in the csv files with the ids that we get back from the - * databse in relations. So store them as pair <csv-id,new entity-id> - */ - private Map<Integer,Integer> agentsTranslationTable = new HashMap<Integer,Integer>(); - private Map<Integer,Integer> pluginsTranslationTable = new HashMap<Integer,Integer>(); - private Map<Integer,Integer> resourceTypeTranslationTable = new HashMap<Integer,Integer>(); - - private Map<Integer,Integer> childParentTypeMap = new HashMap<Integer, Integer>(); - + @DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94") public void testOne() throws Exception { - setup(); startTiming();
Thread.sleep(1234);
commit ff9f820ba31283c57228c6a3357bc31f3f69b6d2 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 22 08:15:43 2010 -0400
add tooltip help
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java index a929a84..0e9fe8c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java @@ -157,6 +157,8 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements disableWhenFiredSelection.setValueMap(yesNo); disableWhenFiredSelection.setDefaultValue("no"); disableWhenFiredSelection.setWrapTitle(false); + disableWhenFiredSelection + .setTooltip("If this setting is turned on, then this alert will be disabled after it fires. When this occurs, the only way for the alert to be able to fire again is if a user manually re-enables the alert, or if a recovery alert triggers and automatically re-enables this alert. If this alert is a recovery alert itself, it cannot be disabled after it fires so it can always recover its target alert."); disableWhenFiredStatic = new StaticTextItem("disableWhenFiredStatic", "Disable When Fired"); disableWhenFiredStatic.setWrapTitle(false);
@@ -164,6 +166,8 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements recoverAlertSelection.setDefaultValue("0"); recoverAlertSelection.setWrapTitle(false); recoverAlertSelection.setRedrawOnChange(true); + recoverAlertSelection + .setTooltip("If this alert is a recovery alert, this option lets you select the target alert that will be re-enabled after this alert triggers. If this is not a recovery alert, do not select an alert here.");
recoverAlertStatic = new StaticTextItem("recoveryAlertStatic", "Recover Alert"); recoverAlertStatic.setDefaultValue(getNoRecoveryMenuItemTitle());
commit c40e42e59d96772ea2b953a47754db8f865d0cb9 Author: Ian Springer ian.springer@redhat.com Date: Wed Sep 22 00:36:38 2010 -0400
fix bug in usage of resource tree node IDs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java index 1b7e5b5..bc9c956 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java @@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/** * This doesn't extend RPCDataSource because it is tree-oriented and behaves differently than normal list data sources @@ -127,13 +128,13 @@ public class ResourceTreeDatasource extends DataSource { public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) { final long start = System.currentTimeMillis();
- String p = request.getCriteria().getAttribute("parentId"); + String parentResourceId = request.getCriteria().getAttribute("parentId"); // System.out.println("All attributes: " + Arrays.toString(request.getCriteria().getAttributes()));
ResourceCriteria criteria = new ResourceCriteria();
- if (p == null) { - System.out.println("DataSourceTree: Loading initial data"); + if (parentResourceId == null) { + System.out.println("ResourceTreeDatasource: Loading initial data...");
// criteria.addFilterId(rootId);
@@ -142,9 +143,9 @@ public class ResourceTreeDatasource extends DataSource { return;
} else { - System.out.println("DataSourceTree: Loading " + p); + System.out.println("ResourceTreeDatasource: Loading Resource [" + parentResourceId + "]...");
- criteria.addFilterParentResourceId(Integer.parseInt(p)); + criteria.addFilterParentResourceId(Integer.parseInt(parentResourceId)); }
// The server is already eager fetch resource type @@ -186,14 +187,14 @@ public class ResourceTreeDatasource extends DataSource { * @return */ public static TreeNode[] buildNodes(List<Resource> resources) { - ResourceTreeNode[] records = new ResourceTreeNode[resources.size()]; - for (int x = 0; x < resources.size(); x++) { - Resource resource = resources.get(x); - ResourceTreeNode record = new ResourceTreeNode(resource); - records[x] = record; + ResourceTreeNode[] nodes = new ResourceTreeNode[resources.size()]; + for (int i = 0; i < resources.size(); i++) { + Resource resource = resources.get(i); + ResourceTreeNode node = new ResourceTreeNode(resource); + nodes[i] = node; }
- return introduceTypeAndCategoryNodes(records); + return introduceTypeAndCategoryNodes(nodes); }
private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[] nodes) { @@ -274,7 +275,7 @@ public class ResourceTreeDatasource extends DataSource { // setAttribute("parentKey", parentId);
ResourceType type = resource.getResourceType(); - String name = pluralize(type.getName()); + String name = StringUtility.pluralize(type.getName()); setName(name); setAttribute("name", name); } @@ -335,7 +336,7 @@ public class ResourceTreeDatasource extends DataSource { }
public Resource getResource() { - return resource; + return this.resource; }
public static String idOf(Resource resource) { @@ -343,19 +344,7 @@ public class ResourceTreeDatasource extends DataSource { }
public static String idOf(int resourceId) { - return "resource" + resourceId; + return String.valueOf(resourceId); } } - - private static String pluralize(String singularNoun) { - // TODO: Make this smarter. - String pluralNoun; - if (singularNoun.endsWith("y") && !singularNoun.endsWith("ay") && !singularNoun.endsWith("ey") && - !singularNoun.endsWith("oy")) { - pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies"; - } else { - pluralNoun = singularNoun + "s"; - } - return pluralNoun; - } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java new file mode 100644 index 0000000..00a2cf1 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java @@ -0,0 +1,41 @@ +/* + * RHQ Management Platform + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.util; + +/** + * A collection of utility methods for working with Strings. + * + * @author Ian Springer + */ +public class StringUtility { + public static String pluralize(String singularNoun) { + String pluralNoun; + if (singularNoun.endsWith("y") && !singularNoun.endsWith("ay") && !singularNoun.endsWith("ey") && + !singularNoun.endsWith("oy")) { + pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies"; + } else { + pluralNoun = singularNoun + "s"; + } + return pluralNoun; + } + + private StringUtility() { + } +}
commit 2791d339c9959921882881afe23764961e0d8135 Author: Joseph Marques joseph@redhat.com Date: Wed Sep 22 00:33:39 2010 -0400
enforce consistency of GroupDefinitions by controlling the merge explicitly
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java index 905688b..ca04351 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java @@ -210,11 +210,15 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal { } }
- try { - return entityManager.merge(groupDefinition); - } catch (Exception e) { - throw new GroupDefinitionUpdateException(e); - } + // do not call entityManager.merge, it could overwrite managed fields + // merge fields explicitly to control precisely which fields get updated + attachedGroupDefinition.setName(groupDefinition.getName()); + attachedGroupDefinition.setDescription(groupDefinition.getDescription()); + attachedGroupDefinition.setRecursive(groupDefinition.isRecursive()); + attachedGroupDefinition.setExpression(groupDefinition.getExpression()); + attachedGroupDefinition.setRecalculationInterval(groupDefinition.getRecalculationInterval()); + + return attachedGroupDefinition; }
// return boolean indicating whether the name of this group definition is changing
commit ba09ae501b545b2a6452290584e7d5a9ea81b6ff Author: Joseph Marques joseph@redhat.com Date: Tue Sep 21 23:31:14 2010 -0400
fix master/details impl to allow detailsView navigation from /0 to /<id>
basically, since the detailsView is already showing when navigating from /0 to /<id>, the animationHide event was being suppressed, which meant that the subsequent callback wasn't invoked. this left the original detailsView canvas attached to the detailsHolder, instead of refreshing the holder with the latest view returned from the renderView method.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java index 0e3a899..c8ab12b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java @@ -187,7 +187,6 @@ public abstract class TableSection extends Table implements BookmarkableView {
@Override public void renderView(ViewPath viewPath) { - basePath = viewPath.getPathToCurrent();
if (!viewPath.isEnd()) { @@ -224,20 +223,42 @@ public abstract class TableSection extends Table implements BookmarkableView { protected void switchToDetailsView() { Canvas contents = getTableContents(); if (contents != null) { - contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() { - @Override - public void execute(boolean b) { - detailsView.setWidth100(); - detailsView.setHeight100(); - - detailsHolder.addMember(new BackButton(extendLocatorId("BackButton"), "Back to List", basePath)); - detailsHolder.addMember(detailsView); - detailsHolder.animateShow(AnimationEffect.WIPE); + if (contents.isVisible()) { + contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() { + @Override + public void execute(boolean b) { + buildDetailsView(); + } + }); + } else { + /* + * if the programmer chooses to go directly from the detailView in create-mode to the + * detailsView in edit-mode, the content canvas will already be hidden, which means the + * animateHide would be a no-op (the event won't fire). this causes the detailsHolder + * to keep a reference to the previous detailsView (the one in create-mode) instead of the + * newly returned reference from getDetailsView(int) that was called when the renderView + * methods were called hierarchically down to render the new detailsView in edit-mode. + * therefore, we need to explicitly destroy what's already there (presumably the detailsView + * in create-mode), and then rebuild it (presumably the detailsView in edit-mode). + */ + for (Canvas child : detailsHolder.getMembers()) { + child.destroy(); } - }); + + buildDetailsView(); + } } }
+ private void buildDetailsView() { + detailsView.setWidth100(); + detailsView.setHeight100(); + + detailsHolder.addMember(new BackButton(extendLocatorId("BackButton"), "Back to List", basePath)); + detailsHolder.addMember(detailsView); + detailsHolder.animateShow(AnimationEffect.WIPE); + } + /** * Switches to viewing the table, hiding the details canvas. */
commit 2b9ec8f1ab6be2fb2a9437b51f89eb19219c849e Author: Joseph Marques joseph@redhat.com Date: Tue Sep 21 23:27:03 2010 -0400
remove debugging statements
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java index 9b17abf..c8293c7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java @@ -141,8 +141,7 @@ public class GroupDefinitionListView extends TableSection { @Override public Canvas getDetailsView(int id) { final SingleGroupDefinitionView singleGroupDefinitionView = new SingleGroupDefinitionView(this - .extendLocatorId("Empty")); + .extendLocatorId("Details")); return singleGroupDefinitionView; } - } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index d6ac260..dde421c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -31,6 +31,8 @@ import com.smartgwt.client.data.Record; import com.smartgwt.client.types.DSOperationType; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.IButton; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.fields.CheckboxItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.SpinnerItem; @@ -65,7 +67,6 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm private int groupDefinitionId; private GroupDefinition groupDefinition; private String basePath; - private ViewId viewId;
// editable form @@ -85,29 +86,18 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm private StaticTextItem expressionStatic; private StaticTextItem recalculationIntervalStatic;
- private GroupDefinitionDataSource dataSource; - public SingleGroupDefinitionView(String locatorId) { - this(locatorId, null); - } - - public SingleGroupDefinitionView(String locatorId, GroupDefinition groupDefinition) { super(locatorId);
- this.dataSource = GroupDefinitionDataSource.getInstance(); - setPadding(10); setOverflow(Overflow.VISIBLE); setWidth(5);
buildForm(); - - this.groupDefinition = groupDefinition; }
public void setGroupDefinition(final GroupDefinition groupDefinition) { this.groupDefinition = groupDefinition; - System.out.println("setGroupDefinition(" + groupDefinition + ")");
// form setup id.setValue(groupDefinition.getId()); @@ -131,50 +121,39 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("GroupDefinitionForm")); form.setFields(id, idStatic, name, nameStatic, description, descriptionStatic, expression, expressionStatic, recursive, recursiveStatic, recalculationInterval, recalculationIntervalStatic); - form.setDataSource(dataSource); + form.setDataSource(GroupDefinitionDataSource.getInstance()); form.setHiliteRequiredFields(true); form.setRequiredTitleSuffix(" <span style="color: red;">* </span>:"); - final DSOperationType operationType; if (groupDefinition.getId() == 0) { - System.out.println("setting form operation: ADD"); form.setSaveOperationType(DSOperationType.ADD); - operationType = DSOperationType.ADD; } else { - System.out.println("setting form operation: UPDATE"); form.setSaveOperationType(DSOperationType.UPDATE); - operationType = DSOperationType.UPDATE; } - System.out.println("form operation default is " + form.getSaveOperationType());
final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"), groupDefinitionId);
// button setup IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); - saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { - public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { - System.out.println("cached operaton type is " + operationType); - form.setSaveOperationType(operationType); - System.out.println("form operation before validation is " + form.getSaveOperationType()); + //saveButton.addClickHandler(new SaveOrUpdateClickHandler(form, operationType, dynaGroupChildrenView)); + saveButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { if (form.validate()) { - System.out.println("form operation after validation is " + form.getSaveOperationType()); form.saveData(new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { - if (groupDefinition.getId() == 0) { - System.out.println("just created new group def"); + if (form.isNewRecord()) { Record[] results = response.getData(); if (results.length != 1) { CoreGUI.getErrorHandler().handleError( "Error: " + results.length + " created instead of one"); } else { Record newRecord = results[0]; - GroupDefinition newGroupDefinition = dataSource + GroupDefinition newGroupDefinition = GroupDefinitionDataSource.getInstance() .copyValues((ListGridRecord) newRecord); History.newItem(basePath + "/" + newGroupDefinition.getId()); } } else { - System.out.println("just edited existing group def"); dynaGroupChildrenView.refresh(); } } @@ -185,8 +164,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
IButton recalculateButton = new LocatableIButton(this.extendLocatorId("Recalculate"), "Save & Recalculate"); recalculateButton.setWidth(150); - recalculateButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { - public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + recalculateButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { if (form.validate()) { form.saveData(new DSCallback() { @Override @@ -214,8 +193,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm });
IButton resetButton = new LocatableIButton(this.extendLocatorId("Reset"), "Reset"); - resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { - public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + resetButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { form.reset(); } }); @@ -239,6 +218,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm super(locatorId, "DynaGroup Children", new Criteria("groupDefinitionId", String.valueOf(groupDefinition .getId()))); setDataSource(ResourceGroupsDataSource.getInstance()); + setMinHeight(250); } }
@@ -285,7 +265,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private void buildForm() { id = new TextItem("id", "ID"); - //id.setVisible(false); + id.setVisible(false); idStatic = new StaticTextItem("idStatic", "ID"); idStatic.setVisible(false);
commit be2e9d2f22804f857e660692c138337f14bfef66 Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 21 20:40:44 2010 -0400
fix so subcategory nodes for subcategories that have parent subcategories and rendered as child nodes of the parent subcategory nodes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java index 5edd16d..38dc487 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java @@ -166,8 +166,9 @@ public class NewResourceTreeView extends LocatableVLayout { }
private void showContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) { + ResourceType type = node.getResource().getResourceType(); ResourceTypeRepository.Cache.getInstance().getResourceTypes( - node.getResourceType().getId(), + type.getId(), EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.subCategory, ResourceTypeRepository.MetadataType.pluginConfigurationDefinition, diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java index 2516ac5..1b7e5b5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java @@ -188,8 +188,8 @@ public class ResourceTreeDatasource extends DataSource { public static TreeNode[] buildNodes(List<Resource> resources) { ResourceTreeNode[] records = new ResourceTreeNode[resources.size()]; for (int x = 0; x < resources.size(); x++) { - Resource res = resources.get(x); - ResourceTreeNode record = new ResourceTreeNode(res); + Resource resource = resources.get(x); + ResourceTreeNode record = new ResourceTreeNode(resource); records[x] = record; }
@@ -198,42 +198,33 @@ public class ResourceTreeDatasource extends DataSource {
private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[] nodes) { List<TreeNode> updatedNodes = new ArrayList<TreeNode>(); - Map<Integer, CategoryTreeNode> categories = new HashMap<Integer, CategoryTreeNode>(); + // Maps category node IDs to the corresponding category nodes. + Map<String, CategoryTreeNode> categories = new HashMap<String, CategoryTreeNode>(); + // Maps Resource types to the corresponding type nodes. Map<ResourceType, TypeTreeNode> types = new HashMap<ResourceType, TypeTreeNode>();
for (ResourceTreeNode node : nodes) { updatedNodes.add(node);
- ResourceType type = node.getResourceType(); + Resource resource = node.getResource(); + ResourceType type = resource.getResourceType(); if (type.getCategory() != ResourceCategory.PLATFORM) { if (!types.containsKey(type)) { - - String parentResourceId = String.valueOf(node.getResource().getParentResource().getId()); - - CategoryTreeNode categoryNode = null; - if (type.getSubCategory() != null) { - ResourceSubCategory category = type.getSubCategory(); - if (category.getName() != null) { - categoryNode = categories.get(category.getId()); + Resource parentResource = resource.getParentResource(); + ResourceSubCategory category = type.getSubCategory(); + if (category != null) { + do { + String categoryNodeId = CategoryTreeNode.idOf(category, parentResource); + CategoryTreeNode categoryNode = categories.get(categoryNodeId); if (categoryNode == null) { - // TODO (ips): Handle connecting child subcat nodes to their parent subcats. - /*ResourceSubCategory parentCategory = category.getParentSubCategory(); - while (parentCategory != null) { - Resource parentType = parentCategory.findParentResourceType(); - if (parentCategory.findTaggedResourceTypes().isEmpty()) { - CategoryTreeNode parentCategoryNode = - new CategoryTreeNode(parentResourceId, parentCategory); - } - }*/ - categoryNode = new CategoryTreeNode(parentResourceId, category); - categories.put(category.getId(), categoryNode); + categoryNode = new CategoryTreeNode(category, parentResource); + categories.put(categoryNode.getID(), categoryNode); updatedNodes.add(categoryNode); } - } + } while ((category = category.getParentSubCategory()) != null); }
- String parentId = (categoryNode != null) ? categoryNode.getID() : parentResourceId; - TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId, type); + TypeTreeNode typeNode = new TypeTreeNode(resource); updatedNodes.add(typeNode); types.put(type, typeNode); } @@ -243,78 +234,65 @@ public class ResourceTreeDatasource extends DataSource { return updatedNodes.toArray(new TreeNode[updatedNodes.size()]); }
- private static boolean sameTypes(ResourceTreeNode[] nodes) { - ResourceType first = nodes[0].getResourceType(); - for (ResourceTreeNode node : nodes) { - if (!first.equals(node)) { - return false; - } - } - return true; - } - public static class CategoryTreeNode extends EnhancedTreeNode { - public CategoryTreeNode(String parentResourceId, ResourceSubCategory category) { - String id = parentResourceId + "__" + fixId(category.getName()); + public CategoryTreeNode(ResourceSubCategory category, Resource parentResource) { + String id = idOf(category, parentResource); setID(id); setAttribute("id", id);
- setParentID(parentResourceId); - setAttribute("parentId", parentResourceId); + ResourceSubCategory parentCategory = category.getParentSubCategory(); + String parentId = (parentCategory != null) ? + CategoryTreeNode.idOf(parentCategory, parentResource) : + ResourceTreeNode.idOf(parentResource); + setParentID(parentId); + setAttribute("parentId", parentId);
// Note, subcategory names are typically already plural, so there's no need to pluralize them. String name = category.getDisplayName(); setName(name); setAttribute("name", name); } + + public static String idOf(ResourceSubCategory category, Resource parentResource) { + return "subcat" + category.getId() + "_" + parentResource.getId(); + } }
+ /** + * The Resource type folder node for an autogroup. + */ public static class TypeTreeNode extends EnhancedTreeNode { - private TypeTreeNode(String parentId, String parentResourceId, ResourceType type) { - String id = parentResourceId + "_" + type.getId(); + private TypeTreeNode(Resource resource) { + String id = idOf(resource); setID(id); setAttribute("id", id);
- if (parentId == null) { - try { - throw new IllegalStateException("**************** WARNING: parent ID is null for type " + type); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - } + String parentId = parentIdOf(resource); setParentID(parentId); setAttribute("parentId", parentId);
// setAttribute("parentKey", parentId);
+ ResourceType type = resource.getResourceType(); String name = pluralize(type.getName()); setName(name); setAttribute("name", name); }
- @Override - public void setParentID(String parentID) { - if (parentID == null) { - try { - throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName()); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - } - super.setParentID(parentID); + public static String idOf(Resource resource) { + Resource parentResource = resource.getParentResource(); + return (parentResource != null) ? "type" + resource.getResourceType().getId() + "_" + + parentResource.getId() : null; }
- @Override - public void setAttribute(String property, String value) { - if (property.equals("parentId") && value == null) { - try { - throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName()); - } catch (IllegalStateException e) { - e.printStackTrace(); - } - } - super.setAttribute(property, value); - } + public static String parentIdOf(Resource resource) { + ResourceType type = resource.getResourceType(); + ResourceSubCategory parentCategory = type.getSubCategory(); + String parentId = (parentCategory != null) ? + CategoryTreeNode.idOf(parentCategory, resource.getParentResource()) : + ResourceTreeNode.idOf(resource.getParentResource()); + return parentId; + } }
public static class ResourceTreeNode extends EnhancedTreeNode { @@ -323,12 +301,20 @@ public class ResourceTreeDatasource extends DataSource { private ResourceTreeNode(Resource resource) { this.resource = resource;
- String id = String.valueOf(resource.getId()); + String id = idOf(resource); setID(id); setAttribute("id", id);
- String parentId = (resource.getParentResource() != null) ? - (resource.getParentResource().getId() + "_" + resource.getResourceType().getId()) : null; + Resource parentResource = resource.getParentResource(); + String parentId; + if (parentResource != null) { + parentId = resource.getResourceType().isSingleton() ? + TypeTreeNode.parentIdOf(resource) : + TypeTreeNode.idOf(resource); + } + else { + parentId = null; + } setParentID(parentId); setAttribute("parentId", parentId);
@@ -352,13 +338,13 @@ public class ResourceTreeDatasource extends DataSource { return resource; }
- public ResourceType getResourceType() { - return resource.getResourceType(); + public static String idOf(Resource resource) { + return idOf(resource.getId()); } - }
- private static String fixId(String id) { - return id.replace(' ', '_'); + public static String idOf(int resourceId) { + return "resource" + resourceId; + } }
private static String pluralize(String singularNoun) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java index 02afc80..418a334 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java @@ -172,7 +172,7 @@ public class ResourceTreeView extends LocatableVLayout {
private void updateBreadcrumbs() { - TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId)); + TreeNode selectedNode = treeGrid.getTree().findById(ResourceTreeDatasource.ResourceTreeNode.idOf(selectedResourceId)); // System.out.println("Trying to preopen: " + selectedNode); if (selectedNode != null) { TreeNode[] parents = treeGrid.getTree().getParents(selectedNode); @@ -204,8 +204,9 @@ public class ResourceTreeView extends LocatableVLayout { }
private void showContextMenu(final ResourceTreeDatasource.ResourceTreeNode node) { + ResourceType type = node.getResource().getResourceType(); ResourceTypeRepository.Cache.getInstance().getResourceTypes( - node.getResourceType().getId(), + type.getId(), EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.subCategory, ResourceTypeRepository.MetadataType.pluginConfigurationDefinition, @@ -433,7 +434,7 @@ public class ResourceTreeView extends LocatableVLayout { Resource getResource(int resourceId) { if (this.treeGrid != null && this.treeGrid.getTree() != null) { ResourceTreeDatasource.ResourceTreeNode treeNode = (ResourceTreeDatasource.ResourceTreeNode) this.treeGrid - .getTree().findById(String.valueOf(resourceId)); + .getTree().findById(ResourceTreeDatasource.ResourceTreeNode.idOf(resourceId)); if (treeNode != null) { return treeNode.getResource(); } @@ -449,8 +450,9 @@ public class ResourceTreeView extends LocatableVLayout { this.selectedResourceId = selectedResourceId;
TreeNode node; + final String resourceNodeId = ResourceTreeDatasource.ResourceTreeNode.idOf(selectedResourceId); if (treeGrid != null && treeGrid.getTree() != null - && (node = treeGrid.getTree().findById(String.valueOf(selectedResourceId))) != null) { + && (node = treeGrid.getTree().findById(resourceNodeId)) != null) {
// This is the case where the tree was previously loaded and we get fired to look at a different // node in the same tree and just have to switch the selection @@ -459,7 +461,7 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.getTree().openFolders(parents); treeGrid.getTree().openFolder(node);
- if (!treeGrid.getSelectedRecord().equals(node)) { + if (!node.equals(treeGrid.getSelectedRecord())) { treeGrid.deselectAllRecords(); treeGrid.selectRecord(node); } @@ -507,7 +509,8 @@ public class ResourceTreeView extends LocatableVLayout {
TreeUtility.printTree(treeGrid.getTree());
- TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId)); + TreeNode selectedNode = + treeGrid.getTree().findById(resourceNodeId); // System.out.println("Trying to preopen: " + selectedNode); if (selectedNode != null) { // System.out.println("Preopen node!!!"); @@ -541,8 +544,7 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.getTree().linkNodes(ResourceTreeDatasource.buildNodes(result));
- TreeNode selectedNode = treeGrid.getTree().findById( - String.valueOf(selectedResourceId)); + TreeNode selectedNode = treeGrid.getTree().findById(resourceNodeId); if (selectedNode != null) { treeGrid.deselectAllRecords(); treeGrid.selectRecord(selectedNode); @@ -564,7 +566,7 @@ public class ResourceTreeView extends LocatableVLayout {
} else { CoreGUI.getMessageCenter().notify( - new Message("Failed to select resource [" + selectedResourceId + new Message("Failed to select Resource [" + selectedResourceId + "] in tree.", Message.Severity.Warning)); }
@@ -573,7 +575,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
- TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId)); + TreeNode selectedNode = treeGrid.getTree().findById(resourceNodeId); // System.out.println("Trying to preopen: " + selectedNode); if (selectedNode != null) { TreeNode[] parents = treeGrid.getTree().getParents(selectedNode);
commit ed4c35f7a4e2f68ebc52eac47912ef7c4f8ebca0 Author: Joseph Marques joseph@redhat.com Date: Tue Sep 21 17:08:29 2010 -0400
add some debugging statements
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index 01dceca..d6ac260 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -105,7 +105,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm this.groupDefinition = groupDefinition; }
- public void setGroupDefinition(GroupDefinition groupDefinition) { + public void setGroupDefinition(final GroupDefinition groupDefinition) { this.groupDefinition = groupDefinition; System.out.println("setGroupDefinition(" + groupDefinition + ")");
@@ -134,6 +134,17 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm form.setDataSource(dataSource); form.setHiliteRequiredFields(true); form.setRequiredTitleSuffix(" <span style="color: red;">* </span>:"); + final DSOperationType operationType; + if (groupDefinition.getId() == 0) { + System.out.println("setting form operation: ADD"); + form.setSaveOperationType(DSOperationType.ADD); + operationType = DSOperationType.ADD; + } else { + System.out.println("setting form operation: UPDATE"); + form.setSaveOperationType(DSOperationType.UPDATE); + operationType = DSOperationType.UPDATE; + } + System.out.println("form operation default is " + form.getSaveOperationType());
final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"), groupDefinitionId); @@ -142,19 +153,16 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + System.out.println("cached operaton type is " + operationType); + form.setSaveOperationType(operationType); + System.out.println("form operation before validation is " + form.getSaveOperationType()); if (form.validate()) { - if (groupDefinitionId == 0) { - System.out.println("setting form operation: ADD"); - form.setSaveOperationType(DSOperationType.ADD); - } else { - System.out.println("setting form operation: UPDATE"); - form.setSaveOperationType(DSOperationType.UPDATE); - } - System.out.println("form operation type is " + form.getSaveOperationType()); + System.out.println("form operation after validation is " + form.getSaveOperationType()); form.saveData(new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { - if (SingleGroupDefinitionView.this.groupDefinitionId == 0) { + if (groupDefinition.getId() == 0) { + System.out.println("just created new group def"); Record[] results = response.getData(); if (results.length != 1) { CoreGUI.getErrorHandler().handleError( @@ -166,6 +174,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm History.newItem(basePath + "/" + newGroupDefinition.getId()); } } else { + System.out.println("just edited existing group def"); dynaGroupChildrenView.refresh(); } }
commit 944ccfa1d927d00b9ca253a3f47dbdf792684592 Author: John Mazzitelli mazz@redhat.com Date: Tue Sep 21 16:54:00 2010 -0400
finished the "recovery editor" portion of the alert definition editor. you can now set recovery alerts and disable-on-fire flag
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java index 8f8c5c3..bf38e6b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java @@ -136,4 +136,10 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A }
protected abstract AlertDefinitionCriteria getCriteria(DSRequest request); + + /** + * Returns a criteria that will query for all alerts, but only for the ID and name fields. + * @return criteria for an inexpensive query to obtain all alert defs + */ + protected abstract AlertDefinitionCriteria getSimpleCriteriaForAll(); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java index fe1e2e2..12e27d9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java @@ -99,10 +99,10 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i prioritySelection.setValue(alertDef.getPriority().name()); priorityStatic.setValue(alertDef.getPriority().name());
- enabledSelection.setValue(alertDef.getEnabled() ? "Yes" : "No"); + enabledSelection.setValue(alertDef.getEnabled() ? "yes" : "no"); enabledStatic.setValue(alertDef.getEnabled() ? "Yes" : "No");
- readOnlySelection.setValue(alertDef.isReadOnly() ? "Yes" : "No"); + readOnlySelection.setValue(alertDef.isReadOnly() ? "yes" : "no"); readOnlyStatic.setValue(alertDef.isReadOnly() ? "Yes" : "No"); }
@@ -181,8 +181,8 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i String prioritySelected = prioritySelection.getValue().toString(); alertDefinition.setPriority(AlertPriority.valueOf(prioritySelected));
- alertDefinition.setEnabled("Yes".equals(enabledSelection.getValue())); - alertDefinition.setReadOnly("Yes".equals(readOnlySelection.getValue())); + alertDefinition.setEnabled("yes".equals(enabledSelection.getValue())); + alertDefinition.setReadOnly("yes".equals(readOnlySelection.getValue())); }
@Override @@ -230,13 +230,19 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i priorityStatic.setValueIcons(priorityIcons);
enabledSelection = new RadioGroupItem("enabled", "Enabled"); - enabledSelection.setValueMap("Yes", "No"); - enabledSelection.setDefaultValue("Yes"); + LinkedHashMap<String, String> enabledYesNo = new LinkedHashMap<String, String>(2); + enabledYesNo.put("yes", "Yes"); + enabledYesNo.put("no", "No"); + enabledSelection.setValueMap(enabledYesNo); + enabledSelection.setDefaultValue("yes"); enabledStatic = new StaticTextItem("enabledStatic", "Enabled");
readOnlySelection = new RadioGroupItem("readOnly", "Protected"); - readOnlySelection.setValueMap("Yes", "No"); - readOnlySelection.setDefaultValue("Yes"); + LinkedHashMap<String, String> readOnlyYesNo = new LinkedHashMap<String, String>(2); + readOnlyYesNo.put("yes", "Yes"); + readOnlyYesNo.put("no", "No"); + readOnlySelection.setValueMap(readOnlyYesNo); + readOnlySelection.setDefaultValue("yes"); readOnlySelection .setPrompt("If true, this definition is protected from being changed by the parent definition. In other words, the parent definition settings will not override this definition."); readOnlyStatic = new StaticTextItem("readOnlyStatic", "Protected"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java index 90f9490..bb2cc71 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java @@ -29,12 +29,21 @@ import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DSRequest;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria; +import org.rhq.core.domain.resource.group.ResourceGroup; +import org.rhq.core.domain.util.PageControl;
/** * @author John Mazzitelli */ public class GroupAlertDefinitionsDataSource extends AbstractAlertDefinitionsDataSource {
+ private ResourceGroup resourceGroup; + + public GroupAlertDefinitionsDataSource(ResourceGroup group) { + super(); + this.resourceGroup = group; + } + @Override protected AlertDefinitionCriteria getCriteria(DSRequest request) { AlertDefinitionCriteria criteria = new AlertDefinitionCriteria(); @@ -54,4 +63,12 @@ public class GroupAlertDefinitionsDataSource extends AbstractAlertDefinitionsDat criteria.setPageControl(getPageControl(request)); return criteria; } + + @Override + protected AlertDefinitionCriteria getSimpleCriteriaForAll() { + AlertDefinitionCriteria criteria = new AlertDefinitionCriteria(); + criteria.addFilterResourceGroupIds(Integer.valueOf(this.resourceGroup.getId())); + criteria.setPageControl(PageControl.getUnlimitedInstance()); + return criteria; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java index 4775ee4..183faec 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java @@ -82,7 +82,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override protected AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource() { - return new GroupAlertDefinitionsDataSource(); + return new GroupAlertDefinitionsDataSource(group); }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java index ab64324..a929a84 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java @@ -23,10 +23,21 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList; +import java.util.LinkedHashMap; + +import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.form.fields.RadioGroupItem; import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import org.rhq.core.domain.alert.AlertDefinition; +import org.rhq.core.domain.criteria.AlertDefinitionCriteria; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** @@ -35,18 +46,25 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements EditAlertDefinitionForm {
private AlertDefinition alertDefinition; + private AbstractAlertDefinitionsDataSource alertDataSource; + private ArrayList<AlertDefinition> allAlertDefinitions;
private SelectItem recoverAlertSelection; + private StaticTextItem recoverAlertStatic; + private RadioGroupItem disableWhenFiredSelection; + private StaticTextItem disableWhenFiredStatic;
private boolean formBuilt = false;
- public RecoveryAlertDefinitionForm(String locatorId) { - this(locatorId, null); + public RecoveryAlertDefinitionForm(String locatorId, AbstractAlertDefinitionsDataSource dataSource) { + this(locatorId, dataSource, null); }
- public RecoveryAlertDefinitionForm(String locatorId, AlertDefinition alertDefinition) { + public RecoveryAlertDefinitionForm(String locatorId, AbstractAlertDefinitionsDataSource dataSource, + AlertDefinition alertDefinition) { super(locatorId); + this.alertDataSource = dataSource; this.alertDefinition = alertDefinition; }
@@ -55,7 +73,6 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements super.onInit();
if (!formBuilt) { - buildForm(); setAlertDefinition(alertDefinition); makeViewOnly(); } @@ -75,7 +92,10 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements if (alertDef == null) { clearFormValues(); } else { - disableWhenFiredSelection.setValue(alertDef.getWillRecover() ? "Yes" : "No"); + refreshWidgets(allAlertDefinitions); + + disableWhenFiredSelection.setValue(alertDef.getWillRecover() ? "yes" : "no"); + disableWhenFiredStatic.setValue(alertDef.getWillRecover() ? "Yes" : "No"); }
markForRedraw(); @@ -83,21 +103,38 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
@Override public void makeEditable() { - // TODO Auto-generated method stub + recoverAlertSelection.show(); + disableWhenFiredSelection.show(); + + recoverAlertStatic.hide(); + disableWhenFiredStatic.hide();
markForRedraw(); }
@Override public void makeViewOnly() { - // TODO Auto-generated method stub + recoverAlertSelection.hide(); + disableWhenFiredSelection.hide(); + + recoverAlertStatic.show(); + disableWhenFiredStatic.show();
markForRedraw(); }
@Override public void saveAlertDefinition() { - // TODO Auto-generated method stub + // this silliness is to workaround the validation that AlertDefinition setters try to do + alertDefinition.setRecoveryId(0); + alertDefinition.setWillRecover(false); + + alertDefinition.setRecoveryId(Integer.valueOf(recoverAlertSelection.getValue().toString())); + if (alertDefinition.getRecoveryId() != 0) { + alertDefinition.setWillRecover(false); + } else { + alertDefinition.setWillRecover("yes".equals(disableWhenFiredSelection.getValue())); + } }
@Override @@ -105,23 +142,133 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements recoverAlertSelection.clearValue(); disableWhenFiredSelection.clearValue();
+ recoverAlertStatic.clearValue(); + disableWhenFiredStatic.clearValue(); + markForRedraw(); }
private void buildForm() { if (!formBuilt) { + disableWhenFiredSelection = new RadioGroupItem("disableWhenFired", "Disable When Fired"); + LinkedHashMap<String, String> yesNo = new LinkedHashMap<String, String>(2); + yesNo.put("yes", "Yes"); + yesNo.put("no", "No"); + disableWhenFiredSelection.setValueMap(yesNo); + disableWhenFiredSelection.setDefaultValue("no"); + disableWhenFiredSelection.setWrapTitle(false); + disableWhenFiredStatic = new StaticTextItem("disableWhenFiredStatic", "Disable When Fired"); + disableWhenFiredStatic.setWrapTitle(false); + recoverAlertSelection = new SelectItem("recoveryAlert", "Recover Alert"); - recoverAlertSelection.setValueMap("Select..."); - recoverAlertSelection.setDefaultValue("Select..."); - // TODO: call into server and get the menu list of all alerts that we can recover + recoverAlertSelection.setDefaultValue("0"); + recoverAlertSelection.setWrapTitle(false); + recoverAlertSelection.setRedrawOnChange(true);
- disableWhenFiredSelection = new RadioGroupItem("disableWhenFired", "Disable When Fired"); - disableWhenFiredSelection.setValueMap("Yes", "No"); - disableWhenFiredSelection.setDefaultValue("Yes"); + recoverAlertStatic = new StaticTextItem("recoveryAlertStatic", "Recover Alert"); + recoverAlertStatic.setDefaultValue(getNoRecoveryMenuItemTitle()); + recoverAlertStatic.setWrapTitle(false); + + // if a recovery alert is set, then this alert definition must not disable itself when fired + // because it will be needed to recover its recovery alert the next time it fires. disabling is only + // for non-recoverable alerts or for alerts that will themselves be recovered. + // therefore, force the disableWhenFired selection to go to no and do not allow it to be changed when appropriate + recoverAlertSelection.addChangedHandler(new ChangedHandler() { + @Override + public void onChanged(ChangedEvent event) { + String recoveryAlertDefId = event.getItem().getValue().toString(); + refreshDisableWhenFiredSelection(recoveryAlertDefId); + } + }); + + refreshWidgets(null); // for it to at least show the initial "no-op" entry + loadAllAlertDefinitionsAndRefreshRecoverAlertSelection(); // this gets the real entries asynchronously
- setFields(recoverAlertSelection, disableWhenFiredSelection); + setFields(recoverAlertSelection, recoverAlertStatic, disableWhenFiredSelection, disableWhenFiredStatic);
formBuilt = true; } } + + private AlertDefinition lookupAlertDefinition(Integer id) { + if (id != null && id.intValue() != 0) { + if (this.allAlertDefinitions != null) { + for (AlertDefinition def : this.allAlertDefinitions) { + if (def.getId() == id.intValue()) { + return def; + } + } + } + } + + return null; + } + + private void loadAllAlertDefinitionsAndRefreshRecoverAlertSelection() { + if (allAlertDefinitions == null) { + AlertDefinitionCriteria criteria = alertDataSource.getSimpleCriteriaForAll(); + GWTServiceLookup.getAlertService().findAlertDefinitionsByCriteria(criteria, + new AsyncCallback<PageList<AlertDefinition>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Cannot build recovery menu", caught); + } + + public void onSuccess(PageList<AlertDefinition> result) { + allAlertDefinitions = result; + refreshWidgets(allAlertDefinitions); + } + }); + } else { + // we already got the values before, just refresh the menu (in case this.alertDef changed) + refreshWidgets(allAlertDefinitions); + } + } + + private void refreshWidgets(ArrayList<AlertDefinition> allDefs) { + int allDefsSize = (allDefs != null) ? allDefs.size() : 0; + LinkedHashMap<String, String> alertMap = new LinkedHashMap<String, String>(allDefsSize + 1); + alertMap.put("0", getNoRecoveryMenuItemTitle()); + if (allDefs != null) { + for (AlertDefinition def : allDefs) { + if (alertDefinition == null || alertDefinition.getId() != def.getId()) { + alertMap.put(String.valueOf(def.getId()), def.getName()); + } + } + } + recoverAlertSelection.setValueMap(alertMap); + + if (alertDefinition != null) { + AlertDefinition recoveryAlert = lookupAlertDefinition(alertDefinition.getRecoveryId()); + if (recoveryAlert != null) { + String recoveryIdStr = String.valueOf(recoveryAlert.getId()); + recoverAlertSelection.setValue(recoveryIdStr); + recoverAlertStatic.setValue(recoveryAlert.getName()); + refreshDisableWhenFiredSelection(recoveryIdStr); + } else { + recoverAlertSelection.setValue("0"); + recoverAlertStatic.setValue(getNoRecoveryMenuItemTitle()); + refreshDisableWhenFiredSelection("0"); + } + } + + recoverAlertSelection.redraw(); + } + + private void refreshDisableWhenFiredSelection(String recoveryAlertDefId) { + if ("0".equals(recoveryAlertDefId)) { + disableWhenFiredSelection.setDisabled(false); + } else { + disableWhenFiredSelection.setValue("no"); + disableWhenFiredSelection.setDisabled(true); + } + disableWhenFiredSelection.redraw(); + } + + private String getNoRecoveryMenuItemTitle() { + StringBuilder str = new StringBuilder(); + str.append("-- "); + str.append("No Recovery"); + str.append(" --"); + return str.toString(); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java index dc04a1e..3bc7a3f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java @@ -34,6 +34,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.criteria.AlertDefinitionCriteria; import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.util.PageControl;
/** * @author John Mazzitelli @@ -115,4 +116,12 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions criteria.setPageControl(getPageControl(request)); return criteria; } + + @Override + protected AlertDefinitionCriteria getSimpleCriteriaForAll() { + AlertDefinitionCriteria criteria = new AlertDefinitionCriteria(); + criteria.addFilterResourceIds(Integer.valueOf(this.resource.getId())); + criteria.setPageControl(PageControl.getUnlimitedInstance()); + return criteria; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java index bc7a8b0..2e3caf0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java @@ -79,7 +79,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout { notificationsTab.setPane(notifications);
Tab recoveryTab = new LocatableTab(tabSet.extendLocatorId("Recovery"), "Recovery"); - recovery = new RecoveryAlertDefinitionForm(this.getLocatorId(), alertDefinition); + recovery = new RecoveryAlertDefinitionForm(this.getLocatorId(), alertDefView.getAlertDefinitionDataSource(), + alertDefinition); recoveryTab.setPane(recovery);
Tab dampeningTab = new LocatableTab(tabSet.extendLocatorId("Dampening"), "Dampening"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java index 9a96db8..15163f0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java @@ -29,12 +29,21 @@ import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DSRequest;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.util.PageControl;
/** * @author John Mazzitelli */ public class TemplateAlertDefinitionsDataSource extends AbstractAlertDefinitionsDataSource {
+ private ResourceType resourceType; + + public TemplateAlertDefinitionsDataSource(ResourceType rt) { + super(); + this.resourceType = rt; + } + @Override protected AlertDefinitionCriteria getCriteria(DSRequest request) { AlertDefinitionCriteria criteria = new AlertDefinitionCriteria(); @@ -54,4 +63,12 @@ public class TemplateAlertDefinitionsDataSource extends AbstractAlertDefinitions criteria.setPageControl(getPageControl(request)); return criteria; } + + @Override + protected AlertDefinitionCriteria getSimpleCriteriaForAll() { + AlertDefinitionCriteria criteria = new AlertDefinitionCriteria(); + criteria.addFilterAlertTemplateResourceTypeId(Integer.valueOf(this.resourceType.getId())); + criteria.setPageControl(PageControl.getUnlimitedInstance()); + return criteria; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java index 4366291..c26a8f9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java @@ -83,7 +83,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override protected AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource() { - return new TemplateAlertDefinitionsDataSource(); + return new TemplateAlertDefinitionsDataSource(resourceType); }
@Override
commit a67696bb08a8ab5c338a6be99de8c7e01ddd2866 Author: Joseph Marques joseph@redhat.com Date: Tue Sep 21 16:26:02 2010 -0400
go to edit mode after finished creating new group definition
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java index 49ea417..32692b1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java @@ -109,6 +109,7 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
@Override protected void executeAdd(final DSRequest request, final DSResponse response) { + System.out.println("executeAdd"); JavaScriptObject data = request.getData(); final ListGridRecord record = new ListGridRecord(data); final GroupDefinition newGroupDefinition = copyValues(record); @@ -136,6 +137,7 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
@Override protected void executeUpdate(final DSRequest request, final DSResponse response) { + System.out.println("executeUpdate"); final ListGridRecord record = getEditedRecord(request); final GroupDefinition updatedGroupDefinition = copyValues(record); final String name = updatedGroupDefinition.getName(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index f4ca2cf..01dceca 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DSCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.data.Record; import com.smartgwt.client.types.DSOperationType; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.IButton; @@ -36,6 +37,7 @@ import com.smartgwt.client.widgets.form.fields.SpinnerItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.form.fields.TextAreaItem; import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout;
import org.rhq.core.domain.authz.Permission; @@ -62,6 +64,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private int groupDefinitionId; private GroupDefinition groupDefinition; + private String basePath;
private ViewId viewId;
@@ -104,6 +107,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
public void setGroupDefinition(GroupDefinition groupDefinition) { this.groupDefinition = groupDefinition; + System.out.println("setGroupDefinition(" + groupDefinition + ")");
// form setup id.setValue(groupDefinition.getId()); @@ -130,11 +134,6 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm form.setDataSource(dataSource); form.setHiliteRequiredFields(true); form.setRequiredTitleSuffix(" <span style="color: red;">* </span>:"); - if (groupDefinition.getId() == 0) { - form.setSaveOperationType(DSOperationType.ADD); - } else { - form.setSaveOperationType(DSOperationType.UPDATE); - }
final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"), groupDefinitionId); @@ -144,10 +143,31 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { if (form.validate()) { + if (groupDefinitionId == 0) { + System.out.println("setting form operation: ADD"); + form.setSaveOperationType(DSOperationType.ADD); + } else { + System.out.println("setting form operation: UPDATE"); + form.setSaveOperationType(DSOperationType.UPDATE); + } + System.out.println("form operation type is " + form.getSaveOperationType()); form.saveData(new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { - dynaGroupChildrenView.refresh(); + if (SingleGroupDefinitionView.this.groupDefinitionId == 0) { + Record[] results = response.getData(); + if (results.length != 1) { + CoreGUI.getErrorHandler().handleError( + "Error: " + results.length + " created instead of one"); + } else { + Record newRecord = results[0]; + GroupDefinition newGroupDefinition = dataSource + .copyValues((ListGridRecord) newRecord); + History.newItem(basePath + "/" + newGroupDefinition.getId()); + } + } else { + dynaGroupChildrenView.refresh(); + } } }); } @@ -256,7 +276,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private void buildForm() { id = new TextItem("id", "ID"); - id.setVisible(false); + //id.setVisible(false); idStatic = new StaticTextItem("idStatic", "ID"); idStatic.setVisible(false);
@@ -387,6 +407,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm public void renderView(ViewPath viewPath) { groupDefinitionId = viewPath.getCurrentAsInt(); viewId = viewPath.getCurrent(); + basePath = viewPath.getPathToCurrent(); GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new AsyncCallback<Set<Permission>>() { @Override public void onFailure(Throwable caught) {
commit 44f77ff7a5df1f2054180290285831b44fa87292 Merge: c1f4166... c073bce... Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 21 15:26:36 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit c073bceb346b0ecc93e238cf58646624fefde13c Merge: 4d44fd5... fe4cc40... Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Sep 21 14:26:49 2010 -0400
Merge branch 'master' into master-jay
Conflicts: modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java index 60a3783,f88f949..f318cf4 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java @@@ -65,3 -563,95 +563,96 @@@ public class RecentAlertsPortlet extend } } } + + class CustomizedResourceSelector extends ResourceSelector { - public CustomizedResourceSelector(String id) { - super(id); ++ public CustomizedResourceSelector(String locatorId) { ++ super(locatorId); ++ } ++ ++ public CustomizedResourceSelector(String locatorId, ResourceType rtFilter, boolean forceRtFilter) { ++ super(locatorId, rtFilter, forceRtFilter); + } + + public void addAvailableGridSelectionsToAssignedGrid() { + assignedGrid.transferSelectedData(availableGrid); + select(assignedGrid.getSelection()); + updateButtons(); + } + } + + class AlertResourceSelectorRegion extends GroupMembersStep { + // private ResourceSelector selector = null; + private CustomizedResourceSelector selector = null; - private ResourceType requireType = null; + private Integer[] currentlyAssignedIds; + + public Integer[] getCurrentlyAssignedIds() { + return currentlyAssignedIds; + } + + public Integer[] getListGridValues() { + Integer[] listGridValues = new Integer[0]; + if ((null != selector) && (null != selector.getAssignedGrid())) { + RecordList allRecords = selector.getAssignedGrid().getDataAsRecordList(); + if (allRecords.getLength() > 0) { + listGridValues = new Integer[allRecords.getLength()]; + for (int i = 0; i < allRecords.getLength(); i++) { + Record record = allRecords.get(i); + listGridValues[i] = record.getAttributeAsInt(RecentAlertsPortlet.ID); + } + } + } + return listGridValues; + } + + public AlertResourceSelectorRegion(Integer[] assigned) { + super(null); + this.currentlyAssignedIds = assigned; + } + + public Canvas getCanvas() { - ResourceType rt = ResourceType.ANY_PLATFORM_TYPE; - if ((selector == null) || (rt != requireType)) { ++ if (selector == null) { + // selector = new ResourceSelector(getName()); - selector = new CustomizedResourceSelector(getName()); ++ selector = new CustomizedResourceSelector(getName(), ResourceType.ANY_PLATFORM_TYPE, true); + selector.setWidth100(); + selector.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH); - selector.setRequireType(rt); + //widget ui updates + selector.getAvailableGrid().setTitle("Available Resources"); + selector.getAvailableGrid().setEmptyMessage("Loading data..."); + selector.getAssignedGrid().setTitle("Selected Resources"); + + //populate fields for grid. + ListGridField nameField = new ListGridField("name", "Name"); + ListGridField iconField = new ListGridField("icon", "icon", 50); + iconField.setImageURLPrefix("types/"); + iconField.setType(ListGridFieldType.ICON); + selector.getAssignedGrid().setFields(iconField, nameField); + + //add listener to AvailableGrid, to act after successfully populated. + selector.getAvailableGrid().addDataArrivedHandler(new DataArrivedHandler() { + @Override + public void onDataArrived(DataArrivedEvent event) { + if ((getCurrentlyAssignedIds() != null) && (getCurrentlyAssignedIds().length > 0)) { + //retrieve the loaded data and add to the table itself + RecordList recordList = selector.getAvailableGrid().getDataAsRecordList(); + for (int ci : getCurrentlyAssignedIds()) { + int located = recordList.findIndex("id", ci); + if (located > -1) { + selector.getAvailableGrid().selectRecord(located); + } + } + selector.addAvailableGridSelectionsToAssignedGrid(); + selector.getAssignedGrid().invalidateCache(); + selector.getAssignedGrid().markForRedraw(); + } else {//no selected resources found + selector.getAvailableGrid().setEmptyMessage("No items to show"); + } + } + }); + } + return selector; + } + + public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) { + this.currentlyAssignedIds = currentlyAssignedIds; + } + } diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java index 0951851,d475aa8..d968e19 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java @@@ -48,10 -49,10 +49,12 @@@ public interface ResourceGroupGWTServic
PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
- void recalculateGroupDefinitions(int[] groupDefinitionIds); + void setAssignedResourceGroupsForResource(int resourceId, int[] resourceGroupIds, boolean setType); + + void setAssignedResources(int groupId, int[] resourceIds, boolean setType);
- void setMembership(int groupId, int[] resourceIds, boolean setType); ++ void recalculateGroupDefinitions(int[] groupDefinitionIds); + void updateGroupDefinition(GroupDefinition groupDefinition);
void updateResourceGroup(ResourceGroup group); diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java index 20786a0,f0fe978..91bf412 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java @@@ -115,11 -110,11 +110,16 @@@ public class ResourceGroupsDataSource e "downMemberCount"))); }
+ if (request.getCriteria().getValues().get("explicitResourceId") != null) { + criteria.addFilterExplicitResourceIds(Integer.parseInt((String) request.getCriteria().getValues().get( + "explicitResourceId"))); + } + + if (request.getCriteria().getValues().get("groupDefinitionId") != null) { + criteria.addFilterGroupDefinitionId(Integer.parseInt((String) request.getCriteria().getValues().get( + "groupDefinitionId"))); + } + return criteria; }
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 6603a00,f085e9b..05590ff --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@@ -187,74 -192,68 +192,64 @@@ public class ResourceGroupDetailView ex // FullHTMLPane timelinePane = new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()); // summaryTab.updateSubTab("Overview", new DashboardView(resource)); // summaryTab.updateSubTab("Timeline", timelinePane); - this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("Overview"), - this.groupComposite)); - - int groupId = this.groupComposite.getResourceGroup().getId(); - - this.monitorGraphs.setCanvas(new FullHTMLPane("/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId)); - this.monitorTables.setCanvas(new FullHTMLPane("/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId)); - this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId)); - this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId)); - this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId)); + // Summary tab is always visible and enabled. - updateSubTab(this.summaryTab, this.summaryOverview, - new OverviewView(this.summaryTab.extendLocatorId("Overview"), this.groupComposite), true, true); - - if (updateTab(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE, true)) { - updateSubTab(this.monitoringTab, this.monitorGraphs, - new FullHTMLPane("/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId), - hasMetricsOfType(this.groupComposite, DataType.MEASUREMENT), true); - updateSubTab(this.monitoringTab, this.monitorTables, - new FullHTMLPane("/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId), - hasMetricsOfType(this.groupComposite, DataType.MEASUREMENT), true); - updateSubTab(this.monitoringTab, this.monitorTraits, - new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId), - hasMetricsOfType(this.groupComposite, DataType.TRAIT), true); - updateSubTab(this.monitoringTab, this.monitorSched, - new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId), - hasMetricsOfType(this.groupComposite, null), true); - updateSubTab(this.monitoringTab, this.monitorCallTime, - new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId), - facets.contains(ResourceTypeFacet.CALL_TIME), true); ++ updateSubTab(this.summaryTab, this.summaryOverview, new OverviewView(this.summaryTab ++ .extendLocatorId("Overview"), this.groupComposite), true, true); ++ ++ if (updateTab(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE, true)) { ++ updateSubTab(this.monitoringTab, this.monitorGraphs, new FullHTMLPane( ++ "/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId), hasMetricsOfType(this.groupComposite, ++ DataType.MEASUREMENT), true); ++ updateSubTab(this.monitoringTab, this.monitorTables, new FullHTMLPane( ++ "/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId), hasMetricsOfType(this.groupComposite, ++ DataType.MEASUREMENT), true); ++ updateSubTab(this.monitoringTab, this.monitorTraits, new TraitsView(this.monitoringTab ++ .extendLocatorId("TraitsView"), groupId), hasMetricsOfType(this.groupComposite, DataType.TRAIT), true); ++ updateSubTab(this.monitoringTab, this.monitorSched, new SchedulesView(this.monitoringTab ++ .extendLocatorId("SchedulesView"), groupId), hasMetricsOfType(this.groupComposite, null), true); ++ updateSubTab(this.monitoringTab, this.monitorCallTime, new FullHTMLPane( ++ "/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId), facets ++ .contains(ResourceTypeFacet.CALL_TIME), true); + // TODO (ips): Add Availability subtab. + }
- this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(this.inventoryTab - .extendLocatorId("MembersView"), groupId)); + // Inventory tab is always visible and enabled. - updateSubTab(this.inventoryTab, this.inventoryMembers, - ResourceSearchView.getMembersOf(this.inventoryMembers.extendLocatorId("View"), groupId), true, true); ++ updateSubTab(this.inventoryTab, this.inventoryMembers, ResourceSearchView.getMembersOf(this.inventoryTab ++ .extendLocatorId("MembersView"), groupId), true, true); // TODO: Uncomment this once the group config component is done. - //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin)); - this.inventoryMembership.setCanvas(new ResourceGroupMembershipView(this.inventoryTab - .extendLocatorId("MembershipView"), groupId)); - - this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" - + groupId)); - this.opSched.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" - + groupId)); - - this.alertHistory.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" - + groupId)); - this.alertDef.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" - + groupId)); - - this.configCurrent.setCanvas(new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" - + groupId)); - this.configHistory - .setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId)); - - this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite)); - - updateTabEnablement(); - } - - private void updateTabEnablement() { - GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory(); - Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets(); - - // Summary and Inventory tabs are always enabled. - - // Only enable "Call Time" and "Traits" subtabs for groups that implement them. - this.monitoringTab.setSubTabEnabled(this.monitorTraits.getLocatorId(), hasTraits(this.groupComposite)); - this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets - .contains(ResourceTypeFacet.CALL_TIME)); - - // Inventory>Connection Settings subtab is only enabled for compat groups that define conn props. - this.inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE - && facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); - - // Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups. - // TODO (ips): Break out mixed groups into a separate view. - getTabSet().setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE); - getTabSet().setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE); + //updateSubTab(this.inventoryTab, this.inventoryConn, + // new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin), + // facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true); - updateSubTab(this.inventoryTab, this.inventoryMembership, - new ResourceGroupMembershipView(this.inventoryTab.extendLocatorId("MembershipView"), groupId), true, true); - - if (updateTab(this.operationsTab, - groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.OPERATION), true)) { - updateSubTab(this.operationsTab, this.opHistory, - new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true); - updateSubTab(this.operationsTab, this.opSched, - new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId), true, true); ++ updateSubTab(this.inventoryTab, this.inventoryMembership, new ResourceGroupMembershipView(this.inventoryTab ++ .extendLocatorId("MembershipView"), groupId), true, true); ++ ++ if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE ++ && facets.contains(ResourceTypeFacet.OPERATION), true)) { ++ updateSubTab(this.operationsTab, this.opHistory, new FullHTMLPane( ++ "/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true); ++ updateSubTab(this.operationsTab, this.opSched, new FullHTMLPane( ++ "/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId), true, true); + }
- // Operations tab is only enabled for compatible groups of a type that supports the Operations facet. - getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); + if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE, true)) { - updateSubTab(this.alertsTab, this.alertHistory, - new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" + groupId), true, true); - updateSubTab(this.alertsTab, this.alertDef, - new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" + groupId), true, true); ++ updateSubTab(this.alertsTab, this.alertHistory, new FullHTMLPane( ++ "/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" + groupId), true, true); ++ updateSubTab(this.alertsTab, this.alertDef, new FullHTMLPane( ++ "/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" + groupId), true, true); + }
- // Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet - // and when the current user has the CONFIGURE_READ permission. - getTabSet().setTabEnabled(this.configurationTab, - facets.contains(ResourceTypeFacet.CONFIGURATION) && this.permissions.isConfigureRead()); - if (updateTab(this.configurationTab, - groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.CONFIGURATION), - this.permissions.isConfigureRead())) { - updateSubTab(this.configurationTab, this.configCurrent, - new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" + groupId), true, true); - updateSubTab(this.configurationTab, this.configHistory, - new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId), true, true); ++ if (updateTab(this.configurationTab, groupCategory == GroupCategory.COMPATIBLE ++ && facets.contains(ResourceTypeFacet.CONFIGURATION), this.permissions.isConfigureRead())) { ++ updateSubTab(this.configurationTab, this.configCurrent, new FullHTMLPane( ++ "/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" + groupId), true, true); ++ updateSubTab(this.configurationTab, this.configHistory, new FullHTMLPane( ++ "/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId), true, true); + }
- // Events tab is only enabled for compatible groups of a type that supports the Events facet. - getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); - if (updateTab(this.eventsTab, - groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.EVENT), true)) { - updateSubTab(this.eventsTab, this.eventHistory, - EventCompositeHistoryView.get(groupComposite), true, true); ++ if (updateTab(this.eventsTab, groupCategory == GroupCategory.COMPATIBLE ++ && facets.contains(ResourceTypeFacet.EVENT), true)) { ++ updateSubTab(this.eventsTab, this.eventHistory, EventCompositeHistoryView.get(groupComposite), true, true); + } }
protected void loadSelectedItem(final int groupId, final ViewPath viewPath) { diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java index 2e3e9c7,2e3e9c7..d87e26b --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java @@@ -43,7 -43,7 +43,7 @@@ public class GroupMembersStep extends A
public Canvas getCanvas() { if (selector == null) { -- selector = new ResourceSelector(getName()); ++ selector = new ResourceSelector("GroupMembers"); } return selector; } diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index 8e73379,88dd2f9..8e4e16f --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@@ -197,92 -189,92 +196,91 @@@ public class ResourceDetailView extend ((TwoLevelTab) top).getLayout().destroyViews(); }
- this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("OverviewView"), - this.resourceComposite)); - this.summaryDashboard.setCanvas(new DashboardView(this.resourceComposite)); - this.summaryTimeline.setCanvas(new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" - + resource.getId())); - - this.monitorGraphs.setCanvas(new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource)); - this.monitorTables.setCanvas(new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId())); - this.monitorTraits - .setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId())); - this.monitorAvail.setCanvas(new FullHTMLPane("/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" - + resource.getId())); - this.monitorSched - .setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId())); - this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" - + resource.getId())); - - this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.inventoryTab - .extendLocatorId("ChildrenView"), resource.getId())); - this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.inventoryTab - .extendLocatorId("PluginConfigView"), resource)); - this.inventoryGroups.setCanvas(ResourceGroupListView.getGroupsOf(this.inventoryTab - .extendLocatorId("GroupsView"), resource.getId())); - this.inventoryGroupMembership.setCanvas(new ResourceResourceGroupsView(this.inventoryTab - .extendLocatorId("GroupMembershipView"), resourceId)); - - // comment out GWT-based operation history until... - // 1) user can delete history if they possess the appropriate permissions - // 2) user can see both operation arguments and results in the history details pop-up - // 3) operation arguments/results become read-only configuration data in the history details pop-up - // 4) user can navigate to the group operation that spawned this resource operation history, if appropriate - // note: enabled operation execution/schedules from left-nav, if it doesn't already exist - this.opHistory.setCanvas(OperationHistoryView.getResourceHistoryView(operationsTab.extendLocatorId("History"), - resourceComposite)); - this.opSched.setCanvas(new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" - + resource.getId())); + ResourcePermission permissions = this.resourceComposite.getResourcePermission(); + Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets(); + - updateSubTab(this.summaryTab, this.summaryOverview, - new OverviewView(this.summaryOverview.getLocatorId(), this.resourceComposite), true, true); - updateSubTab(this.summaryTab, this.summaryDashboard, - new DashboardView(this.resourceComposite), true, true); - updateSubTab(this.summaryTab, this.summaryTimeline, - new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()), true, true); ++ updateSubTab(this.summaryTab, this.summaryOverview, new OverviewView(this.summaryTab ++ .extendLocatorId("OverviewView"), this.resourceComposite), true, true); ++ updateSubTab(this.summaryTab, this.summaryDashboard, new DashboardView(this.resourceComposite), true, true); ++ updateSubTab(this.summaryTab, this.summaryTimeline, new FullHTMLPane( ++ "/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()), true, true); + - updateSubTab(this.monitoringTab, this.monitorGraphs, - new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource), ++ updateSubTab(this.monitoringTab, this.monitorGraphs, new GraphListView(this.monitoringTab ++ .extendLocatorId("GraphListView"), resource), + hasMetricsOfType(this.resourceComposite, DataType.MEASUREMENT), true); - updateSubTab(this.monitoringTab, this.monitorTables, - new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()), - hasMetricsOfType(this.resourceComposite, DataType.MEASUREMENT), true); - updateSubTab(this.monitoringTab, this.monitorTraits, - new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId()), ++ updateSubTab(this.monitoringTab, this.monitorTables, new FullHTMLPane( ++ "/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()), hasMetricsOfType(this.resourceComposite, ++ DataType.MEASUREMENT), true); ++ updateSubTab(this.monitoringTab, this.monitorTraits, new TraitsView(this.monitoringTab ++ .extendLocatorId("TraitsView"), resource.getId()), + hasMetricsOfType(this.resourceComposite, DataType.TRAIT), true); - updateSubTab(this.monitoringTab, this.monitorAvail, - new FullHTMLPane("/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" + resource.getId()), true, - true); - updateSubTab(this.monitoringTab, this.monitorSched, - new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId()), - hasMetricsOfType(this.resourceComposite, null), true); - updateSubTab(this.monitoringTab, this.monitorCallTime, - new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId()), - facets.contains(ResourceTypeFacet.CALL_TIME), true); ++ updateSubTab(this.monitoringTab, this.monitorAvail, new FullHTMLPane( ++ "/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" + resource.getId()), true, true); ++ updateSubTab(this.monitoringTab, this.monitorSched, new SchedulesView(monitoringTab ++ .extendLocatorId("SchedulesView"), resource.getId()), hasMetricsOfType(this.resourceComposite, null), true); ++ updateSubTab(this.monitoringTab, this.monitorCallTime, new FullHTMLPane( ++ "/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId()), facets ++ .contains(ResourceTypeFacet.CALL_TIME), true); + + ResourceType type = this.resourceComposite.getResource().getResourceType(); - updateSubTab(this.inventoryTab, this.inventoryChildren, - ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource.getId()), - !type.getChildResourceTypes().isEmpty(), true); - updateSubTab(this.inventoryTab, this.inventoryConn, - new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource), - facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true); ++ updateSubTab(this.inventoryTab, this.inventoryChildren, ResourceSearchView.getChildrenOf(this.inventoryTab ++ .extendLocatorId("ChildrenView"), resource.getId()), !type.getChildResourceTypes().isEmpty(), true); ++ updateSubTab(this.inventoryTab, this.inventoryConn, new PluginConfigurationEditView(this.inventoryTab ++ .extendLocatorId("PluginConfigView"), resource), facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), ++ true); ++ updateSubTab(this.inventoryTab, this.inventoryGroups, ResourceGroupListView.getGroupsOf(this.inventoryTab ++ .extendLocatorId("GroupsView"), resource.getId()), true, true); ++ updateSubTab(this.inventoryTab, this.inventoryGroupMembership, new ResourceResourceGroupsView(this.inventoryTab ++ .extendLocatorId("GroupMembershipView"), resourceId), true, true); + + if (updateTab(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION), true)) { + // comment out GWT-based operation history until... + // 1) user can delete history if they possess the appropriate permissions + // 2) user can see both operation arguments and results in the history details pop-up + // 3) operation arguments/results become read-only configuration data in the history details pop-up + // 4) user can navigate to the group operation that spawned this resource operation history, if appropriate + // note: enabled operation execution/schedules from left-nav, if it doesn't already exist - updateSubTab(this.operationsTab, this.opHistory, - OperationHistoryView.getResourceHistoryView(operationsTab.extendLocatorId("History"), this.resourceComposite), - true, true); - updateSubTab(this.operationsTab, this.opSched, - new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId()), - true, true); ++ updateSubTab(this.operationsTab, this.opHistory, OperationHistoryView.getResourceHistoryView(operationsTab ++ .extendLocatorId("History"), this.resourceComposite), true, true); ++ updateSubTab(this.operationsTab, this.opSched, new FullHTMLPane( ++ "/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId()), true, true); + }
// comment out GWT-based alert definitions/history views until... // 1) new workflow is implement for alert definition creation, with particular attention to interaction model for alert notifications // 2) user can delete/ack/purgeAll alerts if they possess the appropriate permissions // 3) user can enable/disable/delete alert definitions if they possess the appropriate permissions // 4) user can search alert history by: date alert was fired, alert priority, or alert definition - this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" - + resource.getId())); - this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("AlertDef"), - resourceComposite)); - this.alertDelete.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" - + resource.getId())); - - this.configCurrent - .setCanvas(new ResourceConfigurationEditView(this.extendLocatorId("ResourceConfig"), resource)); - this.configHistory.setCanvas(ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"), - resource.getId())); - - this.eventHistory.setCanvas(EventCompositeHistoryView.get(resourceComposite)); - - this.contentDeployed - .setCanvas(new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId())); - this.contentNew.setCanvas(new FullHTMLPane("/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId())); - this.contentSubscrip.setCanvas(new FullHTMLPane("/rhq/resource/content/subscription-plain.xhtml?id=" - + resource.getId())); - this.contentHistory.setCanvas(new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id=" - + resource.getId())); - - updateTabEnablement(); - } - - private void updateTabEnablement() { - ResourcePermission permissions = this.resourceComposite.getResourcePermission(); - Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets(); - - // Summary, Monitoring, Inventory, and Alerts tabs are always enabled. - - monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.resourceComposite)); - monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME)); - updateSubTab(this.alertsTab, this.alertHistory, - new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" + resource.getId()), true, true); - updateSubTab(this.alertsTab, this.alertDef, - new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("AlertDef"), this.resourceComposite), true, true); - updateSubTab(this.alertsTab, this.alertDelete, - new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" + resource.getId()), true, true); ++ updateSubTab(this.alertsTab, this.alertHistory, new FullHTMLPane( ++ "/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" + resource.getId()), true, true); ++ updateSubTab(this.alertsTab, this.alertDef, new ResourceAlertDefinitionsView(alertsTab ++ .extendLocatorId("AlertDef"), this.resourceComposite), true, true); ++ updateSubTab(this.alertsTab, this.alertDelete, new FullHTMLPane( ++ "/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" + resource.getId()), true, true); + - if (updateTab(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION), permissions.isConfigureRead())) { - updateSubTab(this.configurationTab, this.configCurrent, - new ResourceConfigurationEditView(this.extendLocatorId("ResourceConfig"), resource), true, true); - updateSubTab(this.configurationTab, this.configHistory, - ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"), resource.getId()), true, true); ++ if (updateTab(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION), permissions ++ .isConfigureRead())) { ++ updateSubTab(this.configurationTab, this.configCurrent, new ResourceConfigurationEditView(this ++ .extendLocatorId("ResourceConfig"), resource), true, true); ++ updateSubTab(this.configurationTab, this.configHistory, ConfigurationHistoryView.getHistoryOf( ++ configurationTab.extendLocatorId("Hist"), resource.getId()), true, true); + }
- inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets - .contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); - ResourceType type = this.resourceComposite.getResource().getResourceType(); - inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty()); + if (updateTab(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT), true)) { - updateSubTab(this.eventsTab, this.eventHistory, - EventCompositeHistoryView.get(resourceComposite), true, true); ++ updateSubTab(this.eventsTab, this.eventHistory, EventCompositeHistoryView.get(resourceComposite), true, ++ true); + }
- getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); - getTabSet().setTabEnabled(this.configurationTab, - facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); - getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); - getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT)); + if (updateTab(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT), true)) { - updateSubTab(this.contentTab, this.contentDeployed, - new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()), true, true); - updateSubTab(this.contentTab, this.contentNew, - new FullHTMLPane("/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId()), true, true); - updateSubTab(this.contentTab, this.contentSubscrip, - new FullHTMLPane("/rhq/resource/content/subscription-plain.xhtml?id=" + resource.getId()), true, true); - updateSubTab(this.contentTab, this.contentHistory, - new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id=" + resource.getId()), true, true); ++ updateSubTab(this.contentTab, this.contentDeployed, new FullHTMLPane( ++ "/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()), true, true); ++ updateSubTab(this.contentTab, this.contentNew, new FullHTMLPane( ++ "/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId()), true, true); ++ updateSubTab(this.contentTab, this.contentSubscrip, new FullHTMLPane( ++ "/rhq/resource/content/subscription-plain.xhtml?id=" + resource.getId()), true, true); ++ updateSubTab(this.contentTab, this.contentHistory, new FullHTMLPane( ++ "/rhq/resource/content/history-plain.xhtml?id=" + resource.getId()), true, true); + } }
public Integer getSelectedItemId() { diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java index b210e31,4aaf7ca..b81400d --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java @@@ -138,8 -138,8 +138,8 @@@ public class ClusterManagerBean impleme try { // You are allowed to cause the creation of an auto cluster backing group as long as you can // view the parent group. (That check was done above) - resourceGroupManager.setAssignedResources(subjectManager.getOverlord(), autoClusterBackingGroup.getId(), - resourceIds, false); - resourceGroupManager.setMembership(subjectManager.getOverlord(), autoClusterBackingGroup.getId(), - resourceIds, false); ++ resourceGroupManager.setAssignedResources(subjectManager.getOverlord(), ++ autoClusterBackingGroup.getId(), resourceIds, false); } catch (Exception e) { log.error("Could not add resources to group:" + e); } diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java index 3acae10,28ae218..0e7500f --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java @@@ -1319,40 -1319,6 +1319,39 @@@ public class ResourceGroupManagerBean i } }
+ public void setAssignedResourceGroupsForResource(Subject subject, int resourceId, int[] resourceGroupIds, + boolean setType) throws ResourceGroupDeleteException { + + Resource resource = entityManager.find(Resource.class, resourceId); + Set<ResourceGroup> currentGroups = resource.getExplicitGroups(); + List<Integer> currentGroupIds = new ArrayList<Integer>(currentGroups.size()); + for (ResourceGroup currentGroup : currentGroups) { + currentGroupIds.add(currentGroup.getId()); + } + + int[] resourceIdArr = new int[] { resourceId }; + + List<Integer> addedGroupIds = ArrayUtils.wrapInList(resourceGroupIds); + addedGroupIds.removeAll(currentGroupIds); + for (Integer addedGroupId : addedGroupIds) { + addResourcesToGroup(subject, addedGroupId, resourceIdArr); + // As a result of the membership change ensure that the group type is set correctly. + if (setType) { + setResourceType(addedGroupId); + } + } + + List<Integer> removedGroupIds = new ArrayList<Integer>(currentGroupIds); // groups needing removal + removedGroupIds.removeAll(ArrayUtils.wrapInList(resourceGroupIds)); + for (Integer removedGroupId : removedGroupIds) { + removeResourcesFromGroup(subject, removedGroupId, resourceIdArr); + // As a result of the membership change ensure that the group type is set correctly. + if (setType) { + setResourceType(removedGroupId); + } + } - + } + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Remote interface impl // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
commit c1f4166199695ed25b031074f10cb9a012bacd47 Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 21 13:01:56 2010 -0400
don't pluralize subcat names since they're typically already pluralized as defined in the plugin descriptors
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java index 0862d3a..2516ac5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java @@ -262,7 +262,8 @@ public class ResourceTreeDatasource extends DataSource { setParentID(parentResourceId); setAttribute("parentId", parentResourceId);
- String name = pluralize(category.getDisplayName()); + // Note, subcategory names are typically already plural, so there's no need to pluralize them. + String name = category.getDisplayName(); setName(name); setAttribute("name", name); } @@ -360,8 +361,15 @@ public class ResourceTreeDatasource extends DataSource { return id.replace(' ', '_'); }
- private static String pluralize(String s) { + private static String pluralize(String singularNoun) { // TODO: Make this smarter. - return s + "s"; + String pluralNoun; + if (singularNoun.endsWith("y") && !singularNoun.endsWith("ay") && !singularNoun.endsWith("ey") && + !singularNoun.endsWith("oy")) { + pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies"; + } else { + pluralNoun = singularNoun + "s"; + } + return pluralNoun; } }
commit 4d44fd501554dbb58b30b7f561f110953b525dba Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Sep 21 12:41:16 2010 -0400
Group CRUD - initially restrict group membership to group type for compat groups - renamed some new "setAssigned*" SLSB methods for understanding and consistency. (may need to consider these for remote API later) - added new resource inventory subtabs for group view/assignment
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java index 9ea9467..6c86265 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java @@ -160,7 +160,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { roleIds[i++] = id; }
- GWTServiceLookup.getRoleService().setAssignedSubjectRoles(subjectId, roleIds, + GWTServiceLookup.getRoleService().setAssignedRolesForSubject(subjectId, roleIds, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Failed to save user role assignments.", caught); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java index 333427f..0951851 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java @@ -48,7 +48,9 @@ public interface ResourceGroupGWTService extends RemoteService {
PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
- void setMembership(int groupId, int[] resourceIds, boolean setType); + void setAssignedResourceGroupsForResource(int resourceId, int[] resourceGroupIds, boolean setType); + + void setAssignedResources(int groupId, int[] resourceIds, boolean setType);
void updateGroupDefinition(GroupDefinition groupDefinition);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java index 932ceb8..41d7204 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/RoleGWTService.java @@ -18,13 +18,12 @@ */ package org.rhq.enterprise.gui.coregui.client.gwt;
-import org.rhq.core.domain.auth.Subject; +import com.google.gwt.user.client.rpc.RemoteService; + import org.rhq.core.domain.authz.Role; import org.rhq.core.domain.criteria.RoleCriteria; import org.rhq.core.domain.util.PageList;
-import com.google.gwt.user.client.rpc.RemoteService; - /** * @author Greg Hinkle */ @@ -42,5 +41,5 @@ public interface RoleGWTService extends RemoteService {
void setAssignedSubjects(int roleId, int[] subjectIds);
- void setAssignedSubjectRoles(int subjectId, int[] roleIds); + void setAssignedRolesForSubject(int subjectId, int[] roleIds); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java index 38d409f..7053f7c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java @@ -123,4 +123,11 @@ public class ResourceGroupListView extends Table { }); }
+ // -------- Static Utility loaders ------------ + + public static ResourceGroupListView getGroupsOf(String locatorId, int explicitResourceId) { + return new ResourceGroupListView(locatorId, new Criteria("explicitResourceId", String + .valueOf(explicitResourceId)), "Resource Groups"); + } + } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java index 00e9389..20786a0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java @@ -115,6 +115,11 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> { "downMemberCount"))); }
+ if (request.getCriteria().getValues().get("explicitResourceId") != null) { + criteria.addFilterExplicitResourceIds(Integer.parseInt((String) request.getCriteria().getValues().get( + "explicitResourceId"))); + } + return criteria; }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java index e08b57d..48d0859 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java @@ -22,7 +22,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory; import java.util.HashSet;
import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; @@ -30,6 +29,7 @@ import com.smartgwt.client.widgets.layout.LayoutSpacer; import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.criteria.ResourceGroupCriteria; +import org.rhq.core.domain.resource.group.GroupCategory; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; @@ -79,6 +79,7 @@ public class ResourceGroupMembershipView extends LocatableVLayout { ResourceGroupCriteria c = new ResourceGroupCriteria(); c.addFilterId(this.resourceGroupId); c.fetchExplicitResources(true); + c.fetchResourceType(true); GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(c, new AsyncCallback<PageList<ResourceGroup>>() { public void onFailure(Throwable caught) { @@ -86,11 +87,14 @@ public class ResourceGroupMembershipView extends LocatableVLayout { }
public void onSuccess(PageList<ResourceGroup> result) { - ResourceGroupMembershipView.this.resourceGroup = result.get(0); + ResourceGroup group = result.get(0); + ResourceGroupMembershipView.this.resourceGroup = group; ResourceGroupMembershipView.this.selector = new ResourceGroupResourceSelector( - ResourceGroupMembershipView.this.getLocatorId(), ResourceGroupMembershipView.this.resourceGroup - .getExplicitResources()); - ResourceGroupMembershipView.this.selector.setOverflow(Overflow.AUTO); + ResourceGroupMembershipView.this.getLocatorId(), + group.getExplicitResources(), + (GroupCategory.COMPATIBLE == ResourceGroupMembershipView.this.resourceGroup.getGroupCategory()) ? group + .getResourceType() + : null, false);
addMember(ResourceGroupMembershipView.this.selector); } @@ -100,7 +104,7 @@ public class ResourceGroupMembershipView extends LocatableVLayout { private void save() { int[] resourceIds = getSelectedResourceIds();
- GWTServiceLookup.getResourceGroupService().setMembership(this.resourceGroup.getId(), resourceIds, true, + GWTServiceLookup.getResourceGroupService().setAssignedResources(this.resourceGroup.getId(), resourceIds, true, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java index 6bc96fb..587a8ca 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java @@ -24,9 +24,11 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory;
import java.util.Collection;
+import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
@@ -35,11 +37,16 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.Resour */ public class ResourceGroupResourceSelector extends ResourceSelector {
- public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources) { - super(locatorId); + public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources, + ResourceType resourceTypeFilter, boolean forceResourceTypeFilter) { + + super(locatorId, resourceTypeFilter, forceResourceTypeFilter); + if (null != resources) { ListGridRecord[] data = (new ResourceDatasource()).buildRecords(resources); setAssigned(data); } + + this.setOverflow(Overflow.AUTO); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index e80be32..8e73379 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -44,11 +44,13 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView; import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.ResourceResourceGroupsView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits.TraitsView; @@ -91,6 +93,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo private SubTab monitorCallTime; private SubTab inventoryChildren; private SubTab inventoryConn; + private SubTab inventoryGroups; + private SubTab inventoryGroupMembership; private SubTab opHistory; private SubTab opSched; private SubTab alertHistory; @@ -135,7 +139,10 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo "/images/icons/Inventory_grey_16.png"); inventoryChildren = new SubTab(inventoryTab.extendLocatorId("Children"), "Children", null); inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null); - inventoryTab.registerSubTabs(this.inventoryChildren, this.inventoryConn); + inventoryGroups = new SubTab(inventoryTab.extendLocatorId("Groups"), "Groups", null); + inventoryGroupMembership = new SubTab(inventoryTab.extendLocatorId("GroupMembership"), "Group Membership", null); + inventoryTab.registerSubTabs(this.inventoryChildren, this.inventoryConn, this.inventoryGroups, + this.inventoryGroupMembership); tabs.add(inventoryTab);
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations", @@ -207,9 +214,14 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId()));
- this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource - .getId())); - this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource)); + this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.inventoryTab + .extendLocatorId("ChildrenView"), resource.getId())); + this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.inventoryTab + .extendLocatorId("PluginConfigView"), resource)); + this.inventoryGroups.setCanvas(ResourceGroupListView.getGroupsOf(this.inventoryTab + .extendLocatorId("GroupsView"), resource.getId())); + this.inventoryGroupMembership.setCanvas(new ResourceResourceGroupsView(this.inventoryTab + .extendLocatorId("GroupMembershipView"), resourceId));
// comment out GWT-based operation history until... // 1) user can delete history if they possess the appropriate permissions diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupSelector.java new file mode 100644 index 0000000..6a178ea --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupSelector.java @@ -0,0 +1,50 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory; + +import java.util.Collection; + +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.core.domain.resource.group.ResourceGroup; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceGroupSelector; + +/** + * @author Jay Shaughnessy + */ +public class ResourceResourceGroupSelector extends ResourceGroupSelector { + + public ResourceResourceGroupSelector(String locatorId, Collection<ResourceGroup> resourceGroups) { + + super(locatorId); + + if (null != resourceGroups) { + ListGridRecord[] data = (new ResourceGroupsDataSource()).buildRecords(resourceGroups); + setAssigned(data); + } + + this.setOverflow(Overflow.AUTO); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupsView.java new file mode 100644 index 0000000..8669142 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/ResourceResourceGroupsView.java @@ -0,0 +1,125 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory; + +import java.util.HashSet; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.widgets.IButton; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.layout.LayoutSpacer; +import com.smartgwt.client.widgets.toolbar.ToolStrip; + +import org.rhq.core.domain.criteria.ResourceCriteria; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/** + * @author Jay Shaughnessy + */ +public class ResourceResourceGroupsView extends LocatableVLayout { + + private int resourceId; + private Resource resource; + private ResourceResourceGroupSelector selector; + + public ResourceResourceGroupsView(String locatorId, int resourceId) { + super(locatorId); + + this.resourceId = resourceId; + } + + @Override + protected void onDraw() { + super.onDraw(); + + build(); + } + + public void build() { + ToolStrip toolStrip = new ToolStrip(); + toolStrip.setWidth100(); + + toolStrip.addMember(new LayoutSpacer()); + + IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); + saveButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + save(); + } + }); + + toolStrip.addMember(saveButton); + this.addMember(toolStrip); + + ResourceCriteria c = new ResourceCriteria(); + c.addFilterId(this.resourceId); + c.fetchExplicitGroups(true); + GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to fetch Resource's Groups", caught); + } + + public void onSuccess(PageList<Resource> result) { + resource = result.get(0); + ResourceResourceGroupsView.this.selector = new ResourceResourceGroupSelector( + ResourceResourceGroupsView.this.getLocatorId(), resource.getExplicitGroups()); + + addMember(ResourceResourceGroupsView.this.selector); + } + }); + } + + private void save() { + int[] resourceGroupIds = getSelectedResourceGroupIds(); + + GWTServiceLookup.getResourceGroupService().setAssignedResourceGroupsForResource(this.resource.getId(), + resourceGroupIds, true, new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify( + new Message("Group membership updated for [" + + ResourceResourceGroupsView.this.resource.getName() + "]", Message.Severity.Info)); + CoreGUI.refresh(); + } + }); + } + + private int[] getSelectedResourceGroupIds() { + int[] selection = new int[this.selector.getSelection().size()]; + HashSet<Integer> selectedIds = this.selector.getSelection(); + int i = 0; + for (Integer id : selectedIds) { + selection[i++] = id; + } + + return selection; + } + +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java index b1ad07f..0047b1f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java @@ -47,28 +47,29 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; */ public class ResourceSelector extends AbstractSelector<Resource> {
- private ResourceType requireType; + private ResourceType resourceTypeFilter; + private boolean forceResourceTypeFilter; + private IPickTreeItem typeSelectItem;
public ResourceSelector(String locatorId) { - super(locatorId); - } - - public ResourceType getRequireType() { - return requireType; + this(locatorId, null, false); }
- public void setRequireType(ResourceType requireType) { - this.requireType = requireType; - markForRedraw(); + public ResourceSelector(String locatorId, ResourceType resourceTypeFilter, boolean forceResourceTypeFilter) { + super(locatorId); + this.resourceTypeFilter = resourceTypeFilter; + this.forceResourceTypeFilter = forceResourceTypeFilter; }
protected DynamicForm getAvailableFilterForm() { if (null == availableFilterForm) { availableFilterForm = new LocatableDynamicForm("ResSelectAvailFilterForm"); availableFilterForm.setNumCols(6); + availableFilterForm.setWidth("75%"); final TextItem search = new TextItem("search", "Search"); + final SelectItem categorySelect;
- IPickTreeItem typeSelectItem = new IPickTreeItem("type", "Type"); + typeSelectItem = new IPickTreeItem("type", "Type"); typeSelectItem.setDataSource(new ResourceTypePluginTreeDataSource()); typeSelectItem.setValueField("id"); typeSelectItem.setCanSelectParentItems(true); @@ -76,22 +77,15 @@ public class ResourceSelector extends AbstractSelector<Resource> { typeSelectItem.setEmptyMenuMessage("Loading..."); typeSelectItem.setShowIcons(true);
- if (requireType != null) { - // TODO: Currently ignore the typeSelectItem widget because we already know the type. - // Alternatively, we could display it disabled but we'd want the type name to be displayed as the - // value. To get this to display the type name I think we need to pre-fetch the type tree here. We could - // potentially optimize typeSelectItem.setValue(requireType.getId()) to buildNodes a tree that includes only - // this single type. - //typeSelectItem.setValue(requireType.getId()); - //typeSelectItem.setDisabled(true); - availableFilterForm.setItems(search); - } else { - SelectItem categorySelect = new SelectItem("category", "Category"); - categorySelect.setValueMap("Platform", "Server", "Service"); - categorySelect.setAllowEmptyValue(true); - - availableFilterForm.setItems(search, typeSelectItem, categorySelect); + if (this.forceResourceTypeFilter) { + typeSelectItem.setDisabled(true); } + + categorySelect = new SelectItem("category", "Category"); + categorySelect.setValueMap("Platform", "Server", "Service"); + categorySelect.setAllowEmptyValue(true); + + availableFilterForm.setItems(search, categorySelect, typeSelectItem); }
return availableFilterForm; @@ -173,13 +167,15 @@ public class ResourceSelector extends AbstractSelector<Resource> {
@Override protected ResourceCriteria getFetchCriteria(final DSRequest request) { - ResourceCriteria result = super.getFetchCriteria(request); - - // additional filters - if (null != requireType) { - result.addFilterResourceTypeId(requireType.getId()); + // if specified seed with an initial type filter + if (null != ResourceSelector.this.resourceTypeFilter) { + ResourceSelector.this.typeSelectItem.setValue(resourceTypeFilter.getId()); + request.getCriteria().addCriteria(TYPE.propertyName(), String.valueOf(resourceTypeFilter.getId())); + ResourceSelector.this.resourceTypeFilter = null; }
+ ResourceCriteria result = super.getFetchCriteria(request); + // additional return data result.fetchResourceType(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java index b9642d6..8655bd8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java @@ -71,9 +71,17 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen } }
- public void setMembership(int groupId, int[] resourceIds, boolean setType) { + public void setAssignedResources(int groupId, int[] resourceIds, boolean setType) { try { - groupManager.setMembership(getSessionSubject(), groupId, resourceIds, setType); + groupManager.setAssignedResources(getSessionSubject(), groupId, resourceIds, setType); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } + } + + public void setAssignedResourceGroupsForResource(int resourceId, int[] resourceGroupIds, boolean setType) { + try { + groupManager.setAssignedResources(getSessionSubject(), resourceId, resourceGroupIds, setType); } catch (Throwable t) { throw new RuntimeException(ThrowableUtil.getAllMessages(t)); } @@ -83,7 +91,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen try { Subject user = getSessionSubject(); group = groupManager.createResourceGroup(user, group); - groupManager.setMembership(user, group.getId(), resourceIds, true); + groupManager.setAssignedResources(user, group.getId(), resourceIds, true); return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup"); } catch (Throwable t) { throw new RuntimeException(ThrowableUtil.getAllMessages(t)); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java index 87d9132..7b278e1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java @@ -18,7 +18,6 @@ */ package org.rhq.enterprise.gui.coregui.server.gwt;
-import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Role; import org.rhq.core.domain.criteria.RoleCriteria; import org.rhq.core.domain.util.PageList; @@ -34,20 +33,17 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
private RoleManagerLocal roleManager = LookupUtil.getRoleManager();
- public PageList<Role> findRolesByCriteria(RoleCriteria criteria) { return SerialUtility.prepare(roleManager.findRolesByCriteria(getSessionSubject(), criteria), - "RoleService.findRolesByCriteria"); + "RoleService.findRolesByCriteria"); }
public Role createRole(Role role) { - return SerialUtility.prepare(roleManager.createRole(getSessionSubject(), role), - "RoleService.createRole"); + return SerialUtility.prepare(roleManager.createRole(getSessionSubject(), role), "RoleService.createRole"); }
public Role updateRole(Role role) { - return SerialUtility.prepare(roleManager.updateRole(getSessionSubject(), role), - "RoleService.updateRole"); + return SerialUtility.prepare(roleManager.updateRole(getSessionSubject(), role), "RoleService.updateRole"); }
public void removeRoles(Integer[] roleIds) { @@ -62,8 +58,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW roleManager.setAssignedSubjects(getSessionSubject(), roleId, subjectIds); }
- - public void setAssignedSubjectRoles(int subjectId, int[] roleIds) { + public void setAssignedRolesForSubject(int subjectId, int[] roleIds) { roleManager.setAssignedSubjectRoles(getSessionSubject(), subjectId, roleIds); } } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java index ce68440..c9b4420 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java @@ -721,7 +721,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage // This ensures Hibernate actually fetches the parent Resource. grandchildResource.getParentResource().getId(); } - } + } }
return result; @@ -2126,7 +2126,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage @SuppressWarnings("unchecked") public PageList<Resource> findResourcesByCriteria(Subject subject, ResourceCriteria criteria) { CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria); - ; + if (authorizationManager.isInventoryManager(subject) == false) { if (criteria.isInventoryManagerRequired()) { throw new PermissionException("Subject [" + subject.getName() @@ -2138,8 +2138,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage }
CriteriaQueryRunner<Resource> queryRunner = new CriteriaQueryRunner(criteria, generator, entityManager); - - return queryRunner.execute(); + PageList<Resource> results = queryRunner.execute(); + return results; }
public Resource getPlaformOfResource(Subject subject, int resourceId) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java index 4aaf7ca..b210e31 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java @@ -138,7 +138,7 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe try { // You are allowed to cause the creation of an auto cluster backing group as long as you can // view the parent group. (That check was done above) - resourceGroupManager.setMembership(subjectManager.getOverlord(), autoClusterBackingGroup.getId(), + resourceGroupManager.setAssignedResources(subjectManager.getOverlord(), autoClusterBackingGroup.getId(), resourceIds, false); } catch (Exception e) { log.error("Could not add resources to group:" + e); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java index 28ae218..3acae10 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java @@ -1296,9 +1296,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso return groupIds; }
- public void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType) + public void setAssignedResources(Subject subject, int groupId, int[] resourceIds, boolean setType) throws ResourceGroupDeleteException { - //throws ResourceGroupUpdateException { + List<Integer> currentMembers = resourceManager.findExplicitResourceIdsByResourceGroup(groupId);
List<Integer> newMembers = ArrayUtils.wrapInList(resourceIds); // members needing addition @@ -1319,6 +1319,40 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso } }
+ public void setAssignedResourceGroupsForResource(Subject subject, int resourceId, int[] resourceGroupIds, + boolean setType) throws ResourceGroupDeleteException { + + Resource resource = entityManager.find(Resource.class, resourceId); + Set<ResourceGroup> currentGroups = resource.getExplicitGroups(); + List<Integer> currentGroupIds = new ArrayList<Integer>(currentGroups.size()); + for (ResourceGroup currentGroup : currentGroups) { + currentGroupIds.add(currentGroup.getId()); + } + + int[] resourceIdArr = new int[] { resourceId }; + + List<Integer> addedGroupIds = ArrayUtils.wrapInList(resourceGroupIds); + addedGroupIds.removeAll(currentGroupIds); + for (Integer addedGroupId : addedGroupIds) { + addResourcesToGroup(subject, addedGroupId, resourceIdArr); + // As a result of the membership change ensure that the group type is set correctly. + if (setType) { + setResourceType(addedGroupId); + } + } + + List<Integer> removedGroupIds = new ArrayList<Integer>(currentGroupIds); // groups needing removal + removedGroupIds.removeAll(ArrayUtils.wrapInList(resourceGroupIds)); + for (Integer removedGroupId : removedGroupIds) { + removeResourcesFromGroup(subject, removedGroupId, resourceIdArr); + // As a result of the membership change ensure that the group type is set correctly. + if (setType) { + setResourceType(removedGroupId); + } + } + + } + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Remote interface impl // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java index 45f7cc4..de96dbf 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java @@ -118,7 +118,23 @@ public interface ResourceGroupManagerLocal { * @throws ResourceGroupUpdateException * @throws ResourceGroupDeleteException */ - void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType) + void setAssignedResources(Subject subject, int groupId, int[] resourceIds, boolean setType) + throws ResourceGroupUpdateException, ResourceGroupDeleteException; + + /** + * This method ensures that the resource will have exactly the specified set of explicit group + * membership. Make sure you pass the correct value for the <setType> parameter. + * + * @param subject + * @param resourceId + * @param resourceGroupIds + * @param setType Set to false if addition or removal of the specified resourceId will not alter the group + * type for the specified resource groups (compatible or mixed). Set true to have the group type + * (re)set automatically, based on the new group membership. + * @throws ResourceGroupUpdateException + * @throws ResourceGroupDeleteException + */ + void setAssignedResourceGroupsForResource(Subject subject, int groupId, int[] resourceIds, boolean setType) throws ResourceGroupUpdateException, ResourceGroupDeleteException;
void uninventoryMembers(Subject subject, int groupId);
commit fe4cc406e8b82ba6b8d78d9e0d22440ebbaa432b Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 21 11:15:06 2010 -0400
tabs/subtabs that are not applicable to a Resource or group's type are no longer shown; tabs/subtabs that are not available due to lack of authz permissions are grayed out / disabled
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java index 1739a35..1d6134b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java @@ -21,12 +21,14 @@ package org.rhq.enterprise.gui.coregui.client.components.tab;
import com.smartgwt.client.widgets.Canvas;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable; + /** * Simple class to provide a SubTab a locatorId. * * @author Jay Shaughnessy */ -public class SubTab { +public class SubTab implements Locatable { private String locatorId; private String title; private Canvas canvas; @@ -54,6 +56,11 @@ public class SubTab { }
@Override + public String extendLocatorId(String extension) { + return this.locatorId + "_" + extension; + } + + @Override public String toString() { return "SubTab[title=" + this.title + ", locatorId=" + this.locatorId + "]"; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java index 741d931..0005436 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java @@ -155,7 +155,9 @@ public class SubTabLayout extends LocatableVLayout { }
public void unregisterAllSubTabs() { + destroyViews(); subtabs.clear(); + markForRedraw(); }
public void registerSubTab(SubTab subTab) { @@ -167,6 +169,21 @@ public class SubTabLayout extends LocatableVLayout { subtabs.put(locatorId, subTab); }
+ public void setVisible(SubTab subTab, boolean visible) { + Button button = this.subTabButtons.get(subTab.getLocatorId()); + if (visible) { + if (!button.isVisible()) { + button.show(); + markForRedraw(); + } + } else { + if (button.isVisible()) { + button.hide(); + markForRedraw(); + } + } + } + public SubTab getDefaultSubTab() { // the default subtab is the first one in the set that is not disabled for (SubTab subtab : this.subtabs.values()) { @@ -218,6 +235,16 @@ public class SubTabLayout extends LocatableVLayout { return null; }
+ public SubTab getSubTabByLocatorId(String locatorId) { + for (String subtabLocatorId : this.subtabs.keySet()) { + if (subtabLocatorId.equals(locatorId)) { + return this.subtabs.get(subtabLocatorId); + } + } + + return null; + } + public boolean selectSubTabByTitle(String title) { SubTab subtab = getSubTabByTitle(title); if (subtab == null) { @@ -264,6 +291,7 @@ public class SubTabLayout extends LocatableVLayout { for (SubTab subtab : subtabs.values()) { if (subtab.getCanvas() != null) { subtab.getCanvas().destroy(); + subtab.setCanvas(null); } } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java index 6258e9e..cbb6370 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java @@ -44,6 +44,10 @@ public class TwoLevelTab extends LocatableTab { } }
+ public void setVisible(SubTab subTab, boolean visible) { + layout.setVisible(subTab, visible); + } + public void setSubTabEnabled(String locatorId, boolean enabled) { if (enabled) { layout.enableSubTab(locatorId); @@ -56,6 +60,10 @@ public class TwoLevelTab extends LocatableTab { return this.layout.getSubTabByTitle(title); }
+ public SubTab getSubTabByLocatorId(String locatorId) { + return this.layout.getSubTabByLocatorId(locatorId); + } + public SubTab getDefaultSubTab() { return this.layout.getDefaultSubTab(); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java index bdd1981..8f7452c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java @@ -87,6 +87,33 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo return this.titleBar; }
+ protected boolean updateTab(TwoLevelTab tab, boolean visible, boolean enabled) { + TwoLevelTab attachedTab = getTabSet().getTabByLocatorId(tab.getLocatorId()); + if (visible) { + if (attachedTab == null) { + getTabSet().addTab(tab); + attachedTab = getTabSet().getTabByLocatorId(tab.getLocatorId()); + } + getTabSet().setTabEnabled(attachedTab, enabled); + } else { + if (attachedTab != null) { + getTabSet().removeTab(attachedTab); + } + } + + return enabled; + } + + protected void updateSubTab(TwoLevelTab tab, SubTab subTab, Canvas canvas, boolean visible, boolean enabled) { + tab.setVisible(subTab, visible); + if (visible) { + tab.setSubTabEnabled(subTab.getLocatorId(), enabled); + if (enabled) { + subTab.setCanvas(canvas); + } + } + } + public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { //CoreGUI.printWidgetTree();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 6603a00..f085e9b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -56,6 +56,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp * Be able to view members as a resource list, or edit members via selector. * * @author Jay Shaughnessy + * @author Ian Springer */ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> { private static final String BASE_VIEW_PATH = "ResourceGroup"; @@ -177,84 +178,82 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
protected void updateTabContent(ResourceGroupComposite groupComposite) { this.groupComposite = groupComposite; - - getTitleBar().setGroup(groupComposite.getResourceGroup()); + ResourceGroup group = groupComposite.getResourceGroup(); + int groupId = group.getId(); + getTitleBar().setGroup(group);
for (Tab top : this.getTabSet().getTabs()) { ((TwoLevelTab) top).getLayout().destroyViews(); }
+ GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory(); + Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets(); + // FullHTMLPane timelinePane = new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()); // summaryTab.updateSubTab("Overview", new DashboardView(resource)); // summaryTab.updateSubTab("Timeline", timelinePane); - this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("Overview"), - this.groupComposite)); - - int groupId = this.groupComposite.getResourceGroup().getId(); - - this.monitorGraphs.setCanvas(new FullHTMLPane("/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId)); - this.monitorTables.setCanvas(new FullHTMLPane("/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId)); - this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId)); - this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId)); - this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId)); + // Summary tab is always visible and enabled. + updateSubTab(this.summaryTab, this.summaryOverview, + new OverviewView(this.summaryTab.extendLocatorId("Overview"), this.groupComposite), true, true); + + if (updateTab(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE, true)) { + updateSubTab(this.monitoringTab, this.monitorGraphs, + new FullHTMLPane("/rhq/group/monitor/graphs-plain.xhtml?groupId=" + groupId), + hasMetricsOfType(this.groupComposite, DataType.MEASUREMENT), true); + updateSubTab(this.monitoringTab, this.monitorTables, + new FullHTMLPane("/rhq/group/monitor/tables-plain.xhtml?groupId=" + groupId), + hasMetricsOfType(this.groupComposite, DataType.MEASUREMENT), true); + updateSubTab(this.monitoringTab, this.monitorTraits, + new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId), + hasMetricsOfType(this.groupComposite, DataType.TRAIT), true); + updateSubTab(this.monitoringTab, this.monitorSched, + new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId), + hasMetricsOfType(this.groupComposite, null), true); + updateSubTab(this.monitoringTab, this.monitorCallTime, + new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId), + facets.contains(ResourceTypeFacet.CALL_TIME), true); + // TODO (ips): Add Availability subtab. + }
- this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(this.inventoryTab - .extendLocatorId("MembersView"), groupId)); + // Inventory tab is always visible and enabled. + updateSubTab(this.inventoryTab, this.inventoryMembers, + ResourceSearchView.getMembersOf(this.inventoryMembers.extendLocatorId("View"), groupId), true, true); // TODO: Uncomment this once the group config component is done. - //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin)); - this.inventoryMembership.setCanvas(new ResourceGroupMembershipView(this.inventoryTab - .extendLocatorId("MembershipView"), groupId)); - - this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" - + groupId)); - this.opSched.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" - + groupId)); - - this.alertHistory.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" - + groupId)); - this.alertDef.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" - + groupId)); - - this.configCurrent.setCanvas(new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" - + groupId)); - this.configHistory - .setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId)); - - this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite)); - - updateTabEnablement(); - } - - private void updateTabEnablement() { - GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory(); - Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets(); - - // Summary and Inventory tabs are always enabled. - - // Only enable "Call Time" and "Traits" subtabs for groups that implement them. - this.monitoringTab.setSubTabEnabled(this.monitorTraits.getLocatorId(), hasTraits(this.groupComposite)); - this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets - .contains(ResourceTypeFacet.CALL_TIME)); - - // Inventory>Connection Settings subtab is only enabled for compat groups that define conn props. - this.inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE - && facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); - - // Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups. - // TODO (ips): Break out mixed groups into a separate view. - getTabSet().setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE); - getTabSet().setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE); + //updateSubTab(this.inventoryTab, this.inventoryConn, + // new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin), + // facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true); + updateSubTab(this.inventoryTab, this.inventoryMembership, + new ResourceGroupMembershipView(this.inventoryTab.extendLocatorId("MembershipView"), groupId), true, true); + + if (updateTab(this.operationsTab, + groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.OPERATION), true)) { + updateSubTab(this.operationsTab, this.opHistory, + new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true); + updateSubTab(this.operationsTab, this.opSched, + new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId), true, true); + }
- // Operations tab is only enabled for compatible groups of a type that supports the Operations facet. - getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); + if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE, true)) { + updateSubTab(this.alertsTab, this.alertHistory, + new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" + groupId), true, true); + updateSubTab(this.alertsTab, this.alertDef, + new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" + groupId), true, true); + }
- // Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet - // and when the current user has the CONFIGURE_READ permission. - getTabSet().setTabEnabled(this.configurationTab, - facets.contains(ResourceTypeFacet.CONFIGURATION) && this.permissions.isConfigureRead()); + if (updateTab(this.configurationTab, + groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.CONFIGURATION), + this.permissions.isConfigureRead())) { + updateSubTab(this.configurationTab, this.configCurrent, + new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" + groupId), true, true); + updateSubTab(this.configurationTab, this.configHistory, + new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId), true, true); + }
- // Events tab is only enabled for compatible groups of a type that supports the Events facet. - getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); + if (updateTab(this.eventsTab, + groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.EVENT), true)) { + updateSubTab(this.eventsTab, this.eventHistory, + EventCompositeHistoryView.get(groupComposite), true, true); + } }
protected void loadSelectedItem(final int groupId, final ViewPath viewPath) { @@ -313,12 +312,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource } }
- private static boolean hasTraits(ResourceGroupComposite groupComposite) { + private static boolean hasMetricsOfType(ResourceGroupComposite groupComposite, DataType dataType) { ResourceType type = groupComposite.getResourceGroup().getResourceType(); if (type != null) { Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions(); for (MeasurementDefinition metricDef : metricDefs) { - if (metricDef.getDataType() == DataType.TRAIT) { + if (dataType == null || metricDef.getDataType() == dataType) { return true; } } @@ -332,5 +331,4 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource currentSubTab = subtabTitle; super.selectTab(tabTitle, subtabTitle, viewPath); } - } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index e80be32..88dd2f9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -182,95 +182,99 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
protected void updateTabContent(ResourceComposite resourceComposite) { this.resourceComposite = resourceComposite; - - final Resource resource = this.resourceComposite.getResource(); + Resource resource = this.resourceComposite.getResource(); getTitleBar().setResource(resource);
for (Tab top : this.getTabSet().getTabs()) { ((TwoLevelTab) top).getLayout().destroyViews(); }
- this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("OverviewView"), - this.resourceComposite)); - this.summaryDashboard.setCanvas(new DashboardView(this.resourceComposite)); - this.summaryTimeline.setCanvas(new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" - + resource.getId())); - - this.monitorGraphs.setCanvas(new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource)); - this.monitorTables.setCanvas(new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId())); - this.monitorTraits - .setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId())); - this.monitorAvail.setCanvas(new FullHTMLPane("/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" - + resource.getId())); - this.monitorSched - .setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId())); - this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" - + resource.getId())); - - this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource - .getId())); - this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource)); - - // comment out GWT-based operation history until... - // 1) user can delete history if they possess the appropriate permissions - // 2) user can see both operation arguments and results in the history details pop-up - // 3) operation arguments/results become read-only configuration data in the history details pop-up - // 4) user can navigate to the group operation that spawned this resource operation history, if appropriate - // note: enabled operation execution/schedules from left-nav, if it doesn't already exist - this.opHistory.setCanvas(OperationHistoryView.getResourceHistoryView(operationsTab.extendLocatorId("History"), - resourceComposite)); - this.opSched.setCanvas(new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" - + resource.getId())); + ResourcePermission permissions = this.resourceComposite.getResourcePermission(); + Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets(); + + updateSubTab(this.summaryTab, this.summaryOverview, + new OverviewView(this.summaryOverview.getLocatorId(), this.resourceComposite), true, true); + updateSubTab(this.summaryTab, this.summaryDashboard, + new DashboardView(this.resourceComposite), true, true); + updateSubTab(this.summaryTab, this.summaryTimeline, + new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()), true, true); + + updateSubTab(this.monitoringTab, this.monitorGraphs, + new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource), + hasMetricsOfType(this.resourceComposite, DataType.MEASUREMENT), true); + updateSubTab(this.monitoringTab, this.monitorTables, + new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()), + hasMetricsOfType(this.resourceComposite, DataType.MEASUREMENT), true); + updateSubTab(this.monitoringTab, this.monitorTraits, + new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId()), + hasMetricsOfType(this.resourceComposite, DataType.TRAIT), true); + updateSubTab(this.monitoringTab, this.monitorAvail, + new FullHTMLPane("/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" + resource.getId()), true, + true); + updateSubTab(this.monitoringTab, this.monitorSched, + new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId()), + hasMetricsOfType(this.resourceComposite, null), true); + updateSubTab(this.monitoringTab, this.monitorCallTime, + new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId()), + facets.contains(ResourceTypeFacet.CALL_TIME), true); + + ResourceType type = this.resourceComposite.getResource().getResourceType(); + updateSubTab(this.inventoryTab, this.inventoryChildren, + ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource.getId()), + !type.getChildResourceTypes().isEmpty(), true); + updateSubTab(this.inventoryTab, this.inventoryConn, + new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource), + facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true); + + if (updateTab(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION), true)) { + // comment out GWT-based operation history until... + // 1) user can delete history if they possess the appropriate permissions + // 2) user can see both operation arguments and results in the history details pop-up + // 3) operation arguments/results become read-only configuration data in the history details pop-up + // 4) user can navigate to the group operation that spawned this resource operation history, if appropriate + // note: enabled operation execution/schedules from left-nav, if it doesn't already exist + updateSubTab(this.operationsTab, this.opHistory, + OperationHistoryView.getResourceHistoryView(operationsTab.extendLocatorId("History"), this.resourceComposite), + true, true); + updateSubTab(this.operationsTab, this.opSched, + new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId()), + true, true); + }
// comment out GWT-based alert definitions/history views until... // 1) new workflow is implement for alert definition creation, with particular attention to interaction model for alert notifications // 2) user can delete/ack/purgeAll alerts if they possess the appropriate permissions // 3) user can enable/disable/delete alert definitions if they possess the appropriate permissions // 4) user can search alert history by: date alert was fired, alert priority, or alert definition - this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" - + resource.getId())); - this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("AlertDef"), - resourceComposite)); - this.alertDelete.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" - + resource.getId())); - - this.configCurrent - .setCanvas(new ResourceConfigurationEditView(this.extendLocatorId("ResourceConfig"), resource)); - this.configHistory.setCanvas(ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"), - resource.getId())); - - this.eventHistory.setCanvas(EventCompositeHistoryView.get(resourceComposite)); - - this.contentDeployed - .setCanvas(new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId())); - this.contentNew.setCanvas(new FullHTMLPane("/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId())); - this.contentSubscrip.setCanvas(new FullHTMLPane("/rhq/resource/content/subscription-plain.xhtml?id=" - + resource.getId())); - this.contentHistory.setCanvas(new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id=" - + resource.getId())); - - updateTabEnablement(); - } - - private void updateTabEnablement() { - ResourcePermission permissions = this.resourceComposite.getResourcePermission(); - Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets(); - - // Summary, Monitoring, Inventory, and Alerts tabs are always enabled. - - monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.resourceComposite)); - monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME)); + updateSubTab(this.alertsTab, this.alertHistory, + new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" + resource.getId()), true, true); + updateSubTab(this.alertsTab, this.alertDef, + new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("AlertDef"), this.resourceComposite), true, true); + updateSubTab(this.alertsTab, this.alertDelete, + new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" + resource.getId()), true, true); + + if (updateTab(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION), permissions.isConfigureRead())) { + updateSubTab(this.configurationTab, this.configCurrent, + new ResourceConfigurationEditView(this.extendLocatorId("ResourceConfig"), resource), true, true); + updateSubTab(this.configurationTab, this.configHistory, + ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"), resource.getId()), true, true); + }
- inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets - .contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); - ResourceType type = this.resourceComposite.getResource().getResourceType(); - inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty()); + if (updateTab(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT), true)) { + updateSubTab(this.eventsTab, this.eventHistory, + EventCompositeHistoryView.get(resourceComposite), true, true); + }
- getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); - getTabSet().setTabEnabled(this.configurationTab, - facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); - getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); - getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT)); + if (updateTab(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT), true)) { + updateSubTab(this.contentTab, this.contentDeployed, + new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()), true, true); + updateSubTab(this.contentTab, this.contentNew, + new FullHTMLPane("/rhq/resource/content/deploy-plain.xhtml?id=" + resource.getId()), true, true); + updateSubTab(this.contentTab, this.contentSubscrip, + new FullHTMLPane("/rhq/resource/content/subscription-plain.xhtml?id=" + resource.getId()), true, true); + updateSubTab(this.contentTab, this.contentHistory, + new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id=" + resource.getId()), true, true); + } }
public Integer getSelectedItemId() { @@ -324,11 +328,11 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo }); }
- private static boolean hasTraits(ResourceComposite resourceComposite) { + private static boolean hasMetricsOfType(ResourceComposite resourceComposite, DataType dataType) { ResourceType type = resourceComposite.getResource().getResourceType(); Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions(); for (MeasurementDefinition metricDef : metricDefs) { - if (metricDef.getDataType() == DataType.TRAIT) { + if (dataType == null || metricDef.getDataType() == dataType) { return true; } }
commit 31a27cb1807ea2e0ae258d996ce968ec0f730135 Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 21 11:10:38 2010 -0400
comment out some code that was causing the following unit test failure:
Tests run: 3, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 863.162 sec <<< FAILURE! beforeClass(org.rhq.core.pc.inventory.ResourceContainerTest) Time elapsed: 0 sec <<< FAILURE! java.lang.RuntimeException: Cannot initialize the plugin container at org.rhq.core.pc.plugin.PluginManager.initialize(PluginManager.java:173) at org.rhq.core.pc.PluginContainer.startContainerService(PluginContainer.java:391) at org.rhq.core.pc.PluginContainer.initialize(PluginContainer.java:252) at org.rhq.core.pc.inventory.ResourceContainerTest.beforeClass(ResourceContainerTest.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:607) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:417) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:154) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:88) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:167) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104) at org.testng.TestRunner.runWorkers(TestRunner.java:759) at org.testng.TestRunner.privateRun(TestRunner.java:592) at org.testng.TestRunner.run(TestRunner.java:486) at org.testng.SuiteRunner.runTest(SuiteRunner.java:332) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299) at org.testng.SuiteRunner.run(SuiteRunner.java:204) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:877) at org.testng.TestNG.runSuitesLocally(TestNG.java:842) at org.testng.TestNG.run(TestNG.java:751) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141) at org.apache.maven.surefire.Surefire.run(Surefire.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021) Caused by: org.rhq.core.clientapi.agent.PluginContainerException: A valid plugin JAR URL must be supplied. at org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(AgentPluginDescriptorUtil.java:296) at org.rhq.core.pc.plugin.PluginDescriptorLoader.loadPluginDescriptor(PluginDescriptorLoader.java:67) at org.rhq.core.pc.plugin.PluginManager.loadPlugin(PluginManager.java:316) at org.rhq.core.pc.plugin.PluginManager.initialize(PluginManager.java:168) ... 32 more
Results :
Failed tests: beforeClass(org.rhq.core.pc.inventory.ResourceContainerTest)
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java index 2c64ff1..d9976cb 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java @@ -163,9 +163,11 @@ public class PluginManager implements ContainerService { }
} else { + // TODO (ips, 10/21/10): I don't think this block of code is needed any longer. I am commenting it for + // now, but it should eventually be deleted. // Loading a null plugin loads the plugin using the current classloader (for unit test testing) - log.info("Loading the null plugin which uses non-isolated classloader"); - loadPlugin(null, thisClassLoader); + //log.info("Loading the null plugin which uses non-isolated classloader"); + //loadPlugin(null, thisClassLoader); } } catch (Exception e) { shutdown(); // have to clean up the environments (e.g. unpacked jars) we might have already created @@ -379,7 +381,6 @@ public class PluginManager implements ContainerService { * * @param pluginName the name of the plugin to obtain dependency URLs for * @param pluginNamesUrls map of all known plugin names and their plugin jar URLs - * @param graph the dependency graph * @param allUrls where the results will be stored * * TODO: Use it or lose it - this used to be needed, keeping this around just in case it needs to be resurrected
commit f742f93aabcfe099c727c4eb6b3fbde55f8baf53 Author: Ian Springer ian.springer@redhat.com Date: Mon Sep 20 23:43:29 2010 -0400
pluralize autogroup and subcategory names in the Resource tree (https://bugzilla.redhat.com/show_bug.cgi?id=587631)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java index 9d7f395..0862d3a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java @@ -262,8 +262,9 @@ public class ResourceTreeDatasource extends DataSource { setParentID(parentResourceId); setAttribute("parentId", parentResourceId);
- setName(category.getDisplayName()); - setAttribute("name", category.getDisplayName()); + String name = pluralize(category.getDisplayName()); + setName(name); + setAttribute("name", name); } }
@@ -285,7 +286,7 @@ public class ResourceTreeDatasource extends DataSource {
// setAttribute("parentKey", parentId);
- String name = type.getName(); + String name = pluralize(type.getName()); setName(name); setAttribute("name", name); } @@ -358,4 +359,9 @@ public class ResourceTreeDatasource extends DataSource { private static String fixId(String id) { return id.replace(' ', '_'); } + + private static String pluralize(String s) { + // TODO: Make this smarter. + return s + "s"; + } }
commit 981dad09ee03eb74c3752900a036f03c93aac522 Merge: c443dbc... 73c0d37... Author: Heiko W. Rupp hwr@redhat.com Date: Tue Sep 21 16:29:50 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit c443dbcd87339ccbb859c7ee4fef8576929c82f0 Author: Heiko W. Rupp hwr@redhat.com Date: Tue Sep 21 15:41:27 2010 +0200
Disable here, as it is broken and development goes on in the perftest branch for now.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java index a289960..fdd5f6a 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java @@ -44,7 +44,7 @@ import org.testng.annotations.Test; * * @author Heiko W. Rupp */ -@Test(groups = "PERF") +@Test(groups = "PERF", enabled = false) public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
private final Log log = LogFactory.getLog(AvailabilityInsertPurgeTest.class);
commit 73c0d3779b57b45b62ae592a77024dd476b8c645 Author: Simeon Pinder spinder@redhat.com Date: Tue Sep 21 08:40:46 2010 -0400
RecentAlerts config changes and some modifications to super classes for reuse.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java index a639fca..d21ab76 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java @@ -7,10 +7,15 @@ import com.smartgwt.client.rpc.RPCResponse;
import org.rhq.core.domain.alert.Alert; import org.rhq.core.domain.alert.AlertPriority; +import org.rhq.core.domain.configuration.Property; +import org.rhq.core.domain.configuration.PropertyList; +import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.criteria.AlertCriteria; +import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
public class AlertPortletDataSource extends AlertDataSource { //configuration attributes @@ -19,12 +24,50 @@ public class AlertPortletDataSource extends AlertDataSource { private long alertTimeRange = -1; private String alertResourcesToUse = "all"; private Integer[] alertFilterResourceIds = {}; + private DashboardPortlet portlet = null; + + public AlertPortletDataSource() { + super(); + } + + public AlertPortletDataSource(DashboardPortlet recentAlertsPortlet) { + super(); + this.portlet = recentAlertsPortlet; + }
/** Override the executeFetch for AlertPortlet to allow specifying smaller than total * result displays. */ protected void executeFetch(final DSRequest request, final DSResponse response) { final long start = System.currentTimeMillis(); + //retrieve previous settings from portlet config + if ((portlet != null) && (this.portlet instanceof DashboardPortlet)) { + //must check for whether portlet config + PropertySimple property = portlet.getConfiguration().getSimple( + RecentAlertsPortlet.ALERT_RANGE_RESOURCES_VALUE); + if ((property != null) && (property.getStringValue() != null)) { + //retrieve and translate to int + String retrieved = property.getStringValue(); + if (retrieved.trim().equalsIgnoreCase(RecentAlertsPortlet.RESOURCES_SELECTED)) { + setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_SELECTED); + } else { + setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_ALL); + } + //if 'selected' then check for previously set resource ids to filter on + if (getAlertResourcesToUse().equals(RecentAlertsPortlet.RESOURCES_SELECTED)) { + Integer[] alertResourceFilterIds = null; + alertResourceFilterIds = extractFilterResourceIds(portlet, alertResourceFilterIds); + if (alertFilterResourceIds != null) { + setAlertFilterResourceId(alertFilterResourceIds); + } + } + } else {//create setting + portlet.getConfiguration().put( + new PropertySimple(RecentAlertsPortlet.ALERT_RANGE_RESOURCES_VALUE, + RecentAlertsPortlet.defaultResourceValue)); + setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_ALL); + } + }
AlertCriteria criteria = new AlertCriteria(); criteria.fetchAlertDefinition(true); @@ -34,7 +77,8 @@ public class AlertPortletDataSource extends AlertDataSource { PageControl pc = new PageControl(0, getAlertRangeCompleted()); criteria.setPageControl(pc);//display per page criteria.addFilterStartTime(getAlertTimeRange());//alert age - if (getAlertResourcesToUse().equalsIgnoreCase("selected")) { + if ((getAlertResourcesToUse().equalsIgnoreCase(RecentAlertsPortlet.RESOURCES_SELECTED)) + && (getAlertFilterResourceIds().length > 0)) { //add resource ids to filter on criteria.addFilterResourceIds(getAlertFilterResourceIds()); } @@ -99,4 +143,25 @@ public class AlertPortletDataSource extends AlertDataSource { public void setAlertFilterResourceId(Integer[] alertFilterResourceId) { this.alertFilterResourceIds = alertFilterResourceId; } + + public Integer[] extractFilterResourceIds(DashboardPortlet storedPortlet, Integer[] filterResourceIds) { + PropertyList propertyList = storedPortlet.getConfiguration().getList( + RecentAlertsPortlet.ALERT_RANGE_RESOURCE_IDS); + if ((propertyList != null) && (propertyList.getList() != null) && (!propertyList.getList().isEmpty()) + && (propertyList.getList().get(0) != null)) { + Property container = propertyList.getList().get(0); + if (container instanceof PropertyList) { + PropertyList anotherList = (PropertyList) container; + if (anotherList.getList() != null) { + filterResourceIds = new Integer[anotherList.getList().size()]; + int index = 0; + for (Property p : anotherList.getList()) { + filterResourceIds[index++] = ((PropertySimple) p).getIntegerValue(); + } + } + } + } + return filterResourceIds; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java index 1c8774f..e5a9d1f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java @@ -182,6 +182,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout { updateButtons(); } }); + removeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { deselect(assignedGrid.getSelection()); @@ -265,6 +266,16 @@ public abstract class AbstractSelector<T> extends LocatableVLayout { addMember(hlayout); }
+ protected ClickHandler getAddButtonClickHandler() { + return new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + assignedGrid.transferSelectedData(availableGrid); + select(assignedGrid.getSelection()); + updateButtons(); + } + }; + } + @Override protected void onDestroy() { super.onDestroy(); @@ -310,4 +321,16 @@ public abstract class AbstractSelector<T> extends LocatableVLayout { } availableGrid.markForRedraw(); } + + public LocatableListGrid getAvailableGrid() { + return availableGrid; + } + + public LocatableListGrid getAssignedGrid() { + return assignedGrid; + } + + // public TransferImgButton getAddButton() { + // return addButton; + // } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java index 9e0ee74..c3dea19 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java @@ -223,13 +223,13 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView DashboardPortlet discoveryQueue = new DashboardPortlet("Discovery Queue", AutodiscoveryPortlet.KEY, 250); dashboard.addPortlet(discoveryQueue, 1, 2);
- DashboardPortlet recentAlerts = new DashboardPortlet("Recent Alerts", RecentAlertsPortlet.KEY, 250); + DashboardPortlet recentAlerts = new DashboardPortlet(RecentAlertsPortlet.KEY, RecentAlertsPortlet.KEY, 250); dashboard.addPortlet(recentAlerts, 1, 3);
DashboardPortlet recentlyAdded = new DashboardPortlet("Recently Added Resources", RecentlyAddedView.KEY, 250); dashboard.addPortlet(recentlyAdded, 1, 4);
- DashboardPortlet operations = new DashboardPortlet("Operations", OperationsPortlet.KEY, 250); + DashboardPortlet operations = new DashboardPortlet("Operations", OperationsPortlet.KEY, 500); dashboard.addPortlet(operations, 1, 5);
DashboardPortlet problemResources = new DashboardPortlet("Has Alerts or Currently Unavailable", diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java index c1a4ef9..f88f949 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java @@ -19,6 +19,9 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
import com.smartgwt.client.data.Criteria; +import com.smartgwt.client.data.Record; +import com.smartgwt.client.data.RecordList; +import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; @@ -27,24 +30,34 @@ import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.SpacerItem; import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.events.DataArrivedEvent; +import com.smartgwt.client.widgets.grid.events.DataArrivedHandler; +import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.alert.AlertPriority; +import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletDataSource; import org.rhq.enterprise.gui.coregui.client.alert.AlertsView; import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.wizard.GroupMembersStep; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector; import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
/** + * @author Simeon Pinder * @author Greg Hinkle */ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPortlet { @@ -52,10 +65,11 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor public static final String KEY = "Recent Alerts"; public static final String TITLE = KEY; //widget keys also used in form population - private static final String ALERT_RANGE_DISPLAY_AMOUNT_VALUE = "alert-range-display-amount-value"; - private static final String ALERT_RANGE_PRIORITY_VALUE = "alert-range-priority-value"; - private static final String ALERT_RANGE_TIME_VALUE = "alert-range-time-value"; - private static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value"; + public static final String ALERT_RANGE_DISPLAY_AMOUNT_VALUE = "alert-range-display-amount-value"; + public static final String ALERT_RANGE_PRIORITY_VALUE = "alert-range-priority-value"; + public static final String ALERT_RANGE_TIME_VALUE = "alert-range-time-value"; + public static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value"; + public static final String ALERT_RANGE_RESOURCE_IDS = "alert-range-resource-ids"; //configuration default information private static final String defaultAlertCountValue = "5"; private static final String PRIORITY_ALL = "ALL"; @@ -70,16 +84,24 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor private static final String TIME_WEEK = "week"; private static final String TIME_MONTH = "month"; private static final String defaultTimeValue = TIME_DAY; - private static final String RESOURCES_ALL = "all resources"; - private static final String RESOURCES_SELECTED = "selected resources"; - private static final String defaultResourceValue = RESOURCES_ALL; + public static final String RESOURCES_ALL = "all resources"; + public static final String RESOURCES_SELECTED = "selected resources"; + public static final String defaultResourceValue = RESOURCES_ALL; private static final String unlimited = "unlimited"; - //configuration container element + //alert resource labels + public static final String ALERT_LABEL_SELECTED_RESOURCES = "Selected Resources"; + public static final String ALERT_LABEL_AVAILABLE_RESOURCES = "Available Resources"; + public static final String ALERT_LABEL_RESOURCE_INVENTORY = "Resource Inventory"; + public static final int ALERT_RESOURCE_SELECTION_WIDTH = 800; + public static final String ID = "id"; + //shared private UI elements + private AlertResourceSelectorRegion resourceSelector; private DashboardPortlet storedPortlet = null; private AlertPortletDataSource dataSource; + private Canvas containerCanvas; + private HLayout resourceSelectionLabelRow;
public RecentAlertsPortlet(String locatorId) { - // super(locatorId); this(locatorId, null, null);
setShowHeader(false); @@ -106,7 +128,6 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor //retrieve and translate to int String retrieved = property.getStringValue(); int translatedAlertRangeSelection = translatedAlertRangeSelection(retrieved); - // getDataSource().setAlertRangeCompleted(Integer.parseInt(retrieved)); getDataSource().setAlertRangeCompleted(translatedAlertRangeSelection); } else {//create setting storedPortlet.getConfiguration().put( @@ -143,13 +164,35 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor //retrieve and translate to int String retrieved = property.getStringValue(); if (retrieved.trim().equalsIgnoreCase(RESOURCES_SELECTED)) { - getDataSource().setAlertResourcesToUse("selected"); + getDataSource().setAlertResourcesToUse(RESOURCES_SELECTED); } else { - getDataSource().setAlertResourcesToUse("all"); + getDataSource().setAlertResourcesToUse(RESOURCES_ALL); } } else {//create setting storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue)); - getDataSource().setAlertResourcesToUse("all"); + getDataSource().setAlertResourcesToUse(RESOURCES_ALL); + } + + //resource ids to be conditionally included in the query + Integer[] filterResourceIds = null; + filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, filterResourceIds); + //no defaults + + if (filterResourceIds != null) { + getDataSource().setAlertFilterResourceId(filterResourceIds); + } + + //conditionally display the selected resources ui + if (containerCanvas != null) { + //empty out earlier canvas + for (Canvas c : containerCanvas.getChildren()) { + c.destroy(); + } + if ((resourceSelector != null) && getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) { + containerCanvas.addChild(resourceSelector.getCanvas()); + } else { + containerCanvas.addChild(new Canvas()); + } } }
@@ -222,8 +265,11 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor
//root dynamic form instance final DynamicForm form = new DynamicForm(); - form.setWidth(200); + form.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH + 40);//largest widget display + 40 for buttons + form.setHeight(450); + form.setMargin(5);
+ //vertical container VLayout column = new VLayout();
//label @@ -348,12 +394,29 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor alertResourcesComboBox.setType("selection"); String[] acceptableResourceDisplayValues = { RESOURCES_ALL, RESOURCES_SELECTED }; alertResourcesComboBox.setValueMap(acceptableResourceDisplayValues); - alertResourcesComboBox.setWidth(100); + alertResourcesComboBox.setWidth(150); alertResourcesComboBox.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { String selectedItem = "" + event.getValue(); //stuff into the master form for retrieval form.setValue(ALERT_RANGE_RESOURCES_VALUE, selectedItem); + //empty out earlier canvas + for (Canvas c : containerCanvas.getChildren()) { + c.destroy(); + } + if (selectedItem.equals(RESOURCES_SELECTED)) { + containerCanvas.addChild(resourceSelector.getCanvas()); + resourceSelectionLabelRow.setVisible(true); + for (Canvas c : resourceSelectionLabelRow.getMembers()) { + c.setVisible(true); + } + } else { + containerCanvas.addChild(new Canvas()); + resourceSelectionLabelRow.setVisible(false); + for (Canvas c : resourceSelectionLabelRow.getMembers()) { + c.setVisible(false); + } + } } });
@@ -379,8 +442,62 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor row2.addMember(alertRangeSpanLabel); row2.addMember(timeSelectionWrapper); row2.addMember(resourceSelectionWrapper); + + //Row 3 of labels for the alert selected resources area + resourceSelectionLabelRow = new HLayout(); + resourceSelectionLabelRow.setHeight(30); + resourceSelectionLabelRow.setMembersMargin(5); + resourceSelectionLabelRow.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH);//ui size + fixed button widths + Label availableResourcesLabel = new Label("<b>" + ALERT_LABEL_AVAILABLE_RESOURCES + "</b>"); + availableResourcesLabel.setHeight(20); + availableResourcesLabel.setWrap(false); + resourceSelectionLabelRow.addMember(availableResourcesLabel); + Label spacer = new Label(""); + spacer.setWidth(400); + Label selectedResourcesLabel = new Label("<b>" + ALERT_LABEL_SELECTED_RESOURCES + "</b>"); + selectedResourcesLabel.setHeight(20); + selectedResourcesLabel.setWrap(false); + resourceSelectionLabelRow.addMember(spacer); + resourceSelectionLabelRow.addMember(selectedResourcesLabel); + + //##### if portlet config setting exist, then retrieve############# + Integer[] alertFilterResourceIds = null; + alertFilterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, alertFilterResourceIds); + if (alertFilterResourceIds != null) { + getDataSource().setAlertFilterResourceId(alertFilterResourceIds); + } + + HLayout row4 = new HLayout(); + row4.setID("row4"); + // resourceSelector = new MemberSelect(); + resourceSelector = new AlertResourceSelectorRegion(alertFilterResourceIds); + row4.setWidth100(); + containerCanvas = new Canvas(); + String retProp = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE).getStringValue(); + + //reload the ResourceSelectionRegion if user has chosen to focus on specific resources with alerts + if (retProp.equals(RESOURCES_SELECTED)) { + containerCanvas.addChild(resourceSelector.getCanvas()); + } else { + containerCanvas.addChild(new Canvas()); + //iterate over children of row3 and make invisible + for (Canvas c : resourceSelectionLabelRow.getMembers()) { + c.setVisible(false); + } + } + //add contain resource selection region. + row4.addMember(containerCanvas); + + //finish construction of the layout column.addMember(row); column.addMember(row2); + SpacerItem verticalSpace = new SpacerItem(); + verticalSpace.setHeight(20); + DynamicForm spacerWrapper = new DynamicForm(); + spacerWrapper.setItems(verticalSpace); + column.addMember(spacerWrapper); + column.addMember(resourceSelectionLabelRow); + column.addMember(row4); form.addChild(column);
//submit handler @@ -390,12 +507,30 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor //no need to insert validation here as user not allowed to enter values parseFormAndPopulateConfiguration(form, storedPortlet, ALERT_RANGE_DISPLAY_AMOUNT_VALUE, ALERT_RANGE_PRIORITY_VALUE, ALERT_RANGE_RESOURCES_VALUE, ALERT_RANGE_TIME_VALUE); + + //retrieve alert-resource-selection property + PropertySimple prop = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE); + + //check to see if "Selected Resources" or "All Resources" + if (prop.getStringValue().equals(RESOURCES_SELECTED)) { + //retrieve currentlyAssignedIds + Integer[] valuesToPersist = resourceSelector.getListGridValues(); + resourceSelector.setCurrentlyAssignedIds(valuesToPersist); + + //build property list of ids to persist + PropertyList list = new PropertyList(ALERT_RANGE_RESOURCE_IDS); + for (int rid : resourceSelector.getCurrentlyAssignedIds()) { + list.add(new PropertySimple(ALERT_RANGE_RESOURCE_IDS, rid)); + } + storedPortlet.getConfiguration().put(new PropertyList(ALERT_RANGE_RESOURCE_IDS, list)); + getDataSource().setAlertFilterResourceId(resourceSelector.getCurrentlyAssignedIds()); + } refresh();// + markForRedraw(); } });
return form; - }
/**Iterates over DynamicForm instance to check for properties passed in and if they have been set @@ -428,3 +563,95 @@ public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPor } } } + +class CustomizedResourceSelector extends ResourceSelector { + public CustomizedResourceSelector(String id) { + super(id); + } + + public void addAvailableGridSelectionsToAssignedGrid() { + assignedGrid.transferSelectedData(availableGrid); + select(assignedGrid.getSelection()); + updateButtons(); + } +} + +class AlertResourceSelectorRegion extends GroupMembersStep { + // private ResourceSelector selector = null; + private CustomizedResourceSelector selector = null; + private ResourceType requireType = null; + private Integer[] currentlyAssignedIds; + + public Integer[] getCurrentlyAssignedIds() { + return currentlyAssignedIds; + } + + public Integer[] getListGridValues() { + Integer[] listGridValues = new Integer[0]; + if ((null != selector) && (null != selector.getAssignedGrid())) { + RecordList allRecords = selector.getAssignedGrid().getDataAsRecordList(); + if (allRecords.getLength() > 0) { + listGridValues = new Integer[allRecords.getLength()]; + for (int i = 0; i < allRecords.getLength(); i++) { + Record record = allRecords.get(i); + listGridValues[i] = record.getAttributeAsInt(RecentAlertsPortlet.ID); + } + } + } + return listGridValues; + } + + public AlertResourceSelectorRegion(Integer[] assigned) { + super(null); + this.currentlyAssignedIds = assigned; + } + + public Canvas getCanvas() { + ResourceType rt = ResourceType.ANY_PLATFORM_TYPE; + if ((selector == null) || (rt != requireType)) { + // selector = new ResourceSelector(getName()); + selector = new CustomizedResourceSelector(getName()); + selector.setWidth100(); + selector.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH); + selector.setRequireType(rt); + //widget ui updates + selector.getAvailableGrid().setTitle("Available Resources"); + selector.getAvailableGrid().setEmptyMessage("Loading data..."); + selector.getAssignedGrid().setTitle("Selected Resources"); + + //populate fields for grid. + ListGridField nameField = new ListGridField("name", "Name"); + ListGridField iconField = new ListGridField("icon", "icon", 50); + iconField.setImageURLPrefix("types/"); + iconField.setType(ListGridFieldType.ICON); + selector.getAssignedGrid().setFields(iconField, nameField); + + //add listener to AvailableGrid, to act after successfully populated. + selector.getAvailableGrid().addDataArrivedHandler(new DataArrivedHandler() { + @Override + public void onDataArrived(DataArrivedEvent event) { + if ((getCurrentlyAssignedIds() != null) && (getCurrentlyAssignedIds().length > 0)) { + //retrieve the loaded data and add to the table itself + RecordList recordList = selector.getAvailableGrid().getDataAsRecordList(); + for (int ci : getCurrentlyAssignedIds()) { + int located = recordList.findIndex("id", ci); + if (located > -1) { + selector.getAvailableGrid().selectRecord(located); + } + } + selector.addAvailableGridSelectionsToAssignedGrid(); + selector.getAssignedGrid().invalidateCache(); + selector.getAssignedGrid().markForRedraw(); + } else {//no selected resources found + selector.getAvailableGrid().setEmptyMessage("No items to show"); + } + } + }); + } + return selector; + } + + public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) { + this.currentlyAssignedIds = currentlyAssignedIds; + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java index 8a55ed7..71e6eee 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java @@ -85,7 +85,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> { }
public void executeFetch(final DSRequest request, final DSResponse response) { - ResourceCriteria criteria = getFetchCriteria(request);
resourceService.findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() { @@ -208,4 +207,8 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
return record; } + + public ResourceGWTServiceAsync getResourceService() { + return resourceService; + } }
commit a1bc4dae4211c6eadd0335dd362a582bcaa03240 Author: Simeon Pinder spinder@redhat.com Date: Thu Sep 16 16:13:46 2010 -0400
enable recent alerts config(minus resource selection) and table footer
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java index 33d32b3..61b58b7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java @@ -144,6 +144,7 @@ public class AlertDataSource extends RPCDataSource<Alert> { AlertCriteria criteria = getCriteria(request);
this.alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() { + public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Failed to fetch alerts data", caught); response.setStatus(RPCResponse.STATUS_FAILURE); @@ -153,7 +154,6 @@ public class AlertDataSource extends RPCDataSource<Alert> { public void onSuccess(PageList<Alert> result) { long fetchTime = System.currentTimeMillis() - start; System.out.println(result.size() + " alerts fetched in: " + fetchTime + "ms"); - response.setData(buildRecords(result)); // For paging to work, we have to specify size of full result set. response.setTotalRows(result.getTotalSize()); @@ -296,4 +296,8 @@ public class AlertDataSource extends RPCDataSource<Alert> { } }); } + + public AlertGWTServiceAsync getAlertService() { + return alertService; + } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java new file mode 100644 index 0000000..a639fca --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java @@ -0,0 +1,102 @@ +package org.rhq.enterprise.gui.coregui.client.alert; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.DSRequest; +import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.rpc.RPCResponse; + +import org.rhq.core.domain.alert.Alert; +import org.rhq.core.domain.alert.AlertPriority; +import org.rhq.core.domain.criteria.AlertCriteria; +import org.rhq.core.domain.util.PageControl; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; + +public class AlertPortletDataSource extends AlertDataSource { + //configuration attributes + private int alertRangeCompleted = -1; + private int alertPriorityIndex = -1; + private long alertTimeRange = -1; + private String alertResourcesToUse = "all"; + private Integer[] alertFilterResourceIds = {}; + + /** Override the executeFetch for AlertPortlet to allow specifying smaller than total + * result displays. + */ + protected void executeFetch(final DSRequest request, final DSResponse response) { + final long start = System.currentTimeMillis(); + + AlertCriteria criteria = new AlertCriteria(); + criteria.fetchAlertDefinition(true); + criteria.fetchRecoveryAlertDefinition(true); + // TODO: Uncomment the below once the bad performance of it has been fixed. + //criteria.fetchConditionLogs(true); + PageControl pc = new PageControl(0, getAlertRangeCompleted()); + criteria.setPageControl(pc);//display per page + criteria.addFilterStartTime(getAlertTimeRange());//alert age + if (getAlertResourcesToUse().equalsIgnoreCase("selected")) { + //add resource ids to filter on + criteria.addFilterResourceIds(getAlertFilterResourceIds()); + } + if (getAlertPriorityIndex() > 0) {//add priority selection + criteria.addFilterPriority(AlertPriority.getByLegacyIndex(getAlertPriorityIndex())); + } + + getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() { + + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to fetch alerts data", caught); + response.setStatus(RPCResponse.STATUS_FAILURE); + processResponse(request.getRequestId(), response); + } + + public void onSuccess(PageList<Alert> result) { + long fetchTime = System.currentTimeMillis() - start; + System.out.println(result.size() + " alerts fetched in: " + fetchTime + "ms"); + response.setData(buildRecords(result)); + response.setTotalRows(result.size()); + processResponse(request.getRequestId(), response); + } + }); + } + + public int getAlertRangeCompleted() { + return alertRangeCompleted; + } + + public void setAlertRangeCompleted(int alertRangeCompleted) { + this.alertRangeCompleted = alertRangeCompleted; + } + + public int getAlertPriorityIndex() { + return alertPriorityIndex; + } + + public void setAlertPriorityIndex(int alertPriorityIndex) { + this.alertPriorityIndex = alertPriorityIndex; + } + + public long getAlertTimeRange() { + return alertTimeRange; + } + + public void setAlertTimeRange(long alertTimeRange) { + this.alertTimeRange = alertTimeRange; + } + + public String getAlertResourcesToUse() { + return alertResourcesToUse; + } + + public void setAlertResourcesToUse(String resourcesToUse) { + this.alertResourcesToUse = resourcesToUse; + } + + public Integer[] getAlertFilterResourceIds() { + return alertFilterResourceIds; + } + + public void setAlertFilterResourceId(Integer[] alertFilterResourceId) { + this.alertFilterResourceIds = alertFilterResourceId; + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java index 60a3783..c1a4ef9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java @@ -18,35 +18,200 @@ */ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
+import com.smartgwt.client.data.Criteria; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; +import com.smartgwt.client.widgets.layout.VLayout;
+import org.rhq.core.domain.alert.AlertPriority; +import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletDataSource; import org.rhq.enterprise.gui.coregui.client.alert.AlertsView; +import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
/** * @author Greg Hinkle */ -public class RecentAlertsPortlet extends AlertsView implements Portlet { +public class RecentAlertsPortlet extends AlertsView implements CustomSettingsPortlet {
public static final String KEY = "Recent Alerts"; + public static final String TITLE = KEY; + //widget keys also used in form population + private static final String ALERT_RANGE_DISPLAY_AMOUNT_VALUE = "alert-range-display-amount-value"; + private static final String ALERT_RANGE_PRIORITY_VALUE = "alert-range-priority-value"; + private static final String ALERT_RANGE_TIME_VALUE = "alert-range-time-value"; + private static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value"; + //configuration default information + private static final String defaultAlertCountValue = "5"; + private static final String PRIORITY_ALL = "ALL"; + private static final String PRIORITY_HIGH = AlertPriority.HIGH.getDisplayName(); + private static final String PRIORITY_MEDIUM = AlertPriority.MEDIUM.getDisplayName(); + private static final String PRIORITY_LOW = AlertPriority.LOW.getDisplayName(); + private static final String defaultPriorityValue = PRIORITY_ALL; + private static final String TIME_30_MINS = "30 minutes"; + private static final String TIME_HOUR = "hour"; + private static final String TIME_12_HRS = "12 hours"; + private static final String TIME_DAY = "day"; + private static final String TIME_WEEK = "week"; + private static final String TIME_MONTH = "month"; + private static final String defaultTimeValue = TIME_DAY; + private static final String RESOURCES_ALL = "all resources"; + private static final String RESOURCES_SELECTED = "selected resources"; + private static final String defaultResourceValue = RESOURCES_ALL; + private static final String unlimited = "unlimited"; + //configuration container element + private DashboardPortlet storedPortlet = null; + private AlertPortletDataSource dataSource;
public RecentAlertsPortlet(String locatorId) { - super(locatorId); + // super(locatorId); + this(locatorId, null, null);
setShowHeader(false); - setShowFooter(false); + setShowFooter(true); + //disable footer refresh + setShowFooterRefresh(false);
setOverflow(Overflow.HIDDEN); }
+ public RecentAlertsPortlet(String locatorId, Criteria criteria, String[] excludedFieldNames) { + super(locatorId, criteria, excludedFieldNames); + + //override the shared datasource + this.dataSource = new AlertPortletDataSource(); + setDataSource(this.dataSource); + } + public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - // TODO: Implement this method. + this.storedPortlet = storedPortlet; + //Operation range property - retrieve existing value + PropertySimple property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE); + if ((property != null) && (property.getStringValue() != null)) { + //retrieve and translate to int + String retrieved = property.getStringValue(); + int translatedAlertRangeSelection = translatedAlertRangeSelection(retrieved); + // getDataSource().setAlertRangeCompleted(Integer.parseInt(retrieved)); + getDataSource().setAlertRangeCompleted(translatedAlertRangeSelection); + } else {//create setting + storedPortlet.getConfiguration().put( + new PropertySimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, defaultAlertCountValue)); + getDataSource().setAlertRangeCompleted(Integer.parseInt(defaultAlertCountValue)); + } + //Operation priority property setting + property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE); + if ((property != null) && (property.getStringValue() != null)) { + //retrieve and translate to int + String retrieved = property.getStringValue(); + int translatedPriorityIndex = translatedPriorityToValidIndex(retrieved); + getDataSource().setAlertPriorityIndex(translatedPriorityIndex); + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_PRIORITY_VALUE, defaultPriorityValue)); + getDataSource().setAlertPriorityIndex(translatedPriorityToValidIndex(PRIORITY_ALL)); + } + + //Range to time that alerts will be shown for + property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE); + if ((property != null) && (property.getStringValue() != null)) { + //retrieve and translate to int + String retrieved = property.getStringValue(); + long translatedRange = translateTimeToValidRange(retrieved); + getDataSource().setAlertTimeRange(translatedRange); + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_TIME_VALUE, defaultTimeValue)); + getDataSource().setAlertTimeRange(translateTimeToValidRange(defaultTimeValue)); + } + + //Range of resources to be included in the query + property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE); + if ((property != null) && (property.getStringValue() != null)) { + //retrieve and translate to int + String retrieved = property.getStringValue(); + if (retrieved.trim().equalsIgnoreCase(RESOURCES_SELECTED)) { + getDataSource().setAlertResourcesToUse("selected"); + } else { + getDataSource().setAlertResourcesToUse("all"); + } + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue)); + getDataSource().setAlertResourcesToUse("all"); + } + } + + private int translatedAlertRangeSelection(String retrieved) { + int translated = -1; + if ((retrieved != null) && (!retrieved.trim().isEmpty())) { + if (retrieved.equalsIgnoreCase(unlimited)) { + translated = -1; + } else { + translated = Integer.parseInt(retrieved);//default to all + } + } else {//default to defaultValue + if (defaultAlertCountValue.equalsIgnoreCase(unlimited)) { + translated = -1; + } else { + translated = Integer.parseInt(defaultAlertCountValue); + } + } + return translated; + } + + private int translatedPriorityToValidIndex(String retrieved) { + int translatedPriority = 0;//default to all + if ((retrieved != null) && (!retrieved.trim().isEmpty())) { + if (retrieved.equalsIgnoreCase(PRIORITY_HIGH)) { + translatedPriority = 3; + } else if (retrieved.equalsIgnoreCase(PRIORITY_MEDIUM)) { + translatedPriority = 2; + } else if (retrieved.equalsIgnoreCase(PRIORITY_LOW)) { + translatedPriority = 1; + } else { + translatedPriority = 0;//default to all + } + } + return translatedPriority; + } + + /**Translates the UI selection options into time values for alert query. + * + * @param retrieved + * @return long value mapping to string passed in. + */ + private long translateTimeToValidRange(String retrieved) { + long translated = 0;//default to ALL + if ((retrieved != null) && (!retrieved.trim().isEmpty())) { + if (retrieved.equalsIgnoreCase(TIME_30_MINS)) { + translated = MeasurementUtility.MINUTES * 30; + } else if (retrieved.equalsIgnoreCase(TIME_HOUR)) { + translated = MeasurementUtility.HOURS; + } else if (retrieved.equalsIgnoreCase(TIME_12_HRS)) { + translated = MeasurementUtility.HOURS * 12; + } else if (retrieved.equalsIgnoreCase(TIME_DAY)) { + translated = MeasurementUtility.DAYS; + } else if (retrieved.equalsIgnoreCase(TIME_WEEK)) { + translated = MeasurementUtility.WEEKS; + } else if (retrieved.equalsIgnoreCase(TIME_MONTH)) { + translated = MeasurementUtility.DAYS * 28;//replicated from old struts def. + } else { + translated = MeasurementUtility.DAYS;//default to day otherwise. + } + } + return translated; }
public Canvas getHelpCanvas() { @@ -54,7 +219,205 @@ public class RecentAlertsPortlet extends AlertsView implements Portlet { }
public DynamicForm getCustomSettingsForm() { - return null; // TODO: Implement this method. + + //root dynamic form instance + final DynamicForm form = new DynamicForm(); + form.setWidth(200); + + VLayout column = new VLayout(); + + //label + LocatableLabel alertRangeLabel = new LocatableLabel("DynamicForm_Label_Alert_Range", "<b>Alert Range</b>"); + + //horizontal layout + LocatableHLayout row = new LocatableHLayout("alert-range-settings-row-1"); + row.setMembersMargin(10); + + //-------------combobox for number of completed scheduled ops to display on the dashboard + final SelectItem alertRangeLastComboBox = new SelectItem(ALERT_RANGE_DISPLAY_AMOUNT_VALUE); + alertRangeLastComboBox.setTitle("Last"); + alertRangeLastComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptableDisplayValues = { "5", "10", "unlimited" }; + alertRangeLastComboBox.setValueMap(acceptableDisplayValues); + //set width of dropdown display region + alertRangeLastComboBox.setWidth(100); + alertRangeLastComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, selectedItem); + } + }); + + //default selected value to 'unlimited'(live lists) and check both combobox settings here. + String selectedValue = defaultAlertCountValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE) + .getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put( + new PropertySimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, defaultAlertCountValue)); + } + } + //prepopulate the combobox with the previously stored selection + alertRangeLastComboBox.setDefaultValue(selectedValue); + + //-------------combobox for number of completed scheduled ops to display on the dashboard + final SelectItem alertRangePriorityComboBox = new SelectItem(ALERT_RANGE_PRIORITY_VALUE); + alertRangePriorityComboBox.setTitle(""); + alertRangePriorityComboBox.setHint("<nobr> <b> priority Alerts,</b></nobr>"); + alertRangePriorityComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptablePriorityDisplayValues = { PRIORITY_ALL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW }; + alertRangePriorityComboBox.setValueMap(acceptablePriorityDisplayValues); + //set width of dropdown display region + alertRangePriorityComboBox.setWidth(100); + alertRangePriorityComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(ALERT_RANGE_PRIORITY_VALUE, selectedItem); + } + }); + + //default selected value to 'unlimited'(live lists) and check both combobox settings here. + selectedValue = defaultPriorityValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put( + new PropertySimple(ALERT_RANGE_PRIORITY_VALUE, defaultPriorityValue)); + } + } + //prepopulate the combobox with the previously stored selection + alertRangePriorityComboBox.setDefaultValue(selectedValue); + row.addMember(alertRangeLabel); + DynamicForm wrappedRange = new DynamicForm(); + wrappedRange.setFields(alertRangeLastComboBox); + row.addMember(wrappedRange); + + DynamicForm wrappedPriority = new DynamicForm(); + wrappedPriority.setFields(alertRangePriorityComboBox); + row.addMember(wrappedPriority); + + //horizontal layout + LocatableHLayout row2 = new LocatableHLayout("alert-range-settings-row-2"); + + Label alertRangeSpanLabel = new Label("<b>within the past<b>"); + //------------- Build second combobox for timeframe for problem resources search. + final SelectItem alertRangeTimeComboBox = new SelectItem(ALERT_RANGE_TIME_VALUE); + alertRangeTimeComboBox.setTitle(""); + alertRangeTimeComboBox.setHint(""); + alertRangeTimeComboBox.setType("selection"); + String[] acceptableTimeDisplayValues = { TIME_30_MINS, TIME_HOUR, TIME_12_HRS, TIME_DAY, TIME_WEEK, TIME_MONTH }; + alertRangeTimeComboBox.setValueMap(acceptableTimeDisplayValues); + alertRangeTimeComboBox.setWidth(100); + alertRangeTimeComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(ALERT_RANGE_TIME_VALUE, selectedItem); + } + }); + + //set to default + selectedValue = defaultTimeValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_TIME_VALUE, defaultTimeValue)); + } + } + //prepopulate the combobox with the previously stored selection + alertRangeTimeComboBox.setDefaultValue(selectedValue); + DynamicForm timeSelectionWrapper = new DynamicForm(); + timeSelectionWrapper.setFields(alertRangeTimeComboBox); + + // build resource selection drop down + //------------- Build second combobox for timeframe for problem resources search. + final SelectItem alertResourcesComboBox = new SelectItem(ALERT_RANGE_RESOURCES_VALUE); + alertResourcesComboBox.setTitle("for"); + alertResourcesComboBox.setHint(""); + alertResourcesComboBox.setType("selection"); + String[] acceptableResourceDisplayValues = { RESOURCES_ALL, RESOURCES_SELECTED }; + alertResourcesComboBox.setValueMap(acceptableResourceDisplayValues); + alertResourcesComboBox.setWidth(100); + alertResourcesComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(ALERT_RANGE_RESOURCES_VALUE, selectedItem); + } + }); + + //set to default + selectedValue = defaultResourceValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE) + .getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put( + new PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue)); + } + } + //prepopulate the combobox with the previously stored selection + alertResourcesComboBox.setDefaultValue(selectedValue); + DynamicForm resourceSelectionWrapper = new DynamicForm(); + resourceSelectionWrapper.setFields(alertResourcesComboBox); + + alertRangeSpanLabel.setWrap(false); + alertRangeSpanLabel.setWidth(150); + row2.addMember(alertRangeSpanLabel); + row2.addMember(timeSelectionWrapper); + row2.addMember(resourceSelectionWrapper); + column.addMember(row); + column.addMember(row2); + form.addChild(column); + + //submit handler + form.addSubmitValuesHandler(new SubmitValuesHandler() { + @Override + public void onSubmitValues(SubmitValuesEvent event) { + //no need to insert validation here as user not allowed to enter values + parseFormAndPopulateConfiguration(form, storedPortlet, ALERT_RANGE_DISPLAY_AMOUNT_VALUE, + ALERT_RANGE_PRIORITY_VALUE, ALERT_RANGE_RESOURCES_VALUE, ALERT_RANGE_TIME_VALUE); + refresh();// + } + }); + + return form; + + } + + /**Iterates over DynamicForm instance to check for properties passed in and if they have been set + * to put that property into the DashboardPortlet configuration. + * + * @param form Dynamic form storing user selections + * @param portlet Container for configuration changes + * @param properties Variable list of keys used to verify or populate properties. + */ + private void parseFormAndPopulateConfiguration(final DynamicForm form, DashboardPortlet portlet, + String... properties) { + if ((form != null) && (portlet != null)) { + for (String property : properties) { + if (form.getValue(property) != null) {//if new value supplied + storedPortlet.getConfiguration().put(new PropertySimple(property, form.getValue(property))); + } + } + } + } + + public AlertPortletDataSource getDataSource() { + return dataSource; }
public static final class Factory implements PortletViewFactory {
commit b38fbd992d4a236fdf71ea5001db32b3af889ee8 Merge: 2b0a1c3... a03a5f6... Author: Heiko W. Rupp hwr@redhat.com Date: Tue Sep 21 14:31:49 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 2b0a1c3b350e74bb07943063a2df6b73f3de783c Author: Heiko W. Rupp hwr@redhat.com Date: Tue Sep 21 14:30:38 2010 +0200
Bump target version to follow the recent change to the upgrade script.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml index 1f4adef..11ba639 100644 --- a/modules/core/dbutils/pom.xml +++ b/modules/core/dbutils/pom.xml @@ -22,7 +22,7 @@
<properties> <scm.module.path>modules/core/dbutils/</scm.module.path> - <db.schema.version>2.94</db.schema.version> + <db.schema.version>2.95</db.schema.version> </properties>
<dependencies>
commit c30cc1e7055710aa26f069e108c832daedfb567f Author: Heiko W. Rupp hwr@redhat.com Date: Tue Sep 21 14:24:19 2010 +0200
Update the test to follow the 15 mins backfill wait interval. Otherwise it fails, as the created report would be considered not old enough.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java index ca5ca29..e59794a 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java @@ -505,7 +505,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test { } }
- @Test(enabled = ENABLE_TESTS) + @Test(enabled = true) public void testAgentBackfillPerformance() throws Exception { EntityManager em = beginTx(); List<Resource> allResources = new ArrayList<Resource>(); @@ -548,7 +548,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test { // let's pretend we haven't heard from the agent in a few minutes em = beginTx(); Agent agent = em.find(Agent.class, theAgent.getId()); - agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 * 6)); + agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 * 18)); // 18 mins commitAndClose(em); em = null;
@@ -580,7 +580,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test { // let's again pretend we haven't heard from the agent in a few minutes em = beginTx(); agent = em.find(Agent.class, theAgent.getId()); - agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 * 6)); + agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 * 18)); commitAndClose(em); em = null;
commit a03a5f6757ac252cfd91f5578129e46a5ed54866 Author: Joseph Marques joseph@redhat.com Date: Tue Sep 21 01:37:40 2010 -0400
more dynagroup CRUD work:
* add list of dynagroup children to details view * add ability to recalculate the current group def from details view * fix column widths and cell formatting for list view * add ability to recalculate selected group definitions from list view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java index 00e8819..f0fe978 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java @@ -110,6 +110,11 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> { "downMemberCount"))); }
+ if (request.getCriteria().getValues().get("groupDefinitionId") != null) { + criteria.addFilterGroupDefinitionId(Integer.parseInt((String) request.getCriteria().getValues().get( + "groupDefinitionId"))); + } + return criteria; }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java index a95e0e6..49ea417 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java @@ -30,7 +30,6 @@ import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.rpc.RPCResponse; -import com.smartgwt.client.types.FieldType; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; @@ -70,23 +69,21 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression"); + DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression Set"); expressionField.setRequired(true);
- DataSourceTextField recursiveField = new DataSourceTextField("recursive", "Recursive"); - recursiveField.setType(FieldType.BOOLEAN); - - /* - DataSourceTextField recalculationIntervalField = new DataSourceTextField("recalculationInterval", + DataSourceIntegerField lastCalculationTimeIntervalField = new DataSourceIntegerField("lastCalculationTime", "Recalculation Interval"); - */
- DataSourceTextField nextCalculationTimeField = new DataSourceTextField("nextCalculationTime", + DataSourceIntegerField nextCalculationTimeField = new DataSourceIntegerField("nextCalculationTime", "Next Calculation Time");
- setFields(idField, nameField, descriptionField, expressionField, recursiveField, /*recalculationIntervalField,*/ - nextCalculationTimeField); - + addField(idField); + addField(nameField); + addField(descriptionField); + addField(expressionField); + addField(lastCalculationTimeIntervalField); + addField(nextCalculationTimeField); }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java index d6d78e5..9b17abf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java @@ -21,13 +21,14 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.CellFormatter; -import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.util.TableUtility; @@ -50,25 +51,71 @@ public class GroupDefinitionListView extends TableSection {
@Override protected void configureTable() { - super.configureTable();
- ListGrid grid = getListGrid(); + ListGridField idField = new ListGridField("id", "ID", 50); + ListGridField nameField = new ListGridField("name", "Name", 150); + ListGridField descriptionField = new ListGridField("description", "Description"); + ListGridField expressionField = new ListGridField("expression", "Expression Set", 250); + expressionField.setCellFormatter(new CellFormatter() { + public String format(Object value, ListGridRecord record, int rowNum, int colNum) { + return value.toString().replaceAll("\n", "<br/>"); + } + }); + + ListGridField lastCalculationTimeField = new ListGridField("lastCalculationTime", "Last Calculation Time", 175); + //lastCalculationTimeField.setAlign(Alignment.CENTER); + lastCalculationTimeField.setCellFormatter(new TimestampCellFormatter() { + public String format(Object value, ListGridRecord record, int rowNum, int colNum) { + if (value == null) { + return "Never"; + } + return super.format(value, record, rowNum, colNum); + } + });
- grid.getField("nextCalculationTime").setCellFormatter(new CellFormatter() { + ListGridField nextCalculationTimeField = new ListGridField("nextCalculationTime", "Next Calculation Time", 175); + //nextCalculationTimeField.setAlign(Alignment.CENTER); + nextCalculationTimeField.setCellFormatter(new TimestampCellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { - if ("0".equals(value.toString())) { + if (value == null || "0".equals(value.toString())) { return "N/A"; } - return value.toString(); + return super.format(value, record, rowNum, colNum); } });
+ getListGrid().setFields(idField, nameField, descriptionField, expressionField, lastCalculationTimeField, + nextCalculationTimeField); + addTableAction(extendLocatorId("New"), "New", Table.SelectionEnablement.ALWAYS, null, new TableAction() { public void executeAction(ListGridRecord[] selection) { newDetails(); } });
+ addTableAction(extendLocatorId("Recalculate"), "Recalculate", Table.SelectionEnablement.ANY, null, + new TableAction() { + public void executeAction(ListGridRecord[] selection) { + final int[] groupDefinitionIds = TableUtility.getIds(selection); + ResourceGroupGWTServiceAsync resourceGroupManager = GWTServiceLookup.getResourceGroupService(); + + resourceGroupManager.recalculateGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to recalculate selected group definitions", + caught); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify( + new Message("Successfully recalculated " + groupDefinitionIds.length + + " group definitions", Severity.Info)); + + GroupDefinitionListView.this.refresh(); + } + }); + } + }); + addTableAction(extendLocatorId("Delete"), "Delete", Table.SelectionEnablement.ANY, null, new TableAction() { public void executeAction(ListGridRecord[] selection) { final int[] groupDefinitionIds = TableUtility.getIds(selection); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index 1639a92..f4ca2cf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -23,6 +23,7 @@ import java.util.Set;
import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DSCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; @@ -45,7 +46,11 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; +import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; @@ -131,16 +136,48 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm form.setSaveOperationType(DSOperationType.UPDATE); }
+ final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"), + groupDefinitionId); + // button setup IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { if (form.validate()) { - //createOrUpdate(); form.saveData(new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { - History.back(); + dynaGroupChildrenView.refresh(); + } + }); + } + } + }); + + IButton recalculateButton = new LocatableIButton(this.extendLocatorId("Recalculate"), "Save & Recalculate"); + recalculateButton.setWidth(150); + recalculateButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + if (form.validate()) { + form.saveData(new DSCallback() { + @Override + public void execute(DSResponse response, Object rawData, DSRequest request) { + GWTServiceLookup.getResourceGroupService().recalculateGroupDefinitions( + new int[] { groupDefinitionId }, new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError( + "Failed to recalculate this group definition", caught); + } + + @Override + public void onSuccess(Void result) { + dynaGroupChildrenView.refresh(); + CoreGUI.getMessageCenter().notify( + new Message("Successfully recalculated this group definition", + Severity.Info)); + } + }); } }); } @@ -157,15 +194,25 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm HLayout buttonLayout = new HLayout(10); // margin between members buttonLayout.setMargin(10); // margin around layout widget buttonLayout.addMember(saveButton); + buttonLayout.addMember(recalculateButton); buttonLayout.addMember(resetButton);
// canvas setup addMember(form); addMember(buttonLayout); + addMember(dynaGroupChildrenView);
markForRedraw(); }
+ class DynaGroupChildrenView extends Table { + public DynaGroupChildrenView(String locatorId, int groupDefinitionId) { + super(locatorId, "DynaGroup Children", new Criteria("groupDefinitionId", String.valueOf(groupDefinition + .getId()))); + setDataSource(ResourceGroupsDataSource.getInstance()); + } + } + public void switchToEditMode() { name.show(); description.show(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java index 71f1996..e1bed72 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java @@ -106,7 +106,6 @@ public class ResourceSearchView extends Table { protected void configureTable() {
getListGrid().setSelectionType(SelectionStyle.SIMPLE); - getListGrid().setResizeFieldsInRealTime(true);
ListGridField idField = new ListGridField("id", "Id", 55); idField.setType(ListGridFieldType.INTEGER);
commit c97a7a3d47cadd9405d9becdfda5beb3da783e8a Author: Joseph Marques joseph@redhat.com Date: Tue Sep 21 01:29:37 2010 -0400
add recalculation method to the ResourceGroup GWT service
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java index 333427f..d475aa8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java @@ -30,6 +30,7 @@ import org.rhq.core.domain.util.PageList;
/** * @author Greg Hinkle + * @author Joseph Marques */ @RemoteServiceRelativePath("ResourceGroupGWTService") public interface ResourceGroupGWTService extends RemoteService { @@ -48,6 +49,8 @@ public interface ResourceGroupGWTService extends RemoteService {
PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
+ void recalculateGroupDefinitions(int[] groupDefinitionIds); + void setMembership(int groupId, int[] resourceIds, boolean setType);
void updateGroupDefinition(GroupDefinition groupDefinition); @@ -55,5 +58,4 @@ public interface ResourceGroupGWTService extends RemoteService { void updateResourceGroup(ResourceGroup group);
void updateResourceGroup(ResourceGroup group, boolean updateMembership); - } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java index b9642d6..07b9168 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java @@ -132,6 +132,16 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen } }
+ public void recalculateGroupDefinitions(int[] groupDefinitionIds) { + try { + for (int nextGroupDefinitionId : groupDefinitionIds) { + definitionManager.calculateGroupMembership(getSessionSubject(), nextGroupDefinitionId); + } + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } + } + public void deleteGroupDefinitions(int[] groupDefinitionIds) { try { for (int nextGroupDefinitionId : groupDefinitionIds) {
commit a8203c775172bf83d9aa611433f7c051fa253f7d Author: Joseph Marques joseph@redhat.com Date: Mon Sep 20 22:14:15 2010 -0400
remove redundant data caching methods from ResourceGroupsDatasource
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java index 00e9389..00e8819 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java @@ -54,10 +54,7 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> { }
public ResourceGroupsDataSource() { - - // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data - this.setAutoCacheAllData(false); - this.setCacheAllData(false); + super();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20); idDataField.setPrimaryKey(true); @@ -77,8 +74,6 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> { }
public void executeFetch(final DSRequest request, final DSResponse response) { - final long start = System.currentTimeMillis(); - ResourceGroupCriteria criteria = getFetchCriteria(request);
groupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {
commit a5b3075fb496babadb208e2be2b1d4c5f2e92a1e Author: Joseph Marques joseph@redhat.com Date: Mon Sep 20 22:05:17 2010 -0400
remove redundant data caching methods from ResourceDatasource
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java index 280cb89..8a55ed7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java @@ -58,10 +58,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> { public ResourceDatasource() { super();
- // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data - this.setAutoCacheAllData(false); - this.setCacheAllData(false); - DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20); idDataField.setPrimaryKey(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java index dd5e77b..5b3ecf7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java @@ -58,6 +58,7 @@ public abstract class RPCDataSource<T> extends DataSource { System.out.println("Trying to build DS: " + name); setID(name); } + // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data setClientOnly(false); setAutoCacheAllData(false); setCacheAllData(false);
commit f4d2f1663b3beffe728af06df3aa7a12737fc201 Author: Joseph Marques joseph@redhat.com Date: Mon Sep 20 13:13:58 2010 -0400
remove unnecessary set for number of columns
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index 7b5ea42..1639a92 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -122,7 +122,6 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("GroupDefinitionForm")); form.setFields(id, idStatic, name, nameStatic, description, descriptionStatic, expression, expressionStatic, recursive, recursiveStatic, recalculationInterval, recalculationIntervalStatic); - form.setNumCols(2); form.setDataSource(dataSource); form.setHiliteRequiredFields(true); form.setRequiredTitleSuffix(" <span style="color: red;">* </span>:");
commit 1140690afe36709b2c53722c9ad447fb7a0ec8c1 Author: Ian Springer ian.springer@redhat.com Date: Mon Sep 20 14:58:44 2010 -0400
only ask discovery components for additional classpath URLs (i.e. client jars) if per-resource classloaders are enabled in the plugin container config
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java index aec2353..ffaae5e 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java @@ -463,6 +463,21 @@ public class ClassLoaderManager { return new HashMap<CanonicalResourceKey, ClassLoader>(this.resourceClassLoaders); }
+ /** + * Returns <code>true</code> if this manager will create instances of classloaders for those + * individual Resources that require it, or <code>false</code> if this manager will never create + * individual classloaders for Resources (i.e. {@link #obtainResourceClassLoader(Resource, ResourceContainer, List)} + * will always just return plugin classloaders). + * + * @return <code>true</code> if this manager will create instances of classloaders for those + * individual Resources that require it, or <code>false</code> if this manager will never create + * individual classloaders for Resources (i.e. {@link #obtainResourceClassLoader(Resource, ResourceContainer, List)} + * will always just return plugin classloaders) + */ + public boolean isCreateResourceClassLoaders() { + return this.createResourceClassLoaders; + } + private Set<ClassLoader> getUniquePluginClassLoaders() { HashSet<ClassLoader> uniqueClassLoaders = new HashSet<ClassLoader>(this.pluginClassLoaders.values()); return uniqueClassLoaders; diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java index 4176353..ca8eef6 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java @@ -23,6 +23,7 @@ package org.rhq.core.pc.plugin;
import java.net.URL; +import java.util.Collections; import java.util.List;
import org.apache.commons.logging.Log; @@ -174,14 +175,16 @@ public class PluginComponentFactory implements ContainerService { + parentResource); } } else if (resource.equals(inventoryMgr.getPlatform())) { - // the given resource is our top platform resource, just use its plugin classloader + // the given resource is our top platform resource - just use its plugin classloader return classLoaderMgr.obtainPluginClassLoader(resourceType.getPlugin()); } else { throw new PluginContainerException("Missing parent resource for resource=" + resource); }
// get the classloader the resource should use - List<URL> additionalJars = askDiscoveryComponentForAdditionalClasspathUrls(resource, parentContainer); + List<URL> additionalJars = (classLoaderMgr.isCreateResourceClassLoaders()) ? + askDiscoveryComponentForAdditionalClasspathUrls(resource, parentContainer) : + Collections.<URL>emptyList(); ClassLoader cl = classLoaderMgr.obtainResourceClassLoader(resource, parentContainer, additionalJars); return cl; } catch (Throwable t) {
commit a63b4bcd0ea05090acac14797f9e06d31e00c6b7 Author: John Mazzitelli mazz@redhat.com Date: Mon Sep 20 14:16:36 2010 -0400
use WIPE animation - seems to work faster than the FADE
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java index a1303a1..0e3a899 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java @@ -224,7 +224,7 @@ public abstract class TableSection extends Table implements BookmarkableView { protected void switchToDetailsView() { Canvas contents = getTableContents(); if (contents != null) { - contents.animateHide(AnimationEffect.FADE, new AnimationCallback() { + contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() { @Override public void execute(boolean b) { detailsView.setWidth100(); @@ -232,7 +232,7 @@ public abstract class TableSection extends Table implements BookmarkableView {
detailsHolder.addMember(new BackButton(extendLocatorId("BackButton"), "Back to List", basePath)); detailsHolder.addMember(detailsView); - detailsHolder.animateShow(AnimationEffect.FADE); + detailsHolder.animateShow(AnimationEffect.WIPE); } }); } @@ -246,18 +246,18 @@ public abstract class TableSection extends Table implements BookmarkableView { if (contents != null) {
if (detailsHolder != null && detailsHolder.isVisible()) { - detailsHolder.animateHide(AnimationEffect.FADE, new AnimationCallback() { + detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() { @Override public void execute(boolean b) { for (Canvas child : detailsHolder.getMembers()) { child.destroy(); }
- contents.animateShow(AnimationEffect.FADE); + contents.animateShow(AnimationEffect.WIPE); } }); } else { - contents.animateShow(AnimationEffect.FADE); + contents.animateShow(AnimationEffect.WIPE); } } }
commit 665349f2a221a7aed276f67197ca9289fba322b2 Author: John Mazzitelli mazz@redhat.com Date: Mon Sep 20 13:05:03 2010 -0400
bz 535756 add the ability to create calltime conditions to an alert definition
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java index 098e92a..14cb2c2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java @@ -54,17 +54,40 @@ public class AlertFormatUtility { break; } case THRESHOLD: { - str.append("Metric Value Exceeds Threshold"); - str.append(" ["); - str.append(condition.getName()); - str.append(" "); - str.append(condition.getComparator()); - str.append(" "); double value = condition.getThreshold(); MeasurementUnits units = condition.getMeasurementDefinition().getUnits(); String formatted = MeasurementConverterClient.format(value, units, true); - str.append(formatted); - str.append("]"); + + if (condition.getOption() == null) { + str.append("Metric Value Exceeds Threshold"); + str.append(" ["); + str.append(condition.getName()); + str.append(" "); + str.append(condition.getComparator()); + str.append(" "); + str.append(formatted); + str.append("]"); + } else { + // this is a calltime threshold condition + // the name of the metric is only obtainable by querying for the name from the meas def ID + // but since most times (all the time?) there is only one calltime metric per resource, + // not showing the metric name probably isn't detrimental + str.append("Calltime Value Exceeds Threshold"); + str.append(" ["); + str.append(condition.getOption()); // MIN, MAX, AVG (never null) + str.append(" "); + str.append(condition.getComparator()); // <, >, = + str.append(" "); + str.append(condition.getThreshold()); + str.append("]"); + if (condition.getName() != null && condition.getName().length() > 0) { + str.append(" "); + str.append("with call destination matching"); + str.append(" '"); + str.append(condition.getName()); + str.append("'"); + } + } break; } case BASELINE: { @@ -86,10 +109,39 @@ public class AlertFormatUtility { break; } case CHANGE: { - str.append("Metric Value Change"); - str.append(" ["); - str.append(condition.getName()); - str.append("]"); + if (condition.getOption() == null) { + str.append("Metric Value Change"); + str.append(" ["); + str.append(condition.getName()); + str.append("]"); + } else { + // this is a calltime change condition + // the name of the metric is only obtainable by querying for the name from the meas def ID + // but since most times (all the time?) there is only one calltime metric per resource, + // not showing the metric name probably isn't detrimental + str.append("Calltime Value Changes"); + str.append(" ["); + str.append(condition.getOption()); // MIN, MAX, AVG (never null) + str.append(" "); + str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH + str.append(" "); + str.append("by at least"); + str.append(" "); + + double value = condition.getThreshold(); + MeasurementUnits units = MeasurementUnits.PERCENTAGE; + String formatted = MeasurementConverterClient.format(value, units, true); + str.append(formatted); + + str.append("]"); + if (condition.getName() != null && condition.getName().length() > 0) { + str.append(" "); + str.append("with call destination matching"); + str.append(" '"); + str.append(condition.getName()); + str.append("'"); + } + } break; } case TRAIT: { @@ -122,9 +174,9 @@ public class AlertFormatUtility { if (condition.getOption() != null && condition.getOption().length() > 0) { str.append(" "); str.append("matching"); - str.append(" ["); + str.append(" '"); str.append(condition.getOption()); - str.append("]"); + str.append("'"); } break; } @@ -136,6 +188,16 @@ public class AlertFormatUtility { return str.toString(); }
+ private static String getCalltimeChangeComparator(String comparator) { + if ("HI".equals(comparator)) { + return "Grows"; + } else if ("LO".equals(comparator)) { + return "Shrinks"; + } else { // CH + return "Changes"; + } + } + public static String getAlertRecoveryInfo(Alert alert) { String recoveryInfo; AlertDefinition recoveryAlertDefinition = alert.getRecoveryAlertDefinition(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index 7e81a0e..3fcc64e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -58,6 +58,11 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; */ public class NewConditionEditor extends LocatableDynamicForm {
+ // these aren't "real" calltime condition categories (not real AlertConditionCategory enums) + // but we need these values for the drop down menu selections + private static final String ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE = "calltime-change"; + private static final String ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD = "calltime-threshold"; + private static final String AVAILABILITY_ITEMNAME = "availability"; private static final String THRESHOLD_METRIC_ITEMNAME = "thresholdMetric"; private static final String THRESHOLD_COMPARATOR_ITEMNAME = "thresholdComparator"; @@ -67,6 +72,16 @@ public class NewConditionEditor extends LocatableDynamicForm { private static final String BASELINE_PERCENTAGE_ITEMNAME = "baselinePercentage"; private static final String BASELINE_SELECTION_ITEMNAME = "baselineSelection"; private static final String CHANGE_METRIC_ITEMNAME = "changeMetric"; + private static final String CALLTIME_THRESHOLD_METRIC_ITEMNAME = "calltimeThresholdMetric"; + private static final String CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME = "calltimeThresholdMinMaxAvgSelection"; + private static final String CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME = "calltimeThresholdComparator"; + private static final String CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME = "calltimeThresholdAbsoluteValue"; + private static final String CALLTIME_THRESHOLD_REGEX_ITEMNAME = "calltimeThresholdRegex"; + private static final String CALLTIME_CHANGE_METRIC_ITEMNAME = "calltimeChangeMetric"; + private static final String CALLTIME_CHANGE_MINMAXAVG_ITEMNAME = "calltimeChangeMinMaxAvgSelection"; + private static final String CALLTIME_CHANGE_COMPARATOR_ITEMNAME = "calltimeChangeComparator"; + private static final String CALLTIME_CHANGE_PERCENTAGE_ITEMNAME = "calltimeChangePercentageValue"; + private static final String CALLTIME_CHANGE_REGEX_ITEMNAME = "calltimeChangeRegex"; private static final String TRAIT_METRIC_ITEMNAME = "trait"; private static final String OPERATION_NAME_ITEMNAME = "operation"; private static final String OPERATION_RESULTS_ITEMNAME = "operationResults"; @@ -76,6 +91,7 @@ public class NewConditionEditor extends LocatableDynamicForm { private SelectItem conditionTypeSelectItem; private HashSet<AlertCondition> conditions; // the new condition we create goes into this set private boolean supportsMetrics = false; + private boolean supportsCalltimeMetrics = false; private boolean supportsTraits = false; private boolean supportsOperations = false; private boolean supportsEvents = false; @@ -101,6 +117,10 @@ public class NewConditionEditor extends LocatableDynamicForm { this.supportsMetrics = true; break; } + case CALLTIME: { + this.supportsCalltimeMetrics = true; + break; + } case TRAIT: { this.supportsTraits = true; break; @@ -132,6 +152,10 @@ public class NewConditionEditor extends LocatableDynamicForm { condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold"); condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change"); } + if (supportsCalltimeMetrics) { + condTypes.put(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD, "Calltime Value Threshold"); + condTypes.put(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE, "Calltime Value Change"); + } if (supportsTraits) { condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change"); } @@ -176,6 +200,10 @@ public class NewConditionEditor extends LocatableDynamicForm { formItems.addAll(buildMetricBaselineFormItems()); formItems.addAll(buildMetricChangeFormItems()); } + if (supportsCalltimeMetrics) { + formItems.addAll(buildCalltimeThresholdFormItems()); + formItems.addAll(buildCalltimeChangeFormItems()); + } if (supportsTraits) { formItems.addAll(buildTraitChangeFormItems()); } @@ -194,8 +222,20 @@ public class NewConditionEditor extends LocatableDynamicForm { };
private void saveNewCondition() { - AlertConditionCategory category; - category = AlertConditionCategory.valueOf(conditionTypeSelectItem.getValue().toString()); + final boolean calltimeCategory; + final AlertConditionCategory category; + + String selectedCategory = conditionTypeSelectItem.getValue().toString(); + if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD)) { + calltimeCategory = true; + category = AlertConditionCategory.THRESHOLD; + } else if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE)) { + calltimeCategory = true; + category = AlertConditionCategory.CHANGE; + } else { + calltimeCategory = false; + category = AlertConditionCategory.valueOf(selectedCategory); + }
AlertCondition newCondition = new AlertCondition(); newCondition.setCategory(category); @@ -211,12 +251,21 @@ public class NewConditionEditor extends LocatableDynamicForm { }
case THRESHOLD: { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME)); - newCondition.setName(measDef.getDisplayName()); // TODO should not use display name - newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME))); - newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME)); - newCondition.setOption(null); - newCondition.setMeasurementDefinition(measDef); + if (!calltimeCategory) { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); // TODO should not use display name + newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME)); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + } else { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME)); + newCondition.setName(getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME)); + newCondition.setThreshold(Double.valueOf(getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME)); + newCondition.setOption(getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME)); + newCondition.setMeasurementDefinition(measDef); + } break; }
@@ -231,12 +280,22 @@ public class NewConditionEditor extends LocatableDynamicForm { }
case CHANGE: { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME)); - newCondition.setName(measDef.getDisplayName()); // TODO should not use display name - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(null); - newCondition.setMeasurementDefinition(measDef); + if (!calltimeCategory) { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); // TODO should not use display name + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + } else { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME)); + newCondition.setName(getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME)); + newCondition + .setThreshold(Double.valueOf(getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME)) / 100.0); + newCondition.setComparator(getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME)); + newCondition.setOption(getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME)); + newCondition.setMeasurementDefinition(measDef); + } break; }
@@ -360,6 +419,97 @@ public class NewConditionEditor extends LocatableDynamicForm { return formItems; }
+ private ArrayList<FormItem> buildCalltimeThresholdFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD); + + String helpStr = "Specify the calltime threshold value that, when violated, triggers the condition. The value you specify is an absolute value with an optional units specifier. You also must specify which calltime limit to compare the value with (minimum, maximum or average calltime value)."; + StaticTextItem helpItem = buildHelpTextItem("calltimeThresholdHelp", helpStr, ifFunc); + formItems.add(helpItem); + + formItems.add(buildCalltimeMetricDropDownMenu(CALLTIME_THRESHOLD_METRIC_ITEMNAME, ifFunc)); + + SelectItem minMaxAvgSelection = new SelectItem(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME, "Calltime Limit"); + LinkedHashMap<String, String> limits = new LinkedHashMap<String, String>(3); + limits.put("MIN", "Minimum"); + limits.put("AVG", "Average"); + limits.put("MAX", "Maximum"); + minMaxAvgSelection.setTooltip("The calltime limit value that is to be compared with the given value"); + minMaxAvgSelection.setValueMap(limits); + minMaxAvgSelection.setDefaultValue("AVG"); + minMaxAvgSelection.setWrapTitle(false); + minMaxAvgSelection.setWidth("*"); + minMaxAvgSelection.setRedrawOnChange(true); + minMaxAvgSelection.setShowIfCondition(ifFunc); + formItems.add(minMaxAvgSelection); + + formItems.add(buildComparatorDropDownMenu(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME, ifFunc)); + TextItem absoluteValue = new TextItem(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME, "Calltime Value"); + absoluteValue.setWrapTitle(false); + absoluteValue.setRequired(true); + absoluteValue + .setTooltip("The threshold value of the metric that will trigger the condition when compared using the selected comparator."); + absoluteValue.setShowIfCondition(ifFunc); + formItems.add(absoluteValue); + + TextItem regex = new TextItem(CALLTIME_THRESHOLD_REGEX_ITEMNAME, "Regular Expression"); + regex.setRequired(false); + regex + .setTooltip("If specified, this is a regular expression that must match a call destination in order to trigger the condition."); + regex.setWrapTitle(false); + regex.setShowIfCondition(ifFunc); + formItems.add(regex); + + return formItems; + } + + private ArrayList<FormItem> buildCalltimeChangeFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE); + + String helpStr = "Specify the calltime value that, when changed at least a specified amount, triggers the condition. You must specify which calltime limit to check (minimum, maximum or average calltime value) and the percentage of change that must occur."; + StaticTextItem helpItem = buildHelpTextItem("calltimeChangeHelp", helpStr, ifFunc); + formItems.add(helpItem); + + formItems.add(buildCalltimeMetricDropDownMenu(CALLTIME_CHANGE_METRIC_ITEMNAME, ifFunc)); + + SelectItem minMaxAvgSelection = new SelectItem(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME, "Calltime Limit"); + LinkedHashMap<String, String> limits = new LinkedHashMap<String, String>(3); + limits.put("MIN", "Minimum"); + limits.put("AVG", "Average"); + limits.put("MAX", "Maximum"); + minMaxAvgSelection.setTooltip("The calltime limit value that is to be checked for change"); + minMaxAvgSelection.setValueMap(limits); + minMaxAvgSelection.setDefaultValue("AVG"); + minMaxAvgSelection.setWrapTitle(false); + minMaxAvgSelection.setWidth("*"); + minMaxAvgSelection.setRedrawOnChange(true); + minMaxAvgSelection.setShowIfCondition(ifFunc); + formItems.add(minMaxAvgSelection); + + formItems.add(buildCalltimeComparatorDropDownMenu(CALLTIME_CHANGE_COMPARATOR_ITEMNAME, ifFunc)); + + TextItem percentage = new TextItem(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME, "Percentage Change"); + percentage.setWrapTitle(false); + percentage.setRequired(true); + percentage + .setTooltip("A collected calltime value will trigger this condition when it differs by at least this percentage of the selected calltime limit value"); + percentage.setShowIfCondition(ifFunc); + formItems.add(percentage); + + TextItem regex = new TextItem(CALLTIME_CHANGE_REGEX_ITEMNAME, "Regular Expression"); + regex.setRequired(false); + regex + .setTooltip("If specified, this is a regular expression that must match a call destination in order to trigger the condition."); + regex.setWrapTitle(false); + regex.setShowIfCondition(ifFunc); + formItems.add(regex); + + return formItems; + } + private ArrayList<FormItem> buildTraitChangeFormItems() { ArrayList<FormItem> formItems = new ArrayList<FormItem>();
@@ -510,9 +660,27 @@ public class NewConditionEditor extends LocatableDynamicForm { return metricSelection; }
+ private SelectItem buildCalltimeMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) { + + LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>(); + for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) { + if (def.getDataType() == DataType.CALLTIME) { + metricsMap.put(def.getName(), def.getDisplayName()); + } + } + + SelectItem metricSelection = new SelectItem(itemName, "Metric"); + metricSelection.setValueMap(metricsMap); + metricSelection.setDefaultValue(metricsMap.keySet().iterator().next()); // just use the first one + metricSelection.setWidth("*"); + metricSelection.setRedrawOnChange(true); + metricSelection.setShowIfCondition(ifFunc); + return metricSelection; + } + private SelectItem buildComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
- LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>(); + LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>(3); comparators.put("<", "< (Less than)"); comparators.put("=", "= (Equal to)"); comparators.put(">", "> (Greater than)"); @@ -525,6 +693,21 @@ public class NewConditionEditor extends LocatableDynamicForm { return comparatorSelection; }
+ private SelectItem buildCalltimeComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) { + + LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>(3); + comparators.put("LO", "Shrinks"); + comparators.put("CH", "Changes"); + comparators.put("HI", "Grows"); + + SelectItem comparatorSelection = new SelectItem(itemName, "Comparator"); + comparatorSelection.setValueMap(comparators); + comparatorSelection.setDefaultValue("CH"); + comparatorSelection.setTooltip("How a collected calltime value should be compared to the given calltime limit"); + comparatorSelection.setShowIfCondition(ifFunc); + return comparatorSelection; + } + private StaticTextItem buildHelpTextItem(String itemName, String helpText, FormItemIfFunction ifFunc) { StaticTextItem help = new StaticTextItem(itemName); help.setShowTitle(false); @@ -548,13 +731,25 @@ public class NewConditionEditor extends LocatableDynamicForm {
private class ShowIfCategoryFunction implements FormItemIfFunction { private final AlertConditionCategory category; + private final String calltimeCategory;
public ShowIfCategoryFunction(AlertConditionCategory category) { this.category = category; + this.calltimeCategory = null; + } + + public ShowIfCategoryFunction(String calltimeCategory) { + this.category = null; + this.calltimeCategory = calltimeCategory; }
public boolean execute(FormItem item, Object value, DynamicForm form) { - return category.name().equals(form.getValue("conditionType").toString()); + String conditionTypeString = form.getValue("conditionType").toString(); + if (category != null) { + return category.name().equals(conditionTypeString); + } else { + return calltimeCategory.equals(conditionTypeString); + } } } }
commit d4a02cc3c2fb7e999fede59f3813357e6b0e79ec Author: John Mazzitelli mazz@redhat.com Date: Mon Sep 20 09:19:34 2010 -0400
add more javadocs to explain what the fields are for calltime alert conditions
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java index 3218d9d..640648b 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java @@ -390,6 +390,8 @@ public class AlertCondition implements Serializable { * THRESHOLD: the name of the metric (TODO: today its the display name, very bad for i18n purposes) * BASELINE: the name of the metric (TODO: today its the display name, very bad for i18n purposes) * CHANGE: the name of the metric (TODO: today its the display name, very bad for i18n purposes) + * OR (for calltime alert conditions only) this will be the optional regular expression condition + * (which may be null) * TRAIT: the name of the trait (TODO: today its the display name, very bad for i18n purposes) * CONTROL: the name of the operation (not its display name) * EVENT: the level of event to compare with (DEBUG, INFO, WARN, ERROR, FATAL) @@ -405,11 +407,14 @@ public class AlertCondition implements Serializable { }
/** - * One of these comparators: "<", ">" or "=". - * This will be null if the condition does not compare values. Only THRESHOLD - * and BASELINE condition categories use comparators; other types of conditions - * will return <code>null</code>. + * Will be one of these comparators: "<", ">" or "=" but only for THRESHOLD + * and BASELINE condition categories. For calltime alert conditions (i.e. category + * CHANGE for calltime metric definitions), comparator will be one of these + * comparators: "HI", "LO", "CH" (where "CH" means "change"). * + * Other types of conditions will return <code>null</code> (i.e. this will be + * null if the condition does not compare values). + * * @return comparator string */ public String getComparator() { @@ -422,7 +427,8 @@ public class AlertCondition implements Serializable {
/** * Returns the threshold to compare a measurement value to see if the condition is true. - * This is only valid for conditions of category THRESHOLD and BASELINE. All other + * This is only valid for conditions of category THRESHOLD, BASELINE and CHANGE (but + * only where CHANGE is for a calltime metric alert condition). All other * condition types will return <code>null</code>. * * @return threshold value or null @@ -438,9 +444,9 @@ public class AlertCondition implements Serializable { /** * The option string is optional and its semantics differ based on the category of this condition: * AVAILABILITY: the {@link AvailabilityType} to trigger off of (DOWN or UP) - * THRESHOLD: n/a + * THRESHOLD: for calltime metric conditions, one of "MIN, "MAX", "AVG" - all others are n/a * BASELINE: one of "min", "max" or "mean" - indicates what the threshold is compared to (min/max/avg baseline value) - * CHANGE: n/a + * CHANGE: for calltime metric conditions, one of "MIN, "MAX", "AVG" - all others are n/a * TRAIT: n/a * CONTROL: the {@link OperationRequestStatus} name (SUCCESS, FAILURE, etc). * EVENT: the regular expression of the message to match (which may be empty string if not specified)
commit 24ba99780531d2f187528d7b555d79fab807467b Author: Filip Drabek fdrabek@dhcp-lab-136.englab.brq.redhat.com Date: Mon Sep 20 13:47:47 2010 +0200
BZ - 617603,617649,617653 - permission checks.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java index cb17046..d4451bc 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java @@ -985,7 +985,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
// make sure the user has the proper permissions to do this Resource resource = doomedRequest.getResource(); - if (!authorizationManager.hasResourcePermission(subject, Permission.CONFIGURE_WRITE, resource.getId())) { + if (!authorizationManager.hasResourcePermission(subject, Permission.MODIFY_RESOURCE, resource.getId())) { throw new PermissionException("User [" + subject.getName() + "] does not have permission to purge a configuration update audit trail for resource [" + resource + "]"); @@ -1909,10 +1909,10 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf public int deleteGroupResourceConfigurationUpdates(Subject subject, Integer resourceGroupId, Integer[] groupResourceConfigurationUpdateIds) {
- if (authorizationManager.hasGroupPermission(subject, Permission.CONFIGURE_WRITE, resourceGroupId) == false) { + if (authorizationManager.hasGroupPermission(subject, Permission.MODIFY_RESOURCE, resourceGroupId) == false) { log.error(subject + " attempted to delete " + groupResourceConfigurationUpdateIds.length + " group resource configuration updates for ResourceGroup[id" + resourceGroupId - + "], but did not have the " + Permission.CONFIGURE_WRITE.name() + " permission for this group"); + + "], but did not have the " + Permission.MODIFY_RESOURCE.name() + " permission for this group"); return 0; }
@@ -1983,7 +1983,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf GroupPluginConfigurationUpdate update = getGroupPluginConfigurationById(configurationUpdateId);
int groupId = update.getGroup().getId(); - if (authorizationManager.hasGroupPermission(subject, Permission.CONFIGURE_READ, groupId) == false) { + if (authorizationManager.hasGroupPermission(subject, Permission.MODIFY_RESOURCE, groupId) == false) { throw new PermissionException("User[" + subject.getName() + "] does not have permission to view group resourceConfiguration[id=" + configurationUpdateId + "]"); }
commit 7b688bc68517ad564ff0238e5aba90d52aca2766 Author: Heiko W. Rupp hwr@redhat.com Date: Mon Sep 20 13:00:33 2010 +0200
Update the test to follow the 15 mins backfill wait interval. Otherwise it fails, as the created report would be considered not old enough.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java index 00193d5..ca5ca29 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java @@ -445,7 +445,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test { } }
- @Test(enabled = ENABLE_TESTS) + @Test(enabled = true) public void testAgentBackfill() throws Exception { EntityManager em = beginTx();
@@ -456,8 +456,8 @@ public class AvailabilityManagerTest extends AbstractEJB3Test { commitAndClose(em); em = null;
- // add a report that says the resource was up 10 minutes ago - Availability avail = new Availability(theResource, new Date(System.currentTimeMillis() - 600000), UP); + // add a report that says the resource was up 20 minutes ago + Availability avail = new Availability(theResource, new Date(System.currentTimeMillis() - 12000000), UP); AvailabilityReport report = new AvailabilityReport(false, theAgent.getName()); report.addAvailability(avail); availabilityManager.mergeAvailabilityReport(report); @@ -466,12 +466,12 @@ public class AvailabilityManagerTest extends AbstractEJB3Test { // let's pretend we haven't heard from the agent in a few minutes em = beginTx(); Agent agent = em.find(Agent.class, theAgent.getId()); - agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 * 6)); + agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 * 18)); // 18 mins commitAndClose(em); em = null;
// the agent should be suspect and will be considered down - LookupUtil.getAgentManager().checkForSuspectAgents(); + LookupUtil.getAgentManager().checkForSuspectAgents(); // checks for 15 mins !! AvailabilityType curAvail; curAvail = availabilityManager.getCurrentAvailabilityTypeForResource(overlord, theResource.getId()); assert curAvail == AvailabilityType.DOWN : curAvail; // backfilled with "null" to mean "unknown"
commit c7986f9c539a6f93002eb02a846692ed09ddcc10 Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Sep 17 17:44:30 2010 -0400
Work on Group CRUD - Group category now determined on the fly, a la group def calculation, by group membership. This means a manually group can change category in its lifetime by editing the membership. That may be less important than the fact that it simplifies initial creation and users really only have to care about adding members. - Added basic support for mixed-group tree/detail view. Just enough to get us moving. - Added Inventory->Membership subtab for changing group members. - Changed ResourceManagerLocal.ensureMembershipMatches() to .setMembership() The name is cleaner and in line with naming for a series of new calls that simply syncs associated data to be the set passed in. Also, optionally can reset the group's category based on the membership change. - A couple of locatorId fixes in touched files -
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java index c4a4bca..333427f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java @@ -34,23 +34,26 @@ import org.rhq.core.domain.util.PageList; @RemoteServiceRelativePath("ResourceGroupGWTService") public interface ResourceGroupGWTService extends RemoteService {
- PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria); + GroupDefinition createGroupDefinition(GroupDefinition groupDefinition);
- PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria); + ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds);
- PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria); + void deleteGroupDefinitions(int[] groupDefinitionIds);
- void ensureMembershipMatches(int groupId, int[] resourceIds); + void deleteResourceGroups(int[] groupIds);
- ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds); + PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria);
- void deleteResourceGroups(int[] groupIds); + PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria);
- void updateResourceGroup(ResourceGroup group); + PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria); + + void setMembership(int groupId, int[] resourceIds, boolean setType);
void updateGroupDefinition(GroupDefinition groupDefinition);
- void deleteGroupDefinitions(int[] groupDefinitionIds); + void updateResourceGroup(ResourceGroup group);
- GroupDefinition createGroupDefinition(GroupDefinition groupDefinition); -} + void updateResourceGroup(ResourceGroup group, boolean updateMembership); + +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 128dff8..6603a00 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView; import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.ResourceGroupMembershipView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView; @@ -52,10 +53,9 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchVi import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/** - * Right panel of the group view. + * Be able to view members as a resource list, or edit members via selector. * - * @author Greg Hinkle - * @author Ian Springer + * @author Jay Shaughnessy */ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> { private static final String BASE_VIEW_PATH = "ResourceGroup"; @@ -83,6 +83,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource private SubTab monitorCallTime; private SubTab inventoryMembers; private SubTab inventoryConn; + private SubTab inventoryMembership; private SubTab opHistory; private SubTab opSched; private SubTab alertHistory; @@ -91,12 +92,24 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource private SubTab configHistory; private SubTab eventHistory;
+ private String currentTab; + private String currentSubTab; + public ResourceGroupDetailView(String locatorId) { super(locatorId, BASE_VIEW_PATH); }
@Override public Integer getSelectedItemId() { + // if moving from membership subtab then re-load the detail view as the membership and + // group type may have changed. + if (this.inventoryTab.getTitle().equals(currentTab) + && this.inventoryMembership.getTitle().equals(currentSubTab)) { + this.currentTab = null; + this.currentSubTab = null; + this.groupId = null; + } + return this.groupId; }
@@ -130,7 +143,8 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource "/images/icons/Inventory_grey_16.png"); inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"), "Members", null); inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null); - inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn); + inventoryMembership = new SubTab(inventoryTab.extendLocatorId("Membership"), "Membership", null); + inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn, this.inventoryMembership); tabs.add(inventoryTab);
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations", @@ -184,9 +198,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId)); this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
- this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId)); + this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(this.inventoryTab + .extendLocatorId("MembersView"), groupId)); // TODO: Uncomment this once the group config component is done. //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin)); + this.inventoryMembership.setCanvas(new ResourceGroupMembershipView(this.inventoryTab + .extendLocatorId("MembershipView"), groupId));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId)); @@ -290,6 +307,9 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource }); } }); + } else { + updateTabContent(groupComposite); + selectTab(getTabName(), getSubTabName(), viewPath); } }
@@ -305,4 +325,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource } return false; } + + @Override + public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) { + currentTab = tabTitle; + currentSubTab = subtabTitle; + super.selectTab(tabTitle, subtabTitle, viewPath); + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java index aa2ee61..ba57920 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java @@ -43,6 +43,7 @@ import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler; import org.rhq.core.domain.criteria.ResourceGroupCriteria; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ClusterKey; +import org.rhq.core.domain.resource.group.GroupCategory; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.resource.group.composite.ClusterFlyweight; import org.rhq.core.domain.resource.group.composite.ClusterKeyFlyweight; @@ -89,14 +90,11 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { treeGrid.setSortField("name"); treeGrid.setShowHeader(false);
- addMember(this.treeGrid);
- contextMenu = new ResourceGroupTreeContextMenu(); treeGrid.setContextMenu(contextMenu);
- treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() { @Override public void onSelectionChanged(SelectionEvent selectionEvent) { @@ -141,17 +139,29 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { criteria.fetchResourceType(true);
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria, - new AsyncCallback<PageList<ResourceGroup>>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load group", caught); - } - - @Override - public void onSuccess(PageList<ResourceGroup> result) { - ResourceGroup group = result.get(0); - ResourceGroupTreeView.this.selectedGroup = group; + new AsyncCallback<PageList<ResourceGroup>>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load group", caught); + }
+ @Override + public void onSuccess(PageList<ResourceGroup> result) { + ResourceGroup group = result.get(0); + ResourceGroupTreeView.this.selectedGroup = group; + + if (GroupCategory.MIXED == group.getGroupCategory()) { + ResourceGroupTreeView.this.rootResourceGroup = group; + ResourceGroupTreeView.this.rootGroupId = rootResourceGroup.getId(); + TreeNode fakeRoot = new TreeNode("fakeRootNode"); + TreeNode rootNode = new TreeNode(rootResourceGroup.getName()); + rootNode.setID(String.valueOf(rootResourceGroup.getId())); //getClusterKey().toString()); + fakeRoot.setChildren(new TreeNode[] { rootNode }); + Tree tree = new Tree(); + tree.setRoot(fakeRoot); + treeGrid.setData(tree); + treeGrid.markForRedraw(); + } else { if (group.getClusterResourceGroup() == null) { ResourceGroupTreeView.this.rootResourceGroup = group; // This is a straight up group @@ -164,12 +174,12 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
loadGroup(rootGroup.getId()); } - } - });
- } + } + });
+ }
private void loadGroup(int groupId) {
@@ -193,19 +203,17 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { treeGrid.selectRecord(selectedNode); }
- } else { this.rootGroupId = groupId; - GWTServiceLookup.getClusterService().getClusterTree(groupId, - new AsyncCallback<ClusterFlyweight>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load tree", caught); - } + GWTServiceLookup.getClusterService().getClusterTree(groupId, new AsyncCallback<ClusterFlyweight>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load tree", caught); + }
- public void onSuccess(ClusterFlyweight result) { - loadTreeTypes(result); - } - }); + public void onSuccess(ClusterFlyweight result) { + loadTreeTypes(result); + } + }); }
} @@ -215,60 +223,54 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { typeIds.add(this.rootResourceGroup.getResourceType().getId()); getTreeTypes(root, typeIds);
- ResourceTypeRepository.Cache.getInstance().getResourceTypes( - typeIds.toArray(new Integer[typeIds.size()]), - new ResourceTypeRepository.TypesLoadedCallback() { - @Override - public void onTypesLoaded(HashMap<Integer, ResourceType> types) { - ResourceGroupTreeView.this.typeMap = types; - loadTree(root); - } + ResourceTypeRepository.Cache.getInstance().getResourceTypes(typeIds.toArray(new Integer[typeIds.size()]), + new ResourceTypeRepository.TypesLoadedCallback() { + @Override + public void onTypesLoaded(HashMap<Integer, ResourceType> types) { + ResourceGroupTreeView.this.typeMap = types; + loadTree(root); } - ); + }); }
- private void selectClusterGroup(ClusterKey key) {
GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(key, true, - new AsyncCallback<ResourceGroup>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to create or update auto cluster group", caught); - } + new AsyncCallback<ResourceGroup>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to create or update auto cluster group", caught); + }
- @Override - public void onSuccess(ResourceGroup result) { - int groupId = result.getId(); - History.newItem("ResourceGroup/" + groupId); - } - }); + @Override + public void onSuccess(ResourceGroup result) { + int groupId = result.getId(); + History.newItem("ResourceGroup/" + groupId); + } + });
}
private void loadTree(ClusterFlyweight root) { TreeNode fakeRoot = new TreeNode("fakeRootNode");
- TreeNode rootNode = new TreeNode(rootResourceGroup.getName()); rootNode.setID(String.valueOf(root.getGroupId())); //getClusterKey().toString()); + ResourceType rootResourceType = typeMap.get(rootResourceGroup.getResourceType().getId()); rootNode.setAttribute("resourceType", rootResourceType); String icon = "types/" + rootResourceType.getCategory().getDisplayName() + "_up_16.png"; rootNode.setIcon(icon);
- fakeRoot.setChildren(new TreeNode[]{rootNode}); + fakeRoot.setChildren(new TreeNode[] { rootNode });
ClusterKey rootKey = new ClusterKey(root.getGroupId()); loadTree(rootNode, root, rootKey);
- - Tree tree = new Tree();
tree.setRoot(fakeRoot);
- treeGrid.setData(tree); treeGrid.markForRedraw(); } @@ -286,7 +288,8 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { TreeNode node = new TreeNode(child.getName());
ClusterKeyFlyweight keyFlyweight = child.getClusterKey(); - ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight.getResourceKey()); + ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight + .getResourceKey());
ResourceType type = this.typeMap.get(keyFlyweight.getResourceTypeId());
@@ -294,7 +297,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
node.setIcon(icon);
- node.setID(key.getKey()); node.setAttribute("key", key); node.setAttribute("resourceType", type); @@ -317,7 +319,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { setSelectedGroup(groupId); }
- private void getTreeTypes(ClusterFlyweight clusterFlyweight, Set<Integer> typeIds) { if (clusterFlyweight.getClusterKey() != null) { typeIds.add(clusterFlyweight.getClusterKey().getResourceTypeId()); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java new file mode 100644 index 0000000..e08b57d --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java @@ -0,0 +1,129 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory; + +import java.util.HashSet; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.IButton; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.layout.LayoutSpacer; +import com.smartgwt.client.widgets.toolbar.ToolStrip; + +import org.rhq.core.domain.criteria.ResourceGroupCriteria; +import org.rhq.core.domain.resource.group.ResourceGroup; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/** + * @author Jay Shaughnessy + */ +public class ResourceGroupMembershipView extends LocatableVLayout { + + private int resourceGroupId; + private ResourceGroup resourceGroup; + private ResourceGroupResourceSelector selector; + + public ResourceGroupMembershipView(String locatorId, int resourceGroupId) { + super(locatorId); + + this.resourceGroupId = resourceGroupId; + } + + @Override + protected void onDraw() { + super.onDraw(); + + build(); + } + + public void build() { + ToolStrip toolStrip = new ToolStrip(); + toolStrip.setWidth100(); + + toolStrip.addMember(new LayoutSpacer()); + + IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); + saveButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + save(); + } + }); + + toolStrip.addMember(saveButton); + this.addMember(toolStrip); + + ResourceGroupCriteria c = new ResourceGroupCriteria(); + c.addFilterId(this.resourceGroupId); + c.fetchExplicitResources(true); + GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(c, + new AsyncCallback<PageList<ResourceGroup>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to fetch Resource Group", caught); + } + + public void onSuccess(PageList<ResourceGroup> result) { + ResourceGroupMembershipView.this.resourceGroup = result.get(0); + ResourceGroupMembershipView.this.selector = new ResourceGroupResourceSelector( + ResourceGroupMembershipView.this.getLocatorId(), ResourceGroupMembershipView.this.resourceGroup + .getExplicitResources()); + ResourceGroupMembershipView.this.selector.setOverflow(Overflow.AUTO); + + addMember(ResourceGroupMembershipView.this.selector); + } + }); + } + + private void save() { + int[] resourceIds = getSelectedResourceIds(); + + GWTServiceLookup.getResourceGroupService().setMembership(this.resourceGroup.getId(), resourceIds, true, + new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify( + new Message("Group membership updated for [" + + ResourceGroupMembershipView.this.resourceGroup.getName() + "]", Message.Severity.Info)); + CoreGUI.refresh(); + } + }); + } + + private int[] getSelectedResourceIds() { + int[] selection = new int[this.selector.getSelection().size()]; + HashSet<Integer> selectedIds = this.selector.getSelection(); + int i = 0; + for (Integer id : selectedIds) { + selection[i++] = id; + } + + return selection; + } + +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java new file mode 100644 index 0000000..6bc96fb --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java @@ -0,0 +1,45 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory; + +import java.util.Collection; + +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector; + +/** + * @author Jay Shaughnessy + */ +public class ResourceGroupResourceSelector extends ResourceSelector { + + public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources) { + super(locatorId); + if (null != resources) { + ListGridRecord[] data = (new ResourceDatasource()).buildRecords(resources); + setAssigned(data); + } + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java index 41aff20..2c3f364 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java @@ -91,7 +91,7 @@ public class OverviewView extends LocatableVLayout { return; } group.setName(newName); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( "Failed to change name of Resource group with id " + group.getId() + " from "" @@ -141,7 +141,7 @@ public class OverviewView extends LocatableVLayout { return; } group.setDescription(newDescription); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( "Failed to change description of Resource group with id " + group.getId() + " from "" @@ -177,7 +177,7 @@ public class OverviewView extends LocatableVLayout { return; } group.setLocation(newLocation); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( "Failed to change location of Resource group with id " + group.getId() + " from "" @@ -224,7 +224,8 @@ public class OverviewView extends LocatableVLayout { StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", "Group Definition"); GroupDefinition groupDefinition = group.getGroupDefinition(); String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId()); - groupDefinitionItem.setValue("<a href="" + groupDefinitionUrl + "">" + groupDefinition.getName() + "</a>"); + groupDefinitionItem + .setValue("<a href="" + groupDefinitionUrl + "">" + groupDefinition.getName() + "</a>"); formItems.add(groupDefinitionItem); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java index f06f6ae..6b4664a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java @@ -22,22 +22,16 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.wizard;
-import java.util.LinkedHashMap; - import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.ValuesManager; import com.smartgwt.client.widgets.form.fields.AutoFitTextAreaItem; import com.smartgwt.client.widgets.form.fields.CheckboxItem; -import com.smartgwt.client.widgets.form.fields.IPickTreeItem; import com.smartgwt.client.widgets.form.fields.TextAreaItem; import com.smartgwt.client.widgets.form.fields.TextItem;
-import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ResourceGroup; -import org.rhq.enterprise.gui.coregui.client.components.form.RadioGroupWithComponentsItem; import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypePluginTreeDataSource; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** @@ -68,42 +62,14 @@ public class GroupCreateStep extends AbstractWizardStep {
CheckboxItem recursive = new CheckboxItem("recursive", "Recursive");
- LinkedHashMap<String, Canvas> options = new LinkedHashMap<String, Canvas>(); - options.put("Mixed", null); - - IPickTreeItem typeSelectItem = new IPickTreeItem("type", "Type"); - typeSelectItem.setDataSource(new ResourceTypePluginTreeDataSource()); - typeSelectItem.setValueField("id"); - typeSelectItem.setCanSelectParentItems(true); - typeSelectItem.setLoadDataOnDemand(false); - typeSelectItem.setEmptyMenuMessage("Loading..."); - typeSelectItem.setShowIcons(true); - - DynamicForm form2 = new LocatableDynamicForm("TypeTree"); - form2.setValuesManager(form.getValuesManager()); - form2.setFields(typeSelectItem); - options.put("Compatible", form2); - - RadioGroupWithComponentsItem kind = new RadioGroupWithComponentsItem("groupType", "Group Type", options, - form); - kind.setValue("Mixed"); - form.setFields(name, description, location, recursive, kind); - + form.setFields(name, description, location, recursive); } + return form; }
public boolean nextPage() { - boolean valid = form.validate(); - if (valid) { - RadioGroupWithComponentsItem kind = (RadioGroupWithComponentsItem) form.getField("groupType"); - if ("Compatible".equals(kind.getSelected())) { - DynamicForm form2 = (DynamicForm) kind.getSelectedComponent(); - valid = (null != form2.getValue("type")); - } - } - - return valid; + return form.validate(); }
public String getName() { @@ -116,16 +82,6 @@ public class GroupCreateStep extends AbstractWizardStep { group.setLocation(form.getValueAsString("location")); group.setRecursive(form.getValue("recursive") != null ? true : false);
- RadioGroupWithComponentsItem kind = (RadioGroupWithComponentsItem) form.getField("groupType"); - if ("Compatible".equals(kind.getSelected())) { - DynamicForm form2 = (DynamicForm) kind.getSelectedComponent(); - if (null != form2.getValue("type")) { - ResourceType rt = new ResourceType(); - rt.setId(Integer.parseInt(form2.getValueAsString("type"))); - group.setResourceType(rt); - } - } - return group; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java index a55b334..fbbf71e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java @@ -28,7 +28,6 @@ import java.util.List; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.IButton;
-import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard; @@ -67,23 +66,11 @@ public class GroupCreateWizard extends AbstractWizard { }
public String getSubtitle() { - return null; // TODO: Implement this method. + return null; }
public List<IButton> getCustomButtons(int step) { - return null; // TODO: Implement this method. - } - - /** - * @return only the rt id is set - */ - public ResourceType getCompatibleGroupResourceType() { - ResourceGroup rg = createStep.getGroup(); - ResourceType rt = null; - if (null != rg) { - rt = rg.getResourceType(); - } - return rt; + return null; }
public void cancel() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java index 3a3048d..2e3e9c7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java @@ -26,7 +26,6 @@ import java.util.HashSet;
import com.smartgwt.client.widgets.Canvas;
-import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep; import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
@@ -37,18 +36,14 @@ public class GroupMembersStep extends AbstractWizardStep {
private GroupCreateWizard wizard = null; private ResourceSelector selector = null; - private ResourceType requireType = null;
public GroupMembersStep(GroupCreateWizard wizard) { this.wizard = wizard; }
public Canvas getCanvas() { - ResourceType rt = wizard.getCompatibleGroupResourceType(); - if ((selector == null) || (rt != requireType)) { + if (selector == null) { selector = new ResourceSelector(getName()); - requireType = rt; - selector.setRequireType(rt); } return selector; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index faa406e..ed442b2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -57,8 +57,8 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView private static final String SECTION_GROUPS = "Groups"; private static final String SECTION_RESOURCES = "Resources";
- private static final String SUBSECTION_RESOURCE_INVENTORY = "Resource Inventory"; - private static final String SUBSECTION_GROUP_INVENTORY = "Group Inventory"; + private static final String SUBSECTION_RESOURCE_INVENTORY = "Resources"; + private static final String SUBSECTION_GROUP_INVENTORY = "Groups"; private static final String SUBSECTION_SAVED_SEARCHES = "Saved Searches";
private static final String PAGE_ADQ = "Discovery Manager"; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java index 9817819..71f1996 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java @@ -182,14 +182,13 @@ public class ResourceSearchView extends Table {
// -------- Static Utility loaders ------------
- public static ResourceSearchView getChildrenOf(int resourceId) { - return new ResourceSearchView("ResourceSearchChildren", new Criteria("parentId", String.valueOf(resourceId)), + public static ResourceSearchView getChildrenOf(String locatorId, int resourceId) { + return new ResourceSearchView(locatorId, new Criteria("parentId", String.valueOf(resourceId)), "Child Resources"); }
- public static ResourceSearchView getMembersOf(int groupId) { - return new ResourceSearchView("ResourceSearchMemberOf", new Criteria("groupId", String.valueOf(groupId)), - "Member Resources"); + public static ResourceSearchView getMembersOf(String locatorId, int groupId) { + return new ResourceSearchView(locatorId, new Criteria("groupId", String.valueOf(groupId)), "Member Resources"); }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index 2edb50f..e80be32 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -207,7 +207,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId()));
- this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(resource.getId())); + this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource + .getId())); this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource));
// comment out GWT-based operation history until... diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java index e9f773d..b1ad07f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java @@ -49,8 +49,8 @@ public class ResourceSelector extends AbstractSelector<Resource> {
private ResourceType requireType;
- public ResourceSelector(String id) { - super(id); + public ResourceSelector(String locatorId) { + super(locatorId); }
public ResourceType getRequireType() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java index b2ec813..b9642d6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.gui.coregui.server.gwt;
+import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.criteria.ResourceGroupCriteria; import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; import org.rhq.core.domain.resource.group.GroupDefinition; @@ -36,34 +37,57 @@ import org.rhq.enterprise.server.util.LookupUtil; */ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implements ResourceGroupGWTService {
+ private static final long serialVersionUID = 1L; + private ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager(); private GroupDefinitionManagerLocal definitionManager = LookupUtil.getGroupDefinitionManager();
public PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria) { - return SerialUtility.prepare(groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria), - "ResourceGroupService.findResourceGroupsByCriteria"); + try { + PageList<ResourceGroup> groups = groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria); + return SerialUtility.prepare(groups, "ResourceGroupService.findResourceGroupsByCriteria"); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria) { - return SerialUtility.prepare(groupManager.findResourceGroupCompositesByCriteria(getSessionSubject(), criteria), - "ResourceGroupService.findResourceGroupCompositesByCriteria"); + try { + PageList<ResourceGroupComposite> composites = groupManager.findResourceGroupCompositesByCriteria( + getSessionSubject(), criteria); + return SerialUtility.prepare(composites, "ResourceGroupService.findResourceGroupCompositesByCriteria"); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria) { - return SerialUtility.prepare(definitionManager.findGroupDefinitionsByCriteria(getSessionSubject(), criteria), - "ResourceGroupService.findGroupDefinitionsByCriteria"); + try { + PageList<GroupDefinition> definitions = definitionManager.findGroupDefinitionsByCriteria( + getSessionSubject(), criteria); + return SerialUtility.prepare(definitions, "ResourceGroupService.findGroupDefinitionsByCriteria"); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
- public void ensureMembershipMatches(int groupId, int[] resourceIds) { - groupManager.ensureMembershipMatches(getSessionSubject(), groupId, resourceIds); + public void setMembership(int groupId, int[] resourceIds, boolean setType) { + try { + groupManager.setMembership(getSessionSubject(), groupId, resourceIds, setType); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds) { - group = groupManager.createResourceGroup(getSessionSubject(), group); - - ensureMembershipMatches(group.getId(), resourceIds); - - return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup"); + try { + Subject user = getSessionSubject(); + group = groupManager.createResourceGroup(user, group); + groupManager.setMembership(user, group.getId(), resourceIds, true); + return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup"); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public void deleteResourceGroups(int[] groupIds) { @@ -75,7 +99,19 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen }
public void updateResourceGroup(ResourceGroup group) { - groupManager.updateResourceGroup(getSessionSubject(), group); + try { + groupManager.updateResourceGroup(getSessionSubject(), group); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } + } + + public void updateResourceGroup(ResourceGroup group, boolean updateMembership) { + try { + groupManager.updateResourceGroup(getSessionSubject(), group, null, updateMembership); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public GroupDefinition createGroupDefinition(GroupDefinition groupDefinition) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java index 10611fa..4aaf7ca 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java @@ -48,7 +48,6 @@ import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.PermissionException; import org.rhq.enterprise.server.resource.group.ResourceGroupAlreadyExistsException; import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; -import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
/** * @@ -139,9 +138,9 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe try { // You are allowed to cause the creation of an auto cluster backing group as long as you can // view the parent group. (That check was done above) - resourceGroupManager.ensureMembershipMatches(subjectManager.getOverlord(), autoClusterBackingGroup - .getId(), resourceIds); - } catch (ResourceGroupUpdateException e) { + resourceGroupManager.setMembership(subjectManager.getOverlord(), autoClusterBackingGroup.getId(), + resourceIds, false); + } catch (Exception e) { log.error("Could not add resources to group:" + e); } } @@ -177,11 +176,10 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe }
public ClusterFlyweight getClusterTree(Subject subject, int groupId) { - Query query = entityManager.createQuery( - "SELECT r.id, r.resourceType.id, r.parentResource.id, r.resourceKey, r.name, " + - "(SELECT count(r2) FROM Resource r2 join r2.explicitGroups g2 WHERE g2.id = :groupId and r2.id = r.id) " + - "FROM Resource r join r.implicitGroups g " + - "WHERE g.id = :groupId"); + Query query = entityManager + .createQuery("SELECT r.id, r.resourceType.id, r.parentResource.id, r.resourceKey, r.name, " + + "(SELECT count(r2) FROM Resource r2 join r2.explicitGroups g2 WHERE g2.id = :groupId and r2.id = r.id) " + + "FROM Resource r join r.implicitGroups g " + "WHERE g.id = :groupId");
query.setParameter("groupId", groupId); List<Object[]> rs = query.getResultList(); @@ -203,7 +201,6 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe } }
- ClusterFlyweight key = new ClusterFlyweight(groupId);
buildTree(groupId, key, explicitResources, dataMap); @@ -211,7 +208,8 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe return key; }
- private void buildTree(int groupId, ClusterFlyweight parent, Set<Integer> parentIds, Map<Integer,List<Object[]>> data) { + private void buildTree(int groupId, ClusterFlyweight parent, Set<Integer> parentIds, + Map<Integer, List<Object[]>> data) {
for (Integer parentId : parentIds) {
@@ -219,32 +217,29 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe Map<ClusterKeyFlyweight, Set<Integer>> members = new HashMap<ClusterKeyFlyweight, Set<Integer>>();
if (data.get(parentId) != null) { - for (Object[] child : data.get(parentId)) { - ClusterKeyFlyweight n = new ClusterKeyFlyweight((Integer)child[1], (String)child[3]); + for (Object[] child : data.get(parentId)) { + ClusterKeyFlyweight n = new ClusterKeyFlyweight((Integer) child[1], (String) child[3]); ClusterFlyweight flyweight = children.get(n); - Set<Integer> memberList = members.get(n); - if (flyweight == null) { - flyweight = new ClusterFlyweight(n); - children.put(n, flyweight); - memberList = new HashSet<Integer>(); - members.put(n, memberList); + Set<Integer> memberList = members.get(n); + if (flyweight == null) { + flyweight = new ClusterFlyweight(n); + children.put(n, flyweight); + memberList = new HashSet<Integer>(); + members.put(n, memberList); + } + flyweight.addResource((String) child[4]); + memberList.add((Integer) child[0]); } - flyweight.addResource((String)child[4]); - memberList.add((Integer) child[0]); - } }
parent.setChildren(new ArrayList<ClusterFlyweight>(children.values()));
- for (ClusterFlyweight child : children.values()) { buildTree(groupId, child, members.get(child.getClusterKey()), data); } } }
- - private String getClusterKeyQuery(ClusterKey clusterKey) { if (null == clusterKey) return null; diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java index 04dd614..28ae218 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java @@ -171,8 +171,19 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso }
@RequiredPermission(Permission.MANAGE_INVENTORY) - public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType) + public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group) throws ResourceGroupUpdateException { + return updateResourceGroup(subject, group, null, true); + } + + @RequiredPermission(Permission.MANAGE_INVENTORY) + public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group, RecursivityChangeType changeType) throws ResourceGroupUpdateException { + return updateResourceGroup(subject, group, null, true); + } + + @RequiredPermission(Permission.MANAGE_INVENTORY) + public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType, + boolean updateMembership) throws ResourceGroupUpdateException {
int groupId = group.getId(); ResourceGroup attachedGroup = entityManager.find(ResourceGroup.class, groupId); @@ -198,6 +209,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso } }
+ if (!updateMembership) { + group.setExplicitResources(attachedGroup.getExplicitResources()); + group.setImplicitResources(attachedGroup.getImplicitResources()); + } + group.setMtime(System.currentTimeMillis()); group.setModifiedBy(user.getName());
@@ -320,7 +336,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso try { operationManager.unscheduleGroupOperation(overlord, schedule.getJobId().toString(), group.getId()); } catch (UnscheduleException e) { - log.warn("Failed to unschedule job [" + schedule + "] for a group being deleted [" + group + "]", e); + log + .warn("Failed to unschedule job [" + schedule + "] for a group being deleted [" + group + "]", + e); } } } catch (Exception e) { @@ -759,8 +777,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso * to this method, we can just do simple RHQ_RESOURCE_GROUP_RES_IMP_MAP table insertions */ String insertImplicitQueryString = JDBCUtil.transformQueryForMultipleInParameters( - ResourceGroup.QUERY_NATIVE_ADD_RESOURCES_TO_GROUP_IMPLICIT, "@@RESOURCE_IDS@@", - resourceIdsToAdd.size()); + ResourceGroup.QUERY_NATIVE_ADD_RESOURCES_TO_GROUP_IMPLICIT, "@@RESOURCE_IDS@@", resourceIdsToAdd + .size()); insertImplicitStatement = conn.prepareStatement(insertImplicitQueryString); insertImplicitStatement.setInt(1, implicitRecursiveGroupId); JDBCUtil.bindNTimes(insertImplicitStatement, ArrayUtils.unwrapCollection(resourceIdsToAdd), 2); @@ -822,9 +840,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso ResourceGroup group = getResourceGroupById(subject, groupId, category); Set<Resource> res = group.getExplicitResources(); if (res != null && res.size() > 0) { - List<Resource> resources = PersistenceUtility.getHibernateSession(entityManager) - .createFilter(res, "where this.inventoryStatus = :inventoryStatus") - .setParameter("inventoryStatus", InventoryStatus.COMMITTED).list(); + List<Resource> resources = PersistenceUtility.getHibernateSession(entityManager).createFilter(res, + "where this.inventoryStatus = :inventoryStatus").setParameter("inventoryStatus", + InventoryStatus.COMMITTED).list();
return resources; } else { @@ -1278,7 +1296,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso return groupIds; }
- public void ensureMembershipMatches(Subject subject, int groupId, int[] resourceIds) { + public void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType) + throws ResourceGroupDeleteException { //throws ResourceGroupUpdateException { List<Integer> currentMembers = resourceManager.findExplicitResourceIdsByResourceGroup(groupId);
@@ -1293,6 +1312,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso if (extraMembers.size() > 0) { removeResourcesFromGroup(subject, groupId, ArrayUtils.unwrapCollection(extraMembers)); } + + // As a result of the membership change ensure that the group type is set correctly. + if (setType) { + setResourceType(groupId); + } }
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -1402,11 +1426,6 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso : RecursivityChangeType.RemovedRecursion); }
- @RequiredPermission(Permission.MANAGE_INVENTORY) - public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group) throws ResourceGroupUpdateException { - return updateResourceGroup(subject, group, null); - } - @SuppressWarnings("unchecked") public PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria) { CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java index 2919879..45f7cc4 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java @@ -42,9 +42,6 @@ import org.rhq.core.domain.util.PageList; @Local public interface ResourceGroupManagerLocal {
- ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType) - throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException; - ResourceGroup getResourceGroupById(Subject user, int id, GroupCategory category) throws ResourceGroupNotFoundException;
@@ -108,10 +105,30 @@ public interface ResourceGroupManagerLocal {
List<Integer> findDeletedResourceGroupIds(int[] groupIds);
- void ensureMembershipMatches(Subject subject, int groupId, int[] resourceIds) throws ResourceGroupUpdateException; + /** + * This method ensures that the explicit group membership is set to the specified resources. Members + * will be added or removed as necessary. Make sure you pass the correct value for the <setType> + * parameter. + * + * @param subject + * @param groupId + * @param resourceIds + * @param setType Set to false if the specified resourceIds will not alter the group type (compatible or + * mixed). Set true to have the group type (re)set automatically, based on the new group membership. + * @throws ResourceGroupUpdateException + * @throws ResourceGroupDeleteException + */ + void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType) + throws ResourceGroupUpdateException, ResourceGroupDeleteException;
void uninventoryMembers(Subject subject, int groupId);
+ ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType) + throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException; + + ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType, + boolean updateMembership) throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException; + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // // The following are shared with the Remote Interface @@ -141,5 +158,4 @@ public interface ResourceGroupManagerLocal { ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group);
PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria); - } \ No newline at end of file
commit 3f9bf4117760546e9efd7284cee6ee61e0090405 Merge: e7d80ea... 19cc4a4... Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Sep 17 17:58:39 2010 -0400
Merge branch 'master' into master-jay
commit 19cc4a49d4041a3dcfdf4cb05bff2ab0b56edec1 Author: Ian Springer ian.springer@redhat.com Date: Fri Sep 17 17:40:48 2010 -0400
add support to as5 plugin for managing AS 6.0 M4 and later (https://bugzilla.redhat.com/show_bug.cgi?id=619240); add support to as5 plugin for discovering and managing AS instances with non-standard lib dirs, e.g. jboss.lib.url (https://bugzilla.redhat.com/show_bug.cgi?id=635158); move JmxConnectionHelper to jboss-as-common module
diff --git a/modules/common/jboss-as/pom.xml b/modules/common/jboss-as/pom.xml index d69311c..b60da0b 100644 --- a/modules/common/jboss-as/pom.xml +++ b/modules/common/jboss-as/pom.xml @@ -45,6 +45,12 @@ </dependency>
<dependency> + <groupId>mc4j</groupId> + <artifactId>org-mc4j-ems</artifactId> + <!-- NOTE: The version is defined in the root POM's dependencyManagement section. --> + </dependency> + + <dependency> <groupId>${project.groupId}</groupId> <artifactId>rhq-core-plugin-api</artifactId> <version>${project.version}</version> diff --git a/modules/common/jboss-as/src/main/java/org/jboss/on/common/jbossas/JmxConnectionHelper.java b/modules/common/jboss-as/src/main/java/org/jboss/on/common/jbossas/JmxConnectionHelper.java new file mode 100644 index 0000000..dc57a78 --- /dev/null +++ b/modules/common/jboss-as/src/main/java/org/jboss/on/common/jbossas/JmxConnectionHelper.java @@ -0,0 +1,262 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.jboss.on.common.jbossas; + +import java.io.File; +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.mc4j.ems.connection.ConnectionFactory; +import org.mc4j.ems.connection.EmsConnection; +import org.mc4j.ems.connection.settings.ConnectionSettings; +import org.mc4j.ems.connection.support.ConnectionProvider; +import org.mc4j.ems.connection.support.metadata.ConnectionTypeDescriptor; +import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; + +/** + * Shared helper class to connect to a remote JMX server. + * + * @author Heiko W. Rupp + */ +public class JmxConnectionHelper { + public static final String CONNECTOR_DESCRIPTOR_TYPE = "connectorDescriptorType"; + public static final String CONNECTOR_ADDRESS = "connectorAddress"; + public static final String CONNECTOR_PRINCIPAL = "connectorPrincipal"; + public static final String CONNECTOR_CREDENTIALS = "connectorCredentials"; + public static final String JBOSS_HOME_DIR = "jbossHomeDir"; + + private static final Log log = LogFactory.getLog(JmxConnectionHelper.class); + + private static EmsConnection connection; + private static Configuration configuration; + + private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery"; + + /** + * This is the timeout for the initial connection to the MBeanServer that is made by the AS ResourceComponent's + * start method. + */ + private static final int JNP_TIMEOUT = 30 * 1000; // 30 seconds + /** + * This is the timeout for MBean attribute gets/sets and operations invoked on the remote MBeanServer. + * NOTE: This timeout comes into play if the JBossAS instance has gone down since the original JNP connection was made. + */ + private static final int JNP_SO_TIMEOUT = 15 * 1000; // 15 seconds + + /** + * Controls the dampening of connection error stack traces in an attempt to control spam to the log file. Each time + * a connection error is encountered, this will be incremented. When the connection is finally established, this + * will be reset to zero. + */ + private static int consecutiveConnectionErrors; + + private boolean copyConnectionLibraries; + private File tmpDir; + + /** + * Constructs a new connection helper. + * + * @param copyConnectionLibraries whether to copy the libraries need for the connection so that + * the ems classloader doesn't block the application access to them. + * @param tmpDir the temporary directory to use when copying the libraries + */ + public JmxConnectionHelper(boolean copyConnectionLibraries, File tmpDir) { + this.copyConnectionLibraries = copyConnectionLibraries; + this.tmpDir = tmpDir; + } + + /** + * Obtain an EmsConnection for the passed connection properties. The properties will be retained. + * To create a connection with different properties, use this method again with a different set + * of properties. + * @param config Configuration properties for this connection + * @return an EmsConnection or null in case of failure + * @see #getEmsConnection() + */ + public EmsConnection getEmsConnection(Configuration config) { + EmsConnection emsConnection = null; + configuration = config; + + try { + emsConnection = loadConnection(config, copyConnectionLibraries, tmpDir); + } catch (Exception e) { + log.error("Component attempting to access a connection that could not be loaded"); + } + + return emsConnection; + } + + /** + * Obtain an EmsConnection. This will only work if the connection properties have passed + * before via a call to {@link #getEmsConnection(Configuration)} + * @return an EmsConnection or null in case of failure + * @see #getEmsConnection(org.rhq.core.domain.configuration.Configuration) + */ + public EmsConnection getEmsConnection() { + EmsConnection emsConnection = null; + if (configuration == null) { + throw new RuntimeException("No configuration set"); + } + + try { + emsConnection = loadConnection(configuration, copyConnectionLibraries, tmpDir); + } catch (Exception e) { + log.error("Component attempting to access a connection that could not be loaded"); + } + + return emsConnection; + } + + /** + * This is the preferred way to use a connection from within this class; methods should not access the connection + * property directly as it may not have been instantiated if the connection could not be made. + * <p/> + * <p>If the connection has already been established, return the object reference to it. If not, attempt to make a + * live connection to the JMX server.</p> + * <p/> + * <p>If the connection could not be made in the start(org.rhq.core.pluginapi.inventory.ResourceContext) method, + * this method will effectively try to load the connection on each attempt to use it. As such, multiple threads may + * attempt to access the connection through this means at a time. Therefore, the method has been made synchronized + * on instances of the class.</p> + * <p/> + * <p>If any errors are encountered, this method will log the error, taking into account logic to prevent spamming + * the log file. Calling methods should take care to not redundantly log the exception thrown by this method.</p> + * + * @param pluginConfig + * @return live connection to the JMX server; this will not be <code>null</code> + * @throws Exception if there are any issues at all connecting to the server + */ + private static synchronized EmsConnection loadConnection(Configuration pluginConfig, + boolean copyConnectionLibraries, File tmpDir) throws Exception { + if (connection == null) { + try { + //Configuration pluginConfig = this.resourceContext.getPluginConfiguration(); + + ConnectionSettings connectionSettings = new ConnectionSettings(); + + String connectionTypeDescriptorClass = pluginConfig.getSimple(CONNECTOR_DESCRIPTOR_TYPE) + .getStringValue(); + PropertySimple serverUrl = pluginConfig.getSimple(CONNECTOR_ADDRESS); + + connectionSettings.initializeConnectionType((ConnectionTypeDescriptor) Class.forName( + connectionTypeDescriptorClass).newInstance()); + // if not provided use the default serverUrl + if (null != serverUrl) { + connectionSettings.setServerUrl(serverUrl.getStringValue()); + } + + connectionSettings.setPrincipal(pluginConfig.getSimpleValue(CONNECTOR_PRINCIPAL, null)); + connectionSettings.setCredentials(pluginConfig.getSimpleValue(CONNECTOR_CREDENTIALS, null)); + connectionSettings.setLibraryURI(pluginConfig.getSimpleValue(JBOSS_HOME_DIR, null)); + + if (connectionSettings.getAdvancedProperties() == null) { + connectionSettings.setAdvancedProperties(new Properties()); + } + + connectionSettings.getAdvancedProperties().setProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, "true"); + connectionSettings.getAdvancedProperties().setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, "true"); + + // Make sure the timeout always happens, even if the JBoss server is hung. + connectionSettings.getAdvancedProperties().setProperty("jnp.timeout", String.valueOf(JNP_TIMEOUT)); + connectionSettings.getAdvancedProperties().setProperty("jnp.sotimeout", String.valueOf(JNP_SO_TIMEOUT)); + + // TODO (ips): Remove this? + connectionSettings.getAdvancedProperties().setProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, + Boolean.TRUE.toString()); + + if (copyConnectionLibraries) { + // Tell EMS to make copies of jar files so that the ems classloader doesn't lock + // application files (making us unable to update them) Bug: JBNADM-670 + connectionSettings.getControlProperties().setProperty(ConnectionFactory.COPY_JARS_TO_TEMP, + String.valueOf(Boolean.TRUE)); + } + + // Tell EMS to use the plugin's temp dir, so the PC will be able to clean it up and so an access control + // policy can easily be defined for the dir. EMS will use this for connection libraries (i.e. client + // jars) if COPY_JARS control prop is true, but it will also use it for the ems-mpl jar no matter what, + // so we need to always set it. + connectionSettings.getControlProperties().setProperty(ConnectionFactory.JAR_TEMP_DIR, + tmpDir.getAbsolutePath()); + + connectionSettings.getAdvancedProperties().setProperty(InternalVMTypeDescriptor.DEFAULT_DOMAIN_SEARCH, + "jboss"); + + ConnectionFactory connectionFactory = new ConnectionFactory(); + connectionFactory.discoverServerClasses(connectionSettings); + + ConnectionProvider connectionProvider = connectionFactory.getConnectionProvider(connectionSettings); + connection = connectionProvider.connect(); + + connection.loadSynchronous(false); // this loads all the MBeans + + consecutiveConnectionErrors = 0; + + if (log.isDebugEnabled()) + log.debug("Successfully made connection to the remote server instance"); + } catch (Exception e) { + + // The connection will be established even in the case that the principal cannot be authenticated, + // but the connection will not work. That failure seems to come from the call to loadSynchronous after + // the connection is established. If we get to this point that an exception was thrown, close any + // connection that was made and null it out so we can try to establish it again. + if (connection != null) { + if (log.isDebugEnabled()) + log.debug("Connection created but an exception was thrown. Closing the connection.", e); + connection.close(); + connection = null; + } + + // Since the connection is attempted each time it's used, failure to connect could result in log + // file spamming. Log it once for every 10 consecutive times it's encountered. + if (consecutiveConnectionErrors % 10 == 0) { + log.warn("Could not establish connection to the instance [" + (consecutiveConnectionErrors + 1) + + "] times.", e); + } + + if (log.isDebugEnabled()) + log.debug("Could not connect to the instance for resource ", e); + + consecutiveConnectionErrors++; + + throw e; + } + } + + return connection; + } + + /** + * If necessary attempt to close the EMS connection, then set this.connection null. Synchronized ensure we play + * well with loadConnection. + */ + public synchronized void closeConnection() { + if (connection != null) { + try { + connection.close(); + } catch (Exception e) { + log.error("Error closing EMS connection: " + e); + } + connection = null; + } + } +} diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 720d1ab..361ac15 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -353,8 +353,13 @@ public class InventoryManager extends AgentService implements ContainerService, parentResourceContext, SystemInfoFactory.createSystemInfo(), null, null, this.configuration .getContainerName(), this.configuration.getPluginContainerDeployment());
+ // Configurations are not immutable, so clone the plugin config, so the plugin will not be able to change the + // actual PC-managed plugin config. + Configuration pluginConfigClone = resource.getPluginConfiguration().deepCopy(false); + // TODO (ips): Clone the ResourceType too for the same reason. + DiscoveredResourceDetails details = new DiscoveredResourceDetails(resourceType, resource.getResourceKey(), - resource.getName(), resource.getVersion(), resource.getDescription(), resource.getPluginConfiguration(), + resource.getName(), resource.getVersion(), resource.getDescription(), pluginConfigClone, null); // TODO: I have a feeling we'll need process info, how to get it??
List<URL> results = proxy.getAdditionalClasspathUrls(discoveryContext, details); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java index bef5806..f8ac5a1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java @@ -75,9 +75,10 @@ public class UpdateCollectionIntervalWidget extends LocatableHLayout implements refresh(UpdateCollectionIntervalWidget.this.schedulesView.getListGrid()); } }); + // Specify a null title so no label is rendered to the left of the combo box. SelectItem unitsItem = new SelectItem("units", null); - unitsItem.setValueMap("seconds", "minutes", "hours"); - unitsItem.setDefaultValue("seconds"); + unitsItem.setValueMap("second(s)", "minute(s)", "hour(s)"); + unitsItem.setDefaultValue("second(s)"); unitsItem.setShowTitle(false); this.form.setFields(intervalItem, unitsItem); addMember(this.form); diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java index 6b5dfa4..855791a 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java @@ -47,6 +47,7 @@ import org.jboss.managed.api.ManagedComponent; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.on.common.jbossas.JBPMWorkflowManager; import org.jboss.on.common.jbossas.JBossASPaths; +import org.jboss.on.common.jbossas.JmxConnectionHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -88,7 +89,6 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnectionProvider; import org.rhq.plugins.jbossas5.connection.RemoteProfileServiceConnectionProvider; import org.rhq.plugins.jbossas5.helper.CreateChildResourceFacetDelegate; import org.rhq.plugins.jbossas5.helper.JBossAS5ConnectionTypeDescriptor; -import org.rhq.plugins.jbossas5.helper.JmxConnectionHelper; import org.rhq.plugins.jbossas5.helper.InPluginControlActionFacade; import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java index 94cad13..1eb9df6 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java @@ -1,6 +1,6 @@ /* * Jopr Management Platform -* Copyright (C) 2005-2009 Red Hat, Inc. +* Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -24,10 +24,11 @@ package org.rhq.plugins.jbossas5;
import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; import java.net.InetAddress; +import java.net.MalformedURLException; import java.net.URL; import java.net.UnknownHostException; import java.util.ArrayList; @@ -66,9 +67,10 @@ import org.rhq.plugins.jbossas5.helper.JBossInstanceInfo; import org.rhq.plugins.jbossas5.helper.JBossProductType; import org.rhq.plugins.jbossas5.helper.JBossProperties; import org.rhq.plugins.jbossas5.util.JnpConfig; +import org.rhq.plugins.jbossas5.util.ResourceComponentUtils;
/** - * A Resource discovery component for JBoss AS Server Resources, which include the following: + * A Resource discovery component for JBoss application server Resources, which include the following: * * JBoss AS, 5.2.0.Beta1 and later * JBoss EAP, 5.0.0.Beta and later @@ -78,6 +80,7 @@ import org.rhq.plugins.jbossas5.util.JnpConfig; * @author Ian Springer * @author Mark Spritzler */ +@SuppressWarnings({"UnusedDeclaration"}) public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryComponent, ClassLoaderFacet, ManualAddFacet { private static final String CHANGE_ME = "***CHANGE_ME***"; @@ -87,7 +90,8 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom private static final String LOCALHOST = "127.0.0.1"; private static final String JAVA_HOME_ENV_VAR = "JAVA_HOME";
- private static final Map<JBossProductType, ComparableVersion> MINIMUM_PRODUCT_VERSIONS = new HashMap(3); + private static final Map<JBossProductType, ComparableVersion> MINIMUM_PRODUCT_VERSIONS = + new HashMap<JBossProductType, ComparableVersion>(4); static { MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.AS, new ComparableVersion("5.2.0.Beta1")); MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.EAP, new ComparableVersion("5.0.0.Beta")); @@ -95,19 +99,23 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.SOA, new ComparableVersion("5.0.0.Beta")); }
- private static final List<String> CLIENT_JARS = Arrays.asList( + private static final String[] CLIENT_JAR_URLS = new String[] { // NOTE: The jbossall-client.jar aggregates a whole bunch of other jars from the client dir via its // MANIFEST.MF Class-Path. - "client/jbossall-client.jar", "client/trove.jar", "client/javassist.jar", - "common/lib/jboss-security-aspects.jar", "lib/jboss-managed.jar", "lib/jboss-metatype.jar", - "lib/jboss-dependency.jar"); - - private static final List<String> AS6_CLIENT_JARS = new ArrayList<String>(CLIENT_JARS); - static { - // The below jars are required for JBoss AS 6.0 M1, M2, and M3. - AS6_CLIENT_JARS.add("lib/jboss-classpool.jar"); - AS6_CLIENT_JARS.add("lib/jboss-classpool-scoped.jar"); - } + "%clientUrl%/jbossall-client.jar", // + "%clientUrl%/trove.jar", // + "%clientUrl%/javassist.jar", // + "%commonLibUrl%/jboss-security-aspects.jar", // + "%libUrl%/jboss-managed.jar", // + "%libUrl%/jboss-metatype.jar", // + "%libUrl%/jboss-dependency.jar", // + // AS 6.0 M1 and later + "%libUrl%/jboss-classpool.jar", // + "%libUrl%/jboss-classpool-scoped.jar", // + // AS 6.0 M4 and later + "%commonLibUrl%/jboss-as-profileservice.jar", // + "%libUrl%/jboss-profileservice-spi.jar" // + };
private final Log log = LogFactory.getLog(this.getClass());
@@ -149,34 +157,63 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom public List<URL> getAdditionalClasspathUrls(ResourceDiscoveryContext context, DiscoveredResourceDetails details) throws Exception { Configuration pluginConfig = details.getPluginConfiguration(); - String homeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR) - .getStringValue(); + setValuesForUnsetClientJarUrlProperties(pluginConfig); + + List<URL> clientJarUrls = new ArrayList<URL>(); + for (String clientJarUrlString : CLIENT_JAR_URLS) { + // Substitute values in for any templated plugin config props. + clientJarUrlString = ResourceComponentUtils.replacePropertyExpressionsInTemplate(clientJarUrlString, + pluginConfig); + URL clientJarUrl = new URL(clientJarUrlString); + if (isReadable(clientJarUrl)) { + clientJarUrls.add(clientJarUrl); + } else { + log.warn("Client JAR [" + clientJarUrl + "] does not exist or is not readable (note, this JAR " + + " may not be required for some app server versions)."); + } + }
- List<URL> clientJars = new ArrayList<URL>(); + return clientJarUrls; + }
- for (String jarFileName : getClientJars(pluginConfig)) { - File clientJar = new File(homeDir, jarFileName); - if (!clientJar.exists()) { - throw new FileNotFoundException("Cannot find [" + clientJar + "] - unable to manage server."); + private boolean isReadable(URL url) { + try { + InputStream inputStream = url.openStream(); + try { + inputStream.close(); } - if (!clientJar.canRead()) { - throw new IOException("Cannot read [" + clientJar + "] - unable to manage server."); + catch (IOException e) { + log.error("Failed to close input stream for URL [" + url + "].", e); } - clientJars.add(clientJar.toURI().toURL()); + return true; + } + catch (IOException e) { + return false; } - - return clientJars; }
- private List<String> getClientJars(Configuration pluginConfig) throws IOException { - PropertySimple jbossHomeDir = pluginConfig.getSimple("homeDir"); - JBossInstallationInfo installationInfo = new JBossInstallationInfo(new File(jbossHomeDir.getStringValue())); + private void setValuesForUnsetClientJarUrlProperties(Configuration pluginConfig) throws MalformedURLException { + String homeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR) + .getStringValue(); + URL homeUrl = new File(homeDir).toURI().toURL(); + + String clientUrlString = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.CLIENT_URL, null); + if (clientUrlString == null) { + URL clientUrl = new URL(homeUrl, "client"); + pluginConfig.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.CLIENT_URL, clientUrl)); + }
- if (installationInfo.getMajorVersion().equals("6")) { - return AS6_CLIENT_JARS; + String libUrlString = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.LIB_URL, null); + if (libUrlString == null) { + URL libUrl = new URL(homeUrl, "lib"); + pluginConfig.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.LIB_URL, libUrl)); }
- return CLIENT_JARS; + String commonLibUrlString = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.COMMON_LIB_URL, null); + if (commonLibUrlString == null) { + URL commonLibUrl = new URL(homeUrl, "common/lib"); + pluginConfig.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.COMMON_LIB_URL, commonLibUrl)); + } }
private Set<DiscoveredResourceDetails> discoverExternalJBossAsProcesses(ResourceDiscoveryContext discoveryContext) { diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java index c87a82f..3489fd4 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java @@ -31,6 +31,9 @@ public class ApplicationServerPluginConfigurationProperties { public static final String PRINCIPAL = "principal"; public static final String CREDENTIALS = "credentials"; public static final String HOME_DIR = "homeDir"; + public static final String CLIENT_URL = "clientUrl"; + public static final String LIB_URL = "libUrl"; + public static final String COMMON_LIB_URL = "commonLibUrl"; public static final String SERVER_HOME_DIR = "serverHomeDir"; public static final String JAVA_HOME = "javaHome"; public static final String BIND_ADDRESS = "bindAddress"; diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java index 4c88d99..7fa6360 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java @@ -23,7 +23,8 @@ package org.rhq.plugins.jbossas5.helper;
/** - * The properties that are used by the JBossAS micro-kernel during bootstrap (see http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProperties). + * The properties that are used by the JBossAS micro-kernel during bootstrap + * (see http://community.jboss.org/wiki/JBossProperties). * * @author Ian Springer */ @@ -44,6 +45,7 @@ public abstract class JBossProperties { public static final String HOME_URL = "jboss.home.url"; public static final String LIB_URL = "jboss.lib.url"; public static final String PATCH_URL = "jboss.patch.url"; + public static final String COMMON_LIB_URL = "jboss.common.lib.url";
/** * The configuration name of the server - default 'default' for AS, or 'production' for EAP or SOA diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JmxConnectionHelper.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JmxConnectionHelper.java deleted file mode 100644 index c07254a..0000000 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JmxConnectionHelper.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.plugins.jbossas5.helper; - -import java.io.File; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mc4j.ems.connection.ConnectionFactory; -import org.mc4j.ems.connection.EmsConnection; -import org.mc4j.ems.connection.settings.ConnectionSettings; -import org.mc4j.ems.connection.support.ConnectionProvider; -import org.mc4j.ems.connection.support.metadata.ConnectionTypeDescriptor; -import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertySimple; - -/** - * Shared helper class to connect to a remote server - * - * @author Heiko W. Rupp - */ -public class JmxConnectionHelper { - - public static final String CONNECTOR_DESCRIPTOR_TYPE = "connectorDescriptorType"; - public static final String CONNECTOR_ADDRESS = "connectorAddress"; - public static final String CONNECTOR_PRINCIPAL = "connectorPrincipal"; - public static final String CONNECTOR_CREDENTIALS = "connectorCredentials"; - public static final String JBOSS_HOME_DIR = "jbossHomeDir"; - - private static final Log log = LogFactory.getLog(JmxConnectionHelper.class); - - private static EmsConnection connection; - private static Configuration configuration; - - private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery"; - - /** - * This is the timeout for the initial connection to the MBeanServer that is made by - * {@link org.rhq.plugins.jbossas5.ApplicationServerComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)}. - */ - private static final int JNP_TIMEOUT = 30 * 1000; // 30 seconds - /** - * This is the timeout for MBean attribute gets/sets and operations invoked on the remote MBeanServer. - * NOTE: This timeout comes into play if the JBossAS instance has gone down since the original JNP connection was made. - */ - private static final int JNP_SO_TIMEOUT = 15 * 1000; // 15 seconds - - /** - * Controls the dampening of connection error stack traces in an attempt to control spam to the log file. Each time - * a connection error is encountered, this will be incremented. When the connection is finally established, this - * will be reset to zero. - */ - private static int consecutiveConnectionErrors; - - private boolean copyConnectionLibraries; - private File tmpDir; - - /** - * Constructs a new connection helper. - * - * @param copyConnectionLibraries whether to copy the libraries need for the connection so that - * the ems classloader doesn't block the application access to them. - * @param tmpDir the temporary directory to use when copying the libraries - */ - public JmxConnectionHelper(boolean copyConnectionLibraries, File tmpDir) { - this.copyConnectionLibraries = copyConnectionLibraries; - this.tmpDir = tmpDir; - } - - /** - * Obtain an EmsConnection for the passed connection properties. The properties will be retained. - * To create a connection with different properties, use this method again with a different set - * of properties. - * @param config Configuration properties for this connection - * @return an EmsConnection or null in case of failure - * @see #getEmsConnection() - */ - public EmsConnection getEmsConnection(Configuration config) { - EmsConnection emsConnection = null; - configuration = config; - - try { - emsConnection = loadConnection(config, copyConnectionLibraries, tmpDir); - } catch (Exception e) { - log.error("Component attempting to access a connection that could not be loaded"); - } - - return emsConnection; - } - - /** - * Obtain an EmsConnection. This will only work if the connection properties have passed - * before via a call to {@link #getEmsConnection(Configuration)} - * @return an EmsConnection or null in case of failure - * @see #getEmsConnection(org.rhq.core.domain.configuration.Configuration) - */ - public EmsConnection getEmsConnection() { - EmsConnection emsConnection = null; - if (configuration == null) { - throw new RuntimeException("No configuration set"); - } - - try { - emsConnection = loadConnection(configuration, copyConnectionLibraries, tmpDir); - } catch (Exception e) { - log.error("Component attempting to access a connection that could not be loaded"); - } - - return emsConnection; - } - - /** - * This is the preferred way to use a connection from within this class; methods should not access the connection - * property directly as it may not have been instantiated if the connection could not be made. - * <p/> - * <p>If the connection has already been established, return the object reference to it. If not, attempt to make a - * live connection to the JMX server.</p> - * <p/> - * <p>If the connection could not be made in the start(org.rhq.core.pluginapi.inventory.ResourceContext) method, - * this method will effectively try to load the connection on each attempt to use it. As such, multiple threads may - * attempt to access the connection through this means at a time. Therefore, the method has been made synchronized - * on instances of the class.</p> - * <p/> - * <p>If any errors are encountered, this method will log the error, taking into account logic to prevent spamming - * the log file. Calling methods should take care to not redundantly log the exception thrown by this method.</p> - * - * @param pluginConfig - * @return live connection to the JMX server; this will not be <code>null</code> - * @throws Exception if there are any issues at all connecting to the server - */ - private static synchronized EmsConnection loadConnection(Configuration pluginConfig, - boolean copyConnectionLibraries, File tmpDir) throws Exception { - if (connection == null) { - try { - //Configuration pluginConfig = this.resourceContext.getPluginConfiguration(); - - ConnectionSettings connectionSettings = new ConnectionSettings(); - - String connectionTypeDescriptorClass = pluginConfig.getSimple(CONNECTOR_DESCRIPTOR_TYPE) - .getStringValue(); - PropertySimple serverUrl = pluginConfig.getSimple(CONNECTOR_ADDRESS); - - connectionSettings.initializeConnectionType((ConnectionTypeDescriptor) Class.forName( - connectionTypeDescriptorClass).newInstance()); - // if not provided use the default serverUrl - if (null != serverUrl) { - connectionSettings.setServerUrl(serverUrl.getStringValue()); - } - - connectionSettings.setPrincipal(pluginConfig.getSimpleValue(CONNECTOR_PRINCIPAL, null)); - connectionSettings.setCredentials(pluginConfig.getSimpleValue(CONNECTOR_CREDENTIALS, null)); - connectionSettings.setLibraryURI(pluginConfig.getSimpleValue(JBOSS_HOME_DIR, null)); - - if (connectionSettings.getAdvancedProperties() == null) { - connectionSettings.setAdvancedProperties(new Properties()); - } - - connectionSettings.getAdvancedProperties().setProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, "true"); - connectionSettings.getAdvancedProperties().setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, "true"); - - // Make sure the timeout always happens, even if the JBoss server is hung. - connectionSettings.getAdvancedProperties().setProperty("jnp.timeout", String.valueOf(JNP_TIMEOUT)); - connectionSettings.getAdvancedProperties().setProperty("jnp.sotimeout", String.valueOf(JNP_SO_TIMEOUT)); - - // TODO (ips): Remove this? - connectionSettings.getAdvancedProperties().setProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, - Boolean.TRUE.toString()); - - if (copyConnectionLibraries) { - // Tell EMS to make copies of jar files so that the ems classloader doesn't lock - // application files (making us unable to update them) Bug: JBNADM-670 - connectionSettings.getControlProperties().setProperty(ConnectionFactory.COPY_JARS_TO_TEMP, - String.valueOf(Boolean.TRUE)); - } - - // Tell EMS to use the plugin's temp dir, so the PC will be able to clean it up and so an access control - // policy can easily be defined for the dir. EMS will use this for connection libraries (i.e. client - // jars) if COPY_JARS control prop is true, but it will also use it for the ems-mpl jar no matter what, - // so we need to always set it. - connectionSettings.getControlProperties().setProperty(ConnectionFactory.JAR_TEMP_DIR, - tmpDir.getAbsolutePath()); - - connectionSettings.getAdvancedProperties().setProperty(InternalVMTypeDescriptor.DEFAULT_DOMAIN_SEARCH, - "jboss"); - - ConnectionFactory connectionFactory = new ConnectionFactory(); - connectionFactory.discoverServerClasses(connectionSettings); - - ConnectionProvider connectionProvider = connectionFactory.getConnectionProvider(connectionSettings); - connection = connectionProvider.connect(); - - connection.loadSynchronous(false); // this loads all the MBeans - - consecutiveConnectionErrors = 0; - - if (log.isDebugEnabled()) - log.debug("Successfully made connection to the remote server instance"); - } catch (Exception e) { - - // The connection will be established even in the case that the principal cannot be authenticated, - // but the connection will not work. That failure seems to come from the call to loadSynchronous after - // the connection is established. If we get to this point that an exception was thrown, close any - // connection that was made and null it out so we can try to establish it again. - if (connection != null) { - if (log.isDebugEnabled()) - log.debug("Connection created but an exception was thrown. Closing the connection.", e); - connection.close(); - connection = null; - } - - // Since the connection is attempted each time it's used, failure to connect could result in log - // file spamming. Log it once for every 10 consecutive times it's encountered. - if (consecutiveConnectionErrors % 10 == 0) { - log.warn("Could not establish connection to the instance [" + (consecutiveConnectionErrors + 1) - + "] times.", e); - } - - if (log.isDebugEnabled()) - log.debug("Could not connect to the instance for resource ", e); - - consecutiveConnectionErrors++; - - throw e; - } - } - - return connection; - } - - /** - * If necessary attempt to close the EMS connection, then set this.connection null. Synchronized ensure we play - * well with loadConnection. - */ - public synchronized void closeConnection() { - if (connection != null) { - try { - connection.close(); - } catch (Exception e) { - log.error("Error closing EMS connection: " + e); - } - connection = null; - } - } - -} diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml index ea8ff2d..47ca3e0 100644 --- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml @@ -972,8 +972,17 @@ description="The name of the server configuration (e.g. minimal, default, or all); if not specified, it will default to the last path component of {serverHomeDir}." default="default"/> + <c:simple-property name="clientUrl" required="false" + description="The URL of the server's client JAR library directory; + if not specified, it will default to {homeDir}/client."/> + <c:simple-property name="libUrl" required="false" + description="The URL of the server's main JAR library directory; + if not specified, it will default to {homeDir}/lib."/> + <c:simple-property name="commonLibUrl" required="false" + description="The URL of the server's common JAR library directory; + if not specified, it will default to {homeDir}/common/lib."/> </c:group> - <c:group name="control" displayName="Operations"> + <c:group name="control" displayName="Operations"> <c:simple-property name="scriptPrefix" displayName="Script Prefix" type="string" required="false" description="A prefix applied to script execution commands. Typically a sudo for applicable platforms. The prefix is applied verbatim. As such, a @@ -1011,7 +1020,7 @@ to 'shutdown script'."/> </c:group>
- <c:group name="advanced" displayName="Advanced" hiddenByDefault="true"> + <c:group name="advanced" displayName="Advanced" hiddenByDefault="true"> <c:simple-property name="shutdownMBeanName" displayName="Shutdown MBean Name" default="jboss.system:type=Server" description="Name of the MBean to use when shutting down this server through JMX."/> @@ -1029,7 +1038,7 @@ <c:simple-property name="childJmxServerName" displayName="JBoss AS JVM Name" default="JVM" readOnly="true" required="false" description="The name of the JBoss AS JVM resource."/> - </c:group> + </c:group>
<c:group name="events"> <c:list-property name="logEventSources"> diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java index 5fac37b..8e967ae 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java @@ -115,7 +115,7 @@ import org.rhq.plugins.jmx.JMXDiscoveryComponent; import org.rhq.plugins.jmx.ObjectNameQueryUtility;
/** -* Supports JBoss 3.2.3 through 4.2.x +* Resource component for managing JBoss AS 3.2.3 through 4.2.x, and JBoss EAP and SOA-P 4.x. * * @author Greg Hinkle * @author John Mazzitelli @@ -156,10 +156,6 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet, private static final String RESOURCE_TYPE_WAR = "Web Application (WAR)"; private static final String RESOURCE_TYPE_SAR = "Service Archive (SAR)"; // Not yet used
- // The following constants reference the exact name of the package types as defined in the plugin descriptor - private static final String PACKAGE_TYPE_PATCH = "cumulativePatch"; - private static final String PACKAGE_TYPE_LIBRARY = "library"; - private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery";
private static final String DISTRIBUTED_REPLICANT_MANAGER_MBEAN_NAME_TEMPLATE = "jboss:partitionName=%partitionName%,service=DistributedReplicantManager"; @@ -1070,6 +1066,8 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet, * * @throws Exception if there are any issues at all connecting to the server */ + // TODO (ips): Refactor this method to use the JmxConnectionHelper class from the jboss-as-common module, which is + // what the jboss-as-5 plugin uses. private synchronized EmsConnection loadConnection() throws Exception { if (this.connection == null) { try { diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java index 7cfb2b2..680898f 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java @@ -24,7 +24,7 @@ package org.rhq.plugins.jbossas.helper;
/** * The properties that are used by the JBossAS micro-kernel during bootstrap - * (see http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProperties). + * (see http://community.jboss.org/wiki/JBossProperties). * * @author Ian Springer */
commit 03d5f59b902515e77f998600875130d476cff61d Author: Ian Springer ian.springer@redhat.com Date: Thu Sep 16 18:42:13 2010 -0400
misc minor
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java index 4181721..f5350fd 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java @@ -44,13 +44,13 @@ import org.rhq.core.system.ProcessInfo; * @author John Mazzitelli */ public class DiscoveredResourceDetails { - private final Log log = LogFactory.getLog(this.getClass()); - private static final int RESOURCE_KEY_MAX_LENGTH = 500; private static final int RESOURCE_NAME_MAX_LENGTH = 500; private static final int RESOURCE_VERSION_MAX_LENGTH = 100; private static final int RESOURCE_DESCRIPTION_MAX_LENGTH = 1000;
+ private final Log log = LogFactory.getLog(this.getClass()); + private ResourceType resourceType; private String resourceKey; private String resourceName; @@ -289,7 +289,7 @@ public class DiscoveredResourceDetails {
@Override public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder();
buf.append("key="); buf.append(getResourceKey());
commit e7d80ea51297197d838d2810814e25eb73a47776 Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Sep 17 17:44:30 2010 -0400
Work on Group CRUD - Group category now determined on the fly, a la group def calculation, by group membership. This means a manually group can change category in its lifetime by editing the membership. That may be less important than the fact that it simplifies initial creation and users really only have to care about adding members. - Added basic support for mixed-group tree/detail view. Just enough to get us moving. - Added Inventory->Membership subtab for changing group members. - Changed ResourceManagerLocal.ensureMembershipMatches() to .setMembership() The name is cleaner and in line with naming for a series of new calls that simply syncs associated data to be the set passed in. Also, optionally can reset the group's category based on the membership change. - A couple of locatorId fixes in touched files -
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java index c4a4bca..333427f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java @@ -34,23 +34,26 @@ import org.rhq.core.domain.util.PageList; @RemoteServiceRelativePath("ResourceGroupGWTService") public interface ResourceGroupGWTService extends RemoteService {
- PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria); + GroupDefinition createGroupDefinition(GroupDefinition groupDefinition);
- PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria); + ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds);
- PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria); + void deleteGroupDefinitions(int[] groupDefinitionIds);
- void ensureMembershipMatches(int groupId, int[] resourceIds); + void deleteResourceGroups(int[] groupIds);
- ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds); + PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria);
- void deleteResourceGroups(int[] groupIds); + PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria);
- void updateResourceGroup(ResourceGroup group); + PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria); + + void setMembership(int groupId, int[] resourceIds, boolean setType);
void updateGroupDefinition(GroupDefinition groupDefinition);
- void deleteGroupDefinitions(int[] groupDefinitionIds); + void updateResourceGroup(ResourceGroup group);
- GroupDefinition createGroupDefinition(GroupDefinition groupDefinition); -} + void updateResourceGroup(ResourceGroup group, boolean updateMembership); + +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 128dff8..6603a00 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView; import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.ResourceGroupMembershipView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView; @@ -52,10 +53,9 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchVi import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/** - * Right panel of the group view. + * Be able to view members as a resource list, or edit members via selector. * - * @author Greg Hinkle - * @author Ian Springer + * @author Jay Shaughnessy */ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> { private static final String BASE_VIEW_PATH = "ResourceGroup"; @@ -83,6 +83,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource private SubTab monitorCallTime; private SubTab inventoryMembers; private SubTab inventoryConn; + private SubTab inventoryMembership; private SubTab opHistory; private SubTab opSched; private SubTab alertHistory; @@ -91,12 +92,24 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource private SubTab configHistory; private SubTab eventHistory;
+ private String currentTab; + private String currentSubTab; + public ResourceGroupDetailView(String locatorId) { super(locatorId, BASE_VIEW_PATH); }
@Override public Integer getSelectedItemId() { + // if moving from membership subtab then re-load the detail view as the membership and + // group type may have changed. + if (this.inventoryTab.getTitle().equals(currentTab) + && this.inventoryMembership.getTitle().equals(currentSubTab)) { + this.currentTab = null; + this.currentSubTab = null; + this.groupId = null; + } + return this.groupId; }
@@ -130,7 +143,8 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource "/images/icons/Inventory_grey_16.png"); inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"), "Members", null); inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null); - inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn); + inventoryMembership = new SubTab(inventoryTab.extendLocatorId("Membership"), "Membership", null); + inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn, this.inventoryMembership); tabs.add(inventoryTab);
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations", @@ -184,9 +198,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId)); this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
- this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId)); + this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(this.inventoryTab + .extendLocatorId("MembersView"), groupId)); // TODO: Uncomment this once the group config component is done. //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin)); + this.inventoryMembership.setCanvas(new ResourceGroupMembershipView(this.inventoryTab + .extendLocatorId("MembershipView"), groupId));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId)); @@ -290,6 +307,9 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource }); } }); + } else { + updateTabContent(groupComposite); + selectTab(getTabName(), getSubTabName(), viewPath); } }
@@ -305,4 +325,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource } return false; } + + @Override + public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) { + currentTab = tabTitle; + currentSubTab = subtabTitle; + super.selectTab(tabTitle, subtabTitle, viewPath); + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java index aa2ee61..ba57920 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java @@ -43,6 +43,7 @@ import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler; import org.rhq.core.domain.criteria.ResourceGroupCriteria; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ClusterKey; +import org.rhq.core.domain.resource.group.GroupCategory; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.resource.group.composite.ClusterFlyweight; import org.rhq.core.domain.resource.group.composite.ClusterKeyFlyweight; @@ -89,14 +90,11 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { treeGrid.setSortField("name"); treeGrid.setShowHeader(false);
- addMember(this.treeGrid);
- contextMenu = new ResourceGroupTreeContextMenu(); treeGrid.setContextMenu(contextMenu);
- treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() { @Override public void onSelectionChanged(SelectionEvent selectionEvent) { @@ -141,17 +139,29 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { criteria.fetchResourceType(true);
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria, - new AsyncCallback<PageList<ResourceGroup>>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load group", caught); - } - - @Override - public void onSuccess(PageList<ResourceGroup> result) { - ResourceGroup group = result.get(0); - ResourceGroupTreeView.this.selectedGroup = group; + new AsyncCallback<PageList<ResourceGroup>>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load group", caught); + }
+ @Override + public void onSuccess(PageList<ResourceGroup> result) { + ResourceGroup group = result.get(0); + ResourceGroupTreeView.this.selectedGroup = group; + + if (GroupCategory.MIXED == group.getGroupCategory()) { + ResourceGroupTreeView.this.rootResourceGroup = group; + ResourceGroupTreeView.this.rootGroupId = rootResourceGroup.getId(); + TreeNode fakeRoot = new TreeNode("fakeRootNode"); + TreeNode rootNode = new TreeNode(rootResourceGroup.getName()); + rootNode.setID(String.valueOf(rootResourceGroup.getId())); //getClusterKey().toString()); + fakeRoot.setChildren(new TreeNode[] { rootNode }); + Tree tree = new Tree(); + tree.setRoot(fakeRoot); + treeGrid.setData(tree); + treeGrid.markForRedraw(); + } else { if (group.getClusterResourceGroup() == null) { ResourceGroupTreeView.this.rootResourceGroup = group; // This is a straight up group @@ -164,12 +174,12 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
loadGroup(rootGroup.getId()); } - } - });
- } + } + });
+ }
private void loadGroup(int groupId) {
@@ -193,19 +203,17 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { treeGrid.selectRecord(selectedNode); }
- } else { this.rootGroupId = groupId; - GWTServiceLookup.getClusterService().getClusterTree(groupId, - new AsyncCallback<ClusterFlyweight>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load tree", caught); - } + GWTServiceLookup.getClusterService().getClusterTree(groupId, new AsyncCallback<ClusterFlyweight>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load tree", caught); + }
- public void onSuccess(ClusterFlyweight result) { - loadTreeTypes(result); - } - }); + public void onSuccess(ClusterFlyweight result) { + loadTreeTypes(result); + } + }); }
} @@ -215,60 +223,54 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { typeIds.add(this.rootResourceGroup.getResourceType().getId()); getTreeTypes(root, typeIds);
- ResourceTypeRepository.Cache.getInstance().getResourceTypes( - typeIds.toArray(new Integer[typeIds.size()]), - new ResourceTypeRepository.TypesLoadedCallback() { - @Override - public void onTypesLoaded(HashMap<Integer, ResourceType> types) { - ResourceGroupTreeView.this.typeMap = types; - loadTree(root); - } + ResourceTypeRepository.Cache.getInstance().getResourceTypes(typeIds.toArray(new Integer[typeIds.size()]), + new ResourceTypeRepository.TypesLoadedCallback() { + @Override + public void onTypesLoaded(HashMap<Integer, ResourceType> types) { + ResourceGroupTreeView.this.typeMap = types; + loadTree(root); } - ); + }); }
- private void selectClusterGroup(ClusterKey key) {
GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(key, true, - new AsyncCallback<ResourceGroup>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to create or update auto cluster group", caught); - } + new AsyncCallback<ResourceGroup>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to create or update auto cluster group", caught); + }
- @Override - public void onSuccess(ResourceGroup result) { - int groupId = result.getId(); - History.newItem("ResourceGroup/" + groupId); - } - }); + @Override + public void onSuccess(ResourceGroup result) { + int groupId = result.getId(); + History.newItem("ResourceGroup/" + groupId); + } + });
}
private void loadTree(ClusterFlyweight root) { TreeNode fakeRoot = new TreeNode("fakeRootNode");
- TreeNode rootNode = new TreeNode(rootResourceGroup.getName()); rootNode.setID(String.valueOf(root.getGroupId())); //getClusterKey().toString()); + ResourceType rootResourceType = typeMap.get(rootResourceGroup.getResourceType().getId()); rootNode.setAttribute("resourceType", rootResourceType); String icon = "types/" + rootResourceType.getCategory().getDisplayName() + "_up_16.png"; rootNode.setIcon(icon);
- fakeRoot.setChildren(new TreeNode[]{rootNode}); + fakeRoot.setChildren(new TreeNode[] { rootNode });
ClusterKey rootKey = new ClusterKey(root.getGroupId()); loadTree(rootNode, root, rootKey);
- - Tree tree = new Tree();
tree.setRoot(fakeRoot);
- treeGrid.setData(tree); treeGrid.markForRedraw(); } @@ -286,7 +288,8 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { TreeNode node = new TreeNode(child.getName());
ClusterKeyFlyweight keyFlyweight = child.getClusterKey(); - ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight.getResourceKey()); + ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight + .getResourceKey());
ResourceType type = this.typeMap.get(keyFlyweight.getResourceTypeId());
@@ -294,7 +297,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
node.setIcon(icon);
- node.setID(key.getKey()); node.setAttribute("key", key); node.setAttribute("resourceType", type); @@ -317,7 +319,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { setSelectedGroup(groupId); }
- private void getTreeTypes(ClusterFlyweight clusterFlyweight, Set<Integer> typeIds) { if (clusterFlyweight.getClusterKey() != null) { typeIds.add(clusterFlyweight.getClusterKey().getResourceTypeId()); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java new file mode 100644 index 0000000..e08b57d --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java @@ -0,0 +1,129 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory; + +import java.util.HashSet; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.IButton; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.layout.LayoutSpacer; +import com.smartgwt.client.widgets.toolbar.ToolStrip; + +import org.rhq.core.domain.criteria.ResourceGroupCriteria; +import org.rhq.core.domain.resource.group.ResourceGroup; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/** + * @author Jay Shaughnessy + */ +public class ResourceGroupMembershipView extends LocatableVLayout { + + private int resourceGroupId; + private ResourceGroup resourceGroup; + private ResourceGroupResourceSelector selector; + + public ResourceGroupMembershipView(String locatorId, int resourceGroupId) { + super(locatorId); + + this.resourceGroupId = resourceGroupId; + } + + @Override + protected void onDraw() { + super.onDraw(); + + build(); + } + + public void build() { + ToolStrip toolStrip = new ToolStrip(); + toolStrip.setWidth100(); + + toolStrip.addMember(new LayoutSpacer()); + + IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); + saveButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + save(); + } + }); + + toolStrip.addMember(saveButton); + this.addMember(toolStrip); + + ResourceGroupCriteria c = new ResourceGroupCriteria(); + c.addFilterId(this.resourceGroupId); + c.fetchExplicitResources(true); + GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(c, + new AsyncCallback<PageList<ResourceGroup>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to fetch Resource Group", caught); + } + + public void onSuccess(PageList<ResourceGroup> result) { + ResourceGroupMembershipView.this.resourceGroup = result.get(0); + ResourceGroupMembershipView.this.selector = new ResourceGroupResourceSelector( + ResourceGroupMembershipView.this.getLocatorId(), ResourceGroupMembershipView.this.resourceGroup + .getExplicitResources()); + ResourceGroupMembershipView.this.selector.setOverflow(Overflow.AUTO); + + addMember(ResourceGroupMembershipView.this.selector); + } + }); + } + + private void save() { + int[] resourceIds = getSelectedResourceIds(); + + GWTServiceLookup.getResourceGroupService().setMembership(this.resourceGroup.getId(), resourceIds, true, + new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught); + } + + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify( + new Message("Group membership updated for [" + + ResourceGroupMembershipView.this.resourceGroup.getName() + "]", Message.Severity.Info)); + CoreGUI.refresh(); + } + }); + } + + private int[] getSelectedResourceIds() { + int[] selection = new int[this.selector.getSelection().size()]; + HashSet<Integer> selectedIds = this.selector.getSelection(); + int i = 0; + for (Integer id : selectedIds) { + selection[i++] = id; + } + + return selection; + } + +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java new file mode 100644 index 0000000..6bc96fb --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java @@ -0,0 +1,45 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory; + +import java.util.Collection; + +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector; + +/** + * @author Jay Shaughnessy + */ +public class ResourceGroupResourceSelector extends ResourceSelector { + + public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources) { + super(locatorId); + if (null != resources) { + ListGridRecord[] data = (new ResourceDatasource()).buildRecords(resources); + setAssigned(data); + } + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java index 41aff20..2c3f364 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java @@ -91,7 +91,7 @@ public class OverviewView extends LocatableVLayout { return; } group.setName(newName); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( "Failed to change name of Resource group with id " + group.getId() + " from "" @@ -141,7 +141,7 @@ public class OverviewView extends LocatableVLayout { return; } group.setDescription(newDescription); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( "Failed to change description of Resource group with id " + group.getId() + " from "" @@ -177,7 +177,7 @@ public class OverviewView extends LocatableVLayout { return; } group.setLocation(newLocation); - OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { + OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( "Failed to change location of Resource group with id " + group.getId() + " from "" @@ -224,7 +224,8 @@ public class OverviewView extends LocatableVLayout { StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", "Group Definition"); GroupDefinition groupDefinition = group.getGroupDefinition(); String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId()); - groupDefinitionItem.setValue("<a href="" + groupDefinitionUrl + "">" + groupDefinition.getName() + "</a>"); + groupDefinitionItem + .setValue("<a href="" + groupDefinitionUrl + "">" + groupDefinition.getName() + "</a>"); formItems.add(groupDefinitionItem); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java index f06f6ae..6b4664a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java @@ -22,22 +22,16 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.wizard;
-import java.util.LinkedHashMap; - import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.ValuesManager; import com.smartgwt.client.widgets.form.fields.AutoFitTextAreaItem; import com.smartgwt.client.widgets.form.fields.CheckboxItem; -import com.smartgwt.client.widgets.form.fields.IPickTreeItem; import com.smartgwt.client.widgets.form.fields.TextAreaItem; import com.smartgwt.client.widgets.form.fields.TextItem;
-import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ResourceGroup; -import org.rhq.enterprise.gui.coregui.client.components.form.RadioGroupWithComponentsItem; import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypePluginTreeDataSource; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** @@ -68,42 +62,14 @@ public class GroupCreateStep extends AbstractWizardStep {
CheckboxItem recursive = new CheckboxItem("recursive", "Recursive");
- LinkedHashMap<String, Canvas> options = new LinkedHashMap<String, Canvas>(); - options.put("Mixed", null); - - IPickTreeItem typeSelectItem = new IPickTreeItem("type", "Type"); - typeSelectItem.setDataSource(new ResourceTypePluginTreeDataSource()); - typeSelectItem.setValueField("id"); - typeSelectItem.setCanSelectParentItems(true); - typeSelectItem.setLoadDataOnDemand(false); - typeSelectItem.setEmptyMenuMessage("Loading..."); - typeSelectItem.setShowIcons(true); - - DynamicForm form2 = new LocatableDynamicForm("TypeTree"); - form2.setValuesManager(form.getValuesManager()); - form2.setFields(typeSelectItem); - options.put("Compatible", form2); - - RadioGroupWithComponentsItem kind = new RadioGroupWithComponentsItem("groupType", "Group Type", options, - form); - kind.setValue("Mixed"); - form.setFields(name, description, location, recursive, kind); - + form.setFields(name, description, location, recursive); } + return form; }
public boolean nextPage() { - boolean valid = form.validate(); - if (valid) { - RadioGroupWithComponentsItem kind = (RadioGroupWithComponentsItem) form.getField("groupType"); - if ("Compatible".equals(kind.getSelected())) { - DynamicForm form2 = (DynamicForm) kind.getSelectedComponent(); - valid = (null != form2.getValue("type")); - } - } - - return valid; + return form.validate(); }
public String getName() { @@ -116,16 +82,6 @@ public class GroupCreateStep extends AbstractWizardStep { group.setLocation(form.getValueAsString("location")); group.setRecursive(form.getValue("recursive") != null ? true : false);
- RadioGroupWithComponentsItem kind = (RadioGroupWithComponentsItem) form.getField("groupType"); - if ("Compatible".equals(kind.getSelected())) { - DynamicForm form2 = (DynamicForm) kind.getSelectedComponent(); - if (null != form2.getValue("type")) { - ResourceType rt = new ResourceType(); - rt.setId(Integer.parseInt(form2.getValueAsString("type"))); - group.setResourceType(rt); - } - } - return group; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java index a55b334..fbbf71e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java @@ -28,7 +28,6 @@ import java.util.List; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.IButton;
-import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard; @@ -67,23 +66,11 @@ public class GroupCreateWizard extends AbstractWizard { }
public String getSubtitle() { - return null; // TODO: Implement this method. + return null; }
public List<IButton> getCustomButtons(int step) { - return null; // TODO: Implement this method. - } - - /** - * @return only the rt id is set - */ - public ResourceType getCompatibleGroupResourceType() { - ResourceGroup rg = createStep.getGroup(); - ResourceType rt = null; - if (null != rg) { - rt = rg.getResourceType(); - } - return rt; + return null; }
public void cancel() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java index 3a3048d..2e3e9c7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java @@ -26,7 +26,6 @@ import java.util.HashSet;
import com.smartgwt.client.widgets.Canvas;
-import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep; import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
@@ -37,18 +36,14 @@ public class GroupMembersStep extends AbstractWizardStep {
private GroupCreateWizard wizard = null; private ResourceSelector selector = null; - private ResourceType requireType = null;
public GroupMembersStep(GroupCreateWizard wizard) { this.wizard = wizard; }
public Canvas getCanvas() { - ResourceType rt = wizard.getCompatibleGroupResourceType(); - if ((selector == null) || (rt != requireType)) { + if (selector == null) { selector = new ResourceSelector(getName()); - requireType = rt; - selector.setRequireType(rt); } return selector; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index faa406e..ed442b2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -57,8 +57,8 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView private static final String SECTION_GROUPS = "Groups"; private static final String SECTION_RESOURCES = "Resources";
- private static final String SUBSECTION_RESOURCE_INVENTORY = "Resource Inventory"; - private static final String SUBSECTION_GROUP_INVENTORY = "Group Inventory"; + private static final String SUBSECTION_RESOURCE_INVENTORY = "Resources"; + private static final String SUBSECTION_GROUP_INVENTORY = "Groups"; private static final String SUBSECTION_SAVED_SEARCHES = "Saved Searches";
private static final String PAGE_ADQ = "Discovery Manager"; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java index 9817819..71f1996 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java @@ -182,14 +182,13 @@ public class ResourceSearchView extends Table {
// -------- Static Utility loaders ------------
- public static ResourceSearchView getChildrenOf(int resourceId) { - return new ResourceSearchView("ResourceSearchChildren", new Criteria("parentId", String.valueOf(resourceId)), + public static ResourceSearchView getChildrenOf(String locatorId, int resourceId) { + return new ResourceSearchView(locatorId, new Criteria("parentId", String.valueOf(resourceId)), "Child Resources"); }
- public static ResourceSearchView getMembersOf(int groupId) { - return new ResourceSearchView("ResourceSearchMemberOf", new Criteria("groupId", String.valueOf(groupId)), - "Member Resources"); + public static ResourceSearchView getMembersOf(String locatorId, int groupId) { + return new ResourceSearchView(locatorId, new Criteria("groupId", String.valueOf(groupId)), "Member Resources"); }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index 2edb50f..e80be32 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -207,7 +207,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId()));
- this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(resource.getId())); + this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource + .getId())); this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource));
// comment out GWT-based operation history until... diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java index e9f773d..b1ad07f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java @@ -49,8 +49,8 @@ public class ResourceSelector extends AbstractSelector<Resource> {
private ResourceType requireType;
- public ResourceSelector(String id) { - super(id); + public ResourceSelector(String locatorId) { + super(locatorId); }
public ResourceType getRequireType() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java index b2ec813..b9642d6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.gui.coregui.server.gwt;
+import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.criteria.ResourceGroupCriteria; import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; import org.rhq.core.domain.resource.group.GroupDefinition; @@ -36,34 +37,57 @@ import org.rhq.enterprise.server.util.LookupUtil; */ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implements ResourceGroupGWTService {
+ private static final long serialVersionUID = 1L; + private ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager(); private GroupDefinitionManagerLocal definitionManager = LookupUtil.getGroupDefinitionManager();
public PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria) { - return SerialUtility.prepare(groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria), - "ResourceGroupService.findResourceGroupsByCriteria"); + try { + PageList<ResourceGroup> groups = groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria); + return SerialUtility.prepare(groups, "ResourceGroupService.findResourceGroupsByCriteria"); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria) { - return SerialUtility.prepare(groupManager.findResourceGroupCompositesByCriteria(getSessionSubject(), criteria), - "ResourceGroupService.findResourceGroupCompositesByCriteria"); + try { + PageList<ResourceGroupComposite> composites = groupManager.findResourceGroupCompositesByCriteria( + getSessionSubject(), criteria); + return SerialUtility.prepare(composites, "ResourceGroupService.findResourceGroupCompositesByCriteria"); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria) { - return SerialUtility.prepare(definitionManager.findGroupDefinitionsByCriteria(getSessionSubject(), criteria), - "ResourceGroupService.findGroupDefinitionsByCriteria"); + try { + PageList<GroupDefinition> definitions = definitionManager.findGroupDefinitionsByCriteria( + getSessionSubject(), criteria); + return SerialUtility.prepare(definitions, "ResourceGroupService.findGroupDefinitionsByCriteria"); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
- public void ensureMembershipMatches(int groupId, int[] resourceIds) { - groupManager.ensureMembershipMatches(getSessionSubject(), groupId, resourceIds); + public void setMembership(int groupId, int[] resourceIds, boolean setType) { + try { + groupManager.setMembership(getSessionSubject(), groupId, resourceIds, setType); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds) { - group = groupManager.createResourceGroup(getSessionSubject(), group); - - ensureMembershipMatches(group.getId(), resourceIds); - - return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup"); + try { + Subject user = getSessionSubject(); + group = groupManager.createResourceGroup(user, group); + groupManager.setMembership(user, group.getId(), resourceIds, true); + return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup"); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public void deleteResourceGroups(int[] groupIds) { @@ -75,7 +99,19 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen }
public void updateResourceGroup(ResourceGroup group) { - groupManager.updateResourceGroup(getSessionSubject(), group); + try { + groupManager.updateResourceGroup(getSessionSubject(), group); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } + } + + public void updateResourceGroup(ResourceGroup group, boolean updateMembership) { + try { + groupManager.updateResourceGroup(getSessionSubject(), group, null, updateMembership); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); + } }
public GroupDefinition createGroupDefinition(GroupDefinition groupDefinition) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java index 10611fa..4aaf7ca 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java @@ -48,7 +48,6 @@ import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.PermissionException; import org.rhq.enterprise.server.resource.group.ResourceGroupAlreadyExistsException; import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; -import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
/** * @@ -139,9 +138,9 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe try { // You are allowed to cause the creation of an auto cluster backing group as long as you can // view the parent group. (That check was done above) - resourceGroupManager.ensureMembershipMatches(subjectManager.getOverlord(), autoClusterBackingGroup - .getId(), resourceIds); - } catch (ResourceGroupUpdateException e) { + resourceGroupManager.setMembership(subjectManager.getOverlord(), autoClusterBackingGroup.getId(), + resourceIds, false); + } catch (Exception e) { log.error("Could not add resources to group:" + e); } } @@ -177,11 +176,10 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe }
public ClusterFlyweight getClusterTree(Subject subject, int groupId) { - Query query = entityManager.createQuery( - "SELECT r.id, r.resourceType.id, r.parentResource.id, r.resourceKey, r.name, " + - "(SELECT count(r2) FROM Resource r2 join r2.explicitGroups g2 WHERE g2.id = :groupId and r2.id = r.id) " + - "FROM Resource r join r.implicitGroups g " + - "WHERE g.id = :groupId"); + Query query = entityManager + .createQuery("SELECT r.id, r.resourceType.id, r.parentResource.id, r.resourceKey, r.name, " + + "(SELECT count(r2) FROM Resource r2 join r2.explicitGroups g2 WHERE g2.id = :groupId and r2.id = r.id) " + + "FROM Resource r join r.implicitGroups g " + "WHERE g.id = :groupId");
query.setParameter("groupId", groupId); List<Object[]> rs = query.getResultList(); @@ -203,7 +201,6 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe } }
- ClusterFlyweight key = new ClusterFlyweight(groupId);
buildTree(groupId, key, explicitResources, dataMap); @@ -211,7 +208,8 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe return key; }
- private void buildTree(int groupId, ClusterFlyweight parent, Set<Integer> parentIds, Map<Integer,List<Object[]>> data) { + private void buildTree(int groupId, ClusterFlyweight parent, Set<Integer> parentIds, + Map<Integer, List<Object[]>> data) {
for (Integer parentId : parentIds) {
@@ -219,32 +217,29 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe Map<ClusterKeyFlyweight, Set<Integer>> members = new HashMap<ClusterKeyFlyweight, Set<Integer>>();
if (data.get(parentId) != null) { - for (Object[] child : data.get(parentId)) { - ClusterKeyFlyweight n = new ClusterKeyFlyweight((Integer)child[1], (String)child[3]); + for (Object[] child : data.get(parentId)) { + ClusterKeyFlyweight n = new ClusterKeyFlyweight((Integer) child[1], (String) child[3]); ClusterFlyweight flyweight = children.get(n); - Set<Integer> memberList = members.get(n); - if (flyweight == null) { - flyweight = new ClusterFlyweight(n); - children.put(n, flyweight); - memberList = new HashSet<Integer>(); - members.put(n, memberList); + Set<Integer> memberList = members.get(n); + if (flyweight == null) { + flyweight = new ClusterFlyweight(n); + children.put(n, flyweight); + memberList = new HashSet<Integer>(); + members.put(n, memberList); + } + flyweight.addResource((String) child[4]); + memberList.add((Integer) child[0]); } - flyweight.addResource((String)child[4]); - memberList.add((Integer) child[0]); - } }
parent.setChildren(new ArrayList<ClusterFlyweight>(children.values()));
- for (ClusterFlyweight child : children.values()) { buildTree(groupId, child, members.get(child.getClusterKey()), data); } } }
- - private String getClusterKeyQuery(ClusterKey clusterKey) { if (null == clusterKey) return null; diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java index 04dd614..28ae218 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java @@ -171,8 +171,19 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso }
@RequiredPermission(Permission.MANAGE_INVENTORY) - public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType) + public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group) throws ResourceGroupUpdateException { + return updateResourceGroup(subject, group, null, true); + } + + @RequiredPermission(Permission.MANAGE_INVENTORY) + public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group, RecursivityChangeType changeType) throws ResourceGroupUpdateException { + return updateResourceGroup(subject, group, null, true); + } + + @RequiredPermission(Permission.MANAGE_INVENTORY) + public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType, + boolean updateMembership) throws ResourceGroupUpdateException {
int groupId = group.getId(); ResourceGroup attachedGroup = entityManager.find(ResourceGroup.class, groupId); @@ -198,6 +209,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso } }
+ if (!updateMembership) { + group.setExplicitResources(attachedGroup.getExplicitResources()); + group.setImplicitResources(attachedGroup.getImplicitResources()); + } + group.setMtime(System.currentTimeMillis()); group.setModifiedBy(user.getName());
@@ -320,7 +336,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso try { operationManager.unscheduleGroupOperation(overlord, schedule.getJobId().toString(), group.getId()); } catch (UnscheduleException e) { - log.warn("Failed to unschedule job [" + schedule + "] for a group being deleted [" + group + "]", e); + log + .warn("Failed to unschedule job [" + schedule + "] for a group being deleted [" + group + "]", + e); } } } catch (Exception e) { @@ -759,8 +777,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso * to this method, we can just do simple RHQ_RESOURCE_GROUP_RES_IMP_MAP table insertions */ String insertImplicitQueryString = JDBCUtil.transformQueryForMultipleInParameters( - ResourceGroup.QUERY_NATIVE_ADD_RESOURCES_TO_GROUP_IMPLICIT, "@@RESOURCE_IDS@@", - resourceIdsToAdd.size()); + ResourceGroup.QUERY_NATIVE_ADD_RESOURCES_TO_GROUP_IMPLICIT, "@@RESOURCE_IDS@@", resourceIdsToAdd + .size()); insertImplicitStatement = conn.prepareStatement(insertImplicitQueryString); insertImplicitStatement.setInt(1, implicitRecursiveGroupId); JDBCUtil.bindNTimes(insertImplicitStatement, ArrayUtils.unwrapCollection(resourceIdsToAdd), 2); @@ -822,9 +840,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso ResourceGroup group = getResourceGroupById(subject, groupId, category); Set<Resource> res = group.getExplicitResources(); if (res != null && res.size() > 0) { - List<Resource> resources = PersistenceUtility.getHibernateSession(entityManager) - .createFilter(res, "where this.inventoryStatus = :inventoryStatus") - .setParameter("inventoryStatus", InventoryStatus.COMMITTED).list(); + List<Resource> resources = PersistenceUtility.getHibernateSession(entityManager).createFilter(res, + "where this.inventoryStatus = :inventoryStatus").setParameter("inventoryStatus", + InventoryStatus.COMMITTED).list();
return resources; } else { @@ -1278,7 +1296,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso return groupIds; }
- public void ensureMembershipMatches(Subject subject, int groupId, int[] resourceIds) { + public void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType) + throws ResourceGroupDeleteException { //throws ResourceGroupUpdateException { List<Integer> currentMembers = resourceManager.findExplicitResourceIdsByResourceGroup(groupId);
@@ -1293,6 +1312,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso if (extraMembers.size() > 0) { removeResourcesFromGroup(subject, groupId, ArrayUtils.unwrapCollection(extraMembers)); } + + // As a result of the membership change ensure that the group type is set correctly. + if (setType) { + setResourceType(groupId); + } }
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -1402,11 +1426,6 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso : RecursivityChangeType.RemovedRecursion); }
- @RequiredPermission(Permission.MANAGE_INVENTORY) - public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group) throws ResourceGroupUpdateException { - return updateResourceGroup(subject, group, null); - } - @SuppressWarnings("unchecked") public PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria) { CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java index 2919879..45f7cc4 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java @@ -42,9 +42,6 @@ import org.rhq.core.domain.util.PageList; @Local public interface ResourceGroupManagerLocal {
- ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType) - throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException; - ResourceGroup getResourceGroupById(Subject user, int id, GroupCategory category) throws ResourceGroupNotFoundException;
@@ -108,10 +105,30 @@ public interface ResourceGroupManagerLocal {
List<Integer> findDeletedResourceGroupIds(int[] groupIds);
- void ensureMembershipMatches(Subject subject, int groupId, int[] resourceIds) throws ResourceGroupUpdateException; + /** + * This method ensures that the explicit group membership is set to the specified resources. Members + * will be added or removed as necessary. Make sure you pass the correct value for the <setType> + * parameter. + * + * @param subject + * @param groupId + * @param resourceIds + * @param setType Set to false if the specified resourceIds will not alter the group type (compatible or + * mixed). Set true to have the group type (re)set automatically, based on the new group membership. + * @throws ResourceGroupUpdateException + * @throws ResourceGroupDeleteException + */ + void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType) + throws ResourceGroupUpdateException, ResourceGroupDeleteException;
void uninventoryMembers(Subject subject, int groupId);
+ ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType) + throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException; + + ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType, + boolean updateMembership) throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException; + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // // The following are shared with the Remote Interface @@ -141,5 +158,4 @@ public interface ResourceGroupManagerLocal { ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group);
PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria); - } \ No newline at end of file
commit 33544cd9e57622d9484fc8f7a60146c14f9af3de Merge: b097cf3... 08f582b... Author: Heiko W. Rupp hwr@redhat.com Date: Fri Sep 17 10:09:38 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 08f582bad0e9cbf41aa41f92c1358849c0c6f8f7 Author: Ian Springer ian.springer@redhat.com Date: Thu Sep 16 18:27:40 2010 -0400
increase max length of Resource.version from 50 to 100 chars and make PC more forgiving if a discovery component returns a Resource details with a name, version, or description longer than the max length (fix for https://bugzilla.redhat.com/show_bug.cgi?id=634306)
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml index 3233d47..bf83991 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml @@ -89,7 +89,7 @@ <column name="INVENTORY_STATUS" type="VARCHAR2" size="20"/> <column name="CONNECTED" type="BOOLEAN"/> <column name="DESCRIPTION" type="VARCHAR2" size="1000"/> - <column name="VERSION" type="VARCHAR2" size="50"/> + <column name="VERSION" type="VARCHAR2" size="100"/> <column name="CTIME" type="LONG"/> <column name="MTIME" type="LONG"/> <column name="ITIME" type="LONG"/> diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index f32e5e3..ddb1974 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -32,7 +32,7 @@
<schemaSpec version="2.1"> <!-- Keep the columnType VARCHAR2, but increase size; - (see note for RHQ_ALERT_CONDITION table in alert-schema.xml for more ifo) --> + (see note for RHQ_ALERT_CONDITION table in alert-schema.xml for more info) --> <schema-alterColumn table="RHQ_ALERT_CONDITION" column="OPTION_STATUS" columnType="VARCHAR2" precision="256" /> </schemaSpec>
@@ -3210,6 +3210,11 @@ </schema-directSQL> </schemaSpec>
+ <schemaSpec version="2.95"> + <!-- Increase the max length of a Resource's version from 50 to 100. --> + <schema-alterColumn table="RHQ_RESOURCE" column="VERSION" columnType="VARCHAR2" precision="100" /> + </schemaSpec> + </dbupgrade> </target> </project> diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java index c175dc3..4181721 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. + * Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,8 @@ */ package org.rhq.core.pluginapi.inventory;
+import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.configuration.definition.ConfigurationTemplate; @@ -42,9 +44,11 @@ import org.rhq.core.system.ProcessInfo; * @author John Mazzitelli */ public class DiscoveredResourceDetails { + private final Log log = LogFactory.getLog(this.getClass()); + private static final int RESOURCE_KEY_MAX_LENGTH = 500; private static final int RESOURCE_NAME_MAX_LENGTH = 500; - private static final int RESOURCE_VERSION_MAX_LENGTH = 50; + private static final int RESOURCE_VERSION_MAX_LENGTH = 100; private static final int RESOURCE_DESCRIPTION_MAX_LENGTH = 1000;
private ResourceType resourceType; @@ -134,8 +138,9 @@ public class DiscoveredResourceDetails { }
if (resourceKey.length() > RESOURCE_KEY_MAX_LENGTH) { - throw new IllegalArgumentException("Resource key is longer than maximum length (" + RESOURCE_KEY_MAX_LENGTH - + ") [" + resourceKey + "]"); + throw new IllegalArgumentException("Plugin error: Resource key [" + resourceKey + "] specified by [" + + this.resourceType + "] discovery component is longer than the maximum length (" + + RESOURCE_KEY_MAX_LENGTH + ")."); }
this.resourceKey = resourceKey; @@ -166,11 +171,13 @@ public class DiscoveredResourceDetails { }
if (resourceName.length() > RESOURCE_NAME_MAX_LENGTH) { - throw new IllegalArgumentException("Resource name is longer than maximum length (" - + RESOURCE_NAME_MAX_LENGTH + ") [" + resourceName + "]"); + log.warn("Plugin error: Resource name [" + resourceName + "] specified by [" + this.resourceType + + "] discovery component is longer than the maximum length (" + RESOURCE_NAME_MAX_LENGTH + + " - truncating it to " + RESOURCE_NAME_MAX_LENGTH + " characters..."); + this.resourceName = resourceName.substring(0, RESOURCE_NAME_MAX_LENGTH); + } else { + this.resourceName = resourceName; } - - this.resourceName = resourceName; }
/** @@ -198,11 +205,13 @@ public class DiscoveredResourceDetails { }
if (resourceVersion.length() > RESOURCE_VERSION_MAX_LENGTH) { - throw new IllegalArgumentException("Resource version is longer than maximum length (" - + RESOURCE_VERSION_MAX_LENGTH + ") [" + resourceVersion + "]"); + log.warn("Plugin error: Resource version [" + resourceVersion + "] specified by [" + this.resourceType + + "] discovery component is longer than the maximum length (" + RESOURCE_VERSION_MAX_LENGTH + + " - truncating it to " + RESOURCE_VERSION_MAX_LENGTH + " characters..."); + this.resourceVersion = resourceVersion.substring(0, RESOURCE_VERSION_MAX_LENGTH); + } else { + this.resourceVersion = resourceVersion; } - - this.resourceVersion = resourceVersion; }
/** @@ -228,11 +237,13 @@ public class DiscoveredResourceDetails { }
if (resourceDescription.length() > RESOURCE_DESCRIPTION_MAX_LENGTH) { - throw new IllegalArgumentException("Resource description is longer than maximum length (" - + RESOURCE_DESCRIPTION_MAX_LENGTH + ") [" + resourceDescription + "]"); + log.warn("Plugin error: Resource description [" + resourceDescription + "] specified by [" + this.resourceType + + "] discovery component is longer than the maximum length (" + RESOURCE_DESCRIPTION_MAX_LENGTH + + " - truncating it to " + RESOURCE_DESCRIPTION_MAX_LENGTH + " characters..."); + this.resourceDescription = resourceDescription.substring(0, RESOURCE_DESCRIPTION_MAX_LENGTH); + } else { + this.resourceDescription = resourceDescription; } - - this.resourceDescription = resourceDescription; }
/** @@ -339,6 +350,7 @@ public class DiscoveredResourceDetails { } }
- return new Configuration(); // there is no default plugin config available, return an empty one + // There is no default plugin config template defined - return an empty one. + return new Configuration(); } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java index 6e62db3..1a5e44a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java @@ -1,7 +1,8 @@ /* * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
commit cbda8abbbe6e35206f27bbb95430620f3a702c3e Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 16 17:03:56 2010 -0400
wrap all table cells by default. subclasses are free to override this in configureTable method
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index 5196c71..a0487db 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -186,6 +186,8 @@ public class Table extends LocatableHLayout { listGrid.setAutoFitData(Autofit.HORIZONTAL); listGrid.setAlternateRecordStyles(true); listGrid.setResizeFieldsInRealTime(false); + listGrid.setWrapCells(true); + listGrid.setFixedRecordHeights(false);
// By default, SmartGWT will disable any rows that have a record named "enabled" with a value of false - setting // these fields to a bogus field name will disable this behavior. Note, setting them to null does *not* disable
commit 41e95c0bc4b435c4fbf12495e2110b4c31311c2b Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 16 16:24:59 2010 -0400
able to now create a new alert def and update alert def in the DB
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java index ce834da..818aaca 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java @@ -25,6 +25,7 @@ import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDampening; import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.alert.AlertPriority; import org.rhq.core.domain.alert.BooleanExpression; @@ -71,7 +72,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection { public void executeAction(ListGridRecord[] selection) { newButtonPressed(selection); // I don't think you want this refresh, it will recreate the new alert detail - //CoreGUI.refresh(); + //refresh(); } });
@@ -79,7 +80,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection { : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { public void executeAction(ListGridRecord[] selection) { enableButtonPressed(selection); - CoreGUI.refresh(); + refresh(); } });
@@ -87,7 +88,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection { : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { public void executeAction(ListGridRecord[] selection) { disableButtonPressed(selection); - CoreGUI.refresh(); + refresh(); } });
@@ -95,7 +96,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection { : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { public void executeAction(ListGridRecord[] selection) { deleteButtonPressed(selection); - CoreGUI.refresh(); + refresh(); } }); } @@ -133,11 +134,14 @@ public abstract class AbstractAlertDefinitionsView extends TableSection { AlertDefinition newAlertDef = new AlertDefinition(); newAlertDef.setDeleted(false); newAlertDef.setEnabled(true); - newAlertDef.setNotifyFiltered(false); - newAlertDef.setParentId(Integer.valueOf(0)); - newAlertDef.setConditionExpression(BooleanExpression.ALL); newAlertDef.setPriority(AlertPriority.MEDIUM); + newAlertDef.setParentId(Integer.valueOf(0)); + newAlertDef.setConditionExpression(BooleanExpression.ANY); newAlertDef.setWillRecover(false); + newAlertDef.setRecoveryId(Integer.valueOf(0)); + newAlertDef.setAlertDampening(new AlertDampening(AlertDampening.Category.NONE)); + newAlertDef.setNotifyFiltered(false); + newAlertDef.setControlFiltered(false); singleAlertDefinitionView.setAlertDefinition(newAlertDef); singleAlertDefinitionView.makeEditable(); } else { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java index fcb018d..cbf368d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java @@ -94,6 +94,16 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView { }
@Override + public SingleAlertDefinitionView getDetailsView(int id) { + SingleAlertDefinitionView view = super.getDetailsView(id); + if (id == 0) { + // when creating a new alert def, make sure to set this in the new alert def + view.getAlertDefinition().setResource(resource); + } + return view; + } + + @Override protected boolean isAllowedToModifyAlertDefinitions() { return this.permissions.isAlert(); } @@ -185,19 +195,34 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView { }
@Override - protected void commitAlertDefinition(AlertDefinition alertDefinition) { - GWTServiceLookup.getAlertDefinitionService().updateAlertDefinition(alertDefinition.getId(), alertDefinition, - true, new AsyncCallback<AlertDefinition>() { - @Override - public void onSuccess(AlertDefinition result) { - CoreGUI.getMessageCenter().notify(new Message("Alert definition is updated", Severity.Info)); - ResourceAlertDefinitionsView.this.refresh(); - } - - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to update alert definition", caught); - } - }); + protected void commitAlertDefinition(final AlertDefinition alertDefinition) { + if (alertDefinition.getId() == 0) { + GWTServiceLookup.getAlertDefinitionService().createAlertDefinition(alertDefinition, + Integer.valueOf(resource.getId()), new AsyncCallback<Integer>() { + @Override + public void onSuccess(Integer result) { + CoreGUI.getMessageCenter().notify(new Message("Alert definition is created", Severity.Info)); + alertDefinition.setId(result.intValue()); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to create alert definition", caught); + } + }); + } else { + GWTServiceLookup.getAlertDefinitionService().updateAlertDefinition(alertDefinition.getId(), + alertDefinition, true, new AsyncCallback<AlertDefinition>() { + @Override + public void onSuccess(AlertDefinition result) { + CoreGUI.getMessageCenter().notify(new Message("Alert definition is updated", Severity.Info)); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to update alert definition", caught); + } + }); + } } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java index e309eea..14c123c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java @@ -23,6 +23,9 @@ import com.google.gwt.user.client.rpc.RemoteService; import org.rhq.core.domain.alert.AlertDefinition;
public interface AlertDefinitionGWTService extends RemoteService { + + int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws Exception; + AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition, boolean updateInternals) throws Exception;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java index 169b758..606195b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java @@ -30,6 +30,15 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
private AlertDefinitionManagerLocal alertDefManager = LookupUtil.getAlertDefinitionManager();
+ public int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws Exception { + try { + int results = alertDefManager.createAlertDefinition(getSessionSubject(), alertDefinition, resourceId); + return results; + } catch (Exception e) { + throw new RuntimeException(ThrowableUtil.getAllMessages(e)); + } + } + public AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition, boolean updateInternals) throws Exception { try {
commit 106f6e489ec0552325e6645ecfe9cc801aa9c34e Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 16 16:09:25 2010 -0400
most times, people only have a sinlge condition, and the internals for condition checking on the server are more efficient when using ANY so rather than default to ALL, which to ANY (even though logically it doesn't matter when most times you just have a single condition, in reality, ANY processes a bit faster so use that)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java index 182173a..571daed 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java @@ -138,10 +138,10 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E conditionExpressionForm = new LocatableDynamicForm(this.extendLocatorId("conditionExpressionForm")); conditionExpression = new SelectItem("conditionExpression", "Fire alert when"); LinkedHashMap<String, String> condExprs = new LinkedHashMap<String, String>(2); - condExprs.put(BooleanExpression.ALL.name(), BooleanExpression.ALL.toString()); condExprs.put(BooleanExpression.ANY.name(), BooleanExpression.ANY.toString()); + condExprs.put(BooleanExpression.ALL.name(), BooleanExpression.ALL.toString()); conditionExpression.setValueMap(condExprs); - conditionExpression.setDefaultValue(BooleanExpression.ALL.name()); + conditionExpression.setDefaultValue(BooleanExpression.ANY.name()); conditionExpression.setWrapTitle(false);
conditionExpressionStatic = new StaticTextItem("conditionExpressionStatic", "Fire alert when");
commit cb14e77be0c963c7b63b153c2cb258667ec75f07 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 16 14:28:23 2010 -0400
don't show the trends up/down metrics when building the baseline condition since it doesn't make sense to choose trending metrics (then never get baselines)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index b17e25a..7e81a0e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -46,6 +46,7 @@ import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.NumericType; import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.core.domain.resource.ResourceType; @@ -294,7 +295,7 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu(THRESHOLD_METRIC_ITEMNAME, ifFunc)); + formItems.add(buildMetricDropDownMenu(THRESHOLD_METRIC_ITEMNAME, false, ifFunc)); formItems.add(buildComparatorDropDownMenu(THRESHOLD_COMPARATOR_ITEMNAME, ifFunc)); TextItem absoluteValue = new TextItem(THRESHOLD_ABSVALUE_ITEMNAME, "Metric Value"); absoluteValue.setWrapTitle(false); @@ -317,7 +318,8 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("baselineHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu(BASELINE_METRIC_ITEMNAME, ifFunc)); + // if a metric is trending (up or down), it will never have baselines calculated for it so only show dynamic metrics + formItems.add(buildMetricDropDownMenu(BASELINE_METRIC_ITEMNAME, true, ifFunc)); formItems.add(buildComparatorDropDownMenu(BASELINE_COMPARATOR_ITEMNAME, ifFunc));
TextItem baselinePercentage = new TextItem(BASELINE_PERCENTAGE_ITEMNAME, "Baseline Percentage"); @@ -353,7 +355,7 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu(CHANGE_METRIC_ITEMNAME, ifFunc)); + formItems.add(buildMetricDropDownMenu(CHANGE_METRIC_ITEMNAME, false, ifFunc));
return formItems; } @@ -488,12 +490,14 @@ public class NewConditionEditor extends LocatableDynamicForm { return formItems; }
- private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) { + private SelectItem buildMetricDropDownMenu(String itemName, boolean dynamicOnly, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>(); for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) { if (def.getDataType() == DataType.MEASUREMENT) { - metricsMap.put(def.getName(), def.getDisplayName()); + if (!dynamicOnly || def.getNumericType() == NumericType.DYNAMIC) { + metricsMap.put(def.getName(), def.getDisplayName()); + } } }
commit 0990342d29af546cacce185ac0a14b6f5972ad57 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 16 14:27:26 2010 -0400
make sure the caller gave us the numeric type - if not, we have to query it
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java index 0a2f201..3c41812 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java @@ -591,7 +591,12 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal, if (alertConditionCategory == AlertConditionCategory.BASELINE) {
MeasurementDefinition def = alertCondition.getMeasurementDefinition(); - if (def.getNumericType() != NumericType.DYNAMIC) { + NumericType numType = def.getNumericType(); + if (numType == null) { + def = entityManager.getReference(MeasurementDefinition.class, def.getId()); + numType = def.getNumericType(); + } + if (numType != NumericType.DYNAMIC) { throw new InvalidAlertDefinitionException("Invalid Condition: '" + def.getDisplayName() + "' is a trending metric, and thus will never have baselines calculated for it."); }
commit b21b0b9124584943641dfb0698c574da28fe5234 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 16 14:03:06 2010 -0400
set proper locator on the table
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index 6a3c6f0..2d4e85a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -84,7 +84,7 @@ public class ConditionsEditor extends LocatableVLayout { protected void onInit() { super.onInit();
- table = new Table("conditionsTable"); + table = new Table(extendLocatorId("conditionsTable")); table.setShowHeader(false);
final ConditionDataSource dataSource = new ConditionDataSource();
commit ac55b68d928e6cb3be670cadd49fd447c1f73f9c Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 16 13:12:49 2010 -0400
add the new alert def gwt service to the servlet mappings
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml index 6e5d56b..377ae0d 100644 --- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml +++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml @@ -46,6 +46,11 @@ </servlet-class> </servlet> <servlet> + <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AlertDefinitionGWTService</servlet-name> + <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl + </servlet-class> + </servlet> + <servlet> <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI OperationGWTService</servlet-name> <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl </servlet-class> @@ -149,6 +154,10 @@ <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/AlertGWTService</url-pattern> </servlet-mapping> <servlet-mapping> + <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AlertDefinitionGWTService</servlet-name> + <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/AlertDefinitionGWTService</url-pattern> + </servlet-mapping> + <servlet-mapping> <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI OperationGWTService</servlet-name> <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/OperationGWTService</url-pattern> </servlet-mapping>
commit 11226063e918f7bd9fc622afc2189d1c32d3f359 Merge: a36991e... f439da6... Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Sep 16 12:39:12 2010 -0400
Merge branch 'master' into master-jay
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java index 759f569,08f3290..41aff20 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java @@@ -222,11 -220,11 +223,11 @@@ public class OverviewView extends Locat if (dynamic) { StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", "Group Definition"); GroupDefinition groupDefinition = group.getGroupDefinition(); - // TODO (ips): Make this a link to the group def. - groupDefinitionItem.setValue(groupDefinition.getName()); + String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId()); + groupDefinitionItem.setValue("<a href="" + groupDefinitionUrl + "">" + groupDefinition.getName() + "</a>"); formItems.add(groupDefinitionItem); } - + generalPropsForm.setItems(formItems.toArray(new FormItem[formItems.size()])); addMember(generalPropsForm);
commit a36991e58dbc6623c8a0d027d30b5c6bfb927ffb Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Sep 16 12:37:58 2010 -0400
Made OverviewView and EnhancedDynamicForm Locatable
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java index 02592c8..b0f5042 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java @@ -22,7 +22,9 @@ */ package org.rhq.enterprise.gui.coregui.client.components.form;
-import com.google.gwt.core.client.JavaScriptObject; +import java.util.ArrayList; +import java.util.List; + import com.google.gwt.user.client.Timer; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.FormItemIfFunction; @@ -38,8 +40,7 @@ import com.smartgwt.client.widgets.form.fields.events.ItemHoverHandler; import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent; import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
-import java.util.ArrayList; -import java.util.List; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** * A subclass of SmartGWT's DynamicForm widget that provides the following additional feature: @@ -51,13 +52,9 @@ import java.util.List; * * @author Ian Springer */ -public class EnhancedDynamicForm extends DynamicForm { - public EnhancedDynamicForm(JavaScriptObject jsObj) { - super(jsObj); - } - - public EnhancedDynamicForm() { - super(); +public class EnhancedDynamicForm extends LocatableDynamicForm { + public EnhancedDynamicForm(String locatorId) { + super(locatorId); }
@Override @@ -78,9 +75,8 @@ public class EnhancedDynamicForm extends DynamicForm { final TogglableTextItem togglableTextItem = (TogglableTextItem) item; togglableTextItemNames.add(togglableTextItem.getName());
- final StaticTextItem staticTextItem = - new StaticTextItem(getStaticTextItemName(togglableTextItem.getName()), - togglableTextItem.getTitle()); + final StaticTextItem staticTextItem = new StaticTextItem(getStaticTextItemName(togglableTextItem + .getName()), togglableTextItem.getTitle()); staticTextItem.setAttribute("editing", false); staticTextItem.setTextBoxStyle("editableText");
@@ -147,7 +143,7 @@ public class EnhancedDynamicForm extends DynamicForm { itemsList.add(togglableTextItem); } else { itemsList.add(item); - } + } }
super.setItems((FormItem[]) itemsList.toArray(new FormItem[itemsList.size()])); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index b51bc00..128dff8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -108,14 +108,15 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource protected List<TwoLevelTab> createTabs() { List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png"); + summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary", + "/images/icons/Service_up_16.png"); summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null); summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null); summaryTab.registerSubTabs(summaryOverview, summaryTimeline); tabs.add(summaryTab);
monitoringTab = new TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring", - "/images/icons/Monitor_grey_16.png"); + "/images/icons/Monitor_grey_16.png"); monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"), "Graphs", null); monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"), "Tables", null); monitorTraits = new SubTab(monitoringTab.extendLocatorId("Traits"), "Traits", null); @@ -126,14 +127,14 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource tabs.add(monitoringTab);
inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory", - "/images/icons/Inventory_grey_16.png"); + "/images/icons/Inventory_grey_16.png"); inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"), "Members", null); inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null); inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn); tabs.add(inventoryTab);
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations", - "/images/icons/Operation_grey_16.png"); + "/images/icons/Operation_grey_16.png"); this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), "History", null); this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), "Scheduled", null); operationsTab.registerSubTabs(this.opHistory, this.opSched); @@ -146,7 +147,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource tabs.add(alertsTab);
configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), "Configuration", - "/images/icons/Configure_grey_16.png"); + "/images/icons/Configure_grey_16.png"); this.configCurrent = new SubTab(configurationTab.extendLocatorId("Current"), "Current", null); this.configHistory = new SubTab(configurationTab.extendLocatorId("History"), "History", null); configurationTab.registerSubTabs(this.configCurrent, this.configHistory); @@ -172,7 +173,8 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource // FullHTMLPane timelinePane = new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()); // summaryTab.updateSubTab("Overview", new DashboardView(resource)); // summaryTab.updateSubTab("Timeline", timelinePane); - this.summaryOverview.setCanvas(new OverviewView(this.groupComposite)); + this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("Overview"), + this.groupComposite));
int groupId = this.groupComposite.getResourceGroup().getId();
@@ -187,19 +189,19 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" - + groupId)); + + groupId)); this.opSched.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" - + groupId)); + + groupId));
this.alertHistory.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" - + groupId)); + + groupId)); this.alertDef.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" - + groupId)); + + groupId));
this.configCurrent.setCanvas(new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" - + groupId)); + + groupId)); this.configHistory - .setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId)); + .setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId));
this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite));
@@ -214,11 +216,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
// Only enable "Call Time" and "Traits" subtabs for groups that implement them. this.monitoringTab.setSubTabEnabled(this.monitorTraits.getLocatorId(), hasTraits(this.groupComposite)); - this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME)); + this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets + .contains(ResourceTypeFacet.CALL_TIME));
// Inventory>Connection Settings subtab is only enabled for compat groups that define conn props. this.inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE - && facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); + && facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups. // TODO (ips): Break out mixed groups into a separate view. @@ -230,8 +233,8 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
// Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet // and when the current user has the CONFIGURE_READ permission. - getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) - && this.permissions.isConfigureRead()); + getTabSet().setTabEnabled(this.configurationTab, + facets.contains(ResourceTypeFacet.CONFIGURATION) && this.permissions.isConfigureRead());
// Events tab is only enabled for compatible groups of a type that supports the Events facet. getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); @@ -245,17 +248,17 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource criteria.addFilterVisible(null);
GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria, - new AsyncCallback<PageList<ResourceGroupComposite>>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load group composite for group with id " - + groupId, caught); - } + new AsyncCallback<PageList<ResourceGroupComposite>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError( + "Failed to load group composite for group with id " + groupId, caught); + }
- public void onSuccess(PageList<ResourceGroupComposite> result) { - groupComposite = result.get(0); - loadResourceType(groupComposite, viewPath); - } - }); + public void onSuccess(PageList<ResourceGroupComposite> result) { + groupComposite = result.get(0); + loadResourceType(groupComposite, viewPath); + } + }); }
private void loadResourceType(final ResourceGroupComposite groupComposite, final ViewPath viewPath) { @@ -266,29 +269,27 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource // Load the fully fetched ResourceType. ResourceType groupType = group.getResourceType(); ResourceTypeRepository.Cache.getInstance().getResourceTypes( - groupType.getId(), - EnumSet.of(ResourceTypeRepository.MetadataType.content, - ResourceTypeRepository.MetadataType.operations, - ResourceTypeRepository.MetadataType.measurements, - ResourceTypeRepository.MetadataType.events, - ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), - new ResourceTypeRepository.TypeLoadedCallback() { - public void onTypesLoaded(ResourceType type) { - group.setResourceType(type); - GWTServiceLookup.getAuthorizationService().getImplicitGroupPermissions(group.getId(), - new AsyncCallback<Set<Permission>>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load group permissions.", caught); - } - - public void onSuccess(Set<Permission> result) { - ResourceGroupDetailView.this.permissions = new ResourcePermission(result); - updateTabContent(groupComposite); - selectTab(getTabName(), getSubTabName(), viewPath); - } - }); - } - }); + groupType.getId(), + EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations, + ResourceTypeRepository.MetadataType.measurements, ResourceTypeRepository.MetadataType.events, + ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), + new ResourceTypeRepository.TypeLoadedCallback() { + public void onTypesLoaded(ResourceType type) { + group.setResourceType(type); + GWTServiceLookup.getAuthorizationService().getImplicitGroupPermissions(group.getId(), + new AsyncCallback<Set<Permission>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load group permissions.", caught); + } + + public void onSuccess(Set<Permission> result) { + ResourceGroupDetailView.this.permissions = new ResourcePermission(result); + updateTabContent(groupComposite); + selectTab(getTabName(), getSubTabName(), viewPath); + } + }); + } + }); } }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java index 41de300..759f569 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java @@ -18,13 +18,17 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
+import java.util.ArrayList; +import java.util.Date; +import java.util.List; + import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.layout.HLayout; -import com.smartgwt.client.widgets.layout.VLayout; + import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.GroupDefinition; import org.rhq.core.domain.resource.group.ResourceGroup; @@ -36,22 +40,19 @@ import org.rhq.enterprise.gui.coregui.client.components.form.ValueUpdatedHandler import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.util.message.Message; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** * The group Inventory>Overview subtab. * * @author Ian Springer */ -public class OverviewView extends VLayout { +public class OverviewView extends LocatableVLayout { private ResourceGroupGWTServiceAsync resourceGroupService = GWTServiceLookup.getResourceGroupService(); private ResourceGroupComposite groupComposite;
- public OverviewView(ResourceGroupComposite groupComposite) { - super(); + public OverviewView(String locatorId, ResourceGroupComposite groupComposite) { + super(locatorId); this.groupComposite = groupComposite; }
@@ -65,7 +66,7 @@ public class OverviewView extends VLayout { spacer.setHeight(15); addMember(spacer);
- final EnhancedDynamicForm generalPropsForm = new EnhancedDynamicForm(); + final EnhancedDynamicForm generalPropsForm = new EnhancedDynamicForm(this.extendLocatorId("General"));
List<FormItem> formItems = new ArrayList<FormItem>();
@@ -91,9 +92,9 @@ public class OverviewView extends VLayout { group.setName(newName); OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change name of Resource group with id " - + group.getId() - + " from "" + oldName + "" to "" + newName + "".", caught); + CoreGUI.getErrorHandler().handleError( + "Failed to change name of Resource group with id " + group.getId() + " from "" + + oldName + "" to "" + newName + "".", caught); // We failed to update it on the Server, so change back the ResourceGroup and the form item // to the original value. group.setName(oldName); @@ -101,9 +102,9 @@ public class OverviewView extends VLayout { }
public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Name of Resource group with id " - + group.getId() + " was changed from "" - + oldName + "" to "" + newName + "".", Message.Severity.Info)); + CoreGUI.getMessageCenter().notify( + new Message("Name of Resource group with id " + group.getId() + " was changed from "" + + oldName + "" to "" + newName + "".", Message.Severity.Info)); } }); } @@ -128,7 +129,7 @@ public class OverviewView extends VLayout {
final FormItem descriptionItem = (dynamic) ? new StaticTextItem() : new TogglableTextItem(); descriptionItem.setName("description"); - descriptionItem.setTitle("Description"); + descriptionItem.setTitle("Description"); descriptionItem.setValue(group.getDescription()); if (descriptionItem instanceof TogglableTextItem) { final TogglableTextItem togglableDescriptionItem = (TogglableTextItem) descriptionItem; @@ -141,9 +142,9 @@ public class OverviewView extends VLayout { group.setDescription(newDescription); OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change description of Resource group with id " - + group.getId() - + " from "" + oldDescription + "" to "" + newDescription + "".", caught); + CoreGUI.getErrorHandler().handleError( + "Failed to change description of Resource group with id " + group.getId() + " from "" + + oldDescription + "" to "" + newDescription + "".", caught); // We failed to update it on the Server, so change back the ResourceGroup and the form item // to the original value. group.setDescription(oldDescription); @@ -151,9 +152,10 @@ public class OverviewView extends VLayout { }
public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Description of Resource group with id " - + group.getId() + " was changed from "" - + oldDescription + "" to "" + newDescription + "".", Message.Severity.Info)); + CoreGUI.getMessageCenter().notify( + new Message("Description of Resource group with id " + group.getId() + + " was changed from "" + oldDescription + "" to "" + newDescription + "".", + Message.Severity.Info)); } }); } @@ -176,9 +178,9 @@ public class OverviewView extends VLayout { group.setLocation(newLocation); OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change location of Resource group with id " - + group.getId() - + " from "" + oldLocation + "" to "" + newLocation + "".", caught); + CoreGUI.getErrorHandler().handleError( + "Failed to change location of Resource group with id " + group.getId() + " from "" + + oldLocation + "" to "" + newLocation + "".", caught); // We failed to update it on the Server, so change back the ResourceGroup and the form item // to the original value. group.setLocation(oldLocation); @@ -186,9 +188,10 @@ public class OverviewView extends VLayout { }
public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Location of Resource group with id " - + group.getId() + " was changed from "" - + oldLocation + "" to "" + newLocation + "".", Message.Severity.Info)); + CoreGUI.getMessageCenter().notify( + new Message("Location of Resource group with id " + group.getId() + + " was changed from "" + oldLocation + "" to "" + newLocation + "".", + Message.Severity.Info)); } }); } @@ -223,7 +226,7 @@ public class OverviewView extends VLayout { groupDefinitionItem.setValue(groupDefinition.getName()); formItems.add(groupDefinitionItem); } - + generalPropsForm.setItems(formItems.toArray(new FormItem[formItems.size()])); addMember(generalPropsForm);
@@ -231,9 +234,10 @@ public class OverviewView extends VLayout { spacer = new HLayout(); spacer.setHeight(10); addMember(spacer); - + HTMLFlow note = new HTMLFlow(); - note.setContents("<b>*</b> Dynamic group names and descriptions are managed, and therefore are not editable."); + note + .setContents("<b>*</b> Dynamic group names and descriptions are managed, and therefore are not editable."); note.setAlign(Alignment.CENTER); addMember(note); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index e4bb9fd..65ed1be 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -112,7 +112,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary", - "/images/icons/Service_up_16.png"); + "/images/icons/Service_up_16.png"); summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null); summaryDashboard = new SubTab(summaryTab.extendLocatorId("Dashboard"), "Dashboard", null); summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null); @@ -190,17 +190,20 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo ((TwoLevelTab) top).getLayout().destroyViews(); }
- this.summaryOverview.setCanvas(new OverviewView(this.resourceComposite)); + this.summaryOverview.setCanvas(new OverviewView(this.summaryTab.extendLocatorId("OverviewView"), + this.resourceComposite)); this.summaryDashboard.setCanvas(new DashboardView(this.resourceComposite)); this.summaryTimeline.setCanvas(new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()));
this.monitorGraphs.setCanvas(new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource)); this.monitorTables.setCanvas(new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId())); - this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId())); + this.monitorTraits + .setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId())); this.monitorAvail.setCanvas(new FullHTMLPane("/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" + resource.getId())); - this.monitorSched.setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId())); + this.monitorSched + .setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId())); this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId()));
@@ -256,12 +259,14 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.resourceComposite)); monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
- inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); + inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets + .contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); ResourceType type = this.resourceComposite.getResource().getResourceType(); inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); - getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); + getTabSet().setTabEnabled(this.configurationTab, + facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT)); } @@ -303,11 +308,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo final Resource resource = resourceComposite.getResource(); ResourceTypeRepository.Cache.getInstance().getResourceTypes( resource.getResourceType().getId(), - EnumSet.of( - ResourceTypeRepository.MetadataType.children, - ResourceTypeRepository.MetadataType.content, - ResourceTypeRepository.MetadataType.operations, - ResourceTypeRepository.MetadataType.measurements, + EnumSet.of(ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.content, + ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.measurements, ResourceTypeRepository.MetadataType.events, ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), new ResourceTypeRepository.TypeLoadedCallback() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java index ac2abc2..4cf2119 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewView.java @@ -59,13 +59,11 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); private ResourceComposite resourceComposite;
- - public OverviewView(ResourceComposite resourceComposite) { - super(); + public OverviewView(String locatorId, ResourceComposite resourceComposite) { + super(locatorId); this.resourceComposite = resourceComposite; }
- @Override protected void onDraw() { super.onDraw(); @@ -78,7 +76,6 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL } }
- public void onResourceSelected(ResourceComposite resourceComposite) {
this.resourceComposite = resourceComposite; @@ -86,45 +83,41 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL
// Load metric defs. ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(), - EnumSet.of(ResourceTypeRepository.MetadataType.measurements), - new ResourceTypeRepository.TypeLoadedCallback() { - public void onTypesLoaded(ResourceType type) { - try { - buildForm(type); - loadTraitValues(); - } catch (Exception e) { - SC.say("Form load failure"); - e.printStackTrace(); - } + EnumSet.of(ResourceTypeRepository.MetadataType.measurements), + new ResourceTypeRepository.TypeLoadedCallback() { + public void onTypesLoaded(ResourceType type) { + try { + buildForm(type); + loadTraitValues(); + } catch (Exception e) { + SC.say("Form load failure"); + e.printStackTrace(); } - }); + } + }); }
private void loadTraitValues() { final Resource resource = resourceComposite.getResource(); - GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource( - resource.getId(), - DisplayType.SUMMARY, - new AsyncCallback<List<MeasurementDataTrait>>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load traits for " + resource + ".", - caught); - } + GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource(resource.getId(), + DisplayType.SUMMARY, new AsyncCallback<List<MeasurementDataTrait>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load traits for " + resource + ".", caught); + }
- public void onSuccess(List<MeasurementDataTrait> result) { - // TODO: Implement this method. - for (MeasurementDataTrait trait : result) { - String formId = trait.getName().replaceAll("\.", "_").replaceAll(" ", "__"); - FormItem item = getItem(formId); + public void onSuccess(List<MeasurementDataTrait> result) { + // TODO: Implement this method. + for (MeasurementDataTrait trait : result) { + String formId = trait.getName().replaceAll("\.", "_").replaceAll(" ", "__"); + FormItem item = getItem(formId);
- if (item != null) { - setValue(formId, trait.getValue()); - } + if (item != null) { + setValue(formId, trait.getValue()); } - markForRedraw(); } + markForRedraw(); } - ); + });
}
@@ -172,9 +165,9 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL resource.setName(newName); OverviewView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change name of Resource with id " - + resource.getId() - + " from "" + oldName + "" to "" + newName + "".", caught); + CoreGUI.getErrorHandler().handleError( + "Failed to change name of Resource with id " + resource.getId() + " from "" + oldName + + "" to "" + newName + "".", caught); // We failed to update it on the Server, so change back the Resource and the form item to // the original value. resource.setName(oldName); @@ -182,9 +175,9 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL }
public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Name of Resource with id " - + resource.getId() + " was changed from "" - + oldName + "" to "" + newName + "".", Message.Severity.Info)); + CoreGUI.getMessageCenter().notify( + new Message("Name of Resource with id " + resource.getId() + " was changed from "" + + oldName + "" to "" + newName + "".", Message.Severity.Info)); } }); } @@ -207,9 +200,9 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL resource.setDescription(newDescription); OverviewView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change description of Resource with id " - + resource.getId() - + " from "" + oldDescription + "" to "" + newDescription + "".", caught); + CoreGUI.getErrorHandler().handleError( + "Failed to change description of Resource with id " + resource.getId() + " from "" + + oldDescription + "" to "" + newDescription + "".", caught); // We failed to update it on the Server, so change back the Resource and the form item to // the original value. resource.setDescription(oldDescription); @@ -217,9 +210,10 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL }
public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Description of Resource with id " - + resource.getId() + " was changed from "" - + oldDescription + "" to "" + newDescription + "".", Message.Severity.Info)); + CoreGUI.getMessageCenter().notify( + new Message("Description of Resource with id " + resource.getId() + + " was changed from "" + oldDescription + "" to "" + newDescription + "".", + Message.Severity.Info)); } }); } @@ -242,9 +236,9 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL resource.setLocation(newLocation); OverviewView.this.resourceService.updateResource(resource, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to change location of Resource with id " - + resource.getId() - + " from "" + oldLocation + "" to "" + newLocation + "".", caught); + CoreGUI.getErrorHandler().handleError( + "Failed to change location of Resource with id " + resource.getId() + " from "" + + oldLocation + "" to "" + newLocation + "".", caught); // We failed to update it on the Server, so change back the Resource and the form item to // the original value. resource.setLocation(oldLocation); @@ -252,9 +246,9 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL }
public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("Location of Resource with id " - + resource.getId() + " was changed from "" - + oldLocation + "" to "" + newLocation + "".", Message.Severity.Info)); + CoreGUI.getMessageCenter().notify( + new Message("Location of Resource with id " + resource.getId() + " was changed from "" + + oldLocation + "" to "" + newLocation + "".", Message.Severity.Info)); } }); } @@ -262,7 +256,6 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL } formItems.add(locationItem);
- StaticTextItem versionItem = new StaticTextItem("version", "Version"); formItems.add(versionItem);
@@ -275,16 +268,16 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL StaticTextItem item = new StaticTextItem(id, trait.getDisplayName()); item.setTooltip(trait.getDescription()); formItems.add(item); -// item.setValue("?"); + // item.setValue("?"); }
-// SectionItem section = new SectionItem("Summary", "Summary"); -// section.setTitle("Summary"); -// section.setDefaultValue("Summary"); -// section.setCanCollapse(true); -// section.setCellStyle("HidablePlainSectionHeader"); -// section.setItemIds(itemIds.toArray(new String[itemIds.size()])); -// formItems.add(0, section); + // SectionItem section = new SectionItem("Summary", "Summary"); + // section.setTitle("Summary"); + // section.setDefaultValue("Summary"); + // section.setCanCollapse(true); + // section.setCellStyle("HidablePlainSectionHeader"); + // section.setItemIds(itemIds.toArray(new String[itemIds.size()])); + // formItems.add(0, section);
formItems.add(new SpacerItem()); setItems(formItems.toArray(new FormItem[formItems.size()])); @@ -295,8 +288,7 @@ public class OverviewView extends EnhancedDynamicForm implements ResourceSelectL setValue("location", resource.getLocation()); setValue("version", (resource.getVersion() != null) ? resource.getVersion() : "<i>none</i>"); Resource parentResource = resource.getParentResource(); - setValue("parent", parentResource != null ? - ("<a href="#Resource/" + parentResource.getId() + "">" + - parentResource.getName() + "</a>") : "<i>none</i>"); + setValue("parent", parentResource != null ? ("<a href="#Resource/" + parentResource.getId() + "">" + + parentResource.getName() + "</a>") : "<i>none</i>"); } }
commit 423339c8a5cae0b627d196751b5a0cf37f3630ed Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Sep 16 12:36:29 2010 -0400
There seems to be an OS-specific issue when handling the runTarget if it contains url parameters. On linux it needs to be single-quoted but on Win the quotes don't get eaten. Added OS-activated profile to handle the difference.
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index 950ce71..c8dce21 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -32,6 +32,7 @@ <gwt-plugin.localWorkers>2</gwt-plugin.localWorkers>
<coreGuiParams></coreGuiParams> + <coreGuiRunTarget>'http://localhost:7080/coregui/CoreGUI.html$%7BcoreGuiParams%7D'</coreGuiRunTarget> </properties>
@@ -237,7 +238,7 @@ <inplace>false</inplace> <!-- <logLevel>INFO' -bindAddress 0.0.0.0 -logLevel 'INFO</logLevel> --> <logLevel>INFO</logLevel> - <runTarget>http://localhost:7080/coregui/CoreGUI.html$%7BcoreGuiParams%7D</runTarget> + <runTarget>${coreGuiRunTarget}</runTarget> <extraJvmArgs>${gwt-plugin.extraJvmArgs}</extraJvmArgs> <localWorkers>${gwt-plugin.localWorkers}</localWorkers> <draftCompile>true</draftCompile> @@ -416,6 +417,18 @@ </build> </profile>
+ <!-- Change the runTarget to not have single quotes. The quotes work for linux but not win --> + <profile> + <activation> + <os> + <family>Windows</family> + </os> + </activation> + <properties> + <coreGuiRunTarget>http://localhost:7080/coregui/CoreGUI.html$%7BcoreGuiParams%7D</coreGuiRunTarget> + </properties> + </profile> + </profiles>
commit f439da6dd89dbbad0a4f57cad5038a555136d54d Author: Ian Springer ian.springer@redhat.com Date: Thu Sep 16 11:12:39 2010 -0400
make the group def name on the group Summary>Overview subtab a link to the corresponding group def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java index 0df613d..073ef0c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java @@ -30,7 +30,6 @@ public class LinkManager { private static boolean GWT = true;
public static String getResourceLink(int resourceId) { - if (GWT) { return "#Resource/" + resourceId + "/Summary/Overview"; } else { @@ -38,12 +37,19 @@ public class LinkManager { } }
- public static String getResourceGroupLink(int resouceGroupId) { + public static String getResourceGroupLink(int groupId) { + if (GWT) { + return "#ResourceGroup/" + groupId; + } else { + return "/rhq/group/inventory/view.xhtml?groupId=" + groupId; + } + }
+ public static String getGroupDefinitionLink(int groupDefinitionId) { if (GWT) { - return "#ResourceGroup/" + resouceGroupId; + return "#Inventory/Groups/DynaGroup%20Manager/" + groupDefinitionId; } else { - return "/rhq/group/inventory/view.xhtml?groupId=" + resouceGroupId; + return "/rhq/definition/group/view.xhtml?groupDefinitionId=" + groupDefinitionId; } }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java index 41de300..08f3290 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java @@ -30,6 +30,7 @@ import org.rhq.core.domain.resource.group.GroupDefinition; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm; import org.rhq.enterprise.gui.coregui.client.components.form.TogglableTextItem; import org.rhq.enterprise.gui.coregui.client.components.form.ValueUpdatedHandler; @@ -219,8 +220,8 @@ public class OverviewView extends VLayout { if (dynamic) { StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", "Group Definition"); GroupDefinition groupDefinition = group.getGroupDefinition(); - // TODO (ips): Make this a link to the group def. - groupDefinitionItem.setValue(groupDefinition.getName()); + String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId()); + groupDefinitionItem.setValue("<a href="" + groupDefinitionUrl + "">" + groupDefinition.getName() + "</a>"); formItems.add(groupDefinitionItem); }
commit ad8060db3499243b1b59b15d72aec9940a6e150c Author: Joseph Marques joseph@redhat.com Date: Thu Sep 16 03:39:43 2010 -0400
refinement of CRUD functionality for group definitions:
* expose several more fields in the group definition datasource * mark group definition datasource fields required as appropriate * add form validation and halt create/update workflow until errors are resolved * push the create/update functionality into the datasource impl * update the details-form to use the create/update functionality on the datasource * add hooks to return to the list view after create/update
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java index c373dd7..a95e0e6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java @@ -18,13 +18,19 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
+import java.util.HashMap; +import java.util.Map; + +import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSourceField; +import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.rpc.RPCResponse; +import com.smartgwt.client.types.FieldType; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; @@ -55,17 +61,31 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> { private GroupDefinitionDataSource() { super();
- DataSourceField idDataField = new DataSourceIntegerField("id", "ID"); - idDataField.setPrimaryKey(true); - idDataField.setCanEdit(false); + DataSourceField idField = new DataSourceIntegerField("id", "ID"); + idField.setPrimaryKey(true); + idField.setCanEdit(false);
DataSourceTextField nameField = new DataSourceTextField("name", "Name"); + nameField.setRequired(true); + DataSourceTextField descriptionField = new DataSourceTextField("description", "Description"); + DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression"); + expressionField.setRequired(true); + + DataSourceTextField recursiveField = new DataSourceTextField("recursive", "Recursive"); + recursiveField.setType(FieldType.BOOLEAN); + + /* + DataSourceTextField recalculationIntervalField = new DataSourceTextField("recalculationInterval", + "Recalculation Interval"); + */ + DataSourceTextField nextCalculationTimeField = new DataSourceTextField("nextCalculationTime", "Next Calculation Time");
- setFields(idDataField, nameField, descriptionField, expressionField, nextCalculationTimeField); + setFields(idField, nameField, descriptionField, expressionField, recursiveField, /*recalculationIntervalField,*/ + nextCalculationTimeField);
}
@@ -91,8 +111,71 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> { }
@Override + protected void executeAdd(final DSRequest request, final DSResponse response) { + JavaScriptObject data = request.getData(); + final ListGridRecord record = new ListGridRecord(data); + final GroupDefinition newGroupDefinition = copyValues(record); + final String name = newGroupDefinition.getName(); + + GWTServiceLookup.getResourceGroupService().createGroupDefinition(newGroupDefinition, + new AsyncCallback<GroupDefinition>() { + @Override + public void onFailure(Throwable caught) { + Map<String, String> errors = new HashMap<String, String>(); + errors.put("name", "A group definition with this name already exists."); + response.setErrors(errors); + response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR); + processResponse(request.getRequestId(), response); + } + + @Override + public void onSuccess(GroupDefinition result) { + CoreGUI.getErrorHandler().handleError("Successfully created group definition '" + name + "'"); + response.setData(new Record[] { copyValues(result) }); + processResponse(request.getRequestId(), response); + } + }); + } + + @Override + protected void executeUpdate(final DSRequest request, final DSResponse response) { + final ListGridRecord record = getEditedRecord(request); + final GroupDefinition updatedGroupDefinition = copyValues(record); + final String name = updatedGroupDefinition.getName(); + + GWTServiceLookup.getResourceGroupService().updateGroupDefinition(updatedGroupDefinition, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failure saving group definition '" + name + "'", caught); + } + + @Override + public void onSuccess(Void result) { + CoreGUI.getErrorHandler().handleError("Successfully saved group definition '" + name + "'"); + response.setData(new Record[] { copyValues(updatedGroupDefinition) }); + processResponse(request.getRequestId(), response); + } + }); + } + + @Override public GroupDefinition copyValues(ListGridRecord from) { - return null; // TODO: Implement this method. + GroupDefinition groupDefinition = new GroupDefinition(); + String[] attributes = from.getAttributes(); + for (String nextAttribute : attributes) { + System.out.println("ListGridRecord attribute: " + nextAttribute); + } + groupDefinition.setId(from.getAttributeAsInt("id")); + groupDefinition.setName(from.getAttributeAsString("name")); + groupDefinition.setDescription(from.getAttributeAsString("description")); + groupDefinition.setExpression(from.getAttributeAsString("expression")); + groupDefinition.setRecursive(from.getAttributeAsBoolean("recursive")); + groupDefinition.setRecalculationInterval(Long.valueOf(from.getAttributeAsString("recalculationInterval"))); + // modifiedTime, createdTime, and lastCalculationTime are updated by GroupDefinitionManagerBean only + // nextCalculationTime is a non-persistent, derived field + + return groupDefinition; }
@Override @@ -102,11 +185,12 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> { record.setAttribute("name", from.getName()); record.setAttribute("description", from.getDescription()); record.setAttribute("expression", from.getExpression()); + record.setAttribute("recursive", from.isRecursive()); record.setAttribute("recalculationInterval", from.getRecalculationInterval()); record.setAttribute("modifiedTime", from.getModifiedTime()); record.setAttribute("createdTime", from.getCreatedTime()); record.setAttribute("lastCalculationTime", from.getLastCalculationTime()); - record.setAttribute("nextCalculationTime", from.getNextCalculationTime()); + record.setAttribute("nextCalculationTime", from.getNextCalculationTime()); // derived // record.setAttribute("managedResourceGroups", from.getManagedResourceGroups());
return record; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index 328794e..7b5ea42 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -23,17 +23,19 @@ import java.util.Set;
import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.DSCallback; +import com.smartgwt.client.data.DSRequest; +import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.types.DSOperationType; import com.smartgwt.client.types.Overflow; -import com.smartgwt.client.widgets.form.fields.ButtonItem; +import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.form.fields.CheckboxItem; -import com.smartgwt.client.widgets.form.fields.ResetItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.SpinnerItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.form.fields.TextAreaItem; import com.smartgwt.client.widgets.form.fields.TextItem; -import com.smartgwt.client.widgets.form.fields.events.ClickEvent; -import com.smartgwt.client.widgets.form.fields.events.ClickHandler; +import com.smartgwt.client.widgets.layout.HLayout;
import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; @@ -44,8 +46,8 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.util.FormUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** @@ -58,6 +60,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private ViewId viewId;
+ // editable form + private TextItem id; private TextItem name; private TextAreaItem description; private CheckboxItem recursive; @@ -65,14 +69,14 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm private TextAreaItem expression; private SpinnerItem recalculationInterval;
+ // read-only form + private StaticTextItem idStatic; private StaticTextItem nameStatic; private StaticTextItem descriptionStatic; private StaticTextItem recursiveStatic; private StaticTextItem expressionStatic; private StaticTextItem recalculationIntervalStatic;
- private boolean formBuilt = false; - private GroupDefinitionDataSource dataSource;
public SingleGroupDefinitionView(String locatorId) { @@ -85,7 +89,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm this.dataSource = GroupDefinitionDataSource.getInstance();
setPadding(10); - setOverflow(Overflow.AUTO); + setOverflow(Overflow.VISIBLE); + setWidth(5);
buildForm();
@@ -95,42 +100,69 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm public void setGroupDefinition(GroupDefinition groupDefinition) { this.groupDefinition = groupDefinition;
- if (groupDefinition == null) { - clearFormValues(); - } else { - name.setValue(groupDefinition.getName()); - nameStatic.setValue(groupDefinition.getName()); + // form setup + id.setValue(groupDefinition.getId()); + idStatic.setValue(groupDefinition.getId()); + + name.setValue(groupDefinition.getName()); + nameStatic.setValue(groupDefinition.getName());
- recursive.setValue(groupDefinition.isRecursive() ? "Yes" : "No"); - recursiveStatic.setValue(groupDefinition.isRecursive() ? "Yes" : "No"); + recursive.setValue(groupDefinition.isRecursive()); + recursiveStatic.setValue(groupDefinition.isRecursive());
- description.setValue(groupDefinition.getDescription()); - descriptionStatic.setValue(groupDefinition.getDescription()); + description.setValue(groupDefinition.getDescription()); + descriptionStatic.setValue(groupDefinition.getDescription());
- recalculationInterval.setValue(groupDefinition.getRecalculationInterval()); - recalculationIntervalStatic.setValue(groupDefinition.getRecalculationInterval()); + recalculationInterval.setValue(groupDefinition.getRecalculationInterval()); + recalculationIntervalStatic.setValue(groupDefinition.getRecalculationInterval());
- expression.setValue(groupDefinition.getExpression()); - expressionStatic.setValue(groupDefinition.getExpression()); + expression.setValue(groupDefinition.getExpression()); + expressionStatic.setValue(groupDefinition.getExpression());
- ButtonItem saveButton = new ButtonItem("save", "Save"); - ResetItem resetButton = new ResetItem("reset", "Reset"); + final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("GroupDefinitionForm")); + form.setFields(id, idStatic, name, nameStatic, description, descriptionStatic, expression, expressionStatic, + recursive, recursiveStatic, recalculationInterval, recalculationIntervalStatic); + form.setNumCols(2); + form.setDataSource(dataSource); + form.setHiliteRequiredFields(true); + form.setRequiredTitleSuffix(" <span style="color: red;">* </span>:"); + if (groupDefinition.getId() == 0) { + form.setSaveOperationType(DSOperationType.ADD); + } else { + form.setSaveOperationType(DSOperationType.UPDATE); + }
- saveButton.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent clickEvent) { - createOrUpdate(); + // button setup + IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); + saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + if (form.validate()) { + //createOrUpdate(); + form.saveData(new DSCallback() { + @Override + public void execute(DSResponse response, Object rawData, DSRequest request) { + History.back(); + } + }); } - }); + } + }); + + IButton resetButton = new LocatableIButton(this.extendLocatorId("Reset"), "Reset"); + resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + form.reset(); + } + });
- LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("GroupDefinitionForm")); - form.setFields(name, nameStatic, recursive, recursiveStatic, description, descriptionStatic, - recalculationInterval, recalculationIntervalStatic, expression, expressionStatic, saveButton, - resetButton); - form.setNumCols(4); + HLayout buttonLayout = new HLayout(10); // margin between members + buttonLayout.setMargin(10); // margin around layout widget + buttonLayout.addMember(saveButton); + buttonLayout.addMember(resetButton);
- addMember(form); - formBuilt = true; - } + // canvas setup + addMember(form); + addMember(buttonLayout);
markForRedraw(); } @@ -176,98 +208,40 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm markForRedraw(); }
- public void createOrUpdate() { - groupDefinition.setName(FormUtility.getStringSafely(name)); - groupDefinition.setDescription(FormUtility.getStringSafely(description)); - groupDefinition.setRecursive("Yes".equals(recursive.getValue())); - groupDefinition.setExpression(FormUtility.getStringSafely(expression)); - groupDefinition.setRecalculationInterval(Long.valueOf(FormUtility.getStringSafely(recalculationInterval, "0"))); - - final String name = groupDefinition.getName(); - if (groupDefinitionId == 0) { - GWTServiceLookup.getResourceGroupService().createGroupDefinition(groupDefinition, - new AsyncCallback<GroupDefinition>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failure to create group definition '" + name + "'", - caught); - } - - @Override - public void onSuccess(GroupDefinition result) { - CoreGUI.getErrorHandler().handleError("Successfully created group definition '" + name + "'"); - History.back(); - } - }); - } else { - GWTServiceLookup.getResourceGroupService().updateGroupDefinition(groupDefinition, - new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failure saving group definition '" + name + "'", caught); - } - - @Override - public void onSuccess(Void result) { - CoreGUI.getErrorHandler().handleError("Successfully saved group definition '" + name + "'"); - History.back(); - } - }); - } - } - - public void clearFormValues() { - name.clearValue(); - description.clearValue(); - recursive.clearValue(); - expression.clearValue(); - recalculationInterval.clearValue(); - - nameStatic.clearValue(); - descriptionStatic.clearValue(); - recursiveStatic.clearValue(); - expressionStatic.clearValue(); - recalculationIntervalStatic.clearValue(); - - markForRedraw(); - } - private void buildForm() { - if (!formBuilt) { - - name = new TextItem("name", "Name"); - name.setWidth(400); - name.setDefaultValue(""); - nameStatic = new StaticTextItem("nameStatic", "Name"); - - description = new TextAreaItem("description", "Description"); - description.setWidth(400); - description.setHeight(50); - description.setDefaultValue(""); - descriptionStatic = new StaticTextItem("descriptionStatic", "Description"); - - recursive = new CheckboxItem("recursive", "Recursive"); - recursive.setValueMap("Yes", "No"); - recursive.setDefaultValue("Yes"); - recursiveStatic = new StaticTextItem("recursiveStatic", "Recursive"); - - expression = new TextAreaItem("expression", "Expression"); - expression.setWidth(400); - expression.setHeight(150); - expression.setDefaultValue(""); - expressionStatic = new StaticTextItem("expressionStatic", "Expression"); - - recalculationInterval = new SpinnerItem("recalculationInterval", "Recalculation Interval"); - recalculationInterval.setWrapTitle(false); - recalculationInterval.setMin(0); - recalculationInterval.setDefaultValue(0); - recalculationIntervalStatic = new StaticTextItem("recalculationIntervalStatic", "Recalculation Interval"); - - templateSelector = new SelectItem(); - templateSelector.setValueMap(getTemplates()); - - formBuilt = true; - } + id = new TextItem("id", "ID"); + id.setVisible(false); + idStatic = new StaticTextItem("idStatic", "ID"); + idStatic.setVisible(false); + + name = new TextItem("name", "Name"); + name.setWidth(400); + name.setDefaultValue(""); + nameStatic = new StaticTextItem("nameStatic", "Name"); + + description = new TextAreaItem("description", "Description"); + description.setWidth(400); + description.setHeight(50); + description.setDefaultValue(""); + descriptionStatic = new StaticTextItem("descriptionStatic", "Description"); + + recursive = new CheckboxItem("recursive", "Recursive"); + recursiveStatic = new StaticTextItem("recursiveStatic", "Recursive"); + + expression = new TextAreaItem("expression", "Expression"); + expression.setWidth(400); + expression.setHeight(150); + expression.setDefaultValue(""); + expressionStatic = new StaticTextItem("expressionStatic", "Expression"); + + recalculationInterval = new SpinnerItem("recalculationInterval", "Recalculation Interval"); + recalculationInterval.setWrapTitle(false); + recalculationInterval.setMin(0); + recalculationInterval.setDefaultValue(0); + recalculationIntervalStatic = new StaticTextItem("recalculationIntervalStatic", "Recalculation Interval"); + + templateSelector = new SelectItem(); + templateSelector.setValueMap(getTemplates()); }
public static LinkedHashMap<String, String> getTemplates() { @@ -345,12 +319,18 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm }
public void onSuccess(PageList<GroupDefinition> result) { - GroupDefinition existingGroupDefinition = result.get(0); - setGroupDefinition(existingGroupDefinition); - if (hasEditPermission) { - switchToEditMode(); + if (result.size() == 0) { + CoreGUI.getErrorHandler().handleError( + "No group definition exists with id=" + groupDefinitionId); + History.back(); } else { - switchToViewMode(); + GroupDefinition existingGroupDefinition = result.get(0); + setGroupDefinition(existingGroupDefinition); + if (hasEditPermission) { + switchToEditMode(); + } else { + switchToViewMode(); + } } } });
commit 888dfe3a0fe5e171e108a5d7fb5e619d17e64888 Author: Joseph Marques joseph@redhat.com Date: Thu Sep 16 03:36:10 2010 -0400
remove dead code, buildRecords already exists on the RPCDataSource component
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java index bdfe27e..9af7064 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java @@ -18,7 +18,6 @@ */ package org.rhq.enterprise.gui.coregui.client.admin.roles;
-import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -73,8 +72,6 @@ public class RolesDataSource extends RPCDataSource<Role> { }
public void executeFetch(final DSRequest request, final DSResponse response) { - final long start = System.currentTimeMillis(); - RoleCriteria criteria = new RoleCriteria(); criteria.setPageControl(getPageControl(request));
@@ -120,7 +117,6 @@ public class RolesDataSource extends RPCDataSource<Role> { public void onSuccess(Role result) { CoreGUI.getMessageCenter().notify( new Message("Role [" + result.getName() + "] added", Message.Severity.Info)); - ListGridRecord record = new ListGridRecord(); response.setData(new Record[] { copyValues(result) }); processResponse(request.getRequestId(), response); } @@ -191,14 +187,4 @@ public class RolesDataSource extends RPCDataSource<Role> { to.setAttribute("entity", from); return to; } - - public ListGridRecord[] buildRecords(Collection<Role> roles) { - ListGridRecord[] roleRecords = new ListGridRecord[roles.size()]; - int i = 0; - for (Role role : roles) { - ListGridRecord record = copyValues(role); - roleRecords[i++] = record; - } - return roleRecords; - } }
commit fbdf98e530f549f4f3f30d514b8e712c0d03a882 Author: Joseph Marques joseph@redhat.com Date: Thu Sep 16 03:35:51 2010 -0400
remove getEditedRecord from Roles/UsersDataSource, leveraging the RPCDataSource common impl
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java index 3b9aafb..bdfe27e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java @@ -32,7 +32,6 @@ import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.rpc.RPCResponse; -import com.smartgwt.client.util.JSOHelper; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.auth.Subject; @@ -193,20 +192,6 @@ public class RolesDataSource extends RPCDataSource<Role> { return to; }
- private ListGridRecord getEditedRecord(DSRequest request) { - // Retrieving values before edit - JavaScriptObject oldValues = request.getAttributeAsJavaScriptObject("oldValues"); - // Creating new record for combining old values with changes - ListGridRecord newRecord = new ListGridRecord(); - // Copying properties from old record - JSOHelper.apply(oldValues, newRecord.getJsObj()); - // Retrieving changed values - JavaScriptObject data = request.getData(); - // Apply changes - JSOHelper.apply(data, newRecord.getJsObj()); - return newRecord; - } - public ListGridRecord[] buildRecords(Collection<Role> roles) { ListGridRecord[] roleRecords = new ListGridRecord[roles.size()]; int i = 0; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java index 0fa21cf..af9acd6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java @@ -32,7 +32,6 @@ import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.rpc.RPCResponse; import com.smartgwt.client.types.FieldType; -import com.smartgwt.client.util.JSOHelper; import com.smartgwt.client.widgets.form.validator.LengthRangeValidator; import com.smartgwt.client.widgets.form.validator.MatchesFieldValidator; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -253,18 +252,4 @@ public class UsersDataSource extends RPCDataSource<Subject> { return to; }
- private ListGridRecord getEditedRecord(DSRequest request) { - // Retrieving values before edit - JavaScriptObject oldValues = request.getAttributeAsJavaScriptObject("oldValues"); - // Creating new record for combining old values with changes - ListGridRecord newRecord = new ListGridRecord(); - // Copying properties from old record - JSOHelper.apply(oldValues, newRecord.getJsObj()); - // Retrieving changed values - JavaScriptObject data = request.getData(); - // Apply changes - JSOHelper.apply(data, newRecord.getJsObj()); - return newRecord; - } - }
commit 6d3e8fc6b72f84efa69005497fcbb058528147f6 Author: Joseph Marques joseph@redhat.com Date: Thu Sep 16 03:34:44 2010 -0400
add RPCDataSource method for getting the in-flight edits from the DSRequest
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java index cb2768f..dd5e77b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.List; import java.util.Map;
+import com.google.gwt.core.client.JavaScriptObject; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSource; @@ -30,6 +31,7 @@ import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol; +import com.smartgwt.client.util.JSOHelper; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.util.PageControl; @@ -224,4 +226,18 @@ public abstract class RPCDataSource<T> extends DataSource { addField(field); } } + + public ListGridRecord getEditedRecord(DSRequest request) { + // Retrieving values before edit + JavaScriptObject oldValues = request.getAttributeAsJavaScriptObject("oldValues"); + // Creating new record for combining old values with changes + ListGridRecord newRecord = new ListGridRecord(); + // Copying properties from old record + JSOHelper.apply(oldValues, newRecord.getJsObj()); + // Retrieving changed values + JavaScriptObject data = request.getData(); + // Apply changes + JSOHelper.apply(data, newRecord.getJsObj()); + return newRecord; + } }
commit a0f4c0d3702eae637735186647aa7090e3911dcf Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 17:42:41 2010 -0400
capture all exception messages from errors in ResourceGroupGWTService
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java index 46c965c..b2ec813 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java @@ -24,9 +24,9 @@ import org.rhq.core.domain.resource.group.GroupDefinition; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; import org.rhq.core.domain.util.PageList; +import org.rhq.core.util.exception.ThrowableUtil; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTService; import org.rhq.enterprise.gui.coregui.server.util.SerialUtility; -import org.rhq.enterprise.server.resource.group.ResourceGroupDeleteException; import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal; import org.rhq.enterprise.server.util.LookupUtil; @@ -69,8 +69,8 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen public void deleteResourceGroups(int[] groupIds) { try { groupManager.deleteResourceGroups(getSessionSubject(), groupIds); - } catch (ResourceGroupDeleteException e) { - throw new RuntimeException(e.getMessage()); + } catch (Throwable t) { + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); } }
@@ -84,7 +84,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(results, "ResourceGroupService.createGroupDefinition"); } catch (Throwable t) { - throw new RuntimeException(t.getMessage()); + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); } }
@@ -92,7 +92,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen try { definitionManager.updateGroupDefinition(getSessionSubject(), groupDefinition); } catch (Throwable t) { - throw new RuntimeException(t.getMessage()); + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); } }
@@ -102,7 +102,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen definitionManager.removeGroupDefinition(getSessionSubject(), nextGroupDefinitionId); } } catch (Throwable t) { - throw new RuntimeException(t.getMessage()); + throw new RuntimeException(ThrowableUtil.getAllMessages(t)); } }
commit b097cf35ac6c674747e0fc951103ff77a9d4ee57 Merge: b589ac3... 14fd401... Author: Heiko W. Rupp hwr@redhat.com Date: Thu Sep 16 09:20:23 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit b589ac31791ea0a77666cc638b7e3afa10d91337 Author: Heiko W. Rupp hwr@redhat.com Date: Thu Sep 16 09:18:45 2010 +0200
Don't spam the agent console if the connection fails.
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java index e3da0aa..737634b 100644 --- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java +++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java @@ -19,6 +19,8 @@
package org.rhq.plugins.mysql;
+import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.MeasurementDataNumeric; @@ -47,6 +49,7 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea
private ResourceContext resourceContext; private Connection connection; + private static final Log log = LogFactory.getLog(MySqlComponent.class);
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception { this.resourceContext = resourceContext; @@ -57,7 +60,7 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea try { this.connection.close(); } catch (SQLException e) { - e.printStackTrace(); + log.warn(e); } }
@@ -67,7 +70,9 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea getConnection().createStatement().executeQuery("select 1"); return AvailabilityType.UP; } catch (SQLException e) { - e.printStackTrace(); + if (log.isDebugEnabled()) { + log.debug("getAvail failed: " + e.getMessage()); + } return AvailabilityType.DOWN; } } @@ -105,7 +110,9 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea this.connection = MySqlDiscoveryComponent.buildConnection(resourceContext.getPluginConfiguration());
} catch (SQLException e) { - e.printStackTrace(); + if (log.isDebugEnabled()) { + log.debug("getAvail failed: " + e.getMessage()); + } } return connection; } @@ -146,9 +153,9 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea } } catch (SQLException ex) { // handle any errors - System.out.println("SQLException: " + ex.getMessage()); - System.out.println("SQLState: " + ex.getSQLState()); - System.out.println("VendorError: " + ex.getErrorCode()); + log.info("SQLException: " + ex.getMessage()); + log.info("SQLState: " + ex.getSQLState()); + log.info("VendorError: " + ex.getErrorCode()); } } }
commit 14fd401a427a68a17cbf7f4e4356d66387b73ef7 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 17:34:02 2010 -0400
start using the gwt service for alert defs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java index f986562..fcb018d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java @@ -26,15 +26,21 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions; import java.util.ArrayList; import java.util.EnumSet;
+import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.resource.composite.ResourceComposite; +import org.rhq.core.domain.resource.composite.ResourcePermission; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/** * @author John Mazzitelli @@ -44,10 +50,12 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView { public static final String CRITERIA_RESOURCE_ID = "resourceId";
private Resource resource; + private ResourcePermission permissions;
- public ResourceAlertDefinitionsView(String locatorId, Resource resource) { + public ResourceAlertDefinitionsView(String locatorId, ResourceComposite resourceComposite) { super(locatorId, "Alert Definitions"); - this.resource = resource; + this.resource = resourceComposite.getResource(); + this.permissions = resourceComposite.getResourcePermission();
// make sure we loaded all the type info we'll need. if one of these is null, either the type // doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask. @@ -87,8 +95,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override protected boolean isAllowedToModifyAlertDefinitions() { - // TODO: see if user can modify alerts on this resource - return true; + return this.permissions.isAlert(); }
@Override @@ -98,39 +105,99 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override protected void enableButtonPressed(ListGridRecord[] selection) { - // TODO Auto-generated method stub - String str = "this is not implemented yet but you selected"; + if (selection.length == 0) { + return; + } + + Integer[] alertDefIds = new Integer[selection.length]; + int i = 0; for (ListGridRecord record : selection) { - str += ": " + record.getAttribute("name"); + Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID); + alertDefIds[i++] = id; } - SC.say(str); + GWTServiceLookup.getAlertDefinitionService().enableAlertDefinitions(alertDefIds, new AsyncCallback<Integer>() { + @Override + public void onSuccess(Integer result) { + CoreGUI.getMessageCenter().notify( + new Message("[" + result + "] alert definitions enabled", Severity.Info)); + ResourceAlertDefinitionsView.this.refresh(); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to enable alert definitions", caught); + } + }); }
@Override protected void disableButtonPressed(ListGridRecord[] selection) { - // TODO Auto-generated method stub - String str = "this is not implemented yet but you selected"; + if (selection.length == 0) { + return; + } + + Integer[] alertDefIds = new Integer[selection.length]; + int i = 0; for (ListGridRecord record : selection) { - str += ": " + record.getAttribute("name"); + Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID); + alertDefIds[i++] = id; } - SC.say(str); + GWTServiceLookup.getAlertDefinitionService().disableAlertDefinitions(alertDefIds, new AsyncCallback<Integer>() { + @Override + public void onSuccess(Integer result) { + CoreGUI.getMessageCenter().notify( + new Message("[" + result + "] alert definitions disabled", Severity.Info)); + ResourceAlertDefinitionsView.this.refresh(); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to disable alert definitions", caught); + } + }); }
@Override protected void deleteButtonPressed(ListGridRecord[] selection) { - // TODO Auto-generated method stub - String str = "this is not implemented yet but you selected"; + if (selection.length == 0) { + return; + } + + Integer[] alertDefIds = new Integer[selection.length]; + int i = 0; for (ListGridRecord record : selection) { - str += ": " + record.getAttribute("name"); + Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID); + alertDefIds[i++] = id; } - SC.say(str); + GWTServiceLookup.getAlertDefinitionService().removeAlertDefinitions(alertDefIds, new AsyncCallback<Integer>() { + @Override + public void onSuccess(Integer result) { + CoreGUI.getMessageCenter().notify( + new Message("[" + result + "] alert definitions deleted", Severity.Info)); + ResourceAlertDefinitionsView.this.refresh(); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to delete alert definitions", caught); + } + }); }
@Override protected void commitAlertDefinition(AlertDefinition alertDefinition) { - System.out.println("=======================================>" + alertDefinition); - // TODO call into server SLSB to store alert def - // AlertDefinitionManagerLocal alertDefinitionManager = LookupUtil.getAlertDefinitionManager(); - // alertDefinitionManager.updateAlertDefinition(subject, alertDef.getId(), alertDef, true); + GWTServiceLookup.getAlertDefinitionService().updateAlertDefinition(alertDefinition.getId(), alertDefinition, + true, new AsyncCallback<AlertDefinition>() { + @Override + public void onSuccess(AlertDefinition result) { + CoreGUI.getMessageCenter().notify(new Message("Alert definition is updated", Severity.Info)); + ResourceAlertDefinitionsView.this.refresh(); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to update alert definition", caught); + } + }); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index e4bb9fd..c9f1104 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -112,7 +112,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary", - "/images/icons/Service_up_16.png"); + "/images/icons/Service_up_16.png"); summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null); summaryDashboard = new SubTab(summaryTab.extendLocatorId("Dashboard"), "Dashboard", null); summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null); @@ -197,10 +197,12 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
this.monitorGraphs.setCanvas(new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource)); this.monitorTables.setCanvas(new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId())); - this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId())); + this.monitorTraits + .setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), resource.getId())); this.monitorAvail.setCanvas(new FullHTMLPane("/rhq/resource/monitor/availabilityHistory-plain.xhtml?id=" + resource.getId())); - this.monitorSched.setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId())); + this.monitorSched + .setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId())); this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId()));
@@ -225,7 +227,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo // 4) user can search alert history by: date alert was fired, alert priority, or alert definition this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" + resource.getId())); - this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("Def"), resource)); + this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("AlertDef"), + resourceComposite)); this.alertDelete.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" + resource.getId()));
@@ -256,12 +259,14 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.resourceComposite)); monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
- inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); + inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets + .contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); ResourceType type = this.resourceComposite.getResource().getResourceType(); inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); - getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); + getTabSet().setTabEnabled(this.configurationTab, + facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT)); } @@ -303,11 +308,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo final Resource resource = resourceComposite.getResource(); ResourceTypeRepository.Cache.getInstance().getResourceTypes( resource.getResourceType().getId(), - EnumSet.of( - ResourceTypeRepository.MetadataType.children, - ResourceTypeRepository.MetadataType.content, - ResourceTypeRepository.MetadataType.operations, - ResourceTypeRepository.MetadataType.measurements, + EnumSet.of(ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.content, + ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.measurements, ResourceTypeRepository.MetadataType.events, ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), new ResourceTypeRepository.TypeLoadedCallback() {
commit 5a56ceb783f95a857fdf174e9d77d598c60344f6 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 17:33:47 2010 -0400
add the lookup method for the new alert def service
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java index 9965430..373f87c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java @@ -36,6 +36,10 @@ public class GWTServiceLookup {
public static final String SESSION_NAME = "RHQ_Sesssion";
+ public static AlertDefinitionGWTServiceAsync getAlertDefinitionService() { + return secure(AlertDefinitionGWTServiceAsync.Util.getInstance()); + } + public static ConfigurationGWTServiceAsync getConfigurationService() { return secure(ConfigurationGWTServiceAsync.Util.getInstance()); } @@ -124,9 +128,6 @@ public class GWTServiceLookup { return secure(ClusterGWTServiceAsync.Util.getInstance()); }
- - - private static <T> T secure(Object sdt) { if (!(sdt instanceof ServiceDefTarget)) return null;
commit 0487a6aa2c203ff991e72ecfeacb235dcf11fb96 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 17:20:04 2010 -0400
add alert def manager gwt service
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml index aa2b040..8db747c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml @@ -48,6 +48,7 @@ <entry-point class='org.rhq.enterprise.gui.coregui.client.SearchGUI'/>
<servlet path="/AlertGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AlertGWTServiceImpl"/> + <servlet path="/AlertDefinitionGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl"/> <servlet path="/AuthorizationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AuthorizationGWTServiceImpl"/> <servlet path="/AvailabilityGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.AvailabilityGWTServiceImpl"/> <servlet path="/BundleGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.BundleGWTServiceImpl"/> diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java new file mode 100644 index 0000000..e309eea --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java @@ -0,0 +1,34 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.gwt; + +import com.google.gwt.user.client.rpc.RemoteService; + +import org.rhq.core.domain.alert.AlertDefinition; + +public interface AlertDefinitionGWTService extends RemoteService { + AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition, + boolean updateInternals) throws Exception; + + int enableAlertDefinitions(Integer[] alertDefinitionIds) throws Exception; + + int disableAlertDefinitions(Integer[] alertDefinitionIds) throws Exception; + + int removeAlertDefinitions(Integer[] alertDefinitionIds) throws Exception; +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java new file mode 100644 index 0000000..169b758 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java @@ -0,0 +1,70 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.server.gwt; + +import org.rhq.core.domain.alert.AlertDefinition; +import org.rhq.core.util.exception.ThrowableUtil; +import org.rhq.enterprise.gui.coregui.client.gwt.AlertDefinitionGWTService; +import org.rhq.enterprise.gui.coregui.server.util.SerialUtility; +import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal; +import org.rhq.enterprise.server.util.LookupUtil; + +public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implements AlertDefinitionGWTService { + private static final long serialVersionUID = 1L; + + private AlertDefinitionManagerLocal alertDefManager = LookupUtil.getAlertDefinitionManager(); + + public AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition, + boolean updateInternals) throws Exception { + try { + AlertDefinition results = alertDefManager.updateAlertDefinition(getSessionSubject(), alertDefinitionId, + alertDefinition, updateInternals); + return SerialUtility.prepare(results, "updateAlertDefinition"); + } catch (Exception e) { + throw new RuntimeException(ThrowableUtil.getAllMessages(e)); + } + } + + public int enableAlertDefinitions(Integer[] alertDefinitionIds) throws Exception { + try { + int results = alertDefManager.enableAlertDefinitions(getSessionSubject(), alertDefinitionIds); + return results; + } catch (Exception e) { + throw new RuntimeException(ThrowableUtil.getAllMessages(e)); + } + } + + public int disableAlertDefinitions(Integer[] alertDefinitionIds) throws Exception { + try { + int results = alertDefManager.disableAlertDefinitions(getSessionSubject(), alertDefinitionIds); + return results; + } catch (Exception e) { + throw new RuntimeException(ThrowableUtil.getAllMessages(e)); + } + } + + public int removeAlertDefinitions(Integer[] alertDefinitionIds) throws Exception { + try { + int results = alertDefManager.removeAlertDefinitions(getSessionSubject(), alertDefinitionIds); + return results; + } catch (Exception e) { + throw new RuntimeException(ThrowableUtil.getAllMessages(e)); + } + } +} \ No newline at end of file
commit 695b267b435bfed82b1d2384b618085766950fce Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 17:20:31 2010 -0400
update users datasource to expose factive property
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java index 470b144..0fa21cf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java @@ -97,13 +97,14 @@ public class UsersDataSource extends RPCDataSource<Subject> {
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
+ DataSourceTextField enabled = new DataSourceTextField("factive", "Enabled"); + enabled.setType(FieldType.BOOLEAN); + setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress, - department); + department, enabled); }
public void executeFetch(final DSRequest request, final DSResponse response) { - final long start = System.currentTimeMillis(); - SubjectCriteria criteria = new SubjectCriteria(); criteria.setPageControl(getPageControl(request)); criteria.fetchRoles(true); @@ -228,6 +229,7 @@ public class UsersDataSource extends RPCDataSource<Subject> { to.setDepartment(from.getAttributeAsString("department")); to.setPhoneNumber(from.getAttributeAsString("phoneNumber")); to.setEmailAddress(from.getAttributeAsString("emailAddress")); + to.setFactive(from.getAttributeAsBoolean("factive"));
to.setRoles((Set<Role>) from.getAttributeAsObject("roles")); return to; @@ -243,6 +245,7 @@ public class UsersDataSource extends RPCDataSource<Subject> { to.setAttribute("department", from.getDepartment()); to.setAttribute("phoneNumber", from.getPhoneNumber()); to.setAttribute("emailAddress", from.getEmailAddress()); + to.setAttribute("factive", from.getFactive());
to.setAttribute("roles", from.getRoles());
commit 48805cca6b617fdc1c0f49e5a2b47fcae748b703 Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 17:19:42 2010 -0400
create new users in the 'enabled' state
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java index 279fa33..9ea9467 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java @@ -197,6 +197,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
private void editNewInternal() { subject = new Subject(); + subject.setFactive(true); ListGridRecord r = dataSource.copyValues(subject); editRecord(r);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index 6bafa7b..328794e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -19,7 +19,9 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
import java.util.LinkedHashMap; +import java.util.Set;
+import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.form.fields.ButtonItem; @@ -33,12 +35,12 @@ import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; import org.rhq.core.domain.resource.group.GroupDefinition; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; @@ -71,6 +73,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private boolean formBuilt = false;
+ private GroupDefinitionDataSource dataSource; + public SingleGroupDefinitionView(String locatorId) { this(locatorId, null); } @@ -78,6 +82,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm public SingleGroupDefinitionView(String locatorId, GroupDefinition groupDefinition) { super(locatorId);
+ this.dataSource = GroupDefinitionDataSource.getInstance(); + setPadding(10); setOverflow(Overflow.AUTO);
@@ -165,6 +171,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm expressionStatic.show(); recalculationIntervalStatic.show();
+ viewId.getBreadcrumbs().get(0).setDisplayName("Viewing '" + nameStatic.getValue().toString() + "'"); + markForRedraw(); }
@@ -251,8 +259,9 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
recalculationInterval = new SpinnerItem("recalculationInterval", "Recalculation Interval"); recalculationInterval.setWrapTitle(false); + recalculationInterval.setMin(0); recalculationInterval.setDefaultValue(0); - recalculationIntervalStatic = new StaticTextItem("recalculationInterval", "Recalculation Interval"); + recalculationIntervalStatic = new StaticTextItem("recalculationIntervalStatic", "Recalculation Interval");
templateSelector = new SelectItem(); templateSelector.setValueMap(getTemplates()); @@ -314,26 +323,35 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm return results.toString(); }
- private void lookupDetails(final int groupDefinitionId) { + private void lookupDetails(final int groupDefinitionId, final boolean hasEditPermission) { ResourceGroupDefinitionCriteria criteria = new ResourceGroupDefinitionCriteria(); criteria.addFilterId(groupDefinitionId);
if (groupDefinitionId == 0) { GroupDefinition newGroupDefinition = new GroupDefinition(); setGroupDefinition(newGroupDefinition); - switchToEditMode(); + if (hasEditPermission) { + switchToEditMode(); + } else { + switchToViewMode(); + } } else { GWTServiceLookup.getResourceGroupService().findGroupDefinitionsByCriteria(criteria, new AsyncCallback<PageList<GroupDefinition>>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError( "Failure loading group definition[id=" + groupDefinitionId + "]", caught); + History.back(); }
public void onSuccess(PageList<GroupDefinition> result) { GroupDefinition existingGroupDefinition = result.get(0); setGroupDefinition(existingGroupDefinition); - switchToEditMode(); + if (hasEditPermission) { + switchToEditMode(); + } else { + switchToViewMode(); + } } }); } @@ -343,7 +361,21 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm public void renderView(ViewPath viewPath) { groupDefinitionId = viewPath.getCurrentAsInt(); viewId = viewPath.getCurrent(); - lookupDetails(groupDefinitionId); + GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new AsyncCallback<Set<Permission>>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError( + "Could not determine whether user had MANAGE_INVENTORY permission, defaulting to view-only mode", + caught); + lookupDetails(groupDefinitionId, false); + } + + @Override + public void onSuccess(Set<Permission> result) { + lookupDetails(groupDefinitionId, result.contains(Permission.MANAGE_INVENTORY)); + } + }); + }
}
commit dc486e85b51d9487f4594d96b3eaf371fdd5d548 Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 15:54:18 2010 -0400
use singleton pattern for GroupDefinitionDataSource
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java index 8d9fba7..c373dd7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java @@ -43,7 +43,16 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
- public GroupDefinitionDataSource() { + private static GroupDefinitionDataSource INSTANCE; + + public static GroupDefinitionDataSource getInstance() { + if (INSTANCE == null) { + INSTANCE = new GroupDefinitionDataSource(); + } + return INSTANCE; + } + + private GroupDefinitionDataSource() { super();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java index ce31dd5..d6d78e5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java @@ -45,7 +45,7 @@ public class GroupDefinitionListView extends TableSection {
setHeaderIcon(headerIcon);
- setDataSource(new GroupDefinitionDataSource()); + setDataSource(GroupDefinitionDataSource.getInstance()); }
@Override
commit bd7459d658837d7a5525519def8ec2cb33a990a8 Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 15:53:48 2010 -0400
instead of explicitly going to the master view, go backwards in the history
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index d96880d..6bafa7b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -188,8 +188,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm @Override public void onSuccess(GroupDefinition result) { CoreGUI.getErrorHandler().handleError("Successfully created group definition '" + name + "'"); - String listViewLink = LinkManager.getHubGroupDefinitionsLink(); - CoreGUI.goToView(listViewLink.substring(1)); + History.back(); } }); } else { @@ -203,8 +202,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm @Override public void onSuccess(Void result) { CoreGUI.getErrorHandler().handleError("Successfully saved group definition '" + name + "'"); - String listViewLink = LinkManager.getHubGroupDefinitionsLink(); - CoreGUI.goToView(listViewLink.substring(1)); + History.back(); } }); }
commit c01f40557f67bb7ed93e746a8196e453fca34a6f Merge: 0367592... b8d2720... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 15 16:12:35 2010 -0400
Merge branch 'master' into master-jay
commit 03675928109b9eb3cfa398401db4c6a8dfbbdeb6 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 15 16:09:30 2010 -0400
take away the empty property setting, the pom no defines the empty default
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA.launch b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA.launch index a523723..6f5b7c2 100644 --- a/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA.launch +++ b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA.launch @@ -6,6 +6,6 @@ <listEntry value="org.eclipse.ui.externaltools.launchGroup"/> </listAttribute> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true gwt:debug -DcoreGuiParams="/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true gwt:debug"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/enterprise/gui/coregui}"/> </launchConfiguration>
commit b8d27202c55b4ebc0285562df1c7ce7b1adb32fc Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 15:59:15 2010 -0400
try to clean up the utility that formats the alert condition strings. make sure its more easily i18n'able for later
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java index 2554746..098e92a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java @@ -26,31 +26,134 @@ import org.rhq.core.domain.alert.Alert; import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertConditionCategory; import org.rhq.core.domain.alert.AlertDefinition; -import org.rhq.core.domain.measurement.MeasurementBaseline; import org.rhq.core.domain.measurement.MeasurementConverterClient; -import org.rhq.core.domain.measurement.MeasurementSchedule; import org.rhq.core.domain.measurement.MeasurementUnits; -import org.rhq.core.domain.measurement.util.MeasurementConversionException; - -import java.util.ArrayList; -import java.util.List;
/** * The methods in this class are ported from AlertDefUtil from portal-war and MeasurementFormatter from * server-jar. * * @author Ian Springer + * @author John Mazzitelli */ public class AlertFormatUtility { - private static final String BASELINE_OPT_MEAN = "mean"; - private static final String BASELINE_OPT_MIN = "min"; - private static final String BASELINE_OPT_MAX = "max"; + private AlertFormatUtility() { + } + + public static String formatAlertConditionForDisplay(AlertCondition condition) { + StringBuilder str = new StringBuilder(); + + AlertConditionCategory category = condition.getCategory(); + switch (category) { + case AVAILABILITY: { + str.append("Availability Change"); + str.append(" ["); + str.append("Going").append(' '); // to reinforce this is on the state transition + str.append(condition.getOption()); + str.append("]"); + break; + } + case THRESHOLD: { + str.append("Metric Value Exceeds Threshold"); + str.append(" ["); + str.append(condition.getName()); + str.append(" "); + str.append(condition.getComparator()); + str.append(" "); + double value = condition.getThreshold(); + MeasurementUnits units = condition.getMeasurementDefinition().getUnits(); + String formatted = MeasurementConverterClient.format(value, units, true); + str.append(formatted); + str.append("]"); + break; + } + case BASELINE: { + str.append("Metric Value Exceeds Baseline"); + str.append(" ["); + str.append(condition.getName()); + str.append(" "); + str.append(condition.getComparator()); + str.append(" "); + + double value = condition.getThreshold(); + MeasurementUnits units = MeasurementUnits.PERCENTAGE; + String formatted = MeasurementConverterClient.format(value, units, true); + str.append(formatted);
- private static final String MEASUREMENT_BASELINE_MIN_TEXT = "Min Value"; - private static final String MEASUREMENT_BASELINE_MEAN_TEXT = "Baseline Value"; - private static final String MEASUREMENT_BASELINE_MAX_TEXT = "Max Value"; + str.append(" ").append("of").append(" "); + str.append(condition.getOption()); + str.append("]"); + break; + } + case CHANGE: { + str.append("Metric Value Change"); + str.append(" ["); + str.append(condition.getName()); + str.append("]"); + break; + } + case TRAIT: { + str.append("Trait Change"); + str.append(" ["); + str.append(condition.getName()); + str.append("]"); + break; + } + case CONTROL: { + str.append("Operation Execution"); + str.append(" ["); + str.append(condition.getName()); + str.append("] "); + str.append("with result status"); + str.append(" ["); + str.append(condition.getOption()); + str.append("]"); + break; + } + case RESOURCE_CONFIG: { + str.append("Resource Configuration Change"); + break; + } + case EVENT: { + str.append("Event Detection"); + str.append(" ["); + str.append(condition.getName()); + str.append("]"); + if (condition.getOption() != null && condition.getOption().length() > 0) { + str.append(" "); + str.append("matching"); + str.append(" ["); + str.append(condition.getOption()); + str.append("]"); + } + break; + } + default: { + str.append("BAD CATEGORY: ").append(category.name()); + break; + } + } + return str.toString(); + } + + public static String getAlertRecoveryInfo(Alert alert) { + String recoveryInfo; + AlertDefinition recoveryAlertDefinition = alert.getRecoveryAlertDefinition(); + if (recoveryAlertDefinition != null && recoveryAlertDefinition.getId() != 0) { + int resourceId = alert.getAlertDefinition().getResource().getId(); + recoveryInfo = "Triggered '<a href="/alerts/Config.do?mode=viewRoles&id=" + resourceId + "&ad=" + + recoveryAlertDefinition.getId() + "">" + recoveryAlertDefinition.getName() + + "</a>' to be re-enabled."; + } else if (alert.getWillRecover()) { + recoveryInfo = "This alert caused its alert definition to be disabled."; + } else { + recoveryInfo = "N/A"; + } + return recoveryInfo; + } + + /* THIS IS THE OLD CODE - IT HAS LOTS OF TODOs AND DIDN'T FULLY WORK
- @SuppressWarnings("deprecation") public static String formatAlertConditionForDisplay(AlertCondition condition) { AlertConditionCategory category = condition.getCategory();
@@ -60,11 +163,11 @@ public class AlertFormatUtility { if (category == AlertConditionCategory.CONTROL) { try { String operationName = condition.getName(); - /*Integer resourceTypeId = condition.getAlertDefinition().getResource().getResourceType().getId(); - OperationManagerLocal operationManager = LookupUtil.getOperationManager(); - OperationDefinition definition = operationManager.getOperationDefinitionByResourceTypeAndName( - resourceTypeId, operationName, false); - String operationDisplayName = definition.getDisplayName();*/ + //Integer resourceTypeId = condition.getAlertDefinition().getResource().getResourceType().getId(); + //OperationManagerLocal operationManager = LookupUtil.getOperationManager(); + //OperationDefinition definition = operationManager.getOperationDefinitionByResourceTypeAndName( + // resourceTypeId, operationName, false); + //String operationDisplayName = definition.getDisplayName(); textValue.append(operationName).append(' '); } catch (Exception e) { textValue.append(condition.getName()).append(' '); @@ -124,22 +227,15 @@ public class AlertFormatUtility { return textValue.toString(); }
- public static String getAlertRecoveryInfo(Alert alert) { - String recoveryInfo; - AlertDefinition recoveryAlertDefinition = alert.getRecoveryAlertDefinition(); - if (recoveryAlertDefinition != null && recoveryAlertDefinition.getId() != 0) { - int resourceId = alert.getAlertDefinition().getResource().getId(); - recoveryInfo = "Triggered '<a href="/alerts/Config.do?mode=viewRoles&id=" + resourceId + "&ad=" + recoveryAlertDefinition.getId() - + "">" + recoveryAlertDefinition.getName() + "</a>' to be re-enabled."; - } else if (alert.getWillRecover()) { - recoveryInfo = "This alert caused its alert definition to be disabled."; - } else { - recoveryInfo = "N/A"; - } - return recoveryInfo; - } - private static String getBaselineText(String baselineOption, MeasurementSchedule schedule) { + final String BASELINE_OPT_MEAN = "mean"; + final String BASELINE_OPT_MIN = "min"; + final String BASELINE_OPT_MAX = "max"; + + final String MEASUREMENT_BASELINE_MIN_TEXT = "Min Value"; + final String MEASUREMENT_BASELINE_MEAN_TEXT = "Baseline Value"; + final String MEASUREMENT_BASELINE_MAX_TEXT = "Max Value"; + if ((null != schedule) && (null != schedule.getBaseline())) { MeasurementBaseline baseline = schedule.getBaseline();
@@ -165,10 +261,9 @@ public class AlertFormatUtility { return lookupText; } } - /* - * will need a fall-through here because the value was null; this can happen when the user requests to view - * the formatted baseline before the first time it has been calculated - */ + + // will need a fall-through here because the value was null; this can happen when the user requests to view + // the formatted baseline before the first time it has been calculated }
// here is the fall-through @@ -181,6 +276,5 @@ public class AlertFormatUtility { } }
- private AlertFormatUtility() { - } + */ }
commit 450baca8071b03cdc9ad9ed5bd0647554a3c53f3 Author: Ian Springer ian.springer@redhat.com Date: Wed Sep 15 15:14:14 2010 -0400
fix group bookmarking
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java index 8f0f711..aa2ee61 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java @@ -29,6 +29,7 @@ import java.util.Set;
import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.Record; import com.smartgwt.client.types.SelectionStyle; import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler; import com.smartgwt.client.widgets.grid.events.SelectionEvent; @@ -100,13 +101,20 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { @Override public void onSelectionChanged(SelectionEvent selectionEvent) { if (selectionEvent.getState()) { - ClusterKey key = (ClusterKey) selectionEvent.getRecord().getAttributeAsObject("key"); + Record selectedNode = selectionEvent.getRecord(); + System.out.println("Node selected in tree: " + selectedNode); + ClusterKey key = (ClusterKey) selectedNode.getAttributeAsObject("key"); if (key == null) { - // selected the root group - History.newItem("ResourceGroup/" + selectionEvent.getRecord().getAttribute("id")); + // The root group was selected. + String groupId = selectedNode.getAttribute("id"); + //System.out.println("Selecting group [" + groupId + "]..."); + String viewPath = "ResourceGroup/" + groupId; + String currentViewPath = History.getToken(); + if (!currentViewPath.startsWith(viewPath)) { + CoreGUI.goToView(viewPath); + } } else { - System.out.println("Select group: " + key); - + //System.out.println("Selecting cluster group [" + key + "]..."); selectClusterGroup(key); } } @@ -160,7 +168,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView { } });
- }
@@ -232,7 +239,8 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
@Override public void onSuccess(ResourceGroup result) { - History.newItem("ResourceGroup/" + result.getId()); + int groupId = result.getId(); + History.newItem("ResourceGroup/" + groupId); } });
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java index 7fae500..ec96874 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java @@ -21,10 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail; import com.smartgwt.client.widgets.Canvas;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView; -import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/** @@ -33,11 +30,9 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; public class ResourceTopView extends LocatableHLayout implements BookmarkableView {
private Canvas contentCanvas; - private ResourceTreeView treeView; private ResourceDetailView detailView = new ResourceDetailView(extendLocatorId("Detail"));
- private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
public ResourceTopView(String locatorId) { super(locatorId); @@ -54,13 +49,16 @@ public class ResourceTopView extends LocatableHLayout implements BookmarkableVie setContent(detailView); }
+ public void setContent(Canvas newContent) { - if (contentCanvas.getChildren().length > 0) - contentCanvas.getChildren()[0].destroy(); - contentCanvas.addChild(newContent); - contentCanvas.markForRedraw(); + for (Canvas child : this.contentCanvas.getChildren()) { + child.destroy(); + } + this.contentCanvas.addChild(newContent); + this.contentCanvas.markForRedraw(); }
+ public void renderView(ViewPath viewPath) { this.treeView.renderView(viewPath); this.detailView.renderView(viewPath);
commit fbbdb7e785d6acf996432c38cfeeab05db8f4236 Merge: bee88fc... d20fd07... Author: Ian Springer ian.springer@redhat.com Date: Wed Sep 15 15:06:16 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit bee88fcb8d8ef26c881c1ba9f28149858d6cd7a6 Author: Ian Springer ian.springer@redhat.com Date: Wed Sep 15 15:00:30 2010 -0400
fix going to bookmark via browser for subviews of the Inventory view that have details (e.g. http://localhost:7080/coregui/CoreGUI.html?gwt.codesvr=127.0.0.1:9997#Invent...)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java index a205584..ac0281c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java @@ -64,10 +64,11 @@ public class ResourceGroupTopView extends LocatableHLayout implements Bookmarkab
public void setContent(Canvas newContent) { - if (contentCanvas.getChildren().length > 0) - contentCanvas.getChildren()[0].destroy(); - contentCanvas.addChild(newContent); - contentCanvas.markForRedraw(); + for (Canvas child : this.contentCanvas.getChildren()) { + child.destroy(); + } + this.contentCanvas.addChild(newContent); + this.contentCanvas.markForRedraw(); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index c31881c..faa406e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -19,6 +19,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource;
import java.util.LinkedHashMap; +import java.util.Map;
import com.google.gwt.user.client.History; import com.smartgwt.client.data.Criteria; @@ -77,7 +78,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
private Canvas contentCanvas; private Canvas currentContent; - private LinkedHashMap<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>(); + private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>();
private SectionStack sectionStack;
@@ -105,18 +106,23 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView buildResourcesSection(); buildGroupsSection();
- for (final String name : treeGrids.keySet()) { - TreeGrid grid = treeGrids.get(name); + for (final String sectionName : treeGrids.keySet()) { + TreeGrid grid = treeGrids.get(sectionName);
grid.addSelectionChangedHandler(new SelectionChangedHandler() { public void onSelectionChanged(SelectionEvent selectionEvent) { if (selectionEvent.getState()) { - CoreGUI.goToView("Inventory/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); + String pageName = selectionEvent.getRecord().getAttribute("name"); + String viewPath = "Inventory/" + sectionName + "/" + pageName; + String currentViewPath = History.getToken(); + if (!currentViewPath.startsWith(viewPath)) { + CoreGUI.goToView(viewPath); + } } } });
- SectionStackSection section = new SectionStackSection(name); + SectionStackSection section = new SectionStackSection(sectionName); section.setExpanded(true); section.addItem(grid);
@@ -196,15 +202,11 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView }
public void setContent(Canvas newContent) { - - if (contentCanvas.getChildren().length > 0) { - for (Canvas child : contentCanvas.getChildren()) { - child.destroy(); - } + for (Canvas child : this.contentCanvas.getChildren()) { + child.destroy(); } - - contentCanvas.addChild(newContent); - contentCanvas.markForRedraw(); + this.contentCanvas.addChild(newContent); + this.contentCanvas.markForRedraw(); this.currentContent = newContent; }
@@ -288,22 +290,19 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView }
public void renderView(ViewPath viewPath) { - if (!viewPath.isCurrent(currentSectionViewId) || !viewPath.isNext(currentPageViewId)) { - if (viewPath.isEnd()) { - // Display default view - History.newItem("Inventory/Resources/Platforms"); + // i.e. "Inventory" - display default view + History.newItem("Inventory/Resources/Platforms", false); } else { - + // e.g. Inventory/Administration" renderContentView(viewPath); } } else { if (this.currentContent instanceof BookmarkableView) { ((BookmarkableView) this.currentContent).renderView(viewPath.next().next()); } - } - } + }
commit d20fd07a539d5e2d420144014c72a4cc826556d6 Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 15:05:20 2010 -0400
further work for creating new group definitions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java index b2cbadb..c4a4bca 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java @@ -51,4 +51,6 @@ public interface ResourceGroupGWTService extends RemoteService { void updateGroupDefinition(GroupDefinition groupDefinition);
void deleteGroupDefinitions(int[] groupDefinitionIds); + + GroupDefinition createGroupDefinition(GroupDefinition groupDefinition); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index e5885f4..d96880d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -22,12 +22,12 @@ import java.util.LinkedHashMap;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.Overflow; -import com.smartgwt.client.widgets.form.fields.RadioGroupItem; +import com.smartgwt.client.widgets.form.fields.ButtonItem; +import com.smartgwt.client.widgets.form.fields.CheckboxItem; import com.smartgwt.client.widgets.form.fields.ResetItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.SpinnerItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; -import com.smartgwt.client.widgets.form.fields.SubmitItem; import com.smartgwt.client.widgets.form.fields.TextAreaItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; @@ -42,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.FormUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -57,7 +58,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
private TextItem name; private TextAreaItem description; - private RadioGroupItem recursive; + private CheckboxItem recursive; private SelectItem templateSelector; private TextAreaItem expression; private SpinnerItem recalculationInterval; @@ -106,13 +107,12 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm expression.setValue(groupDefinition.getExpression()); expressionStatic.setValue(groupDefinition.getExpression());
- SubmitItem saveButton = new SubmitItem("save", "Save"); + ButtonItem saveButton = new ButtonItem("save", "Save"); ResetItem resetButton = new ResetItem("reset", "Reset");
saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { - save(); - System.out.println("Save is done"); + createOrUpdate(); } });
@@ -168,28 +168,46 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm markForRedraw(); }
- public void save() { - groupDefinition.setName(name.getValue().toString()); - groupDefinition.setDescription(description.getValue().toString()); + public void createOrUpdate() { + groupDefinition.setName(FormUtility.getStringSafely(name)); + groupDefinition.setDescription(FormUtility.getStringSafely(description)); groupDefinition.setRecursive("Yes".equals(recursive.getValue())); - groupDefinition.setExpression(expression.getValue().toString()); - groupDefinition.setRecalculationInterval(Long.valueOf(recalculationInterval.getValue().toString())); - - GWTServiceLookup.getResourceGroupService().updateGroupDefinition(groupDefinition, new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failure saving group definition[id=" + groupDefinitionId + "]", - caught); - } + groupDefinition.setExpression(FormUtility.getStringSafely(expression)); + groupDefinition.setRecalculationInterval(Long.valueOf(FormUtility.getStringSafely(recalculationInterval, "0")));
- @Override - public void onSuccess(Void result) { - CoreGUI.getErrorHandler().handleError( - "Successfully saved group definition[id=" + groupDefinitionId + "]"); - String listViewLink = LinkManager.getHubGroupDefinitionsLink(); - CoreGUI.goToView(listViewLink.substring(1)); - } - }); + final String name = groupDefinition.getName(); + if (groupDefinitionId == 0) { + GWTServiceLookup.getResourceGroupService().createGroupDefinition(groupDefinition, + new AsyncCallback<GroupDefinition>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failure to create group definition '" + name + "'", + caught); + } + + @Override + public void onSuccess(GroupDefinition result) { + CoreGUI.getErrorHandler().handleError("Successfully created group definition '" + name + "'"); + String listViewLink = LinkManager.getHubGroupDefinitionsLink(); + CoreGUI.goToView(listViewLink.substring(1)); + } + }); + } else { + GWTServiceLookup.getResourceGroupService().updateGroupDefinition(groupDefinition, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failure saving group definition '" + name + "'", caught); + } + + @Override + public void onSuccess(Void result) { + CoreGUI.getErrorHandler().handleError("Successfully saved group definition '" + name + "'"); + String listViewLink = LinkManager.getHubGroupDefinitionsLink(); + CoreGUI.goToView(listViewLink.substring(1)); + } + }); + } }
public void clearFormValues() { @@ -222,7 +240,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm description.setDefaultValue(""); descriptionStatic = new StaticTextItem("descriptionStatic", "Description");
- recursive = new RadioGroupItem("recursive", "Recursive"); + recursive = new CheckboxItem("recursive", "Recursive"); recursive.setValueMap("Yes", "No"); recursive.setDefaultValue("Yes"); recursiveStatic = new StaticTextItem("recursiveStatic", "Recursive"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java index ccb4db5..46c965c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java @@ -78,6 +78,16 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen groupManager.updateResourceGroup(getSessionSubject(), group); }
+ public GroupDefinition createGroupDefinition(GroupDefinition groupDefinition) { + try { + GroupDefinition results = definitionManager.createGroupDefinition(getSessionSubject(), groupDefinition); + + return SerialUtility.prepare(results, "ResourceGroupService.createGroupDefinition"); + } catch (Throwable t) { + throw new RuntimeException(t.getMessage()); + } + } + public void updateGroupDefinition(GroupDefinition groupDefinition) { try { definitionManager.updateGroupDefinition(getSessionSubject(), groupDefinition);
commit 733a2e6f9da1ae93ac22ea8e40ccce5ec26139b9 Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 15:04:22 2010 -0400
form utility class
* initial functions will safely get the string value of a form item
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java new file mode 100644 index 0000000..9f118a7 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java @@ -0,0 +1,46 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.util; + +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.FormItem; + +/** + * A collection of utility methods for working with SmartGWT {@link DynamicForm}s. + * + * @author Joseph Marques + */ +public class FormUtility { + private FormUtility() { + // statuc utility class only + } + + public static String getStringSafely(FormItem item) { + return getStringSafely(item, null); + } + + public static String getStringSafely(FormItem item, String defaultValue) { + if (item.getValue() == null) { + return defaultValue; + } else { + return item.getValue().toString(); + } + } + +}
commit 96f824472b703f28a0c927af4fd06fce94d2b3db Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 13:57:53 2010 -0400
add ability to remove existing group definitions from the list view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java index d6a638a..b2cbadb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java @@ -50,4 +50,5 @@ public interface ResourceGroupGWTService extends RemoteService {
void updateGroupDefinition(GroupDefinition groupDefinition);
+ void deleteGroupDefinitions(int[] groupDefinitionIds); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java index 1a1d32f..ce31dd5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java @@ -18,14 +18,21 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
+import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync; +import org.rhq.enterprise.gui.coregui.client.util.TableUtility; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/** * @author Greg Hinkle @@ -61,6 +68,27 @@ public class GroupDefinitionListView extends TableSection { newDetails(); } }); + + addTableAction(extendLocatorId("Delete"), "Delete", Table.SelectionEnablement.ANY, null, new TableAction() { + public void executeAction(ListGridRecord[] selection) { + final int[] groupDefinitionIds = TableUtility.getIds(selection); + ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(); + groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() { + @Override + public void onSuccess(Void result) { + CoreGUI.getMessageCenter().notify( + new Message("Successfully deleted " + groupDefinitionIds.length + " group definitions", + Severity.Info)); + GroupDefinitionListView.this.refresh(); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to delete selected group definitions", caught); + } + }); + } + }); }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java index 4b59caf..ccb4db5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java @@ -86,4 +86,14 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen } }
+ public void deleteGroupDefinitions(int[] groupDefinitionIds) { + try { + for (int nextGroupDefinitionId : groupDefinitionIds) { + definitionManager.removeGroupDefinition(getSessionSubject(), nextGroupDefinitionId); + } + } catch (Throwable t) { + throw new RuntimeException(t.getMessage()); + } + } + } \ No newline at end of file
commit af400930f6873b0e3d7ff6ec7fb8b1672e7cf580 Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 13:57:15 2010 -0400
update ResourceSearchView to use new TableUtility id extract method
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java index a77a9d9..9817819 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java @@ -44,6 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; +import org.rhq.enterprise.gui.coregui.client.util.TableUtility; import org.rhq.enterprise.gui.coregui.client.util.message.Message; import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -130,12 +131,8 @@ public class ResourceSearchView extends Table {
addTableAction(extendLocatorId("Uninventory"), "Uninventory", Table.SelectionEnablement.ANY, "Are you sure you want to uninventory # resources?", new TableAction() { - public void executeAction(ListGridRecord[] selections) { - int[] resourceIds = new int[selections.length]; - int index = 0; - for (ListGridRecord selection : selections) { - resourceIds[index++] = selection.getAttributeAsInt("id"); - } + public void executeAction(ListGridRecord[] selection) { + int[] resourceIds = TableUtility.getIds(selection); ResourceGWTServiceAsync resourceManager = GWTServiceLookup.getResourceService();
resourceManager.uninventoryResources(resourceIds, new AsyncCallback<List<Integer>>() {
commit 64a808768f65ce9deab73407e25ed8dd4cb4f12a Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 13:56:32 2010 -0400
add utility to extract primary keys of selected list grid records
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TableUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TableUtility.java new file mode 100644 index 0000000..1cb0b2c --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TableUtility.java @@ -0,0 +1,44 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.util; + +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.enterprise.gui.coregui.client.components.table.Table; + +/** + * A collection of utility methods for working with {@link Table}s. + * + * @author Joseph Marques + */ +public class TableUtility { + private TableUtility() { + // statuc utility class only + } + + public static int[] getIds(ListGridRecord[] selections) { + int[] ids = new int[selections.length]; + int index = 0; + for (ListGridRecord selection : selections) { + ids[index++] = selection.getAttributeAsInt("id"); + } + return ids; + } + +}
commit fbe80740ce2ed5b6eb2e392fbc52baccd87b4c63 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 13:50:58 2010 -0400
pass in empty param
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode.launch b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode.launch index f1b94d5..cd53875 100644 --- a/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode.launch +++ b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode.launch @@ -6,6 +6,6 @@ <listEntry value="org.eclipse.ui.externaltools.launchGroup"/> </listAttribute> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true gwt:run"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true gwt:run -DcoreGuiParams="/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/enterprise/gui/coregui}"/> </launchConfiguration>
commit 381de84c3db865e761a48acea6cba0f7787e6f2a Merge: 09a697d... bf86450... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 15 13:43:56 2010 -0400
Merge branch 'master' into master-jay
commit 09a697d7b10f12837cd5e752b0e7601ae91d5922 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 15 13:42:40 2010 -0400
initialize coreGuiParams to ""
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index 4e9532b..950ce71 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -30,6 +30,8 @@ in your settings.xml --> <gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M</gwt-plugin.extraJvmArgs> <gwt-plugin.localWorkers>2</gwt-plugin.localWorkers> + + <coreGuiParams></coreGuiParams> </properties>
commit bf86450cb49576b96ec4065380e52f297eedcd24 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 13:30:02 2010 -0400
pass in an empty params string prop
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA.launch b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA.launch index 6f5b7c2..a523723 100644 --- a/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA.launch +++ b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA.launch @@ -6,6 +6,6 @@ <listEntry value="org.eclipse.ui.externaltools.launchGroup"/> </listAttribute> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true gwt:debug"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true gwt:debug -DcoreGuiParams="/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/enterprise/gui/coregui}"/> </launchConfiguration>
commit d818ed9126d252fcec040ef57388c03601c51e37 Author: Joseph Marques joseph@redhat.com Date: Wed Sep 15 13:16:59 2010 -0400
start of CRUD functionality for group definitions
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/GroupDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/GroupDefinition.java index 48e35cd..42ff182 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/GroupDefinition.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/GroupDefinition.java @@ -131,7 +131,7 @@ public class GroupDefinition implements Serializable { private Set<ResourceGroup> managedResourceGroups;
/* no-arg constructor required by EJB spec */ - protected GroupDefinition() { + public GroupDefinition() { }
public GroupDefinition(String name) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java index b648f57..0df613d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java @@ -132,7 +132,11 @@ public class LinkManager { }
public static String getHubGroupDefinitionsLink() { - return "/rhq/definition/group/list.xhtml"; + if (GWT) { + return "#Inventory/Groups/DynaGroup Manager"; + } else { + return "/rhq/definition/group/list.xhtml"; + } }
public static String getHubNewGroupLink() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java index ff3be5b..d6a638a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java @@ -48,4 +48,6 @@ public interface ResourceGroupGWTService extends RemoteService {
void updateResourceGroup(ResourceGroup group);
+ void updateGroupDefinition(GroupDefinition groupDefinition); + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java index 308f5f5..8d9fba7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java @@ -18,14 +18,6 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
-import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; -import org.rhq.core.domain.resource.group.GroupDefinition; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; - import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; @@ -35,15 +27,22 @@ import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.rpc.RPCResponse; import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; +import org.rhq.core.domain.resource.group.GroupDefinition; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync; +import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; + /** * @author Greg Hinkle + * @author Joseph Marques */ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
- private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
- public GroupDefinitionDataSource() { super();
@@ -54,16 +53,10 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> { DataSourceTextField nameField = new DataSourceTextField("name", "Name"); DataSourceTextField descriptionField = new DataSourceTextField("description", "Description"); DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression"); - DataSourceTextField recalculationIntervalField = new DataSourceTextField("recalculationInterval", "Recalculation Interval"); - DataSourceTextField modifiedTimeField = new DataSourceTextField("modifiedTime", "Modified Time"); - DataSourceTextField createdTimeField = new DataSourceTextField("createdTime", "Created Time"); - DataSourceTextField lastCalculationTimeField = new DataSourceTextField("lastCalculationTime", "Last Calculation Time"); - DataSourceTextField nextCalculationTimeField = new DataSourceTextField("nextCalculationTime", "Next Calculation Time"); -// DataSourceTextField managedResourceGroupsField = new DataSourceTextField("managedResourceGroups", "Managed Resource Groups"); + DataSourceTextField nextCalculationTimeField = new DataSourceTextField("nextCalculationTime", + "Next Calculation Time");
- - setFields(idDataField, nameField, descriptionField, expressionField, recalculationIntervalField, - modifiedTimeField, createdTimeField, lastCalculationTimeField, nextCalculationTimeField); + setFields(idDataField, nameField, descriptionField, expressionField, nextCalculationTimeField);
}
@@ -75,23 +68,22 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> { groupService.findGroupDefinitionsByCriteria(criteria, new AsyncCallback<PageList<GroupDefinition>>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Failed to load group definitions", caught); + response.setStatus(RPCResponse.STATUS_FAILURE); + processResponse(request.getRequestId(), response); }
public void onSuccess(PageList<GroupDefinition> result) { - - response.setStatus(RPCResponse.STATUS_SUCCESS); response.setData(buildRecords(result)); response.setTotalRows(result.getTotalSize()); processResponse(request.getRequestId(), response); - } }); }
@Override public GroupDefinition copyValues(ListGridRecord from) { - return null; // TODO: Implement this method. + return null; // TODO: Implement this method. }
@Override @@ -106,7 +98,7 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> { record.setAttribute("createdTime", from.getCreatedTime()); record.setAttribute("lastCalculationTime", from.getLastCalculationTime()); record.setAttribute("nextCalculationTime", from.getNextCalculationTime()); -// record.setAttribute("managedResourceGroups", from.getManagedResourceGroups()); + // record.setAttribute("managedResourceGroups", from.getManagedResourceGroups());
return record; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java index dc81946..1a1d32f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java @@ -18,44 +18,56 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
-import com.smartgwt.client.types.ListGridFieldType; -import com.smartgwt.client.types.SelectionAppearance; -import com.smartgwt.client.types.SelectionStyle; +import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.CellFormatter; -import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; +import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
/** * @author Greg Hinkle + * @author Joseph Marques */ -public class GroupDefinitionListView extends Table { +public class GroupDefinitionListView extends TableSection {
public GroupDefinitionListView(String locatorId, String headerIcon) { super(locatorId, "Group Definitions");
setHeaderIcon(headerIcon);
- final GroupDefinitionDataSource datasource = new GroupDefinitionDataSource(); - setDataSource(datasource); + setDataSource(new GroupDefinitionDataSource()); }
@Override protected void configureTable() { super.configureTable();
- getListGrid().setSelectionType(SelectionStyle.SIMPLE); - getListGrid().setSelectionAppearance(SelectionAppearance.CHECKBOX); + ListGrid grid = getListGrid();
- ListGridField idField = new ListGridField("id", "Id", 55); - idField.setType(ListGridFieldType.INTEGER); - ListGridField nameField = new ListGridField("name", "Name", 250); - nameField.setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { - return "<a href="#ResourceGroupDefinition/" + listGridRecord.getAttribute("id") + "">" + o + "</a>"; + grid.getField("nextCalculationTime").setCellFormatter(new CellFormatter() { + public String format(Object value, ListGridRecord record, int rowNum, int colNum) { + if ("0".equals(value.toString())) { + return "N/A"; + } + return value.toString(); } });
+ addTableAction(extendLocatorId("New"), "New", Table.SelectionEnablement.ALWAYS, null, new TableAction() { + public void executeAction(ListGridRecord[] selection) { + newDetails(); + } + }); + } + + @Override + public Canvas getDetailsView(int id) { + final SingleGroupDefinitionView singleGroupDefinitionView = new SingleGroupDefinitionView(this + .extendLocatorId("Empty")); + return singleGroupDefinitionView; } + } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java new file mode 100644 index 0000000..e5885f4 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -0,0 +1,333 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions; + +import java.util.LinkedHashMap; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.form.fields.RadioGroupItem; +import com.smartgwt.client.widgets.form.fields.ResetItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.SpinnerItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.SubmitItem; +import com.smartgwt.client.widgets.form.fields.TextAreaItem; +import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.form.fields.events.ClickEvent; +import com.smartgwt.client.widgets.form.fields.events.ClickHandler; + +import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria; +import org.rhq.core.domain.resource.group.GroupDefinition; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.BookmarkableView; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.LinkManager; +import org.rhq.enterprise.gui.coregui.client.ViewId; +import org.rhq.enterprise.gui.coregui.client.ViewPath; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/** + * @author Joseph Marques + */ +public class SingleGroupDefinitionView extends LocatableVLayout implements BookmarkableView { + + private int groupDefinitionId; + private GroupDefinition groupDefinition; + + private ViewId viewId; + + private TextItem name; + private TextAreaItem description; + private RadioGroupItem recursive; + private SelectItem templateSelector; + private TextAreaItem expression; + private SpinnerItem recalculationInterval; + + private StaticTextItem nameStatic; + private StaticTextItem descriptionStatic; + private StaticTextItem recursiveStatic; + private StaticTextItem expressionStatic; + private StaticTextItem recalculationIntervalStatic; + + private boolean formBuilt = false; + + public SingleGroupDefinitionView(String locatorId) { + this(locatorId, null); + } + + public SingleGroupDefinitionView(String locatorId, GroupDefinition groupDefinition) { + super(locatorId); + + setPadding(10); + setOverflow(Overflow.AUTO); + + buildForm(); + + this.groupDefinition = groupDefinition; + } + + public void setGroupDefinition(GroupDefinition groupDefinition) { + this.groupDefinition = groupDefinition; + + if (groupDefinition == null) { + clearFormValues(); + } else { + name.setValue(groupDefinition.getName()); + nameStatic.setValue(groupDefinition.getName()); + + recursive.setValue(groupDefinition.isRecursive() ? "Yes" : "No"); + recursiveStatic.setValue(groupDefinition.isRecursive() ? "Yes" : "No"); + + description.setValue(groupDefinition.getDescription()); + descriptionStatic.setValue(groupDefinition.getDescription()); + + recalculationInterval.setValue(groupDefinition.getRecalculationInterval()); + recalculationIntervalStatic.setValue(groupDefinition.getRecalculationInterval()); + + expression.setValue(groupDefinition.getExpression()); + expressionStatic.setValue(groupDefinition.getExpression()); + + SubmitItem saveButton = new SubmitItem("save", "Save"); + ResetItem resetButton = new ResetItem("reset", "Reset"); + + saveButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + save(); + System.out.println("Save is done"); + } + }); + + LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("GroupDefinitionForm")); + form.setFields(name, nameStatic, recursive, recursiveStatic, description, descriptionStatic, + recalculationInterval, recalculationIntervalStatic, expression, expressionStatic, saveButton, + resetButton); + form.setNumCols(4); + + addMember(form); + formBuilt = true; + } + + markForRedraw(); + } + + public void switchToEditMode() { + name.show(); + description.show(); + recursive.show(); + expression.show(); + recalculationInterval.show(); + + nameStatic.hide(); + descriptionStatic.hide(); + recursiveStatic.hide(); + expressionStatic.hide(); + recalculationIntervalStatic.hide(); + + if (groupDefinitionId == 0) { + viewId.getBreadcrumbs().get(0).setDisplayName("New Group Definition"); + } else { + viewId.getBreadcrumbs().get(0).setDisplayName("Editing '" + nameStatic.getValue().toString() + "'"); + } + CoreGUI.refreshBreadCrumbTrail(); + + markForRedraw(); + } + + public void switchToViewMode() { + name.hide(); + description.hide(); + recursive.hide(); + expression.hide(); + recalculationInterval.hide(); + + nameStatic.show(); + descriptionStatic.show(); + recursiveStatic.show(); + expressionStatic.show(); + recalculationIntervalStatic.show(); + + markForRedraw(); + } + + public void save() { + groupDefinition.setName(name.getValue().toString()); + groupDefinition.setDescription(description.getValue().toString()); + groupDefinition.setRecursive("Yes".equals(recursive.getValue())); + groupDefinition.setExpression(expression.getValue().toString()); + groupDefinition.setRecalculationInterval(Long.valueOf(recalculationInterval.getValue().toString())); + + GWTServiceLookup.getResourceGroupService().updateGroupDefinition(groupDefinition, new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failure saving group definition[id=" + groupDefinitionId + "]", + caught); + } + + @Override + public void onSuccess(Void result) { + CoreGUI.getErrorHandler().handleError( + "Successfully saved group definition[id=" + groupDefinitionId + "]"); + String listViewLink = LinkManager.getHubGroupDefinitionsLink(); + CoreGUI.goToView(listViewLink.substring(1)); + } + }); + } + + public void clearFormValues() { + name.clearValue(); + description.clearValue(); + recursive.clearValue(); + expression.clearValue(); + recalculationInterval.clearValue(); + + nameStatic.clearValue(); + descriptionStatic.clearValue(); + recursiveStatic.clearValue(); + expressionStatic.clearValue(); + recalculationIntervalStatic.clearValue(); + + markForRedraw(); + } + + private void buildForm() { + if (!formBuilt) { + + name = new TextItem("name", "Name"); + name.setWidth(400); + name.setDefaultValue(""); + nameStatic = new StaticTextItem("nameStatic", "Name"); + + description = new TextAreaItem("description", "Description"); + description.setWidth(400); + description.setHeight(50); + description.setDefaultValue(""); + descriptionStatic = new StaticTextItem("descriptionStatic", "Description"); + + recursive = new RadioGroupItem("recursive", "Recursive"); + recursive.setValueMap("Yes", "No"); + recursive.setDefaultValue("Yes"); + recursiveStatic = new StaticTextItem("recursiveStatic", "Recursive"); + + expression = new TextAreaItem("expression", "Expression"); + expression.setWidth(400); + expression.setHeight(150); + expression.setDefaultValue(""); + expressionStatic = new StaticTextItem("expressionStatic", "Expression"); + + recalculationInterval = new SpinnerItem("recalculationInterval", "Recalculation Interval"); + recalculationInterval.setWrapTitle(false); + recalculationInterval.setDefaultValue(0); + recalculationIntervalStatic = new StaticTextItem("recalculationInterval", "Recalculation Interval"); + + templateSelector = new SelectItem(); + templateSelector.setValueMap(getTemplates()); + + formBuilt = true; + } + } + + public static LinkedHashMap<String, String> getTemplates() { + LinkedHashMap<String, String> items = new LinkedHashMap<String, String>(); + + // grouped items + items.put("JBossAS clusters in the system", // + get("groupby resource.trait[partitionName]", // + "resource.type.plugin = JBossAS", // + "resource.type.name = JBossAS Server")); + items.put("Clustered enterprise application archive (EAR)", // + get("groupby resource.parent.trait[partitionName]", // + "groupby resource.name", // + "resource.type.plugin = JBossAS", // + "resource.type.name = Enterprise Application (EAR)")); + items.put("Unique JBossAS versions in inventory", // + get("groupby resource.trait[jboss.system:type=Server:VersionName]", // + "resource.type.plugin = JBossAS", // + "resource.type.name = JBossAS Server")); + items.put("Platform resource in inventory", // + get("resource.type.category = PLATFORM", // + "groupby resource.name")); + items.put("Unique resource type in inventory", // + get("groupby resource.type.plugin", // + "groupby resource.type.name")); + + // simple items + items.put("All JBossAS hosting any version of 'my' app", // + get("resource.type.plugin = JBossAS", // + "resource.type.name = JBossAS Server", // + "resource.child.name.contains = my")); + items.put("All Non-secured JBossAS servers", // + get("empty resource.pluginConfiguration[principal]", // + "resource.type.plugin = JBossAS", // + "resource.type.name = JBossAS Server")); + items.put("All resources currently down", // + get("resource.availability = DOWN")); + + return items; + } + + private static String get(String... pieces) { + StringBuilder results = new StringBuilder(); + boolean first = true; + for (String next : pieces) { + if (first) { + first = false; + } else { + results.append('\n'); + } + results.append(next); + } + return results.toString(); + } + + private void lookupDetails(final int groupDefinitionId) { + ResourceGroupDefinitionCriteria criteria = new ResourceGroupDefinitionCriteria(); + criteria.addFilterId(groupDefinitionId); + + if (groupDefinitionId == 0) { + GroupDefinition newGroupDefinition = new GroupDefinition(); + setGroupDefinition(newGroupDefinition); + switchToEditMode(); + } else { + GWTServiceLookup.getResourceGroupService().findGroupDefinitionsByCriteria(criteria, + new AsyncCallback<PageList<GroupDefinition>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError( + "Failure loading group definition[id=" + groupDefinitionId + "]", caught); + } + + public void onSuccess(PageList<GroupDefinition> result) { + GroupDefinition existingGroupDefinition = result.get(0); + setGroupDefinition(existingGroupDefinition); + switchToEditMode(); + } + }); + } + } + + @Override + public void renderView(ViewPath viewPath) { + groupDefinitionId = viewPath.getCurrentAsInt(); + viewId = viewPath.getCurrent(); + lookupDetails(groupDefinitionId); + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java index e6b5936..4b59caf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java @@ -78,4 +78,12 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen groupManager.updateResourceGroup(getSessionSubject(), group); }
+ public void updateGroupDefinition(GroupDefinition groupDefinition) { + try { + definitionManager.updateGroupDefinition(getSessionSubject(), groupDefinition); + } catch (Throwable t) { + throw new RuntimeException(t.getMessage()); + } + } + } \ No newline at end of file
commit d46933a9d3b0fa0dd02a02500cad325a6118ffcf Author: Joseph Marques joseph@redhat.com Date: Fri Sep 10 14:19:13 2010 -0400
do not link crumbs - many are broken links, nearly all don't change the view anyway
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java index 44586b1..a153ee0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadcrumbTrailPane.java @@ -106,12 +106,12 @@ public class BreadcrumbTrailPane extends ToolStrip {
private Label getCrumb(Breadcrumb crumb, String path) { Label l = null; - if (crumb.isHyperlink()) { - String fullPath = path.toString() + crumb.getName(); - l = new LocatableLabel(fullPath, "<a href="#" + fullPath + "">" + crumb.getDisplayName() + "</a>"); - } else { - l = new Label(crumb.getDisplayName()); - } + String fullPath = path.toString() + crumb.getName(); + //if (crumb.isHyperlink()) { + //l = new LocatableLabel(fullPath, "<a href="#" + fullPath + "">" + crumb.getDisplayName() + "</a>"); + //} else { + l = new LocatableLabel(fullPath, "<b>" + crumb.getDisplayName() + "</b>"); + //} if (crumb.getIcon() != null) { l.setIcon(crumb.getIcon()); l.setIconSize(16);
commit 097a1774d76ff27a72b8a6f9fbff80c20e48956d Author: Joseph Marques joseph@redhat.com Date: Fri Sep 10 14:10:53 2010 -0400
more tidy work for the reports view
* move 'platforms' report from inventory section to reports section * rename 'platforms' to 'cpu & memory utilization' * add icon for 'inventory summary' node
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java index 2e8fae2..f5f7dce 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java @@ -150,11 +150,9 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView final TreeNode alertDefinitions = new TreeNode("Alert Definitions"); alertDefinitions.setIcon("subsystems/alert/Alerts_16.png");
- final TreeNode platforms = new TreeNode("Platforms"); - platforms.setIcon("types/Platform_up_16.png"); - - tree.setRoot(new TreeNode(SECTION_INVENTORY, tagCloud, suspectMetrics, recentConfigurationChanges, - recentOperations, recentAlerts, alertDefinitions, platforms)); + TreeNode inventoryNode = new TreeNode(SECTION_INVENTORY, tagCloud, suspectMetrics, recentConfigurationChanges, + recentOperations, recentAlerts, alertDefinitions); + tree.setRoot(inventoryNode);
inventoryTreeGrid.setData(tree);
@@ -168,9 +166,13 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView reportsTreeGrid.setShowHeader(false);
Tree tree = new Tree(); - final TreeNode inventorySummaryNode = new TreeNode("Inventory Summary"); + final TreeNode inventorySummary = new TreeNode("Inventory Summary"); + inventorySummary.setIcon("subsystems/inventory/Inventory_16.png"); + + final TreeNode platforms = new TreeNode("CPU & Memory Utilization"); + platforms.setIcon("types/Platform_up_16.png");
- TreeNode reportsNode = new TreeNode(SECTION_REPORTS, inventorySummaryNode); + TreeNode reportsNode = new TreeNode(SECTION_REPORTS, inventorySummary, platforms); tree.setRoot(reportsNode);
reportsTreeGrid.setData(tree); @@ -216,13 +218,13 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView content = new AlertsView(this.extendLocatorId("RecentAlerts")); } else if ("Alert Definitions".equals(page)) { //todo - } else if ("Platforms".equals(page)) { - content = new PlatformPortletView(this.extendLocatorId("Platforms")); }
} else if (SECTION_REPORTS.equals(section)) { if ("Inventory Summary".equals(page)) { content = new FullHTMLPane("/rhq/admin/report/resourceInstallReport-body.xhtml"); + } else if ("CPU & Memory Utilization".equals(page)) { + content = new PlatformPortletView(this.extendLocatorId("Platforms")); } } for (String name : treeGrids.keySet()) {
commit b3d884c5ff04671d892a2efb5c8b98bc40cee60d Author: Joseph Marques joseph@redhat.com Date: Fri Sep 10 13:57:40 2010 -0400
tidy up reports > inventory summary
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml index 81ac667..cfcac68 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml @@ -19,17 +19,11 @@
<ui:define name="body">
- rich:panel - <f:facet name="header"> - <h:outputText value="Resource Version Inventory Report"/> - </f:facet> - <h:panelGrid columns="1" width="100%">
<h:form> <h:selectBooleanCheckbox id="groupByVersion" value="#{ResourceInstallReportUIBean.groupByVersion}" label="gbvLabel"> - <a4j:support reRender="reportTable" event="onclick" status="commonStatus"/> </h:selectBooleanCheckbox> <h:outputText value="Group By Version" id="gbvLabel"/>
@@ -38,7 +32,6 @@ value="#{ResourceInstallReportUIBean.resourceInstallCounts}" var="installReport" width="100%" - columnsWidth="15%, 15%, 10%, 10%, 10%" headerClass="tableRowHeader" footerClass="on-pager-footer" onRowMouseOver="this.style.backgroundColor='#E7E7E7'" @@ -86,8 +79,6 @@
</h:panelGrid>
- </rich:panel> - </ui:define>
</ui:composition>
commit 5e8ccd7d51df020575a8602227f9ed39cf0f754a Author: Joseph Marques joseph@redhat.com Date: Fri Sep 10 13:51:58 2010 -0400
move the "Inventory Summary" report to the Reports top view (from Admin top view)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java index df0f4b5..8715366 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java @@ -83,7 +83,6 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable treeGrids.put("Security", buildSecuritySection()); treeGrids.put("Configuration", buildSystemConfigurationSection()); treeGrids.put("Cluster", buildManagementClusterSection()); - treeGrids.put("Reports", buildReportsSection());
for (final String name : treeGrids.keySet()) { TreeGrid grid = treeGrids.get(name); @@ -181,23 +180,6 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable return systemConfigTreeGrid; }
- private TreeGrid buildReportsSection() { - - final TreeGrid reportsTreeGrid = new LocatableTreeGrid("Reports"); - reportsTreeGrid.setLeaveScrollbarGap(false); - reportsTreeGrid.setShowHeader(false); - - Tree tree = new Tree(); - final TreeNode inventorySummaryNode = new TreeNode("Inventory Summary"); - - TreeNode reportsNode = new TreeNode("Reports", inventorySummaryNode); - tree.setRoot(reportsNode); - - reportsTreeGrid.setData(tree); - - return reportsTreeGrid; - } - public void setContent(Canvas newContent) {
if (contentCanvas.getChildren().length > 0) { @@ -220,13 +202,7 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable String page = currentPageViewId.getPath();
Canvas content = null; - if ("Reports".equals(section)) { - - if ("Inventory Summary".equals(page)) { - content = new FullHTMLPane("/rhq/admin/report/resourceInstallReport-body.xhtml"); - } - - } else if ("Security".equals(section)) { + if ("Security".equals(section)) {
if ("Manage Users".equals(page)) { content = new UsersView(this.extendLocatorId("Users")); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java index c507395..2e8fae2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java @@ -42,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.alert.AlertsView; +import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryView; @@ -221,8 +222,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
} else if (SECTION_REPORTS.equals(section)) { if ("Inventory Summary".equals(page)) { - // TODO - content = null; + content = new FullHTMLPane("/rhq/admin/report/resourceInstallReport-body.xhtml"); } } for (String name : treeGrids.keySet()) {
commit 2b9cbc4e7ebb975f22d480d168c400b80cb1f147 Author: Joseph Marques joseph@redhat.com Date: Fri Sep 10 11:42:16 2010 -0400
fix for "Run Operation" button being unnecessarily wide
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java index 7ce66ae..212a5ae 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java @@ -133,6 +133,7 @@ public class OperationHistoryView extends TableSection { IMenuButton operationsButton = new LocatableIMenuButton(this.extendLocatorId("Run"), "Run Operation", operationMenu); operationsButton.setShowMenuBelow(false); + operationsButton.setAutoFit(true); addExtraWidget(operationsButton); }
commit b23dfc62b878474ac43b5ba894e9d716ccdd6453 Author: Joseph Marques joseph@redhat.com Date: Fri Sep 10 11:41:57 2010 -0400
fix resource links for pages still included via iframe
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java index 2ae4974..b648f57 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java @@ -29,17 +29,15 @@ public class LinkManager {
private static boolean GWT = true;
- public static String getResourceLink(int resourceId) {
if (GWT) { return "#Resource/" + resourceId + "/Summary/Overview"; } else { - return "/rhq/resource/summary/summary.xhtml?id=" + resourceId; + return "/rhq/resource/summary/overview.xhtml?id=" + resourceId; } }
- public static String getResourceGroupLink(int resouceGroupId) {
if (GWT) { @@ -61,7 +59,6 @@ public class LinkManager { return "/rhq/subsystem/operationHistory.xhtml"; }
- public static String getSubsystemAlertHistoryLink() { return "/rhq/subsystem/alertHistory.xhtml"; } @@ -70,7 +67,6 @@ public class LinkManager { return "/rhq/subsystem/alertDefinitions.xhtml"; }
- public static String getAutodiscoveryQueueLink() { if (GWT) { return "#Administration/Security/Auto%20Discovery%20Queue"; @@ -87,7 +83,6 @@ public class LinkManager { } }
- public static String getHubAllResourcesLink() { if (GWT) { return "#Inventory"; @@ -120,12 +115,10 @@ public class LinkManager { } }
- public static String getSavedSearchLink(int searchId) { return "/rhq/inventory/browseResources.xhtml?subtab=all&searchId=" + searchId; }
- public static String getHubAllGroupsLink() { return "/rhq/inventory/browseGroups.xhtml?subtab=all"; } @@ -146,12 +139,10 @@ public class LinkManager { return "/resource/group/Inventory.do?mode=new"; }
- public static String getHubNewGroupDefLink() { return "/rhq/definition/group/new.xhtml"; }
- public static String getAdminUsersLink() { if (GWT) { return "#Administration/Security/Manage Users"; @@ -176,7 +167,6 @@ public class LinkManager { } }
- public static String getAdminPluginsLink() { if (GWT) { return "#Administration/Configuration/Plugins"; @@ -185,7 +175,6 @@ public class LinkManager { } }
- public static String getAdminTemplatesLink() { if (GWT) { return "#Administration/Configuration/Templates"; @@ -198,7 +187,6 @@ public class LinkManager { return "/rhq/admin/alert/template/notification/list.xhtml"; }
- public static String getAdminContentProvidersLink() { return "/rhq/content/listContentProviders.xhtml"; } @@ -207,7 +195,6 @@ public class LinkManager { return "/rhq/content/listRepos.xhtml"; }
- public static String getHAServersLink() { if (GWT) { return "#Administration/Cluster/Servers"; @@ -240,7 +227,6 @@ public class LinkManager { } }
- public static String getReportsInventoryLink() { if (GWT) { return "#Administration/Reports/Inventory Summary"; @@ -253,7 +239,6 @@ public class LinkManager { return "/rhq/admin/downloads.xhtml"; }
- public static String getAdminLicenseLink() { if (GWT) { return "#Administration/Configuration/License"; @@ -262,7 +247,6 @@ public class LinkManager { } }
- public static String getDebugSqlLink() { return "/admin/test/sql.jsp"; } @@ -283,7 +267,6 @@ public class LinkManager { return "/admin/user/UserAdmin.do?mode=editPass&u=" + subjectId; }
- public static String getTagLink(String tag) { return "#Reports/Inventory/Tag%20Cloud/" + tag; } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java index ad57e8b..c7ad60c 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java @@ -351,13 +351,17 @@ public class FunctionTagLibrary extends AbstractTagLibrary {
// needs to exist separately from getDefaultContextTabURL because only some facelets understand EntityContext public static String getDefaultResourceTabURL() { - return "/rhq/resource/summary/summary.xhtml"; + return "/rhq/resource/summary/overview.xhtml"; }
public static String getDefaultGroupTabURL() { return "/rhq/group/inventory/view.xhtml"; }
+ public static String getDefaultAutoGroupTabURL() { + return "/rhq/autogroup/monitor/graphs.xhtml"; + } + public static String getAvailabilityURL(AvailabilityType type, int size) { if (size != 16 && size != 24) { throw new IllegalArgumentException("No availability icon for size " + size); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java index 56d5465..c862f61 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java @@ -33,6 +33,7 @@ import javax.faces.context.ResponseWriter; import javax.faces.render.Renderer;
import org.rhq.core.domain.resource.composite.DisambiguationReport; +import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary;
/** * Renderer for {@link DisambiguatedResourceLineageComponent} @@ -40,37 +41,36 @@ import org.rhq.core.domain.resource.composite.DisambiguationReport; * @author Lukas Krejci */ public class DisambiguatedResourceLineageRenderer extends Renderer { - private static final String RESOURCE_URL = "/rhq/resource/summary/summary.xhtml"; - + @Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { DisambiguatedResourceLineageComponent lineageComponent = (DisambiguatedResourceLineageComponent) component; - + String separator = lineageComponent.getSeparator(); List<DisambiguationReport.Resource> parents = lineageComponent.getParents(); boolean renderLinks = lineageComponent.getRenderLinks(); - + if (parents != null && parents.size() > 0) { ResponseWriter writer = context.getResponseWriter(); - + Iterator<DisambiguationReport.Resource> parentsIt = parents.iterator(); - + if (renderLinks) { encodeUrl(writer, parentsIt.next()); - while(parentsIt.hasNext()) { + while (parentsIt.hasNext()) { writer.writeText(separator, null); encodeUrl(writer, parentsIt.next()); } } else { encodeSimple(writer, parentsIt.next()); - while(parentsIt.hasNext()) { + while (parentsIt.hasNext()) { writer.writeText(separator, null); encodeSimple(writer, parentsIt.next()); } } } } - + public static void encodeUrl(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { encodePreName(writer, parent); writer.startElement("a", null); @@ -79,17 +79,17 @@ public class DisambiguatedResourceLineageRenderer extends Renderer { writer.endElement("a"); encodePostName(writer, parent); } - + public static void encodeSimple(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { encodePreName(writer, parent); writeName(writer, parent); encodePostName(writer, parent); } - + private static String getUrl(DisambiguationReport.Resource parent) { - return RESOURCE_URL + "?id=" + parent.getId(); + return FunctionTagLibrary.getDefaultResourceTabURL() + "?id=" + parent.getId(); } - + private static void encodePreName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { if (!parent.getType().isSingleton()) { writer.startElement("span", null); @@ -118,7 +118,7 @@ public class DisambiguatedResourceLineageRenderer extends Renderer { writer.endElement("span"); } } - + private static void writeName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { writer.startElement("span", null); writer.writeAttribute("class", "disambiguated-resource-name", null); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java index 33310b6..73903a5 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceLineageRenderer.java @@ -27,6 +27,7 @@ import javax.faces.context.ResponseWriter; import javax.faces.render.Renderer;
import org.rhq.core.domain.resource.Resource; +import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary; import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.util.HibernatePerformanceMonitor; import org.rhq.enterprise.server.util.LookupUtil; @@ -37,7 +38,6 @@ import org.rhq.enterprise.server.util.LookupUtil; * @author Ian Springer */ public class ResourceLineageRenderer extends Renderer { - private static final String BASE_RESOURCE_URL = "/rhq/resource/summary/summary.xhtml"; private static final String SEPARATOR = " > ";
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager(); @@ -74,7 +74,7 @@ public class ResourceLineageRenderer extends Renderer { }
private String buildURL(Resource resource) { - String url = BASE_RESOURCE_URL + "?id=" + resource.getId(); + String url = FunctionTagLibrary.getDefaultResourceTabURL() + "?id=" + resource.getId();
// Session-encode the URL in case the client doesn't have cookies enabled. url = FacesContext.getCurrentInstance().getExternalContext().encodeResourceURL(url); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java index 4f5bfa9..76e437e 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/InventoryHierarchyTag.java @@ -32,6 +32,7 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.GroupCategory; import org.rhq.core.domain.resource.group.ResourceGroup; +import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary; import org.rhq.enterprise.gui.legacy.util.RequestUtils; import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal; @@ -46,11 +47,7 @@ import org.rhq.enterprise.server.util.LookupUtil; * @author Ian Springer */ public class InventoryHierarchyTag extends TagSupport { - private static final String BASE_RESOURCE_URL = "/rhq/resource/summary/summary.xhtml";
- //private static final String BASE_GROUP_URL = "/Resource.do?type=GROUP"; - private static final String BASE_GROUP_URL = "/rhq/group/inventory/view.xhtml"; - private static final String BASE_AUTOGROUP_URL = "/rhq/autogroup/monitor/graphs.xhtml"; private static final String SEPARATOR = " > ";
private Integer resourceId; @@ -177,7 +174,7 @@ public class InventoryHierarchyTag extends TagSupport { }
private String buildResourceURL(Resource resource) { - String url = BASE_RESOURCE_URL + "?id=" + resource.getId(); + String url = FunctionTagLibrary.getDefaultResourceTabURL() + "?id=" + resource.getId();
// Session-encode the URL in case the client doesn't have cookies enabled. return encodeURL(url); @@ -185,15 +182,16 @@ public class InventoryHierarchyTag extends TagSupport {
private String buildGroupURL(ResourceGroup resourceGroup) { GroupCategory category = resourceGroup.getGroupCategory(); - String url = BASE_GROUP_URL + "?category=" + category.name() + "&groupId=" + resourceGroup.getId(); + String url = FunctionTagLibrary.getDefaultGroupTabURL() + "?category=" + category.name() + "&groupId=" + + resourceGroup.getId();
// Session-encode the URL in case the client doesn't have cookies enabled. return encodeURL(url); }
private String buildAutoGroupURL() { - String url = BASE_AUTOGROUP_URL + "?id=" + parentResourceId + "&parent=" + parentResourceId + "&type=" - + resourceTypeId; + String url = FunctionTagLibrary.getDefaultAutoGroupTabURL() + "?id=" + parentResourceId + "&parent=" + + parentResourceId + "&type=" + resourceTypeId;
// Session-encode the URL in case the client doesn't have cookies enabled. return encodeURL(url); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java index 2efedc9..091fa19 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java @@ -32,6 +32,7 @@ import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.TagSupport;
import org.rhq.core.domain.resource.composite.DisambiguationReport; +import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary;
/** * @@ -122,7 +123,7 @@ public class DisambiguatedResourceNameTag extends TagSupport { if (htmlOutput) { writer.append("<span class="disambiguated-resource-type">"); } - + writer.append(resourceType.getName()).append(" ");
if (resourceType.getPlugin() != null) { @@ -134,7 +135,7 @@ public class DisambiguatedResourceNameTag extends TagSupport { writer.append("</span>"); } } - + if (htmlOutput) { writer.append("</span>"); } @@ -151,7 +152,7 @@ public class DisambiguatedResourceNameTag extends TagSupport { if (htmlOutput) { writer.append("</span>"); } - + if (url != null) { writer.append("</a>"); } @@ -160,7 +161,7 @@ public class DisambiguatedResourceNameTag extends TagSupport { if (htmlOutput) { writer.append("<span class="disambiguated-resource-plugin">"); } - + writer.append(" (").append(resourceType.getPlugin()).append(" plugin)");
if (htmlOutput) { @@ -168,8 +169,8 @@ public class DisambiguatedResourceNameTag extends TagSupport { } } } - + public static String getDefaultResourceUrl(int resourceId) { - return "/rhq/resource/summary/summary.xhtml?id=" + resourceId; + return FunctionTagLibrary.getDefaultResourceTabURL() + "?id=" + resourceId; } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java index 4650eef..e69c57e 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeContextMenuUIBean.java @@ -34,6 +34,7 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.group.ClusterKey; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.gui.util.FacesContextUtility; +import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary; import org.rhq.enterprise.gui.navigation.contextmenu.MenuItemDescriptor; import org.rhq.enterprise.gui.navigation.contextmenu.MetricMenuItemDescriptor; import org.rhq.enterprise.gui.navigation.contextmenu.QuickLinksDescriptor; @@ -175,7 +176,7 @@ public class ResourceGroupTreeContextMenuUIBean extends TreeContextMenuBase { menuItem.setValue(res.getName()); menuItem.setId("groupMember_" + res.getId());
- String url = "/rhq/resource/summary/summary.xhtml?id=" + res.getId(); + String url = FunctionTagLibrary.getDefaultResourceTabURL() + "?id=" + res.getId();
menuItem.setSubmitMode("none"); menuItem.setOnclick("document.location.href='" + url + "'");
commit cc80b28867c8984b6da49e0f43aeab1900384014 Author: Joseph Marques joseph@redhat.com Date: Fri Sep 10 11:01:49 2010 -0400
remove "details" button from operation>history page in favor of double-click details trigger
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java index ae68de0..7ce66ae 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java @@ -32,12 +32,9 @@ import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.operation.OperationRequestStatus; -import org.rhq.core.domain.operation.ResourceOperationHistory; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.enterprise.gui.coregui.client.components.table.Table; -import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.detail.OperationDetailsView; @@ -115,16 +112,6 @@ public class OperationHistoryView extends TableSection { getListGrid().hideField("resource"); }
- addTableAction(extendLocatorId("Details"), "Details", Table.SelectionEnablement.SINGLE, null, - new TableAction() { - public void executeAction(ListGridRecord[] selection) { - ResourceOperationHistory history = (ResourceOperationHistory) selection[0] - .getAttributeAsObject("entity"); - - showDetails(history.getId()); - } - }); - if (resource != null && composite.getResourcePermission().isControl()) { final Menu operationMenu = new LocatableMenu(this.extendLocatorId("Operation")); ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
commit 83e9781e640d06fbe41208d6bec8a4b40c4b82ed Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 12:08:59 2010 -0400
make sure all data we need for the types are preloaded
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java index 0c7cdff..4775ee4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java @@ -23,6 +23,9 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList; +import java.util.EnumSet; + import com.smartgwt.client.data.Criteria; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -30,6 +33,8 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ResourceGroup; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
/** * @author John Mazzitelli @@ -43,6 +48,24 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView { public GroupAlertDefinitionsView(String locatorId, ResourceGroup group) { super(locatorId, "Group Alert Definitions"); this.group = group; + + // make sure we loaded all the type info we'll need. if one of these is null, either the type + // doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask. + ResourceType rt = this.group.getResourceType(); + EnumSet<MetadataType> metadata = EnumSet.noneOf(MetadataType.class); + if (rt.getEventDefinitions() == null) + metadata.add(MetadataType.events); + if (rt.getMetricDefinitions() == null) + metadata.add(MetadataType.measurements); + if (rt.getOperationDefinitions() == null) + metadata.add(MetadataType.operations); + if (rt.getResourceConfigurationDefinition() == null) + metadata.add(MetadataType.resourceConfigurationDefinition); + if (!metadata.isEmpty()) { + ArrayList<ResourceGroup> list = new ArrayList<ResourceGroup>(1); + list.add(this.group); + ResourceTypeRepository.Cache.getInstance().loadResourceTypes(list, metadata, null); + } }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java index da46f44..f986562 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java @@ -23,6 +23,9 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList; +import java.util.EnumSet; + import com.smartgwt.client.data.Criteria; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -30,6 +33,8 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
/** * @author John Mazzitelli @@ -43,6 +48,24 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView { public ResourceAlertDefinitionsView(String locatorId, Resource resource) { super(locatorId, "Alert Definitions"); this.resource = resource; + + // make sure we loaded all the type info we'll need. if one of these is null, either the type + // doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask. + ResourceType rt = this.resource.getResourceType(); + EnumSet<MetadataType> metadata = EnumSet.noneOf(MetadataType.class); + if (rt.getEventDefinitions() == null) + metadata.add(MetadataType.events); + if (rt.getMetricDefinitions() == null) + metadata.add(MetadataType.measurements); + if (rt.getOperationDefinitions() == null) + metadata.add(MetadataType.operations); + if (rt.getResourceConfigurationDefinition() == null) + metadata.add(MetadataType.resourceConfigurationDefinition); + if (!metadata.isEmpty()) { + ArrayList<Resource> list = new ArrayList<Resource>(1); + list.add(this.resource); + ResourceTypeRepository.Cache.getInstance().loadResourceTypes(list, metadata, null); + } }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java index 3ef3dfe..4366291 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java @@ -23,12 +23,16 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.EnumSet; + import com.smartgwt.client.data.Criteria; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
/** * @author John Mazzitelli @@ -42,6 +46,27 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView { public TemplateAlertDefinitionsView(String locatorId, ResourceType resourceType) { super(locatorId, "Alert Templates"); this.resourceType = resourceType; + + // make sure we loaded all the type info we'll need. if one of these is null, either the type + // doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask. + EnumSet<MetadataType> metadata = EnumSet.noneOf(MetadataType.class); + if (resourceType.getEventDefinitions() == null) + metadata.add(MetadataType.events); + if (resourceType.getMetricDefinitions() == null) + metadata.add(MetadataType.measurements); + if (resourceType.getOperationDefinitions() == null) + metadata.add(MetadataType.operations); + if (resourceType.getResourceConfigurationDefinition() == null) + metadata.add(MetadataType.resourceConfigurationDefinition); + if (!metadata.isEmpty()) { + ResourceTypeRepository.Cache.getInstance().getResourceTypes(resourceType.getId(), metadata, + new ResourceTypeRepository.TypeLoadedCallback() { + @Override + public void onTypesLoaded(ResourceType type) { + TemplateAlertDefinitionsView.this.resourceType = type; + } + }); + } }
@Override
commit f22c6f4fa74deea8393f8e53414aa886b18054ce Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 12:08:26 2010 -0400
support the ability to load resource types for resource groups support the ability to pass in a null callback (i.e. just load the types and don't bother calling back into anything)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java index 550413c..d488d14 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java @@ -32,6 +32,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import org.rhq.core.domain.criteria.ResourceTypeCriteria; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; @@ -49,11 +50,9 @@ public class ResourceTypeRepository { private static ResourceTypeGWTServiceAsync resourceTypeService = GWTServiceLookup.getResourceTypeGWTService();
public enum MetadataType { - children, operations, measurements, content, events, pluginConfigurationDefinition, resourceConfigurationDefinition, - subCategory, parentTypes, processScans, productVersions + children, operations, measurements, content, events, pluginConfigurationDefinition, resourceConfigurationDefinition, subCategory, parentTypes, processScans, productVersions }
- public static class Cache { private static final ResourceTypeRepository ourInstance = GWT.create(ResourceTypeRepository.class);
@@ -62,12 +61,10 @@ public class ResourceTypeRepository { } }
- public static interface TypeLoadedCallback { - void onTypesLoaded( ResourceType type); + void onTypesLoaded(ResourceType type); }
- public static interface TypesLoadedCallback { void onTypesLoaded(HashMap<Integer, ResourceType> types); } @@ -76,14 +73,20 @@ public class ResourceTypeRepository { void onResourceTypeLoaded(List<Resource> resources); }
+ public static interface ResourceTypeLoadedInGroupCallback { + void onResourceTypeLoaded(List<ResourceGroup> resources); + } + public void loadResourceTypes(final PageList<Resource> resources, final ResourceTypeLoadedCallback callback) { loadResourceTypes(resources, null, callback); }
public void loadResourceTypes(final List<Resource> resources, final EnumSet<MetadataType> metadataTypes, - final ResourceTypeLoadedCallback callback) { + final ResourceTypeLoadedCallback callback) { if (resources.size() == 0) { - callback.onResourceTypeLoaded(resources); + if (callback != null) { + callback.onResourceTypeLoaded(resources); + } return; }
@@ -98,41 +101,78 @@ public class ResourceTypeRepository { for (Resource res : resources) { res.setResourceType(types.get(res.getResourceType().getId())); } - callback.onResourceTypeLoaded(resources); + if (callback != null) { + callback.onResourceTypeLoaded(resources); + } } });
-// System.out.println("Loaded types from cache in " + (System.currentTimeMillis() - start)); + // System.out.println("Loaded types from cache in " + (System.currentTimeMillis() - start)); + }
+ public void loadResourceTypes(final PageList<ResourceGroup> groups, final ResourceTypeLoadedInGroupCallback callback) { + loadResourceTypes(groups, null, callback); }
+ public void loadResourceTypes(final List<ResourceGroup> groups, final EnumSet<MetadataType> metadataTypes, + final ResourceTypeLoadedInGroupCallback callback) { + if (groups.size() == 0) { + if (callback != null) { + callback.onResourceTypeLoaded(groups); + } + return; + } + + long start = System.currentTimeMillis(); + + Set<Integer> types = new HashSet<Integer>(); + for (ResourceGroup group : groups) { + types.add(group.getResourceType().getId()); + } + getResourceTypes(types.toArray(new Integer[types.size()]), metadataTypes, new TypesLoadedCallback() { + public void onTypesLoaded(HashMap<Integer, ResourceType> types) { + for (ResourceGroup group : groups) { + group.setResourceType(types.get(group.getResourceType().getId())); + } + if (callback != null) { + callback.onResourceTypeLoaded(groups); + } + } + }); + + // System.out.println("Loaded types from cache in " + (System.currentTimeMillis() - start)); + }
public void getResourceTypes(Integer[] resourceTypeIds, final TypesLoadedCallback callback) { getResourceTypes(resourceTypeIds, null, callback); }
- - public void getResourceTypes(final Integer resourceTypeId, final EnumSet<MetadataType> metadataTypes, final TypeLoadedCallback callback) { - getResourceTypes(new Integer[]{resourceTypeId}, metadataTypes, new TypesLoadedCallback() { + public void getResourceTypes(final Integer resourceTypeId, final EnumSet<MetadataType> metadataTypes, + final TypeLoadedCallback callback) { + getResourceTypes(new Integer[] { resourceTypeId }, metadataTypes, new TypesLoadedCallback() { public void onTypesLoaded(HashMap<Integer, ResourceType> types) { - callback.onTypesLoaded(types.get(resourceTypeId)); + if (callback != null) { + callback.onTypesLoaded(types.get(resourceTypeId)); + } } }); }
- public void getResourceTypes(Integer[] resourceTypeIds, final EnumSet<MetadataType> metadataTypes, final TypesLoadedCallback callback) { + public void getResourceTypes(Integer[] resourceTypeIds, final EnumSet<MetadataType> metadataTypes, + final TypesLoadedCallback callback) { ResourceTypeCriteria criteria = new ResourceTypeCriteria();
final HashMap<Integer, ResourceType> cachedTypes = new HashMap<Integer, ResourceType>();
- ArrayList<Integer> typesNeeded = new ArrayList<Integer>(); if (resourceTypeIds == null) { //preload all } else {
for (Integer typeId : resourceTypeIds) { - if (!typeCache.containsKey(typeId) || (metadataTypes != null && (typeCacheLevel.containsKey(typeId)) && !typeCacheLevel.get(typeId).containsAll(metadataTypes))) { + if (!typeCache.containsKey(typeId) + || (metadataTypes != null && (typeCacheLevel.containsKey(typeId)) && !typeCacheLevel.get(typeId) + .containsAll(metadataTypes))) { typesNeeded.add(typeId); } else { cachedTypes.put(typeId, typeCache.get(typeId)); @@ -140,7 +180,9 @@ public class ResourceTypeRepository { }
if (typesNeeded.isEmpty()) { - callback.onTypesLoaded(cachedTypes); + if (callback != null) { + callback.onTypesLoaded(cachedTypes); + } return; } criteria.addFilterIds(typesNeeded.toArray(new Integer[typesNeeded.size()])); @@ -149,50 +191,51 @@ public class ResourceTypeRepository { if (metadataTypes != null) { for (MetadataType metadataType : metadataTypes) { switch (metadataType) { - case children: - criteria.fetchChildResourceTypes(true); - break; - case content: - criteria.fetchPackageTypes(true); - break; - case measurements: - criteria.fetchMetricDefinitions(true); - break; - case operations: - criteria.fetchOperationDefinitions(true); - break; - case events: - criteria.fetchEventDefinitions(true); - break; - case pluginConfigurationDefinition: - criteria.fetchPluginConfigurationDefinition(true); - break; - case resourceConfigurationDefinition: - criteria.fetchResourceConfigurationDefinition(true); - break; - case subCategory: - criteria.fetchSubCategory(true); - break; - case parentTypes: - criteria.fetchParentResourceTypes(true); - break; - case processScans: - criteria.fetchProcessScans(true); - break; - case productVersions: - criteria.fetchProductVersions(true); - break; + case children: + criteria.fetchChildResourceTypes(true); + break; + case content: + criteria.fetchPackageTypes(true); + break; + case measurements: + criteria.fetchMetricDefinitions(true); + break; + case operations: + criteria.fetchOperationDefinitions(true); + break; + case events: + criteria.fetchEventDefinitions(true); + break; + case pluginConfigurationDefinition: + criteria.fetchPluginConfigurationDefinition(true); + break; + case resourceConfigurationDefinition: + criteria.fetchResourceConfigurationDefinition(true); + break; + case subCategory: + criteria.fetchSubCategory(true); + break; + case parentTypes: + criteria.fetchParentResourceTypes(true); + break; + case processScans: + criteria.fetchProcessScans(true); + break; + case productVersions: + criteria.fetchProductVersions(true); + break; } } }
criteria.setPageControl(PageControl.getUnlimitedInstance());
- System.out.println("Loading " + typesNeeded.size() + ((metadataTypes != null) ? (" types: " + metadataTypes.toString()) : "")); + System.out.println("Loading " + typesNeeded.size() + + ((metadataTypes != null) ? (" types: " + metadataTypes.toString()) : ""));
resourceTypeService.findResourceTypesByCriteria(criteria, new AsyncCallback<PageList<ResourceType>>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load resource type metadata",caught); + CoreGUI.getErrorHandler().handleError("Failed to load resource type metadata", caught); }
public void onSuccess(PageList<ResourceType> result) { @@ -202,27 +245,29 @@ public class ResourceTypeRepository { if (metadataTypes != null) { for (MetadataType metadataType : metadataTypes) { switch (metadataType) { - case children: - cachedType.setChildResourceTypes(type.getChildResourceTypes()); - break; - case operations: - cachedType.setOperationDefinitions(type.getOperationDefinitions()); - break; - case measurements: - cachedType.setMetricDefinitions(type.getMetricDefinitions()); - break; - case content: - cachedType.setPackageTypes(type.getPackageTypes()); - break; - case events: - cachedType.setPackageTypes(type.getPackageTypes()); - break; - case pluginConfigurationDefinition: - cachedType.setPluginConfigurationDefinition(type.getPluginConfigurationDefinition()); - break; - case resourceConfigurationDefinition: - cachedType.setResourceConfigurationDefinition(type.getResourceConfigurationDefinition()); - break; + case children: + cachedType.setChildResourceTypes(type.getChildResourceTypes()); + break; + case operations: + cachedType.setOperationDefinitions(type.getOperationDefinitions()); + break; + case measurements: + cachedType.setMetricDefinitions(type.getMetricDefinitions()); + break; + case content: + cachedType.setPackageTypes(type.getPackageTypes()); + break; + case events: + cachedType.setPackageTypes(type.getPackageTypes()); + break; + case pluginConfigurationDefinition: + cachedType + .setPluginConfigurationDefinition(type.getPluginConfigurationDefinition()); + break; + case resourceConfigurationDefinition: + cachedType.setResourceConfigurationDefinition(type + .getResourceConfigurationDefinition()); + break; } } } @@ -240,16 +285,17 @@ public class ResourceTypeRepository { } } } - callback.onTypesLoaded(cachedTypes); + if (callback != null) { + callback.onTypesLoaded(cachedTypes); + } } }); }
- public void preloadAll() { getResourceTypes((Integer[]) null, EnumSet.allOf(MetadataType.class), new TypesLoadedCallback() { public void onTypesLoaded(HashMap<Integer, ResourceType> types) { - System.out.println("Preloaded ["+ types.size() + "] resource types"); + System.out.println("Preloaded [" + types.size() + "] resource types"); } }); }
commit 4edb44646a4b0c816aa6b934704de65ef8e8a40a Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 12:06:49 2010 -0400
add the ability to add resource config change condition
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index fceb893..b17e25a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -78,6 +78,7 @@ public class NewConditionEditor extends LocatableDynamicForm { private boolean supportsTraits = false; private boolean supportsOperations = false; private boolean supportsEvents = false; + private boolean supportsResourceConfig = false; private Runnable okFunction; // this is called after the OK button is pressed and a new condition is saved private ResourceType resourceType;
@@ -89,6 +90,7 @@ public class NewConditionEditor extends LocatableDynamicForm { this.resourceType = rtype;
this.supportsEvents = (rtype.getEventDefinitions() != null && rtype.getEventDefinitions().size() > 0); + this.supportsResourceConfig = (rtype.getResourceConfigurationDefinition() != null);
Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions(); if (metricDefinitions != null && metricDefinitions.size() > 0) { @@ -135,6 +137,9 @@ public class NewConditionEditor extends LocatableDynamicForm { if (supportsOperations) { condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution"); } + if (supportsResourceConfig) { + condTypes.put(AlertConditionCategory.RESOURCE_CONFIG.name(), "Resource Configuration Change"); + } if (supportsEvents) { condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection"); } @@ -179,6 +184,9 @@ public class NewConditionEditor extends LocatableDynamicForm { if (supportsEvents) { formItems.addAll(buildEventFormItems()); } + if (supportsResourceConfig) { + formItems.addAll(buildResourceConfigChangeFormItems()); + } formItems.add(ok);
setFields(formItems.toArray(new FormItem[formItems.size()])); @@ -259,6 +267,15 @@ public class NewConditionEditor extends LocatableDynamicForm { break; }
+ case RESOURCE_CONFIG: { + newCondition.setName(null); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(null); + break; + } + default: { CoreGUI.getErrorHandler().handleError("Invalid alert category selected: " + category); // should never happen break; @@ -459,6 +476,18 @@ public class NewConditionEditor extends LocatableDynamicForm { return formItems; }
+ private ArrayList<FormItem> buildResourceConfigChangeFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.RESOURCE_CONFIG); + + String helpStr = "This condition is triggered when the resource configuration changes."; + StaticTextItem helpItem = buildHelpTextItem("changeConfigHelp", helpStr, ifFunc); + formItems.add(helpItem); + + return formItems; + } + private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
commit 8ffce671fa4d1977b2850a0ae3462969274a701c Author: Ian Springer ian.springer@redhat.com Date: Wed Sep 15 12:04:43 2010 -0400
make CoreGUI.html a welcome page, so http://localhost:7080/coregui/ works
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml index a86b217..6e5d56b 100644 --- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml +++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml @@ -1,10 +1,12 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee - http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" - version="2.5"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" + version="2.5"> + + <display-name>RHQ GUI</display-name> +
<servlet> <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI RoleGWTService</servlet-name> @@ -214,4 +216,10 @@ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI ClusterGWTService</servlet-name> <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/ClusterGWTService</url-pattern> </servlet-mapping> + + + <welcome-file-list> + <welcome-file>CoreGUI.html</welcome-file> + </welcome-file-list> + </web-app> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml index ed22bc6..2cdedb1 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
- <display-name>RHQ</display-name> + <display-name>RHQ Legacy GUI</display-name>
<!--=== Seam ===-->
commit cc727ab9928ec5463171ff4eac8f5d69315198da Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 15 11:33:23 2010 -0400
A few more locatorId hooks in the TopMenu Search bar
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index 34d1621..403456c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -232,7 +232,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { // menuPane.setZIndex(400000); // layout.addMember(menuPane);
- MenuBarView menuBarView = new MenuBarView(); + MenuBarView menuBarView = new MenuBarView("TopMenu"); menuBarView.setWidth("100%"); // WidgetCanvas menuCanvas = new WidgetCanvas(menuBarView); // menuCanvas.setTop(0); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java index c98c16d..da5b92e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java @@ -28,7 +28,6 @@ import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.layout.HLayout; -import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.menu.Menu; import com.smartgwt.client.widgets.menu.MenuBar; import com.smartgwt.client.widgets.menu.MenuItem; @@ -37,23 +36,23 @@ import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.AboutModalWindow; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** * @author Greg Hinkle */ -public class DropDownMenuBarView extends VLayout { +public class DropDownMenuBarView extends LocatableVLayout {
private AboutModalWindow aboutModalWindow;
- public DropDownMenuBarView() { - super(5); + public DropDownMenuBarView(String locatorId) { + super(locatorId, 5); + setHeight(50); setWidth100();
- }
- protected void onDraw3() { super.onDraw();
@@ -62,10 +61,9 @@ public class DropDownMenuBarView extends VLayout { HLayout topBar = new HLayout(); topBar.setHeight(28); topBar.setStyleName("topMenuBar"); -// url("./images/cssButton/button_stretch.png") repeat-x scroll 0 0 #DDDDDD -// topBar.setBackgroundImage("[SKIN]/cssButton/button_stretch.png"); -// topBar.setBackgroundRepeat(BkgndRepeat.REPEAT_X); - + // url("./images/cssButton/button_stretch.png") repeat-x scroll 0 0 #DDDDDD + // topBar.setBackgroundImage("[SKIN]/cssButton/button_stretch.png"); + // topBar.setBackgroundRepeat(BkgndRepeat.REPEAT_X);
Img logo = new Img("header/rhq_logo_28px.png", 80, 28); logo.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { @@ -74,36 +72,36 @@ public class DropDownMenuBarView extends VLayout { } });
- topBar.addMember(logo);
- // Create a menu bar final MenuBar menu = new MenuBar(); menu.setHeight(28);
- - Menu subsystemsMenu = new Menu();
subsystemsMenu.setTitle("Subsystems"); - subsystemsMenu.addItem(new EMenuItem("Configuration Changes", LinkManager.getSubsystemConfigurationLink(), "subsystems/configure/Configure_16.png"));//, new LinkCommand("#config")); - subsystemsMenu.addItem(new EMenuItem("Suspect Metrics", LinkManager.getSubsystemSuspectMetricsLink(), "subsystems/monitor/Monitor_failed_16.png"));//, new LinkCommand("#config")); - subsystemsMenu.addItem(new EMenuItem("Operations", LinkManager.getSubsystemOperationHistoryLink(), "subsystems/control/Operation_16.png"));//, new LinkCommand("#config")); - subsystemsMenu.addItem(new EMenuItem("Alerts", LinkManager.getSubsystemAlertHistoryLink(), "subsystems/alert/Alert_HIGH_16.png"));//, new LinkCommand("#config")); - subsystemsMenu.addItem(new EMenuItem("Alert Definitions", LinkManager.getSubsystemAlertDefsLink(), "subsystems/alert/Alerts_16.png"));//, new LinkCommand("#config")); - + subsystemsMenu.addItem(new EMenuItem("Configuration Changes", LinkManager.getSubsystemConfigurationLink(), + "subsystems/configure/Configure_16.png"));//, new LinkCommand("#config")); + subsystemsMenu.addItem(new EMenuItem("Suspect Metrics", LinkManager.getSubsystemSuspectMetricsLink(), + "subsystems/monitor/Monitor_failed_16.png"));//, new LinkCommand("#config")); + subsystemsMenu.addItem(new EMenuItem("Operations", LinkManager.getSubsystemOperationHistoryLink(), + "subsystems/control/Operation_16.png"));//, new LinkCommand("#config")); + subsystemsMenu.addItem(new EMenuItem("Alerts", LinkManager.getSubsystemAlertHistoryLink(), + "subsystems/alert/Alert_HIGH_16.png"));//, new LinkCommand("#config")); + subsystemsMenu.addItem(new EMenuItem("Alert Definitions", LinkManager.getSubsystemAlertDefsLink(), + "subsystems/alert/Alerts_16.png"));//, new LinkCommand("#config"));
final Menu overviewMenu = new Menu(); overviewMenu.setTitle("Overview"); overviewMenu.setStyleName("SimpleMenuBarButton"); overviewMenu.setBorder("none"); - com.smartgwt.client.widgets.menu.MenuItem subsystemsSubMenuItem = new com.smartgwt.client.widgets.menu.MenuItem("Subsystems"); + com.smartgwt.client.widgets.menu.MenuItem subsystemsSubMenuItem = new com.smartgwt.client.widgets.menu.MenuItem( + "Subsystems"); subsystemsSubMenuItem.setSubmenu(subsystemsMenu); overviewMenu.addItem(subsystemsSubMenuItem); - overviewMenu.addItem(new EMenuItem("AutoDiscovery Queue",LinkManager.getAutodiscoveryQueueLink()));//,new LinkCommand("#cofng")); - overviewMenu.addItem(new EMenuItem("Dashboard",LinkManager.getDashboardLink()));//,new LinkCommand("#cofng")); - + overviewMenu.addItem(new EMenuItem("AutoDiscovery Queue", LinkManager.getAutodiscoveryQueueLink()));//,new LinkCommand("#cofng")); + overviewMenu.addItem(new EMenuItem("Dashboard", LinkManager.getDashboardLink()));//,new LinkCommand("#cofng"));
Menu resourcesMenu = new Menu(); resourcesMenu.setTitle("Resources"); @@ -111,7 +109,8 @@ public class DropDownMenuBarView extends VLayout { resourcesMenu.setBorder("none"); resourcesMenu.setStyleName("menuBarMenuButton"); resourcesMenu.addItem(new EMenuItem("All Resources", LinkManager.getHubAllResourcesLink()));//, new LinkCommand("#fsdf")); - resourcesMenu.addItem(new EMenuItem("Platforms", LinkManager.getHubPlatformsLink(),"types/Platform_up_16.png"));//, new LinkCommand("#fsdf")); + resourcesMenu + .addItem(new EMenuItem("Platforms", LinkManager.getHubPlatformsLink(), "types/Platform_up_16.png"));//, new LinkCommand("#fsdf")); resourcesMenu.addItem(new EMenuItem("Servers", LinkManager.getHubServerssLink(), "types/Server_up_16.png"));//, new LinkCommand("#fsdf")); resourcesMenu.addItem(new EMenuItem("Services", LinkManager.getHubServicesLink(), "types/Service_up_16.png"));//, new LinkCommand("#fsdf")); resourcesMenu.addItem(new MenuItemSeparator()); @@ -136,52 +135,46 @@ public class DropDownMenuBarView extends VLayout { groupsMenu.addItem(new EMenuItem("New Group", LinkManager.getHubNewGroupLink())); //, new LinkCommand("#sf")); groupsMenu.addItem(new EMenuItem("New Group Definition", LinkManager.getHubNewGroupDefLink())); //, new LinkCommand("#sf")); groupsMenu.addItem(new MenuItemSeparator()); -// groupsMenu.addItem(new MenuItem("Favorites")); //, new LinkCommand("#sf")); - + // groupsMenu.addItem(new MenuItem("Favorites")); //, new LinkCommand("#sf"));
Menu securityMenu = new Menu(); securityMenu.setTitle("Security"); - securityMenu.addItem(new EMenuItem("Users",LinkManager.getAdminUsersLink())); - securityMenu.addItem(new EMenuItem("Roles",LinkManager.getAdminRolesLink())); + securityMenu.addItem(new EMenuItem("Users", LinkManager.getAdminUsersLink())); + securityMenu.addItem(new EMenuItem("Roles", LinkManager.getAdminRolesLink())); MenuItem securitySubMenuItem = new MenuItem("Security"); securitySubMenuItem.setSubmenu(securityMenu);
- Menu sysConfigMenu = new Menu(); sysConfigMenu.setTitle("System Configuration"); - sysConfigMenu.addItem(new EMenuItem("Settings",LinkManager.getAdminSysConfigLink())); - sysConfigMenu.addItem(new EMenuItem("Plugins",LinkManager.getAdminPluginsLink())); - sysConfigMenu.addItem(new EMenuItem("Templates",LinkManager.getAdminTemplatesLink())); + sysConfigMenu.addItem(new EMenuItem("Settings", LinkManager.getAdminSysConfigLink())); + sysConfigMenu.addItem(new EMenuItem("Plugins", LinkManager.getAdminPluginsLink())); + sysConfigMenu.addItem(new EMenuItem("Templates", LinkManager.getAdminTemplatesLink())); MenuItem sysConfigSubMenuItem = new MenuItem("System Configuration"); sysConfigSubMenuItem.setSubmenu(sysConfigMenu);
- Menu contentMenu = new Menu(); contentMenu.setTitle("Content"); - contentMenu.addItem(new EMenuItem("Bundles","#Bundles")); - contentMenu.addItem(new EMenuItem("Content Providers",LinkManager.getAdminContentProvidersLink())); - contentMenu.addItem(new EMenuItem("Content Repositories",LinkManager.getAdminContentReposLink())); + contentMenu.addItem(new EMenuItem("Bundles", "#Bundles")); + contentMenu.addItem(new EMenuItem("Content Providers", LinkManager.getAdminContentProvidersLink())); + contentMenu.addItem(new EMenuItem("Content Repositories", LinkManager.getAdminContentReposLink())); MenuItem contentSubMenuItem = new MenuItem("Content"); contentSubMenuItem.setSubmenu(contentMenu);
- Menu haMenu = new Menu(); haMenu.setTitle("High Availability"); - haMenu.addItem(new EMenuItem("Servers",LinkManager.getHAServersLink())); - haMenu.addItem(new EMenuItem("Agents",LinkManager.getHAAgentsLink())); - haMenu.addItem(new EMenuItem("Affinity Groups",LinkManager.getHAAffinityGroupsLink())); - haMenu.addItem(new EMenuItem("Partition Events",LinkManager.getHAEventsLink())); + haMenu.addItem(new EMenuItem("Servers", LinkManager.getHAServersLink())); + haMenu.addItem(new EMenuItem("Agents", LinkManager.getHAAgentsLink())); + haMenu.addItem(new EMenuItem("Affinity Groups", LinkManager.getHAAffinityGroupsLink())); + haMenu.addItem(new EMenuItem("Partition Events", LinkManager.getHAEventsLink())); MenuItem haSubMentItem = new MenuItem("High Availability"); haSubMentItem.setSubmenu(haMenu);
- Menu reportsMenu = new Menu(); reportsMenu.setTitle("Reports"); reportsMenu.addItem(new EMenuItem("Resource Version Inventory Report", LinkManager.getReportsInventoryLink())); MenuItem reportsSubMenuItem = new MenuItem("Reports"); reportsSubMenuItem.setSubmenu(reportsMenu);
- Menu adminMenu = new Menu(); adminMenu.setTitle("Administration"); adminMenu.addItem(securitySubMenuItem); @@ -192,29 +185,22 @@ public class DropDownMenuBarView extends VLayout { adminMenu.addItem(new EMenuItem("Downloads", LinkManager.getAdminDownloadsLink())); adminMenu.addItem(new EMenuItem("License", LinkManager.getAdminLicenseLink()));
- - - - Menu helpMenu = new Menu(); helpMenu.setStyleName("menuBarMenuButton"); helpMenu.setTitle("Help"); helpMenu.addItem(new EMenuItem("Online Documentation", "http://www.rhq-project.org")); //, new LinkCommand("#sdfs")); helpMenu.addItem(new EMenuItem("Open a support case", "http://www.rhq-project.org")); //, new LinkCommand("#sdfs")); -// helpMenu.addItem(new MenuItem("About")); //, new LinkCommand("#sdfs")); + // helpMenu.addItem(new MenuItem("About")); //, new LinkCommand("#sdfs"));
menu.setMenus(overviewMenu, resourcesMenu, groupsMenu, adminMenu, helpMenu);
- topBar.addMember(menu);
- addMember(topBar); - addMember(new SearchBarPane()); + addMember(new SearchBarPane(this.extendLocatorId("Search")));
}
- public static class EMenuItem extends com.smartgwt.client.widgets.menu.MenuItem {
String link; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java index dc5503f..cd1b7d9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java @@ -25,16 +25,16 @@ import com.google.gwt.user.client.ui.Hyperlink; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.layout.LayoutSpacer; -import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.enterprise.gui.coregui.client.components.AboutModalWindow; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * @author Greg Hinkle */ -public class MenuBarView extends VLayout { +public class MenuBarView extends LocatableVLayout {
private AboutModalWindow aboutModalWindow;
@@ -44,6 +44,10 @@ public class MenuBarView extends VLayout {
private HTMLFlow linksPane;
+ public MenuBarView(String locatorId) { + super(locatorId); + } + protected void onDraw() { super.onDraw();
@@ -119,7 +123,7 @@ public class MenuBarView extends VLayout { topStrip.addMember(links); */ addMember(topStrip); - addMember(new SearchBarPane()); + addMember(new SearchBarPane(this.extendLocatorId("Search")));
markForRedraw(); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java index 523dc41..81abe79 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java @@ -18,12 +18,15 @@ */ package org.rhq.enterprise.gui.coregui.client.menu;
-import com.google.gwt.core.client.GWT; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE; + import com.google.gwt.user.client.History; -import com.google.gwt.user.client.ui.TextBox; import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.types.FormLayoutType; -import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.TextMatchStyle; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.form.DynamicForm; @@ -36,35 +39,22 @@ import com.smartgwt.client.widgets.form.fields.SpacerItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; -import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.layout.HLayout; -import com.smartgwt.client.widgets.menu.Menu; -import com.smartgwt.client.widgets.menu.MenuButton; -import com.smartgwt.client.widgets.menu.MenuItem; -import com.smartgwt.client.widgets.menu.MenuItemSeparator; - -import java.util.LinkedHashMap;
import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; - -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/** * @author Greg Hinkle */ -public class SearchBarPane extends HLayout { +public class SearchBarPane extends LocatableHLayout { + + public SearchBarPane(String locatorId) { + super(locatorId);
- public SearchBarPane() { - super(); setWidth100(); setHeight(28); } @@ -73,7 +63,7 @@ public class SearchBarPane extends HLayout { protected void onDraw() { super.onDraw();
- final DynamicForm form = new DynamicForm(); + final DynamicForm form = new LocatableDynamicForm(this.getLocatorId()); form.setNumCols(6); form.setColWidths("120", "140", "400");
@@ -103,7 +93,6 @@ public class SearchBarPane extends HLayout { addMember(form); }
- private ComboBoxItem getResourceComboBox() {
final ComboBoxItem comboBox = new ComboBoxItem("query", "Query"); @@ -122,7 +111,8 @@ public class SearchBarPane extends HLayout { ListGridField availabilityField = new ListGridField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 55); availabilityField.setAlign(Alignment.CENTER);
- comboBox.setPickListFields(nameField, descriptionField, typeNameField, pluginNameField, categoryField, availabilityField); + comboBox.setPickListFields(nameField, descriptionField, typeNameField, pluginNameField, categoryField, + availabilityField);
comboBox.setValueField("id"); comboBox.setDisplayField("name"); @@ -150,19 +140,16 @@ public class SearchBarPane extends HLayout { return comboBox; }
- private ComboBoxItem getGroupComboBox() { ComboBoxItem comboBox = new ComboBoxItem("query", "Query"); comboBox.setWidth(400); comboBox.setShowTitle(false);
- comboBox.setOptionDataSource(new ResourceGroupsDataSource()); ListGridField nameField = new ListGridField("name"); ListGridField descriptionField = new ListGridField("description"); comboBox.setPickListFields(nameField, descriptionField);
- comboBox.setValueField("id"); comboBox.setDisplayField("name"); comboBox.setPickListWidth(600);
commit 10e628a4d743cb0cfaa9bbd9c156c3e996570acf Merge: af0ed91... 8acb1fb... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 15 09:20:13 2010 -0400
Merge branch 'master' into master-jay
commit af0ed9107e4e39ffd14ce345a166ccb466e690a7 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 15 09:16:50 2010 -0400
Added selenium hooks to MessageCenter
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java index 39364d8..7b6d850 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java @@ -46,7 +46,8 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/** * @author Greg Hinkle @@ -66,7 +67,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter super.onDraw(); CoreGUI.getMessageCenter().addMessageListener(this);
- final Menu recentEventsMenu = new Menu(); + final Menu recentEventsMenu = new LocatableMenu(this.extendLocatorId("Messages"));
IMenuButton recentEventsButton = new LocatableIMenuButton(extendLocatorId("RecentEvents"), "Messages", recentEventsMenu); @@ -99,7 +100,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter } });
- VLayout vl = new LocatableVLayout(extendLocatorId("Alignment")); + VLayout vl = new VLayout(); vl.setAutoWidth(); vl.setAlign(Alignment.LEFT); vl.setAlign(VerticalAlignment.CENTER); @@ -136,7 +137,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
form.setItems(title, severity, date, detail, okButton);
- final Window window = new Window(); + final Window window = new LocatableWindow(this.extendLocatorId("Message")); window.setTitle(message.title); window.setWidth(600); window.setHeight(400);
commit 354316f55b57cef67a424b58acfb475ff95ea27f Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 15 09:16:30 2010 -0400
Added support for enabling or disabling our selenium locatorIds via the coreGui url. We now look for url param:
enableLocators=true|false
If true we enable the use of our explicit locatorIds to be used as selenium hooks. If false, or omitted, we run with default Ids and will not be selenium-ready.
To support this from the maven command line and our eclipse external tools config you can now specify the 'coreGuiParams' property. I've added a new eclipse ext tools config called 'Run GWT DevMode-JPDA-Params' that specifies -D$coreGuiParams=?enableLocators=true.
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA-Params.launch b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA-Params.launch new file mode 100644 index 0000000..9791adc --- /dev/null +++ b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA-Params.launch @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"> +<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.ui.externaltools.launchGroup"/> +</listAttribute> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true gwt:debug -DcoreGuiParams=?enableLocators=true"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/enterprise/gui/coregui}"/> +</launchConfiguration> diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index 2d92aba..fd24857 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -235,7 +235,7 @@ <inplace>false</inplace> <!-- <logLevel>INFO' -bindAddress 0.0.0.0 -logLevel 'INFO</logLevel> --> <logLevel>INFO</logLevel> - <runTarget>http://localhost:7080/coregui/CoreGUI.html</runTarget> + <runTarget>http://localhost:7080/coregui/CoreGUI.html$%7BcoreGuiParams%7D</runTarget> <extraJvmArgs>${gwt-plugin.extraJvmArgs}</extraJvmArgs> <localWorkers>${gwt-plugin.localWorkers}</localWorkers> <draftCompile>true</draftCompile> diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index 77cc196..34d1621 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -31,6 +31,7 @@ import com.google.gwt.http.client.URL; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.History; import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; import com.smartgwt.client.core.KeyIdentifier; @@ -60,6 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler; import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility; import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter; import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences; +import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * @author Greg Hinkle @@ -103,11 +105,17 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { private static ProductInfo productInfo;
public void onModuleLoad() { - if (GWT.getHostPageBaseURL().indexOf("/coregui/") == -1) { + String hostPageBaseURL = GWT.getHostPageBaseURL(); + if (hostPageBaseURL.indexOf("/coregui/") == -1) { System.out.println("Suppressing load of CoreGUI module"); return; // suppress loading this module if not using the new GWT app }
+ String enableLocators = Location.getParameter("enableLocators"); + if ((null != enableLocators) && Boolean.parseBoolean(enableLocators)) { + SeleniumUtility.setUseDefaultIds(false); + } + coreGUI = this;
if (!GWT.isScript()) { @@ -358,7 +366,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { String currentViewPath = History.getToken(); if (currentViewPath.equals(viewPath)) { // We're already there - just refresh the view. - refresh(); + refresh(); } else { if (viewPath.matches("(Resource|ResourceGroup)/[^/]*")) { // e.g. "Resource/10001" diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java index e4b60bc..223d0d6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java @@ -17,11 +17,15 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; */ public class SeleniumUtility {
- private static final boolean USE_DEFAULT_IDS = true; - /** A default id that is not ecommended as it will clash with any other element set to the default */ public static final String DEFAULT_ID = "DefaultID";
+ /** + * When true ignore any explicit locatorId assignment and use the standard + * ids generated by smartgwt. + */ + private static boolean useDefaultIds = true; + /** * A utility for assigning an ID to a smartgwt widget. Any current ID will be overwritten. The algorithm is: * <pre> @@ -30,7 +34,7 @@ public class SeleniumUtility { * @return the updated widget */ static public <T extends BaseWidget> T setID(final T widget, String locatorId) { - if (USE_DEFAULT_IDS) { + if (useDefaultIds) { return widget; }
@@ -84,7 +88,7 @@ public class SeleniumUtility { * @return the updated uiObject */ static public <T extends UIObject> T setHtmlId(final T uiObject, String unsafeId) { - if (USE_DEFAULT_IDS) { + if (useDefaultIds) { return uiObject; }
@@ -143,7 +147,7 @@ public class SeleniumUtility { }
static public boolean isUseDefaultIds() { - return USE_DEFAULT_IDS; + return useDefaultIds; }
/** @@ -157,4 +161,13 @@ public class SeleniumUtility { currentMember.destroy(); } } + + public static boolean getUseDefaultIds() { + return SeleniumUtility.useDefaultIds; + } + + public static void setUseDefaultIds(boolean useDefaultIds) { + SeleniumUtility.useDefaultIds = useDefaultIds; + } + }
commit 8acb1fb31579eeeaf3283af315183383eae53f01 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 08:05:25 2010 -0400
use locatable window to facilitate selenium testing
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index 7b85eae..6a3c6f0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -43,6 +43,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/** * @author John Mazzitelli @@ -92,7 +93,8 @@ public class ConditionsEditor extends LocatableVLayout { table.addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() { @Override public void executeAction(ListGridRecord[] selection) { - final Window winModal = new Window(); + final Window winModal = new LocatableWindow(ConditionsEditor.this + .extendLocatorId("newConditionEditorWindow")); winModal.setTitle("Add Condition"); winModal.setOverflow(Overflow.VISIBLE); winModal.setShowMinimizeButton(false);
commit 6efe82d30d878ec3eb3e9eb6947adbe7b0cfd932 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 15 07:58:48 2010 -0400
opps... don't use bit op, need AND logical op
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index bd20b0a..fceb893 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -88,7 +88,7 @@ public class NewConditionEditor extends LocatableDynamicForm { this.okFunction = okFunc; this.resourceType = rtype;
- this.supportsEvents = (rtype.getEventDefinitions() != null & rtype.getEventDefinitions().size() > 0); + this.supportsEvents = (rtype.getEventDefinitions() != null && rtype.getEventDefinitions().size() > 0);
Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions(); if (metricDefinitions != null && metricDefinitions.size() > 0) {
commit 0807155b735ae33c21b69df4758d7f031d4a28a0 Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 14 20:11:07 2010 -0400
fix potential cast exception when sp[ecified metric collection interval is larger than Integer.MAX
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java index 9b68f39..c00175a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java @@ -87,7 +87,7 @@ public abstract class AbstractMeasurementScheduleListView extends Table { return ""; }
- long milliseconds = (Integer) value; + long milliseconds = ((Number) value).longValue(); if (milliseconds == 0) { return "0"; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java index 78fe1d3..bef5806 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java @@ -37,7 +37,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
/** - * Widget for updating the collection intervals on the selected metrics. It displays two form fields for + * Widget for updating the collection intervals for the selected metrics. It displays two form fields for * entering the interval and the interval's units (seconds, minutes, or hours), as well as a Set button * for submitting the update. *
commit 2a60df38568690f9b2b6a555e212c3a6934ea011 Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 14 20:08:22 2010 -0400
add support for lofs and tmpfs filesystems on Solaris (https://bugzilla.redhat.com/show_bug.cgi?id=553034)
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java index b7960c2..a12d556 100644 --- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java +++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. + * Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -22,7 +22,7 @@ */ package org.rhq.plugins.platform;
-import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set;
import org.apache.commons.logging.Log; @@ -38,14 +38,16 @@ import org.rhq.core.system.SystemInfo;
/** * @author Greg Hinkle + * @author Ian Springer */ +@SuppressWarnings({"UnusedDeclaration"}) public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent<PlatformComponent> { private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PlatformComponent> discoveryContext) throws Exception {
- Set<DiscoveredResourceDetails> results = new HashSet<DiscoveredResourceDetails>(); + Set<DiscoveredResourceDetails> results = new LinkedHashSet<DiscoveredResourceDetails>();
SystemInfo sysInfo = discoveryContext.getSystemInformation(); if (!sysInfo.isNative()) { @@ -54,22 +56,30 @@ public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent< return results; }
- String hostname = discoveryContext.getSystemInformation().getHostname(); - - for (FileSystemInfo fs : sysInfo.getFileSystems()) { - int fsType = fs.getFileSystem().getType(); - if (fsType != FileSystem.TYPE_LOCAL_DISK && fsType != FileSystem.TYPE_NETWORK) { - continue; + for (FileSystemInfo fsInfo : sysInfo.getFileSystems()) { + FileSystem fs = fsInfo.getFileSystem(); + int fsType = fs.getType(); + // We only support local, network (nfs), lofs, or tmpfs filesystems - skip any other types. + switch (fsType) { + case FileSystem.TYPE_LOCAL_DISK: + case FileSystem.TYPE_NETWORK: + break; + default: + if (!(fs.getDevName().equals("lofs") || + fs.getDevName().equals("tmpfs"))) { + continue; + } } + Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration(); try { - String key = fs.getMountPoint(); + String key = fsInfo.getMountPoint(); DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(), - key, key, null, fs.getFileSystem().getDevName() + ": " - + fs.getFileSystem().getDirName(), pluginConfig, null); + key, key, null, fsInfo.getFileSystem().getDevName() + ": " + + fsInfo.getFileSystem().getDirName(), pluginConfig, null); results.add(details); } catch (Exception e) { - log.error("File system discovery failed: " + e + ", skipping."); + log.error("File system discovery failed for [" + fsInfo + "]: " + e); } } return results;
commit 497f3d6b13ef46643d68a09bcd46adac121e1b3f Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 13:06:17 2010 -0400
remove unused private inner class
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java index 1925c37..583fe36 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java @@ -57,14 +57,8 @@ public class ResourceGroupComposite implements Serializable { @XmlTransient private ResourcePermission resourcePermission;
- private class GroupDefinitionMember extends ResourceGroup { - public void setGroupCategory(GroupCategory category) { - super.setGroupCategory(category); - } - } - //def no args constructor for JAXB - private ResourceGroupComposite() { + public ResourceGroupComposite() { }
public ResourceGroupComposite(Long explicitCount, Double explicitAvailability, Long implicitCount,
commit ad54a80ad2a1737a960111f226f97f92b984c561 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 13:05:59 2010 -0400
add serialVersionUID to all objects in core/domain missing it
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java index 7e2c87d..b3ac785 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java @@ -45,6 +45,9 @@ import org.rhq.core.domain.resource.group.ResourceGroup; @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONFIG_GROUP_UPDATE_ID_SEQ") @Table(name = "RHQ_CONFIG_GROUP_UPDATE") public abstract class AbstractGroupConfigurationUpdate extends AbstractConfigurationUpdate implements Serializable { + + private static final long serialVersionUID = 1L; + @GeneratedValue(generator = "SEQ", strategy = GenerationType.AUTO) @Id private int id; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java index 2165b34..5b4aca1 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java @@ -35,6 +35,8 @@ import org.rhq.core.domain.content.PackageDetailsKey; */ public class ResourcePackageDetails extends PackageDetails {
+ private static final long serialVersionUID = 1L; + /** * Values the plugin should use when installing this package. */ diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java index 0ff464a..6ef2ce6 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java @@ -27,23 +27,27 @@ import org.rhq.core.domain.tagging.Tag; /** * @author Greg Hinkle */ +@SuppressWarnings("unused") public abstract class TaggedCriteria extends Criteria {
+ private static final long serialVersionUID = 1L; + private Tag filterTag;
private boolean fetchTags;
- protected TaggedCriteria() {
String entityName = getPersistentClass().getName(); - entityName = entityName.substring(entityName.lastIndexOf(".")+1); - - filterOverrides.put("tag", "id IN (SELECT taggedEntity.id FROM " + entityName + " taggedEntity JOIN taggedEntity.tags tag \n " + - " WHERE \n" + - " (tag.namespace LIKE :tagNamespace OR :tagNamespace IS NULL ) AND \n" + // first '?' will get ordinal 1 - " (tag.semantic LIKE :tagSemantic OR :tagSemantic IS NULL ) AND \n" + // second '?' will get ordinal 2 - " (tag.name LIKE :tagName OR :tagName IS NULL ) )"); // third '?' will get ordinal 3 + entityName = entityName.substring(entityName.lastIndexOf(".") + 1); + + filterOverrides.put("tag", "" // + + "id IN ( SELECT taggedEntity.id \n" // + + " FROM " + entityName + " taggedEntity \n" // + + " JOIN taggedEntity.tags tag \n " // + + " WHERE (tag.namespace LIKE :tagNamespace OR :tagNamespace IS NULL ) \n" // first '?' will get ordinal 1 + + " AND (tag.semantic LIKE :tagSemantic OR :tagSemantic IS NULL ) \n" // second '?' will get ordinal 2 + + " AND (tag.name LIKE :tagName OR :tagName IS NULL ) )"); // third '?' will get ordinal 3 }
public void addFilterTagNamespace(String filterTagNamespace) { @@ -71,12 +75,10 @@ public abstract class TaggedCriteria extends Criteria { this.filterTag = tag; }
- public boolean isTagFiltered() { return this.filterTag != null; }
- public void fetchTags(boolean fetchTags) { this.fetchTags = fetchTags; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java b/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java index 6e99c4b..95e920d 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java @@ -24,7 +24,6 @@ package org.rhq.core.domain.dashboard;
import java.io.Serializable; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; @@ -64,6 +63,8 @@ import org.rhq.core.domain.configuration.PropertySimple; @XmlRootElement public class Dashboard implements Serializable {
+ private static final long serialVersionUID = 1L; + @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "RHQ_DASHBOARD_ID_SEQ") @Id @@ -72,36 +73,27 @@ public class Dashboard implements Serializable { @Column(name = "NAME", nullable = false) private String name;
- @Column(name = "SHARED", nullable = false) private boolean shared = false;
- @JoinColumn(name = "CONFIGURATION_ID", referencedColumnName = "ID") @OneToOne(cascade = { CascadeType.ALL }) private Configuration configuration = new Configuration();
- - @JoinColumn(name = "SUBJECT_ID", nullable = false) @ManyToOne(fetch = FetchType.LAZY) private Subject owner;
- @OneToMany(mappedBy = "dashboard", fetch = FetchType.EAGER) - @Cascade( { org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) + @Cascade({ org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE, + org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) private Set<DashboardPortlet> portlets = new HashSet<DashboardPortlet>();
- - - public static final String CFG_COLUMNS = "columns"; public static final String CFG_WIDTHS = "widths"; public static final String CFG_BACKGROUND = "background"; public static final String CFG_REFRESH_RATE = "refresh";
- - public int getId() { return id; } @@ -180,8 +172,6 @@ public class Dashboard implements Serializable { return columnPortlets; }
- - public boolean removePortlet(DashboardPortlet storedPortlet) { return portlets.remove(storedPortlet); } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java b/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java index 38b455a..5562dbe 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java @@ -51,6 +51,7 @@ import org.rhq.core.domain.configuration.Configuration; @XmlRootElement public class DashboardPortlet implements Serializable {
+ private static final long serialVersionUID = 1L;
@Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "RHQ_DASHBOARD_PORTLET_ID_SEQ") @@ -80,7 +81,6 @@ public class DashboardPortlet implements Serializable { @JoinColumn(name = "DASHBOARD_ID", nullable = false) private Dashboard dashboard;
- public DashboardPortlet() { }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java index 9552e31..e18df58 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java @@ -25,6 +25,9 @@ package org.rhq.core.domain.operation.composite; import org.rhq.core.domain.operation.OperationRequestStatus;
public class GroupOperationLastCompletedComposite extends OperationLastCompletedComposite { + + private static final long serialVersionUID = 1L; + private final int groupId; private final String groupName; private final String groupResourceTypeName; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java index ee0f103..b5fba55 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java @@ -30,6 +30,9 @@ import org.rhq.core.domain.operation.ScheduleJobId; * @author John Mazzitelli */ public class GroupOperationScheduleComposite extends OperationScheduleComposite { + + private static final long serialVersionUID = 1L; + private final int groupId; private final String groupName; private final String groupResourceTypeName; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java index 5add81b..0b8bfbd 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java @@ -25,6 +25,9 @@ package org.rhq.core.domain.operation.composite; import org.rhq.core.domain.operation.OperationRequestStatus;
public class ResourceOperationLastCompletedComposite extends OperationLastCompletedComposite { + + private static final long serialVersionUID = 1L; + private int resourceId; private String resourceName; private String resourceTypeName; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java index 4185035..a0996a7 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java @@ -25,6 +25,9 @@ package org.rhq.core.domain.operation.composite; import org.rhq.core.domain.operation.ScheduleJobId;
public class ResourceOperationScheduleComposite extends OperationScheduleComposite { + + private static final long serialVersionUID = 1L; + private int resourceId; private String resourceName; private String resourceTypeName; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java index 0d568d4..1e2af92 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java @@ -68,7 +68,9 @@ import org.rhq.core.domain.content.InstalledPackage; @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CREATE_RES_HIST_ID_SEQ") @Table(name = "RHQ_CREATE_RES_HIST") public class CreateResourceHistory implements Serializable { + // Constants -------------------------------------------- + private static final long serialVersionUID = 1L;
public static final String QUERY_FIND_WITH_STATUS = "CreateResourceHistory.findWithStatus"; public static final String QUERY_FIND_BY_PARENT_RESOURCE_ID = "CreateResourceHistory.findByParentResourceId"; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java index decafe2..375c79d 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java @@ -30,6 +30,9 @@ import java.io.Serializable; * @author Ian Springer */ public class InventorySummary implements Serializable { + + private static final long serialVersionUID = 1L; + private int platformCount; private int serverCount; private int serviceCount; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java index b31fb5b..2770b70 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java @@ -30,6 +30,8 @@ import org.rhq.core.domain.measurement.AvailabilityType; */ public class ResourceAvailabilitySummary implements Serializable {
+ private static final long serialVersionUID = 1L; + long upTime; long downTime; int failures; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java index bf2c7ca..c3fef6c 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java @@ -26,6 +26,8 @@ import org.rhq.core.domain.resource.Resource;
public class ResourceIdFlyWeight extends Resource {
+ private static final long serialVersionUID = 1L; + public ResourceIdFlyWeight(int id, String uuid) { super(id); setUuid(uuid); diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java index 5878192..5c0f0e7 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java @@ -18,15 +18,17 @@ */ package org.rhq.core.domain.resource.composite;
-import org.rhq.core.domain.resource.ResourceCategory; - import java.io.Serializable;
+import org.rhq.core.domain.resource.ResourceCategory; + /** * @author Greg Hinkle */ public class ResourceInstallCount implements Serializable {
+ private static final long serialVersionUID = 1L; + private long count; private String typeName; private String typePlugin; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java index f57608d..5b7a9a6 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java @@ -22,7 +22,6 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List;
- /** * A ClusterKey represents an AutoCluster of resources in a Cluster Hierarchy. Given the key it is * possible to determine specific membership of the AutoCluster at any time. It represents the Cluster @@ -47,7 +46,6 @@ public class ClusterKey implements Serializable {
private static final long serialVersionUID = 1L;
- static final String DELIM = ":"; static final String DELIM_NODE = "::";
@@ -57,7 +55,6 @@ public class ClusterKey implements Serializable { private String key = null; private String namedKey = null;
- public ClusterKey() { }
@@ -80,12 +77,10 @@ public class ClusterKey implements Serializable {
this.clusterGroupId = parentKey.getClusterGroupId(); this.hierarchy = new ArrayList<ClusterKey.Node>(rootClusterNodes); //.size() + 1); -// Collections.copy(this.hierarchy, rootClusterNodes); + // Collections.copy(this.hierarchy, rootClusterNodes); this.hierarchy.add(new ClusterKey.Node(childResourceTypeId, childResourceKey)); }
- - public int getClusterGroupId() { return clusterGroupId; } @@ -146,7 +141,6 @@ public class ClusterKey implements Serializable { return getKey(); }
- public static ClusterKey valueOf(String clusterKey) { ClusterKey result = null;
@@ -182,15 +176,17 @@ public class ClusterKey implements Serializable { return nodes.get(nodes.size() - 1).getResourceTypeId(); }
- @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ClusterKey)) return false; + if (this == o) + return true; + if (!(o instanceof ClusterKey)) + return false;
ClusterKey that = (ClusterKey) o;
- if (!getKey().equals(that.getKey())) return false; + if (!getKey().equals(that.getKey())) + return false;
return true; } @@ -237,8 +233,9 @@ public class ClusterKey implements Serializable { }
private String encode(String info) { - return info.replace(":","%3a"); + return info.replace(":", "%3a"); } + private String decode(String code) { return code.replace("%3a", ":"); } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java index a156804..5e2e207 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java @@ -25,13 +25,13 @@ package org.rhq.core.domain.resource.group.composite; import java.io.Serializable; import java.util.List;
-import org.rhq.core.domain.resource.group.ClusterKey; - /** * @author Greg Hinkle */ public class ClusterFlyweight implements Serializable {
+ private static final long serialVersionUID = 1L; + private int groupId;
private ClusterKeyFlyweight clusterKey; @@ -89,11 +89,4 @@ public class ClusterFlyweight implements Serializable { return children; }
- - - - - - - } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java index e546614..7ed08db 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java @@ -29,6 +29,8 @@ import java.io.Serializable; */ public class ClusterKeyFlyweight implements Serializable {
+ private static final long serialVersionUID = 1L; + private int resourceTypeId; private String resourceKey;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java index 1804daa..57084e2 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java @@ -29,17 +29,25 @@ import org.rhq.core.domain.tagging.Tag; */ public class TagReportComposite extends Tag {
+ private static final long serialVersionUID = 1L; + private Tag tag; - private long total, resourceCount, resourceGroupCount, bundleCount, bundleVersionCount, bundleDeploymentCount, bundleDestinationCount; + private long total; + private long resourceCount; + private long resourceGroupCount; + private long bundleCount; + private long bundleVersionCount; + private long bundleDeploymentCount; + private long bundleDestinationCount;
public TagReportComposite() { }
- public TagReportComposite(int id, String namespace, String semantic, String name, - long total, - long resourceCount, long resourceGroupCount, long bundleCount, long bundleVersionCount, long bundleDeploymentCount, long bundleDestinationCount) { - tag = new Tag(namespace, semantic, name); - tag.setId(id); + public TagReportComposite(int id, String namespace, String semantic, String name, long total, long resourceCount, + long resourceGroupCount, long bundleCount, long bundleVersionCount, long bundleDeploymentCount, + long bundleDestinationCount) { + this.tag = new Tag(namespace, semantic, name); + this.tag.setId(id); this.total = total; this.resourceCount = resourceCount; this.resourceGroupCount = resourceGroupCount; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java index cd6874f..b26aead 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java @@ -7,6 +7,9 @@ package org.rhq.core.domain.util; * @author Ian Springer */ public class UnlimitedPageControl extends PageControl { + + private static final long serialVersionUID = 1L; + public UnlimitedPageControl() { this(new OrderingField[0]); } @@ -22,7 +25,8 @@ public class UnlimitedPageControl extends PageControl {
@Override public void setPageSize(int pageSize) { - throw new UnsupportedOperationException("page size cannot be changed from " + SIZE_UNLIMITED + " for an UnlimitedPageControl."); + throw new UnsupportedOperationException("page size cannot be changed from " + SIZE_UNLIMITED + + " for an UnlimitedPageControl."); }
@Override @@ -30,5 +34,4 @@ public class UnlimitedPageControl extends PageControl { getOrderingFields().clear(); }
- }
commit 583812edd609d72048b452ef01df9bf1de65e20e Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 13:00:21 2010 -0400
remove unused deprecated methods
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java index 03dd41b..3237c49 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java @@ -49,7 +49,11 @@ public class RoleCriteria extends Criteria { private PageOrdering sortName;
public RoleCriteria() { - filterOverrides.put("subjectId", "id in (select sr.id from Role sr JOIN sr.subjects s where s.id = :id)"); + filterOverrides.put("subjectId", "" // + + "id IN ( SELECT innerRole.id " // + + " FROM Role innerRole " // + + " JOIN innerRole.subjects innerSubject " // + + " WHERE innerSubject.id = ? )"); }
@Override @@ -106,81 +110,4 @@ public class RoleCriteria extends Criteria { public boolean isSecurityManagerRequired() { return (this.fetchSubjects || this.fetchResourceGroups); } - - /** - * @Deprecated use addFilterId - */ - @Deprecated - public void setFilterId(Integer filterId) { - this.filterId = filterId; - } - - /** - * @Deprecated use addFilterName - */ - @Deprecated - public void setFilterName(String filterName) { - this.filterName = filterName; - } - - /** - * @Deprecated use addFilterDescription - */ - @Deprecated - public void setFilterDescription(String filterDescription) { - this.filterDescription = filterDescription; - } - - @Deprecated - public Integer getFilterId() { - return this.filterId; - } - - @Deprecated - public boolean getFetchSubjects() { - return this.fetchSubjects; - } - - /** - * Requires MANAGE_SECURITY - * @param fetchSubjects - * @Deprecated use fetchSubjects - */ - @Deprecated - public void setFetchSubjects(boolean fetchSubjects) { - this.fetchSubjects = fetchSubjects; - } - - /** - * @Deprecated use fetchResourceGroups - */ - @Deprecated - public void setFetchResourceGroups(boolean fetchResourceGroups) { - this.fetchResourceGroups = fetchResourceGroups; - } - - /** - * @Deprecated use fetchPermissions - */ - @Deprecated - public void setFetchPermissions(boolean fetchPermissions) { - this.fetchPermissions = fetchPermissions; - } - - /** - * @Deprecated use fetchRoleNotifications - */ - @Deprecated - public void setFetchRoleNotifications(boolean fetchRoleNotifications) { - this.fetchRoleNotifications = fetchRoleNotifications; - } - - /** - * @Deprecated use addSortName - */ - @Deprecated - public void setSortName(PageOrdering sortName) { - addSortField("name"); - this.sortName = sortName; - } }
commit 1f6af685b55276fb7568abd334300de9b15ada32 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 12:59:52 2010 -0400
add the ability to filter SubjectCriteria by roleId
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java index e6e1780..4e9418c 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java @@ -45,6 +45,7 @@ public class SubjectCriteria extends Criteria { private String filterPhoneNumber; private String filterDepartment; private Boolean filterFactive; + private Integer filterRoleId;
private boolean fetchConfiguration; private boolean fetchRoles; @@ -58,6 +59,11 @@ public class SubjectCriteria extends Criteria { private PageOrdering sortDepartment;
public SubjectCriteria() { + filterOverrides.put("roleId", "" // + + "id IN ( SELECT innerSubject.id " // + + " FROM Subject innerSubject " // + + " JOIN innerSubject.roles innerRole " // + + " WHERE innerRole.id = ? )"); }
@Override @@ -101,6 +107,10 @@ public class SubjectCriteria extends Criteria { this.filterFactive = filterFactive; }
+ public void addFilterRoleId(Integer filterRoleId) { + this.filterRoleId = filterRoleId; + } + public void fetchConfiguration(boolean fetchConfiguration) { this.fetchConfiguration = fetchConfiguration; }
commit e92400fbdfb51149eb3444580c80d3113a13a0f6 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 12:59:35 2010 -0400
get use of generics for getPersisttentClass method on Criteria classes
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java index a605adf..9470937 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java @@ -29,8 +29,8 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement;
-import org.rhq.core.domain.alert.AlertPriority; import org.rhq.core.domain.alert.Alert; +import org.rhq.core.domain.alert.AlertPriority; import org.rhq.core.domain.util.PageOrdering;
/** @@ -100,7 +100,7 @@ public class AlertCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<Alert> getPersistentClass() { return Alert.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java index 298a6e5..5c84c62 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java @@ -71,7 +71,7 @@ public class AlertDefinitionCriteria extends Criteria { }
@Override - public Class<?> getPersistentClass() { + public Class<AlertDefinition> getPersistentClass() { return AlertDefinition.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java index e52333f..35c9367 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java @@ -71,7 +71,7 @@ public class BundleCriteria extends TaggedCriteria { }
@Override - public Class<?> getPersistentClass() { + public Class<Bundle> getPersistentClass() { return Bundle.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java index 66d85c2..9e613c6 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java @@ -60,7 +60,7 @@ public class BundleDeploymentCriteria extends TaggedCriteria { }
@Override - public Class<?> getPersistentClass() { + public Class<BundleDeployment> getPersistentClass() { return BundleDeployment.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java index 62a42f8..dcd99d8 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java @@ -23,7 +23,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement;
-import org.rhq.core.domain.bundle.BundleDeployment; import org.rhq.core.domain.bundle.BundleDeploymentStatus; import org.rhq.core.domain.bundle.BundleDestination;
@@ -45,22 +44,19 @@ public class BundleDestinationCriteria extends TaggedCriteria { private String filterDeployDir; private Integer filterGroupId; // needs override
- private boolean fetchBundle; private boolean fetchDeployments; private boolean fetchGroup;
public BundleDestinationCriteria() { - filterOverrides.put("bundleId", "bundle.id = ?"); filterOverrides.put("bundleVersionId", "deployments.bundleVersion.id = ?"); filterOverrides.put("status", "deployment.status like ?"); filterOverrides.put("groupId", "group.id = ?"); - }
@Override - public Class<?> getPersistentClass() { + public Class<BundleDestination> getPersistentClass() { return BundleDestination.class; }
@@ -84,12 +80,10 @@ public class BundleDestinationCriteria extends TaggedCriteria { this.filterDescription = filterDescription; }
- public void addFilterBundleVersionId(Integer filterBundleVersionId) { this.filterBundleVersionId = filterBundleVersionId; }
- public void addFilterGroupId(Integer filterGroupId) { this.filterGroupId = filterGroupId; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java index 130b2b6..26f2b3e 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java @@ -42,8 +42,6 @@ public class BundleFileCriteria extends Criteria { private boolean fetchPackageVersion;
public BundleFileCriteria() { - super(); - filterOverrides.put("bundleVersionId", "bundleVersion.id = ?"); filterOverrides.put("packageVersionId", "packageVersion.id = ?"); } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java index 4e38e46..98f77c1 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java @@ -53,7 +53,7 @@ public class BundleResourceDeploymentCriteria extends Criteria { }
@Override - public Class<?> getPersistentClass() { + public Class<BundleResourceDeployment> getPersistentClass() { return BundleResourceDeployment.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java index c4240b4..bf8b885 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java @@ -52,7 +52,7 @@ public class BundleVersionCriteria extends TaggedCriteria { }
@Override - public Class<?> getPersistentClass() { + public Class<BundleVersion> getPersistentClass() { return BundleVersion.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java index 8156d9a..8d0116e 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java @@ -59,7 +59,7 @@ public class CallTimeDataCriteria extends Criteria { private PageOrdering sortCount; // requires overrides
@Override - public Class<?> getPersistentClass() { + public Class<CallTimeDataValue> getPersistentClass() { return CallTimeDataValue.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java index d4e3fcb..4ad0376 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java @@ -64,7 +64,6 @@ public abstract class Criteria implements Serializable { private String searchExpression;
public Criteria() { - this.filterOverrides = new HashMap<String, String>(); this.sortOverrides = new HashMap<String, String>();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java index f4db72d..9aa52fd 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java @@ -83,7 +83,7 @@ public class EventCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<Event> getPersistentClass() { return Event.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java index e3fb715..1e5c91a 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java @@ -44,7 +44,7 @@ public class GroupOperationHistoryCriteria extends OperationHistoryCriteria { }
@Override - public Class getPersistentClass() { + public Class<GroupOperationHistory> getPersistentClass() { return GroupOperationHistory.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java index 34fb9f9..bf9ba40 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java @@ -3,8 +3,8 @@ package org.rhq.core.domain.criteria; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType;
-import org.rhq.core.domain.util.PageOrdering; import org.rhq.core.domain.content.InstalledPackage; +import org.rhq.core.domain.util.PageOrdering;
@XmlAccessorType(XmlAccessType.FIELD) @SuppressWarnings("unused") @@ -33,7 +33,7 @@ public class InstalledPackageCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<InstalledPackage> getPersistentClass() { return InstalledPackage.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java index 2f13722..10cdcea 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java @@ -22,12 +22,12 @@ */ package org.rhq.core.domain.criteria;
-import org.rhq.core.domain.measurement.MeasurementDataTrait; -import org.rhq.core.domain.util.PageOrdering; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait; +import org.rhq.core.domain.util.PageOrdering; + /** * RHQ {@link Criteria} object for filtered, sortable queries of {@link MeasurementDataTrait trait} data sets. * @@ -85,7 +85,7 @@ public class MeasurementDataTraitCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<MeasurementDataTrait> getPersistentClass() { return MeasurementDataTrait.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java index 2ce0f65..779e4c5 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java @@ -28,9 +28,9 @@ import javax.xml.bind.annotation.XmlAccessorType; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.DisplayType; import org.rhq.core.domain.measurement.MeasurementCategory; +import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.measurement.MeasurementUnits; import org.rhq.core.domain.measurement.NumericType; -import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.util.PageOrdering;
/** @@ -74,7 +74,7 @@ public class MeasurementDefinitionCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<MeasurementDefinition> getPersistentClass() { return MeasurementDefinition.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java index a4c8a09..3a2b130 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java @@ -100,7 +100,7 @@ public class MeasurementScheduleCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<MeasurementSchedule> getPersistentClass() { return MeasurementSchedule.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java index d66d118..854a561 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java @@ -28,8 +28,8 @@ import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType;
-import org.rhq.core.domain.util.PageOrdering; import org.rhq.core.domain.operation.OperationDefinition; +import org.rhq.core.domain.util.PageOrdering;
/** * @author Joseph Marques @@ -72,7 +72,7 @@ public class OperationDefinitionCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<OperationDefinition> getPersistentClass() { return OperationDefinition.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java index f54de21..5f879ea 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java @@ -26,9 +26,8 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType;
import org.rhq.core.domain.operation.JobId; -import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.core.domain.operation.OperationHistory; -import org.rhq.core.domain.operation.ResourceOperationHistory; +import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.core.domain.util.PageOrdering;
/** @@ -58,30 +57,26 @@ public abstract class OperationHistoryCriteria extends Criteria { private PageOrdering sortOperationName; // requires override
public OperationHistoryCriteria() { - init(); - } - - @Override - public Class getPersistentClass() { - return ResourceOperationHistory.class; - } - - private void init() { filterOverrides.put("operationDefinitionId", "operationDefinition.id = ?"); filterOverrides.put("operationName", "operationDefinition.name like ?"); filterOverrides.put("startTime", "startedTime >= ?"); filterOverrides.put("endTime", "modifiedTime <= ?");
filterOverrides.put("resourceIds", "id IN " // - + " ( SELECT roh.id " // - + " FROM ResourceOperationHistory roh " // - + " WHERE roh.resource.id IN ( ? ) ) "); + + " ( SELECT roh.id " // + + " FROM ResourceOperationHistory roh " // + + " WHERE roh.resource.id IN ( ? ) ) ");
sortOverrides.put("startTime", "startedTime"); sortOverrides.put("endTime", "modifiedTime"); sortOverrides.put("operationName", "operationDefinition.name"); }
+ @Override + public Class<? extends OperationHistory> getPersistentClass() { + return OperationHistory.class; + } + public void addFilterId(Integer filterId) { this.filterId = filterId; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java index 3e304b6..592cea1 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java @@ -51,7 +51,7 @@ public class PackageVersionCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<PackageVersion> getPersistentClass() { return PackageVersion.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java index 42e2ec8..60d23da 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java @@ -56,14 +56,15 @@ public class RepoCriteria extends Criteria {
public RepoCriteria() { filterOverrides.put("resourceIds", "resourceRepos.resource.id IN ( ? )"); - filterOverrides.put("contentSourceIds", - "id IN (SELECT innerRepo FROM Repo innerRepo " + - "JOIN innerRepo.repoContentSources rcs " + - "WHERE rcs.contentSource.id IN ( ? ))"); + filterOverrides.put("contentSourceIds", "" // + + "id IN ( SELECT innerRepo " // + + " FROM Repo innerRepo " // + + " JOIN innerRepo.repoContentSources rcs " // + + " WHERE rcs.contentSource.id IN ( ? ))"); }
@Override - public Class getPersistentClass() { + public Class<Repo> getPersistentClass() { return Repo.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java index 3ccab5d..adf2cbd 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java @@ -84,7 +84,7 @@ public class ResourceConfigurationUpdateCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<ResourceConfigurationUpdate> getPersistentClass() { return ResourceConfigurationUpdate.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java index a332b77..1eae4a3 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java @@ -125,8 +125,7 @@ public class ResourceCriteria extends TaggedCriteria { + " FROM Resource ires " // + " JOIN ires.implicitGroups implicitGroup " // + " WHERE implicitGroup.id IN ( ? ) )"); - filterOverrides.put("rootResourceId", - "agent.id = (SELECT r2.agent.id FROM Resource r2 where r2.id = ?)"); + filterOverrides.put("rootResourceId", "agent.id = (SELECT r2.agent.id FROM Resource r2 where r2.id = ?)");
sortOverrides.put("resourceTypeName", "resourceType.name"); sortOverrides.put("resourceCategory", "resourceType.category"); @@ -137,7 +136,7 @@ public class ResourceCriteria extends TaggedCriteria { }
@Override - public Class getPersistentClass() { + public Class<Resource> getPersistentClass() { return Resource.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java index 7544422..1a54f0f 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java @@ -115,7 +115,7 @@ public class ResourceGroupCriteria extends TaggedCriteria { }
@Override - public Class getPersistentClass() { + public Class<ResourceGroup> getPersistentClass() { return ResourceGroup.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java index 96925fb..356dabc 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java @@ -22,12 +22,12 @@ */ package org.rhq.core.domain.criteria;
-import org.rhq.core.domain.resource.group.GroupDefinition; -import org.rhq.core.domain.util.PageOrdering; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType;
+import org.rhq.core.domain.resource.group.GroupDefinition; +import org.rhq.core.domain.util.PageOrdering; + /** * @author Greg Hinkle */ @@ -36,7 +36,6 @@ import javax.xml.bind.annotation.XmlAccessorType; public class ResourceGroupDefinitionCriteria extends Criteria { private static final long serialVersionUID = 1L;
- private Integer filterId; private String filterName; private String filterDescription; @@ -50,13 +49,12 @@ public class ResourceGroupDefinitionCriteria extends Criteria { private PageOrdering sortRecursive; private PageOrdering sortExpression;
- public ResourceGroupDefinitionCriteria() {
}
@Override - public Class getPersistentClass() { + public Class<GroupDefinition> getPersistentClass() { return GroupDefinition.class; }
@@ -80,12 +78,10 @@ public class ResourceGroupDefinitionCriteria extends Criteria { this.filterExpression = filterExpression; }
- public void fetchManagedResourceGroups(boolean fetchManagedResourceGroups) { this.fetchManagedResourceGroups = fetchManagedResourceGroups; }
- public void addSortName(PageOrdering sortName) { addSortField("name"); this.sortName = sortName; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java index e1ab4c4..8e58e69 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java @@ -22,8 +22,6 @@ */ package org.rhq.core.domain.criteria;
-import org.rhq.core.domain.operation.ResourceOperationHistory; - import java.util.Arrays; import java.util.List;
@@ -31,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement;
+import org.rhq.core.domain.operation.ResourceOperationHistory; + /** * @author Joseph Marques */ @@ -49,7 +49,7 @@ public class ResourceOperationHistoryCriteria extends OperationHistoryCriteria { }
@Override - public Class getPersistentClass() { + public Class<ResourceOperationHistory> getPersistentClass() { return ResourceOperationHistory.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java index ba5f05e..93ba523 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java @@ -83,7 +83,7 @@ public class ResourceTypeCriteria extends Criteria { }
@Override - public Class<?> getPersistentClass() { + public Class<ResourceType> getPersistentClass() { return ResourceType.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java index a810df1..634dc15 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java @@ -65,7 +65,7 @@ public class SavedSearchCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<SavedSearch> getPersistentClass() { return SavedSearch.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java index 7c39c50..e6e1780 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java @@ -61,7 +61,7 @@ public class SubjectCriteria extends Criteria { }
@Override - public Class getPersistentClass() { + public Class<Subject> getPersistentClass() { return Subject.class; }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java index 2c93450..3e60bd0 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java @@ -46,13 +46,11 @@ public class TagCriteria extends Criteria { private PageOrdering sortSemantic; private PageOrdering sortName;
- @Override - public Class<?> getPersistentClass() { + public Class<Tag> getPersistentClass() { return Tag.class; }
- public void addFilterNamespace(String filterNamespace) { this.filterNamespace = filterNamespace; } @@ -65,7 +63,6 @@ public class TagCriteria extends Criteria { this.filterName = filterName; }
- public void addSortNamespace(PageOrdering sortNamespace) { addSortField("namespace"); this.sortNamespace = sortNamespace; @@ -81,6 +78,4 @@ public class TagCriteria extends Criteria { this.sortName = sortName; }
- - }
commit d139f3b79e62d87253e2ff846c1bde0a5b47afa7 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 12:57:02 2010 -0400
cosmetic
* remove sections headers, e.g. constants/attributes/constructor/public * remove unused imports * reorder import statements
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java index 26291fb..e50214b 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java @@ -19,7 +19,7 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table;
@Entity -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = Advisory.QUERY_FIND_ALL, query = "SELECT adv FROM Advisory adv"), @NamedQuery(name = Advisory.QUERY_FIND_BY_ADV, query = "SELECT adv " + " FROM Advisory adv " + " WHERE adv.advisory = :advisory "), @@ -44,12 +44,12 @@ import javax.persistence.Table; public class Advisory implements Serializable {
private static final long serialVersionUID = 1L; + public static final String QUERY_FIND_ALL = "Advisory.findAll"; public static final String QUERY_FIND_BY_ADV = "Advisory.findByAdv"; public static final String QUERY_DELETE_BY_ADV_ID = "Advisory.deleteByAdvId"; public static final String QUERY_FIND_COMPOSITE_BY_ID = "Advisory.queryFindCompositeByAdvId"; public static final String QUERY_FIND_BY_ADV_ID = "Advisory.queryFindByAdvId"; - // Attributes --------------------------------------------
@Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @@ -101,8 +101,6 @@ public class Advisory implements Serializable { @OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL) private Set<AdvisoryBuglist> advisorybugs;
- // Constructor ---------------------------------------- - public Advisory() { }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java index 40c2c36..f47ec44 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java @@ -43,15 +43,13 @@ import org.rhq.core.domain.resource.Resource; * @author Jason Dobies */ @Entity -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = Architecture.QUERY_FIND_BY_NAME, query = "SELECT arch FROM Architecture arch WHERE arch.name = :name"), @NamedQuery(name = Architecture.QUERY_FIND_ALL, query = "SELECT arch FROM Architecture arch"), - @NamedQuery(name = Architecture.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT arch.name, arch.name FROM Architecture arch") -}) + @NamedQuery(name = Architecture.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT arch.name, arch.name FROM Architecture arch") }) @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_ARCHITECTURE_ID_SEQ") @Table(name = "RHQ_ARCHITECTURE") public class Architecture implements Serializable { - // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
@@ -60,8 +58,6 @@ public class Architecture implements Serializable {
public static final String QUERY_DYNAMIC_CONFIG_VALUES = "Architecture.dynamicConfigValues";
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -70,8 +66,6 @@ public class Architecture implements Serializable { @Column(name = "NAME", nullable = false) private String name;
- // Constructor ---------------------------------------- - public Architecture() { // for JPA use } @@ -80,8 +74,6 @@ public class Architecture implements Serializable { setName(name); }
- // Public -------------------------------------------- - public int getId() { return id; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java index 72b0011..696796c 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java @@ -40,7 +40,7 @@ import javax.persistence.Table; */
@Entity -@NamedQueries( { @NamedQuery(name = CVE.DELETE_BY_CVE_ID, query = "DELETE CVE cve WHERE cve.id = :cveId"), +@NamedQueries({ @NamedQuery(name = CVE.DELETE_BY_CVE_ID, query = "DELETE CVE cve WHERE cve.id = :cveId"), @NamedQuery(name = CVE.FIND_BY_CVE_ID, query = "SELECT cve FROM CVE as cve WHERE cve.id = :cveId") }) @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CVE_ID_SEQ") @Table(name = "RHQ_CVE") @@ -50,8 +50,6 @@ public class CVE implements Serializable { public static final String FIND_BY_CVE_ID = "CVE.findByCVEId"; public static final String DELETE_BY_CVE_ID = "CVE.deleteByCVEId";
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -60,8 +58,6 @@ public class CVE implements Serializable { @Column(name = "NAME", nullable = false) private String name;
- // Constructor ---------------------------------------- - public CVE() { // for JPA use } @@ -70,8 +66,6 @@ public class CVE implements Serializable { this.name = name; }
- // Public -------------------------------------------- - public int getId() { return id; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java index 5d64d9c..de5bbe1 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java @@ -1,25 +1,25 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.domain.content;
/** @@ -33,20 +33,20 @@ public enum ContentRequestStatus { * state are subject to cleanup if they have been in this state for an extended period of time without a reply * from the agent. */ - IN_PROGRESS("In Progress"), + IN_PROGRESS("In Progress"), //
/** * Indicates the result has been returned from the agent and the plugin was able to execute the actions * described by the request. */ - SUCCESS("Success"), + SUCCESS("Success"), //
/** * Indicates the agent has responded to this request and indicated a failure occurred in either the agent, * plugin container, or plugin itself. An error message will be provided in the request to further describe * the failure. */ - FAILURE("Failure"), + FAILURE("Failure"), //
/** * Indicates the request was successfully sent to the agent, however a response was not received in a timely manner. @@ -55,18 +55,12 @@ public enum ContentRequestStatus { */ TIMED_OUT("Timed Out");
- // Attributes -------------------------------------------- - private String displayText;
- // Constructors -------------------------------------------- - ContentRequestStatus(String displayText) { this.displayText = displayText; // not very I18N'ish :) }
- // Object Overridden Methods -------------------------------------------- - @Override public String toString() { return displayText; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java index e7d50a3..dc8b1e1 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java @@ -1,25 +1,25 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.domain.content;
/** @@ -31,33 +31,27 @@ public enum ContentRequestType { /** * Request is to create/deploy new {@link Package}s to a resource. */ - DEPLOY("Deploy"), + DEPLOY("Deploy"), //
/** * Request is to delete {@link Package}s from a resource. */ - DELETE("Delete"), + DELETE("Delete"), //
/** * Request is to retrieve the content of {@link Package}s. */ GET_BITS("Retrieve Package Bits");
- // Attributes -------------------------------------------- - /** * Used by the user interface when rendering instances of this enumeration. */ private String displayName;
- // Constructors -------------------------------------------- - ContentRequestType(String displayName) { this.displayName = displayName; }
- // Object Overridden Methods -------------------------------------------- - @Override public String toString() { return displayName; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java index 101b61c..9569910 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java @@ -22,8 +22,6 @@ */ package org.rhq.core.domain.content;
-import java.io.ByteArrayOutputStream; -import java.io.PrintStream; import java.io.Serializable; import java.util.Date; import java.util.HashSet; @@ -58,7 +56,7 @@ import org.rhq.core.domain.resource.Resource; * @author Jason Dobies */ @Entity -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = ContentServiceRequest.QUERY_FIND_WITH_STATUS, query = "SELECT csr FROM ContentServiceRequest AS csr WHERE csr.status = :status"), @NamedQuery(name = ContentServiceRequest.QUERY_FIND_BY_RESOURCE_WITH_STATUS, query = "SELECT csr FROM ContentServiceRequest AS csr WHERE csr.resource.id = :resourceId AND csr.status = :status"), @NamedQuery(name = ContentServiceRequest.QUERY_FIND_BY_RESOURCE_WITH_NOT_STATUS, query = "SELECT csr FROM ContentServiceRequest AS csr WHERE csr.resource.id = :resourceId AND csr.status <> :status"), @@ -71,7 +69,6 @@ import org.rhq.core.domain.resource.Resource; @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONTENT_REQ_ID_SEQ") @Table(name = "RHQ_CONTENT_REQ") public class ContentServiceRequest implements Serializable { - // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
@@ -82,8 +79,6 @@ public class ContentServiceRequest implements Serializable { public static final String QUERY_FIND_BY_ID = "ContentServiceRequest.findById"; public static final String QUERY_DELETE_BY_RESOURCES = "ContentServiceRequest.deleteByResources";
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(generator = "SEQ", strategy = GenerationType.AUTO) @Id @@ -119,8 +114,6 @@ public class ContentServiceRequest implements Serializable { @OneToMany(mappedBy = "contentServiceRequest", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) private Set<InstalledPackageHistory> installedPackageHistory;
- // Constructors -------------------------------------------- - public ContentServiceRequest() { }
@@ -130,8 +123,6 @@ public class ContentServiceRequest implements Serializable { this.contentRequestType = contentRequestType; }
- // Public -------------------------------------------- - public int getId() { return id; } @@ -234,7 +225,6 @@ public class ContentServiceRequest implements Serializable { this.installedPackageHistory = installedPackageHistory; }
- /** * The duration of the configuration update request which simply is the difference between the * {@link #getCreatedTime()} and the {@link #getLastModifiedTime()}. If the request hasn't completed yet, this will @@ -253,15 +243,11 @@ public class ContentServiceRequest implements Serializable { return end - start; }
- // Package -------------------------------------------- - @PreUpdate void onUpdate() { this.mtime = System.currentTimeMillis(); }
- // Object Overridden -------------------------------------------- - @Override public int hashCode() { final int PRIME = 31; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java index 511da1a..00877bd 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java @@ -59,7 +59,7 @@ import org.rhq.core.domain.configuration.Configuration; * @author Jason Dobies */ @Entity -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = ContentSource.QUERY_FIND_ALL, query = "SELECT cs FROM ContentSource cs "), @NamedQuery(name = ContentSource.QUERY_FIND_ALL_WITH_CONFIG, query = "SELECT cs FROM ContentSource cs LEFT JOIN FETCH cs.configuration"), @NamedQuery(name = ContentSource.QUERY_FIND_BY_NAME_AND_TYPENAME, query = "SELECT cs " + " FROM ContentSource cs " @@ -86,12 +86,8 @@ public class ContentSource implements Serializable { public static final String QUERY_FIND_BY_REPO_ID = "ContentSource.findByRepoId"; public static final String QUERY_FIND_AVAILABLE_BY_REPO_ID = "ContentSource.findAvailableByRepoId";
- // Constants -------------------------------------------- - private static final long serialVersionUID = 1L;
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -138,8 +134,6 @@ public class ContentSource implements Serializable { @OneToMany(mappedBy = "contentSource", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) private Set<RepoContentSource> repoContentSources;
- // Constructor asdf - public ContentSource() { // for JPA use } @@ -149,8 +143,6 @@ public class ContentSource implements Serializable { this.contentSourceType = contentSourceType; }
- // Public -------------------------------------------- - public int getId() { return id; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java index a2d6142..5a046ab 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java @@ -54,7 +54,7 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; * @author Jason Dobies */ @Entity -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = ContentSourceType.QUERY_FIND_ALL, query = "SELECT cst " + " FROM ContentSourceType cst " + " LEFT JOIN FETCH cst.contentSourceConfigurationDefinition d " + " LEFT JOIN FETCH d.templates "), @NamedQuery(name = ContentSourceType.QUERY_FIND_BY_NAME_WITH_CONFIG_DEF, query = "SELECT cst " @@ -65,7 +65,6 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONTENT_SOURCE_TYPE_ID_SEQ") @Table(name = "RHQ_CONTENT_SOURCE_TYPE") public class ContentSourceType implements Serializable { - // Constants --------------------------------------------
public static final String QUERY_FIND_ALL = "ContentSourceType.findAll"; public static final String QUERY_FIND_BY_NAME_WITH_CONFIG_DEF = "ContentSourceType.findByNameWithConfigDef"; @@ -73,8 +72,6 @@ public class ContentSourceType implements Serializable {
private static final long serialVersionUID = 1L;
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -113,8 +110,6 @@ public class ContentSourceType implements Serializable { @OneToMany(mappedBy = "contentSourceType", fetch = FetchType.LAZY) private Set<ContentSource> contentSources;
- // Constructor ---------------------------------------- - public ContentSourceType() { // for JPA use } @@ -124,8 +119,6 @@ public class ContentSourceType implements Serializable { this.contentSourceApiClass = "undefined"; // TODO: I think we want this @Transient }
- // Public -------------------------------------------- - public int getId() { return id; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java index 5ae9acd..5d32c49 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java @@ -22,8 +22,8 @@ */ package org.rhq.core.domain.content;
-import org.hibernate.annotations.NamedQueries; -import org.hibernate.annotations.NamedQuery; +import java.io.Serializable; +import java.util.Set;
import javax.persistence.CascadeType; import javax.persistence.Column; @@ -40,15 +40,15 @@ import javax.persistence.PreUpdate; import javax.persistence.SequenceGenerator; import javax.persistence.Table;
-import java.io.Serializable; -import java.util.Set; +import org.hibernate.annotations.NamedQueries; +import org.hibernate.annotations.NamedQuery;
/** * * @author Pradeep Kilambi */ @Entity -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = Distribution.QUERY_FIND_ALL, query = "SELECT dt FROM Distribution dt"), @NamedQuery(name = Distribution.QUERY_FIND_PATH_BY_DIST_TYPE, query = "SELECT dt " + " FROM Distribution dt " + " WHERE dt.label = :label AND dt.distributionType.name = :typeName "), @@ -66,8 +66,6 @@ public class Distribution implements Serializable { public static final String QUERY_FIND_PATH_BY_DIST_TYPE = "Distribution.findPathByDistType"; public static final String QUERY_DELETE_BY_DIST_ID = "Distribution.deleteByDistId";
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -95,8 +93,6 @@ public class Distribution implements Serializable { @OneToMany(mappedBy = "distribution", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private Set<DistributionFile> distributionFiles;
- // Constructor ---------------------------------------- - public Set<DistributionFile> getDistributionFiles() { return distributionFiles; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java index 1bf02b8..40a4a26 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java @@ -46,7 +46,7 @@ import javax.xml.bind.annotation.XmlTransient; */ @Entity //@IdClass(DistributionFilePK.class) -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = DistributionFile.SELECT_BY_DIST_ID, query = "SELECT df from DistributionFile df WHERE df.distribution.id = :distId"), @NamedQuery(name = DistributionFile.DELETE_BY_DIST_ID, query = "DELETE DistributionFile df WHERE df.distribution.id = :distId") }) @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DISTRIBUTION_FILE_ID_SEQ") @@ -62,7 +62,6 @@ public class DistributionFile { * @IdClass and ignore these here, even though the mappings should be here and no mappings should be needed in the * @IdClass. */ - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -99,8 +98,6 @@ public class DistributionFile { this.distribution = pk.getDistribution(); }
- // Public -------------------------------------------- - public int getId() { return id; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java index 81adc75..135266c 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java @@ -29,10 +29,10 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table;
/** * Defines a type of (@link Distribution) @@ -44,8 +44,7 @@ import javax.persistence.NamedQuery; @Entity @NamedQueries({ @NamedQuery(name = DistributionType.QUERY_FIND_BY_NAME, query = "SELECT dt FROM DistributionType dt WHERE dt.name = :name"), - @NamedQuery(name = DistributionType.QUERY_DELETE_BY_NAME, query = "DELETE FROM DistributionType dt where dt.name = :name") -}) + @NamedQuery(name = DistributionType.QUERY_DELETE_BY_NAME, query = "DELETE FROM DistributionType dt where dt.name = :name") }) @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DISTRIBUTION_TYPE_ID_SEQ") @Table(name = "RHQ_DISTRIBUTION_TYPE") public class DistributionType implements Serializable { @@ -55,8 +54,6 @@ public class DistributionType implements Serializable { public static final String QUERY_FIND_BY_NAME = "DistributionType.findByName"; public static final String QUERY_DELETE_BY_NAME = "DistributionType.deleteByName";
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -68,8 +65,6 @@ public class DistributionType implements Serializable { @Column(name = "DESCRIPTION", nullable = true) private String description;
- // Constructor ---------------------------------------- - public DistributionType() { // for JPA use } @@ -78,8 +73,6 @@ public class DistributionType implements Serializable { this.name = name; }
- // Public -------------------------------------------- - public int getId() { return id; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java index 3fda3cc..1b79ffb 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java @@ -1,25 +1,25 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.domain.content;
/** @@ -31,12 +31,12 @@ public enum DownloadMode { * is a simple pass-through, where all requests pull down content * directly from the remote repository. */ - NEVER, + NEVER, //
/** * The package bits will be stored in the database. */ - DATABASE, + DATABASE, //
/** * The package bits will be stored in the file system. diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java index b7550f4..2bfc04f 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java @@ -46,7 +46,7 @@ import org.rhq.core.domain.resource.Resource; * @author Jason Dobies */ @Entity -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = InstalledPackage.QUERY_FIND_BY_SET_OF_IDS, query = "SELECT ip FROM InstalledPackage AS ip WHERE ip.id IN ( :packageIds )"), @NamedQuery(name = InstalledPackage.QUERY_FIND_BY_SET_OF_PACKAGE_VER_IDS, query = "SELECT ip FROM InstalledPackage AS ip WHERE ip.packageVersion.id IN ( :packageIds )"), @NamedQuery(name = InstalledPackage.QUERY_FIND_BY_RESOURCE_ID, query = "SELECT ip FROM InstalledPackage AS ip WHERE ip.resource.id = :resourceId"), @@ -89,8 +89,6 @@ public class InstalledPackage implements Serializable { public static final String QUERY_FIND_INSTALLED_PACKAGE_HISTORY = "InstalledPackage.findInstalledPackageHistory"; public static final String QUERY_DELETE_BY_RESOURCES = "InstalledPackage.deleteByResources";
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -111,14 +109,10 @@ public class InstalledPackage implements Serializable { @ManyToOne private Subject user;
- // Constructor ---------------------------------------- - public InstalledPackage() { // needed for JPA }
- // Public -------------------------------------------- - public int getId() { return id; } @@ -171,8 +165,6 @@ public class InstalledPackage implements Serializable { this.user = user; }
- // Object Overridden Methods -------------------------------------------- - @Override public String toString() { return "InstalledPackage[resource=" + resource.getName() + ",packageVersion=" + packageVersion.getDisplayName() diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java index 35ba747..9b21fe2 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java @@ -22,8 +22,6 @@ */ package org.rhq.core.domain.content;
-import java.io.ByteArrayOutputStream; -import java.io.PrintStream; import java.io.Serializable; import java.util.List;
@@ -56,7 +54,7 @@ import org.rhq.core.domain.resource.Resource; * @author Jason Dobies */ @Entity -@NamedQueries( { +@NamedQueries({ @NamedQuery(name = InstalledPackageHistory.QUERY_FIND_CONFIG_BY_PACKAGE_VERSION_AND_REQ, query = "SELECT dcv FROM InstalledPackageHistory iph JOIN iph.deploymentConfigurationValues dcv " + "WHERE iph.packageVersion = :packageVersion " + "AND iph.contentServiceRequest = :contentServiceRequest " @@ -77,7 +75,6 @@ import org.rhq.core.domain.resource.Resource; @SequenceGenerator(name = "SEQ", sequenceName = "RHQ_INSTALLED_PKG_HIST_ID_SEQ") @Table(name = "RHQ_INSTALLED_PKG_HIST") public class InstalledPackageHistory implements Serializable { - // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
@@ -89,8 +86,6 @@ public class InstalledPackageHistory implements Serializable { public static final String QUERY_FIND_BY_ID = "InstalledPackageHistory.findById"; public static final String QUERY_DELETE_BY_RESOURCES = "InstalledPackageHistory.deleteByResources";
- // Attributes -------------------------------------------- - @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ") @Id @@ -144,8 +139,6 @@ public class InstalledPackageHistory implements Serializable { @ManyToOne private ContentServiceRequest contentServiceRequest;
- // Public -------------------------------------------- - public int getId() { return id; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java index db349f3..772b6d7 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java @@ -30,7 +30,6 @@ import java.util.Set;
import org.rhq.core.domain.content.Advisory; import org.rhq.core.domain.content.AdvisoryBuglist; -import org.rhq.core.domain.content.AdvisoryCVE; import org.rhq.core.domain.content.AdvisoryPackage; import org.rhq.core.domain.content.PackageVersion; import org.rhq.core.domain.util.StringUtils; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java index 95a193e..76e886e 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java @@ -1,25 +1,25 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.domain.content.composite;
import java.io.Serializable; @@ -30,7 +30,8 @@ import java.io.Serializable; * @author Jason Dobies */ public class PackageListItemComposite implements Serializable { - // Attributes -------------------------------------------- + + private static final long serialVersionUID = 1L;
private final int id; private final String packageName; @@ -38,8 +39,6 @@ public class PackageListItemComposite implements Serializable { private final String version; private final Long timestamp;
- // Constructors -------------------------------------------- - public PackageListItemComposite(int id, String packageName, String packageTypeName, String version) { this.id = id; this.packageName = packageName; @@ -56,8 +55,6 @@ public class PackageListItemComposite implements Serializable { this.timestamp = timestamp; }
- // Public -------------------------------------------- - public int getId() { return id; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java index 1c7c416..982da7a 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java @@ -1,26 +1,26 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - package org.rhq.core.domain.content.transfer; +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.core.domain.content.transfer;
/** * Describes the result of a content operation executed on a plugin. @@ -28,10 +28,8 @@ * @author Jason Dobies */ public enum ContentResponseResult { - SUCCESS("Success"), - - FAILURE("Failed"), - + SUCCESS("Success"), // + FAILURE("Failed"), // NOT_PERFORMED("Not Performed");
private String displayName; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java index 096a0b3..61e9339 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java @@ -1,49 +1,45 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - package org.rhq.core.domain.content.transfer; +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.core.domain.content.transfer;
import java.io.Serializable; -import java.util.List; import java.util.ArrayList; +import java.util.List; + import org.rhq.core.domain.content.PackageDetailsKey; -import org.rhq.core.domain.content.transfer.ContentResponseResult; -import org.rhq.core.domain.content.transfer.DeployPackageStep; - - /** - * Contains the data necessary to describe the result of deploying a single package. The overall result of the package - * installation and any error message (if there is one) will convey whether or not the package was successfully - * installed. Additionally, if installation steps were determined for this package, they and their respective - * success/failure flags, will be contained in this object as well. - * - * @author Jason Dobies - */ + +/** +* Contains the data necessary to describe the result of deploying a single package. The overall result of the package +* installation and any error message (if there is one) will convey whether or not the package was successfully +* installed. Additionally, if installation steps were determined for this package, they and their respective +* success/failure flags, will be contained in this object as well. +* +* @author Jason Dobies +*/ public class DeployIndividualPackageResponse implements Serializable { - // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
- // Attributes -------------------------------------------- - private PackageDetailsKey key;
private ContentResponseResult result; @@ -51,8 +47,6 @@ public class DeployIndividualPackageResponse implements Serializable {
private List<DeployPackageStep> deploymentSteps;
- // Constructors -------------------------------------------- - public DeployIndividualPackageResponse(PackageDetailsKey key) { this.key = key; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java index fd5d9ba..57c62d1 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java @@ -1,25 +1,25 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.domain.content.transfer;
import java.io.Serializable; @@ -31,12 +31,9 @@ import java.io.Serializable; * @author Jason Dobies */ public class DeployPackageStep implements Serializable { - // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
- // Attributes -------------------------------------------- - /** * Unique identifier for this step within the context of the overall package installation steps for a particular * package. @@ -58,8 +55,6 @@ public class DeployPackageStep implements Serializable { */ private String stepErrorMessage;
- // Public -------------------------------------------- - public DeployPackageStep(String stepKey, String description) { if (stepKey == null) throw new IllegalArgumentException("stepKey cannot be null"); @@ -79,12 +74,15 @@ public class DeployPackageStep implements Serializable { }
public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false;
DeployPackageStep that = (DeployPackageStep) o;
- if (!stepKey.equals(that.stepKey)) return false; + if (!stepKey.equals(that.stepKey)) + return false;
return true; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java index 83f2957..40c1988 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java @@ -1,31 +1,27 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - package org.rhq.core.domain.content.transfer; - -import org.rhq.core.domain.content.transfer.ContentResponseResult; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.core.domain.content.transfer; + import java.io.Serializable; import java.util.HashSet; import java.util.Set; @@ -34,12 +30,9 @@ import java.util.Set; * @author Jason Dobies */ public class DeployPackagesResponse implements Serializable { - // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
- // Attributes -------------------------------------------- - private int requestId;
private ContentResponseResult overallRequestResult; @@ -47,8 +40,6 @@ public class DeployPackagesResponse implements Serializable {
private Set<DeployIndividualPackageResponse> packageResponses = new HashSet<DeployIndividualPackageResponse>();
- // Constructors -------------------------------------------- - public DeployPackagesResponse() { }
@@ -97,5 +88,5 @@ public class DeployPackagesResponse implements Serializable {
packageResponses.add(response); } - + } \ No newline at end of file diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java index 35eb273..dd3848d 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java @@ -1,28 +1,26 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - package org.rhq.core.domain.content.transfer; - -import org.rhq.core.domain.content.transfer.ContentResponseResult; +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.core.domain.content.transfer;
import java.io.Serializable; import java.util.HashSet; @@ -32,12 +30,9 @@ import java.util.Set; * @author Jason Dobies */ public class RemovePackagesResponse implements Serializable { - // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
- // Attributes -------------------------------------------- - private int requestId;
private ContentResponseResult overallRequestResult; @@ -45,8 +40,6 @@ public class RemovePackagesResponse implements Serializable {
private Set<RemoveIndividualPackageResponse> packageResponses = new HashSet<RemoveIndividualPackageResponse>();
- // Constructors -------------------------------------------- - public RemovePackagesResponse() { }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java index c1440cc..2165b34 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java @@ -34,7 +34,6 @@ import org.rhq.core.domain.content.PackageDetailsKey; * @author Jason Dobies */ public class ResourcePackageDetails extends PackageDetails { - // Attributes --------------------------------------------
/** * Values the plugin should use when installing this package. @@ -43,14 +42,10 @@ public class ResourcePackageDetails extends PackageDetails {
private long installationTimestamp;
- // Constructors -------------------------------------------- - public ResourcePackageDetails(PackageDetailsKey key) { super(key); }
- // Public -------------------------------------------- - public Configuration getDeploymentTimeConfiguration() { return deploymentTimeConfiguration; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java index af4f3b9..3ccab5d 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java @@ -88,8 +88,6 @@ public class ResourceConfigurationUpdateCriteria extends Criteria { return ResourceConfigurationUpdate.class; }
- // filters - public void addFilterId(Integer filterId) { this.filterId = filterId; } @@ -122,9 +120,6 @@ public class ResourceConfigurationUpdateCriteria extends Criteria { this.filterResourceGroupIds = Arrays.asList(filterResourceGroupIds); }
- - // Fetches - public void fetchResource(boolean fetchResource) { this.fetchResource = fetchResource; } @@ -137,9 +132,6 @@ public class ResourceConfigurationUpdateCriteria extends Criteria { this.fetchConfiguration = configuration; }
- - // Sorts - public void addSortCtime(PageOrdering sortCtime) { addSortField(SORT_FIELD_CTIME); this.sortCtime = sortCtime;
commit e5fac0a1484e1c2404bfb815d98228c707afca01 Merge: 76eb27f... b02e602... Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 14 11:29:37 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 76eb27f1cdefa7028df485ed5ec1fa54f3018cb7 Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 14 11:23:22 2010 -0400
fix a bunch of bugs in the resource tree plus start cleaning up / refactoring the tree code
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java index 916bcc7..9355e30 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java @@ -665,7 +665,7 @@ import org.rhq.core.domain.util.Summary; @NamedQuery(name = Resource.QUERY_FIND_BY_ID_WITH_INSTALLED_PACKAGES, query = "SELECT r FROM Resource AS r LEFT JOIN r.installedPackages ip WHERE r.id = :id"), @NamedQuery(name = Resource.QUERY_FIND_BY_ID_WITH_INSTALLED_PACKAGE_HIST, query = "SELECT r FROM Resource AS r LEFT JOIN r.installedPackageHistory ip WHERE r.id = :id"), @NamedQuery(name = Resource.QUERY_FIND_PLATFORM_BY_AGENT, query = "SELECT res FROM Resource res WHERE res.resourceType.category = :category AND res.agent = :agent"), - @NamedQuery(name = Resource.QUERY_FIND_PAREBT_ID, query = "SELECT res.parentResource.id FROM Resource AS res WHERE res.id = :id"), + @NamedQuery(name = Resource.QUERY_FIND_PARENT_ID, query = "SELECT res.parentResource.id FROM Resource AS res WHERE res.id = :id"), @NamedQuery(name = Resource.QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE, query = "" + "SELECT DISTINCT r FROM Resource r " + "WHERE r.parentResource.id is null " @@ -679,7 +679,7 @@ import org.rhq.core.domain.util.Summary; + " OR EXISTS (SELECT rr FROM Resource rr WHERE rr.id = :resourceId AND rr.parentResource.parentResource.parentResource.parentResource.parentResource = r) " + " OR EXISTS (SELECT rr FROM Resource rr WHERE rr.id = :resourceId AND rr.parentResource.parentResource.parentResource.parentResource.parentResource.parentResource = r) " + " )"), // - @NamedQuery(name = Resource.QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME, query = "" // + @NamedQuery(name = Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME, query = "" // + "SELECT r.id " // + " FROM Resource r " // + " WHERE ( r.resourceType.id = :resourceTypeId OR :resourceTypeId IS NULL ) " // @@ -692,7 +692,7 @@ import org.rhq.core.domain.util.Summary; + " OR r.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.parentResource.parentResource.id = :resourceId) " + " OR r.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.parentResource.parentResource.parentResource.id = :resourceId) " + " ) "), - @NamedQuery(name = Resource.QUERY_FIND_DESCENDENTS, query = "" // + @NamedQuery(name = Resource.QUERY_FIND_DESCENDANTS, query = "" // + "SELECT r.id " // + " FROM Resource r " // + " WHERE r.id = :resourceId " // @@ -846,12 +846,12 @@ public class Resource implements Comparable<Resource>, Serializable {
public static final String QUERY_FIND_PLATFORM_BY_AGENT = "Resource.findPlatformByAgent";
- public static final String QUERY_FIND_PAREBT_ID = "Resource.findParentId"; + public static final String QUERY_FIND_PARENT_ID = "Resource.findParentId";
public static final String QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE = "Resource.findRootPlatformOfResource";
- public static final String QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME = "Resource.findDescendentsByTypeAndName"; - public static final String QUERY_FIND_DESCENDENTS = "Resource.findDescendents"; + public static final String QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME = "Resource.findDescendantsByTypeAndName"; + public static final String QUERY_FIND_DESCENDANTS = "Resource.findDescendants"; public static final String QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK = "Resource.markResourcesForAsyncDeletionQuick"; public static final String QUERY_FIND_RESOURCES_MARKED_FOR_ASYNC_DELETION = "Resource.findResourcesMarkedForAsyncDeletion";
@@ -913,7 +913,7 @@ public class Resource implements Comparable<Resource>, Serializable {
@JoinColumn(name = "RESOURCE_TYPE_ID", referencedColumnName = "ID", nullable = false) @ManyToOne - // TODO GH: It would be prefferable for this to be lazy, but will need cleanup throughout the app (fetch = FetchType.LAZY) + // TODO GH: It would be preferable for this to be lazy, but will need cleanup throughout the app (fetch = FetchType.LAZY) @Summary(index = 4) private ResourceType resourceType;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java index 80e92f6..14fd30f 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java @@ -256,9 +256,9 @@ public class ResourceSubCategory implements Comparable<ResourceSubCategory>, Ser }
/** - * Returns this subcategory's parent subcategory, or null if this subcateogry has no parent. + * Returns this subcategory's parent subcategory, or null if this subcategory has no parent. * - * @return this subcategory's parent subcategory, or null if this subcateogry has no parent + * @return this subcategory's parent subcategory, or null if this subcategory has no parent */ public ResourceSubCategory getParentSubCategory() { return parentSubCategory; diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index 2d92aba..6ef33a5 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -130,7 +130,7 @@ <artifactId>quartz</artifactId> <!-- NOTE: The version is defined in the root POM's dependencyManagement section. --> <scope>provided</scope> - <!-- by JBossAS itself, which the container build has packaged with 1.6.5 --> + <!-- by JBossAS itself, which the container buildNodes has packaged with 1.6.5 --> </dependency>
<!-- needed for referenced domain entities that use Hibernate annotations (due to JDK5 bug) --> @@ -288,9 +288,9 @@ <configuration> <tasks> <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" /> - <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true"> + <i18n outputdir="${project.buildNodes.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true"> <classpath refid="maven.runtime.classpath" /> - <classfileset dir="${project.build.outputDirectory}"> + <classfileset dir="${project.buildNodes.outputDirectory}"> <include name="**/*I18NResourceKeys.class" /> </classfileset> </i18n> @@ -305,7 +305,7 @@ <phase>process-classes</phase> <configuration> <tasks> - <copy todir="${project.build.outputDirectory}"> + <copy todir="${project.buildNodes.outputDirectory}"> <fileset dir="src/main/webapp-filtered/WEB-INF/classes"> <include name="ApplicationResources.properties" /> </fileset> @@ -352,7 +352,7 @@ <tasks> <!-- <property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" /> - <echo>*** Copying updated files from target/${project.build.finalName}/WEB-INF/classes to ${classes.dir}...</echo> + <echo>*** Copying updated files from target/${project.buildNodes.finalName}/WEB-INF/classes to ${classes.dir}...</echo> <copy todir="${classes.dir}" verbose="${rhq.verbose}"> <fileset dir="war/WEB-INF/classes" /> </copy> diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java index 7498ad2..b332c3a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java @@ -103,7 +103,7 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
private void buildForm() { if (!formBuilt) { - // TODO build components + // TODO buildNodes components // TODO setFields(components);
formBuilt = true; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java index 2ad86d4..db9aeaa 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java @@ -103,7 +103,7 @@ public class NotificationsAlertDefinitionForm extends LocatableDynamicForm imple
private void buildForm() { if (!formBuilt) { - // TODO build components + // TODO buildNodes components // TODO setFields(components);
formBuilt = true; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java index b0ddff7..a3bd629 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java @@ -32,7 +32,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
public abstract class AbstractBundleCreateWizard extends AbstractWizard {
- // the things we build up in the wizard + // the things we buildNodes up in the wizard private String recipe; private BundleVersion bundleVersion; private HashMap<String, Boolean> allBundleFilesStatus; // bundle file names with their upload status (true=they were uploaded) diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java index a0728af..eef6af5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java @@ -30,7 +30,7 @@ import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard; */ public abstract class AbstractBundleDeployWizard extends AbstractWizard {
- // the things we build up in the wizard + // the things we buildNodes up in the wizard private Integer bundleId; private BundleDestination destination; private boolean isNewDestination = false; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java index cf69400..c393657 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java @@ -28,7 +28,7 @@ import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard; */ public abstract class AbstractBundleRevertWizard extends AbstractWizard {
- // the things we build up in the wizard + // the things we buildNodes up in the wizard private BundleDestination destination; private String deploymentDescription; private BundleDeployment deployment; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java new file mode 100644 index 0000000..c0752a1 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java @@ -0,0 +1,53 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.components.tree; + +import com.smartgwt.client.widgets.tree.TreeNode; + +/** + * @author Ian Springer + */ +public class EnhancedTreeNode extends TreeNode { + private static final String ID_FIELD = "id"; + private static final String PARENT_ID_FIELD = "parentId"; + + public String getID() { + return getAttribute(ID_FIELD); + } + + public String getParentID() { + return getAttribute(PARENT_ID_FIELD); + } + + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + String className = this.getClass().getName(); + String simpleClassName = className.substring(className.lastIndexOf(".") + 1); + buffer.append(simpleClassName).append("["); + String id = getID(); + buffer.append("id=").append(id); + String parentId = getParentID(); + buffer.append(", parentId=").append(parentId); + String name = getName(); + buffer.append(", name=").append(name); + buffer.append("]"); + return buffer.toString(); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java index 939c519..bccf8c5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java @@ -165,7 +165,7 @@ public class NewResourceTreeDataSource extends DataSource { EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.subCategory), new ResourceTypeRepository.ResourceTypeLoadedCallback() { public void onResourceTypeLoaded(List<Resource> result) { -// response.setData(build(result)); +// response.setData(buildNodes(result)); processResponse(requestId, response);
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java index fe4fdc2..9d7f395 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; import java.util.List; +import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSRequest; @@ -44,15 +45,17 @@ import org.rhq.core.domain.resource.ResourceSubCategory; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/** - * This doesn't extend RPCDataSource because it is tree oriented and - * behaves different from normal list data sources in some places. + * This doesn't extend RPCDataSource because it is tree-oriented and behaves differently than normal list data sources + * in some places. * * @author Greg Hinkle + * @author Ian Springer */ public class ResourceTreeDatasource extends DataSource { private List<Resource> initialData; @@ -98,7 +101,7 @@ public class ResourceTreeDatasource extends DataSource { String requestId = request.getRequestId(); DSResponse response = new DSResponse(); response.setAttribute("clientContext", request.getAttributeAsObject("clientContext")); - // Asume success + // Assume success response.setStatus(0); switch (request.getOperationType()) { case ADD: @@ -168,7 +171,8 @@ public class ResourceTreeDatasource extends DataSource { ResourceTypeRepository.MetadataType.subCategory), new ResourceTypeRepository.ResourceTypeLoadedCallback() { public void onResourceTypeLoaded(List<Resource> result) { - response.setData(build(result)); + TreeNode[] treeNodes = buildNodes(result); + response.setData(treeNodes); processResponse(requestId, response); response.setStatus(DSResponse.STATUS_SUCCESS); } @@ -181,7 +185,7 @@ public class ResourceTreeDatasource extends DataSource { * @param resources * @return */ - public static TreeNode[] build(List<Resource> resources) { + public static TreeNode[] buildNodes(List<Resource> resources) { ResourceTreeNode[] records = new ResourceTreeNode[resources.size()]; for (int x = 0; x < resources.size(); x++) { Resource res = resources.get(x); @@ -189,52 +193,54 @@ public class ResourceTreeDatasource extends DataSource { records[x] = record; }
- return introduceTypeFolders(records); + return introduceTypeAndCategoryNodes(records); }
- private static TreeNode[] introduceTypeFolders(ResourceTreeNode[] nodes) { - ArrayList<TreeNode> built = new ArrayList<TreeNode>(); - HashMap<ResourceSubCategory, CategoryTreeNode> categories = new HashMap<ResourceSubCategory, CategoryTreeNode>(); - HashMap<ResourceType, TypeTreeNode> types = new HashMap<ResourceType, TypeTreeNode>(); + private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[] nodes) { + List<TreeNode> updatedNodes = new ArrayList<TreeNode>(); + Map<Integer, CategoryTreeNode> categories = new HashMap<Integer, CategoryTreeNode>(); + Map<ResourceType, TypeTreeNode> types = new HashMap<ResourceType, TypeTreeNode>();
for (ResourceTreeNode node : nodes) { - built.add(node); - - if (!types.containsKey(node.getResourceType()) - && node.getResourceType().getCategory() != ResourceCategory.PLATFORM) { - - String parentResourceId = String.valueOf(node.getResource().getParentResource().getId()); - - CategoryTreeNode categoryNode = null; - - if (node.getResourceType().getSubCategory() != null) { - ResourceSubCategory category = node.getResourceType().getSubCategory(); - if (category.getName() != null) { - categoryNode = categories.get(category); - - if (categoryNode == null) { - categoryNode = new CategoryTreeNode(parentResourceId, category); - - categories.put(category, categoryNode); - built.add(categoryNode); + updatedNodes.add(node); + + ResourceType type = node.getResourceType(); + if (type.getCategory() != ResourceCategory.PLATFORM) { + if (!types.containsKey(type)) { + + String parentResourceId = String.valueOf(node.getResource().getParentResource().getId()); + + CategoryTreeNode categoryNode = null; + if (type.getSubCategory() != null) { + ResourceSubCategory category = type.getSubCategory(); + if (category.getName() != null) { + categoryNode = categories.get(category.getId()); + if (categoryNode == null) { + // TODO (ips): Handle connecting child subcat nodes to their parent subcats. + /*ResourceSubCategory parentCategory = category.getParentSubCategory(); + while (parentCategory != null) { + Resource parentType = parentCategory.findParentResourceType(); + if (parentCategory.findTaggedResourceTypes().isEmpty()) { + CategoryTreeNode parentCategoryNode = + new CategoryTreeNode(parentResourceId, parentCategory); + } + }*/ + categoryNode = new CategoryTreeNode(parentResourceId, category); + categories.put(category.getId(), categoryNode); + updatedNodes.add(categoryNode); + } } } - }
- String parentId = null; - if (categoryNode != null) { - parentId = categoryNode.getAttribute("id"); - } else { - parentId = parentResourceId; + String parentId = (categoryNode != null) ? categoryNode.getID() : parentResourceId; + TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId, type); + updatedNodes.add(typeNode); + types.put(type, typeNode); } - - TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId, node.getResourceType().getName()); - built.add(typeNode); - types.put(node.getResourceType(), typeNode); } }
- return built.toArray(new TreeNode[built.size()]); + return updatedNodes.toArray(new TreeNode[updatedNodes.size()]); }
private static boolean sameTypes(ResourceTreeNode[] nodes) { @@ -247,78 +253,87 @@ public class ResourceTreeDatasource extends DataSource { return true; }
- public static class CategoryTreeNode extends TreeNode { - public CategoryTreeNode(String parentId, ResourceSubCategory category) { - setID(parentId + "__" + category.getName()); - setParentID(parentId); - setName(category.getDisplayName()); + public static class CategoryTreeNode extends EnhancedTreeNode { + public CategoryTreeNode(String parentResourceId, ResourceSubCategory category) { + String id = parentResourceId + "__" + fixId(category.getName()); + setID(id); + setAttribute("id", id);
- setAttribute("id", parentId + "__" + category.getName()); - setAttribute("parentId", parentId); - setAttribute("name", category.getDisplayName()); - } + setParentID(parentResourceId); + setAttribute("parentId", parentResourceId);
- @Override - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("CategoryTreeNode["); - String id = getAttribute("id"); - buffer.append("id=").append(id); - String parentId = getAttribute("parentId"); - buffer.append(", parentId=").append(parentId); - String name = getAttribute("name"); - buffer.append(", name=").append(name); - buffer.append("]"); - return buffer.toString(); + setName(category.getDisplayName()); + setAttribute("name", category.getDisplayName()); } }
- public static class TypeTreeNode extends TreeNode { - private TypeTreeNode(String parentId, String parentResourceId, String type) { - setID(parentId + "_" + type); - setParentID(parentId); + public static class TypeTreeNode extends EnhancedTreeNode { + private TypeTreeNode(String parentId, String parentResourceId, ResourceType type) { + String id = parentResourceId + "_" + type.getId(); + setID(id); + setAttribute("id", id);
- setAttribute("id", parentResourceId + "_" + type); + if (parentId == null) { + try { + throw new IllegalStateException("**************** WARNING: parent ID is null for type " + type); + } catch (IllegalStateException e) { + e.printStackTrace(); + } + } + setParentID(parentId); setAttribute("parentId", parentId); + // setAttribute("parentKey", parentId); - setAttribute("name", type); + + String name = type.getName(); + setName(name); + setAttribute("name", name); + } + + @Override + public void setParentID(String parentID) { + if (parentID == null) { + try { + throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName()); + } catch (IllegalStateException e) { + e.printStackTrace(); + } + } + super.setParentID(parentID); }
@Override - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("TypeTreeNode["); - String id = getAttribute("id"); - buffer.append("id=").append(id); - String parentId = getAttribute("parentId"); - buffer.append(", parentId=").append(parentId); - String name = getAttribute("name"); - buffer.append(", name=").append(name); - buffer.append("]"); - return buffer.toString(); + public void setAttribute(String property, String value) { + if (property.equals("parentId") && value == null) { + try { + throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName()); + } catch (IllegalStateException e) { + e.printStackTrace(); + } + } + super.setAttribute(property, value); } }
- public static class ResourceTreeNode extends TreeNode { + public static class ResourceTreeNode extends EnhancedTreeNode { private Resource resource;
private ResourceTreeNode(Resource resource) { this.resource = resource;
String id = String.valueOf(resource.getId()); - String parentId = resource.getParentResource() == null ? null - : (resource.getParentResource().getId() + "_" + resource.getResourceType().getName()); - - // System.out.println(id + " / " + parentId); - setID(id); - setParentID(parentId); - setAttribute("id", id); + + String parentId = (resource.getParentResource() != null) ? + (resource.getParentResource().getId() + "_" + resource.getResourceType().getId()) : null; + setParentID(parentId); setAttribute("parentId", parentId);
+ // System.out.println(id + " / " + parentId); // setAttribute("parentKey", resource.getParentResource() == null ? 0 : (resource.getParentResource().getId() + resource.getResourceType().getName()));
+ setName(resource.getName()); setAttribute("name", resource.getName()); setAttribute("description", resource.getDescription()); ResourceAvailability currentAvail = resource.getCurrentAvailability(); @@ -335,30 +350,12 @@ public class ResourceTreeDatasource extends DataSource { return resource; }
- public void setResource(Resource resource) { - this.resource = resource; - } - public ResourceType getResourceType() { return resource.getResourceType(); } + }
- public String getParentId() { - return getAttribute("parentId"); - } - - @Override - public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append("ResourceTreeNode["); - String id = getAttribute("id"); - buffer.append("id=").append(id); - String parentId = getAttribute("parentId"); - buffer.append(", parentId=").append(parentId); - String name = getAttribute("name"); - buffer.append(", name=").append(name); - buffer.append("]"); - return buffer.toString(); - } + private static String fixId(String id) { + return id.replace(' ', '_'); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java index 57ba8f2..02afc80 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java @@ -35,6 +35,7 @@ import com.smartgwt.client.types.SelectionStyle; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.CloseClickHandler; import com.smartgwt.client.widgets.events.CloseClientEvent; +import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler; import com.smartgwt.client.widgets.grid.events.SelectionEvent; import com.smartgwt.client.widgets.menu.Menu; @@ -129,11 +130,12 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() { public void onSelectionChanged(SelectionEvent selectionEvent) { if (!selectionEvent.isRightButtonDown() && selectionEvent.getState()) { - if (treeGrid.getSelectedRecord() instanceof ResourceTreeDatasource.ResourceTreeNode) { - ResourceTreeDatasource.ResourceTreeNode node = (ResourceTreeDatasource.ResourceTreeNode) treeGrid - .getSelectedRecord(); - //System.out.println("Resource selected in tree: " + node.getResource()); - String viewPath = "Resource/" + node.getResource().getId(); + ListGridRecord selectedNode = treeGrid.getSelectedRecord(); + System.out.println("Node selected in tree: " + selectedNode); + if (selectedNode instanceof ResourceTreeDatasource.ResourceTreeNode) { + ResourceTreeDatasource.ResourceTreeNode resourceNode = + (ResourceTreeDatasource.ResourceTreeNode) selectedNode; + String viewPath = "Resource/" + resourceNode.getResource().getId(); String currentViewPath = History.getToken(); if (!currentViewPath.startsWith(viewPath)) { CoreGUI.goToView(viewPath); @@ -162,14 +164,14 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.addDataArrivedHandler(new DataArrivedHandler() { public void onDataArrived(DataArrivedEvent dataArrivedEvent) { if (!initialSelect) { - updateBreadcrumb(); + updateBreadcrumbs(); } } }); }
- private void updateBreadcrumb() { + private void updateBreadcrumbs() { TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId)); // System.out.println("Trying to preopen: " + selectedNode); if (selectedNode != null) { @@ -177,10 +179,6 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.getTree().openFolders(parents); treeGrid.getTree().openFolder(selectedNode);
- for (TreeNode p : parents) { - // System.out.println("open? " + treeGrid.getTree().isOpen(p) + " node: " + p.getName()); - } - treeGrid.selectRecord(selectedNode); initialSelect = true; treeGrid.markForRedraw(); @@ -466,20 +464,9 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.selectRecord(node); }
- updateBreadcrumb(); - /* - TODO DELETEME - // Update breadcrumbs - viewId.getBreadcrumbs().clear(); - for (int i = parents.length - 1; i >= 0; i--) { - TreeNode n = parents[i]; - adjustBreadcrumb(n, viewId); - } - adjustBreadcrumb(node, viewId); - - CoreGUI.refreshBreadCrumbTrail(); - */ + TreeUtility.printTree(treeGrid.getTree());
+ updateBreadcrumbs(); } else {
// This is for cases where we have to load the tree fresh including down to the currently visible node @@ -505,7 +492,7 @@ public class ResourceTreeView extends LocatableVLayout {
ResourceTreeDatasource dataSource = new ResourceTreeDatasource(result); treeGrid.setDataSource(dataSource); - // GH: couldn't get initial data to mix with the datasource... so i put the inital data in + // GH: couldn't get initial data to mix with the datasource... so i put the initial data in // the first datasource request // treeGrid.setInitialData(selectedLineage);
@@ -514,7 +501,7 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() { public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) { System.out.println("Here!!!!!"); - updateBreadcrumb(); + updateBreadcrumbs(); } });
@@ -532,7 +519,7 @@ public class ResourceTreeView extends LocatableVLayout { System.out.println("open? " + treeGrid.getTree().isOpen(p) + " node: " + p.getName()); }
- updateBreadcrumb(); + updateBreadcrumbs();
treeGrid.selectRecord(selectedNode); initialSelect = true; @@ -552,7 +539,7 @@ public class ResourceTreeView extends LocatableVLayout {
TreeUtility.printTree(treeGrid.getTree());
- treeGrid.getTree().linkNodes(ResourceTreeDatasource.build(result)); + treeGrid.getTree().linkNodes(ResourceTreeDatasource.buildNodes(result));
TreeNode selectedNode = treeGrid.getTree().findById( String.valueOf(selectedResourceId)); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java index 7e96af8..e9f773d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java @@ -80,7 +80,7 @@ public class ResourceSelector extends AbstractSelector<Resource> { // TODO: Currently ignore the typeSelectItem widget because we already know the type. // Alternatively, we could display it disabled but we'd want the type name to be displayed as the // value. To get this to display the type name I think we need to pre-fetch the type tree here. We could - // potentially optimize typeSelectItem.setValue(requireType.getId()) to build a tree that includes only + // potentially optimize typeSelectItem.setValue(requireType.getId()) to buildNodes a tree that includes only // this single type. //typeSelectItem.setValue(requireType.getId()); //typeSelectItem.setDisabled(true); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java index f8ebe39..550413c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java @@ -23,6 +23,8 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set;
import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -41,8 +43,8 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync; */ public class ResourceTypeRepository {
- private HashMap<Integer, ResourceType> typeCache = new HashMap<Integer, ResourceType>(); - private HashMap<Integer, EnumSet<MetadataType>> typeCacheLevel = new HashMap<Integer, EnumSet<MetadataType>>(); + private Map<Integer, ResourceType> typeCache = new HashMap<Integer, ResourceType>(); + private Map<Integer, EnumSet<MetadataType>> typeCacheLevel = new HashMap<Integer, EnumSet<MetadataType>>();
private static ResourceTypeGWTServiceAsync resourceTypeService = GWTServiceLookup.getResourceTypeGWTService();
@@ -78,7 +80,8 @@ public class ResourceTypeRepository { loadResourceTypes(resources, null, callback); }
- public void loadResourceTypes(final List<Resource> resources, final EnumSet<MetadataType> metadataTypes, final ResourceTypeLoadedCallback callback) { + public void loadResourceTypes(final List<Resource> resources, final EnumSet<MetadataType> metadataTypes, + final ResourceTypeLoadedCallback callback) { if (resources.size() == 0) { callback.onResourceTypeLoaded(resources); return; @@ -86,7 +89,7 @@ public class ResourceTypeRepository {
long start = System.currentTimeMillis();
- HashSet<Integer> types = new HashSet<Integer>(); + Set<Integer> types = new HashSet<Integer>(); for (Resource res : resources) { types.add(res.getResourceType().getId()); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java index 8199c50..360fd86 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java @@ -1,9 +1,30 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ package org.rhq.enterprise.gui.coregui.client.util;
import com.smartgwt.client.widgets.tree.Tree; import com.smartgwt.client.widgets.tree.TreeNode; +import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
/** + * A collection of utility methods for working with SmartGWT {@link Tree}s. + * * @author Ian Springer */ public class TreeUtility { @@ -15,15 +36,34 @@ public class TreeUtility { private static void printTreeNode(Tree tree, TreeNode node) { int level = tree.getLevel(node); for (int i = 0; i < level; i++) { - System.out.print(' '); + System.out.print(" "); } - System.out.println("* " + node); + System.out.println("* " + toString(node)); TreeNode[] childNodes = tree.getChildren(node); for (TreeNode childNode : childNodes) { printTreeNode(tree, childNode); } }
+ private static String toString(TreeNode node) { + if (node instanceof EnhancedTreeNode) { + return node.toString(); + } else { + StringBuilder buffer = new StringBuilder(); + String className = node.getClass().getName(); + String simpleClassName = className.substring(className.lastIndexOf(".") + 1); + buffer.append(simpleClassName).append("["); + String id = node.getAttribute("id"); + buffer.append("id=").append(id); + String parentId = node.getAttribute("parentId"); + buffer.append(", parentId=").append(parentId); + String name = node.getName(); + buffer.append(", name=").append(name); + buffer.append("]"); + return buffer.toString(); + } + } + private TreeUtility() { } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java index 6bb2d7d..25b19b0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java @@ -174,7 +174,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
public List<Resource> getResourceLineageAndSiblings(int resourceId) { return SerialUtility.prepare(resourceManager.getResourceLineageAndSiblings(resourceId), - "ResourceService.getResourceLineage"); + "ResourceService.getResourceLineageAndSiblings"); }
public Resource getPlatformForResource(int resourceId) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java index e228f15..ce68440 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java @@ -290,7 +290,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage // set agent references null // foobar the resourceKeys // update the inventory status to UNINVENTORY - Query toBeDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDENTS); + Query toBeDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS); toBeDeletedQuery.setParameter("resourceId", resourceId); List<Integer> toBeDeletedResourceIds = toBeDeletedQuery.getResultList();
@@ -358,7 +358,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage @SuppressWarnings("unchecked") public List<Integer> getResourceDescendantsByTypeAndName(Subject user, int resourceId, Integer resourceTypeId, String name) { - Query descendantQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME); + Query descendantQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME); descendantQuery.setParameter("resourceId", resourceId); descendantQuery.setParameter("resourceTypeId", resourceTypeId); name = QueryUtility.formatSearchParameter(name); @@ -655,7 +655,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage @Nullable private Integer getParentResourceId(int resourceId) {
- Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_PAREBT_ID); + Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_PARENT_ID); query.setParameter("id", resourceId);
try { @@ -701,11 +701,27 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public List<Resource> getResourceLineageAndSiblings(int resourceId) { List<Resource> resourceLineage = getResourceLineage(resourceId); - LinkedList<Resource> result = new LinkedList<Resource>(); + List<Resource> result = new LinkedList<Resource>();
- result.add(resourceLineage.get(0)); + Resource platform = resourceLineage.get(0); + result.add(platform); for (Resource resource : resourceLineage) { - result.addAll(resource.getChildResources()); + if (resource.getParentResource() != null) { + // This ensures Hibernate actually fetches the parent Resource. + resource.getParentResource().getId(); + } + Set<Resource> childResources = resource.getChildResources(); + result.addAll(childResources); + for (Resource childResource : childResources) { + // This ensures Hibernate actually fetches the parent Resource. + childResource.getParentResource().getId(); + Set<Resource> grandchildResources = childResource.getChildResources(); + result.addAll(grandchildResources); + for (Resource grandchildResource : grandchildResources) { + // This ensures Hibernate actually fetches the parent Resource. + grandchildResource.getParentResource().getId(); + } + } }
return result;
commit b02e60272034d5f1785dd87b9e38046a31784c1f Merge: bf9bb7b... fc50175... Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Sep 14 10:52:46 2010 -0400
Merge branch 'master' into master-jay
commit bf9bb7bed3e3b697789ec1b953e68e966cf9488f Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Sep 14 10:50:48 2010 -0400
More Adminisration Section Work - First working version of role management (still needs work to get it looking better) - Tweaks to User management - Selenium hooks worked into roles - Add margin to TableSection to get BackButton some buffer space.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java index 74b9c34..3ec8b14 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java @@ -18,8 +18,9 @@ */ package org.rhq.enterprise.gui.coregui.client.admin.roles;
-import org.rhq.core.domain.authz.Permission; -import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.Set;
import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.DynamicForm; @@ -30,65 +31,58 @@ import com.smartgwt.client.widgets.form.fields.CheckboxItem; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.HeaderItem;
-import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.Set; +import org.rhq.core.domain.authz.Permission; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** * @author Greg Hinkle */ public class PermissionEditorView extends CanvasItem {
- private Set<Permission> selectedPermissions = EnumSet.noneOf(Permission.class);
- private DynamicForm parentForm; - private DynamicForm form;
- - public PermissionEditorView(String name, String title) { + public PermissionEditorView(String locatorId, String name, String title) { super(name, title);
- setCanvas(new SimpleCollapsiblePanel("Permissions", buildForm())); + setCanvas(buildForm(locatorId)); }
+ public Canvas buildForm(String locatorId) { + this.form = new LocatableDynamicForm(locatorId); + this.form.setNumCols(4); + this.form.setColWidths("20%", "20%", "20%", "40%");
- public Canvas buildForm() { - System.out.println("Building permissions canvas"); - -// Object o = getAttributeAsObject(getFieldName()); - - this.form = new DynamicForm(); ArrayList<FormItem> items = new ArrayList<FormItem>();
- - HeaderItem h1 = new HeaderItem("globalPermissions","Global Permissions"); + HeaderItem h1 = new HeaderItem("globalPermissions", "Global Permissions"); h1.setValue("Global Permissions"); items.add(h1); for (Permission p : Permission.values()) { if (p.getTarget() == Permission.Target.GLOBAL) { - items.add(new CheckboxItem(p.name(),p.name())); + CheckboxItem cb = new CheckboxItem(p.name(), p.name()); + cb.setShowTitle(false); + items.add(cb); } }
- HeaderItem h2 = new HeaderItem("resourcePermissions","Resource Permissions"); + HeaderItem h2 = new HeaderItem("resourcePermissions", "Resource Permissions"); h2.setValue("Resource Permissions"); items.add(h2); for (Permission p : Permission.values()) { if (p.getTarget() == Permission.Target.RESOURCE) { - items.add(new CheckboxItem(p.name(),p.name())); + CheckboxItem cb = new CheckboxItem(p.name(), p.name()); + cb.setShowTitle(false); + items.add(cb); } }
form.setItems(items.toArray(new FormItem[items.size()]));
- return form; }
- public void setPermissions(Set<Permission> permissions) { this.selectedPermissions = permissions; for (Permission p : Permission.values()) { @@ -98,7 +92,7 @@ public class PermissionEditorView extends CanvasItem { form.addItemChangedHandler(new ItemChangedHandler() { public void onItemChanged(ItemChangedEvent itemChangedEvent) { for (Permission p : Permission.values()) { - if ((Boolean)form.getValue(p.name())) { + if ((Boolean) form.getValue(p.name())) { selectedPermissions.add(p); } else { selectedPermissions.remove(p); @@ -116,11 +110,6 @@ public class PermissionEditorView extends CanvasItem {
@Override public Object getValue() { - System.out.println("Finding Value"); return super.getValue(); } - - public void setParentForm(DynamicForm parentForm) { - this.parentForm = parentForm; - } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java index ad9c982..7a81733 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java @@ -18,57 +18,57 @@ */ package org.rhq.enterprise.gui.coregui.client.admin.roles;
-import java.util.Collection; import java.util.HashSet; import java.util.Set;
+import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.Record; +import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.DSOperationType; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.TitleOrientation; import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Label; -import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; -import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; import com.smartgwt.client.widgets.form.fields.CanvasItem; -import com.smartgwt.client.widgets.form.fields.ResetItem; -import com.smartgwt.client.widgets.form.fields.SubmitItem; -import com.smartgwt.client.widgets.form.fields.TextItem; -import com.smartgwt.client.widgets.form.fields.events.ClickEvent; -import com.smartgwt.client.widgets.form.fields.events.ClickHandler; import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.authz.Role; +import org.rhq.core.domain.criteria.RoleCriteria; import org.rhq.core.domain.resource.group.ResourceGroup; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; +import org.rhq.enterprise.gui.coregui.client.ViewId; +import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceGroupSelector; import org.rhq.enterprise.gui.coregui.client.util.message.Message; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** * @author Greg Hinkle */ -public class RoleEditView extends LocatableVLayout { +public class RoleEditView extends LocatableVLayout implements BookmarkableView {
- private Role roleBeingEdited; + private Role role;
- private Label message = new Label("Select a role to edit..."); + private Label message = new Label("Loading...");
private VLayout editCanvas; - private HeaderLabel editLabel; private DynamicForm form; + private PermissionEditorView permissionEditorItem;
private CanvasItem groupSelectorItem; @@ -77,187 +77,210 @@ public class RoleEditView extends LocatableVLayout { private CanvasItem subjectSelectorItem; private RoleSubjectSelector subjectSelector;
- private Window editorWindow; + private RolesDataSource dataSource;
public RoleEditView(String locatorId) { super(locatorId); - setPadding(10); - setOverflow(Overflow.AUTO); - - addMember(message); - - addMember(buildRoleForm()); - - editCanvas.hide(); - } - - private Canvas buildRoleForm() {
- this.editCanvas = new VLayout(); - this.editCanvas.setWidth100(); - this.editCanvas.setHeight100(); + this.dataSource = RolesDataSource.getInstance();
- editLabel = new HeaderLabel("Create User"); - // TODO create header css style and set + this.setPadding(10); + setOverflow(Overflow.AUTO);
- editCanvas.addMember(editLabel); + buildRoleEditor(); + this.editCanvas.hide();
- form = new LocatableDynamicForm(extendLocatorId("RoleForm")); - form.setWidth100(); + this.addMember(message); + this.addMember(editCanvas); + }
- form.setDataSource(RolesDataSource.getInstance()); + private Canvas buildRoleEditor() { + form = new LocatableDynamicForm(extendLocatorId(this.getLocatorId()));
- TextItem idItem = new TextItem("id", "Id"); + form.setHiliteRequiredFields(true); + form.setRequiredTitleSuffix("* :");
- TextItem nameItem = new TextItem("name", "Name"); + form.setDataSource(this.dataSource); + form.setUseAllDataSourceFields(true);
- permissionEditorItem = new PermissionEditorView("permissionEditor", "Permissions"); + permissionEditorItem = new PermissionEditorView(this.getLocatorId(), "permissionsEditor", "Permissions"); permissionEditorItem.setShowTitle(false); permissionEditorItem.setColSpan(2);
groupSelectorItem = new CanvasItem("groupSelectionCanvas", "Assigned Resource Groups"); - groupSelectorItem.setCanvas(new Label("loading...")); //new RoleResourceGroupSelector(null)); groupSelectorItem.setTitleOrientation(TitleOrientation.TOP); groupSelectorItem.setColSpan(2);
subjectSelectorItem = new CanvasItem("subjectSelectionCanvas", "Assigned Subjects"); - subjectSelectorItem.setCanvas(new Label("loading...")); //new RoleSubjectSelector(null)); subjectSelectorItem.setTitleOrientation(TitleOrientation.TOP); subjectSelectorItem.setColSpan(2);
- SubmitItem saveButton = new SubmitItem("save", "Save"); - - saveButton.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent clickEvent) { - save(); - System.out.println("Save is done"); + IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); + saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + if (form.validate()) { + save(); + } } });
- form.addSubmitValuesHandler(new SubmitValuesHandler() { - public void onSubmitValues(SubmitValuesEvent submitValuesEvent) { - Object o = submitValuesEvent.getValues(); - System.out.println("O: " + o); + IButton resetButton = new LocatableIButton(this.extendLocatorId("Reset"), "Reset"); + resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + form.reset(); } });
- form.setItems(idItem, nameItem, permissionEditorItem, groupSelectorItem, subjectSelectorItem, saveButton, - new ResetItem("reset", "Reset")); - - editCanvas.addMember(form); - - return editCanvas; - } - - public void editRecord(Record record) { - this.roleBeingEdited = (Role) record.getAttributeAsObject("entity"); - message.hide(); - editCanvas.show(); - try { - editLabel.setContents("Editing Role " + record.getAttribute("name")); - form.editRecord(record); - permissionEditorItem.setParentForm(form); - permissionEditorItem.setPermissions((Set<Permission>) record.getAttributeAsObject("permissions")); - - groupSelector = new RoleResourceGroupSelector("RoleEditor-Groups", (Collection<ResourceGroup>) record - .getAttributeAsObject("resourceGroups")); - groupSelectorItem.setCanvas(groupSelector); - - subjectSelector = new RoleSubjectSelector("RoleEditor-Subjects", (Collection<Subject>) record - .getAttributeAsObject("subjects")); - subjectSelectorItem.setCanvas(subjectSelector); - - } catch (Throwable t) { - t.printStackTrace(); - } - // markForRedraw(); - } + IButton cancelButton = new LocatableIButton(this.extendLocatorId("Cancel"), "Cancel"); + cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { + History.back(); + } + });
- public void editNone() { - message.show(); - editCanvas.hide(); + HLayout buttonLayout = new HLayout(10); + buttonLayout.setAlign(Alignment.CENTER); + buttonLayout.addMember(saveButton); + buttonLayout.addMember(resetButton); + buttonLayout.addMember(cancelButton);
- // markForRedraw(); - } + form.setItems(permissionEditorItem, groupSelectorItem, subjectSelectorItem);
- public void editNew() { - ListGridRecord r = RolesDataSource.getInstance().copyValues(new Role()); - editRecord(r); - form.setSaveOperationType(DSOperationType.ADD); - - editLabel.setContents("Create Role"); + this.editCanvas = new VLayout();
- editorWindow = new Window(); - editorWindow.setTitle("Create Role"); - editorWindow.setWidth(800); - editorWindow.setHeight(800); - editorWindow.setIsModal(true); - editorWindow.setShowModalMask(true); - editorWindow.setCanDragResize(true); - editorWindow.centerInPage(); - editorWindow.addItem(this); - editorWindow.show(); + editCanvas.addMember(form); + editCanvas.addMember(buttonLayout);
+ return editCanvas; }
public void save() { + final HashSet<Integer> groupSelection = this.groupSelector.getSelection(); + final HashSet<Integer> userSelection = this.subjectSelector.getSelection();
- System.out.println("Saving role"); + // The form.saveData() call triggers either RolesDataSource.executeAdd() to create the new Role, + // or executeUpdate() if saving changes to an existing Role. On success we need to perform the + // subsequent user or group assignment, so set this callback on completion. form.saveData(new DSCallback() { public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) { - HashSet<Integer> selection = groupSelector.getSelection(); - int[] groupIds = new int[selection.size()]; + + int roleId = Integer.parseInt(new ListGridRecord(dsRequest.getData()).getAttribute("id")); + + int[] groupIds = new int[groupSelection.size()]; int i = 0; - for (Integer id : selection) { + for (Integer id : groupSelection) { groupIds[i++] = id; }
- int roleId; - if (roleBeingEdited != null && roleBeingEdited.getId() != null) { - roleId = roleBeingEdited.getId(); - } else { - // new role - roleId = Integer.parseInt(new ListGridRecord(dsRequest.getData()).getAttribute("id")); - } - GWTServiceLookup.getRoleService().setAssignedResourceGroups(roleId, groupIds, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to update role's assigned groups", caught); + CoreGUI.getErrorHandler().handleError("Failed to save role group assignments.", caught); }
public void onSuccess(Void result) { CoreGUI.getMessageCenter().notify( - new Message("Updated assigned groups", Message.Severity.Info)); + new Message("Succesfully saved role group assignments.", Message.Severity.Info)); } });
- HashSet<Integer> selectedSubjects = subjectSelector.getSelection(); - int[] subjectIds = new int[selectedSubjects.size()]; + int[] subjectIds = new int[userSelection.size()]; i = 0; - for (Integer id : selectedSubjects) { + for (Integer id : userSelection) { subjectIds[i++] = id; }
GWTServiceLookup.getRoleService().setAssignedSubjects(roleId, subjectIds, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to update role's assigned subjects", caught); + CoreGUI.getErrorHandler().handleError("Failed to save role user assignments.", caught); + History.back(); }
public void onSuccess(Void result) { CoreGUI.getMessageCenter().notify( - new Message("Updated role assigned subjects", Message.Severity.Info)); + new Message("Succesfully saved role user assignments.", Message.Severity.Info)); + History.back(); } }); - - if (editorWindow != null) { - editorWindow.destroy(); - } } }); }
- public DynamicForm getForm() { - return form; + @SuppressWarnings("unchecked") + public void editRecord(Record record) { + this.groupSelector = new RoleResourceGroupSelector(this.extendLocatorId("Groups"), (Set<ResourceGroup>) record + .getAttributeAsObject("resourceGroups")); + this.subjectSelector = new RoleSubjectSelector(this.extendLocatorId("Subjects"), (Set<Subject>) record + .getAttributeAsObject("subjects")); + + this.groupSelectorItem.setCanvas(this.groupSelector); + this.subjectSelectorItem.setCanvas(this.subjectSelector); + + Set<Permission> permissions = (Set<Permission>) record.getAttributeAsObject("permissions"); + this.permissionEditorItem.setPermissions(permissions); + + try { + form.editRecord(record); + } catch (Throwable t) { + t.printStackTrace(); + } + message.hide(); + editCanvas.show(); + form.setSaveOperationType(DSOperationType.UPDATE); + } + + private void editNewInternal() { + role = new Role(); + ListGridRecord r = dataSource.copyValues(role); + editRecord(r); + + // This tells form.saveData() to call RolesDataSource.executeAdd() on the new Role's ListGridRecord + form.setSaveOperationType(DSOperationType.ADD); + } + + public static void editNew(String locatorId) { + RoleEditView editView = new RoleEditView(locatorId); + editView.editNewInternal(); + } + + private void editRole(int roleId, final ViewId current) { + + final int id = Integer.valueOf(current.getBreadcrumbs().get(0).getName()); + + if (id > 0) { + RoleCriteria criteria = new RoleCriteria(); + criteria.addFilterId(id); + criteria.fetchPermissions(true); + criteria.fetchResourceGroups(true); + criteria.fetchSubjects(true); + + GWTServiceLookup.getRoleService().findRolesByCriteria(criteria, new AsyncCallback<PageList<Role>>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load role for editing", caught); + } + + @Override + public void onSuccess(PageList<Role> result) { + Role role = result.get(0); + Record record = new RolesDataSource().copyValues(role); + editRecord(record); + + current.getBreadcrumbs().get(0).setDisplayName("Editing: " + role.getName()); + CoreGUI.refreshBreadCrumbTrail(); + } + }); + } else { + editNewInternal(); + current.getBreadcrumbs().get(0).setDisplayName("New Role"); + CoreGUI.refreshBreadCrumbTrail(); + } + } + + @Override + public void renderView(ViewPath viewPath) { + int roleId = viewPath.getCurrentAsInt(); + + editRole(roleId, viewPath.getCurrent()); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java deleted file mode 100644 index 59ebf1c..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.admin.roles; - -import org.rhq.core.domain.resource.group.ResourceGroup; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel; -import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource; - -import com.smartgwt.client.types.DragDataAction; -import com.smartgwt.client.types.DragTrackerMode; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.TransferImgButton; -import com.smartgwt.client.widgets.form.fields.CanvasItem; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.layout.HLayout; -import com.smartgwt.client.widgets.layout.VStack; - -/** - * @author Greg Hinkle - */ -public class RoleGroupsEditorItem extends CanvasItem { - - private PageList<ResourceGroup> assignedGroups; - - private ListGrid assignedGroupGrid; - private ListGrid availableGroupGrid; - - public RoleGroupsEditorItem(String name, String title) { - super(name, title); - setCanvas(new SimpleCollapsiblePanel("Assigned Groups", buildForm())); - } - - private Canvas buildForm() { - - HLayout layout = new HLayout(10); - - availableGroupGrid = new ListGrid(); - availableGroupGrid.setHeight(350); - availableGroupGrid.setCanDragRecordsOut(true); - availableGroupGrid.setDragTrackerMode(DragTrackerMode.RECORD); - availableGroupGrid.setDragDataAction(DragDataAction.MOVE); - availableGroupGrid.setDataSource(ResourceGroupsDataSource.getInstance()); - availableGroupGrid.setAutoFetchData(true); - availableGroupGrid.setFields(new ListGridField("id",50), new ListGridField("name")); - - layout.addMember(availableGroupGrid); - - VStack moveButtonStack = new VStack(10); - moveButtonStack.setWidth(50); - - TransferImgButton addButton = new TransferImgButton(TransferImgButton.RIGHT); - TransferImgButton removeButton = new TransferImgButton(TransferImgButton.LEFT); - TransferImgButton addAllButton = new TransferImgButton(TransferImgButton.RIGHT_ALL); - TransferImgButton removeAllButton = new TransferImgButton(TransferImgButton.LEFT_ALL); - - moveButtonStack.addMember(addButton); - moveButtonStack.addMember(removeButton); - moveButtonStack.addMember(addAllButton); - moveButtonStack.addMember(removeAllButton); - - layout.addMember(moveButtonStack); - - assignedGroupGrid = new ListGrid(); - assignedGroupGrid.setHeight(350); - assignedGroupGrid.setCanDragRecordsOut(true); - assignedGroupGrid.setCanAcceptDroppedRecords(true); - assignedGroupGrid.setDataSource(ResourceGroupsDataSource.getInstance()); - assignedGroupGrid.setFields(new ListGridField("id", 50), new ListGridField("name")); - - layout.addMember(assignedGroupGrid); - - - return layout; - } - - public void setGroups(PageList<ResourceGroup> assignedGroups) { - this.assignedGroups = assignedGroups; - - assignedGroupGrid.setData(ResourceGroupsDataSource.getInstance().buildRecords(assignedGroups)); - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java index 12f5fde..8190d3f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java @@ -35,8 +35,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.Resour */ public class RoleResourceGroupSelector extends ResourceGroupSelector {
- public RoleResourceGroupSelector(String id, Collection<ResourceGroup> groups) { - super(id); + public RoleResourceGroupSelector(String locatorId, Collection<ResourceGroup> groups) { + super(locatorId); if (groups != null) { ListGridRecord[] data = (new ResourceGroupsDataSource()).buildRecords(groups); setAssigned(data); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java index 42e4b2f..8cbf180 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java @@ -47,18 +47,18 @@ public class RoleSubjectSelector extends AbstractSelector<Subject> { }
@Override - protected DynamicForm getAvailableFilterForm() { - return null; // TODO: Implement this method. + protected RPCDataSource<Subject> getDataSource() { + return new SelectedSubjectsDataSource(); }
@Override - protected RPCDataSource<Subject> getDataSource() { - return new SelectedSubjectsDataSource(); + protected DynamicForm getAvailableFilterForm() { + return null; // No Filters Currently }
@Override protected Criteria getLatestCriteria(DynamicForm availableFilterForm) { - return null; // TODO: Implement this method. + return null; // No Filters Currently }
public class SelectedSubjectsDataSource extends UsersDataSource { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java index 5ddbde2..3b9aafb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java @@ -64,12 +64,11 @@ public class RolesDataSource extends RPCDataSource<Role> { }
public RolesDataSource() { - DataSourceField idDataField = new DataSourceIntegerField("id", "ID"); idDataField.setPrimaryKey(true); idDataField.setCanEdit(false);
- DataSourceTextField nameField = new DataSourceTextField("name", "Name"); + DataSourceTextField nameField = new DataSourceTextField("name", "Name", 100, true);
setFields(idDataField, nameField); } @@ -97,9 +96,6 @@ public class RolesDataSource extends RPCDataSource<Role> { }
public void onSuccess(PageList<Role> result) { - - System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start)); - response.setData(buildRecords(result)); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set processResponse(request.getRequestId(), response); @@ -118,7 +114,6 @@ public class RolesDataSource extends RPCDataSource<Role> { Map<String, String> errors = new HashMap<String, String>(); errors.put("name", "A role with name already exists."); response.setErrors(errors); - // CoreGUI.getErrorHandler().handleError("Failed to create role",caught); response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR); processResponse(request.getRequestId(), response); } @@ -137,7 +132,6 @@ public class RolesDataSource extends RPCDataSource<Role> { @Override protected void executeUpdate(final DSRequest request, final DSResponse response) { final ListGridRecord record = getEditedRecord(request); - System.out.println("Updating record: " + record); Role updatedRole = copyValues(record); roleService.updateRole(updatedRole, new AsyncCallback<Role>() { public void onFailure(Throwable caught) { @@ -147,7 +141,6 @@ public class RolesDataSource extends RPCDataSource<Role> { public void onSuccess(Role result) { CoreGUI.getMessageCenter().notify( new Message("Role [" + result.getName() + "] updated", Message.Severity.Info)); - System.out.println("Role Updated"); response.setData(new Record[] { copyValues(result) }); processResponse(request.getRequestId(), response); } @@ -168,7 +161,6 @@ public class RolesDataSource extends RPCDataSource<Role> { public void onSuccess(Void result) { CoreGUI.getMessageCenter().notify( new Message("Role [" + newRole.getName() + "] removed", Message.Severity.Info)); - System.out.println("Role deleted"); response.setData(new Record[] { rec }); processResponse(request.getRequestId(), response); } @@ -176,12 +168,12 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
+ @SuppressWarnings("unchecked") public Role copyValues(ListGridRecord from) { Role to = new Role(); to.setId(from.getAttributeAsInt("id")); to.setName(from.getAttributeAsString("name")); - // to.setDate (from.getAttributeAsDate ("date")); - // from.getAttributeAsIntArray("resourceGroups"); + to.setResourceGroups((Set<ResourceGroup>) from.getAttributeAsObject("resourceGroups")); to.setPermissions((Set<Permission>) from.getAttributeAsObject("permissions")); to.setSubjects((Set<Subject>) from.getAttributeAsObject("subjects")); @@ -192,6 +184,7 @@ public class RolesDataSource extends RPCDataSource<Role> { ListGridRecord to = new ListGridRecord(); to.setAttribute("id", from.getId()); to.setAttribute("name", from.getName()); + to.setAttribute("resourceGroups", from.getResourceGroups()); to.setAttribute("permissions", from.getPermissions()); to.setAttribute("subjects", from.getSubjects()); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java index 55d5bb7..a9ea8b3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java @@ -22,7 +22,6 @@ import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView; -import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; @@ -52,26 +51,15 @@ public class RolesView extends TableSection implements BookmarkableView {
addTableAction(extendLocatorId("New"), "New", new TableAction() { public void executeAction(ListGridRecord[] selection) { - createRole(); + newDetails(); } }); }
- public void createRole() { - RoleEditView editView = new RoleEditView(extendLocatorId("Edit")); - - editView.editNew(); - } - @Override public Canvas getDetailsView(int id) { RoleEditView editor = new RoleEditView(extendLocatorId("Detail"));
return editor; } - - public void renderView(ViewPath viewPath) { - - System.out.println("Display role list"); - } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java deleted file mode 100644 index 38f0e7a..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.admin.users; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.authz.Role; -import org.rhq.core.domain.resource.group.ResourceGroup; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesDataSource; -import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel; -import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource; - -import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.types.DSOperationType; -import com.smartgwt.client.types.DragDataAction; -import com.smartgwt.client.types.DragTrackerMode; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.TransferImgButton; -import com.smartgwt.client.widgets.form.fields.CanvasItem; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.layout.HLayout; -import com.smartgwt.client.widgets.layout.VStack; - -import java.util.List; -import java.util.Set; - -/** - * @author Greg Hinkle - */ -public class SubjectRolesEditorItem extends CanvasItem { - - private Set<Role> assignedRoles; - private Subject subject; - - private ListGrid assignedRoleGrid; - private ListGrid availableRoleGrid; - - public SubjectRolesEditorItem(String name, String title) { - super(name, title); - setShowTitle(false); - setColSpan(2); -// setWidth("90%"); - setCanvas(new SimpleCollapsiblePanel("Assigned Roles", buildForm())); - } - - private Canvas buildForm() { - - HLayout layout = new HLayout(10); - - availableRoleGrid = new ListGrid(); - availableRoleGrid.setHeight(250); - availableRoleGrid.setCanDragRecordsOut(true); - availableRoleGrid.setDragTrackerMode(DragTrackerMode.RECORD); - availableRoleGrid.setDragDataAction(DragDataAction.MOVE); - availableRoleGrid.setDataSource(RolesDataSource.getInstance()); - availableRoleGrid.setAutoFetchData(true); - availableRoleGrid.setFields(new ListGridField("id", 50), new ListGridField("name")); - - layout.addMember(availableRoleGrid); - - VStack moveButtonStack = new VStack(10); - moveButtonStack.setWidth(50); - - TransferImgButton addButton = new TransferImgButton(TransferImgButton.RIGHT); - TransferImgButton removeButton = new TransferImgButton(TransferImgButton.LEFT); - TransferImgButton addAllButton = new TransferImgButton(TransferImgButton.RIGHT_ALL); - TransferImgButton removeAllButton = new TransferImgButton(TransferImgButton.LEFT_ALL); - - moveButtonStack.addMember(addButton); - moveButtonStack.addMember(removeButton); - moveButtonStack.addMember(addAllButton); - moveButtonStack.addMember(removeAllButton); - - layout.addMember(moveButtonStack); - - assignedRoleGrid = new ListGrid(); - assignedRoleGrid.setHeight(250); - assignedRoleGrid.setCanDragRecordsOut(true); - assignedRoleGrid.setCanAcceptDroppedRecords(true); -// assignedRoleGrid.setDataSource(RolesDataSource.getInstance()); - assignedRoleGrid.setFields(new ListGridField("id", 50), new ListGridField("name")); - - layout.addMember(assignedRoleGrid); - - - return layout; - } - - public void setRoles(Set<Role> assignedRoles) { - this.assignedRoles = assignedRoles; - - assignedRoleGrid.setData(RolesDataSource.getInstance().buildRecords(assignedRoles)); - } - - public Set<Role> getRoles() { - return this.assignedRoles; - } - - public Subject getSubject() { - return subject; - } - - public void setSubject(Subject subject) { - this.subject = subject; - if (subject != null) { - assignedRoleGrid.setCriteria(new Criteria("subjectId", String.valueOf(subject.getId()))); - } - } -} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java index bd13da7..279fa33 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java @@ -29,13 +29,13 @@ import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.Record; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.DSOperationType; +import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.TitleOrientation; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.CanvasItem; -import com.smartgwt.client.widgets.form.fields.SectionItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; @@ -60,19 +60,16 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; */ public class UserEditView extends LocatableVLayout implements BookmarkableView {
- private Label message = new Label("Select a user to edit..."); - - // private SubjectRolesEditorItem subjectRolesEditorItem ; + private Label message = new Label("Loading...");
private VLayout editCanvas; private DynamicForm form;
- CanvasItem roleSelectionItem; - private UsersDataSource dataSource;
private Subject subject;
+ private CanvasItem roleSelectionItem; private SubjectRoleSelector roleSelector;
public UserEditView(String locatorId) { @@ -80,15 +77,13 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
dataSource = UsersDataSource.getInstance();
- setWidth100(); - setHeight100(); + setOverflow(Overflow.AUTO);
buildSubjectEditor(); editCanvas.hide();
addMember(message); addMember(editCanvas); - }
private Canvas buildSubjectEditor() { @@ -98,12 +93,10 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { form.setHiliteRequiredFields(true); form.setRequiredTitleSuffix("* :");
- SectionItem userEditSection = new SectionItem("userEditSection", "Edit User"); - - form.setUseAllDataSourceFields(true); form.setDataSource(dataSource); + form.setUseAllDataSourceFields(true);
- this.roleSelectionItem = new CanvasItem("selectRoles", "Select Roles"); + this.roleSelectionItem = new CanvasItem("selectRoles", "Assigned Roles"); this.roleSelectionItem.setTitleOrientation(TitleOrientation.TOP); this.roleSelectionItem.setColSpan(2);
@@ -152,8 +145,10 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
public void save() { final HashSet<Integer> roles = roleSelector.getSelection(); - // The form.saveData() call triggers UsersDataSource.executeAdd() to create the new Subject. On - // successful create we need to perform the role assignment, so set this callback on completion. + + // The form.saveData() call triggers either UsersDataSource.executeAdd() to create the new Subject, + // or executeUpdate() if saving changes to an existing Subject. On success we need to perform the + // subsequent role assignment, so set this callback on completion. form.saveData(new DSCallback() { public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
@@ -168,21 +163,21 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { GWTServiceLookup.getRoleService().setAssignedSubjectRoles(subjectId, roleIds, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to set subject role assignments.", caught); + CoreGUI.getErrorHandler().handleError("Failed to save user role assignments.", caught); History.back(); }
public void onSuccess(Void result) { CoreGUI.getMessageCenter().notify( - new Message("Succesfully saved new user roles.", Message.Severity.Info)); + new Message("Succesfully saved user role assignments.", Message.Severity.Info)); History.back(); } }); - } }); }
+ @SuppressWarnings("unchecked") public void editRecord(Record record) { roleSelector = new SubjectRoleSelector(this.extendLocatorId("Roles"), (Set<Role>) record .getAttributeAsObject("roles")); @@ -200,13 +195,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { markForRedraw(); }
- public void editNone() { - message.show(); - editCanvas.hide(); - markForRedraw(); - } - - public void editNewInternal() { + private void editNewInternal() { subject = new Subject(); ListGridRecord r = dataSource.copyValues(subject); editRecord(r); @@ -247,6 +236,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { CoreGUI.refreshBreadCrumbTrail(); } }); + } else { editNewInternal(); current.getBreadcrumbs().get(0).setDisplayName("New User"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java index 809edec..470b144 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java @@ -97,11 +97,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
- DataSourceField roles = new DataSourceField(); - roles.setForeignKey("Roles.id"); - roles.setName("roles"); - roles.setMultiple(true); - setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress, department); } @@ -121,16 +116,7 @@ public class UsersDataSource extends RPCDataSource<Subject> { }
public void onSuccess(PageList<Subject> result) { - System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start)); - - ListGridRecord[] records = new ListGridRecord[result.size()]; - for (int x = 0; x < result.size(); x++) { - Subject subject = result.get(x); - - records[x] = copyValues(subject); - } - - response.setData(records); + response.setData(buildRecords(result)); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set processResponse(request.getRequestId(), response); } @@ -177,7 +163,6 @@ public class UsersDataSource extends RPCDataSource<Subject> { @Override protected void executeUpdate(final DSRequest request, final DSResponse response) { final ListGridRecord record = getEditedRecord(request); - System.out.println("Updating record: " + record); final Subject updatedSubject = copyValues(record); subjectService.updateSubject(updatedSubject, new AsyncCallback<Subject>() { public void onFailure(Throwable caught) { @@ -202,7 +187,6 @@ public class UsersDataSource extends RPCDataSource<Subject> { } }); } else { - System.out.println("Subject Updated"); CoreGUI.getMessageCenter().notify( new Message("User [" + result.getName() + "] updated", Message.Severity.Info)); response.setData(new Record[] { copyValues(result) }); @@ -233,6 +217,7 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
+ @SuppressWarnings("unchecked") public Subject copyValues(ListGridRecord from) { Subject to = new Subject(); to.setId(from.getAttributeAsInt("id")); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java index 72e2aa7..e1de74d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java @@ -32,7 +32,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; public class UsersView extends TableSection {
public UsersView(String locatorId) { - super(locatorId, "Users View"); + super(locatorId, "Users");
final UsersDataSource datasource = UsersDataSource.getInstance();
@@ -43,8 +43,6 @@ public class UsersView extends TableSection { protected void configureTable() {
final ListGrid grid = getListGrid(); - grid.getField("id").setWidth(20); - grid.getField("name").setWidth(100); grid.hideField("password"); grid.hideField("passwordVerify");
@@ -64,6 +62,7 @@ public class UsersView extends TableSection {
public Canvas getDetailsView(int id) { final UserEditView userEditor = new UserEditView(extendLocatorId("Detail")); + return userEditor; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java index cb09a01..ed9163d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java @@ -26,24 +26,23 @@ import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.layout.VLayout;
/** + * TODO: Not Quite Working. For some reason the icon is not clickable. + * * @author Greg Hinkle */ public class SimpleCollapsiblePanel extends VLayout {
- private Canvas content; private String title;
private boolean expanded = true;
- public SimpleCollapsiblePanel(String title, Canvas content) { this.content = content; this.title = title; setWidth100(); }
- @Override protected void onInit() { super.onInit(); @@ -51,12 +50,11 @@ public class SimpleCollapsiblePanel extends VLayout { final Button button = new Button(title); button.setShowRollOver(false); button.setActionType(SelectionType.RADIO); - button.setBorder(null); + //button.setBorder(null); button.setAutoFit(true);
- button.setIcon("[skin]/images/SectionHeader/opener_opened.png"); - button.setBaseStyle("SimpleButton"); + //button.setBaseStyle("SimpleButton");
button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { @@ -74,7 +72,6 @@ public class SimpleCollapsiblePanel extends VLayout { } });
- addMember(button); addMember(content); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java index 1617a2d..1c8774f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java @@ -129,6 +129,9 @@ public abstract class AbstractSelector<T> extends LocatableVLayout { @Override public void run() { if (latestCriteria != null) { + // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data + availableGrid.invalidateCache(); + Criteria c = latestCriteria; latestCriteria = null; availableGrid.fetchData(c); @@ -144,12 +147,12 @@ public abstract class AbstractSelector<T> extends LocatableVLayout { moveButtonStack.setAlign(VerticalAlignment.CENTER); moveButtonStack.setWidth(40);
- addButton = new LocatableTransferImgButton(TransferImgButton.RIGHT); + addButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.RIGHT); addButton.setDisabled(true); - removeButton = new LocatableTransferImgButton(TransferImgButton.LEFT); + removeButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.LEFT); removeButton.setDisabled(true); - addAllButton = new LocatableTransferImgButton(TransferImgButton.RIGHT_ALL); - removeAllButton = new LocatableTransferImgButton(TransferImgButton.LEFT_ALL); + addAllButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.RIGHT_ALL); + removeAllButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.LEFT_ALL); removeAllButton.setDisabled(true);
moveButtonStack.addMember(addButton); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java index 9bd3a6a..a1303a1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java @@ -79,8 +79,9 @@ public abstract class TableSection extends Table implements BookmarkableView { super.onInit();
detailsHolder = new VLayout(); - detailsHolder.setWidth100(); - detailsHolder.setHeight100(); + //detailsHolder.setWidth100(); + //detailsHolder.setHeight100(); + detailsHolder.setMargin(5); detailsHolder.hide();
addMember(detailsHolder); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java index 9de2407..00e9389 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java @@ -42,8 +42,6 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; */ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
- private String query; - private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
private static ResourceGroupsDataSource INSTANCE; @@ -85,14 +83,12 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
groupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load groups", caught); + CoreGUI.getErrorHandler().handleError("Failed to fetch groups data", caught); response.setStatus(RPCResponse.STATUS_FAILURE); processResponse(request.getRequestId(), response); }
public void onSuccess(PageList<ResourceGroup> result) { - System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start)); - response.setData(buildRecords(result)); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set processResponse(request.getRequestId(), response); @@ -104,7 +100,10 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> { ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.setPageControl(getPageControl(request)); - criteria.addFilterName(query); + + if (request.getCriteria().getValues().get("name") != null) { + criteria.addFilterName((String) request.getCriteria().getValues().get("name")); + }
if (request.getCriteria().getValues().get("category") != null) { criteria.addFilterGroupCategory(GroupCategory.valueOf(((String) request.getCriteria().getValues().get( diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java index f2f15dc..c983dee 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java @@ -21,29 +21,33 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection; import java.util.Collection;
import com.smartgwt.client.data.Criteria; +import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.SpacerItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector; import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** * @author Greg Hinkle */ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
- public ResourceGroupSelector(String id) { - super(id); + public ResourceGroupSelector(String locatorId) { + super(locatorId); }
protected DynamicForm getAvailableFilterForm() { - DynamicForm availableFilterForm = new DynamicForm(); - availableFilterForm.setNumCols(5); + DynamicForm availableFilterForm = new LocatableDynamicForm(this.getLocatorId()); + availableFilterForm.setWidth100(); + availableFilterForm.setNumCols(4);
final TextItem search = new TextItem("search", "Search");
@@ -61,7 +65,7 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
// TODO: Until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed, avoid AdvancedCriteria and always // use server-side fetch and simple criteria. When fixed, use the commented version below. Also see - // ResourceGroupDataSource. + // AbstractSelector and ResourceGroupDataSource. protected Criteria getLatestCriteria(DynamicForm availableFilterForm) { String search = (String) availableFilterForm.getValue("search"); String category = (String) availableFilterForm.getValue("groupCategory"); @@ -104,5 +108,15 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> { } return records; } + + @Override + protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) { + ResourceGroupCriteria result = super.getFetchCriteria(request); + if (null != result) { + result.setStrict(false); + } + return result; + } + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java index e255096..efbd818 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java @@ -7,28 +7,22 @@ import com.smartgwt.client.widgets.TransferImgButton; * * @author Jay Shaughnessy */ -public class LocatableTransferImgButton extends TransferImgButton { +public class LocatableTransferImgButton extends TransferImgButton implements Locatable {
- /** - * <pre> - * ID Format: "simpleClassname-imgName" - * </pre> - * @param img not null. - */ - public LocatableTransferImgButton(TransferImg img) { - this(getSuffix(img), img); - } + private String locatorId;
/** * <pre> - * ID Format: "simpleClassname_locatorId" + * ID Format: "simpleClassname_locatorId_imgName" * </pre> * @param locatorId not null. * @param img not null or empty. */ public LocatableTransferImgButton(String locatorId, TransferImg img) { super(img); - SeleniumUtility.setID(this, locatorId); + this.locatorId = locatorId; + this.locatorId = extendLocatorId(getSuffix(img)); + SeleniumUtility.setID(this, this.locatorId); }
static private String getSuffix(TransferImg img) { @@ -54,4 +48,12 @@ public class LocatableTransferImgButton extends TransferImgButton { return img.toString(); }
+ public String getLocatorId() { + return locatorId; + } + + public String extendLocatorId(String extension) { + return this.locatorId + "_" + extension; + } + } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java index 7770cba..aeac399 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java @@ -66,6 +66,9 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { private EntityManager entityManager;
@EJB + private RoleManagerLocal roleManager; // self-referencing + + @EJB private SubjectManagerLocal subjectManager;
@EJB @@ -262,7 +265,6 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { return; }
- @RequiredPermission(Permission.MANAGE_SECURITY) public void setAssignedSubjectRoles(Subject subject, int subjectId, int[] roleIds) {
@@ -280,23 +282,21 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { for (Integer id : newRoles) { newRoleIds[i++] = id; } - addRolesToSubject(subject, subjectId, newRoleIds); + roleManager.addRolesToSubject(subject, subjectId, newRoleIds); }
- List<Integer> extraMembers = new ArrayList<Integer>(currentRoles); // members needing removal - extraMembers.removeAll(ArrayUtils.wrapInList(roleIds)); - if (extraMembers.size() > 0) { - int[] extraMemberIds = new int[extraMembers.size()]; + List<Integer> removedRoles = new ArrayList<Integer>(currentRoles); // members needing removal + removedRoles.removeAll(ArrayUtils.wrapInList(roleIds)); + if (removedRoles.size() > 0) { + int[] removedRoleIds = new int[removedRoles.size()]; int i = 0; - for (Integer id : extraMembers) { - extraMemberIds[i++] = id; + for (Integer id : removedRoles) { + removedRoleIds[i++] = id; } - removeRolesFromSubject(subject, subjectId, extraMemberIds); + roleManager.removeRolesFromSubject(subject, subjectId, removedRoleIds); } }
- - /** * @see org.rhq.enterprise.server.authz.RoleManagerLocal#getRoleById(Integer) */ @@ -491,32 +491,32 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { public void setAssignedResourceGroups(Subject subject, int roleId, int[] groupIds) {
Role role = getRole(subject, roleId); - List<Integer> currentMembers = new ArrayList<Integer>(); + List<Integer> currentGroups = new ArrayList<Integer>(); for (ResourceGroup group : role.getResourceGroups()) { - currentMembers.add(group.getId()); + currentGroups.add(group.getId()); }
- List<Integer> newMembers = ArrayUtils.wrapInList(groupIds); // members needing addition - newMembers.removeAll(currentMembers); - if (newMembers.size() > 0) { - int[] newMemberInts = new int[newMembers.size()]; + List<Integer> newGroups = ArrayUtils.wrapInList(groupIds); // members needing addition + newGroups.removeAll(currentGroups); + if (newGroups.size() > 0) { + int[] newGroupIds = new int[newGroups.size()]; int i = 0; - for (Integer id : newMembers) { - newMemberInts[i++] = id; + for (Integer id : newGroups) { + newGroupIds[i++] = id; } - addResourceGroupsToRole(subject, roleId, newMemberInts); + roleManager.addResourceGroupsToRole(subject, roleId, newGroupIds); }
- List<Integer> extraMembers = new ArrayList<Integer>(currentMembers); // members needing removal - extraMembers.removeAll(ArrayUtils.wrapInList(groupIds)); - if (extraMembers.size() > 0) { - int[] removeMemberInts = new int[extraMembers.size()]; + List<Integer> removedGroups = new ArrayList<Integer>(currentGroups); // members needing removal + removedGroups.removeAll(ArrayUtils.wrapInList(groupIds)); + if (removedGroups.size() > 0) { + int[] removedGroupIds = new int[removedGroups.size()]; int i = 0; - for (Integer id : extraMembers) { - removeMemberInts[i++] = id; + for (Integer id : removedGroups) { + removedGroupIds[i++] = id; }
- removeResourceGroupsFromRole(subject, roleId, removeMemberInts); + roleManager.removeResourceGroupsFromRole(subject, roleId, removedGroupIds); } }
@@ -564,32 +564,33 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
@RequiredPermission(Permission.MANAGE_SECURITY) public void setAssignedSubjects(Subject subject, int roleId, int[] subjectIds) { + Role role = getRole(subject, roleId); - List<Integer> currentMembers = new ArrayList<Integer>(); - for (ResourceGroup group : role.getResourceGroups()) { - currentMembers.add(group.getId()); + List<Integer> currentSubjects = new ArrayList<Integer>(); + for (Subject currentSubject : role.getSubjects()) { + currentSubjects.add(currentSubject.getId()); }
- List<Integer> newMembers = ArrayUtils.wrapInList(subjectIds); // members needing addition - newMembers.removeAll(currentMembers); - if (newMembers.size() > 0) { - int[] newMemberIds = new int[newMembers.size()]; + List<Integer> newSubjects = ArrayUtils.wrapInList(subjectIds); // members needing addition + newSubjects.removeAll(currentSubjects); + if (newSubjects.size() > 0) { + int[] newSubjectIds = new int[newSubjects.size()]; int i = 0; - for (Integer id : newMembers) { - newMemberIds[i++] = id; + for (Integer id : newSubjects) { + newSubjectIds[i++] = id; } - addSubjectsToRole(subject, roleId, newMemberIds); + roleManager.addSubjectsToRole(subject, roleId, newSubjectIds); }
- List<Integer> extraMembers = new ArrayList<Integer>(currentMembers); // members needing removal - extraMembers.removeAll(ArrayUtils.wrapInList(subjectIds)); - if (extraMembers.size() > 0) { - int[] removeMemberIds = new int[extraMembers.size()]; + List<Integer> removedSubjects = new ArrayList<Integer>(currentSubjects); // members needing removal + removedSubjects.removeAll(ArrayUtils.wrapInList(subjectIds)); + if (removedSubjects.size() > 0) { + int[] removedSubjectIds = new int[removedSubjects.size()]; int i = 0; - for (Integer id : extraMembers) { - removeMemberIds[i++] = id; + for (Integer id : removedSubjects) { + removedSubjectIds[i++] = id; } - removeSubjectsFromRole(subject, roleId, removeMemberIds); + roleManager.removeSubjectsFromRole(subject, roleId, removedSubjectIds); } }
commit fc50175d9159e90c52b8839283d7baba4323336e Author: Simeon Pinder spinder@redhat.com Date: Mon Sep 13 20:46:27 2010 -0400
enable server side operations portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java index ce381ce..54647a1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java @@ -64,14 +64,15 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting private static final String TITLE = KEY; private static String recentOperations = "Recent Operations"; private static String scheduledOperations = "Scheduled Operations"; - private boolean operationsRangeLastEnabled = false; - private boolean operationsRangeNextEnabled = false; - private int operationsRangeScheduled = -1; - private int operationsRangeCompleted = -1; + public static String RANGE_DISABLED_MESSAGE = "(Results currently disabled. Change settings to enable results.)"; + //TODO: change this to use the Smart GWT default value. + public static String RANGE_DISABLED_MESSAGE_DEFAULT = "No items to show."; //ListGrids for operations private LocatableListGrid recentOperationsGrid = null; private LocatableListGrid scheduledOperationsGrid = null; private DashboardPortlet storedPortlet = null; + private RecentOperationsDataSource dataSourceCompleted; + private ScheduledOperationsDataSource dataSourceScheduled; public static String unlimited = "unlimited"; public static String defaultValue = unlimited; public static boolean defaultEnabled = true; @@ -83,17 +84,18 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
public OperationsPortlet(String locatorId) { super(locatorId); + this.dataSourceCompleted = new RecentOperationsDataSource(this); + this.dataSourceScheduled = new ScheduledOperationsDataSource(this); }
@Override protected void onInit() { super.onInit(); - //set title for larger container setTitle(TITLE);
this.recentOperationsGrid = new LocatableListGrid(recentOperations); - recentOperationsGrid.setDataSource(new RecentOperationsDataSource()); + recentOperationsGrid.setDataSource(getDataSourceCompleted()); recentOperationsGrid.setAutoFetchData(true); recentOperationsGrid.setTitle(recentOperations); recentOperationsGrid.setWidth100(); @@ -111,7 +113,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
// Add the list table as the top half of the view. this.scheduledOperationsGrid = new LocatableListGrid(scheduledOperations); - scheduledOperationsGrid.setDataSource(new ScheduledOperationsDataSource()); + scheduledOperationsGrid.setDataSource(getDataSourceScheduled()); scheduledOperationsGrid.setAutoFetchData(true); scheduledOperationsGrid.setTitle(scheduledOperations); scheduledOperationsGrid.setWidth100(); @@ -140,42 +142,44 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting //retrieve and translate to int String retrieved = property.getStringValue(); if (retrieved.equals(unlimited)) { - setOperationsRangeCompleted(-1); + getDataSourceCompleted().setOperationsRangeCompleted(-1); } else { - setOperationsRangeCompleted(Integer.parseInt(retrieved)); + getDataSourceCompleted().setOperationsRangeCompleted(Integer.parseInt(retrieved)); } } else {//create setting storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue)); - setOperationsRangeCompleted(-1); + getDataSourceCompleted().setOperationsRangeCompleted(-1); } + property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED); if ((property != null) && (property.getStringValue() != null)) { //retrieve and translate to int String retrieved = property.getStringValue(); if (retrieved.equals(unlimited)) { - setOperationsRangeScheduled(-1); + getDataSourceScheduled().setOperationsRangeScheduled(-1); } else { - setOperationsRangeScheduled(Integer.parseInt(retrieved)); + getDataSourceScheduled().setOperationsRangeScheduled(Integer.parseInt(retrieved)); } } else {//create setting storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue)); - setOperationsRangeScheduled(-1); + getDataSourceScheduled().setOperationsRangeScheduled(-1); } //Checkbox settings property property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED); if ((property != null) && (property.getBooleanValue() != null)) { - setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue()); + getDataSourceScheduled().setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue()); } else {//create setting storedPortlet.getConfiguration() .put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, defaultEnabled)); - setOperationsRangeScheduleEnabled(defaultEnabled); + getDataSourceScheduled().setOperationsRangeScheduleEnabled(defaultEnabled); } property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED); if ((property != null) && (property.getBooleanValue() != null)) { - setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue()); + getDataSourceCompleted().setOperationsRangeCompleteEnabled(property.getBooleanValue().booleanValue()); } else {//create setting storedPortlet.getConfiguration() .put(new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, defaultEnabled)); + getDataSourceCompleted().setOperationsRangeCompleteEnabled(defaultEnabled); } }
@@ -359,38 +363,6 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting } }
- public boolean isOperationsRangeCompletedEnabled() { - return operationsRangeLastEnabled; - } - - public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) { - this.operationsRangeLastEnabled = operationsRangeLastEnabled; - } - - public boolean isOperationsRangeScheduleEnabled() { - return operationsRangeNextEnabled; - } - - public void setOperationsRangeScheduleEnabled(boolean operationsRangeNextEnabled) { - this.operationsRangeNextEnabled = operationsRangeNextEnabled; - } - - public int getOperationsRangeScheduled() { - return operationsRangeScheduled; - } - - public void setOperationsRangeScheduled(int operationsRangeScheduled) { - this.operationsRangeScheduled = operationsRangeScheduled; - } - - public int getOperationsRangeCompleted() { - return operationsRangeCompleted; - } - - public void setOperationsRangeCompleted(int operationsRangeCompleted) { - this.operationsRangeCompleted = operationsRangeCompleted; - } - /** Custom refresh operation as we cannot directly extend Table because it only * contains one ListGrid while the OperationsPortlet displays two tables. */ @@ -424,4 +396,19 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting return definition; }
+ public RecentOperationsDataSource getDataSourceCompleted() { + return this.dataSourceCompleted; + } + + public ScheduledOperationsDataSource getDataSourceScheduled() { + return this.dataSourceScheduled; + } + + public LocatableListGrid getCompletedOperationsGrid() { + return this.recentOperationsGrid; + } + + public LocatableListGrid getScheduledOperationsGrid() { + return this.scheduledOperationsGrid; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java index 72f2fb9..b74efea 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java @@ -24,7 +24,6 @@ import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria; -import org.rhq.core.domain.criteria.ResourceCriteria; import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria; import org.rhq.core.domain.operation.GroupOperationHistory; import org.rhq.core.domain.operation.ResourceOperationHistory; @@ -44,10 +43,9 @@ public interface OperationGWTService extends RemoteService {
PageList<GroupOperationHistory> findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria);
- List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations( - ResourceCriteria criteria); + List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(int pageSize);
- List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(ResourceCriteria criteria); + List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize);
void scheduleResourceOperation(int resourceId, String operationName, Configuration parameters, ExecutionSchedule schedule, String description, int timeout) throws RuntimeException; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java index e53708c..2c02f25 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java @@ -31,11 +31,12 @@ import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria; import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite; import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; @@ -52,10 +53,18 @@ public class RecentOperationsDataSource extends public static final String operation = "operation"; public static final String time = "time"; public static final String status = "status"; + private Portlet portlet; + + //config attributes + private boolean operationsRangeLastEnabled = false; + private int operationsRangeCompleted = -1; + private boolean dataRangeDisabled = true; + public static String RANGE_DISABLED_MESSAGE = "(Results currently disabled. Change settings to enable results.)";
/** Build list of fields for the datasource and then adds them to it. */ - public RecentOperationsDataSource() { + public RecentOperationsDataSource(Portlet portlet) { + this.portlet = portlet; setClientOnly(false); setDataProtocol(DSProtocol.CLIENTCUSTOM); setDataFormat(DSDataFormat.CUSTOM); @@ -100,9 +109,30 @@ public class RecentOperationsDataSource extends * @param response outgoing response */ public void executeFetch(final DSRequest request, final DSResponse response) { + int pageSize = -1; + //retrieve current portlet display settings + if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) { + OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet; + //populate criteria with portlet preferences defined. + if (operationsPortlet != null) { + if (isOperationsRangeCompletedEnabled()) { + pageSize = getOperationsRangeCompleted(); + operationsPortlet.getCompletedOperationsGrid().setEmptyMessage( + OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT); + } else {//show the component, return no results and indicate that you've disabled this display + pageSize = 0; + operationsPortlet.getCompletedOperationsGrid().setEmptyMessage( + OperationsPortlet.RANGE_DISABLED_MESSAGE); + response.setData(null); + response.setTotalRows(0); + //pass off for processing + processResponse(request.getRequestId(), response); + return; + } + } + }
- ResourceCriteria c = new ResourceCriteria(); - GWTServiceLookup.getOperationService().findRecentCompletedOperations(c, + GWTServiceLookup.getOperationService().findRecentCompletedOperations(pageSize, new AsyncCallback<List<DisambiguationReport<ResourceOperationLastCompletedComposite>>>() {
public void onFailure(Throwable throwable) { @@ -204,4 +234,21 @@ public class RecentOperationsDataSource extends
return record; } + + public boolean isOperationsRangeCompletedEnabled() { + return operationsRangeLastEnabled; + } + + public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) { + this.operationsRangeLastEnabled = operationsRangeLastEnabled; + } + + public int getOperationsRangeCompleted() { + return operationsRangeCompleted; + } + + public void setOperationsRangeCompleted(int operationsRangeCompleted) { + this.operationsRangeCompleted = operationsRangeCompleted; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java index 4f58644..ebb1185 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java @@ -30,10 +30,11 @@ import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria; import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite; import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; @@ -49,10 +50,15 @@ public class ScheduledOperationsDataSource extends public static final String location = "location"; public static final String operation = "operation"; public static final String time = "time"; + //config settings + private boolean operationsRangeNextEnabled = false; + private int operationsRangeScheduled = -1; + private Portlet portlet;
/** Build list of fields for the datasource and then adds them to it. */ - public ScheduledOperationsDataSource() { + public ScheduledOperationsDataSource(Portlet portlet) { + this.portlet = portlet; setClientOnly(false); setDataProtocol(DSProtocol.CLIENTCUSTOM); setDataFormat(DSDataFormat.CUSTOM); @@ -96,8 +102,30 @@ public class ScheduledOperationsDataSource extends */ public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria c = new ResourceCriteria(); - GWTServiceLookup.getOperationService().findScheduledOperations(c, + int pageSize = -1; + //retrieve current portlet display settings + if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) { + OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet; + //populate criteria with portlet preferences defined. + if (operationsPortlet != null) { + if (isOperationsRangeScheduleEnabled()) { + pageSize = getOperationsRangeScheduled(); + operationsPortlet.getScheduledOperationsGrid().setEmptyMessage( + OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT); + } else {//show the component, return no results and indicate that you've disabled this display + pageSize = 0; + operationsPortlet.getScheduledOperationsGrid().setEmptyMessage( + OperationsPortlet.RANGE_DISABLED_MESSAGE); + response.setData(null); + response.setTotalRows(0); + //pass off for processing + processResponse(request.getRequestId(), response); + return; + } + } + } + + GWTServiceLookup.getOperationService().findScheduledOperations(pageSize, new AsyncCallback<List<DisambiguationReport<ResourceOperationScheduleComposite>>>() {
public void onFailure(Throwable throwable) { @@ -172,4 +200,21 @@ public class ScheduledOperationsDataSource extends return record;
} + + public boolean isOperationsRangeScheduleEnabled() { + return operationsRangeNextEnabled; + } + + public void setOperationsRangeScheduleEnabled(boolean operationsRangeNextEnabled) { + this.operationsRangeNextEnabled = operationsRangeNextEnabled; + } + + public int getOperationsRangeScheduled() { + return operationsRangeScheduled; + } + + public void setOperationsRangeScheduled(int operationsRangeScheduled) { + this.operationsRangeScheduled = operationsRangeScheduled; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java index e44c086..a7f72ed 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java @@ -24,7 +24,6 @@ import org.quartz.CronTrigger;
import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria; -import org.rhq.core.domain.criteria.ResourceCriteria; import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria; import org.rhq.core.domain.operation.GroupOperationHistory; import org.rhq.core.domain.operation.ResourceOperationHistory; @@ -88,9 +87,9 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O * */ public List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations( - ResourceCriteria criteria) { + int pageSize) {
- PageControl pageControl = new PageControl(0, -1); + PageControl pageControl = new PageControl(0, pageSize); PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = operationManager .findRecentlyCompletedResourceOperations(getSessionSubject(), null, pageControl);
@@ -105,10 +104,9 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O /** Find scheduled operations, disambiguate them and return that list. * */ - public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations( - ResourceCriteria criteria) { + public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize) {
- PageControl pageControl = new PageControl(0, -1); + PageControl pageControl = new PageControl(0, pageSize); PageList<ResourceOperationScheduleComposite> scheduledResourceOps = operationManager .findCurrentlyScheduledResourceOperations(getSessionSubject(), pageControl);
commit b9b50704a663d86eb0f961aa45c09cc2cc40063a Author: John Mazzitelli mazz@redhat.com Date: Mon Sep 13 17:23:27 2010 -0400
abstract out the save method since different SLSBs need to be called depending on the type of alert def (resource, group, or template)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java index 657fd5c..ce834da 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java @@ -119,14 +119,14 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
AlertDefinition alertDef = getAlertDefinitionDataSource().copyValues(record); SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this - .extendLocatorId(alertDef.getName()), getResourceType(), alertDef); + .extendLocatorId(alertDef.getName()), this, alertDef); return singleAlertDefinitionView; }
@Override public SingleAlertDefinitionView getDetailsView(int id) { final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this - .extendLocatorId("singleAlertDefinitionView"), getResourceType()); + .extendLocatorId("singleAlertDefinitionView"), this);
if (id == 0) { // create an empty one with all defaults @@ -176,4 +176,6 @@ public abstract class AbstractAlertDefinitionsView extends TableSection { protected abstract void enableButtonPressed(ListGridRecord[] selection);
protected abstract void disableButtonPressed(ListGridRecord[] selection); + + protected abstract void commitAlertDefinition(AlertDefinition alertDefinition); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java index ec67b08..0c7cdff 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java @@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -106,4 +107,11 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView { } SC.say(str); } + + @Override + protected void commitAlertDefinition(AlertDefinition alertDefinition) { + // TODO call into server SLSB to store alert def + // GroupAlertDefinitionManagerLocal groupAlertDefinitionManager = LookupUtil.getGroupAlertDefinitionManager(); + // groupAlertDefinitionManager.updateGroupAlertDefinitions(subject, alertDef, true); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java index 83a8629..da46f44 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java @@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType;
@@ -101,4 +102,12 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView { } SC.say(str); } + + @Override + protected void commitAlertDefinition(AlertDefinition alertDefinition) { + System.out.println("=======================================>" + alertDefinition); + // TODO call into server SLSB to store alert def + // AlertDefinitionManagerLocal alertDefinitionManager = LookupUtil.getAlertDefinitionManager(); + // alertDefinitionManager.updateAlertDefinition(subject, alertDef.getId(), alertDef, true); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java index 7cf6356..bc7a8b0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java @@ -30,8 +30,6 @@ import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet; @@ -54,11 +52,12 @@ public class SingleAlertDefinitionView extends LocatableVLayout { private Button saveButton; private Button cancelButton;
- public SingleAlertDefinitionView(String locatorId, ResourceType resourceType) { - this(locatorId, resourceType, null); + public SingleAlertDefinitionView(String locatorId, AbstractAlertDefinitionsView alertDefView) { + this(locatorId, alertDefView, null); }
- public SingleAlertDefinitionView(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) { + public SingleAlertDefinitionView(String locatorId, final AbstractAlertDefinitionsView alertDefView, + AlertDefinition alertDefinition) { super(locatorId);
this.alertDefinition = alertDefinition; @@ -71,7 +70,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout { generalPropertiesTab.setPane(generalProperties);
Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), "Conditions"); - conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), resourceType, alertDefinition); + conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), alertDefView.getResourceType(), + alertDefinition); conditionsTab.setPane(conditions);
Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"), "Notifications"); @@ -117,8 +117,9 @@ public class SingleAlertDefinitionView extends LocatableVLayout { setAlertDefinition(getAlertDefinition()); // loads data into static fields makeViewOnly();
- // TODO getAlertDefinition() should now have the new user data - commit it to DB - CoreGUI.refresh(); + alertDefView.commitAlertDefinition(getAlertDefinition()); + + alertDefView.refresh(); } });
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java index d5a5e14..3ef3dfe 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java @@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.resource.ResourceType;
/** @@ -105,4 +106,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView { } SC.say(str); } + + @Override + protected void commitAlertDefinition(AlertDefinition alertDefinition) { + // TODO call into server SLSB to store alert def + // AlertTemplateManagerLocal alertTemplateManager = LookupUtil.getAlertTemplateManager(); + // alertTemplateManager.updateAlertTemplate(subject, alertDef, true); + } }
commit f1599977fb315f35391f8b8c54babc40c5b062ea Author: John Mazzitelli mazz@redhat.com Date: Mon Sep 13 17:08:19 2010 -0400
builds the conditions object and sets the new condition in the alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index 78261a3..7b85eae 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -111,7 +111,13 @@ public class ConditionsEditor extends LocatableVLayout { });
NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"), - conditions, ConditionsEditor.this.resourceType, winModal); + conditions, ConditionsEditor.this.resourceType, new Runnable() { + @Override + public void run() { + winModal.markForDestroy(); + table.refresh(); + } + }); winModal.addItem(newConditionEditor); winModal.show(); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index 7922824..bd20b0a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -24,13 +24,11 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList; -import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Set;
import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.FormItemIfFunction; import com.smartgwt.client.widgets.form.fields.ButtonItem; @@ -46,10 +44,12 @@ import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertConditionCategory; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** @@ -57,42 +57,49 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; */ public class NewConditionEditor extends LocatableDynamicForm {
+ private static final String AVAILABILITY_ITEMNAME = "availability"; + private static final String THRESHOLD_METRIC_ITEMNAME = "thresholdMetric"; + private static final String THRESHOLD_COMPARATOR_ITEMNAME = "thresholdComparator"; + private static final String THRESHOLD_ABSVALUE_ITEMNAME = "metricAbsoluteValue"; + private static final String BASELINE_METRIC_ITEMNAME = "baselineMetric"; + private static final String BASELINE_COMPARATOR_ITEMNAME = "baselineComparator"; + private static final String BASELINE_PERCENTAGE_ITEMNAME = "baselinePercentage"; + private static final String BASELINE_SELECTION_ITEMNAME = "baselineSelection"; + private static final String CHANGE_METRIC_ITEMNAME = "changeMetric"; + private static final String TRAIT_METRIC_ITEMNAME = "trait"; + private static final String OPERATION_NAME_ITEMNAME = "operation"; + private static final String OPERATION_RESULTS_ITEMNAME = "operationResults"; + private static final String EVENT_SEVERITY_ITEMNAME = "eventSeverity"; + private static final String EVENT_REGEX_ITEMNAME = "eventRegex"; + private SelectItem conditionTypeSelectItem; private HashSet<AlertCondition> conditions; // the new condition we create goes into this set - private Collection<String> metrics; - private Collection<String> traits; - private Collection<String> operations; - private boolean supportsEvents; - private Window parentWindow; // where this form is located; after form is OK'ed, this window will be destroyed + private boolean supportsMetrics = false; + private boolean supportsTraits = false; + private boolean supportsOperations = false; + private boolean supportsEvents = false; + private Runnable okFunction; // this is called after the OK button is pressed and a new condition is saved + private ResourceType resourceType;
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Window parent) { + public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Runnable okFunc) {
super(locatorId); this.conditions = conditions; - this.parentWindow = parent; + this.okFunction = okFunc; + this.resourceType = rtype;
this.supportsEvents = (rtype.getEventDefinitions() != null & rtype.getEventDefinitions().size() > 0);
Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions(); - Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions(); - if (metricDefinitions == null || metricDefinitions.size() == 0) { - this.metrics = null; - this.traits = null; - } else { + if (metricDefinitions != null && metricDefinitions.size() > 0) { for (MeasurementDefinition measurementDefinition : metricDefinitions) { switch (measurementDefinition.getDataType()) { case MEASUREMENT: { - if (this.metrics == null) { - this.metrics = new ArrayList<String>(); - } - this.metrics.add(measurementDefinition.getDisplayName()); + this.supportsMetrics = true; break; } case TRAIT: { - if (this.traits == null) { - this.traits = new ArrayList<String>(); - } - this.traits.add(measurementDefinition.getDisplayName()); + this.supportsTraits = true; break; } default: { @@ -102,13 +109,9 @@ public class NewConditionEditor extends LocatableDynamicForm { } }
- if (operationDefinitions == null || operationDefinitions.size() == 0) { - this.operations = null; - } else { - this.operations = new ArrayList<String>(operationDefinitions.size()); - for (OperationDefinition operationDefinition : operationDefinitions) { - this.operations.add(operationDefinition.getDisplayName()); - } + Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions(); + if (operationDefinitions != null && operationDefinitions.size() > 0) { + this.supportsOperations = true; } }
@@ -121,15 +124,15 @@ public class NewConditionEditor extends LocatableDynamicForm { conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type"); LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7); condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability Change"); - if (metrics != null) { + if (supportsMetrics) { condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold"); condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold"); condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change"); } - if (traits != null) { + if (supportsTraits) { condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change"); } - if (operations != null) { + if (supportsOperations) { condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution"); } if (supportsEvents) { @@ -152,8 +155,8 @@ public class NewConditionEditor extends LocatableDynamicForm { @Override public void onClick(ClickEvent event) { if (validate(false)) { - // TODO - NewConditionEditor.this.parentWindow.markForDestroy(); + saveNewCondition(); + okFunction.run(); } } }); @@ -162,15 +165,15 @@ public class NewConditionEditor extends LocatableDynamicForm { formItems.add(conditionTypeSelectItem); formItems.add(spacer); formItems.addAll(buildAvailabilityChangeFormItems()); - if (metrics != null) { + if (supportsMetrics) { formItems.addAll(buildMetricThresholdFormItems()); formItems.addAll(buildMetricBaselineFormItems()); formItems.addAll(buildMetricChangeFormItems()); } - if (traits != null) { + if (supportsTraits) { formItems.addAll(buildTraitChangeFormItems()); } - if (operations != null) { + if (supportsOperations) { formItems.addAll(buildOperationFormItems()); } if (supportsEvents) { @@ -181,6 +184,90 @@ public class NewConditionEditor extends LocatableDynamicForm { setFields(formItems.toArray(new FormItem[formItems.size()])); };
+ private void saveNewCondition() { + AlertConditionCategory category; + category = AlertConditionCategory.valueOf(conditionTypeSelectItem.getValue().toString()); + + AlertCondition newCondition = new AlertCondition(); + newCondition.setCategory(category); + + switch (category) { + case AVAILABILITY: { + newCondition.setName(null); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(AVAILABILITY_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + } + + case THRESHOLD: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); // TODO should not use display name + newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME)); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + break; + } + + case BASELINE: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(BASELINE_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); // TODO should not use display name + newCondition.setThreshold(Double.valueOf(getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)) / 100.0); + newCondition.setComparator(getValueAsString(BASELINE_COMPARATOR_ITEMNAME)); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + break; + } + + case CHANGE: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); // TODO should not use display name + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + break; + } + + case TRAIT: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(TRAIT_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); // TODO should not use display name + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + break; + } + + case CONTROL: { + newCondition.setName(getValueAsString(OPERATION_NAME_ITEMNAME)); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(OPERATION_RESULTS_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + } + + case EVENT: { + newCondition.setName(getValueAsString(EVENT_SEVERITY_ITEMNAME)); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(EVENT_REGEX_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + } + + default: { + CoreGUI.getErrorHandler().handleError("Invalid alert category selected: " + category); // should never happen + break; + } + } + + this.conditions.add(newCondition); + } + private ArrayList<FormItem> buildMetricThresholdFormItems() { ArrayList<FormItem> formItems = new ArrayList<FormItem>();
@@ -190,10 +277,9 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("thresholdMetric", ifFunc)); - formItems.add(buildComparatorDropDownMenu("thresholdComparator", ifFunc)); - - TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value"); + formItems.add(buildMetricDropDownMenu(THRESHOLD_METRIC_ITEMNAME, ifFunc)); + formItems.add(buildComparatorDropDownMenu(THRESHOLD_COMPARATOR_ITEMNAME, ifFunc)); + TextItem absoluteValue = new TextItem(THRESHOLD_ABSVALUE_ITEMNAME, "Metric Value"); absoluteValue.setWrapTitle(false); absoluteValue.setRequired(true); absoluteValue @@ -214,10 +300,10 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("baselineHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("baselineMetric", ifFunc)); - formItems.add(buildComparatorDropDownMenu("baselineComparator", ifFunc)); + formItems.add(buildMetricDropDownMenu(BASELINE_METRIC_ITEMNAME, ifFunc)); + formItems.add(buildComparatorDropDownMenu(BASELINE_COMPARATOR_ITEMNAME, ifFunc));
- TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage"); + TextItem baselinePercentage = new TextItem(BASELINE_PERCENTAGE_ITEMNAME, "Baseline Percentage"); baselinePercentage.setWrapTitle(false); baselinePercentage.setRequired(true); baselinePercentage @@ -225,13 +311,13 @@ public class NewConditionEditor extends LocatableDynamicForm { baselinePercentage.setShowIfCondition(ifFunc); formItems.add(baselinePercentage);
- SelectItem baselineSelection = new SelectItem("baselineSelection", "Baseline"); + SelectItem baselineSelection = new SelectItem(BASELINE_SELECTION_ITEMNAME, "Baseline"); LinkedHashMap<String, String> baselines = new LinkedHashMap<String, String>(3); - baselines.put("min", "Minimum"); // title should have the current value of the min baseline - baselines.put("avg", "Baseline"); // title should have the current value of the avg baseline - baselines.put("max", "Maximum"); // title should have the current value of the max baseline + baselines.put("min", "Minimum"); // TODO can we have the current value of the min baseline + baselines.put("mean", "Average"); // TODO can we have the current value of the avg baseline + baselines.put("max", "Maximum"); // TODO can we have the current value of the max baseline baselineSelection.setValueMap(baselines); - baselineSelection.setDefaultValue("avg"); + baselineSelection.setDefaultValue("mean"); baselineSelection.setWrapTitle(false); baselineSelection.setWidth("*"); baselineSelection.setRedrawOnChange(true); @@ -250,7 +336,7 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("changeMetric", ifFunc)); + formItems.add(buildMetricDropDownMenu(CHANGE_METRIC_ITEMNAME, ifFunc));
return formItems; } @@ -265,11 +351,13 @@ public class NewConditionEditor extends LocatableDynamicForm { formItems.add(helpItem);
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>(); - for (String traitName : this.traits) { - traitsMap.put(traitName, traitName); + for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) { + if (def.getDataType() == DataType.TRAIT) { + traitsMap.put(def.getName(), def.getDisplayName()); + } }
- SelectItem traitSelection = new SelectItem("trait", "Trait"); + SelectItem traitSelection = new SelectItem(TRAIT_METRIC_ITEMNAME, "Trait"); traitSelection.setValueMap(traitsMap); traitSelection.setDefaultValue(traitsMap.keySet().iterator().next()); // just use the first one traitSelection.setWidth("*"); @@ -289,7 +377,7 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("availabilityHelp", helpStr, ifFunc); formItems.add(helpItem);
- SelectItem selection = new SelectItem("availability", "Availability"); + SelectItem selection = new SelectItem(AVAILABILITY_ITEMNAME, "Availability"); LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2); avails.put(AvailabilityType.UP.name(), "Goes UP"); avails.put(AvailabilityType.DOWN.name(), "Goes DOWN"); @@ -311,11 +399,11 @@ public class NewConditionEditor extends LocatableDynamicForm { formItems.add(helpItem);
LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>(); - for (String opName : this.operations) { - ops.put(opName, opName); + for (OperationDefinition opDef : this.resourceType.getOperationDefinitions()) { + ops.put(opDef.getName(), opDef.getDisplayName()); }
- SelectItem opSelection = new SelectItem("operation", "Operation"); + SelectItem opSelection = new SelectItem(OPERATION_NAME_ITEMNAME, "Operation"); opSelection.setValueMap(ops); opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one opSelection.setWidth("*"); @@ -323,7 +411,7 @@ public class NewConditionEditor extends LocatableDynamicForm { opSelection.setShowIfCondition(ifFunc); formItems.add(opSelection);
- SelectItem opResultsSelection = new SelectItem("operationResults", "Operation Status"); + SelectItem opResultsSelection = new SelectItem(OPERATION_RESULTS_ITEMNAME, "Operation Status"); LinkedHashMap<String, String> operationStatuses = new LinkedHashMap<String, String>(4); operationStatuses.put(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.INPROGRESS.name()); operationStatuses.put(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.SUCCESS.name()); @@ -347,7 +435,7 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("eventHelp", helpStr, ifFunc); formItems.add(helpItem);
- SelectItem eventSeveritySelection = new SelectItem("eventSeverity", "Event Severity"); + SelectItem eventSeveritySelection = new SelectItem(EVENT_SEVERITY_ITEMNAME, "Event Severity"); LinkedHashMap<String, String> severities = new LinkedHashMap<String, String>(5); severities.put(EventSeverity.DEBUG.name(), EventSeverity.DEBUG.name()); severities.put(EventSeverity.INFO.name(), EventSeverity.INFO.name()); @@ -360,7 +448,7 @@ public class NewConditionEditor extends LocatableDynamicForm { eventSeveritySelection.setShowIfCondition(ifFunc); formItems.add(eventSeveritySelection);
- TextItem eventRegex = new TextItem("eventRegex", "Regular Expression"); + TextItem eventRegex = new TextItem(EVENT_REGEX_ITEMNAME, "Regular Expression"); eventRegex.setRequired(false); eventRegex .setTooltip("If specified, this is a regular expression that must match a collected event message in order to trigger the condition."); @@ -374,8 +462,10 @@ public class NewConditionEditor extends LocatableDynamicForm { private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>(); - for (String metricName : this.metrics) { - metricsMap.put(metricName, metricName); + for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) { + if (def.getDataType() == DataType.MEASUREMENT) { + metricsMap.put(def.getName(), def.getDisplayName()); + } }
SelectItem metricSelection = new SelectItem(itemName, "Metric"); @@ -413,6 +503,16 @@ public class NewConditionEditor extends LocatableDynamicForm { return help; }
+ private MeasurementDefinition getMeasurementDefinition(String metricName) { + for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) { + if (metricName.equals(def.getName())) { + return def; + } + } + CoreGUI.getErrorHandler().handleError("Should have found metric definition - something is wrong"); + return null; + } + private class ShowIfCategoryFunction implements FormItemIfFunction { private final AlertConditionCategory category;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java index 8269a8d..7cf6356 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java @@ -31,6 +31,7 @@ import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet; @@ -117,6 +118,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout { makeViewOnly();
// TODO getAlertDefinition() should now have the new user data - commit it to DB + CoreGUI.refresh(); } });
commit d0a76a4f3628d280bd861237869933dc126e235b Author: John Mazzitelli mazz@redhat.com Date: Mon Sep 13 15:23:41 2010 -0400
add javadoc omments to AlertCondition so its clear what the different fields should be based on the different category semantics
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java index b54d58e..3218d9d 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java @@ -47,7 +47,9 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlTransient;
+import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.operation.OperationRequestStatus;
/** * An alert condition (e.g. ActiveThreads > 100) as configured in an alert definition. @@ -366,6 +368,13 @@ public class AlertCondition implements Serializable { this.category = category; }
+ /** + * Identifies the measurement definition of the metric that is to be compared when determining + * if the condition is true. This is null if the condition category is not a metric-related one + * (metric related categories are THRESHOLD, TRAIT, BASELINE and CHANGE; others are not). + * + * @return measurement definition or null + */ public MeasurementDefinition getMeasurementDefinition() { return this.measurementDefinition; } @@ -374,6 +383,19 @@ public class AlertCondition implements Serializable { this.measurementDefinition = measurementDefinition; }
+ /** + * The name of the condition whose semantics are different based on this condition's category: + * + * AVAILABILITY: n/a (null) + * THRESHOLD: the name of the metric (TODO: today its the display name, very bad for i18n purposes) + * BASELINE: the name of the metric (TODO: today its the display name, very bad for i18n purposes) + * CHANGE: the name of the metric (TODO: today its the display name, very bad for i18n purposes) + * TRAIT: the name of the trait (TODO: today its the display name, very bad for i18n purposes) + * CONTROL: the name of the operation (not its display name) + * EVENT: the level of event to compare with (DEBUG, INFO, WARN, ERROR, FATAL) + * + * @return additional information about the condition + */ public String getName() { return this.name; } @@ -382,6 +404,14 @@ public class AlertCondition implements Serializable { this.name = name; }
+ /** + * One of these comparators: "<", ">" or "=". + * This will be null if the condition does not compare values. Only THRESHOLD + * and BASELINE condition categories use comparators; other types of conditions + * will return <code>null</code>. + * + * @return comparator string + */ public String getComparator() { return this.comparator; } @@ -390,6 +420,13 @@ public class AlertCondition implements Serializable { this.comparator = comparator; }
+ /** + * Returns the threshold to compare a measurement value to see if the condition is true. + * This is only valid for conditions of category THRESHOLD and BASELINE. All other + * condition types will return <code>null</code>. + * + * @return threshold value or null + */ public Double getThreshold() { return this.threshold; } @@ -398,6 +435,18 @@ public class AlertCondition implements Serializable { this.threshold = threshold; }
+ /** + * The option string is optional and its semantics differ based on the category of this condition: + * AVAILABILITY: the {@link AvailabilityType} to trigger off of (DOWN or UP) + * THRESHOLD: n/a + * BASELINE: one of "min", "max" or "mean" - indicates what the threshold is compared to (min/max/avg baseline value) + * CHANGE: n/a + * TRAIT: n/a + * CONTROL: the {@link OperationRequestStatus} name (SUCCESS, FAILURE, etc). + * EVENT: the regular expression of the message to match (which may be empty string if not specified) + * + * @return additional information about the condition + */ public String getOption() { return this.option; }
commit 4752d410687ff02f7c04e3f62a552f3f7e55bb06 Author: John Mazzitelli mazz@redhat.com Date: Mon Sep 13 14:17:48 2010 -0400
get new condition editor to show metrics, operations, etc
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java index 23bc0cc..657fd5c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java @@ -29,6 +29,7 @@ import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.alert.AlertPriority; import org.rhq.core.domain.alert.BooleanExpression; import org.rhq.core.domain.criteria.AlertDefinitionCriteria; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; @@ -118,14 +119,14 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
AlertDefinition alertDef = getAlertDefinitionDataSource().copyValues(record); SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this - .extendLocatorId(alertDef.getName()), alertDef); + .extendLocatorId(alertDef.getName()), getResourceType(), alertDef); return singleAlertDefinitionView; }
@Override public SingleAlertDefinitionView getDetailsView(int id) { final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this - .extendLocatorId("Empty")); + .extendLocatorId("singleAlertDefinitionView"), getResourceType());
if (id == 0) { // create an empty one with all defaults @@ -160,6 +161,8 @@ public abstract class AbstractAlertDefinitionsView extends TableSection { return singleAlertDefinitionView; }
+ protected abstract ResourceType getResourceType(); + protected abstract Criteria getCriteria();
protected abstract AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java index e1cb68f..182173a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java @@ -32,6 +32,7 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem; import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.alert.BooleanExpression; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -40,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; */ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements EditAlertDefinitionForm {
+ private final ResourceType resourceType; private AlertDefinition alertDefinition;
private SelectItem conditionExpression; @@ -49,12 +51,13 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
private boolean formBuilt = false;
- public ConditionsAlertDefinitionForm(String locatorId) { - this(locatorId, null); + public ConditionsAlertDefinitionForm(String locatorId, ResourceType resourceType) { + this(locatorId, resourceType, null); }
- public ConditionsAlertDefinitionForm(String locatorId, AlertDefinition alertDefinition) { + public ConditionsAlertDefinitionForm(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) { super(locatorId); + this.resourceType = resourceType; this.alertDefinition = alertDefinition; }
@@ -146,7 +149,7 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
conditionExpressionForm.setFields(conditionExpression, conditionExpressionStatic);
- conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), null); + conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), resourceType, null);
setMembers(conditionExpressionForm, conditionsEditor); formBuilt = true; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index 1742ec0..78261a3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -29,12 +29,14 @@ import java.util.Set; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.fields.DataSourceTextField; +import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.CloseClickHandler; import com.smartgwt.client.widgets.events.CloseClientEvent; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; @@ -47,11 +49,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; */ public class ConditionsEditor extends LocatableVLayout {
+ private ResourceType resourceType; private HashSet<AlertCondition> conditions; private Table table;
- public ConditionsEditor(String locatorId, HashSet<AlertCondition> conditions) { + public ConditionsEditor(String locatorId, ResourceType resourceType, HashSet<AlertCondition> conditions) { super(locatorId); + this.resourceType = resourceType; setConditions(conditions); }
@@ -90,20 +94,24 @@ public class ConditionsEditor extends LocatableVLayout { public void executeAction(ListGridRecord[] selection) { final Window winModal = new Window(); winModal.setTitle("Add Condition"); + winModal.setOverflow(Overflow.VISIBLE); winModal.setShowMinimizeButton(false); winModal.setIsModal(true); winModal.setShowModalMask(true); winModal.setAutoSize(true); winModal.setAutoCenter(true); + //winModal.setShowResizer(true); + //winModal.setCanDragResize(true); winModal.centerInPage(); winModal.addCloseClickHandler(new CloseClickHandler() { @Override public void onCloseClick(CloseClientEvent event) { - winModal.destroy(); + winModal.markForDestroy(); } }); + NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"), - conditions); + conditions, ConditionsEditor.this.resourceType, winModal); winModal.addItem(newConditionEditor); winModal.show(); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java index c0b37ca..ec67b08 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java @@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ResourceGroup;
/** @@ -44,6 +45,11 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView { }
@Override + protected ResourceType getResourceType() { + return group.getResourceType(); + } + + @Override protected Criteria getCriteria() { Criteria criteria = new Criteria(); criteria.addCriteria(CRITERIA_GROUP_ID, group.getId()); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index c6c59c1..7922824 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -24,11 +24,13 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.Set;
import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.FormItemIfFunction; import com.smartgwt.client.widgets.form.fields.ButtonItem; @@ -44,7 +46,10 @@ import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertConditionCategory; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.operation.OperationRequestStatus; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** @@ -52,12 +57,59 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; */ public class NewConditionEditor extends LocatableDynamicForm {
- private HashSet<AlertCondition> conditions; // the new condition we create goes into this set private SelectItem conditionTypeSelectItem; + private HashSet<AlertCondition> conditions; // the new condition we create goes into this set + private Collection<String> metrics; + private Collection<String> traits; + private Collection<String> operations; + private boolean supportsEvents; + private Window parentWindow; // where this form is located; after form is OK'ed, this window will be destroyed + + public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Window parent) {
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions) { super(locatorId); this.conditions = conditions; + this.parentWindow = parent; + + this.supportsEvents = (rtype.getEventDefinitions() != null & rtype.getEventDefinitions().size() > 0); + + Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions(); + Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions(); + if (metricDefinitions == null || metricDefinitions.size() == 0) { + this.metrics = null; + this.traits = null; + } else { + for (MeasurementDefinition measurementDefinition : metricDefinitions) { + switch (measurementDefinition.getDataType()) { + case MEASUREMENT: { + if (this.metrics == null) { + this.metrics = new ArrayList<String>(); + } + this.metrics.add(measurementDefinition.getDisplayName()); + break; + } + case TRAIT: { + if (this.traits == null) { + this.traits = new ArrayList<String>(); + } + this.traits.add(measurementDefinition.getDisplayName()); + break; + } + default: { + break; + } + } + } + } + + if (operationDefinitions == null || operationDefinitions.size() == 0) { + this.operations = null; + } else { + this.operations = new ArrayList<String>(operationDefinitions.size()); + for (OperationDefinition operationDefinition : operationDefinitions) { + this.operations.add(operationDefinition.getDisplayName()); + } + } }
@Override @@ -68,15 +120,23 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type"); LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7); - condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold"); - condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold"); - condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change"); - condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change"); condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability Change"); - condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution"); - condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection"); + if (metrics != null) { + condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold"); + condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold"); + condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change"); + } + if (traits != null) { + condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change"); + } + if (operations != null) { + condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution"); + } + if (supportsEvents) { + condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection"); + } conditionTypeSelectItem.setValueMap(condTypes); - conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.THRESHOLD.name()); + conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.AVAILABILITY.name()); conditionTypeSelectItem.setWrapTitle(false); conditionTypeSelectItem.setRedrawOnChange(true); conditionTypeSelectItem.setWidth("*"); @@ -91,21 +151,31 @@ public class NewConditionEditor extends LocatableDynamicForm { ok.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { - // TODO - SC.say("Not yet implemented"); + if (validate(false)) { + // TODO + NewConditionEditor.this.parentWindow.markForDestroy(); + } } });
ArrayList<FormItem> formItems = new ArrayList<FormItem>(); formItems.add(conditionTypeSelectItem); formItems.add(spacer); - formItems.addAll(buildMetricThresholdFormItems()); - formItems.addAll(buildMetricBaselineFormItems()); - formItems.addAll(buildMetricChangeFormItems()); - formItems.addAll(buildTraitChangeFormItems()); formItems.addAll(buildAvailabilityChangeFormItems()); - formItems.addAll(buildOperationFormItems()); - formItems.addAll(buildEventFormItems()); + if (metrics != null) { + formItems.addAll(buildMetricThresholdFormItems()); + formItems.addAll(buildMetricBaselineFormItems()); + formItems.addAll(buildMetricChangeFormItems()); + } + if (traits != null) { + formItems.addAll(buildTraitChangeFormItems()); + } + if (operations != null) { + formItems.addAll(buildOperationFormItems()); + } + if (supportsEvents) { + formItems.addAll(buildEventFormItems()); + } formItems.add(ok);
setFields(formItems.toArray(new FormItem[formItems.size()])); @@ -126,6 +196,8 @@ public class NewConditionEditor extends LocatableDynamicForm { TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value"); absoluteValue.setWrapTitle(false); absoluteValue.setRequired(true); + absoluteValue + .setTooltip("The threshold value of the metric that will trigger the condition when compared using the selected comparator.");
absoluteValue.setShowIfCondition(ifFunc); formItems.add(absoluteValue); @@ -148,6 +220,8 @@ public class NewConditionEditor extends LocatableDynamicForm { TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage"); baselinePercentage.setWrapTitle(false); baselinePercentage.setRequired(true); + baselinePercentage + .setTooltip("A collected metric value will trigger this condition when compared to this percentage of the selected baseline value using the selected comparator"); baselinePercentage.setShowIfCondition(ifFunc); formItems.add(baselinePercentage);
@@ -158,8 +232,9 @@ public class NewConditionEditor extends LocatableDynamicForm { baselines.put("max", "Maximum"); // title should have the current value of the max baseline baselineSelection.setValueMap(baselines); baselineSelection.setDefaultValue("avg"); - baselineSelection.setWidth("*"); baselineSelection.setWrapTitle(false); + baselineSelection.setWidth("*"); + baselineSelection.setRedrawOnChange(true); baselineSelection.setShowIfCondition(ifFunc); formItems.add(baselineSelection);
@@ -189,14 +264,16 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("traitHelp", helpStr, ifFunc); formItems.add(helpItem);
- LinkedHashMap<String, String> traits = new LinkedHashMap<String, String>(); - // TODO - traits.put("dummy trait", "Dummy Trait Name"); + LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>(); + for (String traitName : this.traits) { + traitsMap.put(traitName, traitName); + }
SelectItem traitSelection = new SelectItem("trait", "Trait"); - traitSelection.setValueMap(traits); - traitSelection.setDefaultValue(traits.keySet().iterator().next()); // just use the first one + traitSelection.setValueMap(traitsMap); + traitSelection.setDefaultValue(traitsMap.keySet().iterator().next()); // just use the first one traitSelection.setWidth("*"); + traitSelection.setRedrawOnChange(true); traitSelection.setShowIfCondition(ifFunc); formItems.add(traitSelection);
@@ -234,12 +311,15 @@ public class NewConditionEditor extends LocatableDynamicForm { formItems.add(helpItem);
LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>(); - // TODO - ops.put("dummy op", "Dummy Op Name"); + for (String opName : this.operations) { + ops.put(opName, opName); + }
SelectItem opSelection = new SelectItem("operation", "Operation"); opSelection.setValueMap(ops); opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one + opSelection.setWidth("*"); + opSelection.setRedrawOnChange(true); opSelection.setShowIfCondition(ifFunc); formItems.add(opSelection);
@@ -251,7 +331,6 @@ public class NewConditionEditor extends LocatableDynamicForm { operationStatuses.put(OperationRequestStatus.CANCELED.name(), OperationRequestStatus.CANCELED.name()); opResultsSelection.setValueMap(operationStatuses); opResultsSelection.setDefaultValue(OperationRequestStatus.FAILURE.name()); - opResultsSelection.setWidth("*"); opResultsSelection.setWrapTitle(false); opResultsSelection.setShowIfCondition(ifFunc); formItems.add(opResultsSelection); @@ -283,6 +362,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
TextItem eventRegex = new TextItem("eventRegex", "Regular Expression"); eventRegex.setRequired(false); + eventRegex + .setTooltip("If specified, this is a regular expression that must match a collected event message in order to trigger the condition."); eventRegex.setWrapTitle(false); eventRegex.setShowIfCondition(ifFunc); formItems.add(eventRegex); @@ -292,13 +373,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
- LinkedHashMap<String, String> metrics = new LinkedHashMap<String, String>(); - metrics.put("dummy metric", "Dummy Metric Name"); + LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>(); + for (String metricName : this.metrics) { + metricsMap.put(metricName, metricName); + }
SelectItem metricSelection = new SelectItem(itemName, "Metric"); - metricSelection.setValueMap(metrics); - metricSelection.setDefaultValue(metrics.keySet().iterator().next()); // just use the first one + metricSelection.setValueMap(metricsMap); + metricSelection.setDefaultValue(metricsMap.keySet().iterator().next()); // just use the first one metricSelection.setWidth("*"); + metricSelection.setRedrawOnChange(true); metricSelection.setShowIfCondition(ifFunc); return metricSelection; } @@ -313,6 +397,7 @@ public class NewConditionEditor extends LocatableDynamicForm { SelectItem comparatorSelection = new SelectItem(itemName, "Comparator"); comparatorSelection.setValueMap(comparators); comparatorSelection.setDefaultValue("<"); + comparatorSelection.setTooltip("How a collected metric value should be compared to the given threshold value"); comparatorSelection.setShowIfCondition(ifFunc); return comparatorSelection; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java index 7cf7226..83a8629 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java @@ -28,6 +28,7 @@ import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType;
/** * @author John Mazzitelli @@ -44,6 +45,11 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView { }
@Override + protected ResourceType getResourceType() { + return resource.getResourceType(); + } + + @Override protected Criteria getCriteria() { Criteria criteria = new Criteria(); criteria.addCriteria(CRITERIA_RESOURCE_ID, resource.getId()); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java index d06e422..8269a8d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java @@ -30,6 +30,7 @@ import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet; @@ -41,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; public class SingleAlertDefinitionView extends LocatableVLayout {
private AlertDefinition alertDefinition; + private GeneralPropertiesAlertDefinitionForm generalProperties; private ConditionsAlertDefinitionForm conditions; private NotificationsAlertDefinitionForm notifications; @@ -51,11 +53,11 @@ public class SingleAlertDefinitionView extends LocatableVLayout { private Button saveButton; private Button cancelButton;
- public SingleAlertDefinitionView(String locatorId) { - this(locatorId, null); + public SingleAlertDefinitionView(String locatorId, ResourceType resourceType) { + this(locatorId, resourceType, null); }
- public SingleAlertDefinitionView(String locatorId, AlertDefinition alertDefinition) { + public SingleAlertDefinitionView(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) { super(locatorId);
this.alertDefinition = alertDefinition; @@ -68,7 +70,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout { generalPropertiesTab.setPane(generalProperties);
Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), "Conditions"); - conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), alertDefinition); + conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), resourceType, alertDefinition); conditionsTab.setPane(conditions);
Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"), "Notifications"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java index d2f44f6..d5a5e14 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java @@ -44,6 +44,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView { }
@Override + protected ResourceType getResourceType() { + return resourceType; + } + + @Override protected Criteria getCriteria() { Criteria criteria = new Criteria(); criteria.addCriteria(CRITERIA_RESOURCE_TYPE_ID, resourceType.getId());
commit 8d1ef83e3075616b615c385f2174c7228ddde9d6 Author: Simeon Pinder spinder@redhat.com Date: Mon Sep 13 12:24:48 2010 -0400
moved Table attrs back to private, enabled RecentlyAdded server side
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index 0d4e6d6..5196c71 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -77,12 +77,12 @@ public class Table extends LocatableHLayout { private TableFilter filterForm; private ListGrid listGrid; private ToolStrip footer; - protected Label tableInfo; + private Label tableInfo;
private List<String> headerIcons = new ArrayList<String>();
private boolean showHeader = true; - protected boolean showFooter = true; + private boolean showFooter = true; private boolean showFooterRefresh = true;
private String tableTitle; @@ -249,7 +249,7 @@ public class Table extends LocatableHLayout { // Now give subclasses a chance to configure the table configureTable();
- tableInfo = new Label("Total: " + listGrid.getTotalRows()); + setTableInfo(new Label("Total: " + listGrid.getTotalRows()));
// NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since // super.onDraw() is what actually adds the fields to the ListGrid (based on what fields are defined in @@ -260,7 +260,7 @@ public class Table extends LocatableHLayout { } }
- tableInfo.setWrap(false); + getTableInfo().setWrap(false);
if (showHeader) {
@@ -543,8 +543,8 @@ public class Table extends LocatableHLayout { ((TableWidget) extraWidget).refresh(this.listGrid); } } - if (this.tableInfo != null) { - this.tableInfo.setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)"); + if (getTableInfo() != null) { + getTableInfo().setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)"); } } } @@ -659,4 +659,12 @@ public class Table extends LocatableHLayout { public void setShowFooterRefresh(boolean showFooterRefresh) { this.showFooterRefresh = showFooterRefresh; } + + public Label getTableInfo() { + return tableInfo; + } + + public void setTableInfo(Label tableInfo) { + this.tableInfo = tableInfo; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java index fb1db39..17b4074 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java @@ -23,6 +23,10 @@
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported;
+import java.util.ArrayList; +import java.util.Date; +import java.util.List; + import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSRequest; @@ -32,28 +36,28 @@ import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.widgets.tree.TreeNode; -import org.rhq.core.domain.criteria.ResourceCriteria; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
public class RecentlyAddedResourceDS extends DataSource { + private Portlet portlet; + private int maximumRecentlyAddedToDisplay; + private int maximumRecentlyAddedWithinHours; + private long oldestDate = -1;
- - public RecentlyAddedResourceDS() { + public RecentlyAddedResourceDS(Portlet recentlyAddedPortlet) { + this.portlet = recentlyAddedPortlet; setClientOnly(false); setDataProtocol(DSProtocol.CLIENTCUSTOM); setDataFormat(DSDataFormat.CUSTOM);
- DataSourceTextField idField = new DataSourceTextField("id", "ID"); idField.setPrimaryKey(true);
@@ -75,11 +79,11 @@ public class RecentlyAddedResourceDS extends DataSource { // Asume success response.setStatus(0); switch (request.getOperationType()) { - case FETCH: - executeFetch(request, response); - break; - default: - break; + case FETCH: + executeFetch(request, response); + break; + default: + break; }
return request.getData(); @@ -87,21 +91,43 @@ public class RecentlyAddedResourceDS extends DataSource {
public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria c = new ResourceCriteria(); + long ctime = -1; + int maxItems = -1; + //retrieve current portlet display settings + if ((this.portlet != null) && (this.portlet instanceof RecentlyAddedView)) { + RecentlyAddedView recentAdditionsPortlet = (RecentlyAddedView) this.portlet; + if (recentAdditionsPortlet != null) { + if (getMaximumRecentlyAddedToDisplay() > 0) { + maxItems = getMaximumRecentlyAddedToDisplay(); + }
- String p = request.getCriteria().getAttribute("parentId"); + //define the time window + if (getMaximumRecentlyAddedWithinHours() > 0) { + ctime = System.currentTimeMillis() + - (getMaximumRecentlyAddedWithinHours() * MeasurementUtility.HOURS); + setOldestDate(ctime); + }
- if (p == null) { - c.addFilterResourceCategory(ResourceCategory.PLATFORM); - c.fetchChildResources(true); - } else { - c.addFilterParentResourceId(Integer.parseInt(p)); + } }
+ // TODO: spinder: revisit this later. ResourceCriteria mechanism does not work. Not sure if it's better? + // ResourceCriteria c = new ResourceCriteria(); + // + // String p = request.getCriteria().getAttribute("parentId"); + // + // if (p == null) { + // c.addFilterResourceCategory(ResourceCategory.PLATFORM); + // c.fetchChildResources(true); + // } else { + // c.addFilterParentResourceId(Integer.parseInt(p)); + // } + // TODO GH: Enhance resourceCriteria query to support itime based filtering for // "Recently imported" resources
- GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100, + // GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100, + GWTServiceLookup.getResourceService().findRecentlyAddedResources(ctime, maxItems, new AsyncCallback<List<RecentlyAddedResourceComposite>>() { public void onFailure(Throwable throwable) { CoreGUI.getErrorHandler().handleError("Failed to load recently added resources", throwable); @@ -120,38 +146,38 @@ public class RecentlyAddedResourceDS extends DataSource { processResponse(request.getRequestId(), response); } }); -// -// GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() { -// public void onFailure(Throwable caught) { -// CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught); -// response.setStatus(DSResponse.STATUS_FAILURE); -// processResponse(request.getRequestId(), response); -// } -// -// public void onSuccess(PageList<Resource> result) { -// PageList<Resource> all = new PageList<Resource>(); -// -// for (Resource root : result) { -// all.add(root); -// if (root.getChildResources() != null) -// all.addAll(root.getChildResources()); -// } -// -// -// response.setData(buildNodes(all)); -// response.setTotalRows(all.getTotalSize()); -// processResponse(request.getRequestId(), response); -// } -// }); + // + // GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() { + // public void onFailure(Throwable caught) { + // CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught); + // response.setStatus(DSResponse.STATUS_FAILURE); + // processResponse(request.getRequestId(), response); + // } + // + // public void onSuccess(PageList<Resource> result) { + // PageList<Resource> all = new PageList<Resource>(); + // + // for (Resource root : result) { + // all.add(root); + // if (root.getChildResources() != null) + // all.addAll(root.getChildResources()); + // } + // + // + // response.setData(buildNodes(all)); + // response.setTotalRows(all.getTotalSize()); + // processResponse(request.getRequestId(), response); + // } + // }); }
-// private TreeNode[] buildNodes(PageList<Resource> list) { -// TreeNode[] treeNodes = new TreeNode[list.size()]; -// for (int i = 0; i < list.size(); ++i) { -// treeNodes[i] = new ResourceTreeNode(list.get(i)); -// } -// return treeNodes; -// } + // private TreeNode[] buildNodes(PageList<Resource> list) { + // TreeNode[] treeNodes = new TreeNode[list.size()]; + // for (int i = 0; i < list.size(); ++i) { + // treeNodes[i] = new ResourceTreeNode(list.get(i)); + // } + // return treeNodes; + // }
private TreeNode[] buildNodes(List<RecentlyAddedResourceComposite> list) { TreeNode[] treeNodes = new TreeNode[list.size()]; @@ -169,8 +195,7 @@ public class RecentlyAddedResourceDS extends DataSource { Date dateAdded = new Date(recentlyAdded.getCtime());
String id = String.valueOf(recentlyAdded.getId()); - String parentId = recentlyAdded.getParentId() == 0 ? null - : String.valueOf((recentlyAdded.getParentId())); + String parentId = recentlyAdded.getParentId() == 0 ? null : String.valueOf((recentlyAdded.getParentId()));
setID(id); setParentID(parentId); @@ -191,8 +216,8 @@ public class RecentlyAddedResourceDS extends DataSource { this.resource = resource;
String id = String.valueOf(resource.getId()); - String parentId = resource.getParentResource() == null ? null - : String.valueOf((resource.getParentResource().getId())); + String parentId = resource.getParentResource() == null ? null : String.valueOf((resource + .getParentResource().getId()));
setID(id); setParentID(parentId); @@ -201,10 +226,10 @@ public class RecentlyAddedResourceDS extends DataSource { setAttribute("parentId", parentId); setAttribute("name", resource.getName()); setAttribute("timestamp", "");//String.valueOf(resource.getItime())); // Seems to be null - setAttribute("currentAvailability", - resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP - ? "/images/icons/availability_green_16.png" - : "/images/icons/availability_red_16.png"); + setAttribute( + "currentAvailability", + resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP ? "/images/icons/availability_green_16.png" + : "/images/icons/availability_red_16.png"); }
public Resource getResource() { @@ -223,4 +248,29 @@ public class RecentlyAddedResourceDS extends DataSource { return getAttribute("parentId"); } } + + public int getMaximumRecentlyAddedToDisplay() { + return maximumRecentlyAddedToDisplay; + } + + public void setMaximumRecentlyAddedToDisplay(int maximumRecentlyAddedToDisplay) { + this.maximumRecentlyAddedToDisplay = maximumRecentlyAddedToDisplay; + } + + public int getMaximumRecentlyAddedWithinHours() { + return maximumRecentlyAddedWithinHours; + } + + public void setMaximumRecentlyAddedWithinHours(int maximumRecentlyAddedWithinHours) { + this.maximumRecentlyAddedWithinHours = maximumRecentlyAddedWithinHours; + } + + public long getOldestDate() { + return oldestDate; + } + + public void setOldestDate(long oldestDate) { + this.oldestDate = oldestDate; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java index c856151..31bcf9d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java @@ -49,27 +49,25 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
private boolean simple = true; private DashboardPortlet storedPortlet; + private RecentlyAddedResourceDS dataSource; + private TreeGrid treeGrid = null; public static final String unlimited = "unlimited"; public static final String defaultValue = unlimited;
private static final String RECENTLY_ADDED_SHOW_MAX = "recently-added-show-amount"; - private static final String RECENTLY_ADDED_SHOW_HRS = "recently-added-time-range";
public RecentlyAddedView(String locatorId) { super(locatorId); + //insert the datasource + this.dataSource = new RecentlyAddedResourceDS(this); }
- private TreeGrid treeGrid = null; - - private int maximumRecentlyAddedToDisplay; - private int maximumRecentlyAddedWithinHours; - @Override protected void onInit() { super.onInit(); treeGrid = new TreeGrid(); - treeGrid.setDataSource(new RecentlyAddedResourceDS()); + treeGrid.setDataSource(getDataSource()); treeGrid.setAutoFetchData(true); treeGrid.setTitle("Recently Added Resources"); treeGrid.setResizeFieldsInRealTime(true); @@ -83,7 +81,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting } });
- ListGridField timestampField = new ListGridField("timestamp", "Date//Time"); + ListGridField timestampField = new ListGridField("timestamp", "Date/Time");
treeGrid.setFields(resourceNameField, timestampField);
@@ -100,20 +98,24 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX) != null) { //retrieve and translate to int String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX).getStringValue(); - if (retrieved.equals(unlimited)) { - maximumRecentlyAddedToDisplay = -1; - } else { - maximumRecentlyAddedToDisplay = Integer.parseInt(retrieved); + if (getDataSource() != null) {//check for initialization of datasource unavailability + if (retrieved.equals(unlimited)) { + getDataSource().setMaximumRecentlyAddedToDisplay(-1); + } else { + getDataSource().setMaximumRecentlyAddedToDisplay(Integer.parseInt(retrieved)); + } } } else {//create setting storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_MAX, defaultValue)); } if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS) != null) { String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS).getStringValue(); - if (retrieved.equals(unlimited)) { - setMaximumRecentlyAddedWithinHours(-1); - } else { - setMaximumRecentlyAddedWithinHours(Integer.parseInt(retrieved)); + if (getDataSource() != null) {//check for initialization of datasource unavailability + if (retrieved.equals(unlimited)) { + getDataSource().setMaximumRecentlyAddedWithinHours(-1); + } else { + getDataSource().setMaximumRecentlyAddedWithinHours(Integer.parseInt(retrieved)); + } } } else { storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue)); @@ -130,7 +132,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting //-------------combobox for number of recently added resources to display on the dashboard final SelectItem maximumRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_MAX); maximumRecentlyAddedComboBox.setTitle("Show"); - maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved resources on dashboard.</b></nobr>"); + maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved platforms on dashboard.</b></nobr>"); //spinder 9/3/10: the following is required workaround to disable editability of combobox. maximumRecentlyAddedComboBox.setType("selection"); //define acceptable values for display amount @@ -216,19 +218,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting this.treeGrid.markForRedraw(); }
- public int getMaximumRecentlyAddedToDisplay() { - return maximumRecentlyAddedToDisplay; - } - - public void setMaximumRecentlyAddedToDisplay(int maximumRecentlyAddedToDisplay) { - this.maximumRecentlyAddedToDisplay = maximumRecentlyAddedToDisplay; - } - - public int getMaximumRecentlyAddedWithinHours() { - return maximumRecentlyAddedWithinHours; - } - - public void setMaximumRecentlyAddedWithinHours(int maximumRecentlyAddedWithinHours) { - this.maximumRecentlyAddedWithinHours = maximumRecentlyAddedWithinHours; + public RecentlyAddedResourceDS getDataSource() { + return dataSource; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java index 3faa954..2778c59 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java @@ -62,6 +62,9 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort public static final String KEY = "Has Alerts or Currently Unavailable"; private static final String TITLE = KEY; private DashboardPortlet storedPortlet; + //reference to datasource + private ProblemResourcesDataSource dataSource; + //constants public static final String unlimited = "unlimited"; public static final String defaultValue = unlimited; @@ -97,9 +100,6 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort } }
- //reference to datasource - private ProblemResourcesDataSource dataSource; - @Override public ProblemResourcesDataSource getDataSource() { return (ProblemResourcesDataSource) super.getDataSource(); @@ -251,7 +251,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort }
protected void refreshTableInfo() { - if (showFooter) { + if (isShowFooter()) { long begin = 0; List<Long> bounds = MeasurementUtility.calculateTimeFrame(getDataSource() .getMaximumProblemResourcesWithinHours(), MeasurementUtility.UNIT_HOURS); @@ -272,7 +272,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort } } //remove selected count as portlet is view only. Selection not used. - this.tableInfo.setContents("Total: " + getListGrid().getTotalRows()); + getTableInfo().setContents("Total: " + getListGrid().getTotalRows()); } }
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java index 64fd5f8..e228f15 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java @@ -213,7 +213,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
if (!authorizationManager.hasResourcePermission(user, Permission.MODIFY_RESOURCE, resource.getId())) { throw new PermissionException("You do not have permission to modify Resource with id " + resource.getId() - + "."); + + "."); }
/*if (getResourceByParentAndKey(user, resource.getParentResource(), resource.getResourceKey()) != null) @@ -246,8 +246,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage @SuppressWarnings("unchecked") @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public List<Integer> uninventoryResource(Subject user, int resourceId) { -// Resource resource = resourceManager.getResourceTree(resourceId, true); - Resource resource = entityManager.find(Resource.class,resourceId); + // Resource resource = resourceManager.getResourceTree(resourceId, true); + Resource resource = entityManager.find(Resource.class, resourceId); if (resource == null) { log.info("Delete resource not possible, as resource with id [" + resourceId + "] was not found"); return Collections.emptyList(); // Resource not found. TODO give a nice message to the user @@ -313,10 +313,10 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION is an expensive recursive query // But luckily we have already (through such a recursive query above) determined the doomed resources -// Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION); -// markDeletedQuery.setParameter("resourceId", resourceId); -// markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED); -// int resourcesDeleted = markDeletedQuery.executeUpdate(); + // Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION); + // markDeletedQuery.setParameter("resourceId", resourceId); + // markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED); + // int resourcesDeleted = markDeletedQuery.executeUpdate();
i = 0; int resourcesDeleted = 0; @@ -326,11 +326,11 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage j = toBeDeletedResourceIds.size(); List<Integer> idsToDelete = toBeDeletedResourceIds.subList(i, j);
- - Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK); + Query markDeletedQuery = entityManager + .createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK); markDeletedQuery.setParameter("resourceIds", idsToDelete); markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED); - resourcesDeleted+= markDeletedQuery.executeUpdate(); + resourcesDeleted += markDeletedQuery.executeUpdate(); i = j; }
@@ -1063,7 +1063,11 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage }
query.setParameter("oldestEpochTime", ctime); - query.setMaxResults(maxItems); // this query is only used by the dashboard portlet, let's not blow it up + if ((maxItems > 100) || (maxItems < 0)) {//cap infininte(-1) and large requests to 100 + query.setMaxResults(100); // this query is only used by the dashboard portlet, let's not blow it up + } else { + query.setMaxResults(maxItems); + } return query.getResultList(); }
@@ -2093,14 +2097,14 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage Resource parent = resource.getParentResource(); ResourceComposite composite = new ResourceComposite(resource, parent, availType); composite.setResourceFacets(typeManager.getResourceFacets(resource.getResourceType().getId())); - Set<Permission> permissions = authorizationManager.getImplicitResourcePermissions(subject, resource.getId()); + Set<Permission> permissions = authorizationManager + .getImplicitResourcePermissions(subject, resource.getId()); composite.setResourcePermission(new ResourcePermission(permissions)); // TODO: jmarques: Alter criteria projection to include permissions. results.add(composite); }
- return new PageList<ResourceComposite>(results, resources.getTotalSize(), resources - .getPageControl()); + return new PageList<ResourceComposite>(results, resources.getTotalSize(), resources.getPageControl()); }
@SuppressWarnings("unchecked") @@ -2168,6 +2172,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public <T> List<DisambiguationReport<T>> disambiguate(List<T> results, IntExtractor<? super T> extractor, DisambiguationUpdateStrategy updateStrategy) { - return Disambiguator.disambiguate(results, updateStrategy, extractor, entityManager, typeManager.getDuplicateTypeNames()); + return Disambiguator.disambiguate(results, updateStrategy, extractor, entityManager, typeManager + .getDuplicateTypeNames()); } }
commit e3467c9c4e144cf4f1859fdce25711b6239c2783 Author: Simeon Pinder spinder@redhat.com Date: Mon Sep 13 09:00:28 2010 -0400
enable server side for autodiscovery and some cleanup.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java index e66f091..8159d23 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java @@ -35,6 +35,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -54,6 +55,15 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C super(locatorId, true); }
+ @Override + protected void onInit() { + super.onInit(); + //initialize the datasource to include Portlet instance + if (getTreeGrid() != null) { + getTreeGrid().setDataSource(new AutodiscoveryQueueDataSource(this)); + } + } + /** Implement configure action. */ @Override @@ -63,9 +73,9 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C //retrieve and translate to int String retrieved = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue(); if (retrieved.equals(unlimited)) { - maximumPlatformsToDisplay = -1; + setMaximumPlatformsToDisplay(-1); } else { - maximumPlatformsToDisplay = Integer.parseInt(retrieved); + setMaximumPlatformsToDisplay(Integer.parseInt(retrieved)); } } else {//create setting storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue)); @@ -153,4 +163,12 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C return new AutodiscoveryPortlet(locatorId); } } + + public int getMaximumPlatformsToDisplay() { + return maximumPlatformsToDisplay; + } + + public void setMaximumPlatformsToDisplay(int maximumPlatformsToDisplay) { + this.maximumPlatformsToDisplay = maximumPlatformsToDisplay; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java index 01a5ad3..63ed782 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java @@ -20,7 +20,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery;
import java.util.ArrayList; import java.util.Date; -import java.util.EnumSet; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -40,6 +39,8 @@ import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageOrdering; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
@@ -48,15 +49,20 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; */ public class AutodiscoveryQueueDataSource extends DataSource {
- + private Portlet portlet = null; + private int unlimited = -1; private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+ public AutodiscoveryQueueDataSource(Portlet portlet) { + this(); + this.portlet = portlet; + } + public AutodiscoveryQueueDataSource() { setClientOnly(false); setDataProtocol(DSProtocol.CLIENTCUSTOM); setDataFormat(DSDataFormat.CUSTOM);
- DataSourceTextField idField = new DataSourceTextField("id", "ID"); idField.setPrimaryKey(true);
@@ -75,7 +81,8 @@ public class AutodiscoveryQueueDataSource extends DataSource {
DataSourceTextField statusField = new DataSourceTextField("status", "Inventory Status");
- setFields(idField, parentIdField, resourceNameField, resourceKeyField, resourceTypeField, descriptionField, statusField, timestampField); + setFields(idField, parentIdField, resourceNameField, resourceKeyField, resourceTypeField, descriptionField, + statusField, timestampField); }
protected Object transformRequest(DSRequest request) { @@ -84,17 +91,16 @@ public class AutodiscoveryQueueDataSource extends DataSource { // Asume success response.setStatus(0); switch (request.getOperationType()) { - case FETCH: - executeFetch(request, response); - break; - default: - break; + case FETCH: + executeFetch(request, response); + break; + default: + break; }
return request.getData(); }
- protected void executeFetch(final DSRequest request, final DSResponse response) { PageControl pc = getPageControl(request);
@@ -114,21 +120,18 @@ public class AutodiscoveryQueueDataSource extends DataSource { statuses.add(InventoryStatus.NEW); }
+ resourceService.getQueuedPlatformsAndServers(statuses, pc, new AsyncCallback<Map<Resource, List<Resource>>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load inventory discovery queue", caught); + }
- resourceService.getQueuedPlatformsAndServers(statuses, pc, - new AsyncCallback<Map<Resource, List<Resource>>>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load inventory discovery queue", caught); - } - - public void onSuccess(Map<Resource, List<Resource>> result) { - response.setData(buildNodes(result)); - processResponse(request.getRequestId(), response); - } - }); + public void onSuccess(Map<Resource, List<Resource>> result) { + response.setData(buildNodes(result)); + processResponse(request.getRequestId(), response); + } + }); }
- private TreeNode[] buildNodes(Map<Resource, List<Resource>> result) {
ArrayList<ResourceTreeNode> nodes = new ArrayList<ResourceTreeNode>(); @@ -146,7 +149,6 @@ public class AutodiscoveryQueueDataSource extends DataSource { return treeNodes; }
- /** * Returns a prepopulated PageControl based on the provided DSRequest. This will set sort fields, * pagination, but *not* filter fields. @@ -157,10 +159,12 @@ public class AutodiscoveryQueueDataSource extends DataSource { protected PageControl getPageControl(DSRequest request) { // Initialize paging. PageControl pageControl; - if (request.getStartRow() == null || request.getEndRow() == null) { - pageControl = new PageControl(); + //retrieve portlet.configurationInformation + if ((this.portlet != null) || (this.portlet instanceof AutodiscoveryPortlet)) {//using default + AutodiscoveryPortlet settings = (AutodiscoveryPortlet) this.portlet; + pageControl = new PageControl(0, settings.getMaximumPlatformsToDisplay()); } else { - pageControl = PageControl.getExplicitPageControl(request.getStartRow(), request.getEndRow() - request.getStartRow()); + pageControl = new PageControl(0, unlimited); }
// Initialize sorting. @@ -177,7 +181,6 @@ public class AutodiscoveryQueueDataSource extends DataSource { return pageControl; }
- public static class ResourceTreeNode extends TreeNode {
private Resource resource; @@ -186,8 +189,8 @@ public class AutodiscoveryQueueDataSource extends DataSource { this.resource = resource;
String id = String.valueOf(resource.getId()); - String parentId = resource.getParentResource() == null ? null - : String.valueOf((resource.getParentResource().getId())); + String parentId = resource.getParentResource() == null ? null : String.valueOf((resource + .getParentResource().getId()));
setID(id); setParentID(parentId); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java index 2d81fe0..445d1cb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java @@ -22,6 +22,7 @@ import java.util.ArrayList;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.Criteria; +import com.smartgwt.client.data.DataSource; import com.smartgwt.client.types.SelectionAppearance; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.IButton; @@ -57,6 +58,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { private boolean simple = false; private TreeGrid treeGrid; private ToolStrip footer; + private DataSource dataSource = null;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -107,7 +109,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
treeGrid.setHeight100();
- treeGrid.setDataSource(new AutodiscoveryQueueDataSource()); + treeGrid.setDataSource(dataSource = new AutodiscoveryQueueDataSource()); treeGrid.setAutoFetchData(true); treeGrid.setResizeFieldsInRealTime(true);
@@ -230,4 +232,12 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { this.treeGrid.invalidateCache(); this.treeGrid.markForRedraw(); } + + public DataSource getDataSource() { + return dataSource; + } + + public TreeGrid getTreeGrid() { + return treeGrid; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java index bc72530..1dd89ce 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java @@ -1,5 +1,23 @@ package org.rhq.enterprise.gui.coregui.client.util;
+/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ import java.util.ArrayList; import java.util.List;
commit 3bd640d779cbd010aa70fa13a81a54598ed78ada Author: Simeon Pinder spinder@redhat.com Date: Sun Sep 12 21:23:06 2010 -0400
add footer for portlet and port of measurement utility.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index f30ab10..0d4e6d6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -77,12 +77,13 @@ public class Table extends LocatableHLayout { private TableFilter filterForm; private ListGrid listGrid; private ToolStrip footer; - private Label tableInfo; + protected Label tableInfo;
private List<String> headerIcons = new ArrayList<String>();
private boolean showHeader = true; - private boolean showFooter = true; + protected boolean showFooter = true; + private boolean showFooterRefresh = true;
private String tableTitle; private Criteria criteria; @@ -122,7 +123,7 @@ public class Table extends LocatableHLayout {
private List<TableActionInfo> tableActions = new ArrayList<TableActionInfo>(); private boolean tableActionDisableOverride = false; - private List<Canvas> extraWidgets = new ArrayList<Canvas>(); + protected List<Canvas> extraWidgets = new ArrayList<Canvas>();
public Table(String locatorId) { this(locatorId, null, null, null, null, true); @@ -314,13 +315,15 @@ public class Table extends LocatableHLayout {
footer.addMember(new LayoutSpacer());
- IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh"); - refreshButton.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent clickEvent) { - listGrid.invalidateCache(); - } - }); - footer.addMember(refreshButton); + if (isShowFooterRefresh()) { + IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh"); + refreshButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + listGrid.invalidateCache(); + } + }); + footer.addMember(refreshButton); + }
footer.addMember(tableInfo);
@@ -648,4 +651,12 @@ public class Table extends LocatableHLayout { this.actionButton = actionButton; } } + + public boolean isShowFooterRefresh() { + return showFooterRefresh; + } + + public void setShowFooterRefresh(boolean showFooterRefresh) { + this.showFooterRefresh = showFooterRefresh; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java index 815afd7..3faa954 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java @@ -19,9 +19,14 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+//import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; @@ -34,11 +39,14 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.configuration.definition.PropertySimpleType; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget; import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/** * A view that displays a paginated table of Resources with alerts, @@ -48,13 +56,13 @@ import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource */ public class ProblemResourcesPortlet extends Table implements CustomSettingsPortlet {
+ //keys for smart gwt elements. should be unique public static final String PROBLEM_RESOURCE_SHOW_HRS = "max-problems-query-span"; public static final String PROBLEM_RESOURCE_SHOW_MAX = "max-problems-shown"; public static final String KEY = "Has Alerts or Currently Unavailable"; private static final String TITLE = KEY; - private int maximumProblemResourcesToDisplay = -1; - private int maximumProblemResourcesWithinHours = -1; private DashboardPortlet storedPortlet; + //constants public static final String unlimited = "unlimited"; public static final String defaultValue = unlimited;
@@ -62,10 +70,13 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort super(locatorId, TITLE, true);
setShowHeader(false); - setShowFooter(false); + setShowFooter(true); + //disable footer refresh + setShowFooterRefresh(false);
setOverflow(Overflow.HIDDEN);
+ //insert the datasource this.dataSource = new ProblemResourcesDataSource(this);
setDataSource(this.dataSource); @@ -82,16 +93,18 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort listGrid.setCellHeight(50); //wrap to display disambiguation listGrid.setWrapCells(true); - listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%"); - listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%"); - listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%"); - listGrid.getField(ProblemResourcesDataSource.available).setWidth("10%"); + addExtraWidget(new TimeRange(this.getLocatorId(), this)); } }
//reference to datasource private ProblemResourcesDataSource dataSource;
+ @Override + public ProblemResourcesDataSource getDataSource() { + return (ProblemResourcesDataSource) super.getDataSource(); + } + /** Implement configure action. * */ @@ -99,27 +112,39 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
this.storedPortlet = storedPortlet; - if (storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_MAX) != null) { + int configuredValue = -1; + + //determine configuration value for ProblemResourceShowMax + configuredValue = populateConfigurationValue(storedPortlet, PROBLEM_RESOURCE_SHOW_MAX, defaultValue); + getDataSource().setMaximumProblemResourcesToDisplay(configuredValue); + + //determine configuration value for ProblemResourceShowHrs + configuredValue = populateConfigurationValue(storedPortlet, PROBLEM_RESOURCE_SHOW_HRS, defaultValue); + getDataSource().setMaximumProblemResourcesWithinHours(configuredValue); + } + + /**Determine which configuration value to use given the property passed in. + * + * @param storedPortlet DashboardPortlet instance + * @param propertyKey Widget key + * @param defaultKeyValue default value to be used if property not yet set. + * @return int value of configuration, Ex. 1,5,10,unlimited where unlimited==-1. + */ + private int populateConfigurationValue(DashboardPortlet storedPortlet, String propertyKey, String defaultKeyValue) { + int configuredValue; + if ((storedPortlet != null) && (storedPortlet.getConfiguration().getSimple(propertyKey) != null)) { //retrieve and translate to int - String retrieved = storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_MAX).getStringValue(); + String retrieved = storedPortlet.getConfiguration().getSimple(propertyKey).getStringValue(); if (retrieved.equals(unlimited)) { - maximumProblemResourcesToDisplay = -1; + configuredValue = -1; } else { - maximumProblemResourcesToDisplay = Integer.parseInt(retrieved); + configuredValue = Integer.parseInt(retrieved); } - } else {//create setting - storedPortlet.getConfiguration().put(new PropertySimple(PROBLEM_RESOURCE_SHOW_MAX, defaultValue)); - } - if (storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_HRS) != null) { - String retrieved = storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_HRS).getStringValue(); - if (retrieved.equals(unlimited)) { - setMaximumProblemResourcesWithinHours(-1); - } else { - setMaximumProblemResourcesWithinHours(Integer.parseInt(retrieved)); - } - } else { - storedPortlet.getConfiguration().put(new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, defaultValue)); + } else {//create setting if not already there. + storedPortlet.getConfiguration().put(new PropertySimple(propertyKey, defaultKeyValue)); + configuredValue = -1; } + return configuredValue; }
@Override @@ -198,6 +223,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort storedPortlet.getConfiguration().put( new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, form.getValue(PROBLEM_RESOURCE_SHOW_HRS))); } + refresh(); } });
@@ -224,19 +250,62 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort return definition; }
- public int getMaximumProblemResourcesToDisplay() { - return maximumProblemResourcesToDisplay; + protected void refreshTableInfo() { + if (showFooter) { + long begin = 0; + List<Long> bounds = MeasurementUtility.calculateTimeFrame(getDataSource() + .getMaximumProblemResourcesWithinHours(), MeasurementUtility.UNIT_HOURS); + begin = bounds.get(0); + long end = bounds.get(1); + + //if range spans greater than year then change formatter. + if ((end - begin) > MeasurementUtility.ONE_YEAR) { + timeRange = new String[] { MeasurementUtility.getDateTimeYearFormatter().format(new Date(begin)), + MeasurementUtility.getDateTimeYearFormatter().format(new Date(end)) }; + } else { + timeRange = new String[] { MeasurementUtility.getDateTimeFormatter().format(new Date(begin)), + MeasurementUtility.getDateTimeFormatter().format(new Date(end)) }; + } + for (Canvas extraWidget : extraWidgets) { + if (extraWidget instanceof TableWidget) { + ((TableWidget) extraWidget).refresh(getListGrid()); + } + } + //remove selected count as portlet is view only. Selection not used. + this.tableInfo.setContents("Total: " + getListGrid().getTotalRows()); + } + } + + private String[] timeRange = null; + + public String[] getTimeRange() { + return timeRange; }
- public void setMaximumProblemResourcesToDisplay(int maxPerRow) { - this.maximumProblemResourcesToDisplay = maxPerRow; +} + +/**Construct table widget Label to display timerange settings used with latest datasource query. + * + * @author spinder + */ +class TimeRange extends LocatableHLayout implements TableWidget { + private Label label = new Label(); + private ProblemResourcesPortlet portlet = null; + + public TimeRange(String locatorId, ProblemResourcesPortlet problemResourcesPortlet) { + super(locatorId); + this.portlet = problemResourcesPortlet; }
- public void setMaximumProblemResourcesWithinHours(int maximumProblemResourcesWithinHours) { - this.maximumProblemResourcesWithinHours = maximumProblemResourcesWithinHours; + @Override + public void refresh(ListGrid listGrid) { + this.label.setWidth(400); + this.label.setContents("From " + portlet.getTimeRange()[0] + " to " + portlet.getTimeRange()[1]); }
- public int getMaximumProblemResourcesWithinHours() { - return maximumProblemResourcesWithinHours; + @Override + protected void onDraw() { + super.onDraw(); + addMember(this.label); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java index 7597d13..38c316b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java @@ -52,6 +52,10 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo public static final String alerts = "alerts"; public static final String available = "available"; private Portlet portlet = null; + private long oldestDate = -1; + //configure elements + private int maximumProblemResourcesToDisplay = -1; + private int maximumProblemResourcesWithinHours = -1;
/** Build list of fields for the datasource and then adds them to it. * @param problemResourcesPortlet @@ -108,13 +112,13 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo ProblemResourcesPortlet problemPortlet = (ProblemResourcesPortlet) this.portlet; //populate criteria with portlet preferences defined. if (problemPortlet != null) { - if (problemPortlet.getMaximumProblemResourcesToDisplay() > 0) { - maxItems = problemPortlet.getMaximumProblemResourcesToDisplay(); + if (getMaximumProblemResourcesToDisplay() > 0) { + maxItems = getMaximumProblemResourcesToDisplay(); } //define the time window - if (problemPortlet.getMaximumProblemResourcesWithinHours() > 0) { - ctime = System.currentTimeMillis() - - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000); + if (getMaximumProblemResourcesWithinHours() > 0) { + ctime = System.currentTimeMillis() - (getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000); + setOldestDate(ctime); } } } @@ -200,4 +204,28 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo public DisambiguationReport<ProblemResourceComposite> copyValues(ListGridRecord from) { throw new UnsupportedOperationException("ProblemResource data is read only"); } + + public long getOldestDate() { + return oldestDate; + } + + public void setOldestDate(long oldestDate) { + this.oldestDate = oldestDate; + } + + public int getMaximumProblemResourcesToDisplay() { + return maximumProblemResourcesToDisplay; + } + + public void setMaximumProblemResourcesToDisplay(int maxPerRow) { + this.maximumProblemResourcesToDisplay = maxPerRow; + } + + public void setMaximumProblemResourcesWithinHours(int maximumProblemResourcesWithinHours) { + this.maximumProblemResourcesWithinHours = maximumProblemResourcesWithinHours; + } + + public int getMaximumProblemResourcesWithinHours() { + return maximumProblemResourcesWithinHours; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java new file mode 100644 index 0000000..bc72530 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java @@ -0,0 +1,99 @@ +package org.rhq.enterprise.gui.coregui.client.util; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.i18n.client.DateTimeFormat; + +public class MeasurementUtility { + + private static DateTimeFormat formatter = DateTimeFormat.getFormat("MMM d, hh:mm a"); + private static DateTimeFormat formatterYear = DateTimeFormat.getFormat("MMM d, yyyy hh:mm a"); + + //Time constants + public static final int UNIT_COLLECTION_POINTS = 1; + public static final int UNIT_MINUTES = 2; + public static final int UNIT_HOURS = 3; + public static final int UNIT_DAYS = 4; + public static final int UNIT_WEEKS = 5; + /* + * show units in terms of milliseconds + */ + public static final long MINUTES = 60000; + public static final long HOURS = 3600000; + public static final long DAYS = 86400000; + public static final long WEEKS = 604800000; + + /** + * five minutes in millisecond increments + */ + public static final long FIVE_MINUTES = 300000; + public static final long ONE_YEAR = WEEKS * 52; + + /** + * Method calculateTimeFrame + * <p/> + * Returns a two element<code>List</code> of <code>Long</code> objects representing the begin and end times (in + * milliseconds since the epoch) of the timeframe. Returns null instead if the time unit is indicated as + * <code>UNIT_COLLECTION_POINTS</code>. Ported to GWT from MeasurementUtils(i:server side dep + * ii:old DateFormat doesn't play well with GWT). + * + * @param lastN the number of time units in the time frame + * @param unit the unit of time (as defined by <code>UNIT_*</code> constants + * @return List + */ + public static List<Long> calculateTimeFrame(int lastN, int unit) { + List<Long> l = new ArrayList<Long>(0); + if (unit == UNIT_COLLECTION_POINTS) { + return null; + } + + long now = System.currentTimeMillis(); + + long retrospective = lastN; + + switch (unit) { + case UNIT_WEEKS: + retrospective *= WEEKS; + break; + case UNIT_MINUTES: + retrospective *= MINUTES; + break; + case UNIT_HOURS: + retrospective *= HOURS; + break; + case UNIT_DAYS: + retrospective *= DAYS; + break; + default: + retrospective = -1; + break; + } + + if (retrospective < 0) {//translate unlimited hrs to 0 time. + retrospective = now; + } + + l.add(now - retrospective); + l.add(now); + + return l; + } + + /**Utility to return shared DateTimeFormat("MMM d, hh:mm a"); + * + * @return DateTimeFormat + */ + public static DateTimeFormat getDateTimeFormatter() { + return formatter; + } + + /**Utility to return shared DateTimeFormat("MMM d, yyyy hh:mm a"); + * + * @return DateTimeFormat + */ + public static DateTimeFormat getDateTimeYearFormatter() { + return formatterYear; + } + +}
commit 4b78144546207ab92eddf048699a3a46fbb1434b Author: Ian Springer ian.springer@redhat.com Date: Sat Sep 11 16:29:57 2010 -0400
extract superclass for resource and group detail view classes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java index 1302774..cba747e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java @@ -35,7 +35,7 @@ public class ViewId { public ViewId(String path, Breadcrumb... breadcrumbs) { this.path = path; if ( breadcrumbs != null) { - this.breadcrumbs = Arrays.asList(breadcrumbs); + this.breadcrumbs = Arrays.asList(breadcrumbs); } else { this.breadcrumbs = new ArrayList<Breadcrumb>(); } @@ -57,6 +57,11 @@ public class ViewId { }
@Override + public String toString() { + return this.path; + } + + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java new file mode 100644 index 0000000..bdd1981 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java @@ -0,0 +1,198 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.common.detail; + +import com.google.gwt.user.client.History; +import com.smartgwt.client.types.Side; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.layout.Layout; +import org.rhq.enterprise.gui.coregui.client.BookmarkableView; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.ViewPath; +import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab; +import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab; +import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent; +import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler; +import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +import java.util.List; + +/** + * @author Greg Hinkle + * @author Ian Springer + */ +public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends LocatableVLayout + implements BookmarkableView, TwoLevelTabSelectedHandler { + private String baseViewPath; + private TwoLevelTabSet tabSet; + private String tabName; + private String subTabName; + private U titleBar; + + public AbstractTwoLevelTabSetView(String locatorId, String baseViewPath) { + super(locatorId); + this.baseViewPath = baseViewPath; + + setWidth100(); + setHeight100(); + + this.titleBar = createTitleBar(); + addMember(this.titleBar); + + this.tabSet = new TwoLevelTabSet(extendLocatorId("TabSet")); + this.tabSet.setTabBarPosition(Side.TOP); + this.tabSet.setWidth100(); + this.tabSet.setHeight100(); + this.tabSet.setEdgeMarginSize(0); + this.tabSet.setEdgeSize(0); + + List<TwoLevelTab> tabsList = createTabs(); + this.tabSet.setTabs(tabsList.toArray(new TwoLevelTab[tabsList.size()])); + + this.tabSet.addTwoLevelTabSelectedHandler(this); + + addMember(this.tabSet); + } + + // ------------------ Abstract Methods -------------------- + public abstract Integer getSelectedItemId(); + + protected abstract U createTitleBar(); + + protected abstract List<TwoLevelTab> createTabs(); + + protected abstract void loadSelectedItem(int itemId, ViewPath viewPath); + + protected abstract void updateTabContent(T selectedItem); + // --------------------------------------------------------- + + protected U getTitleBar() { + return this.titleBar; + } + + public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { + //CoreGUI.printWidgetTree(); + + if (getSelectedItemId() == null) { + // History.fireCurrentHistoryState(); + } else { + // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views. + // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId()); + String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId(); + String path = this.baseViewPath + "/" + getSelectedItemId() + tabPath; + + // If the tab that was selected is not already the current history item, the user clicked on the tab, rather + // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the + // current history item. + if (!History.getToken().equals(path)) { + History.newItem(path, true); + } + } + } + + public void renderView(ViewPath viewPath) { + // e.g. #Resource/10010/Summary/Overview + // ^ current path + int id = Integer.parseInt(viewPath.getCurrent().getPath()); + viewPath.next(); + + if (!viewPath.isEnd()) { + // e.g. #Resource/10010/Summary/Overview + // ^ current path + this.tabName = viewPath.getCurrent().getPath(); + viewPath.next(); + if (!viewPath.isEnd()) { + // e.g. #Resource/10010/Summary/Overview + // ^ current path + this.subTabName = viewPath.getCurrent().getPath(); + viewPath.next(); + } else { + this.subTabName = null; + } + } else { + this.tabName = null; + } + + if (getSelectedItemId() == null || getSelectedItemId() != id) { + // A different Resource or first load - go get data. + loadSelectedItem(id, viewPath); + } else { + // Same Resource - just switch tabs. + selectTab(this.tabName, this.subTabName, viewPath); + } + } + + /** + * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs"). + * + * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected + * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected + * @param viewPath the view path, which may have additional view items to be rendered + */ + public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) { + try { + TwoLevelTab tab = (tabTitle != null) ? this.tabSet.getTabByTitle(tabTitle) : + this.tabSet.getDefaultTab(); + if (tab == null || tab.getDisabled()) { + CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle); + // TODO: Should we fire a history event here to redirect to a valid bookmark? + tab = this.tabSet.getDefaultTab(); + if (tab == null) { + throw new IllegalStateException("No default tab is defined."); + } + subtabTitle = null; + } + // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first. + + SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab(); + if (subtab == null || tab.getLayout().isDisabled()) { + CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle); + // TODO: Should we fire a history event here to redirect to a valid bookmark? + subtab = tab.getLayout().getDefaultSubTab(); + } + tab.getLayout().selectSubTab(subtab); + + // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire). + this.tabSet.selectTab(tab); + + // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view). + Canvas subView = subtab.getCanvas(); + if (subView instanceof BookmarkableView) { + ((BookmarkableView) subView).renderView(viewPath); + } + + this.tabSet.markForRedraw(); + } catch (Exception e) { + System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e); + } + } + + public TwoLevelTabSet getTabSet() { + return tabSet; + } + + public String getTabName() { + return tabName; + } + + public String getSubTabName() { + return subTabName; + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 9d289ca..b51bc00 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -18,13 +18,12 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
+import java.util.ArrayList; import java.util.EnumSet; +import java.util.List; import java.util.Set;
-import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.types.Side; -import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.authz.Permission; @@ -38,23 +37,19 @@ import org.rhq.core.domain.resource.group.GroupCategory; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane; import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab; import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab; -import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent; -import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler; -import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView; import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** * Right panel of the group view. @@ -62,13 +57,14 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * @author Greg Hinkle * @author Ian Springer */ -public class ResourceGroupDetailView extends LocatableVLayout implements BookmarkableView, TwoLevelTabSelectedHandler { - private static final String DEFAULT_TAB_NAME = "Inventory"; +public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> { + private static final String BASE_VIEW_PATH = "ResourceGroup";
- private int groupId; + private Integer groupId; private ResourceGroupComposite groupComposite; private ResourcePermission permissions;
+ // tabs private TwoLevelTab summaryTab; private TwoLevelTab monitoringTab; private TwoLevelTab inventoryTab; @@ -77,8 +73,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar private TwoLevelTab configurationTab; private TwoLevelTab eventsTab;
- private TwoLevelTabSet topTabSet; - + // subtabs private SubTab summaryOverview; private SubTab summaryTimeline; private SubTab monitorGraphs; @@ -96,32 +91,30 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar private SubTab configHistory; private SubTab eventHistory;
- private ResourceGroupTitleBar titleBar; - - private String tabName; - private String subTabName; - public ResourceGroupDetailView(String locatorId) { - super(locatorId); + super(locatorId, BASE_VIEW_PATH); + }
- setWidth100(); - setHeight100(); + @Override + public Integer getSelectedItemId() { + return this.groupId; + }
- // The Tabs section + @Override + protected ResourceGroupTitleBar createTitleBar() { + return new ResourceGroupTitleBar(getLocatorId()); + }
- topTabSet = new TwoLevelTabSet(getLocatorId()); - topTabSet.setTabBarPosition(Side.TOP); - topTabSet.setWidth100(); - topTabSet.setHeight100(); - topTabSet.setEdgeMarginSize(0); - topTabSet.setEdgeSize(0); + protected List<TwoLevelTab> createTabs() { + List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(topTabSet.extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png"); + summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png"); summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null); summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null); summaryTab.registerSubTabs(summaryOverview, summaryTimeline); + tabs.add(summaryTab);
- monitoringTab = new TwoLevelTab(topTabSet.extendLocatorId("Monitoring"), "Monitoring", + monitoringTab = new TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring", "/images/icons/Monitor_grey_16.png"); monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"), "Graphs", null); monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"), "Tables", null); @@ -130,54 +123,49 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar monitorSched = new SubTab(monitoringTab.extendLocatorId("Schedules"), "Schedules", null); monitorCallTime = new SubTab(monitoringTab.extendLocatorId("CallTime"), "Call Time", null); monitoringTab.registerSubTabs(monitorGraphs, monitorTables, monitorTraits, monitorSched, monitorCallTime); + tabs.add(monitoringTab);
- inventoryTab = new TwoLevelTab(topTabSet.extendLocatorId("Inventory"), "Inventory", + inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory", "/images/icons/Inventory_grey_16.png"); inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"), "Members", null); inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null); inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn); + tabs.add(inventoryTab);
- operationsTab = new TwoLevelTab(topTabSet.extendLocatorId("Operations"), "Operations", + operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations", "/images/icons/Operation_grey_16.png"); this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), "History", null); this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), "Scheduled", null); operationsTab.registerSubTabs(this.opHistory, this.opSched); + tabs.add(operationsTab);
- alertsTab = new TwoLevelTab(topTabSet.extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png"); + alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png"); this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"), "History", null); this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"), "Definitions", null); alertsTab.registerSubTabs(alertHistory, alertDef); + tabs.add(alertsTab);
- configurationTab = new TwoLevelTab(topTabSet.extendLocatorId("Configuration"), "Configuration", + configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), "Configuration", "/images/icons/Configure_grey_16.png"); this.configCurrent = new SubTab(configurationTab.extendLocatorId("Current"), "Current", null); this.configHistory = new SubTab(configurationTab.extendLocatorId("History"), "History", null); configurationTab.registerSubTabs(this.configCurrent, this.configHistory); + tabs.add(configurationTab);
- eventsTab = new TwoLevelTab(topTabSet.extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png"); + eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png"); this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"), "History", null); eventsTab.registerSubTabs(eventHistory); + tabs.add(eventsTab);
- topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab, alertsTab, configurationTab, - eventsTab); - - topTabSet.addTwoLevelTabSelectedHandler(this); - - titleBar = new ResourceGroupTitleBar(getLocatorId()); - addMember(titleBar); - - addMember(topTabSet); - - // CoreGUI.addBreadCrumb(getPlace()); + return tabs; }
- public void updateDetailViews(ResourceGroupComposite groupComposite) { - + protected void updateTabContent(ResourceGroupComposite groupComposite) { this.groupComposite = groupComposite;
- this.titleBar.setGroup(groupComposite.getResourceGroup()); + getTitleBar().setGroup(groupComposite.getResourceGroup());
- for (Tab top : this.topTabSet.getTabs()) { + for (Tab top : this.getTabSet().getTabs()) { ((TwoLevelTab) top).getLayout().destroyViews(); }
@@ -218,7 +206,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar updateTabEnablement(); }
- private void updateTabEnablement() { GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory(); Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets(); @@ -235,74 +222,22 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups. // TODO (ips): Break out mixed groups into a separate view. - this.topTabSet.setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE); - this.topTabSet.setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE); + getTabSet().setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE); + getTabSet().setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
// Operations tab is only enabled for compatible groups of a type that supports the Operations facet. - this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); + getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
// Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet // and when the current user has the CONFIGURE_READ permission. - this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) + getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && this.permissions.isConfigureRead());
// Events tab is only enabled for compatible groups of a type that supports the Events facet. - this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); - } - - public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { - //CoreGUI.printWidgetTree(); - - if (this.groupComposite == null) { - // History.fireCurrentHistoryState(); - } else { - String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId(); - String path = "ResourceGroup/" + this.groupComposite.getResourceGroup().getId() + tabPath; - - // If the tab that was selected is not already the current history item, the user clicked on the tab, rather - // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the - // current history item. - if (!History.getToken().equals(path)) { - //System.out.println("Firing History event [" + path + "]..."); - History.newItem(path, true); - } - } + getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); }
- public void renderView(ViewPath viewPath) { - // e.g. #ResourceGroup/10010/Summary/Overview - // ^ current path - int groupId = Integer.parseInt(viewPath.getCurrent().getPath()); - viewPath.next(); - - if (!viewPath.isEnd()) { - // e.g. #ResourceGroup/10010/Summary/Overview - // ^ current path - this.tabName = viewPath.getCurrent().getPath(); - viewPath.next(); - if (!viewPath.isEnd()) { - // e.g. #ResourceGroup/10010/Summary/Overview - // ^ current path - this.subTabName = viewPath.getCurrent().getPath(); - viewPath.next(); - } else { - this.subTabName = null; - } - } else { - this.tabName = null; - } - - if (this.groupId != groupId) { - // A different group or first load - go get data. - loadSelectedGroup(groupId, viewPath); - } else { - // Same group - just switch tabs. - selectTab(this.tabName, this.subTabName, viewPath); - } - - } - - public void loadSelectedGroup(final int groupId, final ViewPath viewPath) { + protected void loadSelectedItem(final int groupId, final ViewPath viewPath) { this.groupId = groupId;
ResourceGroupCriteria criteria = new ResourceGroupCriteria(); @@ -348,8 +283,8 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
public void onSuccess(Set<Permission> result) { ResourceGroupDetailView.this.permissions = new ResourcePermission(result); - updateDetailViews(groupComposite); - selectTab(tabName, subTabName, viewPath); + updateTabContent(groupComposite); + selectTab(getTabName(), getSubTabName(), viewPath); } }); } @@ -357,48 +292,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar } }
- /** - * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs"). - * - * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected - * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected - * @param viewPath the view path, which may have additional view items to be rendered - */ - public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) { - try { - TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) : - this.topTabSet.getDefaultTab(); - if (tab == null || tab.getDisabled()) { - CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle); - // TODO: Should we fire a history event here to redirect to a valid bookmark? - tab = this.topTabSet.getDefaultTab(); - subtabTitle = null; - } - // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first. - - SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab(); - if (subtab == null || tab.getLayout().isDisabled()) { - CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle); - // TODO: Should we fire a history event here to redirect to a valid bookmark? - subtab = tab.getLayout().getDefaultSubTab(); - } - tab.getLayout().selectSubTab(subtab); - - // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire). - this.topTabSet.selectTab(tab); - - // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view). - Canvas subView = subtab.getCanvas(); - if (subView instanceof BookmarkableView) { - ((BookmarkableView) subView).renderView(viewPath); - } - - this.topTabSet.markForRedraw(); - } catch (Exception e) { - System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e); - } - } - private static boolean hasTraits(ResourceGroupComposite groupComposite) { ResourceType type = groupComposite.getResourceGroup().getResourceType(); if (type != null) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index 2451e4b..e4bb9fd 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -18,13 +18,12 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+import java.util.ArrayList; import java.util.EnumSet; +import java.util.List; import java.util.Set;
-import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.types.Side; -import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.criteria.ResourceCriteria; @@ -36,17 +35,14 @@ import org.rhq.core.domain.resource.ResourceTypeFacet; import org.rhq.core.domain.resource.composite.ResourceComposite; import org.rhq.core.domain.resource.composite.ResourcePermission; import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.alert.definitions.ResourceAlertDefinitionsView; import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane; import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab; import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab; -import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent; -import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler; -import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView; import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView; @@ -61,7 +57,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.D import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.OverviewView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.util.message.Message; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** * Right panel of the Resource view. @@ -69,12 +64,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * @author Greg Hinkle * @author Ian Springer */ -public class ResourceDetailView extends LocatableVLayout implements BookmarkableView, TwoLevelTabSelectedHandler { - private int resourceId; +public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceComposite, ResourceTitleBar> { + private static final String BASE_VIEW_PATH = "Resource";
- private ResourceComposite resourceComposite; + private Integer resourceId;
- private TwoLevelTabSet topTabSet; + private ResourceComposite resourceComposite;
private TwoLevelTab summaryTab; private TwoLevelTab monitoringTab; @@ -109,33 +104,22 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable private SubTab contentSubscrip; private SubTab contentHistory;
- private ResourceTitleBar titleBar; - - private String tabName; - private String subTabName; - public ResourceDetailView(String locatorId) { - super(locatorId); - - setWidth100(); - setHeight100(); - - // The Tabs section + super(locatorId, BASE_VIEW_PATH); + }
- topTabSet = new TwoLevelTabSet(extendLocatorId("TabSet")); - topTabSet.setTabBarPosition(Side.TOP); - topTabSet.setWidth100(); - topTabSet.setHeight100(); - topTabSet.setEdgeMarginSize(0); - topTabSet.setEdgeSize(0); + protected List<TwoLevelTab> createTabs() { + List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(topTabSet.extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png"); + summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary", + "/images/icons/Service_up_16.png"); summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null); summaryDashboard = new SubTab(summaryTab.extendLocatorId("Dashboard"), "Dashboard", null); summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null); summaryTab.registerSubTabs(summaryOverview, summaryDashboard, summaryTimeline); + tabs.add(summaryTab);
- monitoringTab = new TwoLevelTab(topTabSet.extendLocatorId("Monitoring"), "Monitoring", + monitoringTab = new TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring", "/images/icons/Monitor_grey_16.png"); monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"), "Graphs", null); monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"), "Tables", null); @@ -145,64 +129,64 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable monitorCallTime = new SubTab(monitoringTab.extendLocatorId("CallTime"), "Call Time", null); monitoringTab.registerSubTabs(monitorGraphs, monitorTables, monitorTraits, monitorAvail, monitorSched, monitorCallTime); + tabs.add(monitoringTab);
- inventoryTab = new TwoLevelTab(topTabSet.extendLocatorId("Inventory"), "Inventory", + inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory", "/images/icons/Inventory_grey_16.png"); inventoryChildren = new SubTab(inventoryTab.extendLocatorId("Children"), "Children", null); inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null); inventoryTab.registerSubTabs(this.inventoryChildren, this.inventoryConn); + tabs.add(inventoryTab);
- operationsTab = new TwoLevelTab(topTabSet.extendLocatorId("Operations"), "Operations", + operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations", "/images/icons/Operation_grey_16.png"); this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), "History", null); this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), "Scheduled", null); operationsTab.registerSubTabs(this.opHistory, this.opSched); + tabs.add(operationsTab);
- alertsTab = new TwoLevelTab(topTabSet.extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png"); + alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png"); this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"), "History", null); this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"), "Definitions", null); this.alertDelete = new SubTab(alertsTab.extendLocatorId("DELETEME"), "DELETEME", null); alertsTab.registerSubTabs(alertHistory, alertDef, alertDelete); + tabs.add(alertsTab);
- configurationTab = new TwoLevelTab(topTabSet.extendLocatorId("Configuration"), "Configuration", + configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), "Configuration", "/images/icons/Configure_grey_16.png"); this.configCurrent = new SubTab(configurationTab.extendLocatorId("Current"), "Current", null); this.configHistory = new SubTab(configurationTab.extendLocatorId("History"), "History", null); configurationTab.registerSubTabs(this.configCurrent, this.configHistory); + tabs.add(configurationTab);
- eventsTab = new TwoLevelTab(topTabSet.extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png"); + eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png"); this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"), "History", null); eventsTab.registerSubTabs(eventHistory); + tabs.add(eventsTab);
- contentTab = new TwoLevelTab(topTabSet.extendLocatorId("Content"), "Content", + contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), "Content", "/images/icons/Content_grey_16.png"); this.contentDeployed = new SubTab(contentTab.extendLocatorId("Deployed"), "Deployed", null); this.contentNew = new SubTab(contentTab.extendLocatorId("New"), "New", null); this.contentSubscrip = new SubTab(contentTab.extendLocatorId("Subscriptions"), "Subscriptions", null); this.contentHistory = new SubTab(contentTab.extendLocatorId("History"), "History", null); contentTab.registerSubTabs(contentDeployed, contentNew, contentSubscrip, contentHistory); + tabs.add(contentTab);
- topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab, alertsTab, configurationTab, - eventsTab, contentTab); - - topTabSet.addTwoLevelTabSelectedHandler(this); - - titleBar = new ResourceTitleBar(extendLocatorId("TitleBar")); - - addMember(titleBar); - addMember(topTabSet); - - // CoreGUI.addBreadCrumb(getPlace()); + return tabs; }
- public void updateDetailViews(ResourceComposite resourceComposite) { + protected ResourceTitleBar createTitleBar() { + return new ResourceTitleBar(extendLocatorId("TitleBar")); + }
+ protected void updateTabContent(ResourceComposite resourceComposite) { this.resourceComposite = resourceComposite;
final Resource resource = this.resourceComposite.getResource(); - this.titleBar.setResource(resource); + getTitleBar().setResource(resource);
- for (Tab top : this.topTabSet.getTabs()) { + for (Tab top : this.getTabSet().getTabs()) { ((TwoLevelTab) top).getLayout().destroyViews(); }
@@ -276,66 +260,17 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable ResourceType type = this.resourceComposite.getResource().getResourceType(); inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
- this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); - this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); - this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); - this.topTabSet.setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT)); - } - - public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { - //CoreGUI.printWidgetTree(); - - if (this.resourceComposite == null) { - // History.fireCurrentHistoryState(); - } else { - // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views. - // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId()); - String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId(); - String path = "Resource/" + resourceId + tabPath; - - // If the tab that was selected is not already the current history item, the user clicked on the tab, rather - // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the - // current history item. - if (!History.getToken().equals(path)) { - System.out.println("Firing History event [" + path + "]..."); - History.newItem(path, true); - } - } + getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); + getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); + getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); + getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT)); }
- public void renderView(ViewPath viewPath) { - // e.g. #Resource/10010/Summary/Overview - // ^ current path - int resourceId = Integer.parseInt(viewPath.getCurrent().getPath()); - viewPath.next(); - - if (!viewPath.isEnd()) { - // e.g. #Resource/10010/Summary/Overview - // ^ current path - this.tabName = viewPath.getCurrent().getPath(); - viewPath.next(); - if (!viewPath.isEnd()) { - // e.g. #Resource/10010/Summary/Overview - // ^ current path - this.subTabName = viewPath.getCurrent().getPath(); - viewPath.next(); - } else { - this.subTabName = null; - } - } else { - this.tabName = null; - } - - if (this.resourceId != resourceId) { - // A different Resource or first load - go get data. - loadSelectedResource(resourceId, viewPath); - } else { - // Same Resource - just switch tabs. - selectTab(this.tabName, this.subTabName, viewPath); - } + public Integer getSelectedItemId() { + return this.resourceId; }
- public void loadSelectedResource(final int resourceId, final ViewPath viewPath) { + protected void loadSelectedItem(final int resourceId, final ViewPath viewPath) { this.resourceId = resourceId;
ResourceCriteria criteria = new ResourceCriteria(); @@ -379,54 +314,12 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable public void onTypesLoaded(ResourceType type) { resourceComposite.getResource().setResourceType(type); ResourceDetailView.this.resourceComposite = resourceComposite; - updateDetailViews(resourceComposite); - selectTab(tabName, subTabName, viewPath); + updateTabContent(resourceComposite); + selectTab(getTabName(), getSubTabName(), viewPath); } }); }
- /** - * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs"). - * - * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected - * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected - * @param viewPath the view path, which may have additional view items to be rendered - */ - public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) { - try { - TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) : - this.topTabSet.getDefaultTab(); - if (tab == null || tab.getDisabled()) { - CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle); - // TODO: Should we fire a history event here to redirect to a valid bookmark? - tab = this.topTabSet.getDefaultTab(); - subtabTitle = null; - } - // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first. - - SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab(); - if (subtab == null || tab.getLayout().isDisabled()) { - CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle); - // TODO: Should we fire a history event here to redirect to a valid bookmark? - subtab = tab.getLayout().getDefaultSubTab(); - } - tab.getLayout().selectSubTab(subtab); - - // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire). - this.topTabSet.selectTab(tab); - - // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view). - Canvas subView = subtab.getCanvas(); - if (subView instanceof BookmarkableView) { - ((BookmarkableView) subView).renderView(viewPath); - } - - this.topTabSet.markForRedraw(); - } catch (Exception e) { - System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e); - } - } - private static boolean hasTraits(ResourceComposite resourceComposite) { ResourceType type = resourceComposite.getResource().getResourceType(); Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions();
commit f32625b5a47a803f36bc77351f8efa8344070381 Author: Ian Springer ian.springer@redhat.com Date: Sat Sep 11 01:25:22 2010 -0400
various fixes to tab/tree navigation/bookmarking; various refactoring of tab components; some refactoring of Resource and group detail views
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index 12c624c..77cc196 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -132,11 +132,9 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { messages = GWT.create(Messages.class);
checkLoginStatus(); - }
public static void checkLoginStatus() { - // String sessionIdString = com.google.gwt.user.client.Cookies.getCookie("RHQ_Sesssion"); // if (sessionIdString == null) {
@@ -255,9 +253,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { }
public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) { - String event = URL.decodeComponent(stringValueChangeEvent.getValue()); - System.out.println("Handling history event: " + event); + //System.out.println("Handling history event: " + event); currentPath = event;
currentViewPath = new ViewPath(event); @@ -357,8 +354,24 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { contentCanvas.markForRedraw(); }
- public static void goTo(String path) { - History.newItem(path); + public static void goToView(String viewPath) { + String currentViewPath = History.getToken(); + if (currentViewPath.equals(viewPath)) { + // We're already there - just refresh the view. + refresh(); + } else { + if (viewPath.matches("(Resource|ResourceGroup)/[^/]*")) { + // e.g. "Resource/10001" + if (!currentViewPath.startsWith(viewPath)) { + // The Resource that was selected is not the same Resource that was previously selected - + // grab the end portion of the previous history URL and append it to the new history URL, + // so the same tab is selected for the new Resource. + String suffix = currentViewPath.replaceFirst("^[^/]*/[^/]*", ""); + viewPath += suffix; + } + } + History.newItem(viewPath); + } }
public static void refreshBreadCrumbTrail() { @@ -386,6 +399,10 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { }); }
+ public static void goToResourceOrGroupView(String newToken) { + + } + private class RootCanvas extends VLayout implements BookmarkableView {
ViewId currentViewId; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java index aa9da49..935f351 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java @@ -78,7 +78,7 @@ public class DemoCanvas extends Canvas { topTabSet.addTab(configTab); topTabSet.addTab(treeTab); //topTabSet.addTab(alertHistoryTab); - //topTabSet.selectTab(alertHistoryTab); + //topTabSet.selectSubTabByTitle(alertHistoryTab);
final Menu configSelectMenu = new Menu(); configSelectMenu.addItem(new MenuItem("Agent")); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java index 7d022ce..1302774 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java @@ -28,12 +28,10 @@ import java.util.List; */ public class ViewId {
- private String path;
private List<Breadcrumb> breadcrumbs;
- public ViewId(String path, Breadcrumb... breadcrumbs) { this.path = path; if ( breadcrumbs != null) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java index 445b0b7..d0e3c06 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java @@ -19,13 +19,14 @@ package org.rhq.enterprise.gui.coregui.client;
import java.util.ArrayList; +import java.util.List;
/** * @author Greg Hinkle */ public class ViewPath {
- private ArrayList<ViewId> viewPath = new ArrayList<ViewId>(); + private List<ViewId> viewPath = new ArrayList<ViewId>();
private int index = 0;
@@ -35,12 +36,12 @@ public class ViewPath { }
public ViewPath(String pathString) { - for (String pe : pathString.split("/")) { - viewPath.add(new ViewId(pe)); + for (String pathElement : pathString.split("/")) { + viewPath.add(new ViewId(pathElement)); } }
- public ArrayList<ViewId> getViewPath() { + public List<ViewId> getViewPath() { return viewPath; }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java index 7c69fa5..df0f4b5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java @@ -91,7 +91,7 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable grid.addSelectionChangedHandler(new SelectionChangedHandler() { public void onSelectionChanged(SelectionEvent selectionEvent) { if (selectionEvent.getState()) { - CoreGUI.goTo("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); + CoreGUI.goToView("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); } } }); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java index 1db0e78..741d931 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java @@ -48,7 +48,6 @@ public class SubTabLayout extends LocatableVLayout {
private SubTab currentlyDisplayed; private String currentlySelected; - private int currentIndex;
public SubTabLayout(String locatorId) { super(locatorId); @@ -99,12 +98,9 @@ public class SubTabLayout extends LocatableVLayout { // button.setStyleName("SubTabButton"); // button.setStylePrimaryName("SubTabButton");
- final Integer index = i++; - button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { currentlySelected = locatorId; - currentIndex = index; fireSubTabSelection(); draw(); } @@ -116,14 +112,14 @@ public class SubTabLayout extends LocatableVLayout { }
// Initial settings - selectTabByLocatorId(currentlySelected); + selectSubTabByLocatorId(currentlySelected); }
@Override protected void onDraw() { super.onDraw();
- selectTabByLocatorId(currentlySelected); + selectSubTabByLocatorId(currentlySelected); }
public void enableSubTab(String locatorId) { @@ -171,17 +167,25 @@ public class SubTabLayout extends LocatableVLayout { subtabs.put(locatorId, subTab); }
- public int getCurrentIndex() { - return currentIndex; + public SubTab getDefaultSubTab() { + // the default subtab is the first one in the set that is not disabled + for (SubTab subtab : this.subtabs.values()) { + if (!this.disabledSubTabs.contains(subtab.getLocatorId())) { + return subtab; + } + } + return null; }
- public SubTab getDefaultSubTab() { - return subtabs.values().iterator().next(); + public boolean selectSubTab(SubTab subtab) { + if (subtab == null) { + throw new IllegalArgumentException("subtab is null."); + } + return selectSubTabByLocatorId(subtab.getLocatorId()); }
- public boolean selectTabByLocatorId(String locatorId) { + public boolean selectSubTabByLocatorId(String locatorId) { boolean foundTab = false; - int i = 0; for (String subtabLocatorId : this.subtabs.keySet()) { if (subtabLocatorId.equals(locatorId)) { if (this.disabledSubTabs.contains(subtabLocatorId)) { @@ -190,12 +194,10 @@ public class SubTabLayout extends LocatableVLayout { CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + subtab.getTitle() + "'."); } else { this.currentlySelected = subtabLocatorId; - this.currentIndex = i; foundTab = true; } break; } - i++; }
if (foundTab) { @@ -205,30 +207,31 @@ public class SubTabLayout extends LocatableVLayout { return foundTab; }
- public boolean selectTab(String title) { - boolean foundTab = false; - int i = 0; + public SubTab getSubTabByTitle(String title) { for (String subtabLocatorId : this.subtabs.keySet()) { SubTab subtab = this.subtabs.get(subtabLocatorId); if (subtab.getTitle().equals(title)) { - if (this.disabledSubTabs.contains(subtab.getLocatorId())) { - // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL. - CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'."); - } else { - this.currentlySelected = subtab.getLocatorId(); - this.currentIndex = i; - foundTab = true; - } - break; + return subtab; } - i++; }
- if (foundTab) { + return null; + } + + public boolean selectSubTabByTitle(String title) { + SubTab subtab = getSubTabByTitle(title); + if (subtab == null) { + return false; + } else { + if (this.disabledSubTabs.contains(subtab.getLocatorId())) { + // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL. + CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'."); + return false; + } + this.currentlySelected = subtab.getLocatorId(); refresh(); + return true; } - - return foundTab; }
public SubTab getCurrentSubTab() { @@ -246,7 +249,7 @@ public class SubTabLayout extends LocatableVLayout {
public void fireSubTabSelection() { TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?", getCurrentSubTab().getTitle(), -1, - currentIndex, getCurrentCanvas()); + getCurrentCanvas()); hm.fireEvent(event); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java index 845128f..6258e9e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java @@ -52,6 +52,14 @@ public class TwoLevelTab extends LocatableTab { } }
+ public SubTab getSubTabByTitle(String title) { + return this.layout.getSubTabByTitle(title); + } + + public SubTab getDefaultSubTab() { + return this.layout.getDefaultSubTab(); + } + public SubTabLayout getLayout() { return layout; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java index 374c049..5f2b2ab 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java @@ -18,10 +18,8 @@ */ package org.rhq.enterprise.gui.coregui.client.components.tab;
-import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.GwtEvent; import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.tab.Tab;
/** * @author Greg Hinkle @@ -30,19 +28,17 @@ public class TwoLevelTabSelectedEvent extends GwtEvent<TwoLevelTabSelectedHandle
public static final GwtEvent.Type<TwoLevelTabSelectedHandler> TYPE = new Type<TwoLevelTabSelectedHandler>();
- String id; - String subTabId; + private String id; + private String subTabId;
- int tabNum; - int subTabNum; + private int tabNum;
- Canvas subTabPane; + private Canvas subTabPane;
- public TwoLevelTabSelectedEvent(String id, String subTabId, int tabNum, int subTabNum, Canvas subTabPane) { + public TwoLevelTabSelectedEvent(String id, String subTabId, int tabNum, Canvas subTabPane) { this.id = id; this.subTabId = subTabId; this.tabNum = tabNum; - this.subTabNum = subTabNum; this.subTabPane = subTabPane; }
@@ -70,14 +66,6 @@ public class TwoLevelTabSelectedEvent extends GwtEvent<TwoLevelTabSelectedHandle this.tabNum = tabNum; }
- public int getSubTabNum() { - return subTabNum; - } - - public void setSubTabNum(int subTabNum) { - this.subTabNum = subTabNum; - } - public Canvas getSubTabPane() { return subTabPane; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java index a5c2611..d39efb7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java @@ -70,23 +70,30 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle }
public void onTabSelected(TabSelectedEvent tabSelectedEvent) { - System.out.println("TwoLevelTabSet.onTabSelected(): " + tabSelectedEvent.getTab().getTitle()); TwoLevelTab tab = (TwoLevelTab) getSelectedTab(); TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(), tab.getLayout().getCurrentSubTab().getTitle(), tabSelectedEvent.getTabNum(), - tab.getLayout().getCurrentIndex(), tab.getLayout().getCurrentCanvas()); + tab.getLayout().getCurrentCanvas()); m.fireEvent(event); }
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { - System.out.println("TwoLevelTabSet.onTwoLevelTabSelected(): " + tabSelectedEvent.getId() + "/" + - tabSelectedEvent.getSubTabId()); tabSelectedEvent.setTabNum(getSelectedTabNumber()); - Tab tab = getSelectedTab(); + Tab tab = getSelectedTab(); tabSelectedEvent.setId(tab.getTitle()); m.fireEvent(tabSelectedEvent); }
+ public TwoLevelTab getDefaultTab() { + TwoLevelTab[] tabs = getTabs(); + for (TwoLevelTab tab : tabs) { + if (!tab.getDisabled()) { + return tab; + } + } + return null; + } + public TwoLevelTab getTabByTitle(String title) { return (TwoLevelTab) super.getTabByTitle(title); } @@ -94,4 +101,12 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle public TwoLevelTab getTabByLocatorId(String locatorId) { return (TwoLevelTab) super.getTabByLocatorId(locatorId); } + + public void setTabEnabled(TwoLevelTab tab, boolean enabled) { + if (enabled) { + enableTab(tab); + } else { + disableTab(tab); + } + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java index 0d04750..4f5374c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Set;
-import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; @@ -70,7 +69,7 @@ public class FavoritesButton extends LocatableIMenuButton { MenuItem item = new MenuItem(String.valueOf(resourceId)); item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { - History.newItem("Resource/" + resourceId); + CoreGUI.goToView("Resource/" + resourceId); } }); items[i] = item; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 6bb216e..9d289ca 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -177,7 +177,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
this.titleBar.setGroup(groupComposite.getResourceGroup());
- for (Tab top : topTabSet.getTabs()) { + for (Tab top : this.topTabSet.getTabs()) { ((TwoLevelTab) top).getLayout().destroyViews(); }
@@ -185,7 +185,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar // summaryTab.updateSubTab("Overview", new DashboardView(resource)); // summaryTab.updateSubTab("Timeline", timelinePane); this.summaryOverview.setCanvas(new OverviewView(this.groupComposite)); - summaryTab.updateSubTab(this.summaryOverview);
int groupId = this.groupComposite.getResourceGroup().getId();
@@ -194,126 +193,113 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId)); this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId)); this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId)); - monitoringTab.updateSubTab(this.monitorGraphs); - monitoringTab.updateSubTab(this.monitorTables); - monitoringTab.updateSubTab(this.monitorSched); - monitoringTab.updateSubTab(this.monitorCallTime);
this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId)); - inventoryTab.updateSubTab(this.inventoryMembers); - - // inventoryTab.updateSubTab("Connection Settings", new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin)); + // TODO: Uncomment this once the group config component is done. + //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId)); this.opSched.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId)); - operationsTab.updateSubTab(this.opHistory); - operationsTab.updateSubTab(this.opSched);
this.alertHistory.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId=" + groupId)); this.alertDef.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId=" + groupId)); - alertsTab.updateSubTab(this.alertHistory); - alertsTab.updateSubTab(this.alertDef);
this.configCurrent.setCanvas(new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" + groupId)); this.configHistory .setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId)); - configurationTab.updateSubTab(this.configCurrent); - configurationTab.updateSubTab(this.configHistory);
this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite)); - eventsTab.updateSubTab(this.eventHistory);
updateTabEnablement(); }
private void updateTabEnablement() { - GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory(); Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
// Summary and Inventory tabs are always enabled. - topTabSet.enableTab(summaryTab); - topTabSet.enableTab(inventoryTab); + + // Only enable "Call Time" and "Traits" subtabs for groups that implement them. + this.monitoringTab.setSubTabEnabled(this.monitorTraits.getLocatorId(), hasTraits(this.groupComposite)); + this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
// Inventory>Connection Settings subtab is only enabled for compat groups that define conn props. - inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE + this.inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups. - if (groupCategory == GroupCategory.COMPATIBLE) { - topTabSet.enableTab(monitoringTab); - topTabSet.enableTab(alertsTab); - } else { - topTabSet.disableTab(monitoringTab); - topTabSet.disableTab(alertsTab); - } + // TODO (ips): Break out mixed groups into a separate view. + this.topTabSet.setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE); + this.topTabSet.setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
// Operations tab is only enabled for compatible groups of a type that supports the Operations facet. - if (facets.contains(ResourceTypeFacet.OPERATION)) { - topTabSet.enableTab(operationsTab); - } else { - topTabSet.disableTab(operationsTab); - } + this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
// Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet // and when the current user has the CONFIGURE_READ permission. - if (facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()) { - topTabSet.enableTab(configurationTab); - } else { - topTabSet.disableTab(configurationTab); - } + this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) + && this.permissions.isConfigureRead());
// Events tab is only enabled for compatible groups of a type that supports the Events facet. - if (facets.contains(ResourceTypeFacet.EVENT)) { - topTabSet.enableTab(eventsTab); - } else { - topTabSet.disableTab(eventsTab); - } - - // only enable "Call Time" and "Traits" subtabs for groups that implement them. - monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.groupComposite)); - monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME)); + this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); }
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { + //CoreGUI.printWidgetTree(); + if (this.groupComposite == null) { -// History.fireCurrentHistoryState(); + // History.fireCurrentHistoryState(); } else { - // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views. -// selectTab(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId()); String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId(); String path = "ResourceGroup/" + this.groupComposite.getResourceGroup().getId() + tabPath;
- // But still add an item to the history, specifying false to tell it not to fire an event. - History.newItem(path, true); + // If the tab that was selected is not already the current history item, the user clicked on the tab, rather + // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the + // current history item. + if (!History.getToken().equals(path)) { + //System.out.println("Firing History event [" + path + "]..."); + History.newItem(path, true); + } } }
public void renderView(ViewPath viewPath) { - // e.g. #ResourceGroup/10010/Inventory/Overview + // e.g. #ResourceGroup/10010/Summary/Overview + // ^ current path int groupId = Integer.parseInt(viewPath.getCurrent().getPath()); - - viewPath.next(); - - tabName = (!viewPath.isEnd()) ? viewPath.getCurrent().getPath() : null; // e.g. "Inventory" - subTabName = (viewPath.viewsLeft() >= 1) ? viewPath.getNext().getPath() : null; // e.g. "Overview" - - viewPath.next(); viewPath.next();
+ if (!viewPath.isEnd()) { + // e.g. #ResourceGroup/10010/Summary/Overview + // ^ current path + this.tabName = viewPath.getCurrent().getPath(); + viewPath.next(); + if (!viewPath.isEnd()) { + // e.g. #ResourceGroup/10010/Summary/Overview + // ^ current path + this.subTabName = viewPath.getCurrent().getPath(); + viewPath.next(); + } else { + this.subTabName = null; + } + } else { + this.tabName = null; + }
if (this.groupId != groupId) { + // A different group or first load - go get data. loadSelectedGroup(groupId, viewPath); } else { - // Same group just switching tabs - selectTab(tabName, subTabName, viewPath); + // Same group - just switch tabs. + selectTab(this.tabName, this.subTabName, viewPath); } + }
public void loadSelectedGroup(final int groupId, final ViewPath viewPath) { @@ -337,7 +323,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar }); }
- private void loadResourceType(final ResourceGroupComposite groupComposite, final ViewPath viewPath) { final ResourceGroup group = this.groupComposite.getResourceGroup();
@@ -372,33 +357,48 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar } }
+ /** + * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs"). + * + * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected + * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected + * @param viewPath the view path, which may have additional view items to be rendered + */ + public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) { + try { + TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) : + this.topTabSet.getDefaultTab(); + if (tab == null || tab.getDisabled()) { + CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle); + // TODO: Should we fire a history event here to redirect to a valid bookmark? + tab = this.topTabSet.getDefaultTab(); + subtabTitle = null; + } + // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
- public void selectTab(String tabName, String subtabName, ViewPath viewPath) { - if (tabName == null) { - tabName = DEFAULT_TAB_NAME; - } - TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName); - if (tab == null) { - CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName); - // TODO: Should we fire a history event here to redirect to a valid bookmark? - tab = this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME); - } - this.topTabSet.selectTab(tab); - if (subtabName != null) { - if (!tab.getLayout().selectTab(subtabName)) { - CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName); + SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab(); + if (subtab == null || tab.getLayout().isDisabled()) { + CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle); // TODO: Should we fire a history event here to redirect to a valid bookmark? - return; - } else { - Canvas subView = tab.getLayout().getCurrentCanvas(); - if (subView instanceof BookmarkableView) { - ((BookmarkableView) subView).renderView(viewPath); - } + subtab = tab.getLayout().getDefaultSubTab(); } + tab.getLayout().selectSubTab(subtab); + + // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire). + this.topTabSet.selectTab(tab); + + // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view). + Canvas subView = subtab.getCanvas(); + if (subView instanceof BookmarkableView) { + ((BookmarkableView) subView).renderView(viewPath); + } + + this.topTabSet.markForRedraw(); + } catch (Exception e) { + System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e); } }
- private static boolean hasTraits(ResourceGroupComposite groupComposite) { ResourceType type = groupComposite.getResourceGroup().getResourceType(); if (type != null) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java index 7fe5361..a205584 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java @@ -25,10 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail; import com.smartgwt.client.widgets.Canvas;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView; -import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/** @@ -37,17 +34,14 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; public class ResourceGroupTopView extends LocatableHLayout implements BookmarkableView {
private Canvas contentCanvas; - - private ResourceGroupTreeView treeView; private ResourceGroupDetailView detailView;
- private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService(); - public ResourceGroupTopView(String locatorId) { super(locatorId); }
+ @Override protected void onInit() { super.onInit(); @@ -68,7 +62,6 @@ public class ResourceGroupTopView extends LocatableHLayout implements Bookmarkab setContent(detailView); }
-
public void setContent(Canvas newContent) { if (contentCanvas.getChildren().length > 0) @@ -77,16 +70,9 @@ public class ResourceGroupTopView extends LocatableHLayout implements Bookmarkab contentCanvas.markForRedraw(); }
- public void renderView(ViewPath viewPath) { - if (viewPath.isEnd()) { - // default detail view - viewPath.getViewPath().add(new ViewId("Inventory")); - viewPath.getViewPath().add(new ViewId("Overview")); - } -
+ public void renderView(ViewPath viewPath) { this.treeView.renderView(viewPath); - this.detailView.renderView(viewPath); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java index 28aee70..4be1f22 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java @@ -49,8 +49,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource { groupIdField.setHidden(true); fields.add(0, groupIdField);
- DataSourceTextField resourceNameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, - "Resource Name"); + DataSourceTextField resourceNameField = + new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource"); fields.add(0, resourceNameField);
return fields; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index 731711e..c31881c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -111,7 +111,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView grid.addSelectionChangedHandler(new SelectionChangedHandler() { public void onSelectionChanged(SelectionEvent selectionEvent) { if (selectionEvent.getState()) { - CoreGUI.goTo("Inventory/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); + CoreGUI.goToView("Inventory/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); } } }); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index fc67739..2451e4b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -264,7 +264,6 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable }
private void updateTabEnablement() { - ResourcePermission permissions = this.resourceComposite.getResourcePermission(); Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
@@ -277,29 +276,10 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable ResourceType type = this.resourceComposite.getResource().getResourceType(); inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
- if (facets.contains(ResourceTypeFacet.OPERATION)) { - topTabSet.enableTab(operationsTab); - } else { - topTabSet.disableTab(operationsTab); - } - - if (facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()) { - topTabSet.enableTab(configurationTab); - } else { - topTabSet.disableTab(configurationTab); - } - - if (facets.contains(ResourceTypeFacet.EVENT)) { - topTabSet.enableTab(eventsTab); - } else { - topTabSet.disableTab(eventsTab); - } - - if (facets.contains(ResourceTypeFacet.CONTENT)) { - topTabSet.enableTab(contentTab); - } else { - topTabSet.disableTab(contentTab); - } + this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION)); + this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()); + this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT)); + this.topTabSet.setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT)); }
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { @@ -309,7 +289,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable // History.fireCurrentHistoryState(); } else { // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views. - // selectTab(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId()); + // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId()); String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId(); String path = "Resource/" + resourceId + tabPath;
@@ -324,26 +304,35 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable }
public void renderView(ViewPath viewPath) { - // e.g. #Resource/10010/Inventory/Overview - // ^ Current Path + // e.g. #Resource/10010/Summary/Overview + // ^ current path int resourceId = Integer.parseInt(viewPath.getCurrent().getPath()); - viewPath.next();
- tabName = (!viewPath.isEnd()) ? viewPath.getCurrent().getPath() : null; // e.g. "Inventory" - subTabName = (viewPath.viewsLeft() >= 1) ? viewPath.getNext().getPath() : null; // e.g. "Overview" - - viewPath.next(); - viewPath.next(); + if (!viewPath.isEnd()) { + // e.g. #Resource/10010/Summary/Overview + // ^ current path + this.tabName = viewPath.getCurrent().getPath(); + viewPath.next(); + if (!viewPath.isEnd()) { + // e.g. #Resource/10010/Summary/Overview + // ^ current path + this.subTabName = viewPath.getCurrent().getPath(); + viewPath.next(); + } else { + this.subTabName = null; + } + } else { + this.tabName = null; + }
if (this.resourceId != resourceId) { - // A different resource or first load, go get data + // A different Resource or first load - go get data. loadSelectedResource(resourceId, viewPath); } else { - // same resource just switch tabs - selectTab(tabName, subTabName, viewPath); + // Same Resource - just switch tabs. + selectTab(this.tabName, this.subTabName, viewPath); } - }
public void loadSelectedResource(final int resourceId, final ViewPath viewPath) { @@ -360,7 +349,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable new Message("Resource with id [" + resourceId + "] does not exist or is not accessible.", Message.Severity.Warning));
- CoreGUI.goTo(InventoryView.VIEW_PATH); + CoreGUI.goToView(InventoryView.VIEW_PATH); }
public void onSuccess(PageList<ResourceComposite> result) { @@ -396,37 +385,45 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable }); }
- public void selectTab(String tabName, String subtabName, ViewPath viewPath) { + /** + * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs"). + * + * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected + * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected + * @param viewPath the view path, which may have additional view items to be rendered + */ + public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) { try { - TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName); + TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) : + this.topTabSet.getDefaultTab(); if (tab == null || tab.getDisabled()) { - CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName); + CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle); // TODO: Should we fire a history event here to redirect to a valid bookmark? - Tab defaultTab = this.topTabSet.getTab(0); - tab = (TwoLevelTab) defaultTab; + tab = this.topTabSet.getDefaultTab(); + subtabTitle = null; } - SubTab subTab = null; - if (subtabName != null) { - if (!tab.getLayout().selectTab(subtabName)) { - CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName); - // TODO: Should we fire a history event here to redirect to a valid bookmark? - SubTab defaultSubtab = tab.getLayout().getDefaultSubTab(); - tab.getLayout().selectTab(defaultSubtab.getTitle()); - } - subTab = tab.getLayout().getCurrentSubTab(); + // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first. + + SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab(); + if (subtab == null || tab.getLayout().isDisabled()) { + CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle); + // TODO: Should we fire a history event here to redirect to a valid bookmark? + subtab = tab.getLayout().getDefaultSubTab(); } + tab.getLayout().selectSubTab(subtab); + + // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire). this.topTabSet.selectTab(tab); - if (subTab != null) { - tab.updateSubTab(subTab); - Canvas subView = subTab.getCanvas(); - if (subView instanceof BookmarkableView) { - ((BookmarkableView) subView).renderView(viewPath); - } + + // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view). + Canvas subView = subtab.getCanvas(); + if (subView instanceof BookmarkableView) { + ((BookmarkableView) subView).renderView(viewPath); } - tab.getLayout().markForRedraw(); + this.topTabSet.markForRedraw(); } catch (Exception e) { - System.err.println("Failed to select tab " + tabName + "/" + subtabName + ": " + e); + System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e); } }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java index 83c5352..7fae500 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java @@ -62,14 +62,7 @@ public class ResourceTopView extends LocatableHLayout implements BookmarkableVie }
public void renderView(ViewPath viewPath) { - if (viewPath.isEnd()) { - // default detail view - viewPath.getViewPath().add(new ViewId("Summary")); - viewPath.getViewPath().add(new ViewId("Overview")); - } - this.treeView.renderView(viewPath); - this.detailView.renderView(viewPath); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java index 8566975..57ba8f2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java @@ -91,7 +91,7 @@ public class ResourceTreeView extends LocatableVLayout {
private ViewId currentViewId;
- private ArrayList<ResourceSelectListener> selectListeners = new ArrayList<ResourceSelectListener>(); + private List<ResourceSelectListener> selectListeners = new ArrayList<ResourceSelectListener>();
private boolean initialSelect = false;
@@ -105,6 +105,7 @@ public class ResourceTreeView extends LocatableVLayout { }
public void onInit() { + // TODO (ips): Are we intentionally avoiding calling super.onInit() here? If so, why? }
private void buildTree() { @@ -124,7 +125,6 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.setLeaveScrollbarGap(false);
contextMenu = new Menu(); - MenuItem item = new MenuItem("Expand node");
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() { public void onSelectionChanged(SelectionEvent selectionEvent) { @@ -132,16 +132,11 @@ public class ResourceTreeView extends LocatableVLayout { if (treeGrid.getSelectedRecord() instanceof ResourceTreeDatasource.ResourceTreeNode) { ResourceTreeDatasource.ResourceTreeNode node = (ResourceTreeDatasource.ResourceTreeNode) treeGrid .getSelectedRecord(); - System.out.println("Resource selected in tree: " + node.getResource()); - - String newToken = "Resource/" + node.getResource().getId(); - String currentToken = History.getToken(); - if (!currentToken.startsWith(newToken)) { - - String ending = currentToken.replaceFirst("^[^\/]*\/[^\/]*", ""); - - History.newItem("Resource/" + node.getResource().getId() + ending); - + //System.out.println("Resource selected in tree: " + node.getResource()); + String viewPath = "Resource/" + node.getResource().getId(); + String currentViewPath = History.getToken(); + if (!currentViewPath.startsWith(viewPath)) { + CoreGUI.goToView(viewPath); } } } @@ -167,13 +162,13 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.addDataArrivedHandler(new DataArrivedHandler() { public void onDataArrived(DataArrivedEvent dataArrivedEvent) { if (!initialSelect) { - updateBreadcrumb(); } } }); }
+ private void updateBreadcrumb() { TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId)); // System.out.println("Trying to preopen: " + selectedNode); @@ -455,7 +450,7 @@ public class ResourceTreeView extends LocatableVLayout { public void setSelectedResource(final int selectedResourceId) { this.selectedResourceId = selectedResourceId;
- TreeNode node = null; + TreeNode node; if (treeGrid != null && treeGrid.getTree() != null && (node = treeGrid.getTree().findById(String.valueOf(selectedResourceId))) != null) {
@@ -466,8 +461,10 @@ public class ResourceTreeView extends LocatableVLayout { treeGrid.getTree().openFolders(parents); treeGrid.getTree().openFolder(node);
- treeGrid.deselectAllRecords(); - treeGrid.selectRecord(node); + if (!treeGrid.getSelectedRecord().equals(node)) { + treeGrid.deselectAllRecords(); + treeGrid.selectRecord(node); + }
updateBreadcrumb(); /* diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java index 9d56dc2..c507395 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java @@ -100,7 +100,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView grid.addSelectionChangedHandler(new SelectionChangedHandler() { public void onSelectionChanged(SelectionEvent selectionEvent) { if (selectionEvent.getState()) { - CoreGUI.goTo("Reports/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); + CoreGUI.goToView("Reports/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); } } }); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java index 37f553d..10213f4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java @@ -21,20 +21,22 @@ package org.rhq.enterprise.gui.coregui.client.util.rpc; import com.smartgwt.client.widgets.Img;
import java.util.HashSet; +import java.util.Set;
/** * @author Greg Hinkle */ public class RPCManager {
+ private static final RPCManager INSTANCE = new RPCManager();
- int nextCallId = 0; + private int nextCallId = 0;
- HashSet<MonitoringRequestCallback> inProgress = new HashSet<MonitoringRequestCallback>(); + private Set<MonitoringRequestCallback> inProgress = new HashSet<MonitoringRequestCallback>();
- Img activityIndicator; + private Img activityIndicator;
- public RPCManager() { + private RPCManager() { activityIndicator = new Img("/coregui/images/ajax-loader.gif", 16, 16); activityIndicator.setZIndex(10000); activityIndicator.setLeft(10); @@ -43,6 +45,10 @@ public class RPCManager { activityIndicator.draw(); }
+ public static RPCManager getInstance() { + return INSTANCE; + } + public int register(MonitoringRequestCallback callback) { inProgress.add(callback); refresh(); @@ -50,13 +56,13 @@ public class RPCManager { }
public void failCall(MonitoringRequestCallback callback) { - System.out.println("RPC [" + callback.getName() + "] failed in [" + callback.age() + "]"); + //System.err.println("RPC [" + callback.getName() + "] failed in [" + callback.age() + "] ms."); inProgress.remove(callback); refresh(); }
public void succeedCall(MonitoringRequestCallback callback) { - System.out.println("RPC [" + callback.getName() + "] succeeded in [" + callback.age() + "]"); + //System.out.println("RPC [" + callback.getName() + "] succeeded in [" + callback.age() + "] ms."); inProgress.remove(callback); refresh(); } @@ -76,17 +82,8 @@ public class RPCManager { }
activityIndicator.setTooltip(buf.toString()); - } else { activityIndicator.hide(); } } - - - public static RPCManager INSTANCE = new RPCManager(); - - public static RPCManager getInstance() { - return INSTANCE; - } - }
commit f121c0c17c6740c078e71a8d7da0ddda549c1392 Author: John Mazzitelli mazz@redhat.com Date: Fri Sep 10 17:22:43 2010 -0400
continuing to build out the "new condition" dialog window for alert def/condition editor
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java index e6ee5c0..23bc0cc 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java @@ -137,6 +137,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection { newAlertDef.setConditionExpression(BooleanExpression.ALL); newAlertDef.setPriority(AlertPriority.MEDIUM); newAlertDef.setWillRecover(false); + singleAlertDefinitionView.setAlertDefinition(newAlertDef); singleAlertDefinitionView.makeEditable(); } else { final AlertDefinitionCriteria criteria = new AlertDefinitionCriteria(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java index d1f5de5..fe1e2e2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java @@ -219,7 +219,7 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i priorities.put(AlertPriority.HIGH.name(), AlertPriority.HIGH.name()); priorities.put(AlertPriority.MEDIUM.name(), AlertPriority.MEDIUM.name()); priorities.put(AlertPriority.LOW.name(), AlertPriority.LOW.name()); - LinkedHashMap<String, String> priorityIcons = new LinkedHashMap<String, String>(); + LinkedHashMap<String, String> priorityIcons = new LinkedHashMap<String, String>(3); priorityIcons.put(AlertPriority.HIGH.name(), "/images/icons/Flag_red_16.png"); priorityIcons.put(AlertPriority.MEDIUM.name(), "/images/icons/Flag_yellow_16.png"); priorityIcons.put(AlertPriority.LOW.name(), "/images/icons/Flag_blue_16.png"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index 9f39e6e..c6c59c1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -23,18 +23,28 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedHashMap;
import com.smartgwt.client.types.Alignment; import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.FormItemIfFunction; import com.smartgwt.client.widgets.form.fields.ButtonItem; +import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.SpacerItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertConditionCategory; +import org.rhq.core.domain.event.EventSeverity; +import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** @@ -42,7 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; */ public class NewConditionEditor extends LocatableDynamicForm {
- private HashSet<AlertCondition> conditions; + private HashSet<AlertCondition> conditions; // the new condition we create goes into this set private SelectItem conditionTypeSelectItem;
public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions) { @@ -54,6 +64,8 @@ public class NewConditionEditor extends LocatableDynamicForm { protected void onInit() { super.onInit();
+ setMargin(20); + conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type"); LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7); condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold"); @@ -66,6 +78,12 @@ public class NewConditionEditor extends LocatableDynamicForm { conditionTypeSelectItem.setValueMap(condTypes); conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.THRESHOLD.name()); conditionTypeSelectItem.setWrapTitle(false); + conditionTypeSelectItem.setRedrawOnChange(true); + conditionTypeSelectItem.setWidth("*"); + + SpacerItem spacer = new SpacerItem(); + spacer.setColSpan(2); + spacer.setHeight(5);
ButtonItem ok = new ButtonItem("buttonItem", "OK"); ok.setColSpan(2); @@ -78,6 +96,247 @@ public class NewConditionEditor extends LocatableDynamicForm { } });
- setFields(conditionTypeSelectItem, ok); + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + formItems.add(conditionTypeSelectItem); + formItems.add(spacer); + formItems.addAll(buildMetricThresholdFormItems()); + formItems.addAll(buildMetricBaselineFormItems()); + formItems.addAll(buildMetricChangeFormItems()); + formItems.addAll(buildTraitChangeFormItems()); + formItems.addAll(buildAvailabilityChangeFormItems()); + formItems.addAll(buildOperationFormItems()); + formItems.addAll(buildEventFormItems()); + formItems.add(ok); + + setFields(formItems.toArray(new FormItem[formItems.size()])); }; + + private ArrayList<FormItem> buildMetricThresholdFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.THRESHOLD); + + String helpStr = "Specify the threshold value that, when violated, triggers the condition. The value you specify is an absolute value with an optional units specifier."; + StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr, ifFunc); + formItems.add(helpItem); + + formItems.add(buildMetricDropDownMenu("thresholdMetric", ifFunc)); + formItems.add(buildComparatorDropDownMenu("thresholdComparator", ifFunc)); + + TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value"); + absoluteValue.setWrapTitle(false); + absoluteValue.setRequired(true); + + absoluteValue.setShowIfCondition(ifFunc); + formItems.add(absoluteValue); + + return formItems; + } + + private ArrayList<FormItem> buildMetricBaselineFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.BASELINE); + + String helpStr = "Specify the baseline value that must be violated to trigger the condition. The value you specify is a percentage of the given baseline value."; + StaticTextItem helpItem = buildHelpTextItem("baselineHelp", helpStr, ifFunc); + formItems.add(helpItem); + + formItems.add(buildMetricDropDownMenu("baselineMetric", ifFunc)); + formItems.add(buildComparatorDropDownMenu("baselineComparator", ifFunc)); + + TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage"); + baselinePercentage.setWrapTitle(false); + baselinePercentage.setRequired(true); + baselinePercentage.setShowIfCondition(ifFunc); + formItems.add(baselinePercentage); + + SelectItem baselineSelection = new SelectItem("baselineSelection", "Baseline"); + LinkedHashMap<String, String> baselines = new LinkedHashMap<String, String>(3); + baselines.put("min", "Minimum"); // title should have the current value of the min baseline + baselines.put("avg", "Baseline"); // title should have the current value of the avg baseline + baselines.put("max", "Maximum"); // title should have the current value of the max baseline + baselineSelection.setValueMap(baselines); + baselineSelection.setDefaultValue("avg"); + baselineSelection.setWidth("*"); + baselineSelection.setWrapTitle(false); + baselineSelection.setShowIfCondition(ifFunc); + formItems.add(baselineSelection); + + return formItems; + } + + private ArrayList<FormItem> buildMetricChangeFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.CHANGE); + + String helpStr = "Specify the metric whose value must change to trigger the condition."; + StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp", helpStr, ifFunc); + formItems.add(helpItem); + + formItems.add(buildMetricDropDownMenu("changeMetric", ifFunc)); + + return formItems; + } + + private ArrayList<FormItem> buildTraitChangeFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.TRAIT); + + String helpStr = "Specify the trait whose value must change to trigger the condition."; + StaticTextItem helpItem = buildHelpTextItem("traitHelp", helpStr, ifFunc); + formItems.add(helpItem); + + LinkedHashMap<String, String> traits = new LinkedHashMap<String, String>(); + // TODO + traits.put("dummy trait", "Dummy Trait Name"); + + SelectItem traitSelection = new SelectItem("trait", "Trait"); + traitSelection.setValueMap(traits); + traitSelection.setDefaultValue(traits.keySet().iterator().next()); // just use the first one + traitSelection.setWidth("*"); + traitSelection.setShowIfCondition(ifFunc); + formItems.add(traitSelection); + + return formItems; + } + + private ArrayList<FormItem> buildAvailabilityChangeFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.AVAILABILITY); + + String helpStr = "Specify the availability state change that will trigger the condition."; + StaticTextItem helpItem = buildHelpTextItem("availabilityHelp", helpStr, ifFunc); + formItems.add(helpItem); + + SelectItem selection = new SelectItem("availability", "Availability"); + LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2); + avails.put(AvailabilityType.UP.name(), "Goes UP"); + avails.put(AvailabilityType.DOWN.name(), "Goes DOWN"); + selection.setValueMap(avails); + selection.setDefaultValue(AvailabilityType.DOWN.name()); + selection.setShowIfCondition(ifFunc); + + formItems.add(selection); + return formItems; + } + + private ArrayList<FormItem> buildOperationFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.CONTROL); + + String helpStr = "Specify the result that must occur when the selected operation is executed in order to trigger the condition."; + StaticTextItem helpItem = buildHelpTextItem("operationHelp", helpStr, ifFunc); + formItems.add(helpItem); + + LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>(); + // TODO + ops.put("dummy op", "Dummy Op Name"); + + SelectItem opSelection = new SelectItem("operation", "Operation"); + opSelection.setValueMap(ops); + opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one + opSelection.setShowIfCondition(ifFunc); + formItems.add(opSelection); + + SelectItem opResultsSelection = new SelectItem("operationResults", "Operation Status"); + LinkedHashMap<String, String> operationStatuses = new LinkedHashMap<String, String>(4); + operationStatuses.put(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.INPROGRESS.name()); + operationStatuses.put(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.SUCCESS.name()); + operationStatuses.put(OperationRequestStatus.FAILURE.name(), OperationRequestStatus.FAILURE.name()); + operationStatuses.put(OperationRequestStatus.CANCELED.name(), OperationRequestStatus.CANCELED.name()); + opResultsSelection.setValueMap(operationStatuses); + opResultsSelection.setDefaultValue(OperationRequestStatus.FAILURE.name()); + opResultsSelection.setWidth("*"); + opResultsSelection.setWrapTitle(false); + opResultsSelection.setShowIfCondition(ifFunc); + formItems.add(opResultsSelection); + + return formItems; + } + + private ArrayList<FormItem> buildEventFormItems() { + ArrayList<FormItem> formItems = new ArrayList<FormItem>(); + + ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.EVENT); + + String helpStr = "Specify the event severity that an event message must be reported with in order to trigger this condition. If you specify an optional regular expression, the event message must also match that regular expression in order for the condition to trigger."; + StaticTextItem helpItem = buildHelpTextItem("eventHelp", helpStr, ifFunc); + formItems.add(helpItem); + + SelectItem eventSeveritySelection = new SelectItem("eventSeverity", "Event Severity"); + LinkedHashMap<String, String> severities = new LinkedHashMap<String, String>(5); + severities.put(EventSeverity.DEBUG.name(), EventSeverity.DEBUG.name()); + severities.put(EventSeverity.INFO.name(), EventSeverity.INFO.name()); + severities.put(EventSeverity.WARN.name(), EventSeverity.WARN.name()); + severities.put(EventSeverity.ERROR.name(), EventSeverity.ERROR.name()); + severities.put(EventSeverity.FATAL.name(), EventSeverity.FATAL.name()); + eventSeveritySelection.setValueMap(severities); + eventSeveritySelection.setDefaultValue(EventSeverity.ERROR.name()); + eventSeveritySelection.setWrapTitle(false); + eventSeveritySelection.setShowIfCondition(ifFunc); + formItems.add(eventSeveritySelection); + + TextItem eventRegex = new TextItem("eventRegex", "Regular Expression"); + eventRegex.setRequired(false); + eventRegex.setWrapTitle(false); + eventRegex.setShowIfCondition(ifFunc); + formItems.add(eventRegex); + + return formItems; + } + + private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) { + + LinkedHashMap<String, String> metrics = new LinkedHashMap<String, String>(); + metrics.put("dummy metric", "Dummy Metric Name"); + + SelectItem metricSelection = new SelectItem(itemName, "Metric"); + metricSelection.setValueMap(metrics); + metricSelection.setDefaultValue(metrics.keySet().iterator().next()); // just use the first one + metricSelection.setWidth("*"); + metricSelection.setShowIfCondition(ifFunc); + return metricSelection; + } + + private SelectItem buildComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) { + + LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>(); + comparators.put("<", "< (Less than)"); + comparators.put("=", "= (Equal to)"); + comparators.put(">", "> (Greater than)"); + + SelectItem comparatorSelection = new SelectItem(itemName, "Comparator"); + comparatorSelection.setValueMap(comparators); + comparatorSelection.setDefaultValue("<"); + comparatorSelection.setShowIfCondition(ifFunc); + return comparatorSelection; + } + + private StaticTextItem buildHelpTextItem(String itemName, String helpText, FormItemIfFunction ifFunc) { + StaticTextItem help = new StaticTextItem(itemName); + help.setShowTitle(false); + help.setColSpan(2); + help.setRowSpan(2); + help.setWrap(true); + help.setValue(helpText); + help.setShowIfCondition(ifFunc); + return help; + } + + private class ShowIfCategoryFunction implements FormItemIfFunction { + private final AlertConditionCategory category; + + public ShowIfCategoryFunction(AlertConditionCategory category) { + this.category = category; + } + + public boolean execute(FormItem item, Object value, DynamicForm form) { + return category.name().equals(form.getValue("conditionType").toString()); + } + } }
commit ee8eb63dc16b3e4d9847c0d26705dee5008e2222 Author: Simeon Pinder spinder@redhat.com Date: Thu Sep 9 18:30:01 2010 -0400
organize config labels.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java index ad0895b..e66f091 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java @@ -88,7 +88,7 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C //horizontal display component LocatableHLayout row = new LocatableHLayout("auto-discovery.configuration"); BlurbItem label = new BlurbItem("discovery-platform-count-label"); - label.setValue("Maximum Platforms to show"); + label.setValue("Number of platforms to display");
//-------------combobox for number of platforms to display on the dashboard final SelectItem maximumPlatformsComboBox = new SelectItem(AUTODISCOVERY_PLATFORM_MAX); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java index 655596b..c856151 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java @@ -129,7 +129,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
//-------------combobox for number of recently added resources to display on the dashboard final SelectItem maximumRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_MAX); - maximumRecentlyAddedComboBox.setTitle("Show maximum of"); + maximumRecentlyAddedComboBox.setTitle("Show"); maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved resources on dashboard.</b></nobr>"); //spinder 9/3/10: the following is required workaround to disable editability of combobox. maximumRecentlyAddedComboBox.setType("selection"); @@ -154,7 +154,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
//------------- Build second combobox for timeframe for problem resources search. final SelectItem maximumTimeRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_HRS); - maximumTimeRecentlyAddedComboBox.setTitle("For the last "); + maximumTimeRecentlyAddedComboBox.setTitle("Over "); maximumTimeRecentlyAddedComboBox.setHint("<nobr><b> hours </b></nobr>"); //spinder 9/3/10: the following is required workaround to disable editability of combobox. maximumTimeRecentlyAddedComboBox.setType("selection"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java index 88df56f..815afd7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java @@ -136,8 +136,8 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
//-------------combobox for number of resource to display on the dashboard final SelectItem maximumProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_MAX); - maximumProblemResourcesComboBox.setTitle("Show maximum of"); - maximumProblemResourcesComboBox.setHint("<nobr><b> problem resources for display on dashboard.</b></nobr>"); + maximumProblemResourcesComboBox.setTitle("Display"); + maximumProblemResourcesComboBox.setHint("<nobr><b> problem resources on dashboard.</b></nobr>"); //spinder 9/3/10: the following is required workaround to disable editability of combobox. maximumProblemResourcesComboBox.setType("selection"); //define acceptable values for display amount @@ -161,7 +161,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
//------------- Build second combobox for timeframe for problem resources search. final SelectItem maximumTimeProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_HRS); - maximumTimeProblemResourcesComboBox.setTitle("For the last "); + maximumTimeProblemResourcesComboBox.setTitle("Over "); maximumTimeProblemResourcesComboBox.setHint("<nobr><b> hours </b></nobr>"); //spinder 9/3/10: the following is required workaround to disable editability of combobox. maximumTimeProblemResourcesComboBox.setType("selection");
commit b07055b4f5bb90aa5d4d3c01541793fc5c23b3ef Author: Simeon Pinder spinder@redhat.com Date: Thu Sep 9 18:16:01 2010 -0400
enable server side problem resource config.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java index 81accf8..ce381ce 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java @@ -74,7 +74,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting private DashboardPortlet storedPortlet = null; public static String unlimited = "unlimited"; public static String defaultValue = unlimited; - public static boolean defaultEnabled = false; + public static boolean defaultEnabled = true;
//default no-args constructor for serialization. private OperationsPortlet() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java index fefa85f..b282e41 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java @@ -50,7 +50,7 @@ public interface ResourceGWTService extends RemoteService {
List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems);
- List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(ResourceCriteria criteria); + List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems);
Resource getPlatformForResource(int resourceId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java index d0835b8..7597d13 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java @@ -31,7 +31,6 @@ import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ProblemResourceComposite; @@ -102,26 +101,25 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo */ public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria criteria = new ResourceCriteria(); + long ctime = -1; + int maxItems = -1; //retrieve current portlet display settings if ((this.portlet != null) && (this.portlet instanceof ProblemResourcesPortlet)) { ProblemResourcesPortlet problemPortlet = (ProblemResourcesPortlet) this.portlet; //populate criteria with portlet preferences defined. if (problemPortlet != null) { if (problemPortlet.getMaximumProblemResourcesToDisplay() > 0) { - criteria.setPaging(0, problemPortlet.getMaximumProblemResourcesToDisplay()); + maxItems = problemPortlet.getMaximumProblemResourcesToDisplay(); } //define the time window if (problemPortlet.getMaximumProblemResourcesWithinHours() > 0) { - criteria.addFilterStartItime(System.currentTimeMillis() - - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000)); - criteria.addFilterEndItime(System.currentTimeMillis()); + ctime = System.currentTimeMillis() + - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000); } } - //problem resources within the time specified }
- GWTServiceLookup.getResourceService().findProblemResources(criteria, + GWTServiceLookup.getResourceService().findProblemResources(ctime, maxItems, new AsyncCallback<List<DisambiguationReport<ProblemResourceComposite>>>() {
public void onFailure(Throwable throwable) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java index aca7778..6bb2d7d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java @@ -146,16 +146,14 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re /** Locate ProblemResourcesComposites and generate the disambiguation reports for them. * Criteria passed in not currently used. */ - public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(ResourceCriteria criteria) { + public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems) {
List<ProblemResourceComposite> located = new ArrayList<ProblemResourceComposite>(); MeasurementProblemManagerLocal problemManager = LookupUtil.getMeasurementProblemManager(); ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
//retrieve list of discovered problem resources. Grab all, live scrolling data - //TODO: modify MeasurementProblemManagerLocal to accept ResourceCriteria - // located = problemManager.findProblemResources(getSessionSubject(), 0, new PageControl(0, -1)); - located = problemManager.findProblemResources(getSessionSubject(), 0, new PageControl(0, -1)); + located = problemManager.findProblemResources(getSessionSubject(), ctime, new PageControl(0, maxItems));
//translate the returned problem resources to disambiguated links List<DisambiguationReport<ProblemResourceComposite>> translated = resourceManager.disambiguate(located, @@ -197,15 +195,6 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re return platforms; }
- // @Override - // public List<ProblemResourceComposite> findProblemResources(long ctime, int maxItems) { - // List<ProblemResourceComposite> problems = - // resourceManager.findResourceCompositesByCriteria(getSessionSubject(), criteria)( - // getSessionSubject(), ctime, maxItems); - // - // return problems; - // } - public List<Integer> uninventoryResources(int[] resourceIds) { return SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(), resourceIds), "ResourceService.uninventoryResources");
commit e3421f51e395eda30bcb42e44658e37e26ad6800 Author: John Mazzitelli mazz@redhat.com Date: Fri Sep 10 12:55:31 2010 -0400
show priority flag icons in alert def pages
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java index 7e56aec..8f8c5c3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java @@ -23,6 +23,7 @@ import java.util.Date; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.data.fields.DataSourceImageField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.FieldType; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -70,7 +71,20 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A record.setAttribute(FIELD_MTIME, new Date(from.getMtime())); record.setAttribute(FIELD_ENABLED, from.getEnabled()); record.setAttribute(FIELD_DELETED, from.getDeleted()); - record.setAttribute(FIELD_PRIORITY, from.getPriority().getDisplayName()); + switch (from.getPriority()) { + case HIGH: { + record.setAttribute(FIELD_PRIORITY, "/images/icons/Flag_red_16.png"); + break; + } + case MEDIUM: { + record.setAttribute(FIELD_PRIORITY, "/images/icons/Flag_yellow_16.png"); + break; + } + case LOW: { + record.setAttribute(FIELD_PRIORITY, "/images/icons/Flag_blue_16.png"); + break; + } + } record.setAttribute(FIELD_OBJECT, from); return record; } @@ -99,7 +113,7 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A enabledField.setType(FieldType.BOOLEAN); addField(enabledField);
- DataSourceTextField priorityField = new DataSourceTextField(FIELD_PRIORITY, "Priority"); + DataSourceImageField priorityField = new DataSourceImageField(FIELD_PRIORITY, "Priority"); addField(priorityField); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java index b3f07bd..d1f5de5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java @@ -97,7 +97,7 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i descriptionStatic.setValue(alertDef.getDescription());
prioritySelection.setValue(alertDef.getPriority().name()); - priorityStatic.setValue(alertDef.getPriority().getDisplayName()); + priorityStatic.setValue(alertDef.getPriority().name());
enabledSelection.setValue(alertDef.getEnabled() ? "Yes" : "No"); enabledStatic.setValue(alertDef.getEnabled() ? "Yes" : "No"); @@ -216,12 +216,18 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
prioritySelection = new SelectItem("priority", "Priority"); LinkedHashMap<String, String> priorities = new LinkedHashMap<String, String>(3); - priorities.put(AlertPriority.HIGH.name(), AlertPriority.HIGH.getDisplayName()); - priorities.put(AlertPriority.MEDIUM.name(), AlertPriority.MEDIUM.getDisplayName()); - priorities.put(AlertPriority.LOW.name(), AlertPriority.LOW.getDisplayName()); + priorities.put(AlertPriority.HIGH.name(), AlertPriority.HIGH.name()); + priorities.put(AlertPriority.MEDIUM.name(), AlertPriority.MEDIUM.name()); + priorities.put(AlertPriority.LOW.name(), AlertPriority.LOW.name()); + LinkedHashMap<String, String> priorityIcons = new LinkedHashMap<String, String>(); + priorityIcons.put(AlertPriority.HIGH.name(), "/images/icons/Flag_red_16.png"); + priorityIcons.put(AlertPriority.MEDIUM.name(), "/images/icons/Flag_yellow_16.png"); + priorityIcons.put(AlertPriority.LOW.name(), "/images/icons/Flag_blue_16.png"); prioritySelection.setValueMap(priorities); + prioritySelection.setValueIcons(priorityIcons); prioritySelection.setDefaultValue(AlertPriority.MEDIUM.name()); priorityStatic = new StaticTextItem("priorityStatic", "Priority"); + priorityStatic.setValueIcons(priorityIcons);
enabledSelection = new RadioGroupItem("enabled", "Enabled"); enabledSelection.setValueMap("Yes", "No");
commit 2c01272635223d14b4019408aaeaab104022d1c0 Author: Ian Springer ian.springer@redhat.com Date: Fri Sep 10 01:22:28 2010 -0400
upgrade GWT from 2.0.3 to 2.0.4 (make sure to do a mvn clean install of coregui after pulling down this commit!); include GWT version in About window
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index 37e1993..2d92aba 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -23,8 +23,9 @@
<properties> <!-- dependency versions --> - <gwt.version>2.0.3</gwt.version> - + <gwt.version>2.0.4</gwt.version> + <smartgwt.version>2.2</smartgwt.version> + <!-- If this is too much memory to allocate to your gwt:debug process then override this property in in your settings.xml --> <gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M</gwt-plugin.extraJvmArgs> @@ -86,13 +87,13 @@ <dependency> <groupId>com.smartgwt</groupId> <artifactId>smartgwt</artifactId> - <version>2.2</version> + <version>${smartgwt.version}</version> </dependency> <!-- <dependency> <groupId>com.smartgwt</groupId> <artifactId>smartgwt-skins</artifactId> - <version>2.1</version> + <version>${smartgwt.version}</version> </dependency> -->
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java index b714a33..2611435 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java @@ -45,7 +45,7 @@ public class AboutModalWindow extends Window { public AboutModalWindow() { setTitle(MESSAGES.about_title(PRODUCT_INFO.getFullName())); setWidth(300); - setHeight(290); + setHeight(300); setOverflow(Overflow.VISIBLE); setShowMinimizeButton(false); setIsModal(true); @@ -74,7 +74,9 @@ public class AboutModalWindow extends Window { + "</span><br/>\n" + "<span class="DisplayLabel">" + MESSAGES.about_buildNumber() + " " + PRODUCT_INFO.getBuildNumber() + "</span><p/>\n" + - "<span class="DisplayLabel">SmartGWT version: " + Version.getVersion() + " (built " + Version.getBuildDate() + ")" + "<span class="DisplayLabel">GWT version: " + MESSAGES.gwt_version() + + "</span><br/>\n" + + "<span class="DisplayLabel">SmartGWT version: " + Version.getVersion() + "</span><br/>\n" + "<p><a href="http://jboss.org/%5C" title="JBoss " + MESSAGES.about_homepage() + "">\n" + " <img height="55" alt="" + MESSAGES.about_jbossByRedHat() + "" src="/images/jboss_logo.png">\n" + @@ -86,9 +88,11 @@ public class AboutModalWindow extends Window { HLayout bottomPanel = new HLayout(); bottomPanel.setAlign(VerticalAlignment.BOTTOM); contentPane.addMember(bottomPanel); + Canvas spacer = new Canvas(); spacer.setWidth("*"); bottomPanel.addMember(spacer); + Button closeButton = new Button(MESSAGES.button_close()); closeButton.setShowRollOver(true); closeButton.setShowDown(true); diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index 60fe75b..927f231 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -3,6 +3,11 @@ ###########################
# +# Build Info +# +gwt.version = ${gwt.version} + +# # Standard Button Labels # button.ok = OK
commit e07ebd6a7670ca982b95363820f925531acc0963 Author: Ian Springer ian.springer@redhat.com Date: Fri Sep 10 00:31:41 2010 -0400
various refactorings of tab code; start of utility method for dumping the widget tree to stdout
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java index 4b387eb..1db0e78 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java @@ -38,10 +38,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * @author Greg Hinkle */ public class SubTabLayout extends LocatableVLayout { - private ToolStrip buttonBar;
+ /** maps subtab locator IDs to SubTabs */ private Map<String, SubTab> subtabs = new LinkedHashMap<String, SubTab>(); - private Map<String, Button> subTabButtons = new HashMap<String, Button>(); + /** maps subtab locator IDs to subtab Buttons */ + private Map<String, Button> subTabButtons = new LinkedHashMap<String, Button>(); + /** locator IDs of subtabs that are disabled */ private Set<String> disabledSubTabs = new HashSet<String>();
private SubTab currentlyDisplayed; @@ -62,7 +64,7 @@ public class SubTabLayout extends LocatableVLayout { setMargin(0); setPadding(0);
- buttonBar = new ToolStrip(); + ToolStrip buttonBar = new ToolStrip(); buttonBar.setBackgroundColor("grey"); buttonBar.setWidth100(); buttonBar.setBorder(null); @@ -77,7 +79,6 @@ public class SubTabLayout extends LocatableVLayout { SubTab subTab = subtabs.get(locatorId);
if (currentlySelected == null) { - // currentlyDisplayed = subTab; currentlySelected = locatorId; }
@@ -105,7 +106,7 @@ public class SubTabLayout extends LocatableVLayout { currentlySelected = locatorId; currentIndex = index; fireSubTabSelection(); - draw(subtabs.get(locatorId)); + draw(); } });
@@ -151,35 +152,9 @@ public class SubTabLayout extends LocatableVLayout { // }
String locatorId = subTab.getLocatorId(); - subtabs.put(locatorId, subTab); - if (isDrawn() && locatorId.equals(currentlySelected)) { - draw(subTab); - } - } - - private void draw(SubTab subTab) { - if (currentlyDisplayed != null && currentlyDisplayed.getCanvas() != subTab.getCanvas()) { - try { - currentlyDisplayed.getCanvas().hide(); - } catch (Exception e) { - // ignore this - } - } - - Canvas canvas = subTab.getCanvas(); - if (canvas != null) { - if (hasMember(canvas)) { - if (!canvas.isVisible()) { - canvas.show(); - } - } else { - if (!canvas.isCreated()) { - canvas.setOverflow(Overflow.SCROLL); - } - addMember(canvas); - } - markForRedraw(); - currentlyDisplayed = subTab; + this.subtabs.put(locatorId, subTab); + if (locatorId.equals(this.currentlySelected)) { + refresh(); } }
@@ -200,37 +175,31 @@ public class SubTabLayout extends LocatableVLayout { return currentIndex; }
- public String getCurrentTitle() { - return subtabs.get(currentlySelected).getTitle(); - } - public SubTab getDefaultSubTab() { return subtabs.values().iterator().next(); }
public boolean selectTabByLocatorId(String locatorId) { boolean foundTab = false; - this.currentlySelected = locatorId; int i = 0; for (String subtabLocatorId : this.subtabs.keySet()) { if (subtabLocatorId.equals(locatorId)) { - SubTab subtab = this.subtabs.get(subtabLocatorId); if (this.disabledSubTabs.contains(subtabLocatorId)) { // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL. + SubTab subtab = this.subtabs.get(subtabLocatorId); CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + subtab.getTitle() + "'."); - break; + } else { + this.currentlySelected = subtabLocatorId; + this.currentIndex = i; + foundTab = true; } - this.currentIndex = i; - foundTab = true; break; } i++; }
- if (foundTab && isDrawn()) { - Button button = (Button) this.buttonBar.getMember(this.currentIndex); - button.select(); - draw(this.subtabs.get(locatorId)); + if (foundTab) { + refresh(); }
return foundTab; @@ -245,20 +214,18 @@ public class SubTabLayout extends LocatableVLayout { if (this.disabledSubTabs.contains(subtab.getLocatorId())) { // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL. CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'."); - break; + } else { + this.currentlySelected = subtab.getLocatorId(); + this.currentIndex = i; + foundTab = true; } - this.currentlySelected = subtab.getLocatorId(); - this.currentIndex = i; - foundTab = true; break; } i++; }
- if (foundTab && isDrawn()) { - Button button = (Button) buttonBar.getMember(currentIndex); - button.select(); - draw(subtabs.get(currentlySelected)); + if (foundTab) { + refresh(); }
return foundTab; @@ -278,8 +245,8 @@ public class SubTabLayout extends LocatableVLayout { }
public void fireSubTabSelection() { - TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?", getCurrentTitle(), -1, currentIndex, - getCurrentCanvas()); + TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?", getCurrentSubTab().getTitle(), -1, + currentIndex, getCurrentCanvas()); hm.fireEvent(event); }
@@ -297,4 +264,37 @@ public class SubTabLayout extends LocatableVLayout { } } } + + private void refresh() { + if (isDrawn()) { + Button button = this.subTabButtons.get(this.currentlySelected); + button.select(); + + SubTab currentSubtab = this.subtabs.get(this.currentlySelected); + + if (this.currentlyDisplayed != null && this.currentlyDisplayed.getCanvas() != currentSubtab.getCanvas()) { + try { + this.currentlyDisplayed.getCanvas().hide(); + } catch (Exception e) { + // ignore this + } + } + + Canvas canvas = currentSubtab.getCanvas(); + if (canvas != null) { + if (hasMember(canvas)) { + if (!canvas.isVisible()) { + canvas.show(); + } + } else { + if (!canvas.isCreated()) { + canvas.setOverflow(Overflow.SCROLL); + } + addMember(canvas); + } + markForRedraw(); + this.currentlyDisplayed = currentSubtab; + } + } + } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java index 7215baa..a5c2611 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java @@ -73,8 +73,8 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle System.out.println("TwoLevelTabSet.onTabSelected(): " + tabSelectedEvent.getTab().getTitle()); TwoLevelTab tab = (TwoLevelTab) getSelectedTab(); TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(), - tab.getLayout().getCurrentTitle(), tabSelectedEvent.getTabNum(), tab.getLayout().getCurrentIndex(), tab - .getLayout().getCurrentCanvas()); + tab.getLayout().getCurrentSubTab().getTitle(), tabSelectedEvent.getTabNum(), + tab.getLayout().getCurrentIndex(), tab.getLayout().getCurrentCanvas()); m.fireEvent(event); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 7a2064f..6bb216e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -228,13 +228,11 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite)); eventsTab.updateSubTab(this.eventHistory);
- // topTabSet.setSelectedTab(selectedTab); - completeTabUpdate(); - + updateTabEnablement(); }
- private void completeTabUpdate() { + private void updateTabEnablement() {
GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory(); Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets(); @@ -318,7 +316,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar } }
- public void loadSelectedGroup(int groupId, final ViewPath viewPath) { + public void loadSelectedGroup(final int groupId, final ViewPath viewPath) { this.groupId = groupId;
ResourceGroupCriteria criteria = new ResourceGroupCriteria(); @@ -327,12 +325,11 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria, new AsyncCallback<PageList<ResourceGroupComposite>>() { - @Override public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load group composite", caught); + CoreGUI.getErrorHandler().handleError("Failed to load group composite for group with id " + + groupId, caught); }
- @Override public void onSuccess(PageList<ResourceGroupComposite> result) { groupComposite = result.get(0); loadResourceType(groupComposite, viewPath); @@ -414,5 +411,4 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar } return false; } - } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index dc2b363..fc67739 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -274,6 +274,8 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); + ResourceType type = this.resourceComposite.getResource().getResourceType(); + inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
if (facets.contains(ResourceTypeFacet.OPERATION)) { topTabSet.enableTab(operationsTab); @@ -377,7 +379,9 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable final Resource resource = resourceComposite.getResource(); ResourceTypeRepository.Cache.getInstance().getResourceTypes( resource.getResourceType().getId(), - EnumSet.of(ResourceTypeRepository.MetadataType.content, + EnumSet.of( + ResourceTypeRepository.MetadataType.children, + ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.measurements, ResourceTypeRepository.MetadataType.events, diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java new file mode 100644 index 0000000..5790c70 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java @@ -0,0 +1,190 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.util; + +import com.google.gwt.user.client.ui.Widget; +import com.smartgwt.client.widgets.BaseWidget; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.Layout; +import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.tab.Tab; +import com.smartgwt.client.widgets.tab.TabSet; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author Ian Springer + */ +public class WidgetUtility { + private WidgetUtility() { + } + + public static void printWidgetTree(Widget widget) { + printWidgetTree(widget, 0); + } + + private static void printWidgetTree(Widget widget, int level) { + try { + printWidget(widget, level); + } catch (Exception e) { + System.err.println("====================================================================================="); + System.err.println("Failed to print widget [" + widget + "]: " + e); + System.err.println("====================================================================================="); + } + + // Recurse. + List<Widget> children; + try { + children = getChildren(widget); + } catch (Exception e) { + System.err.println("====================================================================================="); + System.err.println("Failed to get children of widget [" + widget + "]: " + e); + System.err.println("====================================================================================="); + return; + } + + for (Widget child : children) { + printWidgetTree(child, level + 1); + } + } + + private static void printWidget(Widget widget, int level) { + String simpleClassName; + try { + String className = widget.getClass().getName(); + simpleClassName = className.substring(className.lastIndexOf(".") + 1); + } catch (Exception e) { + simpleClassName = "?"; + } + String id; + try { + id = (widget.getElement() != null) ? widget.getElement().getId() : "?"; + } catch (Exception e) { + id = "?"; + } + String title; + try { + title = widget.getTitle(); + } catch (Exception e) { + title = "?"; + } + + StringBuilder flags = new StringBuilder(); + + if (widget.isAttached()) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("attached"); + } + if (widget.isVisible()) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("visible"); + } + + if (widget instanceof BaseWidget) { + BaseWidget baseWidget = (BaseWidget) widget; + + if (baseWidget.isCreated()) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("created"); + } + if (baseWidget.isConfigOnly()) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("configOnly"); + } + } + + if (widget instanceof Canvas) { + Canvas canvas = (Canvas) widget; + + if (canvas.isDrawn()) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("drawn"); + } + if (canvas.isDirty()) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("dirty"); + } + if (canvas.isDisabled()) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("disabled"); + } + } + + if (widget instanceof HLayout) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("hlayout"); + } else if (widget instanceof VLayout) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("vlayout"); + } else if (widget instanceof Layout) { + if (flags.length() != 0) { + flags.append(", "); + } + flags.append("layout"); + } + + StringBuilder indent = new StringBuilder(); + for (int i = 0; i < level; i++) { + indent.append(" "); + } + + System.out.println(indent + simpleClassName + "[id=" + id + ", title=" + title + ", flags=[" + flags + "]]"); + } + + private static List<Widget> getChildren(Widget widget) { + List<Widget> children; + if (widget instanceof TabSet) { + TabSet tabSet = (TabSet) widget; + Tab[] tabs = tabSet.getTabs(); + children = new ArrayList<Widget>(); + for (Tab tab : tabs) { + children.add(tab.getPane()); + } + } else if (widget instanceof Canvas) { + Canvas canvas = (Canvas) widget; + Canvas[] childrenArray = canvas.getChildren(); + children = new ArrayList<Widget>(); + children.addAll(Arrays.asList(childrenArray)); + } else { + children = new ArrayList<Widget>(); + } + return children; + } +}
commit d00a7dd10a914fc0b1359e9e4da04a802629b941 Author: Ian Springer ian.springer@redhat.com Date: Thu Sep 9 19:30:38 2010 -0400
fix various bugs in Resource tab navigation; fix bug that was causing Schedules subtabs to fail to render; start coding a debug utility for dumping the entire GWT widget tree to stdout; fix conditional rendering of certain subtabs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml index f26acb7..aa2b040 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml @@ -41,7 +41,7 @@ <!-- <set-property name="user.agent" value="safari"/> -->
<!-- Firefox 3 --> - <!--<set-property name="user.agent" value="gecko1_8"/>--> + <set-property name="user.agent" value="gecko1_8"/>
<entry-point class='org.rhq.enterprise.gui.coregui.client.CoreGUI'/> diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index 9b35895..12c624c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -57,6 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView; import org.rhq.enterprise.gui.coregui.client.report.ReportTopView; import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView; import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler; +import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility; import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter; import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
@@ -321,6 +322,10 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { return userPreferences; }
+ public static void printWidgetTree() { + WidgetUtility.printWidgetTree(coreGUI.rootCanvas); + } + public static void setSessionSubject(Subject subject) { // TODO this breaks because of reattach rules, bizarrely even in queries. gonna switch out to non-subject include apis // Create a minimized session object for validation on requests diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java index 7aa6dff..b714a33 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.gui.coregui.client.components;
+import com.smartgwt.client.Version; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.widgets.Button; @@ -44,7 +45,7 @@ public class AboutModalWindow extends Window { public AboutModalWindow() { setTitle(MESSAGES.about_title(PRODUCT_INFO.getFullName())); setWidth(300); - setHeight(255); + setHeight(290); setOverflow(Overflow.VISIBLE); setShowMinimizeButton(false); setIsModal(true); @@ -72,7 +73,9 @@ public class AboutModalWindow extends Window { "<span class="DisplayLabel">" + MESSAGES.about_version() + " " + PRODUCT_INFO.getVersion() + "</span><br/>\n" + "<span class="DisplayLabel">" + MESSAGES.about_buildNumber() + " " + PRODUCT_INFO.getBuildNumber() - + "</span>\n" + + + "</span><p/>\n" + + "<span class="DisplayLabel">SmartGWT version: " + Version.getVersion() + " (built " + Version.getBuildDate() + ")" + + "</span><br/>\n" + "<p><a href="http://jboss.org/%5C" title="JBoss " + MESSAGES.about_homepage() + "">\n" + " <img height="55" alt="" + MESSAGES.about_jbossByRedHat() + "" src="/images/jboss_logo.png">\n" + "</a></p>\n" + diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java index e6be4f8..1739a35 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java @@ -53,4 +53,8 @@ public class SubTab { this.canvas = canvas; }
+ @Override + public String toString() { + return "SubTab[title=" + this.title + ", locatorId=" + this.locatorId + "]"; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java index 512540e..4b387eb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java @@ -18,10 +18,7 @@ */ package org.rhq.enterprise.gui.coregui.client.components.tab;
-import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Set; +import java.util.*;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerRegistration; @@ -33,6 +30,7 @@ import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.toolbar.ToolStrip;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -40,16 +38,15 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * @author Greg Hinkle */ public class SubTabLayout extends LocatableVLayout { - private ToolStrip buttonBar;
- private LinkedHashMap<String, SubTab> subtabs = new LinkedHashMap<String, SubTab>(); - private HashMap<String, Button> subTabButtons = new HashMap<String, Button>(); + private Map<String, SubTab> subtabs = new LinkedHashMap<String, SubTab>(); + private Map<String, Button> subTabButtons = new HashMap<String, Button>(); private Set<String> disabledSubTabs = new HashSet<String>();
- SubTab currentlyDisplayed; - String currentlySelected; - int currentIndex = 0; + private SubTab currentlyDisplayed; + private String currentlySelected; + private int currentIndex;
public SubTabLayout(String locatorId) { super(locatorId); @@ -128,10 +125,10 @@ public class SubTabLayout extends LocatableVLayout { selectTabByLocatorId(currentlySelected); }
- public void enableSubTab(String title) { - disabledSubTabs.remove(title); - if (subTabButtons.containsKey(title)) { - subTabButtons.get(title).enable(); + public void enableSubTab(String locatorId) { + disabledSubTabs.remove(locatorId); + if (subTabButtons.containsKey(locatorId)) { + subTabButtons.get(locatorId).enable(); markForRedraw(); } } @@ -172,14 +169,16 @@ public class SubTabLayout extends LocatableVLayout { Canvas canvas = subTab.getCanvas(); if (canvas != null) { if (hasMember(canvas)) { - canvas.show(); + if (!canvas.isVisible()) { + canvas.show(); + } } else { if (!canvas.isCreated()) { canvas.setOverflow(Overflow.SCROLL); } - addMember(canvas); - markForRedraw(); + addMember(canvas); } + markForRedraw(); currentlyDisplayed = subTab; } } @@ -205,22 +204,33 @@ public class SubTabLayout extends LocatableVLayout { return subtabs.get(currentlySelected).getTitle(); }
+ public SubTab getDefaultSubTab() { + return subtabs.values().iterator().next(); + } + public boolean selectTabByLocatorId(String locatorId) { boolean foundTab = false; - currentlySelected = locatorId; + this.currentlySelected = locatorId; int i = 0; - for (String sub : subtabs.keySet()) { - if (sub.equals(locatorId)) { - currentIndex = i; + for (String subtabLocatorId : this.subtabs.keySet()) { + if (subtabLocatorId.equals(locatorId)) { + SubTab subtab = this.subtabs.get(subtabLocatorId); + if (this.disabledSubTabs.contains(subtabLocatorId)) { + // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL. + CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + subtab.getTitle() + "'."); + break; + } + this.currentIndex = i; foundTab = true; break; } i++; }
- if (isDrawn()) { - ((Button) buttonBar.getMember(currentIndex)).select(); - draw(subtabs.get(locatorId)); + if (foundTab && isDrawn()) { + Button button = (Button) this.buttonBar.getMember(this.currentIndex); + button.select(); + draw(this.subtabs.get(locatorId)); }
return foundTab; @@ -229,25 +239,35 @@ public class SubTabLayout extends LocatableVLayout { public boolean selectTab(String title) { boolean foundTab = false; int i = 0; - for (String sub : subtabs.keySet()) { - SubTab subtab = subtabs.get(sub); + for (String subtabLocatorId : this.subtabs.keySet()) { + SubTab subtab = this.subtabs.get(subtabLocatorId); if (subtab.getTitle().equals(title)) { + if (this.disabledSubTabs.contains(subtab.getLocatorId())) { + // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL. + CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'."); + break; + } this.currentlySelected = subtab.getLocatorId(); - currentIndex = i; + this.currentIndex = i; foundTab = true; break; } i++; }
- if (isDrawn()) { - ((Button) buttonBar.getMember(currentIndex)).select(); + if (foundTab && isDrawn()) { + Button button = (Button) buttonBar.getMember(currentIndex); + button.select(); draw(subtabs.get(currentlySelected)); }
return foundTab; }
+ public SubTab getCurrentSubTab() { + return this.subtabs.get(this.currentlySelected); + } + // ------- Event support ------- // Done with a separate handler manager from parent class on purpose (compatibility issue)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java index c78db8a..845128f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java @@ -26,7 +26,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab; * @author Greg Hinkle */ public class TwoLevelTab extends LocatableTab { - private SubTabLayout layout;
public TwoLevelTab(String locatorId, String title, String icon) { @@ -45,11 +44,11 @@ public class TwoLevelTab extends LocatableTab { } }
- public void setSubTabEnabled(String tab, boolean enabled) { + public void setSubTabEnabled(String locatorId, boolean enabled) { if (enabled) { - layout.enableSubTab(tab); + layout.enableSubTab(locatorId); } else { - layout.disableSubTab(tab); + layout.disableSubTab(locatorId); } }
@@ -62,4 +61,8 @@ public class TwoLevelTab extends LocatableTab { return layout; }
+ @Override + public String toString() { + return "TwoLevelTab[title=" + getTitle() + ", locatorId=" + getLocatorId() + "]"; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java index de4a27c..7215baa 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java @@ -27,6 +27,8 @@ import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
/** + * A tab set where each {@link TwoLevelTab tab} has one or more {@link SubTab subtab}s. + * * @author Greg Hinkle */ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandler, TwoLevelTabSelectedHandler { @@ -37,16 +39,27 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
public void setTabs(TwoLevelTab... tabs) { super.setTabs(tabs); - for (TwoLevelTab tab : tabs) { - + for (TwoLevelTab tab : tabs) { tab.getLayout().addTwoLevelTabSelectedHandler(this); - updateTab(tab, tab.getPane()); }
addTabSelectedHandler(this); }
+ public TwoLevelTab[] getTabs() { + Tab[] tabs = super.getTabs(); + TwoLevelTab[] twoLevelTabs = new TwoLevelTab[tabs.length]; + for (int i = 0, tabsLength = tabs.length; i < tabsLength; i++) { + Tab tab = tabs[i]; + if (!(tab instanceof TwoLevelTab)) { + throw new IllegalStateException("TwoLevelTabSet contains a Tab that is not a TwoLevelTab."); + } + twoLevelTabs[i] = (TwoLevelTab) tab; + } + return twoLevelTabs; + } + // ------- Event support ------- // Done with a separate handler manager from parent class on purpose (compatibility issue)
@@ -57,9 +70,8 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle }
public void onTabSelected(TabSelectedEvent tabSelectedEvent) { - + System.out.println("TwoLevelTabSet.onTabSelected(): " + tabSelectedEvent.getTab().getTitle()); TwoLevelTab tab = (TwoLevelTab) getSelectedTab(); - TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(), tab.getLayout().getCurrentTitle(), tabSelectedEvent.getTabNum(), tab.getLayout().getCurrentIndex(), tab .getLayout().getCurrentCanvas()); @@ -67,19 +79,19 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle }
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { + System.out.println("TwoLevelTabSet.onTwoLevelTabSelected(): " + tabSelectedEvent.getId() + "/" + + tabSelectedEvent.getSubTabId()); tabSelectedEvent.setTabNum(getSelectedTabNumber()); - tabSelectedEvent.setId(getSelectedTab().getTitle()); - + Tab tab = getSelectedTab(); + tabSelectedEvent.setId(tab.getTitle()); m.fireEvent(tabSelectedEvent); }
- public Tab getTabByTitle(String title) { - Tab[] tabs = getTabs(); - for (Tab tab : tabs) { - if (tab.getTitle().equals(title)) { - return tab; - } - } - return null; + public TwoLevelTab getTabByTitle(String title) { + return (TwoLevelTab) super.getTabByTitle(title); + } + + public TwoLevelTab getTabByLocatorId(String locatorId) { + return (TwoLevelTab) super.getTabByLocatorId(locatorId); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index abae48f..f30ab10 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -53,6 +53,7 @@ import com.smartgwt.client.widgets.layout.LayoutSpacer; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.toolbar.ToolStrip;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; @@ -208,136 +209,140 @@ public class Table extends LocatableHLayout {
@Override protected void onDraw() { - super.onDraw(); + try { + super.onDraw();
- for (Canvas child : contents.getMembers()) { - contents.removeChild(child); - } - - // Title - title = new HTMLFlow(); - setTableTitle(tableTitle); - - if (showHeader) { - titleLayout = new HLayout(); - titleLayout.setAutoHeight(); - titleLayout.setAlign(VerticalAlignment.BOTTOM); - } + for (Canvas child : contents.getMembers()) { + contents.removeChild(child); + }
- // Add components to the view - if (showHeader) { - contents.addMember(titleLayout, 0); - } + // Title + title = new HTMLFlow(); + setTableTitle(tableTitle);
- if (filterForm.hasContent()) { - contents.addMember(filterForm); - } + if (showHeader) { + titleLayout = new HLayout(); + titleLayout.setAutoHeight(); + titleLayout.setAlign(VerticalAlignment.BOTTOM); + }
- contents.addMember(listGrid); + // Add components to the view + if (showHeader) { + contents.addMember(titleLayout, 0); + }
- // Footer - footer = new ToolStrip(); - footer.setPadding(5); - footer.setWidth100(); - footer.setMembersMargin(15); - contents.addMember(footer); - - // The ListGrid has been created and configured - // Now give subclasses a chance to configure the table - configureTable(); - - tableInfo = new Label("Total: " + listGrid.getTotalRows()); - - // NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since - // super.onDraw() is what actually adds the fields to the ListGrid (based on what fields are defined in - // the underlying datasource). - if (this.excludedFieldNames != null) { - for (String excludedFieldName : excludedFieldNames) { - this.listGrid.hideField(excludedFieldName); + if (filterForm.hasContent()) { + contents.addMember(filterForm); } - }
- tableInfo.setWrap(false); + contents.addMember(listGrid);
- if (showHeader) { + // Footer + footer = new ToolStrip(); + footer.setPadding(5); + footer.setWidth100(); + footer.setMembersMargin(15); + contents.addMember(footer);
- for (String headerIcon : headerIcons) { - Img img = new Img(headerIcon, 24, 24); - img.setPadding(4); - titleLayout.addMember(img); - } + // The ListGrid has been created and configured + // Now give subclasses a chance to configure the table + configureTable();
- titleLayout.addMember(title); + tableInfo = new Label("Total: " + listGrid.getTotalRows());
- if (titleComponent != null) { - titleLayout.addMember(new LayoutSpacer()); - titleLayout.addMember(titleComponent); + // NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since + // super.onDraw() is what actually adds the fields to the ListGrid (based on what fields are defined in + // the underlying datasource). + if (this.excludedFieldNames != null) { + for (String excludedFieldName : excludedFieldNames) { + this.listGrid.hideField(excludedFieldName); + } }
- } + tableInfo.setWrap(false);
- if (showFooter) { + if (showHeader) {
- footer.removeMembers(footer.getMembers()); + for (String headerIcon : headerIcons) { + Img img = new Img(headerIcon, 24, 24); + img.setPadding(4); + titleLayout.addMember(img); + }
- for (final TableActionInfo tableAction : tableActions) { - IButton button = new LocatableIButton(tableAction.getLocatorId(), tableAction.getTitle()); - button.setDisabled(true); - button.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent clickEvent) { - if (tableAction.confirmMessage != null) { + titleLayout.addMember(title);
- String message = tableAction.confirmMessage.replaceAll("\#", String.valueOf(listGrid - .getSelection().length)); + if (titleComponent != null) { + titleLayout.addMember(new LayoutSpacer()); + titleLayout.addMember(titleComponent); + }
- SC.ask(message, new BooleanCallback() { - public void execute(Boolean confirmed) { - if (confirmed) { - tableAction.action.executeAction(listGrid.getSelection()); - } - } - }); - } else { - tableAction.action.executeAction(listGrid.getSelection()); - } - } - }); - tableAction.actionButton = button; - footer.addMember(button); }
- for (Canvas extraWidgetCanvas : extraWidgets) { - footer.addMember(extraWidgetCanvas); - } + if (showFooter) {
- footer.addMember(new LayoutSpacer()); + footer.removeMembers(footer.getMembers());
- IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh"); - refreshButton.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent clickEvent) { - listGrid.invalidateCache(); - } - }); - footer.addMember(refreshButton); + for (final TableActionInfo tableAction : tableActions) { + IButton button = new LocatableIButton(tableAction.getLocatorId(), tableAction.getTitle()); + button.setDisabled(true); + button.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + if (tableAction.confirmMessage != null) {
- footer.addMember(tableInfo); + String message = tableAction.confirmMessage.replaceAll("\#", String.valueOf(listGrid + .getSelection().length));
- // Manages enable/disable buttons for the grid - listGrid.addSelectionChangedHandler(new SelectionChangedHandler() { - public void onSelectionChanged(SelectionEvent selectionEvent) { - refreshTableInfo(); + SC.ask(message, new BooleanCallback() { + public void execute(Boolean confirmed) { + if (confirmed) { + tableAction.action.executeAction(listGrid.getSelection()); + } + } + }); + } else { + tableAction.action.executeAction(listGrid.getSelection()); + } + } + }); + tableAction.actionButton = button; + footer.addMember(button); } - });
- listGrid.addDataArrivedHandler(new DataArrivedHandler() { - public void onDataArrived(DataArrivedEvent dataArrivedEvent) { - refreshTableInfo(); - fieldSizes.clear(); + for (Canvas extraWidgetCanvas : extraWidgets) { + footer.addMember(extraWidgetCanvas); } - });
- // ensure buttons are initially set correctly - refreshTableInfo(); + footer.addMember(new LayoutSpacer()); + + IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh"); + refreshButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + listGrid.invalidateCache(); + } + }); + footer.addMember(refreshButton); + + footer.addMember(tableInfo); + + // Manages enable/disable buttons for the grid + listGrid.addSelectionChangedHandler(new SelectionChangedHandler() { + public void onSelectionChanged(SelectionEvent selectionEvent) { + refreshTableInfo(); + } + }); + + listGrid.addDataArrivedHandler(new DataArrivedHandler() { + public void onDataArrived(DataArrivedEvent dataArrivedEvent) { + refreshTableInfo(); + fieldSizes.clear(); + } + }); + + // Ensure buttons are initially set correctly. + refreshTableInfo(); + } + } catch (Exception e) { + CoreGUI.getErrorHandler().handleError("Failed to draw Table [" + this + "].", e); } }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java index 1cf02e7..78fe1d3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java @@ -96,9 +96,13 @@ public class UpdateCollectionIntervalWidget extends LocatableHLayout implements
@Override public void refresh(ListGrid listGrid) { - int count = listGrid.getSelection().length; - Long interval = getInterval(); - this.setButton.setDisabled(count == 0 || interval == null); + if (isDrawn()) { + int count = listGrid.getSelection().length; + Long interval = getInterval(); + this.setButton.setDisabled(count == 0 || interval == null); + } else { + markForRedraw(); + } }
private Long getInterval() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 59997b4..7a2064f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -29,6 +29,8 @@ import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.criteria.ResourceGroupCriteria; +import org.rhq.core.domain.measurement.DataType; +import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.ResourceTypeFacet; import org.rhq.core.domain.resource.composite.ResourcePermission; @@ -242,7 +244,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar topTabSet.enableTab(inventoryTab);
// Inventory>Connection Settings subtab is only enabled for compat groups that define conn props. - inventoryTab.setSubTabEnabled("Connection Settings", groupCategory == GroupCategory.COMPATIBLE + inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE && facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups. @@ -276,8 +278,9 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar topTabSet.disableTab(eventsTab); }
- // only enable "Call Time" sub-tab for those that implement it - monitoringTab.setSubTabEnabled("Call Time", facets.contains(ResourceTypeFacet.CALL_TIME)); + // only enable "Call Time" and "Traits" subtabs for groups that implement them. + monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.groupComposite)); + monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME)); }
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { @@ -300,7 +303,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
viewPath.next();
- tabName = (!viewPath.isEnd()) ? viewPath.getCurrent().getPath() : null; // e.g. "Inventory" subTabName = (viewPath.viewsLeft() >= 1) ? viewPath.getNext().getPath() : null; // e.g. "Overview"
@@ -319,7 +321,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar public void loadSelectedGroup(int groupId, final ViewPath viewPath) { this.groupId = groupId;
- ResourceGroupCriteria criteria = new ResourceGroupCriteria(); criteria.addFilterId(groupId); criteria.addFilterVisible(null); @@ -349,7 +350,9 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar ResourceType groupType = group.getResourceType(); ResourceTypeRepository.Cache.getInstance().getResourceTypes( groupType.getId(), - EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations, + EnumSet.of(ResourceTypeRepository.MetadataType.content, + ResourceTypeRepository.MetadataType.operations, + ResourceTypeRepository.MetadataType.measurements, ResourceTypeRepository.MetadataType.events, ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), new ResourceTypeRepository.TypeLoadedCallback() { @@ -377,16 +380,16 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar if (tabName == null) { tabName = DEFAULT_TAB_NAME; } - TwoLevelTab tab = (TwoLevelTab) this.topTabSet.getTabByTitle(tabName); + TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName); if (tab == null) { CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName); // TODO: Should we fire a history event here to redirect to a valid bookmark? - tab = (TwoLevelTab) this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME); + tab = this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME); } this.topTabSet.selectTab(tab); if (subtabName != null) { if (!tab.getLayout().selectTab(subtabName)) { - CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName); + CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName); // TODO: Should we fire a history event here to redirect to a valid bookmark? return; } else { @@ -398,4 +401,18 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar } }
+ + private static boolean hasTraits(ResourceGroupComposite groupComposite) { + ResourceType type = groupComposite.getResourceGroup().getResourceType(); + if (type != null) { + Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions(); + for (MeasurementDefinition metricDef : metricDefs) { + if (metricDef.getDataType() == DataType.TRAIT) { + return true; + } + } + } + return false; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java index 51b48eb..76b7b76 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java @@ -261,11 +261,24 @@ public class ResourceGroupTreeDatasource extends DataSource { setAttribute("parentId", parentId); setAttribute("name", category.getDisplayName()); } + + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + buffer.append("CategoryTreeNode["); + String id = getAttribute("id"); + buffer.append("id=").append(id); + String parentId = getAttribute("parentId"); + buffer.append(", parentId=").append(parentId); + String name = getAttribute("name"); + buffer.append(", name=").append(name); + buffer.append("]"); + return buffer.toString(); + } }
public static class TypeTreeNode extends TreeNode { - private TypeTreeNode(String parentId, String parentResourceId, String type) { setID(parentId + "_" + type); setParentID(parentId); @@ -276,10 +289,22 @@ public class ResourceGroupTreeDatasource extends DataSource { setAttribute("name", type); }
+ @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + buffer.append("TypeTreeNode["); + String id = getAttribute("id"); + buffer.append("id=").append(id); + String parentId = getAttribute("parentId"); + buffer.append(", parentId=").append(parentId); + String name = getAttribute("name"); + buffer.append(", name=").append(name); + buffer.append("]"); + return buffer.toString(); + } }
public static class ResourceTreeNode extends TreeNode { - private Resource resource;
private ResourceTreeNode(Resource resource) { @@ -325,5 +350,19 @@ public class ResourceGroupTreeDatasource extends DataSource { public String getParentId() { return getAttribute("parentId"); } + + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + buffer.append("ResourceTreeNode["); + String id = getAttribute("id"); + buffer.append("id=").append(id); + String parentId = getAttribute("parentId"); + buffer.append(", parentId=").append(parentId); + String name = getAttribute("name"); + buffer.append(", name=").append(name); + buffer.append("]"); + return buffer.toString(); + } } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index e43ccef..dc2b363 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -28,6 +28,8 @@ import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.criteria.ResourceCriteria; +import org.rhq.core.domain.measurement.DataType; +import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.ResourceTypeFacet; @@ -65,11 +67,9 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * Right panel of the Resource view. * * @author Greg Hinkle + * @author Ian Springer */ public class ResourceDetailView extends LocatableVLayout implements BookmarkableView, TwoLevelTabSelectedHandler { - - private static final String DEFAULT_TAB_NAME = "Summary"; - private int resourceId;
private ResourceComposite resourceComposite; @@ -202,7 +202,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable final Resource resource = this.resourceComposite.getResource(); this.titleBar.setResource(resource);
- for (Tab top : topTabSet.getTabs()) { + for (Tab top : this.topTabSet.getTabs()) { ((TwoLevelTab) top).getLayout().destroyViews(); }
@@ -210,9 +210,6 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable this.summaryDashboard.setCanvas(new DashboardView(this.resourceComposite)); this.summaryTimeline.setCanvas(new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId())); - summaryTab.updateSubTab(this.summaryOverview); - summaryTab.updateSubTab(this.summaryDashboard); - summaryTab.updateSubTab(this.summaryTimeline);
this.monitorGraphs.setCanvas(new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource)); this.monitorTables.setCanvas(new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId())); @@ -222,17 +219,9 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable this.monitorSched.setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId())); this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id=" + resource.getId())); - monitoringTab.updateSubTab(this.monitorGraphs); - monitoringTab.updateSubTab(this.monitorTables); - monitoringTab.updateSubTab(this.monitorTraits); - monitoringTab.updateSubTab(this.monitorAvail); - monitoringTab.updateSubTab(this.monitorSched); - monitoringTab.updateSubTab(this.monitorCallTime);
this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(resource.getId())); this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource)); - inventoryTab.updateSubTab(this.inventoryChildren); - inventoryTab.updateSubTab(this.inventoryConn);
// comment out GWT-based operation history until... // 1) user can delete history if they possess the appropriate permissions @@ -244,33 +233,24 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable resourceComposite)); this.opSched.setCanvas(new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId())); - operationsTab.updateSubTab(this.opHistory); - operationsTab.updateSubTab(this.opSched);
// comment out GWT-based alert definitions/history views until... // 1) new workflow is implement for alert definition creation, with particular attention to interaction model for alert notifications // 2) user can delete/ack/purgeAll alerts if they possess the appropriate permissions // 3) user can enable/disable/delete alert definitions if they possess the appropriate permissions - // 4) user can search alert history by: date alert was fired, alert priority, or alert definition - //alertsTab.updateSubTab("History", new ResourceAlertHistoryView(resource.getId())); + // 4) user can search alert history by: date alert was fired, alert priority, or alert definition this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" + resource.getId())); this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("Def"), resource)); this.alertDelete.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" + resource.getId())); - alertsTab.updateSubTab(this.alertHistory); - alertsTab.updateSubTab(this.alertDef); - alertsTab.updateSubTab(this.alertDelete);
this.configCurrent .setCanvas(new ResourceConfigurationEditView(this.extendLocatorId("ResourceConfig"), resource)); this.configHistory.setCanvas(ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"), resource.getId())); - configurationTab.updateSubTab(this.configCurrent); - configurationTab.updateSubTab(this.configHistory);
this.eventHistory.setCanvas(EventCompositeHistoryView.get(resourceComposite)); - eventsTab.updateSubTab(this.eventHistory);
this.contentDeployed .setCanvas(new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId())); @@ -279,26 +259,21 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable + resource.getId())); this.contentHistory.setCanvas(new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id=" + resource.getId())); - contentTab.updateSubTab(contentDeployed); - contentTab.updateSubTab(contentNew); - contentTab.updateSubTab(contentSubscrip); - contentTab.updateSubTab(contentHistory); - - // topTabSet.setSelectedTab(selectedTab);
- completeTabUpdate(); + updateTabEnablement(); }
- private void completeTabUpdate() { + private void updateTabEnablement() {
ResourcePermission permissions = this.resourceComposite.getResourcePermission(); Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
// Summary, Monitoring, Inventory, and Alerts tabs are always enabled.
- monitoringTab.setSubTabEnabled("Call Time", facets.contains(ResourceTypeFacet.CALL_TIME)); + monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.resourceComposite)); + monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
- inventoryTab.setSubTabEnabled("Connection Settings", facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION)); + inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
if (facets.contains(ResourceTypeFacet.OPERATION)) { topTabSet.enableTab(operationsTab); @@ -323,26 +298,26 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable } else { topTabSet.disableTab(contentTab); } - - if (topTabSet.getSelectedTab().getDisabled()) { - topTabSet.selectTab(0); - } - - topTabSet.markForRedraw(); }
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) { + //CoreGUI.printWidgetTree(); + if (this.resourceComposite == null) { // History.fireCurrentHistoryState(); } else { // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views. // selectTab(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId()); - String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId(); String path = "Resource/" + resourceId + tabPath;
- // But still add an item to the history, specifying false to tell it not to fire an event. - History.newItem(path, true); + // If the tab that was selected is not already the current history item, the user clicked on the tab, rather + // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the + // current history item. + if (!History.getToken().equals(path)) { + System.out.println("Firing History event [" + path + "]..."); + History.newItem(path, true); + } } }
@@ -402,7 +377,9 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable final Resource resource = resourceComposite.getResource(); ResourceTypeRepository.Cache.getInstance().getResourceTypes( resource.getResourceType().getId(), - EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations, + EnumSet.of(ResourceTypeRepository.MetadataType.content, + ResourceTypeRepository.MetadataType.operations, + ResourceTypeRepository.MetadataType.measurements, ResourceTypeRepository.MetadataType.events, ResourceTypeRepository.MetadataType.resourceConfigurationDefinition), new ResourceTypeRepository.TypeLoadedCallback() { @@ -411,34 +388,52 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable ResourceDetailView.this.resourceComposite = resourceComposite; updateDetailViews(resourceComposite); selectTab(tabName, subTabName, viewPath); - } }); }
public void selectTab(String tabName, String subtabName, ViewPath viewPath) { - if (tabName == null) { - tabName = DEFAULT_TAB_NAME; - } - TwoLevelTab tab = (TwoLevelTab) this.topTabSet.getTabByTitle(tabName); - if (tab == null) { - CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName); - // TODO: Should we fire a history event here to redirect to a valid bookmark? - tab = (TwoLevelTab) this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME); - } - this.topTabSet.selectTab(tab); - if (subtabName != null) { - if (!tab.getLayout().selectTab(subtabName)) { - CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName); + try { + TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName); + if (tab == null || tab.getDisabled()) { + CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName); // TODO: Should we fire a history event here to redirect to a valid bookmark? - return; - } else { - Canvas subView = tab.getLayout().getCurrentCanvas(); + Tab defaultTab = this.topTabSet.getTab(0); + tab = (TwoLevelTab) defaultTab; + } + SubTab subTab = null; + if (subtabName != null) { + if (!tab.getLayout().selectTab(subtabName)) { + CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName); + // TODO: Should we fire a history event here to redirect to a valid bookmark? + SubTab defaultSubtab = tab.getLayout().getDefaultSubTab(); + tab.getLayout().selectTab(defaultSubtab.getTitle()); + } + subTab = tab.getLayout().getCurrentSubTab(); + } + this.topTabSet.selectTab(tab); + if (subTab != null) { + tab.updateSubTab(subTab); + Canvas subView = subTab.getCanvas(); if (subView instanceof BookmarkableView) { ((BookmarkableView) subView).renderView(viewPath); } } + tab.getLayout().markForRedraw(); + this.topTabSet.markForRedraw(); + } catch (Exception e) { + System.err.println("Failed to select tab " + tabName + "/" + subtabName + ": " + e); } }
+ private static boolean hasTraits(ResourceComposite resourceComposite) { + ResourceType type = resourceComposite.getResource().getResourceType(); + Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions(); + for (MeasurementDefinition metricDef : metricDefs) { + if (metricDef.getDataType() == DataType.TRAIT) { + return true; + } + } + return false; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java index ecb4806..fe4fdc2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java @@ -55,10 +55,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp * @author Greg Hinkle */ public class ResourceTreeDatasource extends DataSource { - - private boolean initialized = false; - int rootId; - List<Resource> initialData; + private List<Resource> initialData;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -69,8 +66,6 @@ public class ResourceTreeDatasource extends DataSource {
this.initialData = initialData;
- this.rootId = rootId; - DataSourceField idDataField = new DataSourceTextField("id", "ID"); idDataField.setPrimaryKey(true);
@@ -240,7 +235,6 @@ public class ResourceTreeDatasource extends DataSource { }
return built.toArray(new TreeNode[built.size()]); - }
private static boolean sameTypes(ResourceTreeNode[] nodes) { @@ -263,10 +257,23 @@ public class ResourceTreeDatasource extends DataSource { setAttribute("parentId", parentId); setAttribute("name", category.getDisplayName()); } + + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + buffer.append("CategoryTreeNode["); + String id = getAttribute("id"); + buffer.append("id=").append(id); + String parentId = getAttribute("parentId"); + buffer.append(", parentId=").append(parentId); + String name = getAttribute("name"); + buffer.append(", name=").append(name); + buffer.append("]"); + return buffer.toString(); + } }
public static class TypeTreeNode extends TreeNode { - private TypeTreeNode(String parentId, String parentResourceId, String type) { setID(parentId + "_" + type); setParentID(parentId); @@ -277,10 +284,22 @@ public class ResourceTreeDatasource extends DataSource { setAttribute("name", type); }
+ @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + buffer.append("TypeTreeNode["); + String id = getAttribute("id"); + buffer.append("id=").append(id); + String parentId = getAttribute("parentId"); + buffer.append(", parentId=").append(parentId); + String name = getAttribute("name"); + buffer.append(", name=").append(name); + buffer.append("]"); + return buffer.toString(); + } }
public static class ResourceTreeNode extends TreeNode { - private Resource resource;
private ResourceTreeNode(Resource resource) { @@ -327,5 +346,19 @@ public class ResourceTreeDatasource extends DataSource { public String getParentId() { return getAttribute("parentId"); } + + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + buffer.append("ResourceTreeNode["); + String id = getAttribute("id"); + buffer.append("id=").append(id); + String parentId = getAttribute("parentId"); + buffer.append(", parentId=").append(parentId); + String name = getAttribute("name"); + buffer.append(", name=").append(name); + buffer.append("]"); + return buffer.toString(); + } } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java index e73c7ef..8566975 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java @@ -73,6 +73,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectLi import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard; import org.rhq.enterprise.gui.coregui.client.inventory.resource.factory.ResourceFactoryCreateWizard; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.util.TreeUtility; import org.rhq.enterprise.gui.coregui.client.util.message.Message; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -520,6 +521,8 @@ public class ResourceTreeView extends LocatableVLayout { } });
+ TreeUtility.printTree(treeGrid.getTree()); + TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId)); // System.out.println("Trying to preopen: " + selectedNode); if (selectedNode != null) { @@ -550,6 +553,8 @@ public class ResourceTreeView extends LocatableVLayout { new ResourceTypeRepository.ResourceTypeLoadedCallback() { public void onResourceTypeLoaded(List<Resource> result) {
+ TreeUtility.printTree(treeGrid.getTree()); + treeGrid.getTree().linkNodes(ResourceTreeDatasource.build(result));
TreeNode selectedNode = treeGrid.getTree().findById( diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java new file mode 100644 index 0000000..8199c50 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java @@ -0,0 +1,29 @@ +package org.rhq.enterprise.gui.coregui.client.util; + +import com.smartgwt.client.widgets.tree.Tree; +import com.smartgwt.client.widgets.tree.TreeNode; + +/** + * @author Ian Springer + */ +public class TreeUtility { + public static void printTree(Tree tree) { + TreeNode rootNode = tree.getRoot(); + printTreeNode(tree, rootNode); + } + + private static void printTreeNode(Tree tree, TreeNode node) { + int level = tree.getLevel(node); + for (int i = 0; i < level; i++) { + System.out.print(' '); + } + System.out.println("* " + node); + TreeNode[] childNodes = tree.getChildren(node); + for (TreeNode childNode : childNodes) { + printTreeNode(tree, childNode); + } + } + + private TreeUtility() { + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java index 5b3e09e..8fb1e41 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java @@ -3,7 +3,7 @@ package org.rhq.enterprise.gui.coregui.client.util.selenium; import com.smartgwt.client.widgets.layout.HLayout;
/** - * Wrapper for com.smartgwt.client.widgets.layout.HLayout that sets the ID for use with selenium scLocators. + * Wrapper for a SmartGWT {@link HLayout} that sets the ID for use with Selenium scLocators. * * @author Jay Shaughnessy */ @@ -46,5 +46,4 @@ public class LocatableHLayout extends HLayout implements Locatable { public String extendLocatorId(String extension) { return this.locatorId + "_" + extension; } - } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java index 4ba995c..0dda6bf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.gui.coregui.client.util.selenium;
+import com.smartgwt.client.widgets.tab.Tab; import com.smartgwt.client.widgets.tab.TabSet;
/** @@ -41,10 +42,28 @@ public class LocatableTabSet extends TabSet { SeleniumUtility.setID(this, locatorId); }
+ public void setTabs(LocatableTab... tabs) { + super.setTabs(tabs); + } + + public LocatableTab[] getTabs() { + Tab[] tabs = super.getTabs(); + LocatableTab[] locatableTabs = new LocatableTab[tabs.length]; + for (int i = 0, tabsLength = tabs.length; i < tabsLength; i++) { + Tab tab = tabs[i]; + if (!(tab instanceof LocatableTab)) { + throw new IllegalStateException("LocatableTabSet contains a Tab that is not a LocatableTab."); + } + locatableTabs[i] = (LocatableTab) tab; + } + return locatableTabs; + } + /** * Returns the locatorId. This can be useful for constructing more granular locatorIds. For example, if * the widget contains sub-widgets. Note, this is the raw locatorId for the widget, to get the fully - * formed ID, typically ofthe form "simpleClassname_locatorId" Call {@link getID()}. + * formed ID, typically of the form "simpleClassname_locatorId", call + * {@link com.smartgwt.client.widgets.Canvas#getID()}. * * @return the locatorId */ @@ -67,4 +86,23 @@ public class LocatableTabSet extends TabSet { return this.locatorId + "_" + extension; }
+ public LocatableTab getTabByTitle(String title) { + LocatableTab[] tabs = getTabs(); + for (LocatableTab tab : tabs) { + if (tab.getTitle().equals(title)) { + return tab; + } + } + return null; + } + + public LocatableTab getTabByLocatorId(String locatorId) { + LocatableTab[] tabs = getTabs(); + for (LocatableTab tab : tabs) { + if (tab.getLocatorId().equals(locatorId)) { + return tab; + } + } + return null; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java index 0a9b00e..61991c4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java @@ -3,7 +3,7 @@ package org.rhq.enterprise.gui.coregui.client.util.selenium; import com.smartgwt.client.widgets.layout.VLayout;
/** - * Wrapper for com.smartgwt.client.widgets.layout.VLayout that sets the ID for use with selenium scLocators. + * Wrapper for a SmartGWT {@link VLayout} that sets the ID for use with Selenium scLocators. * * @author Jay Shaughnessy */ @@ -50,5 +50,4 @@ public class LocatableVLayout extends VLayout implements Locatable { public void destroyMembers() { SeleniumUtility.destroyMembers(this); } - }
commit d5c7dd9fe06a82c944231ef63d102f48968585c9 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 9 17:17:32 2010 -0400
more alert def conditions editor stuff - starting the "add new condition" dialog
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java index c4e1844..e1cb68f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java @@ -139,7 +139,11 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E condExprs.put(BooleanExpression.ANY.name(), BooleanExpression.ANY.toString()); conditionExpression.setValueMap(condExprs); conditionExpression.setDefaultValue(BooleanExpression.ALL.name()); + conditionExpression.setWrapTitle(false); + conditionExpressionStatic = new StaticTextItem("conditionExpressionStatic", "Fire alert when"); + conditionExpressionStatic.setWrapTitle(false); + conditionExpressionForm.setFields(conditionExpression, conditionExpressionStatic);
conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), null); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index ecd93d0..1742ec0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -29,7 +29,9 @@ import java.util.Set; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.fields.DataSourceTextField; -import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Window; +import com.smartgwt.client.widgets.events.CloseClickHandler; +import com.smartgwt.client.widgets.events.CloseClientEvent; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition; @@ -86,8 +88,24 @@ public class ConditionsEditor extends LocatableVLayout { table.addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() { @Override public void executeAction(ListGridRecord[] selection) { - // TODO Auto-generated method stub - SC.say("Not implemented yet"); + final Window winModal = new Window(); + winModal.setTitle("Add Condition"); + winModal.setShowMinimizeButton(false); + winModal.setIsModal(true); + winModal.setShowModalMask(true); + winModal.setAutoSize(true); + winModal.setAutoCenter(true); + winModal.centerInPage(); + winModal.addCloseClickHandler(new CloseClickHandler() { + @Override + public void onCloseClick(CloseClientEvent event) { + winModal.destroy(); + } + }); + NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"), + conditions); + winModal.addItem(newConditionEditor); + winModal.show(); } }); table.addTableAction(this.extendLocatorId("delete"), "Delete", SelectionEnablement.ANY, "Are you sure?", diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java new file mode 100644 index 0000000..9f39e6e --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -0,0 +1,83 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.coregui.client.alert.definitions; + +import java.util.HashSet; +import java.util.LinkedHashMap; + +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.form.fields.ButtonItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.ClickEvent; +import com.smartgwt.client.widgets.form.fields.events.ClickHandler; + +import org.rhq.core.domain.alert.AlertCondition; +import org.rhq.core.domain.alert.AlertConditionCategory; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; + +/** + * @author John Mazzitelli + */ +public class NewConditionEditor extends LocatableDynamicForm { + + private HashSet<AlertCondition> conditions; + private SelectItem conditionTypeSelectItem; + + public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions) { + super(locatorId); + this.conditions = conditions; + } + + @Override + protected void onInit() { + super.onInit(); + + conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type"); + LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7); + condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold"); + condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold"); + condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change"); + condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change"); + condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability Change"); + condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution"); + condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection"); + conditionTypeSelectItem.setValueMap(condTypes); + conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.THRESHOLD.name()); + conditionTypeSelectItem.setWrapTitle(false); + + ButtonItem ok = new ButtonItem("buttonItem", "OK"); + ok.setColSpan(2); + ok.setAlign(Alignment.CENTER); + ok.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + // TODO + SC.say("Not yet implemented"); + } + }); + + setFields(conditionTypeSelectItem, ok); + }; +}
commit b10d84bf08e986ade3786ef53bcea64c94c11468 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 9 13:44:52 2010 -0400
more incremental coding for the conditions editor of alert def editor
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java index f19d967..c4e1844 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java @@ -23,24 +23,27 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.HashSet; import java.util.LinkedHashMap;
-import com.smartgwt.client.widgets.form.fields.CanvasItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.alert.BooleanExpression; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** * @author John Mazzitelli */ -public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implements EditAlertDefinitionForm { +public class ConditionsAlertDefinitionForm extends LocatableVLayout implements EditAlertDefinitionForm {
private AlertDefinition alertDefinition;
private SelectItem conditionExpression; + private ConditionsEditor conditionsEditor;
private StaticTextItem conditionExpressionStatic;
@@ -81,6 +84,7 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen clearFormValues(); } else { conditionExpression.setValue(alertDef.getConditionExpression().name()); + conditionsEditor.setConditions(alertDef.getConditions()); conditionExpressionStatic.setValue(alertDef.getConditionExpression().toString()); }
@@ -90,6 +94,7 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen @Override public void makeEditable() { conditionExpression.show(); + conditionsEditor.setEditable(true); conditionExpressionStatic.hide();
markForRedraw(); @@ -98,6 +103,7 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen @Override public void makeViewOnly() { conditionExpression.hide(); + conditionsEditor.setEditable(false); conditionExpressionStatic.show();
markForRedraw(); @@ -107,11 +113,15 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen public void saveAlertDefinition() { String condExpr = conditionExpression.getValue().toString(); alertDefinition.setConditionExpression(BooleanExpression.valueOf(condExpr)); + + HashSet<AlertCondition> conditions = conditionsEditor.getConditions(); + alertDefinition.setConditions(conditions); }
@Override public void clearFormValues() { conditionExpression.clearValue(); + conditionsEditor.setConditions(null);
conditionExpressionStatic.clearValue();
@@ -121,6 +131,8 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen private void buildForm() { if (!formBuilt) {
+ LocatableDynamicForm conditionExpressionForm; + conditionExpressionForm = new LocatableDynamicForm(this.extendLocatorId("conditionExpressionForm")); conditionExpression = new SelectItem("conditionExpression", "Fire alert when"); LinkedHashMap<String, String> condExprs = new LinkedHashMap<String, String>(2); condExprs.put(BooleanExpression.ALL.name(), BooleanExpression.ALL.toString()); @@ -128,16 +140,11 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen conditionExpression.setValueMap(condExprs); conditionExpression.setDefaultValue(BooleanExpression.ALL.name()); conditionExpressionStatic = new StaticTextItem("conditionExpressionStatic", "Fire alert when"); + conditionExpressionForm.setFields(conditionExpression, conditionExpressionStatic);
- ConditionsEditor conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), this); - - CanvasItem canvasItem = new CanvasItem("conditionsEditorCanvasItem"); - canvasItem.setCanvas(conditionsEditor); - canvasItem.setShowTitle(false); - canvasItem.setColSpan(2); - - setFields(conditionExpression, conditionExpressionStatic, canvasItem); + conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), null);
+ setMembers(conditionExpressionForm, conditionsEditor); formBuilt = true; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index ddc3545..ecd93d0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -23,9 +23,13 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.HashSet; +import java.util.Set; + import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.fields.DataSourceTextField; +import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition; @@ -41,12 +45,32 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; */ public class ConditionsEditor extends LocatableVLayout {
- private final ConditionsAlertDefinitionForm form; + private HashSet<AlertCondition> conditions; private Table table;
- public ConditionsEditor(String locatorId, ConditionsAlertDefinitionForm form) { + public ConditionsEditor(String locatorId, HashSet<AlertCondition> conditions) { super(locatorId); - this.form = form; + setConditions(conditions); + } + + /** + * Returns the conditions that this editor currently has in memory. + * This will never be <code>null</code>. + * + * @return conditions set that was possibly edited by the user + */ + public HashSet<AlertCondition> getConditions() { + return conditions; + } + + public void setConditions(Set<AlertCondition> set) { + conditions = new HashSet<AlertCondition>(); // make our own copy + if (set != null) { + conditions.addAll(set); + } + if (table != null) { + table.refresh(); + } }
@Override @@ -55,19 +79,26 @@ public class ConditionsEditor extends LocatableVLayout {
table = new Table("conditionsTable"); table.setShowHeader(false); - table.setDataSource(new ConditionDataSource()); + + final ConditionDataSource dataSource = new ConditionDataSource(); + table.setDataSource(dataSource);
table.addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() { @Override public void executeAction(ListGridRecord[] selection) { // TODO Auto-generated method stub + SC.say("Not implemented yet"); } }); table.addTableAction(this.extendLocatorId("delete"), "Delete", SelectionEnablement.ANY, "Are you sure?", new TableAction() { @Override public void executeAction(ListGridRecord[] selection) { - // TODO Auto-generated method stub + for (ListGridRecord record : selection) { + AlertCondition cond = dataSource.copyValues(record); + conditions.remove(cond); + } + table.refresh(); } });
@@ -102,7 +133,7 @@ public class ConditionsEditor extends LocatableVLayout {
@Override protected void executeFetch(DSRequest request, DSResponse response) { - response.setData(buildRecords(ConditionsEditor.this.form.getAlertDefinition().getConditions())); + response.setData(buildRecords(conditions)); processResponse(request.getRequestId(), response); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java index 05e6c18..d06e422 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java @@ -121,6 +121,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout { cancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { + setAlertDefinition(getAlertDefinition()); // reverts data back to original makeViewOnly(); } });
commit 0074e60a201b6d8796f2cea440d4df3b32003c9a Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 9 13:44:00 2010 -0400
avoid NPE. this can occur if calling the set-disable-override method before the table is drawn
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index d12a864..abae48f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -501,39 +501,43 @@ public class Table extends LocatableHLayout { if (showFooter) { int count = this.listGrid.getSelection().length; for (TableActionInfo tableAction : tableActions) { - boolean enabled; - if (!this.tableActionDisableOverride) { - switch (tableAction.enablement) { - case ALWAYS: - enabled = true; - break; - case NEVER: + if (tableAction.actionButton != null) { // if null, we haven't initialized our buttons yet, so skip this + boolean enabled; + if (!this.tableActionDisableOverride) { + switch (tableAction.enablement) { + case ALWAYS: + enabled = true; + break; + case NEVER: + enabled = false; + break; + case ANY: + enabled = (count >= 1); + break; + case SINGLE: + enabled = (count == 1); + break; + case MULTIPLE: + enabled = (count > 1); + break; + default: + throw new IllegalStateException("Unhandled SelectionEnablement: " + + tableAction.enablement.name()); + } + } else { enabled = false; - break; - case ANY: - enabled = (count >= 1); - break; - case SINGLE: - enabled = (count == 1); - break; - case MULTIPLE: - enabled = (count > 1); - break; - default: - throw new IllegalStateException("Unhandled SelectionEnablement: " - + tableAction.enablement.name()); } - } else { - enabled = false; + tableAction.actionButton.setDisabled(!enabled); } - tableAction.actionButton.setDisabled(!enabled); } for (Canvas extraWidget : extraWidgets) { if (extraWidget instanceof TableWidget) { ((TableWidget) extraWidget).refresh(this.listGrid); } } - this.tableInfo.setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)"); + if (this.tableInfo != null) { + this.tableInfo.setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)"); + } } }
commit ede3762f4450a72eb47c9359b115ab5342f0d26d Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 8 21:54:59 2010 -0400
keep default ids in place for just a little longer
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java index 21ef740..e4b60bc 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java @@ -17,7 +17,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; */ public class SeleniumUtility {
- private static final boolean USE_DEFAULT_IDS = false; + private static final boolean USE_DEFAULT_IDS = true;
/** A default id that is not ecommended as it will clash with any other element set to the default */ public static final String DEFAULT_ID = "DefaultID";
commit 3465dd5d19d96e5be1ff3569beec2b7b30e333e6 Merge: 5fc1c81... e292517... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 8 17:28:08 2010 -0400
Merge branch 'master' into master-jay
commit 5fc1c81999013914039d01d293a8dfc3eb6827fa Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 8 17:26:23 2010 -0400
A bunch of fixes to Admin/User mgmt. - Fixes to Administration View setup/left nav/rendering -- I believe this also fixes the issues with the "sticking" Admin top menu and default content. - Users list/new/delete should all be working - removed password/verify from list view - removed pop-up window for create in favor of straight master-detail approach. This should be more consistent across the app, makes better use of real-estate, and avoids an issue/possible bug with smartgwt callbacks.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index e0625a5..6856a55 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -257,7 +257,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { Canvas canvas;
if (breadcrumbName.equals("Administration")) { - canvas = new AdministrationView("Administration"); + canvas = new AdministrationView("Admin"); } else if (breadcrumbName.equals("Demo")) { canvas = new DemoCanvas(); } else if (breadcrumbName.equals("Inventory")) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java index 709d1cd..7c69fa5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java @@ -84,14 +84,15 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable treeGrids.put("Configuration", buildSystemConfigurationSection()); treeGrids.put("Cluster", buildManagementClusterSection()); treeGrids.put("Reports", buildReportsSection()); - treeGrids.put("Security", buildSecuritySection());
for (final String name : treeGrids.keySet()) { TreeGrid grid = treeGrids.get(name);
grid.addSelectionChangedHandler(new SelectionChangedHandler() { public void onSelectionChanged(SelectionEvent selectionEvent) { - CoreGUI.goTo("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); + if (selectionEvent.getState()) { + CoreGUI.goTo("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name")); + } } });
@@ -199,8 +200,11 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
public void setContent(Canvas newContent) {
- if (contentCanvas.getChildren().length > 0) - contentCanvas.getChildren()[0].destroy(); + if (contentCanvas.getChildren().length > 0) { + for (Canvas child : contentCanvas.getChildren()) { + child.destroy(); + } + }
contentCanvas.addChild(newContent); contentCanvas.markForRedraw(); @@ -272,7 +276,14 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable } }
- setContent(content); + // ignore clicks on subsection folder nodes + if (null != content) { + setContent(content); + + if (content instanceof BookmarkableView) { + ((BookmarkableView) content).renderView(viewPath.next().next()); + } + }
}
@@ -286,17 +297,12 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable } else { renderContentView(viewPath); } - } - - // When looking at a detail view, always fire the event down - if (!viewPath.isEnd()) { - - if (currentContent instanceof BookmarkableView) { - ((BookmarkableView) currentContent).renderView(viewPath.next().next()); + } else { + if (this.currentContent instanceof BookmarkableView) { + ((BookmarkableView) this.currentContent).renderView(viewPath.next().next()); }
} - }
private static String addQueryStringParam(String url, String param) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java index 1a36bc7..bd13da7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java @@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.admin.users; import java.util.HashSet; import java.util.Set;
+import com.google.gwt.user.client.History; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSCallback; import com.smartgwt.client.data.DSRequest; @@ -32,7 +33,6 @@ import com.smartgwt.client.types.TitleOrientation; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Label; -import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.CanvasItem; import com.smartgwt.client.widgets.form.fields.SectionItem; @@ -49,11 +49,9 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; -import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.message.Message; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -67,7 +65,6 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { // private SubjectRolesEditorItem subjectRolesEditorItem ;
private VLayout editCanvas; - private HeaderLabel editLabel; private DynamicForm form;
CanvasItem roleSelectionItem; @@ -76,7 +73,6 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
private Subject subject;
- private Window editorWindow; private SubjectRoleSelector roleSelector;
public UserEditView(String locatorId) { @@ -104,30 +100,12 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
SectionItem userEditSection = new SectionItem("userEditSection", "Edit User");
- // TextItem firstName = new TextItem("firstName", "First Name"); - // - // TextItem lastName = new TextItem("lastName", "Last Name"); - // - // TextItem email = new TextItem("email", "Email Address"); - // - // - // BooleanItem enabled = new BooleanItem(); - // enabled.setName("enabled"); - // enabled.setTitle("Enabled"); - // - // TextItem username = new TextItem("username", "Username"); - // - // TextItem phone = new TextItem("phone", "Phone"); - - // form.setField//s(userEditSection); - form.setUseAllDataSourceFields(true); form.setDataSource(dataSource);
this.roleSelectionItem = new CanvasItem("selectRoles", "Select Roles"); this.roleSelectionItem.setTitleOrientation(TitleOrientation.TOP); this.roleSelectionItem.setColSpan(2); - // roleSelectionItem.setCanvas(new SubjectRoleSelector(null));
TextItem departmentItem = new TextItem("department"); departmentItem.setRequired(false); @@ -137,10 +115,6 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { if (form.validate()) { save(); - if (editorWindow != null) { - editorWindow.destroy(); - CoreGUI.refresh(); - } } } }); @@ -155,15 +129,11 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { IButton cancelButton = new LocatableIButton(this.extendLocatorId("Cancel"), "Cancel"); cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { - if (editorWindow != null) { - editorWindow.destroy(); - } else { - form.reset(); - } + History.back(); } });
- HLayout buttonLayout = new LocatableHLayout(this.extendLocatorId("Buttons"), 10); + HLayout buttonLayout = new HLayout(10); buttonLayout.setAlign(Alignment.CENTER); buttonLayout.addMember(saveButton); buttonLayout.addMember(resetButton); @@ -180,8 +150,10 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
}
- private void save() { + public void save() { final HashSet<Integer> roles = roleSelector.getSelection(); + // The form.saveData() call triggers UsersDataSource.executeAdd() to create the new Subject. On + // successful create we need to perform the role assignment, so set this callback on completion. form.saveData(new DSCallback() { public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
@@ -197,11 +169,13 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Failed to set subject role assignments.", caught); + History.back(); }
public void onSuccess(Void result) { CoreGUI.getMessageCenter().notify( new Message("Succesfully saved new user roles.", Message.Severity.Info)); + History.back(); } });
@@ -210,9 +184,6 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { }
public void editRecord(Record record) { - - // form.getDataSource().getField("username").setCanEdit(true ); - roleSelector = new SubjectRoleSelector(this.extendLocatorId("Roles"), (Set<Role>) record .getAttributeAsObject("roles")); roleSelectionItem.setCanvas(roleSelector); @@ -239,50 +210,48 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { subject = new Subject(); ListGridRecord r = dataSource.copyValues(subject); editRecord(r); - // form.getDataSource().getField("username").setCanEdit(false); - form.setSaveOperationType(DSOperationType.ADD); - - editorWindow = new Window(); - editorWindow.setTitle("Create User"); - editorWindow.setWidth(800); - editorWindow.setHeight(800); - editorWindow.setIsModal(true); - editorWindow.setShowModalMask(true); - editorWindow.setCanDragResize(true); - editorWindow.centerInPage(); - editorWindow.addItem(this); - editorWindow.show();
+ // This tells form.saveData() to call UsersDataSource.executeAdd() on the new Subject's ListGridRecord + form.setSaveOperationType(DSOperationType.ADD); }
public static void editNew(String locatorId) { UserEditView editView = new UserEditView(locatorId); editView.editNewInternal(); - }
private void editSubject(int subjectId, final ViewId current) {
- SubjectCriteria criteria = new SubjectCriteria(); - criteria.fetchRoles(true); - criteria.fetchConfiguration(true); + final int id = Integer.valueOf(current.getBreadcrumbs().get(0).getName());
- GWTServiceLookup.getSubjectService().findSubjectsByCriteria(criteria, new AsyncCallback<PageList<Subject>>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load subject for editing", caught); - } + if (id > 0) { + SubjectCriteria criteria = new SubjectCriteria(); + criteria.addFilterId(id); + criteria.fetchRoles(true); + criteria.fetchConfiguration(true);
- @Override - public void onSuccess(PageList<Subject> result) { - Subject subject = result.get(0); - Record record = new UsersDataSource().copyValues(subject); - editRecord(record); + GWTServiceLookup.getSubjectService().findSubjectsByCriteria(criteria, + new AsyncCallback<PageList<Subject>>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load subject for editing", caught); + }
- current.getBreadcrumbs().get(0).setDisplayName("Editing: " + subject.getName()); - CoreGUI.refreshBreadCrumbTrail(); - } - }); + @Override + public void onSuccess(PageList<Subject> result) { + Subject subject = result.get(0); + Record record = new UsersDataSource().copyValues(subject); + editRecord(record); + + current.getBreadcrumbs().get(0).setDisplayName("Editing: " + subject.getName()); + CoreGUI.refreshBreadCrumbTrail(); + } + }); + } else { + editNewInternal(); + current.getBreadcrumbs().get(0).setDisplayName("New User"); + CoreGUI.refreshBreadCrumbTrail(); + } }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java index 578d2b6..809edec 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java @@ -18,26 +18,15 @@ */ package org.rhq.enterprise.gui.coregui.client.admin.users;
-import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.authz.Role; -import org.rhq.core.domain.criteria.SubjectCriteria; -import org.rhq.core.domain.resource.group.ResourceGroup; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import java.util.HashMap; +import java.util.Map; +import java.util.Set;
-import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSourceField; -import com.smartgwt.client.data.FieldValueExtractor; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; @@ -48,9 +37,15 @@ import com.smartgwt.client.widgets.form.validator.LengthRangeValidator; import com.smartgwt.client.widgets.form.validator.MatchesFieldValidator; import com.smartgwt.client.widgets.grid.ListGridRecord;
-import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.authz.Role; +import org.rhq.core.domain.criteria.SubjectCriteria; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync; +import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; +import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/** * @author Greg Hinkle @@ -61,7 +56,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
private SubjectGWTServiceAsync subjectService = GWTServiceLookup.getSubjectService();
- public static UsersDataSource getInstance() { if (INSTANCE == null) { INSTANCE = new UsersDataSource(); @@ -69,9 +63,8 @@ public class UsersDataSource extends RPCDataSource<Subject> { return INSTANCE; }
+ public UsersDataSource() {
- public UsersDataSource() { - DataSourceField idDataField = new DataSourceIntegerField("id", "ID"); idDataField.setPrimaryKey(true); idDataField.setCanEdit(false); @@ -90,7 +83,6 @@ public class UsersDataSource extends RPCDataSource<Subject> { passwordValdidator.setErrorMessage("Password must be at least six characters"); password.setValidators(passwordValdidator);
- DataSourceTextField passwordVerify = new DataSourceTextField("passwordVerify", "Verify", 100, false); passwordVerify.setType(FieldType.PASSWORD);
@@ -99,10 +91,9 @@ public class UsersDataSource extends RPCDataSource<Subject> { passwordsEqualValidator.setErrorMessage("Passwords do not match"); passwordVerify.setValidators(passwordsEqualValidator);
- DataSourceTextField emailAddress = new DataSourceTextField("emailAddress", "Email Address", 100, true);
- DataSourceTextField phone = new DataSourceTextField("phoneNumber", "Phone", 15, false); + DataSourceTextField phone = new DataSourceTextField("phoneNumber", "Phone", 15, false);
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
@@ -111,11 +102,10 @@ public class UsersDataSource extends RPCDataSource<Subject> { roles.setName("roles"); roles.setMultiple(true);
- - setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress, department); + setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress, + department); }
- public void executeFetch(final DSRequest request, final DSResponse response) { final long start = System.currentTimeMillis();
@@ -141,13 +131,12 @@ public class UsersDataSource extends RPCDataSource<Subject> { }
response.setData(records); - response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set + response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set processResponse(request.getRequestId(), response); } }); }
- @Override protected void executeAdd(final DSRequest request, final DSResponse response) { JavaScriptObject data = request.getData(); @@ -160,7 +149,7 @@ public class UsersDataSource extends RPCDataSource<Subject> { Map<String, String> errors = new HashMap<String, String>(); errors.put("name", "A user with this name already exists."); response.setErrors(errors); -// CoreGUI.getErrorHandler().handleError("Failed to create role",caught); + // CoreGUI.getErrorHandler().handleError("Failed to create role",caught); response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR); processResponse(request.getRequestId(), response); } @@ -169,12 +158,14 @@ public class UsersDataSource extends RPCDataSource<Subject> { String password = rec.getAttribute("password"); subjectService.createPrincipal(newSubject.getName(), password, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Subject created, but failed to create principal",caught); + CoreGUI.getErrorHandler() + .handleError("Subject created, but failed to create principal", caught); }
public void onSuccess(Void nothing) { - CoreGUI.getMessageCenter().notify(new Message("Created User [" + newSubject.getName() + "]", Message.Severity.Info)); - response.setData(new Record[]{copyValues(result)}); + CoreGUI.getMessageCenter().notify( + new Message("Created User [" + newSubject.getName() + "]", Message.Severity.Info)); + response.setData(new Record[] { copyValues(result) }); processResponse(request.getRequestId(), response); } }); @@ -203,16 +194,18 @@ public class UsersDataSource extends RPCDataSource<Subject> { }
public void onSuccess(Void nothing) { - CoreGUI.getMessageCenter().notify(new Message("User updated and password changed", Message.Severity.Info)); - response.setData(new Record[]{copyValues(result)}); + CoreGUI.getMessageCenter().notify( + new Message("User updated and password changed", Message.Severity.Info)); + response.setData(new Record[] { copyValues(result) }); processResponse(request.getRequestId(), response);
} }); } else { System.out.println("Subject Updated"); - CoreGUI.getMessageCenter().notify(new Message("User [" + result.getName() + "] updated", Message.Severity.Info)); - response.setData(new Record[]{copyValues(result)}); + CoreGUI.getMessageCenter().notify( + new Message("User [" + result.getName() + "] updated", Message.Severity.Info)); + response.setData(new Record[] { copyValues(result) }); processResponse(request.getRequestId(), response); } } @@ -225,21 +218,21 @@ public class UsersDataSource extends RPCDataSource<Subject> { final ListGridRecord rec = new ListGridRecord(data); final Subject subjectToDelete = copyValues(rec);
- subjectService.deleteSubjects(new int[]{subjectToDelete.getId()}, new AsyncCallback<Void>() { + subjectService.deleteSubjects(new int[] { subjectToDelete.getId() }, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Failed to delete role", caught); }
public void onSuccess(Void result) { - CoreGUI.getMessageCenter().notify(new Message("User [" + subjectToDelete.getName() + "] removed", Message.Severity.Info)); - response.setData(new Record[]{rec}); + CoreGUI.getMessageCenter().notify( + new Message("User [" + subjectToDelete.getName() + "] removed", Message.Severity.Info)); + response.setData(new Record[] { rec }); processResponse(request.getRequestId(), response); } });
}
- public Subject copyValues(ListGridRecord from) { Subject to = new Subject(); to.setId(from.getAttributeAsInt("id")); @@ -272,7 +265,6 @@ public class UsersDataSource extends RPCDataSource<Subject> { return to; }
- private ListGridRecord getEditedRecord(DSRequest request) { // Retrieving values before edit JavaScriptObject oldValues = request.getAttributeAsJavaScriptObject("oldValues"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java index aa0cf64..72e2aa7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java @@ -19,6 +19,7 @@ package org.rhq.enterprise.gui.coregui.client.admin.users;
import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.components.table.Table; @@ -41,31 +42,28 @@ public class UsersView extends TableSection { @Override protected void configureTable() {
- getListGrid().getField("id").setWidth(55); - getListGrid().getField("name").setWidth(100); + final ListGrid grid = getListGrid(); + grid.getField("id").setWidth(20); + grid.getField("name").setWidth(100); + grid.hideField("password"); + grid.hideField("passwordVerify");
addTableAction(extendLocatorId("Delete"), "Delete", Table.SelectionEnablement.ANY, "Are you sure you want to delete # users?", new TableAction() { public void executeAction(ListGridRecord[] selection) { - getListGrid().removeSelectedData(); + grid.removeSelectedData(); } });
addTableAction(extendLocatorId("New"), "New", new TableAction() { public void executeAction(ListGridRecord[] selection) { - createUser(); + newDetails(); } }); }
- public void createUser() { - UserEditView editView = new UserEditView(extendLocatorId("Edit")); - editView.editNewInternal(); - } - public Canvas getDetailsView(int id) { final UserEditView userEditor = new UserEditView(extendLocatorId("Detail")); - return userEditor; } }
commit fa6ab36ec6ff7be045d84e99e72860c3a97d40f3 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 8 17:19:16 2010 -0400
Add newDetails() to TableSection. This complements showDetails(id) and should be called instead of showDetails(0) when wanting an empty form for creating a new entity.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java index 126c672..7cf7226 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java @@ -63,7 +63,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override protected void newButtonPressed(ListGridRecord[] selection) { - showDetails(0); + newDetails(); }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java index 01a19f3..44746c2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java @@ -146,17 +146,35 @@ public abstract class TableSection extends Table implements BookmarkableView { }
/** - * Shows the details for an item has the given ID. Note that an empty - * details view will be shown if the id passed in is 0. + * Shows empty details for a new item being created. + * This method is usually called when a user clicks a 'New' button. + * + * @see #showDetails(ListGridRecord) + */ + public void newDetails() { + History.newItem(basePath + "/0"); + } + + /** + * Shows the details for an item has the given ID. * This method is usually called when a user goes to the details - * page via a bookmark or direct link. + * page via a bookmark, double-cick on a list view row, or direct link. * - * @param id the id of the row whose details are to be shown; pass in 0 to show empty details + * @param id the id of the row whose details are to be shown; Should be a valid id, > 0. * * @see #showDetails(ListGridRecord) + * + * @throws IllegalArgumentException if id <= 0. */ public void showDetails(int id) { - History.newItem(basePath + "/" + id); + if (id > 0) { + History.newItem(basePath + "/" + id); + } else { + String msg = "Can not show detail for [" + this.getClass() + "]. Illegal 'id': " + id + + " Please report this bug"; + CoreGUI.getErrorHandler().handleError(msg); + throw new IllegalArgumentException(msg); + } }
/** @@ -232,9 +250,8 @@ public abstract class TableSection extends Table implements BookmarkableView { detailsHolder.animateHide(AnimationEffect.FADE, new AnimationCallback() { @Override public void execute(boolean b) { - // TODO: Implement this method. for (Canvas child : detailsHolder.getMembers()) { - detailsHolder.removeMember(child); + child.destroy(); }
contents.animateShow(AnimationEffect.FADE);
commit bfc20948d695463b215f247339cf0c9568a151b9 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 8 17:16:33 2010 -0400
removed 'Preferences' from top menu. Currently this may not be needed at all, but even if it is it wil likely be integrated into either user mgmt or possibly even more fine-grained use, like specific to a group config update.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java index 8e51dd9..dc5503f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java @@ -89,7 +89,6 @@ public class MenuBarView extends VLayout { // loggedInAs.setValign(VerticalAlignment.CENTER); // helpLayout.addMember(loggedInAs); topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Help", "Help"))); - topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Preferences", "Preferences"))); topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Log Out", "LogOut"))); // helpLayout.setLayoutAlign(VerticalAlignment.CENTER); // topStrip.addMember(helpLayout);
commit 818b8aa88257a97541c8f97f1a167aa7f99c319a Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Sep 8 17:15:00 2010 -0400
Selenium Work - It seems that in certain scenarios a DSCallback can't locate an element with a '-' in the id attribute. The dash seems to be used as a delimiter, this may be a bug in smartgwt. Anyway, changing all use of '-' in locatorIds to '_'.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java index ef0c74d..a8472b8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java @@ -455,7 +455,7 @@ public class ConfigurationEditor extends LocatableVLayout { .getNonGroupedProperties() : definition.getPropertiesInGroup(group.getName()))); Collections.sort(definitions, new PropertyDefinitionComparator());
- DynamicForm form = buildPropertiesForm(locatorId + "-Props", definitions, configuration); + DynamicForm form = buildPropertiesForm(locatorId + "_Props", definitions, configuration);
section.addItem(form); return section; @@ -493,7 +493,7 @@ public class ConfigurationEditor extends LocatableVLayout { propertyMap.put(property); } } - addItems(locatorId + "-" + propertyDefinition.getName(), fields, propertyDefinition, property, odd); + addItems(locatorId + "_" + propertyDefinition.getName(), fields, propertyDefinition, property, odd); odd = !odd; }
@@ -635,7 +635,7 @@ public class ConfigurationEditor extends LocatableVLayout { editField.addRecordClickHandler(new RecordClickHandler() { public void onRecordClick(RecordClickEvent recordClickEvent) { System.out.println("You want to edit: " + recordClickEvent.getRecord()); - displayMapEditor(locatorId + "-MapEdit", summaryTable, recordClickEvent.getRecord(), + displayMapEditor(locatorId + "_MapEdit", summaryTable, recordClickEvent.getRecord(), propertyDefinition, propertyList, (PropertyMap) recordClickEvent.getRecord().getAttributeAsObject( "_RHQ_PROPERTY")); } @@ -684,7 +684,7 @@ public class ConfigurationEditor extends LocatableVLayout { addRowButton.setIcon(Window.getImgURL("[SKIN]/actions/add.png")); addRowButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(ClickEvent clickEvent) { - displayMapEditor(locatorId + "-MapEdit", summaryTable, null, propertyDefinition, propertyList, null); + displayMapEditor(locatorId + "_MapEdit", summaryTable, null, propertyDefinition, propertyList, null); } });
@@ -917,7 +917,7 @@ public class ConfigurationEditor extends LocatableVLayout { LocatableVLayout layout = new LocatableVLayout(locatorId); layout.setHeight100();
- DynamicForm childForm = buildPropertiesForm(locatorId + "-Child", definitions, finalMap); + DynamicForm childForm = buildPropertiesForm(locatorId + "_Child", definitions, finalMap); childForm.setHeight100(); layout.addMember(childForm);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java index 6c0481d..bd9d966 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java @@ -5,7 +5,7 @@ public interface Locatable { /** * Returns the locatorId. This can be useful for constructing more granular locatorIds. For example, if * the widget contains sub-widgets. Note, this is the raw locatorId for the widget, to get the fully - * formed ID, typically ofthe form "simpleClassname-locatorId" Call {@link getID()}. + * formed ID, typically ofthe form "simpleClassname_locatorId" Call {@link getID()}. * * @return the locatorId */ @@ -15,7 +15,7 @@ public interface Locatable { * Extends this widget's original locatorId with an extension. This can be useful for constructing more * granular locatorIds. For example, if the widget contains sub-widgets. * <pre> - * ID Format: "getLocatorId()-extension" + * ID Format: "getLocatorId()_extension" * </pre> * * @param extension not null or empty. diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java index a6dd2ca..5219934 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java @@ -11,7 +11,7 @@ public class LocatableButton extends Button {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java index b923b1c..39e4772 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java @@ -13,7 +13,7 @@ public class LocatableDialog extends Dialog implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null. */ @@ -28,6 +28,6 @@ public class LocatableDialog extends Dialog implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java index a29789c..1fb565c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java @@ -13,7 +13,7 @@ public class LocatableDynamicForm extends DynamicForm implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -28,7 +28,7 @@ public class LocatableDynamicForm extends DynamicForm implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java index 25f8216..5b3e09e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java @@ -13,7 +13,7 @@ public class LocatableHLayout extends HLayout implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -24,7 +24,7 @@ public class LocatableHLayout extends HLayout implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. * @param membersMargin @@ -44,7 +44,7 @@ public class LocatableHLayout extends HLayout implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java index 653190c..a8e758e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java @@ -13,7 +13,7 @@ public class LocatableHTMLPane extends HTMLPane implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -28,7 +28,7 @@ public class LocatableHTMLPane extends HTMLPane implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java index 83e2443..b30f134 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java @@ -14,7 +14,7 @@ public class LocatableHeaderControl extends HeaderControl implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. * @param icon @@ -26,7 +26,7 @@ public class LocatableHeaderControl extends HeaderControl implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. * @param icon @@ -47,7 +47,7 @@ public class LocatableHeaderControl extends HeaderControl implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java index 72ce93b..f265697 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java @@ -11,7 +11,7 @@ public class LocatableIButton extends IButton {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java index e3b2eae..7734c3b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java @@ -14,7 +14,7 @@ public class LocatableIMenuButton extends IMenuButton implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -25,7 +25,7 @@ public class LocatableIMenuButton extends IMenuButton implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -44,6 +44,6 @@ public class LocatableIMenuButton extends IMenuButton implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java index 8317ff5..c0dc681 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java @@ -11,7 +11,7 @@ public class LocatableImg extends Img {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null. * @param img not null or empty. diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java index bd7ab1f..3b06238 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java @@ -13,7 +13,7 @@ public class LocatableLabel extends Label implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -24,7 +24,7 @@ public class LocatableLabel extends Label implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -43,7 +43,7 @@ public class LocatableLabel extends Label implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java index e14a421..7a2e99b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java @@ -13,7 +13,7 @@ public class LocatableLayout extends Layout implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -28,7 +28,7 @@ public class LocatableLayout extends Layout implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java index 458a97a..87ed4b7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java @@ -13,7 +13,7 @@ public class LocatableListGrid extends ListGrid implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -28,6 +28,6 @@ public class LocatableListGrid extends ListGrid implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java index 424f64d..827ba2a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java @@ -13,7 +13,7 @@ public class LocatableMenu extends Menu implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -32,7 +32,7 @@ public class LocatableMenu extends Menu implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java index 33e2b9e..62fb4ac 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java @@ -13,7 +13,7 @@ public class LocatableSectionStack extends SectionStack implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -28,7 +28,7 @@ public class LocatableSectionStack extends SectionStack implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java index 6b2b379..ba1435f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java @@ -11,7 +11,7 @@ public class LocatableStretchImgButton extends StretchImgButton {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null. * @param img not null or empty. diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java index 9932a65..197a1be 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java @@ -31,7 +31,7 @@ public class LocatableTab extends Tab implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -64,7 +64,7 @@ public class LocatableTab extends Tab implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java index e290758..4ba995c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java @@ -31,7 +31,7 @@ public class LocatableTabSet extends TabSet {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -44,7 +44,7 @@ public class LocatableTabSet extends TabSet { /** * Returns the locatorId. This can be useful for constructing more granular locatorIds. For example, if * the widget contains sub-widgets. Note, this is the raw locatorId for the widget, to get the fully - * formed ID, typically ofthe form "simpleClassname-locatorId" Call {@link getID()}. + * formed ID, typically ofthe form "simpleClassname_locatorId" Call {@link getID()}. * * @return the locatorId */ @@ -56,7 +56,7 @@ public class LocatableTabSet extends TabSet { * Extends this widget's original locatorId with an extension. This can be useful for constructing more * granular locatorIds. For example, if the widget contains sub-widgets. * <pre> - * ID Format: "getLocatorId()-extension" + * ID Format: "getLocatorId()_extension" * </pre> * * @param extension not null or empty. @@ -64,7 +64,7 @@ public class LocatableTabSet extends TabSet { * @return the new, extended locatorId */ public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java index b93bfe8..c6308a3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java @@ -13,7 +13,7 @@ public class LocatableTileLayout extends TileLayout implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -28,7 +28,7 @@ public class LocatableTileLayout extends TileLayout implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java index 7f1dfb7..fa24d45 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java @@ -13,7 +13,7 @@ public class LocatableToolStrip extends ToolStrip implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -28,7 +28,7 @@ public class LocatableToolStrip extends ToolStrip implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java index 58d11f7..e255096 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java @@ -21,7 +21,7 @@ public class LocatableTransferImgButton extends TransferImgButton {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null. * @param img not null or empty. diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java index 39e4afa..c4d6a87 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java @@ -13,7 +13,7 @@ public class LocatableTreeGrid extends TreeGrid implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null. */ @@ -28,6 +28,6 @@ public class LocatableTreeGrid extends TreeGrid implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java index e396236..0a9b00e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java @@ -13,7 +13,7 @@ public class LocatableVLayout extends VLayout implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -24,7 +24,7 @@ public class LocatableVLayout extends VLayout implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. * @param membersMargin @@ -44,7 +44,7 @@ public class LocatableVLayout extends VLayout implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
public void destroyMembers() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java index 66792a2..90324df 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java @@ -14,7 +14,7 @@ public class LocatableWidgetCanvas extends WidgetCanvas implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -33,7 +33,7 @@ public class LocatableWidgetCanvas extends WidgetCanvas implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java index 87c6b22..56f34bd 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java @@ -13,7 +13,7 @@ public class LocatableWindow extends Window implements Locatable {
/** * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @param locatorId not null or empty. */ @@ -32,7 +32,7 @@ public class LocatableWindow extends Window implements Locatable { }
public String extendLocatorId(String extension) { - return this.locatorId + "-" + extension; + return this.locatorId + "_" + extension; }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java index 43678f0..21ef740 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java @@ -17,7 +17,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; */ public class SeleniumUtility {
- private static final boolean USE_DEFAULT_IDS = true; + private static final boolean USE_DEFAULT_IDS = false;
/** A default id that is not ecommended as it will clash with any other element set to the default */ public static final String DEFAULT_ID = "DefaultID"; @@ -25,7 +25,7 @@ public class SeleniumUtility { /** * A utility for assigning an ID to a smartgwt widget. Any current ID will be overwritten. The algorithm is: * <pre> - * ID Format: "simpleClassname-locatorId" + * ID Format: "simpleClassname_locatorId" * </pre> * @return the updated widget */ @@ -34,7 +34,7 @@ public class SeleniumUtility { return widget; }
- String unsafeId = getSimpleClassName(widget) + "-" + locatorId; + String unsafeId = getSimpleClassName(widget) + "_" + locatorId; String safeId = SeleniumUtility.getSafeId(unsafeId, DEFAULT_ID); Canvas canvasWithId = Canvas.getById(safeId); if (null != canvasWithId) { @@ -127,6 +127,7 @@ public class SeleniumUtility { * <pre> * - removes spaces * - removes dots + * - converts '-' to '_' * </pre> * @param unsafeId The desired Id but with potential problems * @param defaultId @@ -137,7 +138,7 @@ public class SeleniumUtility { return defaultId; }
- String safeId = unsafeId.replace(" ", "").replace(".", ""); + String safeId = unsafeId.replace(" ", "").replace(".", "").replace("-", "_"); return safeId; }
commit e292517b3189ed60c6b38cdab023d6fec7dd9098 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 8 17:01:50 2010 -0400
initial start of the conditions tab for alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java index 201360b..f19d967 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java @@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.LinkedHashMap;
+import com.smartgwt.client.widgets.form.fields.CanvasItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem;
@@ -128,7 +129,14 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen conditionExpression.setDefaultValue(BooleanExpression.ALL.name()); conditionExpressionStatic = new StaticTextItem("conditionExpressionStatic", "Fire alert when");
- setFields(conditionExpression, conditionExpressionStatic); + ConditionsEditor conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), this); + + CanvasItem canvasItem = new CanvasItem("conditionsEditorCanvasItem"); + canvasItem.setCanvas(conditionsEditor); + canvasItem.setShowTitle(false); + canvasItem.setColSpan(2); + + setFields(conditionExpression, conditionExpressionStatic, canvasItem);
formBuilt = true; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java new file mode 100644 index 0000000..ddc3545 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -0,0 +1,109 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.coregui.client.alert.definitions; + +import com.smartgwt.client.data.DSRequest; +import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.data.fields.DataSourceTextField; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.core.domain.alert.AlertCondition; +import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility; +import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; +import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement; +import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/** + * @author John Mazzitelli + */ +public class ConditionsEditor extends LocatableVLayout { + + private final ConditionsAlertDefinitionForm form; + private Table table; + + public ConditionsEditor(String locatorId, ConditionsAlertDefinitionForm form) { + super(locatorId); + this.form = form; + } + + @Override + protected void onInit() { + super.onInit(); + + table = new Table("conditionsTable"); + table.setShowHeader(false); + table.setDataSource(new ConditionDataSource()); + + table.addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() { + @Override + public void executeAction(ListGridRecord[] selection) { + // TODO Auto-generated method stub + } + }); + table.addTableAction(this.extendLocatorId("delete"), "Delete", SelectionEnablement.ANY, "Are you sure?", + new TableAction() { + @Override + public void executeAction(ListGridRecord[] selection) { + // TODO Auto-generated method stub + } + }); + + addMember(table); + } + + public void setEditable(boolean editable) { + table.setTableActionDisableOverride(!editable); + } + + private class ConditionDataSource extends RPCDataSource<AlertCondition> { + private static final String FIELD_OBJECT = "obj"; + private static final String FIELD_CONDITION = "condition"; + + public ConditionDataSource() { + DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION, "Condition"); + addField(conditionField); + } + + @Override + public AlertCondition copyValues(ListGridRecord from) { + return (AlertCondition) from.getAttributeAsObject(FIELD_OBJECT); + } + + @Override + public ListGridRecord copyValues(AlertCondition from) { + ListGridRecord record = new ListGridRecord(); + record.setAttribute(FIELD_CONDITION, AlertFormatUtility.formatAlertConditionForDisplay(from)); + record.setAttribute(FIELD_OBJECT, from); + return record; + } + + @Override + protected void executeFetch(DSRequest request, DSResponse response) { + response.setData(buildRecords(ConditionsEditor.this.form.getAlertDefinition().getConditions())); + processResponse(request.getRequestId(), response); + } + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java index ac7b789..dc04a1e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java @@ -97,6 +97,8 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.fetchGroupAlertDefinition(true); + criteria.fetchConditions(true); + criteria.fetchAlertNotifications(true);
Criteria requestCriteria = request.getCriteria(); if (requestCriteria != null) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index 90b448f..d12a864 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -120,6 +120,7 @@ public class Table extends LocatableHLayout { ;
private List<TableActionInfo> tableActions = new ArrayList<TableActionInfo>(); + private boolean tableActionDisableOverride = false; private List<Canvas> extraWidgets = new ArrayList<Canvas>();
public Table(String locatorId) { @@ -476,29 +477,54 @@ public class Table extends LocatableHLayout { this.headerIcons.add(headerIcon); }
+ /** + * By default, all table actions have buttons that are enabled or + * disabled based on if and how many rows are selected. There are + * times when you don't want the user to be able to press table action + * buttons regardless of which rows are selected. This method let's + * you set this override-disable flag. + * + * @param disabled if true, all table action buttons will be disabled + * if false, table action buttons will be enabled based on their predefined + * selection enablement rule. + */ + public void setTableActionDisableOverride(boolean disabled) { + this.tableActionDisableOverride = disabled; + refreshTableInfo(); + } + + public boolean getTableActionDisableOverride() { + return this.tableActionDisableOverride; + } + protected void refreshTableInfo() { if (showFooter) { int count = this.listGrid.getSelection().length; for (TableActionInfo tableAction : tableActions) { boolean enabled; - switch (tableAction.enablement) { - case ALWAYS: - enabled = true; - break; - case NEVER: + if (!this.tableActionDisableOverride) { + switch (tableAction.enablement) { + case ALWAYS: + enabled = true; + break; + case NEVER: + enabled = false; + break; + case ANY: + enabled = (count >= 1); + break; + case SINGLE: + enabled = (count == 1); + break; + case MULTIPLE: + enabled = (count > 1); + break; + default: + throw new IllegalStateException("Unhandled SelectionEnablement: " + + tableAction.enablement.name()); + } + } else { enabled = false; - break; - case ANY: - enabled = (count >= 1); - break; - case SINGLE: - enabled = (count == 1); - break; - case MULTIPLE: - enabled = (count > 1); - break; - default: - throw new IllegalStateException("Unhandled SelectionEnablement: " + tableAction.enablement.name()); } tableAction.actionButton.setDisabled(!enabled); }
commit 116b730cb2cd65086374eccb0d74904abef053cb Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 8 16:59:25 2010 -0400
fix NPE - make sure targetUnits is not null before checking to see if its family is RELATIVE
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java index f78b62c..f084ec0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java @@ -1,47 +1,46 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - package org.rhq.core.domain.measurement; - - import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; - import org.rhq.core.domain.measurement.util.MeasurementConversionException; - - import com.google.gwt.i18n.client.NumberFormat; - - import java.util.HashSet; - import java.util.Set; - - public class MeasurementConverterClient { +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.core.domain.measurement; + +import java.util.HashSet; +import java.util.Set; + +import com.google.gwt.i18n.client.NumberFormat; + +import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; +import org.rhq.core.domain.measurement.util.MeasurementConversionException; + +public class MeasurementConverterClient { private static final int MAX_PRECISION_DIGITS = 4; private static final String NULL_OR_NAN_FORMATTED_VALUE = "--no data available--";
- private static NumberFormat getDefaultNumberFormat() { NumberFormat nf = NumberFormat.getFormat("0.0");
return nf; }
- public static Double scale(MeasurementNumericValueAndUnits origin, MeasurementUnits targetUnits) + public static Double scale(MeasurementNumericValueAndUnits origin, MeasurementUnits targetUnits) throws MeasurementConversionException { MeasurementUnits originUnits = origin.getUnits(); Double originValue = origin.getValue(); @@ -201,7 +200,7 @@ }
public static String format(Double value, MeasurementUnits targetUnits, boolean bestFit, - Integer minimumFractionDigits, Integer maximumFractionDigits) { + Integer minimumFractionDigits, Integer maximumFractionDigits) { if (value == null || Double.isNaN(value)) { return NULL_OR_NAN_FORMATTED_VALUE; } @@ -213,15 +212,13 @@ }
// apply relative scale at presentation time - if (MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) { + if (targetUnits != null && MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) { value = MeasurementUnits.scaleUp(value, targetUnits); }
- NumberFormat numberFormat = - NumberFormat.getFormat( - getFormat( - minimumFractionDigits != null ? minimumFractionDigits : 1, - maximumFractionDigits != null ? maximumFractionDigits : 1)); + NumberFormat numberFormat = NumberFormat.getFormat(getFormat( + minimumFractionDigits != null ? minimumFractionDigits : 1, + maximumFractionDigits != null ? maximumFractionDigits : 1));
String formatted = numberFormat.format(value);
@@ -273,7 +270,7 @@ if (MeasurementUnits.Family.RELATIVE == units.getFamily()) { return new MeasurementNumericValueAndUnits(origin, units); } - + if (MeasurementUnits.Family.TEMPERATURE == units.getFamily()) { return new MeasurementNumericValueAndUnits(origin, units); } @@ -347,14 +344,14 @@ return currentValueAndUnits; }
- public static String getFormat(int minDigits, int maxDigits) { - StringBuilder buf = new StringBuilder("0."); - for (int i = 0; i < minDigits;i++) { - buf.append("0"); - } - for (int i = 0; i < (maxDigits-minDigits);i++) { - buf.append("#"); - } - return buf.toString(); - } + public static String getFormat(int minDigits, int maxDigits) { + StringBuilder buf = new StringBuilder("0."); + for (int i = 0; i < minDigits; i++) { + buf.append("0"); + } + for (int i = 0; i < (maxDigits - minDigits); i++) { + buf.append("#"); + } + return buf.toString(); + } }
commit bcf70dce12b481f4f0876a9d87eb3f7781df9497 Merge: ce3f841... 256cc0e... Author: John Sanda jsanda@redhat.com Date: Wed Sep 8 13:38:17 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 256cc0e5624dcb2c1c656057924590126e37e5ff Author: Simeon Pinder spinder@redhat.com Date: Wed Sep 8 17:27:50 2010 -0400
refresh/config for portlets i)auto discovery ii)recently added.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java index 0356212..ad0895b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java @@ -18,29 +18,58 @@ */ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue;
+import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.BlurbItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/** * @author Greg Hinkle */ -public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements Portlet { +public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements CustomSettingsPortlet {
public static final String KEY = "Discovery Queue"; + private static final String AUTODISCOVERY_PLATFORM_MAX = "auto-discovery-platform-max"; + private String unlimited = "unlimited"; + private String defaultValue = unlimited; + private DashboardPortlet storedPortlet; + private int maximumPlatformsToDisplay = -1;
public AutodiscoveryPortlet(String locatorId) { super(locatorId, true); }
+ /** Implement configure action. + */ + @Override public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - // TODO: Implement this method. + this.storedPortlet = storedPortlet; + if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) != null) { + //retrieve and translate to int + String retrieved = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue(); + if (retrieved.equals(unlimited)) { + maximumPlatformsToDisplay = -1; + } else { + maximumPlatformsToDisplay = Integer.parseInt(retrieved); + } + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue)); + } }
public Canvas getHelpCanvas() { @@ -48,8 +77,73 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements P + "for monitoring and management or to ingnore them from further action."); }
+ /** Build custom for to dispaly the Portlet Configuration settings. + * + */ public DynamicForm getCustomSettingsForm() { - return null; // TODO: Implement this method. + + final DynamicForm form = new DynamicForm(); + form.setLayoutAlign(VerticalAlignment.CENTER); + + //horizontal display component + LocatableHLayout row = new LocatableHLayout("auto-discovery.configuration"); + BlurbItem label = new BlurbItem("discovery-platform-count-label"); + label.setValue("Maximum Platforms to show"); + + //-------------combobox for number of platforms to display on the dashboard + final SelectItem maximumPlatformsComboBox = new SelectItem(AUTODISCOVERY_PLATFORM_MAX); + maximumPlatformsComboBox.setTitle(""); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumPlatformsComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptableDisplayValues = { "1", "2", "5", "10", unlimited }; + maximumPlatformsComboBox.setValueMap(acceptableDisplayValues); + //set width of dropdown display region + maximumPlatformsComboBox.setWidth(100); + maximumPlatformsComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(AUTODISCOVERY_PLATFORM_MAX, selectedItem); + } + }); + + //wrap field item in dynamicform for addition as a field item + DynamicForm item = new DynamicForm(); + item.setFields(label); + + row.addMember(item); + DynamicForm item2 = new DynamicForm(); + item2.setFields(maximumPlatformsComboBox); + row.addMember(item2); + + //default selected value to 'unlimited'(live lists) and check both combobox settings here. + String selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumPlatformsComboBox.setDefaultValue(selectedValue); + + form.addChild(row); + + //submit handler + form.addSubmitValuesHandler(new SubmitValuesHandler() { + @Override + public void onSubmitValues(SubmitValuesEvent event) { + if (form.getValue(AUTODISCOVERY_PLATFORM_MAX) != null) { + storedPortlet.getConfiguration().put( + new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, form.getValue(AUTODISCOVERY_PLATFORM_MAX))); + } + } + }); + + return form; }
public static final class Factory implements PortletViewFactory { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java index 3a551eb..655596b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java @@ -26,32 +26,49 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.tree.TreeGrid;
+import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; +import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-public class RecentlyAddedView extends LocatableVLayout implements Portlet { +public class RecentlyAddedView extends LocatableVLayout implements CustomSettingsPortlet {
public static final String KEY = "Recently Added Portlet";
private boolean simple = true; + private DashboardPortlet storedPortlet; + public static final String unlimited = "unlimited"; + public static final String defaultValue = unlimited; + + private static final String RECENTLY_ADDED_SHOW_MAX = "recently-added-show-amount"; + + private static final String RECENTLY_ADDED_SHOW_HRS = "recently-added-time-range";
public RecentlyAddedView(String locatorId) { super(locatorId); }
+ private TreeGrid treeGrid = null; + + private int maximumRecentlyAddedToDisplay; + private int maximumRecentlyAddedWithinHours; + @Override protected void onInit() { super.onInit(); - TreeGrid treeGrid = new TreeGrid(); + treeGrid = new TreeGrid(); treeGrid.setDataSource(new RecentlyAddedResourceDS()); treeGrid.setAutoFetchData(true); treeGrid.setTitle("Recently Added Resources"); @@ -79,7 +96,28 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet { }
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - + this.storedPortlet = storedPortlet; + if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX) != null) { + //retrieve and translate to int + String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX).getStringValue(); + if (retrieved.equals(unlimited)) { + maximumRecentlyAddedToDisplay = -1; + } else { + maximumRecentlyAddedToDisplay = Integer.parseInt(retrieved); + } + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_MAX, defaultValue)); + } + if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS) != null) { + String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS).getStringValue(); + if (retrieved.equals(unlimited)) { + setMaximumRecentlyAddedWithinHours(-1); + } else { + setMaximumRecentlyAddedWithinHours(Integer.parseInt(retrieved)); + } + } else { + storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue)); + } }
public Canvas getHelpCanvas() { @@ -87,7 +125,76 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet { }
public DynamicForm getCustomSettingsForm() { - return null; + final DynamicForm form = new DynamicForm(); + + //-------------combobox for number of recently added resources to display on the dashboard + final SelectItem maximumRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_MAX); + maximumRecentlyAddedComboBox.setTitle("Show maximum of"); + maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved resources on dashboard.</b></nobr>"); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumRecentlyAddedComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptableDisplayValues = { "5", "10", "15", "20", "30", unlimited }; + maximumRecentlyAddedComboBox.setValueMap(acceptableDisplayValues); + //set width of dropdown display region + maximumRecentlyAddedComboBox.setWidth(100); + + //default selected value to 'unlimited'(live lists) and check both combobox settings here. + String selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_MAX, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumRecentlyAddedComboBox.setDefaultValue(selectedValue); + + //------------- Build second combobox for timeframe for problem resources search. + final SelectItem maximumTimeRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_HRS); + maximumTimeRecentlyAddedComboBox.setTitle("For the last "); + maximumTimeRecentlyAddedComboBox.setHint("<nobr><b> hours </b></nobr>"); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumTimeRecentlyAddedComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptableTimeValues = { "1", "4", "8", "24", "48", unlimited }; + maximumTimeRecentlyAddedComboBox.setValueMap(acceptableTimeValues); + maximumTimeRecentlyAddedComboBox.setWidth(100); + + //set to default + selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumTimeRecentlyAddedComboBox.setDefaultValue(selectedValue); + + //insert fields + form.setFields(maximumRecentlyAddedComboBox, maximumTimeRecentlyAddedComboBox); + + //submit handler + form.addSubmitValuesHandler(new SubmitValuesHandler() { + @Override + public void onSubmitValues(SubmitValuesEvent event) { + if (form.getValue(RECENTLY_ADDED_SHOW_MAX) != null) { + storedPortlet.getConfiguration().put( + new PropertySimple(RECENTLY_ADDED_SHOW_MAX, form.getValue(RECENTLY_ADDED_SHOW_MAX))); + } + if (form.getValue(RECENTLY_ADDED_SHOW_HRS) != null) { + storedPortlet.getConfiguration().put( + new PropertySimple(RECENTLY_ADDED_SHOW_HRS, form.getValue(RECENTLY_ADDED_SHOW_HRS))); + } + } + }); + + return form; }
public static final class Factory implements PortletViewFactory { @@ -97,4 +204,31 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet { return new RecentlyAddedView(locatorId); } } + + /** Custom refresh operation as we cannot directly extend Table because it + * contains a TreeGrid which is not a Table. + */ + @Override + public void redraw() { + super.redraw(); + //now reload the table data + this.treeGrid.invalidateCache(); + this.treeGrid.markForRedraw(); + } + + public int getMaximumRecentlyAddedToDisplay() { + return maximumRecentlyAddedToDisplay; + } + + public void setMaximumRecentlyAddedToDisplay(int maximumRecentlyAddedToDisplay) { + this.maximumRecentlyAddedToDisplay = maximumRecentlyAddedToDisplay; + } + + public int getMaximumRecentlyAddedWithinHours() { + return maximumRecentlyAddedWithinHours; + } + + public void setMaximumRecentlyAddedWithinHours(int maximumRecentlyAddedWithinHours) { + this.maximumRecentlyAddedWithinHours = maximumRecentlyAddedWithinHours; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java index 57472d3..88df56f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java @@ -82,7 +82,6 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort listGrid.setCellHeight(50); //wrap to display disambiguation listGrid.setWrapCells(true); - // System.out.println("@@@@:"+listGrid.getField(ProblemResourcesDataSource.resource)+":W"+listGrid.getField(ProblemResourcesDataSource.resource).getWidth()); listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%"); listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%"); listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java index 54d175f..2d81fe0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java @@ -219,4 +219,15 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { } return selected.toArray(new Integer[selected.size()]); } + + /** Custom refresh operation as we cannot directly extend Table because it + * contains a TreeGrid which is not a Table. + */ + @Override + public void redraw() { + super.redraw(); + //now reload the table data + this.treeGrid.invalidateCache(); + this.treeGrid.markForRedraw(); + } }
commit c6fa4276a970f11ad543bdd83d714c3c2cc8c5bb Author: Simeon Pinder spinder@redhat.com Date: Wed Sep 8 09:23:39 2010 -0400
i)OperationsPortlet config/refresh ii)editable combobox fix.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java index b7eeef9..81accf8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java @@ -21,15 +21,29 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operatio
import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.CheckboxItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; import com.smartgwt.client.widgets.grid.HeaderSpan; +import com.smartgwt.client.widgets.layout.VStack;
+import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; +import org.rhq.core.domain.configuration.definition.PropertySimpleType; import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource; import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -38,12 +52,34 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * * @author Simeon Pinder */ -public class OperationsPortlet extends LocatableVLayout implements Portlet { +public class OperationsPortlet extends LocatableVLayout implements CustomSettingsPortlet {
+ //unique field/form identifiers + public static final String OPERATIONS_RANGE_COMPLETED_ENABLED = "operations-completed-enabled"; + public static final String OPERATIONS_RANGE_SCHEDULED_ENABLED = "operations-scheduled-enabled"; + public static final String OPERATIONS_RANGE_COMPLETED = "operations-range-completed"; + public static final String OPERATIONS_RANGE_SCHEDULED = "operations-range-scheduled"; + //portlet key public static final String KEY = "Operations"; private static final String TITLE = KEY; private static String recentOperations = "Recent Operations"; private static String scheduledOperations = "Scheduled Operations"; + private boolean operationsRangeLastEnabled = false; + private boolean operationsRangeNextEnabled = false; + private int operationsRangeScheduled = -1; + private int operationsRangeCompleted = -1; + //ListGrids for operations + private LocatableListGrid recentOperationsGrid = null; + private LocatableListGrid scheduledOperationsGrid = null; + private DashboardPortlet storedPortlet = null; + public static String unlimited = "unlimited"; + public static String defaultValue = unlimited; + public static boolean defaultEnabled = false; + + //default no-args constructor for serialization. + private OperationsPortlet() { + super("(unitialized)"); + }
public OperationsPortlet(String locatorId) { super(locatorId); @@ -56,13 +92,16 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { //set title for larger container setTitle(TITLE);
- // Add the list table as the top half of the view. - LocatableListGrid recentOperationsGrid = new LocatableListGrid(recentOperations); + this.recentOperationsGrid = new LocatableListGrid(recentOperations); recentOperationsGrid.setDataSource(new RecentOperationsDataSource()); recentOperationsGrid.setAutoFetchData(true); - String[] allRows = new String[] { RecentOperationsDataSource.location, RecentOperationsDataSource.operation, - RecentOperationsDataSource.resource, RecentOperationsDataSource.status, RecentOperationsDataSource.time }; - recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, allRows)); + recentOperationsGrid.setTitle(recentOperations); + recentOperationsGrid.setWidth100(); + //defining header span + String[] completedRows = new String[] { RecentOperationsDataSource.location, + RecentOperationsDataSource.operation, RecentOperationsDataSource.resource, + RecentOperationsDataSource.status, RecentOperationsDataSource.time }; + recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, completedRows)); recentOperationsGrid.setHeaderSpanHeight(new Integer(20)); recentOperationsGrid.setHeaderHeight(40); recentOperationsGrid.setResizeFieldsInRealTime(true); @@ -71,13 +110,15 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { addMember(recentOperationsGrid);
// Add the list table as the top half of the view. - LocatableListGrid scheduledOperationsGrid = new LocatableListGrid(scheduledOperations); + this.scheduledOperationsGrid = new LocatableListGrid(scheduledOperations); scheduledOperationsGrid.setDataSource(new ScheduledOperationsDataSource()); scheduledOperationsGrid.setAutoFetchData(true); - String[] allRows2 = new String[] { ScheduledOperationsDataSource.location, + scheduledOperationsGrid.setTitle(scheduledOperations); + scheduledOperationsGrid.setWidth100(); + String[] scheduledRows = new String[] { ScheduledOperationsDataSource.location, ScheduledOperationsDataSource.operation, ScheduledOperationsDataSource.resource, ScheduledOperationsDataSource.time }; - scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, allRows2)); + scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, scheduledRows)); scheduledOperationsGrid.setHeaderSpanHeight(new Integer(20)); scheduledOperationsGrid.setHeaderHeight(40);
@@ -92,8 +133,50 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
@Override public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - // TODO implement this. - + this.storedPortlet = storedPortlet; + //Operation range property - retrieve existing value + PropertySimple property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED); + if ((property != null) && (property.getStringValue() != null)) { + //retrieve and translate to int + String retrieved = property.getStringValue(); + if (retrieved.equals(unlimited)) { + setOperationsRangeCompleted(-1); + } else { + setOperationsRangeCompleted(Integer.parseInt(retrieved)); + } + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue)); + setOperationsRangeCompleted(-1); + } + property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED); + if ((property != null) && (property.getStringValue() != null)) { + //retrieve and translate to int + String retrieved = property.getStringValue(); + if (retrieved.equals(unlimited)) { + setOperationsRangeScheduled(-1); + } else { + setOperationsRangeScheduled(Integer.parseInt(retrieved)); + } + } else {//create setting + storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue)); + setOperationsRangeScheduled(-1); + } + //Checkbox settings property + property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED); + if ((property != null) && (property.getBooleanValue() != null)) { + setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue()); + } else {//create setting + storedPortlet.getConfiguration() + .put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, defaultEnabled)); + setOperationsRangeScheduleEnabled(defaultEnabled); + } + property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED); + if ((property != null) && (property.getBooleanValue() != null)) { + setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue()); + } else {//create setting + storedPortlet.getConfiguration() + .put(new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, defaultEnabled)); + } }
@Override @@ -101,8 +184,171 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { return new HTMLFlow("This portlet displays both operations that have occurred and are scheduled to occur."); }
+ /** Constructs the dynamic form instance using 1 column and multiple row layouts. + */ public DynamicForm getCustomSettingsForm() { - return null; + + //root dynamic form instance + final DynamicForm form = new DynamicForm(); + + //vertical layout + VStack column = new VStack(); + + //label + Label operationRange = new Label("Operation Range"); + column.addMember(operationRange); + + //horizontal layout + LocatableHLayout row = new LocatableHLayout("enable.completed.operations"); + + //checkbox indicating whether to apply completed operations grouping settings + final CheckboxItem enableCompletedOperationsGrouping = new CheckboxItem(); + enableCompletedOperationsGrouping.setName(OPERATIONS_RANGE_COMPLETED_ENABLED); + enableCompletedOperationsGrouping.setTitle(" show Last "); + //add change listener + enableCompletedOperationsGrouping.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(OPERATIONS_RANGE_COMPLETED_ENABLED, selectedItem); + } + }); + //retrieve previous value otherwise initialize to true(live unlimited list) + PropertySimple retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED); + if (retrieved != null) { + enableCompletedOperationsGrouping.setValue(retrieved.getBooleanValue()); + } else {//default + enableCompletedOperationsGrouping.setValue(true); + } + + //wrap field item in dynamicform for addition as a field item + DynamicForm item = new DynamicForm(); + item.setFields(enableCompletedOperationsGrouping); + row.addMember(item); + + //-------------combobox for number of completed scheduled ops to display on the dashboard + final SelectItem maximumCompletedOperationsComboBox = new SelectItem(OPERATIONS_RANGE_COMPLETED); + maximumCompletedOperationsComboBox.setTitle(""); + maximumCompletedOperationsComboBox.setHint("<nobr><b> completed operations.</b></nobr>"); + //spinder: required to disable editability + maximumCompletedOperationsComboBox.setType("selection"); + //define acceptable values for display amount + String[] acceptableDisplayValues = { "1", "5", "10", "15", unlimited }; + maximumCompletedOperationsComboBox.setValueMap(acceptableDisplayValues); + //set width of dropdown display region + maximumCompletedOperationsComboBox.setWidth(100); + maximumCompletedOperationsComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(OPERATIONS_RANGE_COMPLETED, selectedItem); + } + }); + + //default selected value to 'unlimited'(live lists) and check both combobox settings here. + String selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumCompletedOperationsComboBox.setDefaultValue(selectedValue); + DynamicForm item2 = new DynamicForm(); + item2.setFields(maximumCompletedOperationsComboBox); + row.addMember(item2); + + //horizontal layout + LocatableHLayout row2 = new LocatableHLayout("enable.scheduled.operations"); + + final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem(); + enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED); + enableScheduledOperationsGrouping.setTitle(" show Next "); + enableScheduledOperationsGrouping.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(OPERATIONS_RANGE_SCHEDULED_ENABLED, selectedItem); + } + }); + + //wrap field item in dynamicform for addition + DynamicForm fieldWrapper = new DynamicForm(); + fieldWrapper.setFields(enableScheduledOperationsGrouping); + row2.addMember(fieldWrapper); + + //retrieve previous value otherwise initialize to true(live unlimited list) + retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED); + if (retrieved != null) { + enableScheduledOperationsGrouping.setValue(retrieved.getBooleanValue()); + } else { + enableScheduledOperationsGrouping.setValue(true); + } + + //------------- Build second combobox for timeframe for problem resources search. + final SelectItem maximumScheduledOperationsComboBox = new SelectItem(OPERATIONS_RANGE_SCHEDULED); + maximumScheduledOperationsComboBox.setTitle(""); + maximumScheduledOperationsComboBox.setHint("<nobr><b> scheduled operations.</b></nobr>"); + maximumScheduledOperationsComboBox.setType("selection"); + maximumScheduledOperationsComboBox.setValueMap(acceptableDisplayValues); + maximumScheduledOperationsComboBox.setWidth(100); + maximumScheduledOperationsComboBox.addChangeHandler(new ChangeHandler() { + public void onChange(ChangeEvent event) { + String selectedItem = "" + event.getValue(); + //stuff into the master form for retrieval + form.setValue(OPERATIONS_RANGE_SCHEDULED, selectedItem); + } + }); + + //set to default + selectedValue = defaultValue; + if (storedPortlet != null) { + //if property exists retrieve it + if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED) != null) { + selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED).getStringValue(); + } else {//insert default value + storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue)); + } + } + //prepopulate the combobox with the previously stored selection + maximumScheduledOperationsComboBox.setDefaultValue(selectedValue); + DynamicForm fieldWrapper2 = new DynamicForm(); + fieldWrapper2.setFields(maximumScheduledOperationsComboBox); + row2.addMember(fieldWrapper2); + column.addMember(row); + column.addMember(row2); + form.addChild(column); + + //submit handler + form.addSubmitValuesHandler(new SubmitValuesHandler() { + @Override + public void onSubmitValues(SubmitValuesEvent event) { + //no need to insert validation here as user not allowed to enter values + if (form.getValue(OPERATIONS_RANGE_SCHEDULED) != null) {//if new value supplied + storedPortlet.getConfiguration().put( + new PropertySimple(OPERATIONS_RANGE_SCHEDULED, form.getValue(OPERATIONS_RANGE_SCHEDULED))); + } + if (form.getValue(OPERATIONS_RANGE_COMPLETED) != null) {//if new value supplied + storedPortlet.getConfiguration().put( + new PropertySimple(OPERATIONS_RANGE_COMPLETED, form.getValue(OPERATIONS_RANGE_COMPLETED))); + } + if (form.getValue(OPERATIONS_RANGE_COMPLETED_ENABLED) != null) {//if new value supplied + storedPortlet.getConfiguration().put( + new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, form + .getValue(OPERATIONS_RANGE_COMPLETED_ENABLED))); + } + if (form.getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED) != null) {//if new value supplied + storedPortlet.getConfiguration().put( + new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, form + .getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED))); + } + } + }); + + return form; }
public static final class Factory implements PortletViewFactory { @@ -113,4 +359,69 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { } }
+ public boolean isOperationsRangeCompletedEnabled() { + return operationsRangeLastEnabled; + } + + public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) { + this.operationsRangeLastEnabled = operationsRangeLastEnabled; + } + + public boolean isOperationsRangeScheduleEnabled() { + return operationsRangeNextEnabled; + } + + public void setOperationsRangeScheduleEnabled(boolean operationsRangeNextEnabled) { + this.operationsRangeNextEnabled = operationsRangeNextEnabled; + } + + public int getOperationsRangeScheduled() { + return operationsRangeScheduled; + } + + public void setOperationsRangeScheduled(int operationsRangeScheduled) { + this.operationsRangeScheduled = operationsRangeScheduled; + } + + public int getOperationsRangeCompleted() { + return operationsRangeCompleted; + } + + public void setOperationsRangeCompleted(int operationsRangeCompleted) { + this.operationsRangeCompleted = operationsRangeCompleted; + } + + /** Custom refresh operation as we cannot directly extend Table because it only + * contains one ListGrid while the OperationsPortlet displays two tables. + */ + @Override + public void redraw() { + super.redraw(); + //now reload the table data + this.recentOperationsGrid.invalidateCache(); + this.recentOperationsGrid.markForRedraw(); + this.scheduledOperationsGrid.invalidateCache(); + this.scheduledOperationsGrid.markForRedraw(); + } + + public ConfigurationDefinition getConfigurationDefinition() { + ConfigurationDefinition definition = new ConfigurationDefinition("OperationsPortlet Configuration", + "The configuration settings for the Operations portlet."); + + definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED, + "Maximum number of Completed operations to display.", true, PropertySimpleType.STRING)); + definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED, + "Maximum number of Scheduled operations to display.", true, PropertySimpleType.STRING)); + definition + .put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED_ENABLED, + "Whether to enable completed operations results grouping for dashboard.", true, + PropertySimpleType.BOOLEAN)); + definition + .put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, + "Whether to enable scheduled operations results grouping for dashboard.", true, + PropertySimpleType.BOOLEAN)); + + return definition; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java index f87d80d..57472d3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java @@ -19,8 +19,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-import java.util.ArrayList; - import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; @@ -84,6 +82,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort listGrid.setCellHeight(50); //wrap to display disambiguation listGrid.setWrapCells(true); + // System.out.println("@@@@:"+listGrid.getField(ProblemResourcesDataSource.resource)+":W"+listGrid.getField(ProblemResourcesDataSource.resource).getWidth()); listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%"); listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%"); listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%"); @@ -137,20 +136,14 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort final DynamicForm form = new DynamicForm();
//-------------combobox for number of resource to display on the dashboard - // final ComboBoxItem maximumProblemResourcesComboBox = new ComboBoxItem(PROBLEM_RESOURCE_SHOW_MAX); - //TODO: spinder(9/1/10) field is still editable. This looks like a bug. final SelectItem maximumProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_MAX); maximumProblemResourcesComboBox.setTitle("Show maximum of"); maximumProblemResourcesComboBox.setHint("<nobr><b> problem resources for display on dashboard.</b></nobr>"); - maximumProblemResourcesComboBox.setType("comboBox"); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumProblemResourcesComboBox.setType("selection"); //define acceptable values for display amount String[] acceptableDisplayValues = { "5", "10", "15", "20", "30", unlimited }; maximumProblemResourcesComboBox.setValueMap(acceptableDisplayValues); - //load the acceptable values for validity check later. - final ArrayList<String> acceptableProblemResourceDisplayValues = new ArrayList<String>(); - for (String value : acceptableDisplayValues) { - acceptableProblemResourceDisplayValues.add(value); - } //set width of dropdown display region maximumProblemResourcesComboBox.setWidth(100);
@@ -171,14 +164,10 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort final SelectItem maximumTimeProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_HRS); maximumTimeProblemResourcesComboBox.setTitle("For the last "); maximumTimeProblemResourcesComboBox.setHint("<nobr><b> hours </b></nobr>"); - maximumTimeProblemResourcesComboBox.setType("comboBox"); + //spinder 9/3/10: the following is required workaround to disable editability of combobox. + maximumTimeProblemResourcesComboBox.setType("selection"); //define acceptable values for display amount String[] acceptableTimeValues = { "1", "4", "8", "24", "48", unlimited }; - //load the acceptable values for validity check later. - final ArrayList<String> acceptableTimeDisplayValues = new ArrayList<String>(); - for (String value : acceptableTimeValues) { - acceptableTimeDisplayValues.add(value); - } maximumTimeProblemResourcesComboBox.setValueMap(acceptableTimeValues); maximumTimeProblemResourcesComboBox.setWidth(100);
@@ -202,15 +191,11 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort form.addSubmitValuesHandler(new SubmitValuesHandler() { @Override public void onSubmitValues(SubmitValuesEvent event) { - String maxItems = (String) form.getValue(PROBLEM_RESOURCE_SHOW_MAX); - String timeFrame = (String) form.getValue(PROBLEM_RESOURCE_SHOW_HRS); - //TODO: spinder 9/1/10: use smartgwt validation here? - //shouldn't be necessary, but SelectItem remains editable for odd reason. - if (acceptableProblemResourceDisplayValues.contains(maxItems.trim())) { + if (form.getValue(PROBLEM_RESOURCE_SHOW_MAX) != null) { storedPortlet.getConfiguration().put( new PropertySimple(PROBLEM_RESOURCE_SHOW_MAX, form.getValue(PROBLEM_RESOURCE_SHOW_MAX))); } - if (acceptableTimeDisplayValues.contains(timeFrame.trim())) { + if (form.getValue(PROBLEM_RESOURCE_SHOW_HRS) != null) { storedPortlet.getConfiguration().put( new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, form.getValue(PROBLEM_RESOURCE_SHOW_HRS))); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java index 87ed4b7..28e6169 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java @@ -13,7 +13,7 @@ public class LocatableListGrid extends ListGrid implements Locatable {
/** * <pre> - * ID Format: "simpleClassname_locatorId" + * ID Format: "scClassname-id" * </pre> * @param locatorId not null or empty. */
commit ce3f841a30ea1f4d56055c42e252acad575043bb Author: John Sanda jsanda@redhat.com Date: Wed Sep 8 13:36:49 2010 -0400
Initial commit for measurement_utils.js
Defines the class MeausrementModule which provides some properties and methods for working with measurement schedules.
diff --git a/etc/cli-scripts/measurement_utils.js b/etc/cli-scripts/measurement_utils.js new file mode 100644 index 0000000..261aa8e --- /dev/null +++ b/etc/cli-scripts/measurement_utils.js @@ -0,0 +1,134 @@ +testUpdates = { + context: 'Resource', + id: 10033, + schedules: { + 'Late Collections': interval(15, minutes), + 'Failed Collections per Minute': interval(15, minutes), + 'Currently Schedule Measurements': 'enabled' + } +} + +testGroupUpdates = { + context: 'Group', + id: 10031, + schedules: { + 'Used Swap Space': 'disabled', + 'Total Memory': interval(3, minutes) + } +} + +/** + * MeasurementModule is a class that provides properties and methods for working with + * measurements. + */ +function MeasurementModule() { + + /** + * Performs the actual updates, calling MeasurementScheduleManager. + * + * @param updates + * @param criteria + * @param enableSchedules + * @param disableSchedules + * @param updateSchedules + */ + function doScheduleUpdates(updates, criteria, enableSchedules, disableSchedules, updateSchedules) { + criteria.fetchDefinition(true); + var schedules = MeasurementScheduleManager.findSchedulesByCriteria(criteria); + + foreach(schedules, function (schedule) { + var measurementName = schedule.definition.displayName; + + if (updates.schedules[measurementName]) { + switch (updates.schedules[measurementName]) { + case 'enabled': + MeasurementScheduleManager[enableSchedules](updates.id, [schedule.definition.id]); + break; + case 'disabled': + MeasurementScheduleManager[disableSchedules](updates.id, + [schedule.definition.id]); + break; + default: + var interval = updates.schedules[measurementName]; + MeasurementScheduleManager[updateSchedules](updates.id, + [schedule.definition.id], interval); + } + } + }); + + } + + /** + * Intended for use with the interval method. + */ + this.time = { + seconds: 1000, + minutes: 60 * seconds, + hours: 60 * minutes + } + + /** + * A helper method that calculates a shedule's interval in milliseconds + * @param num + * @param time + */ + this.interval = function (num, time) { + return num * time; + } + + /** + * Updates the metric schedule as specified in the updates object. The object is expected + * to contain three properties or keys. The first of these required keys is <context>. + * Accepted values are the strings 'Resource' or 'Group'. + * + * The next required key is <id>, and its values is expected to be an integer. The + * interpretation of its values is dependent on the value of <context>. When the value of + * <context> is 'Resource', then <id> is treated as a resource id. If the value of + * <context> is 'Group', then <id> is treated as a compatible group id. + * + * The third required key is <schedules>, and it a nested object that specifies the + * schedules to be updated. The keys of <schedules> are the measurement display names. + * Expected values are 'enabled', 'disabled', or an integer which specifies the + * collection interval in milliseconds. + * + * Here is an example to illustrate what the updates object should look like: + * + * resourceSchedulesUpdates = { + * context: 'Resource', + * id: 123, + * schedules: { + * 'Measurement A': 'enabled', + * 'Measurement B': 'disabled, + * 'Measurement C': interval(20, time.minutes) + * } + * } + * + * @param updates The updates to perform + */ + this.updateSchedules = function (updates) { + if (!updates.id) { + throw '<id> is a required property'; + } + + if (!updates.schedules) { + throw '<schedules> is a required property'; + } + + if (updates.context == 'Resource') { + var criteria = MeasurementScheduleCriteria(); + criteria.addFilterResourceId(updates.id); + doScheduleUpdates(updates, criteria, 'enableSchedulesForResource', + 'disableSchedulesForResource', 'updateSchedulesForResource'); + } + else if (updates.context == 'Group') { + var criteria = MeasurementScheduleCriteria(); + criteria.addFilterResourceGroupId(updates.id); + doScheduleUpdates(updates, criteria, 'enableSchedulesForCompatibleGroup', + 'disableSchedulesForCompatibleGroup', 'updateSchedulesForCompatibleGroup'); + } + else { + throw "Unrecognized value for context: " + updates.context + " - expected either " + + "<Resource> or <Group>"; + } + } +}
commit ca5e991eef94926a016a43500eac107051ebde44 Author: John Sanda jsanda@redhat.com Date: Tue Sep 7 16:52:03 2010 -0400
Putting build number generation plugins in profile to facilitate building in mead
We execute git during the build to generate some build properties, namely a build number. The git executable however is not available in the mead build environment. I have move the plugins involved with generating build properties into a profile so that we can disable them during builds in mead.
diff --git a/pom.xml b/pom.xml index 70c5254..497a520 100644 --- a/pom.xml +++ b/pom.xml @@ -604,85 +604,6 @@ </executions> </plugin>
- <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>write-build-time-properties-file</id> - <goals> - <goal>run</goal> - </goals> - <phase>generate-sources</phase> - <configuration> - <tasks> - <tstamp> - <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT" /> - </tstamp> - <mkdir dir="target" /> - <echo file="target/build-time.properties" level="error">buildTime = ${buildTime}</echo> - </tasks> - </configuration> - </execution> - - <execution> - <id>echo-build-properties</id> - <phase>compile</phase> - <inherited>false</inherited> - <goals> - <goal>run</goal> - </goals> - <configuration> - <tasks> - <echo level="debug">buildTime = ${buildTime}</echo> - <echo level="debug">buildNumber = ${buildNumber}</echo> - </tasks> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>generate-build-number-properties</id> - <phase>generate-sources</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>git</executable> - <arguments> - <argument>log</argument> - <argument>--pretty=format:buildNumber = %h</argument> - <argument>-n1</argument> - </arguments> - <outputFile>${project.build.directory}/build-number.properties</outputFile> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>properties-maven-plugin</artifactId> - <executions> - <execution> - <id>read-build-properties</id> - <phase>process-sources</phase> - <goals> - <goal>read-project-properties</goal> - </goals> - <configuration> - <files> - <file>${project.build.directory}/build-time.properties</file> - <file>${project.build.directory}/build-number.properties</file> - </files> - </configuration> - </execution> - </executions> - </plugin>
<plugin> <artifactId>maven-resources-plugin</artifactId> @@ -1083,6 +1004,98 @@ </build> </profile>
+ <profile> + <id>build-properties</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>write-build-time-properties-file</id> + <goals> + <goal>run</goal> + </goals> + <phase>generate-sources</phase> + <configuration> + <tasks> + <tstamp> + <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" + timezone="GMT"/> + </tstamp> + <mkdir dir="target"/> + <echo file="target/build-time.properties" level="error">buildTime = ${buildTime} + </echo> + </tasks> + </configuration> + </execution> + + <execution> + <id>echo-build-properties</id> + <phase>compile</phase> + <inherited>false</inherited> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <echo level="debug">buildTime = ${buildTime}</echo> + <echo level="debug">buildNumber = ${buildNumber}</echo> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-build-number-properties</id> + <phase>generate-sources</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <executable>git</executable> + <arguments> + <argument>log</argument> + <argument>--pretty=format:buildNumber = %h</argument> + <argument>-n1</argument> + </arguments> + <outputFile>${project.build.directory}/build-number.properties</outputFile> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>properties-maven-plugin</artifactId> + <executions> + <execution> + <id>read-build-properties</id> + <phase>process-sources</phase> + <goals> + <goal>read-project-properties</goal> + </goals> + <configuration> + <files> + <file>${project.build.directory}/build-time.properties</file> + <file>${project.build.directory}/build-number.properties</file> + </files> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles>
commit 560767773837cf185c700cec5e4e3424e83d21fb Merge: 06b4a2c... 05f3a00... Author: John Sanda jsanda@redhat.com Date: Tue Sep 7 16:50:28 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 05f3a00fae75d97d066559c7671dc4f0770a1dbd Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 8 13:54:18 2010 -0400
bz 631895 - allow a user to enter --resourceId option to discovery prompt command in order to perform a service scan. Like the rest of the options of this command (exception being --ful) this new feature still will not send up an inventory report to the RHQ Server - use --full for that. This --resourceId is to assist developers while they are writing plugins to test service scans or allows users to see what the next service scan would detect. Since service scans are scheduled every 24 hours, this helps people see if anything would result - if something is discovered using this command, you can do a "discovery --full" to force a full discovery to be performed and the inventory report sent up to the server.
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java index 7920df0..eb1df86 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java @@ -1832,7 +1832,7 @@ public interface AgentI18NResourceKeys { String DISCOVERY = "PromptCommand.discovery";
@I18NMessage("discovery [--plugin=<plugin name>] [--resourceType=<type name>]\n\\n" // - + "\ [--verbose]\n\\n" // + + "\ [--resourceId=<id>] [--verbose]\n\\n" // + "\ discovery --full [--verbose]\n\\n" // + "\ discovery --blacklist={list|clear}") String DISCOVERY_SYNTAX = "PromptCommand.discovery.syntax"; @@ -1840,16 +1840,16 @@ public interface AgentI18NResourceKeys { @I18NMessage("Asks a plugin to run a server scan discovery") String DISCOVERY_HELP = "PromptCommand.discovery.help";
- @I18NMessage("Asks a plugin to run a discovery scan. This is a way to determine\n\\n" - + "what servers a plugin can actually find. Note that this will run a server\n\\n" - + "scan, not a service scan (i.e. it will not try to discover child services\n\\n" - + "for parent servers already in inventory) unless you use --full. Also note\n\\n" - + "that only --full will actually send an inventory report to the server.\n\\n" + @I18NMessage("Asks a plugin to run a discovery scan. This is a way to determine what\n\\n" + + "resources a plugin can actually find. Note that this will run a server scan\n\\n" + + "not a service scan (i.e. it will not try to discover child services for parent\n\\n" + + "servers already in inventory) unless you use --full or --resourceId. Also\n\\n" + + "note that only --full will actually send an inventory report to the server.\n\\n" + "The valid command line arguments are:\n\\n" + "\ -f, --full : Runs a detailed discovery inside the plugin container.\n\\n" + "\ This will update the actual agent inventory by sending\n\\n" + "\ an inventory report to the server.\n\\n" - + "\ This ignores --plugin and --resourceType.\n\\n" + + "\ This ignores --plugin, --resourceType and --resourceId.\n\\n" + "\ -p, --plugin=<name> : The name of the plugin whose discovery will run.\n\\n" + "\ If you do not specify a plugin, all plugins will\n\\n" + "\ run their discovery.\n\\n" @@ -1859,6 +1859,11 @@ public interface AgentI18NResourceKeys { + "\ discovered (and if no plugin was specified,\n\\n" + "\ then all resource types for all plugins will\n\\n" + "\ be discovered).\n\\n" + + "\ -i, --resourceId=<id> : specifies the specific resource ID whose\n\\n" + + "\ services are to be discovered. If specified,\n\\n" + + "\ a service scan is performed as opposed to a\n\\n" + + "\ server scan and the --plugin/--resourceType\n\\n" + + "\ options are ignored.\n\\n" + "\ -v, --verbose : If doing a non-full discovery, this prints the plugin\n\\n" + "\ configuration of each discovered resource. For --full\n\\n" + "\ scans, this will dump all resources and errors found.\n\\n" @@ -1877,6 +1882,12 @@ public interface AgentI18NResourceKeys { @I18NMessage("Full discovery run in [{0}] ms") String DISCOVERY_FULL_RUN = "PromptCommand.discovery.full-run";
+ @I18NMessage("Service discovery run for resource [{0}]") + String DISCOVERY_RESOURCE_SERVICES = "PromptCommand.discovery.resource-service-scan"; + + @I18NMessage("The given resource ID [{0}] does not match any resource in inventory.") + String DISCOVERY_RESOURCE_ID_INVALID = "PromptCommand.discovery.resource-id-invalid"; + @I18NMessage("=== {0} Inventory Report ===\n\\n" // + "Start Time: {1,date,medium} {1,time,medium}\n\\n" // + "Finish Time: {2,date,medium} {2,time,medium}\n\\n" // diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java index 3aea8ec..8736f05 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java @@ -33,17 +33,19 @@ import java.util.Set; import mazz.i18n.Msg;
import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager; +import org.rhq.core.clientapi.server.discovery.InventoryReport; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.clientapi.server.discovery.InventoryReport; import org.rhq.core.domain.resource.ProcessScan; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pc.PluginContainer; +import org.rhq.core.pc.PluginContainerConfiguration; import org.rhq.core.pc.inventory.InventoryManager; import org.rhq.core.pc.inventory.ResourceContainer; +import org.rhq.core.pc.inventory.RuntimeDiscoveryExecutor; import org.rhq.core.pc.plugin.PluginComponentFactory; import org.rhq.core.pc.util.DiscoveryComponentProxyFactory; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; @@ -58,6 +60,7 @@ import org.rhq.core.system.SystemInfoFactory; import org.rhq.core.system.pquery.ProcessInfoQuery; import org.rhq.core.util.exception.ExceptionPackage; import org.rhq.core.util.exception.ThrowableUtil; +import org.rhq.enterprise.agent.AgentConfiguration; import org.rhq.enterprise.agent.AgentMain; import org.rhq.enterprise.agent.i18n.AgentI18NFactory; import org.rhq.enterprise.agent.i18n.AgentI18NResourceKeys; @@ -89,7 +92,7 @@ public class DiscoveryPromptCommand implements AgentPromptCommand { System.arraycopy(args, 1, realArgs, 0, args.length - 1);
// use getAgentName because it is the name of the plugin container - processCommand(agent.getConfiguration().getAgentName(), realArgs, out); + processCommand(agent, realArgs, out); } else { out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_PC_NOT_STARTED)); } @@ -118,14 +121,18 @@ public class DiscoveryPromptCommand implements AgentPromptCommand { return MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_DETAILED_HELP); }
- private void processCommand(String pcName, String[] args, PrintWriter out) { + private void processCommand(AgentMain agent, String[] args, PrintWriter out) { + AgentConfiguration agentConfig = agent.getConfiguration(); + String pcName = agentConfig.getAgentName(); String pluginName = null; String resourceTypeName = null; + Integer resourceId = null; boolean verbose = false; boolean full = false;
- String sopts = "-p:r:fvb:"; + String sopts = "-p:i:r:fvb:"; LongOpt[] lopts = { new LongOpt("plugin", LongOpt.REQUIRED_ARGUMENT, null, 'p'), // + new LongOpt("resourceId", LongOpt.REQUIRED_ARGUMENT, null, 'i'), // new LongOpt("resourceType", LongOpt.REQUIRED_ARGUMENT, null, 'r'), // new LongOpt("full", LongOpt.NO_ARGUMENT, null, 'f'), // new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'), // @@ -148,6 +155,11 @@ public class DiscoveryPromptCommand implements AgentPromptCommand { break; }
+ case 'i': { + resourceId = Integer.valueOf(getopt.getOptarg()); + break; + } + case 'r': { resourceTypeName = getopt.getOptarg(); break; @@ -187,9 +199,10 @@ public class DiscoveryPromptCommand implements AgentPromptCommand { }
if (full) { - // do a full discovery - we ignore the -p and -r options and do everything + // do a full discovery - we ignore the -p and -r and -i options and do everything InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager(); - HashSet<ResourceType> blacklist = inventoryManager.getDiscoveryComponentProxyFactory().getResourceTypeBlacklist(); + HashSet<ResourceType> blacklist = inventoryManager.getDiscoveryComponentProxyFactory() + .getResourceTypeBlacklist(); if (!blacklist.isEmpty()) { out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_BLACKLISTED_TYPES, blacklist)); } @@ -201,10 +214,25 @@ public class DiscoveryPromptCommand implements AgentPromptCommand { printInventoryReport(scan2, out, verbose); } else { try { - discovery(pcName, out, pluginName, resourceTypeName, verbose); + if (resourceId == null) { + discovery(pcName, out, pluginName, resourceTypeName, verbose); + } else { + // specifying a resource ID implies we must ignore -r and -p (since type/plugin is determined by the resource) + InventoryManager im = PluginContainer.getInstance().getInventoryManager(); + ResourceContainer resourceContainer = im.getResourceContainer(resourceId); + if (resourceContainer != null) { + Resource resource = resourceContainer.getResource(); + PluginContainerConfiguration pcc = agentConfig.getPluginContainerConfiguration(); + RuntimeDiscoveryExecutor scanner = new RuntimeDiscoveryExecutor(im, pcc, resource); + InventoryReport report = scanner.call(); + out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_RESOURCE_SERVICES, resource.getName())); + printInventoryReport(report, out, verbose); + } else { + out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_RESOURCE_ID_INVALID, resourceId)); + } + } } catch (Exception e) { out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_ERROR, ThrowableUtil.getAllMessages(e))); - return; } }
@@ -261,7 +289,8 @@ public class DiscoveryPromptCommand implements AgentPromptCommand { }
InventoryManager inventoryManager = pc.getInventoryManager(); - HashSet<ResourceType> blacklist = inventoryManager.getDiscoveryComponentProxyFactory().getResourceTypeBlacklist(); + HashSet<ResourceType> blacklist = inventoryManager.getDiscoveryComponentProxyFactory() + .getResourceTypeBlacklist(); Iterator<ResourceType> iterator = blacklist.iterator(); while (iterator.hasNext()) { ResourceType type = iterator.next();
commit a572ff4732dfa48147cadfdba026742c05eba1a3 Author: John Mazzitelli mazz@redhat.com Date: Tue Sep 7 16:58:25 2010 -0400
we never updated ecllipse classpath to point to our current EMS version - this corrects that mistake
diff --git a/.classpath b/.classpath index dc15df6..c13d973 100644 --- a/.classpath +++ b/.classpath @@ -202,7 +202,7 @@ <classpathentry exported="true" kind="var" path="M2_REPO/javax/faces/jsf-impl/1.2_14/jsf-impl-1.2_14.jar" sourcepath="/M2_REPO/javax/faces/jsf-impl/1.2_14/jsf-impl-1.2_14-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/com/sun/facelets/jsf-facelets/1.1.15.B1/jsf-facelets-1.1.15.B1.jar" sourcepath="/M2_REPO/com/sun/facelets/jsf-facelets/1.1.15.B1/jsf-facelets-1.1.15.B1-sources.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.2.14/org-mc4j-ems-1.2.14.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.2.13/org-mc4j-ems-1.2.13-sources.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.2.15.1/org-mc4j-ems-1.2.15.1.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.2.15.1/org-mc4j-ems-1.2.15.1-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5.jar" sourcepath="/M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/mail/mail/1.4.2/mail-1.4.2.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar"/>
commit 8cc4a2da37215e02591d3a24d790f47c7593a9be Author: Joseph Marques joseph@redhat.com Date: Tue Sep 7 18:34:44 2010 -0400
add more consistency to left-hand navigation element of the inventory browser
* new top-level nodes ** pull-up auto discovery node as top-level node within resource section ** pull-up group definitions node as top-level node within group section ** rename both to use a manager suffix, to be more consistent across sections
* collapse superfluous nodes into nodes that didn't do anything ** collapse "all reosurces" node into its "inventory" parent folder/node ** collapse "all groups" node into its "inventory" parent folder/node ** rename both "inventory" folders/nodes by prefixing with section/context
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index a3d0821..731711e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -47,6 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/** * @author Greg Hinkle + * @author Joseph Marques */ public class InventoryView extends LocatableHLayout implements BookmarkableView {
@@ -55,14 +56,15 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView private static final String SECTION_GROUPS = "Groups"; private static final String SECTION_RESOURCES = "Resources";
- private static final String SUBSECTION_INVENTORY = "Inventory"; + private static final String SUBSECTION_RESOURCE_INVENTORY = "Resource Inventory"; + private static final String SUBSECTION_GROUP_INVENTORY = "Group Inventory"; private static final String SUBSECTION_SAVED_SEARCHES = "Saved Searches";
- private static final String PAGE_ADQ = "Auto Discovery Queue"; + private static final String PAGE_ADQ = "Discovery Manager"; private static final String PAGE_COMPATIBLE_GROUPS = "Compatible Groups"; private static final String PAGE_DOWN = "Down Servers"; private static final String PAGE_GROUPS = "All Groups"; - private static final String PAGE_GROUP_DEFINITIONS = "Group Definitions"; + private static final String PAGE_GROUP_DEFINITIONS = "DynaGroup Manager"; private static final String PAGE_MIXED_GROUPS = "Mixed Groups"; private static final String PAGE_PLATFORMS = "Platforms"; private static final String PAGE_PROBLEM_GROUPS = "Problem Groups"; @@ -126,10 +128,13 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView }
private SectionStackSection buildResourcesSection() { + final SectionStackSection section = new SectionStackSection(SECTION_RESOURCES); section.setExpanded(true);
- final TreeNode allResources = new TreeNode(PAGE_RESOURCES); + final TreeNode discoveryQueue = new TreeNode(PAGE_ADQ); + discoveryQueue.setIcon("global/Recent_16.png"); + final TreeNode onlyPlatforms = new TreeNode(PAGE_PLATFORMS); onlyPlatforms.setIcon("types/Platform_up_16.png");
@@ -139,11 +144,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView final TreeNode onlyServices = new TreeNode(PAGE_SERVICES); onlyServices.setIcon("types/Service_up_16.png");
- final TreeNode discoveryQueue = new TreeNode("Auto Discovery Queue"); - discoveryQueue.setIcon("global/Recent_16.png"); - - final TreeNode inventory = new TreeNode(SUBSECTION_INVENTORY, allResources, onlyPlatforms, onlyServers, - onlyServices, discoveryQueue); + final TreeNode inventory = new TreeNode(SUBSECTION_RESOURCE_INVENTORY, onlyPlatforms, onlyServers, onlyServices);
final TreeNode downServers = new TreeNode(PAGE_DOWN); downServers.setIcon("types/Server_down_16.png"); @@ -153,7 +154,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView TreeGrid treeGrid = new LocatableTreeGrid(SECTION_RESOURCES); treeGrid.setShowHeader(false); Tree tree = new Tree(); - tree.setRoot(new TreeNode(SECTION_RESOURCES, inventory, savedSearches)); + tree.setRoot(new TreeNode(SECTION_RESOURCES, discoveryQueue, inventory, savedSearches)); treeGrid.setData(tree);
treeGrid.getTree().openAll(); @@ -168,15 +169,15 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView final SectionStackSection section = new SectionStackSection(SECTION_GROUPS); section.setExpanded(true);
- final TreeNode allGroups = new TreeNode(PAGE_GROUPS); + final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS); + groupGroupDefinitions.setIcon("types/GroupDefinition_16.png"); + final TreeNode onlyCompatible = new TreeNode(PAGE_COMPATIBLE_GROUPS); onlyCompatible.setIcon("types/Cluster_up_16.png"); final TreeNode onlyMixed = new TreeNode(PAGE_MIXED_GROUPS); onlyMixed.setIcon("types/Group_up_16.png"); - final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS); - groupGroupDefinitions.setIcon("types/GroupDefinition_16.png"); - final TreeNode inventory = new TreeNode(SECTION_GROUPS, allGroups, onlyCompatible, onlyMixed, - groupGroupDefinitions); + + final TreeNode inventory = new TreeNode(SUBSECTION_GROUP_INVENTORY, onlyCompatible, onlyMixed);
final TreeNode problemGroups = new TreeNode(PAGE_PROBLEM_GROUPS); final TreeNode savedSearches = new TreeNode(SUBSECTION_SAVED_SEARCHES, problemGroups); @@ -184,7 +185,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView TreeGrid treeGrid = new LocatableTreeGrid(SECTION_GROUPS); treeGrid.setShowHeader(false); Tree tree = new Tree(); - tree.setRoot(new TreeNode(SECTION_GROUPS, inventory, savedSearches)); + tree.setRoot(new TreeNode(SECTION_GROUPS, groupGroupDefinitions, inventory, savedSearches)); treeGrid.setData(tree);
treeGrid.getTree().openAll(); @@ -217,11 +218,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
Canvas content = null; if (SECTION_RESOURCES.equals(section)) { - - if (PAGE_RESOURCES.equals(page)) { - content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES, - "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png"); - } else if (PAGE_PLATFORMS.equals(page)) { + if (PAGE_PLATFORMS.equals(page)) { content = new ResourceSearchView(extendLocatorId("Platforms"), new Criteria( ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS, "types/Platform_up_24.png"); @@ -240,14 +237,13 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView AvailabilityType.DOWN.name()); criteria.addCriteria(ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()); content = new ResourceSearchView(extendLocatorId("DownResources"), criteria, PAGE_DOWN); + } else { // selected the Inventory node itself + content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES, + "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png"); }
} else if (SECTION_GROUPS.equals(section)) { - - if (PAGE_GROUPS.equals(page)) { - content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS, - "types/Cluster_up_24.png", "types/Group_up_24.png"); - } else if (PAGE_COMPATIBLE_GROUPS.equals(page)) { + if (PAGE_COMPATIBLE_GROUPS.equals(page)) { content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria("category", "compatible"), PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_24.png"); } else if (PAGE_MIXED_GROUPS.equals(page)) { @@ -260,6 +256,9 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView // new button on this page. content = new ResourceGroupListView(extendLocatorId("DownGroups"), new Criteria("availability", "down"), PAGE_PROBLEM_GROUPS); + } else { // selected the Inventory node itself + content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS, + "types/Cluster_up_24.png", "types/Group_up_24.png"); } }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java index 29673a6..54d175f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java @@ -82,7 +82,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { HTMLFlow title = new HTMLFlow(); title.setWidth100(); title.setHeight(35); - title.setContents("Auto Discovery Queue"); + title.setContents("Discovery Manager"); title.setPadding(4); title.setStyleName("HeaderLabel"); titleLayout.addMember(title); @@ -109,7 +109,6 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
treeGrid.setDataSource(new AutodiscoveryQueueDataSource()); treeGrid.setAutoFetchData(true); - treeGrid.setTitle("Auto Discovery Queue"); treeGrid.setResizeFieldsInRealTime(true);
final TreeGridField name, key, type, description, status, ctime;
commit de9516869976390c3a0c8bcf3fcd0fce451bfb90 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 30 01:13:55 2010 -0400
primitive solution to time out the coregui user session prior to the http session
* upon login, refresh the count-down timer @ 29 minutes (http session is 30 mins) * upon logout, destroy/cancel the count-down timer * if the count-down timer expires, immitate a logout action
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index e0625a5..f153fea 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -30,6 +30,7 @@ import com.google.gwt.http.client.Response; import com.google.gwt.http.client.URL; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.History; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; import com.smartgwt.client.core.KeyIdentifier; @@ -69,6 +70,14 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static Subject sessionSubject;
+ private static Timer sessionTimer = new Timer() { + @Override + public void run() { + System.out.println("Session Timer Expired"); + new LoginView(true).showLoginDialog(); // log user out, show login dialog + } + }; + private static UserPreferences userPreferences;
private static ErrorHandler errorHandler = new ErrorHandler(); @@ -192,6 +201,16 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> { } }
+ public static void refreshSessionTimer() { + System.out.println("Refreshing Session Timer"); + sessionTimer.schedule(29 * 60 * 1000); // 29 minutes from now, timeout before the http session timeout + } + + public static void destroySessionTimer() { + System.out.println("Destroying Session Timer"); + sessionTimer.cancel(); + } + private void buildCoreUI() { // If the core gui is already built (eg. from previous login, just refire event) if (this.rootCanvas == null) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java index 82d010d..6290eb7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java @@ -63,18 +63,22 @@ public class LoginView extends Canvas { }
public LoginView(boolean logout) { + if (logout) { + CoreGUI.destroySessionTimer(); + if (CoreGUI.getSessionSubject() != null) { + GWTServiceLookup.getSubjectService().logout(CoreGUI.getSessionSubject(), new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to logout", caught); + CoreGUI.checkLoginStatus(); + }
- if (logout && CoreGUI.getSessionSubject() != null) { - GWTServiceLookup.getSubjectService().logout(CoreGUI.getSessionSubject(), new AsyncCallback<Void>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to logout", caught); - CoreGUI.checkLoginStatus(); - } - - public void onSuccess(Void result) { - CoreGUI.checkLoginStatus(); - } - }); + public void onSuccess(Void result) { + CoreGUI.checkLoginStatus(); + } + }); + } + } else { + CoreGUI.refreshSessionTimer(); }
}
commit 25c2c140c9cf11a801d08b49212d0e2eda3dc877 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 12:26:27 2010 -0400
add left-nav and table header icons for group definitions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java index 9e3f983..dc81946 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java @@ -32,9 +32,11 @@ import org.rhq.enterprise.gui.coregui.client.components.table.Table; */ public class GroupDefinitionListView extends Table {
- public GroupDefinitionListView(String locatorId) { + public GroupDefinitionListView(String locatorId, String headerIcon) { super(locatorId, "Group Definitions");
+ setHeaderIcon(headerIcon); + final GroupDefinitionDataSource datasource = new GroupDefinitionDataSource(); setDataSource(datasource); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index ac717bf..a3d0821 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -174,6 +174,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView final TreeNode onlyMixed = new TreeNode(PAGE_MIXED_GROUPS); onlyMixed.setIcon("types/Group_up_16.png"); final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS); + groupGroupDefinitions.setIcon("types/GroupDefinition_16.png"); final TreeNode inventory = new TreeNode(SECTION_GROUPS, allGroups, onlyCompatible, onlyMixed, groupGroupDefinitions);
@@ -253,7 +254,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria("category", "mixed"), PAGE_MIXED_GROUPS, "types/Group_up_24.png"); } else if (PAGE_GROUP_DEFINITIONS.equals(page)) { - content = new GroupDefinitionListView(extendLocatorId("Definitions")); + content = new GroupDefinitionListView(extendLocatorId("Definitions"), "types/GroupDefinition_16.png"); } else if (PAGE_PROBLEM_GROUPS.equals(page)) { //TODO - there is no underlying support for this criteria. Also, there should not be an active // new button on this page.
commit c559a5bfc79a7232526a565b058151d0cd2edb66 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 11:47:35 2010 -0400
add group definition icon to coregui
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/types/GroupDefinition_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/types/GroupDefinition_16.png new file mode 100644 index 0000000..20b0f01 Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/types/GroupDefinition_16.png differ
commit 307c5f41f63a9f3ba7b79d4f5c99efed815c7b5b Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 11:47:22 2010 -0400
set the node icons for compatible/mixed groups in the inventory view left-nav
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index c051000..ac717bf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -170,7 +170,9 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
final TreeNode allGroups = new TreeNode(PAGE_GROUPS); final TreeNode onlyCompatible = new TreeNode(PAGE_COMPATIBLE_GROUPS); + onlyCompatible.setIcon("types/Cluster_up_16.png"); final TreeNode onlyMixed = new TreeNode(PAGE_MIXED_GROUPS); + onlyMixed.setIcon("types/Group_up_16.png"); final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS); final TreeNode inventory = new TreeNode(SECTION_GROUPS, allGroups, onlyCompatible, onlyMixed, groupGroupDefinitions);
commit aaace38e92ecb818c9fe482dd2880ce33347cd62 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 11:42:05 2010 -0400
cosmetic, refactoring according to code conventions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java index 25c24bb..a77a9d9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java @@ -18,6 +18,13 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.resource;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN; +import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE; + import java.util.ArrayList; import java.util.List;
@@ -40,13 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.util.message.Message; import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN; -import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE; - /** * @author Greg Hinkle */ @@ -99,10 +99,8 @@ public class ResourceSearchView extends Table { // setTitleComponent(searchPanel); setDataSource(datasource);
- }
- @Override protected void configureTable() {
@@ -115,7 +113,8 @@ public class ResourceSearchView extends Table { ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250); nameField.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { - return "<a href="" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")) + "">" + o + "</a>"; + return "<a href="" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")) + "">" + o + + "</a>"; } });
commit 47a25eff072edf9443a3587ab032e67a11b2f12f Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 11:41:41 2010 -0400
add appropriate table header icons for inventory view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java index b1f70b7..38d409f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java @@ -51,10 +51,12 @@ public class ResourceGroupListView extends Table { this(locatorId, null, title); }
- public ResourceGroupListView(String locatorId, Criteria criteria, String title) { + public ResourceGroupListView(String locatorId, Criteria criteria, String title, String... headerIcons) { super(locatorId, title, criteria);
- setHeaderIcon("types/Group_up_24.png"); + for (String headerIcon : headerIcons) { + addHeaderIcon(headerIcon); + }
final ResourceGroupsDataSource datasource = ResourceGroupsDataSource.getInstance(); setDataSource(datasource); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index d4b0b63..c051000 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -216,16 +216,20 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView if (SECTION_RESOURCES.equals(section)) {
if (PAGE_RESOURCES.equals(page)) { - content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES); + content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES, + "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png"); } else if (PAGE_PLATFORMS.equals(page)) { content = new ResourceSearchView(extendLocatorId("Platforms"), new Criteria( - ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS); + ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS, + "types/Platform_up_24.png"); } else if (PAGE_SERVERS.equals(page)) { content = new ResourceSearchView(extendLocatorId("Servers"), new Criteria( - ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()), PAGE_SERVERS); + ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()), PAGE_SERVERS, + "types/Server_up_24.png"); } else if (PAGE_SERVICES.equals(page)) { content = new ResourceSearchView(extendLocatorId("Services"), new Criteria( - ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVICE.name()), PAGE_SERVICES); + ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVICE.name()), PAGE_SERVICES, + "types/Service_up_24.png"); } else if (PAGE_ADQ.equals(page)) { content = new ResourceAutodiscoveryView(this.extendLocatorId("ADQ")); } else if (PAGE_DOWN.equals(page)) { @@ -238,13 +242,14 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView } else if (SECTION_GROUPS.equals(section)) {
if (PAGE_GROUPS.equals(page)) { - content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS); + content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS, + "types/Cluster_up_24.png", "types/Group_up_24.png"); } else if (PAGE_COMPATIBLE_GROUPS.equals(page)) { content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria("category", - "compatible"), PAGE_COMPATIBLE_GROUPS); + "compatible"), PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_24.png"); } else if (PAGE_MIXED_GROUPS.equals(page)) { content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria("category", "mixed"), - PAGE_MIXED_GROUPS); + PAGE_MIXED_GROUPS, "types/Group_up_24.png"); } else if (PAGE_GROUP_DEFINITIONS.equals(page)) { content = new GroupDefinitionListView(extendLocatorId("Definitions")); } else if (PAGE_PROBLEM_GROUPS.equals(page)) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java index 7a4b3be..25c24bb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java @@ -74,18 +74,20 @@ public class ResourceSearchView extends Table { this(locatorId, criteria, DEFAULT_TITLE); }
- public ResourceSearchView(String locatorId, Criteria criteria, String title) { - this(locatorId, criteria, title, null, null); + public ResourceSearchView(String locatorId, Criteria criteria, String title, String... headerIcons) { + this(locatorId, criteria, title, null, null, headerIcons); }
/** * A Resource list filtered by a given criteria with the given title. */ public ResourceSearchView(String locatorId, Criteria criteria, String title, SortSpecifier[] sortSpecifier, - String[] excludeFields) { + String[] excludeFields, String... headerIcons) { super(locatorId, title, criteria, sortSpecifier, excludeFields);
- setHeaderIcon("types/Platform_up_24.png"); + for (String headerIcon : headerIcons) { + addHeaderIcon(headerIcon); + }
// DynamicForm searchPanel = new DynamicForm(); // final TextItem searchBox = new TextItem("query", "Search Resources");
commit cbf929586870b5697931bf0019ca82f661654051 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 11:40:26 2010 -0400
enhance Table component to be able to display multiple title-prefix images
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index a18d6f8..90b448f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -78,7 +78,7 @@ public class Table extends LocatableHLayout { private ToolStrip footer; private Label tableInfo;
- private String headerIcon; + private List<String> headerIcons = new ArrayList<String>();
private boolean showHeader = true; private boolean showFooter = true; @@ -260,7 +260,7 @@ public class Table extends LocatableHLayout {
if (showHeader) {
- if (headerIcon != null) { + for (String headerIcon : headerIcons) { Img img = new Img(headerIcon, 24, 24); img.setPadding(4); titleLayout.addMember(img); @@ -465,12 +465,15 @@ public class Table extends LocatableHLayout { this.extraWidgets.add(canvas); }
- public String getHeaderIcon() { - return headerIcon; + public void setHeaderIcon(String headerIcon) { + if (this.headerIcons.size() > 0) { + this.headerIcons.clear(); + } + addHeaderIcon(headerIcon); }
- public void setHeaderIcon(String headerIcon) { - this.headerIcon = headerIcon; + public void addHeaderIcon(String headerIcon) { + this.headerIcons.add(headerIcon); }
protected void refreshTableInfo() {
commit 4158471e033ff8a545b13dfa15cf9e96ee76a3b0 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 11:21:52 2010 -0400
fix table title for "all groups" list view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java index 393bd45..d4b0b63 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java @@ -238,7 +238,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView } else if (SECTION_GROUPS.equals(section)) {
if (PAGE_GROUPS.equals(page)) { - content = new ResourceGroupListView(extendLocatorId("AllGroups")); + content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS); } else if (PAGE_COMPATIBLE_GROUPS.equals(page)) { content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria("category", "compatible"), PAGE_COMPATIBLE_GROUPS);
commit 66bd7d5d9ca050ba70b21810ec2ce45b041313e8 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 11:21:34 2010 -0400
all instantiations of ResourceGroupListView should set the datasource
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java index d5b2df6..b1f70b7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java @@ -54,6 +54,8 @@ public class ResourceGroupListView extends Table { public ResourceGroupListView(String locatorId, Criteria criteria, String title) { super(locatorId, title, criteria);
+ setHeaderIcon("types/Group_up_24.png"); + final ResourceGroupsDataSource datasource = ResourceGroupsDataSource.getInstance(); setDataSource(datasource); }
commit 24e1e33f51575f54cb217d96b163070378601cb5 Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 02:48:53 2010 -0400
update EventCompositeHistoryView to use latest infrastructure changes:
* merge EventCompositeHistoryTable impl into EventCompositeHistoryView ** delete obsolete the EventCompositeHistoryTable class ** change EventCompositeHistoryView to implement TableSection instead of Table * update EventCompositeDetailsView to implement BookmarkableView ** appropriately update View class to instantiate Details view * expose static factory create methods for resource/group contexts in View class ** remove Resource/Group views in favor of calling static factory create methods * fix typo in displayName for severity column in EventCompositeDatasource
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java index c7df7f4..40dc105 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java @@ -63,7 +63,7 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> { timestamp.setType(FieldType.DATETIME); addField(timestamp);
- DataSourceTextField severity = new DataSourceTextField("severity", "Servity"); + DataSourceTextField severity = new DataSourceTextField("severity", "Severity"); addField(severity);
DataSourceTextField details = new HighlightingDatasourceTextField("details", "Details"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java index 600ad2a..343947b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java @@ -22,47 +22,104 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.common.event;
+import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.TitleOrientation; -import com.smartgwt.client.widgets.Window; +import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.form.fields.TextAreaItem; -import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.VLayout;
+import org.rhq.core.domain.criteria.EventCriteria; +import org.rhq.core.domain.event.composite.EventComposite; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.BookmarkableView; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.ViewId; +import org.rhq.enterprise.gui.coregui.client.ViewPath; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; + /** * @author Joseph Marques */ -public class EventCompositeDetailsView extends VLayout { +public class EventCompositeDetailsView extends VLayout implements BookmarkableView { + + private int eventId; + private EventComposite composite;
- private ListGridRecord eventRecord; + private ViewId viewId; + + public EventCompositeDetailsView(int eventId) { + this.eventId = eventId; + }
- public EventCompositeDetailsView(ListGridRecord eventRecord) { - this.eventRecord = eventRecord; + public EventCompositeDetailsView(EventComposite composite) { + this.composite = composite; }
@Override - protected void onInit() { - super.onInit(); + protected void onDraw() { + super.onDraw(); + + for (Canvas child : getMembers()) { + child.destroy(); + } + + if (this.composite != null) { + show(composite); + } else { + show(eventId); + } + } + + private void show(int eventId) { + EventCriteria criteria = new EventCriteria(); + criteria.addFilterId(eventId); + GWTServiceLookup.getEventService().findEventCompositesByCriteria(criteria, + new AsyncCallback<PageList<EventComposite>>() { + @Override + public void onSuccess(PageList<EventComposite> result) { + EventComposite composite = result.get(0); + show(composite); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failure loading event details", caught); + } + }); + } + + private void show(EventComposite composite) { + for (Canvas child : getMembers()) { + removeChild(child); + } + + if (this.viewId != null) { + viewId.getBreadcrumbs().get(0).setDisplayName("Event Details"); + CoreGUI.refreshBreadCrumbTrail(); + } + + this.composite = composite;
DynamicForm form = new DynamicForm(); form.setWidth100(); form.setHeight100();
StaticTextItem id = new StaticTextItem("id", "Id"); - id.setValue(eventRecord.getAttribute("id")); + id.setValue(composite.getEventId());
StaticTextItem severity = new StaticTextItem("severity", "Severity"); - severity.setValue(eventRecord.getAttribute("severity")); + severity.setValue(composite.getSeverity().name());
StaticTextItem source = new StaticTextItem("source", "Source"); - source.setValue(eventRecord.getAttribute("source")); + source.setValue(composite.getSourceLocation());
StaticTextItem timestamp = new StaticTextItem("timestamp", "Timestamp"); - timestamp.setValue(eventRecord.getAttribute("timestamp")); + timestamp.setValue(composite.getTimestamp());
TextAreaItem detail = new TextAreaItem("details", "Details"); - detail.setValue(eventRecord.getAttribute("details")); + detail.setValue(composite.getEventDetail()); detail.setTitleOrientation(TitleOrientation.TOP); detail.setColSpan(2); detail.setWidth("100%"); @@ -73,20 +130,12 @@ public class EventCompositeDetailsView extends VLayout { addMember(form); }
- public void displayInDialog() { - Window window = new Window(); - window.setTitle("Event Details"); - window.setWidth(800); - window.setHeight(800); - window.setIsModal(true); - window.setShowModalMask(true); - window.setCanDragResize(true); - window.centerInPage(); - window.addItem(this); - window.setDismissOnEscape(true); - window.setDismissOnOutsideClick(true); - window.show(); - window.focus(); + @Override + public void renderView(ViewPath viewPath) { + eventId = viewPath.getCurrentAsInt(); + viewId = viewPath.getCurrent(); + + show(eventId); }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java deleted file mode 100644 index e74a169..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.common.event; - -import com.smartgwt.client.types.SortDirection; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.grid.CellFormatter; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent; -import com.smartgwt.client.widgets.grid.events.CellDoubleClickHandler; - -import org.rhq.core.domain.common.EntityContext; -import org.rhq.enterprise.gui.coregui.client.components.table.Table; - -/** - * @author Joseph Marques - */ -public class EventCompositeHistoryTable extends Table { - - public EventCompositeHistoryTable(String tableTitle, EntityContext context) { - super(tableTitle); - - setDataSource(new EventCompositeDatasource(context)); - - ListGrid grid = getListGrid(); - - // getListGrid().getField("id").setWidth(60); - - grid.getField("timestamp").setWidth(125); - grid.getField("timestamp").setSortDirection(SortDirection.DESCENDING); - - grid.getField("severity").setWidth(75); - grid.getField("severity").setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { - return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o; - } - }); - - grid.getField("source").setWidth(275); - grid.getField("source").setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { - String sourceLocation = (String) o; - int length = sourceLocation.length(); - if (length > 40) { - return "..." + sourceLocation.substring(length - 40); // the last 40 chars - } - return sourceLocation; - } - }); - - setupTableInteractions(); - - grid.sort(); // will sort by timestamp, whose default ordering is descending - } - - private void setupTableInteractions() { - getListGrid().addCellDoubleClickHandler(new CellDoubleClickHandler() { - public void onCellDoubleClick(CellDoubleClickEvent cellDoubleClickEvent) { - ListGridRecord record = cellDoubleClickEvent.getRecord(); - EventCompositeDetailsView detailsView = new EventCompositeDetailsView(record); - detailsView.displayInDialog(); - } - }); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java index 3de4d04..b9434f0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java @@ -26,18 +26,22 @@ import java.util.ArrayList; import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.types.MultipleAppearance; -import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.data.SortSpecifier; +import com.smartgwt.client.types.SortDirection; +import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.EventSeverity; +import org.rhq.core.domain.resource.composite.ResourceComposite; +import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.components.form.TableFilterForm; +import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; -import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement; +import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.message.Message; import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; @@ -45,114 +49,130 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; /** * @author Joseph Marques */ -public abstract class EventCompositeHistoryView extends VLayout { +public class EventCompositeHistoryView extends TableSection {
- private EventCompositeHistoryTable eventCompositeHistoryTable; - private EntityContext entityContext; - private boolean permitted; + private static SortSpecifier DEFAULT_SORT_SPECIFIER = new SortSpecifier("timestamp", SortDirection.DESCENDING); + private EntityContext context; + private boolean hasWriteAccess;
- public EventCompositeHistoryView() { - setWidth100(); - setHeight100(); - setMembersMargin(10); + public static EventCompositeHistoryView get(ResourceGroupComposite composite) { + String tableTitle = "Group Event History"; + EntityContext context = EntityContext.forGroup(composite.getResourceGroup().getId()); + boolean hasWriteAccess = composite.getResourcePermission().isEvent(); + return new EventCompositeHistoryView(tableTitle, context, hasWriteAccess); }
- @Override - protected void onInit() { - super.onInit(); + public static EventCompositeHistoryView get(ResourceComposite composite) { + String tableTitle = "Resource Event History"; + EntityContext context = EntityContext.forResource(composite.getResource().getId()); + boolean hasWriteAccess = composite.getResourcePermission().isEvent(); + return new EventCompositeHistoryView(tableTitle, context, hasWriteAccess); + }
- entityContext = getEntityContext(); - eventCompositeHistoryTable = new EventCompositeHistoryTable(getTableTitle(), entityContext); - permitted = checkModifyPermission(); + private EventCompositeHistoryView(String tableTitle, EntityContext context, boolean hasWriteAccess) { + super("EventCompositeHistoryTable", tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER }); + this.context = context; + this.hasWriteAccess = hasWriteAccess;
- setupTableFilters(); - setupTableContents(); + setDataSource(new EventCompositeDatasource(this.context)); }
- private void setupTableFilters() { - TableFilterForm form = new TableFilterForm(eventCompositeHistoryTable); - + @Override + protected void configureTableFilters() { final TextItem sourceFilter = new TextItem("source", "Source Filter"); final TextItem detailsFilter = new TextItem("details", "Details Filter"); + final EnumSelectItem severityFilter = new EnumSelectItem("severities", "Severity Filter", EventSeverity.class);
- final SelectItem severityMultiFilter = new SelectItem("severities", "Severity Filter"); - severityMultiFilter.setMultiple(true); - severityMultiFilter.setMultipleAppearance(MultipleAppearance.PICKLIST); - String[] severities = new String[EventSeverity.values().length]; - int i = 0; - for (EventSeverity nextOption : EventSeverity.values()) { - severities[i++] = nextOption.name(); - } - severityMultiFilter.setValueMap(severities); - severityMultiFilter.setValues(severities); // select them all by default - - form.setItems(sourceFilter, detailsFilter, severityMultiFilter); - addMember(form); + setFilterFormItems(sourceFilter, detailsFilter, severityFilter); }
- private void setupTableContents() { - eventCompositeHistoryTable.addTableAction("deleteButton", "Delete", (permitted) ? SelectionEnablement.ANY - : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { - public void executeAction(ListGridRecord[] selection) { - deleteButtonPressed(selection); + @Override + protected void configureTable() { + ListGrid grid = getListGrid(); + + // getListGrid().getField("id").setWidth(60); + + grid.getField("timestamp").setWidth(125); + + grid.getField("severity").setWidth(75); + grid.getField("severity").setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { + return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o; } });
- eventCompositeHistoryTable.addTableAction("purgeAllButton", "Purge All", - (permitted) ? SelectionEnablement.ALWAYS : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { - public void executeAction(ListGridRecord[] selection) { - purgeButtonPressed(); + grid.getField("source").setWidth(275); + grid.getField("source").setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { + String sourceLocation = (String) o; + int length = sourceLocation.length(); + if (length > 40) { + return "..." + sourceLocation.substring(length - 40); // the last 40 chars } - }); + return sourceLocation; + } + });
- addMember(eventCompositeHistoryTable); + setupTableInteractions(); }
- protected abstract String getTableTitle(); - - protected abstract EntityContext getEntityContext(); + private void setupTableInteractions() { + addTableAction("deleteButton", "Delete", hasWriteAccess ? SelectionEnablement.ANY : SelectionEnablement.NEVER, + "Are You Sure?", new TableAction() { + public void executeAction(ListGridRecord[] selection) { + deleteButtonPressed(selection); + } + });
- protected abstract boolean checkModifyPermission(); + addTableAction("purgeAllButton", "Purge All", hasWriteAccess ? SelectionEnablement.ALWAYS + : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { + public void executeAction(ListGridRecord[] selection) { + purgeButtonPressed(); + } + }); + }
private void deleteButtonPressed(ListGridRecord[] selection) { List<Integer> eventIds = new ArrayList<Integer>(); for (ListGridRecord nextRecord : selection) { eventIds.add(nextRecord.getAttributeAsInt("id")); } - GWTServiceLookup.getEventService().deleteEventsForContext(entityContext, eventIds, - new AsyncCallback<Integer>() { - @Override - public void onSuccess(Integer result) { - CoreGUI.getMessageCenter().notify( - new Message("Successfully deleted " + result + " events for " + entityContext.toShortString(), - Severity.Info)); - eventCompositeHistoryTable.refresh(); - } + GWTServiceLookup.getEventService().deleteEventsForContext(context, eventIds, new AsyncCallback<Integer>() { + @Override + public void onSuccess(Integer result) { + CoreGUI.getMessageCenter().notify( + new Message("Successfully deleted " + result + " events for " + context.toShortString(), + Severity.Info)); + refresh(); + }
- @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError( - "Failed to delete selected events for " + entityContext.toShortString(), caught); - } - }); + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError( + "Failed to delete selected events for " + context.toShortString(), caught); + } + }); }
private void purgeButtonPressed() { - GWTServiceLookup.getEventService().purgeEventsForContext(entityContext, new AsyncCallback<Integer>() { + GWTServiceLookup.getEventService().purgeEventsForContext(context, new AsyncCallback<Integer>() { @Override public void onSuccess(Integer result) { CoreGUI.getMessageCenter().notify( - new Message("Successfully purged " + result + " events for " + entityContext.toShortString(), + new Message("Successfully purged " + result + " events for " + context.toShortString(), Severity.Info)); - eventCompositeHistoryTable.refresh(); + refresh(); }
@Override public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to purge events for " + entityContext.toShortString(), - caught); + CoreGUI.getErrorHandler().handleError("Failed to purge events for " + context.toShortString(), caught); } }); }
+ @Override + public Canvas getDetailsView(int eventId) { + return new EventCompositeDetailsView(eventId); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 966e4c6..59997b4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -46,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedE import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler; import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.event.GroupEventCompositeHistoryView; +import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView; @@ -223,7 +223,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar configurationTab.updateSubTab(this.configCurrent); configurationTab.updateSubTab(this.configHistory);
- this.eventHistory.setCanvas(new GroupEventCompositeHistoryView(groupId)); + this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite)); eventsTab.updateSubTab(this.eventHistory);
// topTabSet.setSelectedTab(selectedTab); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java deleted file mode 100644 index 0b24878..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.event; - -import org.rhq.core.domain.common.EntityContext; -import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; - -/** - * @author Joseph Marques - */ -public class GroupEventCompositeHistoryView extends EventCompositeHistoryView { - - private int groupId; - - public GroupEventCompositeHistoryView(int groupId) { - super(); - this.groupId = groupId; - } - - @Override - public String getTableTitle() { - return "Group Event History"; - } - - @Override - public EntityContext getEntityContext() { - return EntityContext.forGroup(groupId); - } - - @Override - protected boolean checkModifyPermission() { - return true; // does the user have Permission.MANAGE_EVENTS ? - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index 82c362e..e43ccef 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -45,11 +45,11 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedE import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler; import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event.ResourceEventCompositeHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView; @@ -269,7 +269,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable configurationTab.updateSubTab(this.configCurrent); configurationTab.updateSubTab(this.configHistory);
- this.eventHistory.setCanvas(new ResourceEventCompositeHistoryView(resource.getId())); + this.eventHistory.setCanvas(EventCompositeHistoryView.get(resourceComposite)); eventsTab.updateSubTab(this.eventHistory);
this.contentDeployed diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java deleted file mode 100644 index d2fb5d8..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event; - -import org.rhq.core.domain.common.EntityContext; -import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; - -/** - * @author Joseph Marques - */ -public class ResourceEventCompositeHistoryView extends EventCompositeHistoryView { - - private int resourceId; - - public ResourceEventCompositeHistoryView(int resourceId) { - super(); - this.resourceId = resourceId; - } - - @Override - public String getTableTitle() { - return "Resource Event History"; - } - - @Override - public EntityContext getEntityContext() { - return EntityContext.forResource(resourceId); - } - - @Override - protected boolean checkModifyPermission() { - return true; // does the user have Permission.MANAGE_EVENTS ? - } -}
commit 739b97deab7144a1e4d659bbd649dc02f4c976ff Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 02:42:48 2010 -0400
infrastructure component enhancements:
* move TableFilterForm inside Table...rename to TableFilter * add EnumSelectItem as convenience wrapper for creating multi-select form items for enums, automatically constructing the value map
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnumSelectItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnumSelectItem.java new file mode 100644 index 0000000..e1a09fe --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnumSelectItem.java @@ -0,0 +1,81 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.components.form; + +import java.util.EnumSet; +import java.util.LinkedHashMap; +import java.util.Set; + +import com.google.gwt.core.client.JavaScriptObject; +import com.smartgwt.client.types.MultipleAppearance; +import com.smartgwt.client.widgets.form.fields.SelectItem; + +/** + * A convenients class for exposing an {@link Enum} as a multi-select form item. + * + * @author Joseph Marques + */ +public class EnumSelectItem extends SelectItem { + + public EnumSelectItem(Class<? extends Enum<?>> e) { + super(); + init(e); + } + + public EnumSelectItem(JavaScriptObject jsObj, Class<? extends Enum<?>> e) { + super(jsObj); + init(e); + } + + public EnumSelectItem(String name, Class<? extends Enum<?>> e) { + super(name); + init(e); + } + + public EnumSelectItem(String name, String title, Class<? extends Enum<?>> e) { + super(name, title); + init(e); + } + + public void init(Class<? extends Enum<?>> e) { + setMultiple(true); + setMultipleAppearance(MultipleAppearance.PICKLIST); + + LinkedHashMap<String, String> valueMap = getEnumValueMap(e); + Set<String> keys = valueMap.keySet(); + + setValueMap(valueMap); + setValues(keys.toArray(new String[keys.size()])); // select them all by default + } + + @SuppressWarnings("unchecked") + private LinkedHashMap<String, String> getEnumValueMap(Class<? extends Enum> e) { + LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); + for (Object o : EnumSet.allOf(e)) { + Enum v = (Enum) o; + map.put(v.name(), v.toString()); + } + return map; + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java deleted file mode 100644 index 8687ea5..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.enterprise.gui.coregui.client.components.form; - -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.FormItem; -import com.smartgwt.client.widgets.form.fields.SelectItem; -import com.smartgwt.client.widgets.form.fields.TextItem; -import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; -import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; -import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent; -import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler; - -import org.rhq.enterprise.gui.coregui.client.components.table.Table; - -/** - * A subclass of SmartGWT's DynamicForm widget that provides a more convenient interface for filtering a {@link Table} - * of results. - * - * @author Joseph Marques - */ -public class TableFilterForm extends DynamicForm implements KeyPressHandler, ChangedHandler { - - private Table table; - - public TableFilterForm(Table table) { - super(); - setWidth100(); - this.table = table; - this.table.setTableTitle(null); - } - - @Override - public void setItems(FormItem... items) { - super.setItems(items); - setupFormItems(items); - } - - private void setupFormItems(FormItem... formItems) { - for (FormItem nextFormItem : formItems) { - nextFormItem.setWrapTitle(false); - nextFormItem.setWidth(300); // wider than default - if (nextFormItem instanceof TextItem) { - nextFormItem.addKeyPressHandler(this); - } else if (nextFormItem instanceof SelectItem) { - nextFormItem.addChangedHandler(this); - } - } - } - - private void fetchFilteredTableData() { - table.refresh(getValuesAsCriteria()); - } - - public void onKeyPress(KeyPressEvent event) { - if (event.getKeyName().equals("Enter") == false) { - return; - } - fetchFilteredTableData(); - } - - public void onChanged(ChangedEvent event) { - fetchFilteredTableData(); - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index c26ccef..a18d6f8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -35,6 +35,14 @@ import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent; +import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.events.DataArrivedEvent; import com.smartgwt.client.widgets.grid.events.DataArrivedHandler; @@ -65,6 +73,7 @@ public class Table extends LocatableHLayout { private HLayout titleLayout; private Canvas titleComponent;
+ private TableFilter filterForm; private ListGrid listGrid; private ToolStrip footer; private Label tableInfo; @@ -157,6 +166,9 @@ public class Table extends LocatableHLayout { protected void onInit() { super.onInit();
+ filterForm = new TableFilter(this); + configureTableFilters(); + listGrid = new LocatableListGrid(getLocatorId()); listGrid.setAutoFetchData(autoFetchData);
@@ -216,6 +228,10 @@ public class Table extends LocatableHLayout { contents.addMember(titleLayout, 0); }
+ if (filterForm.hasContent()) { + contents.addMember(filterForm); + } + contents.addMember(listGrid);
// Footer @@ -324,6 +340,18 @@ public class Table extends LocatableHLayout { } }
+ public void setFilterFormItems(FormItem... formItems) { + this.filterForm.setItems(formItems); + } + + /** + * Overriding components can use this as a chance to add {@link FormItem}s which will filter + * the table that displays their data. + */ + protected void configureTableFilters() { + + } + /** * Overriding components can use this as a chance to configure the list grid after it has been * created but before it has been drawn to the DOM. This is also the proper place to add table @@ -480,7 +508,63 @@ public class Table extends LocatableHLayout { } }
- // -------------- Inner utility class ------------- + // -------------- Inner utility classes ------------- // + + /** + * A subclass of SmartGWT's DynamicForm widget that provides a more convenient interface for filtering a {@link Table} + * of results. + * + * @author Joseph Marques + */ + private static class TableFilter extends DynamicForm implements KeyPressHandler, ChangedHandler { + + private Table table; + + public TableFilter(Table table) { + super(); + setWidth100(); + this.table = table; + //this.table.setTableTitle(null); + } + + @Override + public void setItems(FormItem... items) { + super.setItems(items); + setupFormItems(items); + } + + private void setupFormItems(FormItem... formItems) { + for (FormItem nextFormItem : formItems) { + nextFormItem.setWrapTitle(false); + nextFormItem.setWidth(300); // wider than default + if (nextFormItem instanceof TextItem) { + nextFormItem.addKeyPressHandler(this); + } else if (nextFormItem instanceof SelectItem) { + nextFormItem.addChangedHandler(this); + } + } + } + + private void fetchFilteredTableData() { + table.refresh(getValuesAsCriteria()); + } + + public void onKeyPress(KeyPressEvent event) { + if (event.getKeyName().equals("Enter") == false) { + return; + } + fetchFilteredTableData(); + } + + public void onChanged(ChangedEvent event) { + fetchFilteredTableData(); + } + + public boolean hasContent() { + return super.getFields().length != 0; + } + + }
private static class TableActionInfo {
commit 96ecc5267928948c3c96123b5e05f715c7dcbbbf Author: Joseph Marques joseph@redhat.com Date: Fri Aug 27 02:36:46 2010 -0400
expose the new MANAGE_EVENTS permission to the ResourceComposite level
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java index 40deb43..916bcc7 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java @@ -568,6 +568,7 @@ import org.rhq.core.domain.util.Summary; + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 4), " // we want MODIFY_RESOURCE (4), not VIEW_RESOURCE (3) + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 10), " // we want CONTROL, 10 + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 7), " // we want MANAGE_ALERTS, 7 + + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 14), " // we want MANAGE_EVENTS, 14 + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 13), " // we want CONFIGURE_READ, 13 + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 11), " // we want CONFIGURE_WRITE, 11 + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 9), " // we want MANAGE_CONTENT, 9 @@ -590,6 +591,7 @@ import org.rhq.core.domain.util.Summary; + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 4), " // we want MODIFY_RESOURCE (4), not VIEW_RESOURCE (3) + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 10), " // we want CONTROL, 10 + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 7), " // we want MANAGE_ALERTS, 7 + + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 14), " // we want MANAGE_EVENTS, 14 + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 13), " // we want CONFIGURE_READ, 13 + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 11), " // we want CONFIGURE_WRITE, 11 + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 9), " // we want MANAGE_CONTENT, 9 diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java index 823a785..9f22d68 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java @@ -74,22 +74,24 @@ public class ResourceComposite implements Serializable { * Provides specified permissions - used for non-admin queries. */ public ResourceComposite(Resource resource, AvailabilityType availability, Number measure, Number inventory, - Number control, Number alert, Number configureRead, Number configureWrite, Number content, + Number control, Number alert, Number event, Number configureRead, Number configureWrite, Number content, Number createChildResources, Number deleteResources) { this(resource, null, availability, new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0, - control.intValue() > 0, alert.intValue() > 0, configureRead.intValue() > 0, configureWrite.intValue() > 0, - content.intValue() > 0, createChildResources.intValue() > 0, deleteResources.intValue() > 0)); + control.intValue() > 0, alert.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0, + configureWrite.intValue() > 0, content.intValue() > 0, createChildResources.intValue() > 0, deleteResources + .intValue() > 0)); }
/** * Provides specified permissions - used for non-admin queries. */ public ResourceComposite(Resource resource, Resource parent, AvailabilityType availability, Number measure, - Number inventory, Number control, Number alert, Number configureRead, Number configureWrite, Number content, - Number createChildResources, Number deleteResources) { + Number inventory, Number control, Number alert, Number event, Number configureRead, Number configureWrite, + Number content, Number createChildResources, Number deleteResources) { this(resource, parent, availability, new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0, - control.intValue() > 0, alert.intValue() > 0, configureRead.intValue() > 0, configureWrite.intValue() > 0, - content.intValue() > 0, createChildResources.intValue() > 0, deleteResources.intValue() > 0)); + control.intValue() > 0, alert.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0, + configureWrite.intValue() > 0, content.intValue() > 0, createChildResources.intValue() > 0, deleteResources + .intValue() > 0)); }
/** diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java index ee8e8a8..e75fa14 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java @@ -43,6 +43,8 @@ public class ResourcePermission implements Serializable {
private boolean alert;
+ private boolean event; + private boolean configureRead;
private boolean configureWrite; @@ -57,7 +59,7 @@ public class ResourcePermission implements Serializable { * All permissions */ public ResourcePermission() { - this(true, true, true, true, true, true, true, true, true); + this(true, true, true, true, true, true, true, true, true, true); }
public ResourcePermission(// @@ -65,6 +67,7 @@ public class ResourcePermission implements Serializable { boolean inventory, // boolean control, // boolean alert, // + boolean event, // boolean configureRead, // boolean configureWrite, // boolean content, // @@ -74,6 +77,7 @@ public class ResourcePermission implements Serializable { this.inventory = inventory; this.control = control; this.alert = alert; + this.event = event; this.configureRead = configureRead; this.configureWrite = configureWrite; this.content = content; @@ -86,6 +90,7 @@ public class ResourcePermission implements Serializable { permissions.contains(Permission.MODIFY_RESOURCE),// permissions.contains(Permission.CONTROL), // permissions.contains(Permission.MANAGE_ALERTS), // + permissions.contains(Permission.MANAGE_EVENTS), // permissions.contains(Permission.CONFIGURE_READ), // permissions.contains(Permission.CONFIGURE_WRITE), // permissions.contains(Permission.MANAGE_CONTENT), // @@ -109,6 +114,10 @@ public class ResourcePermission implements Serializable { return alert; }
+ public boolean isEvent() { + return event; + } + public boolean isConfigureRead() { return configureRead; } @@ -136,6 +145,7 @@ public class ResourcePermission implements Serializable { "inventory: " + inventory + ", " + // "control: " + control + ", " + // "alert: " + alert + ", " + // + "event: " + event + ", " + // "configure-read: " + configureRead + ", " + // "configure-write: " + configureWrite + ", " + // "content: " + content + ", " + //
commit db9494f4420d200904fe7a694e9a8acc8dd75f1f Author: Joseph Marques joseph@redhat.com Date: Wed Aug 25 16:42:28 2010 -0400
change JSP import to use new location of EntityContext
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp index 0bad7a1..5b4320e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp @@ -1,4 +1,5 @@ <%@ page import="org.rhq.core.domain.auth.Subject" %> +<%@ page import="org.rhq.core.domain.common.EntityContext"%> <%@ page import="org.rhq.core.domain.event.composite.EventComposite" %> <%@ page import="org.rhq.core.domain.util.OrderingField" %> <%@ page import="org.rhq.core.domain.util.PageControl" %> @@ -14,7 +15,6 @@ <%@ page import="java.util.regex.Pattern"%> <%@ page import="java.util.*"%> <%@ page import="org.rhq.core.domain.event.EventSeverity"%> -<%@ page import="org.rhq.enterprise.server.common.EntityContext"%> <%@ page import="org.rhq.core.domain.util.PageOrdering"%> <%@ page contentType="text/javascript" language="java" %>
commit 70795ef4e1a29f10e562f4f6b7f386e52127cd56 Author: Joseph Marques joseph@redhat.com Date: Wed Aug 25 11:25:29 2010 -0400
add locatorID for buttons to adhere to modified API for addTableAction
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java index ea5cd03..3de4d04 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java @@ -91,19 +91,19 @@ public abstract class EventCompositeHistoryView extends VLayout { }
private void setupTableContents() { - eventCompositeHistoryTable.addTableAction("Delete", (permitted) ? SelectionEnablement.ANY + eventCompositeHistoryTable.addTableAction("deleteButton", "Delete", (permitted) ? SelectionEnablement.ANY : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { public void executeAction(ListGridRecord[] selection) { deleteButtonPressed(selection); } });
- eventCompositeHistoryTable.addTableAction("Purge All", (permitted) ? SelectionEnablement.ALWAYS - : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { - public void executeAction(ListGridRecord[] selection) { - purgeButtonPressed(); - } - }); + eventCompositeHistoryTable.addTableAction("purgeAllButton", "Purge All", + (permitted) ? SelectionEnablement.ALWAYS : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { + public void executeAction(ListGridRecord[] selection) { + purgeButtonPressed(); + } + });
addMember(eventCompositeHistoryTable); }
commit d3db6bf1337204344e59a0938fc5e74d0419bc06 Author: Joseph Marques joseph@redhat.com Date: Wed Aug 25 09:47:29 2010 -0400
improve error message handling when failing to log into coregui
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java index d534aca..82d010d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java @@ -58,7 +58,6 @@ public class LoginView extends Canvas {
private SubmitItem loginButton;
- public LoginView() { this(false); } @@ -97,7 +96,6 @@ public class LoginView extends Canvas { HeaderItem header = new HeaderItem(); header.setValue("RHQ Login");
- TextItem user = new TextItem("user", "User"); user.setRequired(true); user.setAttribute("autoComplete", "native"); @@ -126,7 +124,6 @@ public class LoginView extends Canvas {
form.setFields(logo, header, user, password, loginButton);
- window = new Window(); window.setTitle("RHQ Login"); window.setWidth(400); @@ -158,38 +155,35 @@ public class LoginView extends Canvas { }
loginButton.setDisabled(true); - RequestBuilder b = new RequestBuilder(RequestBuilder.GET, - "/j_security_check.do?j_username=" + user + "&j_password=" + password); + try { + RequestBuilder b = new RequestBuilder(RequestBuilder.GET, "/j_security_check.do?j_username=" + user + + "&j_password=" + password); b.setCallback(new RequestCallback() { public void onResponseReceived(Request request, Response response) { - if (response.getStatusCode() == 200) { - System.out.println("Portal-War logged in"); + int statusCode = response.getStatusCode(); + if (statusCode == 200) { window.destroy(); loginShowing = false; CoreGUI.checkLoginStatus(); } else { - form.setFieldErrors("login", "The username or password provided does not match our records.", true); - loginButton.setDisabled(false); + handleError(statusCode); } }
public void onError(Request request, Throwable exception) { - System.out.println("Portal-War login failed"); - loginButton.setDisabled(false); + handleError(0); } }); b.send(); } catch (Exception e) { - loginButton.setDisabled(false); - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + handleError(0); } finally { if (CoreGUI.detectIe6()) { CoreGUI.unforceIe6Hacks(); } }
- /* SubjectGWTServiceAsync subjectService = SubjectGWTServiceAsync.Util.getInstance();
@@ -205,16 +199,25 @@ public class LoginView extends Canvas { CoreGUI.setSessionSubject(result);
*//* We can cache all metadata right here - ResourceTypeRepository.Cache.getInstance().getResourceTypes( + ResourceTypeRepository.Cache.getInstance().getResourceTypes( (Integer[]) null, EnumSet.allOf(ResourceTypeRepository.MetadataType.class), new ResourceTypeRepository.TypesLoadedCallback() { public void onTypesLoaded(HashMap<Integer, ResourceType> types) { System.out.println("Preloaded [" + types.size() + "] resource types"); buildCoreUI(); } - }); - *//* - } - }); */ + }); + *//* + } + }); */ + + }
+ private void handleError(int statusCode) { + if (statusCode == 401) { + form.setFieldErrors("login", "The username or password provided does not match our records", true); + } else { + form.setFieldErrors("login", "The server could data source is unavailable", true); + } + loginButton.setDisabled(false); } }
commit ee01ad67f5fd45bed6589a48dea84129c5096617 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 22:18:17 2010 -0400
concrete implementation of event>history sub-tab for groups (mixed and compat)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index d8f83ab..966e4c6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -46,6 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedE import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler; import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.event.GroupEventCompositeHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView; @@ -198,6 +199,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId)); inventoryTab.updateSubTab(this.inventoryMembers); + // inventoryTab.updateSubTab("Connection Settings", new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" @@ -221,7 +223,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar configurationTab.updateSubTab(this.configCurrent); configurationTab.updateSubTab(this.configHistory);
- this.eventHistory.setCanvas(new FullHTMLPane("/rhq/group/events/history-plain.xhtml?groupId=" + groupId)); + this.eventHistory.setCanvas(new GroupEventCompositeHistoryView(groupId)); eventsTab.updateSubTab(this.eventHistory);
// topTabSet.setSelectedTab(selectedTab); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java new file mode 100644 index 0000000..0b24878 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java @@ -0,0 +1,54 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.event; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; + +/** + * @author Joseph Marques + */ +public class GroupEventCompositeHistoryView extends EventCompositeHistoryView { + + private int groupId; + + public GroupEventCompositeHistoryView(int groupId) { + super(); + this.groupId = groupId; + } + + @Override + public String getTableTitle() { + return "Group Event History"; + } + + @Override + public EntityContext getEntityContext() { + return EntityContext.forGroup(groupId); + } + + @Override + protected boolean checkModifyPermission() { + return true; // does the user have Permission.MANAGE_EVENTS ? + } +}
commit c7596b299f47773f2dabc92a22b918b5d01c7f36 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 22:17:55 2010 -0400
concrete implementation of event>history sub-tab for resources
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index f0e1c3f..82c362e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event.ResourceEventCompositeHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView; @@ -202,9 +203,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable this.titleBar.setResource(resource);
for (Tab top : topTabSet.getTabs()) { - ((TwoLevelTab) top).getLayout().destroyViews(); - }
this.summaryOverview.setCanvas(new OverviewView(this.resourceComposite)); @@ -239,10 +238,10 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable // 1) user can delete history if they possess the appropriate permissions // 2) user can see both operation arguments and results in the history details pop-up // 3) operation arguments/results become read-only configuration data in the history details pop-up - // 4) user can navigate to the group operation that spawned this resource operation history, if appropriate + // 4) user can navigate to the group operation that spawned this resource operation history, if appropriate + // note: enabled operation execution/schedules from left-nav, if it doesn't already exist this.opHistory.setCanvas(OperationHistoryView.getResourceHistoryView(operationsTab.extendLocatorId("History"), resourceComposite)); - // note: enabled operation execution/schedules from left-nav, if it doesn't already exist this.opSched.setCanvas(new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId())); operationsTab.updateSubTab(this.opHistory); @@ -254,7 +253,6 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable // 3) user can enable/disable/delete alert definitions if they possess the appropriate permissions // 4) user can search alert history by: date alert was fired, alert priority, or alert definition //alertsTab.updateSubTab("History", new ResourceAlertHistoryView(resource.getId())); - this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" + resource.getId())); this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("Def"), resource)); @@ -271,13 +269,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable configurationTab.updateSubTab(this.configCurrent); configurationTab.updateSubTab(this.configHistory);
- // comment out GWT-based view until... - // 1) user can search event history by: metric display range, event source, event details, event severity - // 2) user can delete events if they possess the appropriate permissions - //eventsTab.updateSubTab("History", EventHistoryView.createResourceHistoryView(resource.getId())); - - this.eventHistory - .setCanvas(new FullHTMLPane("/rhq/resource/events/history-plain.xhtml?id=" + resource.getId())); + this.eventHistory.setCanvas(new ResourceEventCompositeHistoryView(resource.getId())); eventsTab.updateSubTab(this.eventHistory);
this.contentDeployed diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java new file mode 100644 index 0000000..d2fb5d8 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java @@ -0,0 +1,54 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView; + +/** + * @author Joseph Marques + */ +public class ResourceEventCompositeHistoryView extends EventCompositeHistoryView { + + private int resourceId; + + public ResourceEventCompositeHistoryView(int resourceId) { + super(); + this.resourceId = resourceId; + } + + @Override + public String getTableTitle() { + return "Resource Event History"; + } + + @Override + public EntityContext getEntityContext() { + return EntityContext.forResource(resourceId); + } + + @Override + protected boolean checkModifyPermission() { + return true; // does the user have Permission.MANAGE_EVENTS ? + } +}
commit abd053238b39a75051638bb1923f8d68094b6c83 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 22:17:29 2010 -0400
reusable base classes for event>history views
* supports full feature parity with existing JSF views including sorting, scrolling (pagination), and filtering, and table actions * filtering support: event details, event source/location, event severity * table actions support: delete selected events, purge all events for the given context (resource, group, auto-group), double-click row item displays modal panel with full details in a large text area input * enhancement: will highlight in-line matches for event details filter
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java new file mode 100644 index 0000000..c7df7f4 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java @@ -0,0 +1,147 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.common.event; + +import java.util.Map; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.DSRequest; +import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.data.fields.DataSourceTextField; +import com.smartgwt.client.rpc.RPCResponse; +import com.smartgwt.client.types.FieldType; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.core.domain.criteria.EventCriteria; +import org.rhq.core.domain.event.EventSeverity; +import org.rhq.core.domain.event.composite.EventComposite; +import org.rhq.core.domain.util.PageControl; +import org.rhq.core.domain.util.PageList; +import org.rhq.core.domain.util.PageOrdering; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.HighlightingDatasourceTextField; +import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; + +/** + * @author Joseph Marques + */ +public class EventCompositeDatasource extends RPCDataSource<EventComposite> { + + private EntityContext entityContext; + + public EventCompositeDatasource(EntityContext context) { + super(); + this.entityContext = context; + + // DataSourceField id = new DataSourceIntegerField("id", "Id"); + // id.setPrimaryKey(true); + // addField(id); + + DataSourceTextField timestamp = new DataSourceTextField("timestamp", "Timestamp"); + timestamp.setType(FieldType.DATETIME); + addField(timestamp); + + DataSourceTextField severity = new DataSourceTextField("severity", "Servity"); + addField(severity); + + DataSourceTextField details = new HighlightingDatasourceTextField("details", "Details"); + addField(details); + + DataSourceTextField sourceLocation = new DataSourceTextField("source", "Source Location"); + addField(sourceLocation); + } + + @Override + public EventComposite copyValues(ListGridRecord from) { + return null; // TODO: Implement this method. + } + + @Override + public ListGridRecord copyValues(EventComposite from) { + ListGridRecord record = new ListGridRecord(); + + record.setAttribute("id", from.getEventId()); + record.setAttribute("timestamp", from.getTimestamp()); + record.setAttribute("details", from.getEventDetail()); + record.setAttribute("severity", from.getSeverity().name()); + record.setAttribute("source", from.getSourceLocation()); + + return record; + } + + @Override + protected void executeFetch(final DSRequest request, final DSResponse response) { + EventCriteria criteria = getFetchCriteria(request); + + GWTServiceLookup.getEventService().findEventCompositesByCriteria(criteria, + new AsyncCallback<PageList<EventComposite>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load event data", caught); + response.setStatus(RPCResponse.STATUS_FAILURE); + } + + public void onSuccess(PageList<EventComposite> result) { + ListGridRecord[] records = buildRecords(result); + highlightFilterMatches(request, records); + response.setData(records); + response.setTotalRows(result.getTotalSize()); + processResponse(request.getRequestId(), response); + } + }); + } + + @SuppressWarnings("unchecked") + protected EventCriteria getFetchCriteria(final DSRequest request) { + EventCriteria criteria = new EventCriteria(); + + PageControl pageControl = getPageControl(request); + if (pageControl.getOrderingFields().isEmpty()) { + criteria.addSortTimestamp(PageOrdering.DESC); // default sort + } else { + criteria.setPageControl(pageControl); + } + + // TODO: This call is broken in 2.2, http://code.google.com/p/smartgwt/issues/detail?id=490 + // when using AdvancedCriteria + Map<String, Object> criteriaMap = request.getCriteria().getValues(); + + criteria.addFilterSourceName((String) criteriaMap.get("source")); + criteria.addFilterDetail((String) criteriaMap.get("details")); + + if (criteriaMap.get("severities") != null) { + String[] severityStrings = criteriaMap.get("severities").toString().split(","); + EventSeverity[] severities = new EventSeverity[severityStrings.length]; + int i = 0; + for (String nextSeverity : severityStrings) { + severities[i++] = EventSeverity.valueOf(nextSeverity); + } + criteria.addFilterSeverities(severities); + } + + criteria.addFilterEntityContext(entityContext); + + return criteria; + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java new file mode 100644 index 0000000..600ad2a --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java @@ -0,0 +1,92 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.common.event; + +import com.smartgwt.client.types.TitleOrientation; +import com.smartgwt.client.widgets.Window; +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.TextAreaItem; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.layout.VLayout; + +/** + * @author Joseph Marques + */ +public class EventCompositeDetailsView extends VLayout { + + private ListGridRecord eventRecord; + + public EventCompositeDetailsView(ListGridRecord eventRecord) { + this.eventRecord = eventRecord; + } + + @Override + protected void onInit() { + super.onInit(); + + DynamicForm form = new DynamicForm(); + form.setWidth100(); + form.setHeight100(); + + StaticTextItem id = new StaticTextItem("id", "Id"); + id.setValue(eventRecord.getAttribute("id")); + + StaticTextItem severity = new StaticTextItem("severity", "Severity"); + severity.setValue(eventRecord.getAttribute("severity")); + + StaticTextItem source = new StaticTextItem("source", "Source"); + source.setValue(eventRecord.getAttribute("source")); + + StaticTextItem timestamp = new StaticTextItem("timestamp", "Timestamp"); + timestamp.setValue(eventRecord.getAttribute("timestamp")); + + TextAreaItem detail = new TextAreaItem("details", "Details"); + detail.setValue(eventRecord.getAttribute("details")); + detail.setTitleOrientation(TitleOrientation.TOP); + detail.setColSpan(2); + detail.setWidth("100%"); + detail.setHeight("100%"); + + form.setItems(id, severity, source, timestamp, detail); + + addMember(form); + } + + public void displayInDialog() { + Window window = new Window(); + window.setTitle("Event Details"); + window.setWidth(800); + window.setHeight(800); + window.setIsModal(true); + window.setShowModalMask(true); + window.setCanDragResize(true); + window.centerInPage(); + window.addItem(this); + window.setDismissOnEscape(true); + window.setDismissOnOutsideClick(true); + window.show(); + window.focus(); + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java new file mode 100644 index 0000000..e74a169 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java @@ -0,0 +1,86 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.common.event; + +import com.smartgwt.client.types.SortDirection; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent; +import com.smartgwt.client.widgets.grid.events.CellDoubleClickHandler; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.enterprise.gui.coregui.client.components.table.Table; + +/** + * @author Joseph Marques + */ +public class EventCompositeHistoryTable extends Table { + + public EventCompositeHistoryTable(String tableTitle, EntityContext context) { + super(tableTitle); + + setDataSource(new EventCompositeDatasource(context)); + + ListGrid grid = getListGrid(); + + // getListGrid().getField("id").setWidth(60); + + grid.getField("timestamp").setWidth(125); + grid.getField("timestamp").setSortDirection(SortDirection.DESCENDING); + + grid.getField("severity").setWidth(75); + grid.getField("severity").setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { + return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o; + } + }); + + grid.getField("source").setWidth(275); + grid.getField("source").setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { + String sourceLocation = (String) o; + int length = sourceLocation.length(); + if (length > 40) { + return "..." + sourceLocation.substring(length - 40); // the last 40 chars + } + return sourceLocation; + } + }); + + setupTableInteractions(); + + grid.sort(); // will sort by timestamp, whose default ordering is descending + } + + private void setupTableInteractions() { + getListGrid().addCellDoubleClickHandler(new CellDoubleClickHandler() { + public void onCellDoubleClick(CellDoubleClickEvent cellDoubleClickEvent) { + ListGridRecord record = cellDoubleClickEvent.getRecord(); + EventCompositeDetailsView detailsView = new EventCompositeDetailsView(record); + detailsView.displayInDialog(); + } + }); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java new file mode 100644 index 0000000..ea5cd03 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java @@ -0,0 +1,158 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.common.event; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.types.MultipleAppearance; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.layout.VLayout; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.core.domain.event.EventSeverity; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.form.TableFilterForm; +import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; +import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; + +/** + * @author Joseph Marques + */ +public abstract class EventCompositeHistoryView extends VLayout { + + private EventCompositeHistoryTable eventCompositeHistoryTable; + private EntityContext entityContext; + private boolean permitted; + + public EventCompositeHistoryView() { + setWidth100(); + setHeight100(); + setMembersMargin(10); + } + + @Override + protected void onInit() { + super.onInit(); + + entityContext = getEntityContext(); + eventCompositeHistoryTable = new EventCompositeHistoryTable(getTableTitle(), entityContext); + permitted = checkModifyPermission(); + + setupTableFilters(); + setupTableContents(); + } + + private void setupTableFilters() { + TableFilterForm form = new TableFilterForm(eventCompositeHistoryTable); + + final TextItem sourceFilter = new TextItem("source", "Source Filter"); + final TextItem detailsFilter = new TextItem("details", "Details Filter"); + + final SelectItem severityMultiFilter = new SelectItem("severities", "Severity Filter"); + severityMultiFilter.setMultiple(true); + severityMultiFilter.setMultipleAppearance(MultipleAppearance.PICKLIST); + String[] severities = new String[EventSeverity.values().length]; + int i = 0; + for (EventSeverity nextOption : EventSeverity.values()) { + severities[i++] = nextOption.name(); + } + severityMultiFilter.setValueMap(severities); + severityMultiFilter.setValues(severities); // select them all by default + + form.setItems(sourceFilter, detailsFilter, severityMultiFilter); + addMember(form); + } + + private void setupTableContents() { + eventCompositeHistoryTable.addTableAction("Delete", (permitted) ? SelectionEnablement.ANY + : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { + public void executeAction(ListGridRecord[] selection) { + deleteButtonPressed(selection); + } + }); + + eventCompositeHistoryTable.addTableAction("Purge All", (permitted) ? SelectionEnablement.ALWAYS + : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() { + public void executeAction(ListGridRecord[] selection) { + purgeButtonPressed(); + } + }); + + addMember(eventCompositeHistoryTable); + } + + protected abstract String getTableTitle(); + + protected abstract EntityContext getEntityContext(); + + protected abstract boolean checkModifyPermission(); + + private void deleteButtonPressed(ListGridRecord[] selection) { + List<Integer> eventIds = new ArrayList<Integer>(); + for (ListGridRecord nextRecord : selection) { + eventIds.add(nextRecord.getAttributeAsInt("id")); + } + GWTServiceLookup.getEventService().deleteEventsForContext(entityContext, eventIds, + new AsyncCallback<Integer>() { + @Override + public void onSuccess(Integer result) { + CoreGUI.getMessageCenter().notify( + new Message("Successfully deleted " + result + " events for " + entityContext.toShortString(), + Severity.Info)); + eventCompositeHistoryTable.refresh(); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError( + "Failed to delete selected events for " + entityContext.toShortString(), caught); + } + }); + } + + private void purgeButtonPressed() { + GWTServiceLookup.getEventService().purgeEventsForContext(entityContext, new AsyncCallback<Integer>() { + @Override + public void onSuccess(Integer result) { + CoreGUI.getMessageCenter().notify( + new Message("Successfully purged " + result + " events for " + entityContext.toShortString(), + Severity.Info)); + eventCompositeHistoryTable.refresh(); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to purge events for " + entityContext.toShortString(), + caught); + } + }); + } + +}
commit 81cb060f2bae643bf13f6f8cf1a65a6cace1723e Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 22:12:41 2010 -0400
reformat, cosmetic
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java index 15c25b0..5846d8d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java @@ -22,8 +22,11 @@ */ package org.rhq.enterprise.gui.coregui.client.gwt;
+import java.util.List; + import com.google.gwt.user.client.rpc.RemoteService;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.EventCriteria; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventSeverity; @@ -36,29 +39,18 @@ import org.rhq.core.domain.util.PageList; */ public interface EventGWTService extends RemoteService {
+ EventSeverity[] getSeverityBuckets(int resourceId, long begin, long end, int numBuckets); + + EventSeverity[] getSeverityBucketsForAutoGroup(int parentResourceId, int resourceTypeId, long begin, long end, + int numBuckets);
- EventSeverity[] getSeverityBuckets( - int resourceId, - long begin, - long end, - int numBuckets); + EventSeverity[] getSeverityBucketsForCompGroup(int resourceGroupId, long begin, long end, int numBuckets);
PageList<Event> findEventsByCriteria(EventCriteria criteria); - EventSeverity[] getSeverityBucketsForAutoGroup( - int parentResourceId, - int resourceTypeId, - long begin, - long end, - int numBuckets);
PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria); - EventSeverity[] getSeverityBucketsForCompGroup(
int deleteEventsForContext(EntityContext context, List<Integer> eventIds); - int resourceGroupId, - long begin, - long end, - int numBuckets);
int purgeEventsForContext(EntityContext context); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java index f61b617..665f370 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java @@ -41,31 +41,29 @@ import org.rhq.enterprise.server.util.LookupUtil; */ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements EventGWTService {
- private EventManagerLocal eventManager = LookupUtil.getEventManager(); + private static final long serialVersionUID = 1L;
+ private EventManagerLocal eventManager = LookupUtil.getEventManager();
public EventSeverity[] getSeverityBuckets(int resourceId, long begin, long end, int numBuckets) { - return SerialUtility.prepare( - eventManager.getSeverityBuckets(getSessionSubject(), resourceId, begin, end, numBuckets), - "EventService.getSeverityBuckets"); + return SerialUtility.prepare(eventManager.getSeverityBuckets(getSessionSubject(), resourceId, begin, end, + numBuckets), "EventService.getSeverityBuckets"); }
- public EventSeverity[] getSeverityBucketsForAutoGroup(int parentResourceId, int resourceTypeId, long begin, long end, int numBuckets) { - return SerialUtility.prepare( - eventManager.getSeverityBucketsForAutoGroup(getSessionSubject(), parentResourceId, resourceTypeId, begin, end, numBuckets), - "EventService.getSeverityBucketsForAutoGroup"); + public EventSeverity[] getSeverityBucketsForAutoGroup(int parentResourceId, int resourceTypeId, long begin, + long end, int numBuckets) { + return SerialUtility.prepare(eventManager.getSeverityBucketsForAutoGroup(getSessionSubject(), parentResourceId, + resourceTypeId, begin, end, numBuckets), "EventService.getSeverityBucketsForAutoGroup"); }
public EventSeverity[] getSeverityBucketsForCompGroup(int resourceGroupId, long begin, long end, int numBuckets) { - return SerialUtility.prepare( - eventManager.getSeverityBucketsForCompGroup(getSessionSubject(), resourceGroupId, begin, end, numBuckets), - "EventService.getSeverityBucketsForCompGroup"); - } + return SerialUtility.prepare(eventManager.getSeverityBucketsForCompGroup(getSessionSubject(), resourceGroupId, + begin, end, numBuckets), "EventService.getSeverityBucketsForCompGroup"); + }
public PageList<Event> findEventsByCriteria(EventCriteria criteria) { - return SerialUtility.prepare( - eventManager.findEventsByCriteria(getSessionSubject(), criteria), - "EventService.findEventsByCriteria"); + return SerialUtility.prepare(eventManager.findEventsByCriteria(getSessionSubject(), criteria), + "EventService.findEventsByCriteria"); }
public PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria) {
commit efaa7ce2368c536aa685a8120ab39a64b280332c Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 22:12:23 2010 -0400
add delete/purge methods to EventGWTService** classes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java index 1b8c87f..15c25b0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java @@ -43,6 +43,7 @@ public interface EventGWTService extends RemoteService { long end, int numBuckets);
+ PageList<Event> findEventsByCriteria(EventCriteria criteria); EventSeverity[] getSeverityBucketsForAutoGroup( int parentResourceId, int resourceTypeId, @@ -53,10 +54,11 @@ public interface EventGWTService extends RemoteService { PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria); EventSeverity[] getSeverityBucketsForCompGroup(
+ int deleteEventsForContext(EntityContext context, List<Integer> eventIds); int resourceGroupId, long begin, long end, int numBuckets);
- PageList<Event> findEventsByCriteria(EventCriteria criteria); + int purgeEventsForContext(EntityContext context); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java index 957d9c2..f61b617 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java @@ -22,6 +22,9 @@ */ package org.rhq.enterprise.gui.coregui.server.gwt;
+import java.util.List; + +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.EventCriteria; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventSeverity; @@ -69,4 +72,13 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event return SerialUtility.prepare(eventManager.findEventCompositesByCriteria(getSessionSubject(), criteria), "EventService.findEventsByCriteria"); } + + public int deleteEventsForContext(EntityContext context, List<Integer> eventIds) { + return eventManager.deleteEventsForContext(getSessionSubject(), context, eventIds); + } + + public int purgeEventsForContext(EntityContext context) { + return eventManager.purgeEventsForContext(getSessionSubject(), context); + } + }
commit 93768d38ede3cd73b35cecac8be0ee26853b7cc5 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 22:11:21 2010 -0400
update EventGWTService** classes to retrieve EventComposite data by Criteria
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java index 04b967b..1b8c87f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java @@ -27,10 +27,12 @@ import com.google.gwt.user.client.rpc.RemoteService; import org.rhq.core.domain.criteria.EventCriteria; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventSeverity; +import org.rhq.core.domain.event.composite.EventComposite; import org.rhq.core.domain.util.PageList;
/** * @author Greg Hinkle + * @author Joseph Marques */ public interface EventGWTService extends RemoteService {
@@ -48,6 +50,7 @@ public interface EventGWTService extends RemoteService { long end, int numBuckets);
+ PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria); EventSeverity[] getSeverityBucketsForCompGroup(
int resourceGroupId, diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java index cdfd2cb..957d9c2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java @@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt; import org.rhq.core.domain.criteria.EventCriteria; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventSeverity; +import org.rhq.core.domain.event.composite.EventComposite; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.gwt.EventGWTService; import org.rhq.enterprise.gui.coregui.server.util.SerialUtility; @@ -33,6 +34,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
/** * @author Greg Hinkle + * @author Joseph Marques */ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements EventGWTService {
@@ -62,4 +64,9 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event eventManager.findEventsByCriteria(getSessionSubject(), criteria), "EventService.findEventsByCriteria"); } + + public PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria) { + return SerialUtility.prepare(eventManager.findEventCompositesByCriteria(getSessionSubject(), criteria), + "EventService.findEventsByCriteria"); + } }
commit fb0e601f0f7cfaf52d057dbcdb39f2eb6a6923dd Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 22:06:50 2010 -0400
remove existing GWT-based Event views
* these will be replaced by EventComposite views to reduce DB roundtrips as well as payload between (UI) client and (web) server
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDatasource.java deleted file mode 100644 index 41e7971..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDatasource.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event; - -import java.util.Date; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.DSRequest; -import com.smartgwt.client.data.DSResponse; -import com.smartgwt.client.data.DataSourceField; -import com.smartgwt.client.data.fields.DataSourceImageField; -import com.smartgwt.client.data.fields.DataSourceIntegerField; -import com.smartgwt.client.data.fields.DataSourceTextField; -import com.smartgwt.client.types.FieldType; -import com.smartgwt.client.widgets.grid.ListGridRecord; - -import org.rhq.core.domain.criteria.EventCriteria; -import org.rhq.core.domain.event.Event; -import org.rhq.core.domain.util.PageList; -import org.rhq.core.domain.util.PageOrdering; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; - -/** - * @author Greg Hinkle - */ -public class EventDatasource extends RPCDataSource<Event> { - - - public EventDatasource() { - super(); - -// DataSourceField id = new DataSourceIntegerField("id", "Id"); -// id.setPrimaryKey(true); -// addField(id); - - DataSourceTextField detail = new DataSourceTextField("detail", "Detail"); - addField(detail); - -// DataSourceTextField detailExcerpt = new DataSourceTextField("detailExcerpt", "Detail Excerpt"); -// addField(detailExcerpt); - - DataSourceTextField severity = new DataSourceTextField("severity", "Servity"); - addField(severity); - -// DataSourceTextField source = new DataSourceTextField("source", "Source"); -// addField(source); - - DataSourceTextField sourceLocation = new DataSourceTextField("sourceLocation", "Source Location"); - addField(sourceLocation); - -// DataSourceTextField type = new DataSourceTextField("type", "Type"); -// addField(type); - - DataSourceTextField timestamp = new DataSourceTextField("timestamp", "Timestamp"); - timestamp.setType(FieldType.DATETIME); - addField(timestamp); - - - } - - - @Override - protected void executeFetch(final DSRequest request, final DSResponse response) { - - EventCriteria criteria = new EventCriteria(); - criteria.addSortSeverity(PageOrdering.DESC); - - criteria.setPageControl(getPageControl(request)); - criteria.fetchSource(true); - - if (request.getCriteria().getValues().get("resourceId") != null) { - criteria.addFilterResourceId(request.getCriteria().getAttributeAsInt("resourceId")); - } - - GWTServiceLookup.getEventService().findEventsByCriteria(criteria, - new AsyncCallback<PageList<Event>>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError("Failed to load event data", caught); - } - - public void onSuccess(PageList<Event> result) { - response.setData(buildRecords(result)); - response.setTotalRows(result.getTotalSize()); - processResponse(request.getRequestId(), response); - } - }); - - } - - @Override - public Event copyValues(ListGridRecord from) { - return null; // TODO: Implement this method. - } - - @Override - public ListGridRecord copyValues(Event from) { - ListGridRecord record = new ListGridRecord(); - - record.setAttribute("id", from.getId()); - record.setAttribute("detail", from.getDetail()); - record.setAttribute("detailExcerpt", from.getDetailExcerpt()); - record.setAttribute("severity", from.getSeverity().name()); - record.setAttribute("source", from.getSource()); - record.setAttribute("sourceLocation", from.getSource().getLocation()); - record.setAttribute("type", from.getType()); - record.setAttribute("timestamp", new Date(from.getTimestamp())); - - return record; - } - - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDetailsView.java deleted file mode 100644 index 13ab506..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDetailsView.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event; - -import com.smartgwt.client.types.TitleOrientation; -import com.smartgwt.client.widgets.Window; -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.StaticTextItem; -import com.smartgwt.client.widgets.form.fields.TextAreaItem; -import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.layout.VLayout; - -/** - * @author Greg Hinkle - */ -public class EventDetailsView extends VLayout { - - - private ListGridRecord eventRecord; - - - public EventDetailsView(ListGridRecord eventRecord) { - this.eventRecord = eventRecord; - } - - @Override - protected void onInit() { - super.onInit(); - - - DynamicForm form = new DynamicForm(); - form.setWidth100(); - form.setHeight100(); - - StaticTextItem id = new StaticTextItem("id","Id"); - id.setValue(eventRecord.getAttribute("id")); - - StaticTextItem severity = new StaticTextItem("severity","Severity"); - severity.setValue(eventRecord.getAttribute("severity")); - - StaticTextItem source = new StaticTextItem("sourceLocation","Source"); - source.setValue(eventRecord.getAttribute("sourceLocation")); - - StaticTextItem timestamp = new StaticTextItem("timestamp","Timestamp"); - timestamp.setValue(eventRecord.getAttribute("timestamp")); - - TextAreaItem detail = new TextAreaItem("detail", "Detail"); - detail.setTitleOrientation(TitleOrientation.TOP); - detail.setColSpan(2); - detail.setWidth("100%"); - detail.setHeight("100%"); - detail.setValue(eventRecord.getAttribute("detail")); - - - form.setItems(id,severity,source,timestamp,detail); - - - - addMember(form); - - } - - public void displayInDialog() { - Window window = new Window(); - window.setTitle("Event Details"); - window.setWidth(800); - window.setHeight(800); - window.setIsModal(true); - window.setShowModalMask(true); - window.setCanDragResize(true); - window.centerInPage(); - window.addItem(this); - window.setDismissOnEscape(true); - window.setDismissOnOutsideClick(true); - window.show(); - window.focus(); - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventHistoryView.java deleted file mode 100644 index a1e45ce..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventHistoryView.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event; - -import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.grid.CellFormatter; -import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent; -import com.smartgwt.client.widgets.grid.events.CellDoubleClickHandler; - -import org.rhq.enterprise.gui.coregui.client.components.table.Table; -import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; - -/** - * @author Greg Hinkle - */ -public class EventHistoryView extends Table { - - public EventHistoryView(String locatorId, Criteria criteria) { - super(locatorId, "Event History", criteria); - - setDataSource(new EventDatasource()); - - // getListGrid().getField("id").setWidth(60); - getListGrid().getField("severity").setWidth(120); - getListGrid().getField("severity").setCellFormatter(new CellFormatter() { - public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { - return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o; - } - }); - - getListGrid().addCellDoubleClickHandler(new CellDoubleClickHandler() { - public void onCellDoubleClick(CellDoubleClickEvent cellDoubleClickEvent) { - // TODO: Implement this method. - showEventDetails(cellDoubleClickEvent.getRecord()); - } - }); - - addTableAction(extendLocatorId("Detail"), "Details", SelectionEnablement.SINGLE, null, new TableAction() { - public void executeAction(ListGridRecord[] selection) { - showEventDetails(selection[0]); - } - }); - - getListGrid().getField("sourceLocation").setWidth(200); - getListGrid().getField("timestamp").setWidth(160); - } - - public static void showEventDetails(ListGridRecord record) { - new EventDetailsView(record).displayInDialog(); - } - - public static EventHistoryView createResourceHistoryView(String locatorId, int resourceId) { - Criteria criteria = new Criteria(); - criteria.addCriteria("resourceId", resourceId); - return new EventHistoryView(locatorId, criteria); - } -}
commit 6a432844fff9298ab8f61bb934875e1d7fc6267c Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 22:04:53 2010 -0400
improvements to some GWT infrastructure components
TableFilterForm * represents a DynamicForm containing fields that filter the results of an associated Tabular display * will automatically setup onKeyPress event handler for TextItem fields * will automatically setup onChanged event handler for SelectItem fields
HighlightingDatasourceTextField * to be used when constructing an RPCDataSource definition * usage: 'new DatasourceTextField' with 'new HighlightingDatasourceTextField' * end-result is that the pattern entered in the FormItem of the same name will cause the column of the same name in the associated Table to highlight matching results in-line
RPCDataSource (improvements) * corresponding handling code for the HighlightingDatasourceTextField * contains the logic for (under-the-covers) adding new DatasourceTextFields for the columns which will show the highlighted results
ColoringUtility * contains the code for performing the actual highlighting logic, which involves injecting <span> tags with background-color style attributes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java new file mode 100644 index 0000000..8687ea5 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java @@ -0,0 +1,86 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.components.form; + +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent; +import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler; + +import org.rhq.enterprise.gui.coregui.client.components.table.Table; + +/** + * A subclass of SmartGWT's DynamicForm widget that provides a more convenient interface for filtering a {@link Table} + * of results. + * + * @author Joseph Marques + */ +public class TableFilterForm extends DynamicForm implements KeyPressHandler, ChangedHandler { + + private Table table; + + public TableFilterForm(Table table) { + super(); + setWidth100(); + this.table = table; + this.table.setTableTitle(null); + } + + @Override + public void setItems(FormItem... items) { + super.setItems(items); + setupFormItems(items); + } + + private void setupFormItems(FormItem... formItems) { + for (FormItem nextFormItem : formItems) { + nextFormItem.setWrapTitle(false); + nextFormItem.setWidth(300); // wider than default + if (nextFormItem instanceof TextItem) { + nextFormItem.addKeyPressHandler(this); + } else if (nextFormItem instanceof SelectItem) { + nextFormItem.addChangedHandler(this); + } + } + } + + private void fetchFilteredTableData() { + table.refresh(getValuesAsCriteria()); + } + + public void onKeyPress(KeyPressEvent event) { + if (event.getKeyName().equals("Enter") == false) { + return; + } + fetchFilteredTableData(); + } + + public void onChanged(ChangedEvent event) { + fetchFilteredTableData(); + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/HighlightingDatasourceTextField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/HighlightingDatasourceTextField.java new file mode 100644 index 0000000..7eb6a62 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/HighlightingDatasourceTextField.java @@ -0,0 +1,47 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.util; + +import com.smartgwt.client.data.fields.DataSourceTextField; + +/** + * @author Joseph Marques + */ +public class HighlightingDatasourceTextField extends DataSourceTextField { + + public HighlightingDatasourceTextField(String name, String title, int length, boolean required) { + super(name, title, length, required); + } + + public HighlightingDatasourceTextField(String name, String title, int length) { + super(name, title, length); + } + + public HighlightingDatasourceTextField(String name, String title) { + super(name, title); + } + + public HighlightingDatasourceTextField(String name) { + super(name); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java index 950d28c..cb2768f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java @@ -18,13 +18,16 @@ */ package org.rhq.enterprise.gui.coregui.client.util;
+import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map;
import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; +import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -32,6 +35,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageOrdering; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.util.effects.ColoringUtility;
/** * Base GWT-RPC oriented DataSource class. @@ -41,6 +45,8 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI; */ public abstract class RPCDataSource<T> extends DataSource {
+ private List<String> hightlightingFieldNames = new ArrayList<String>(); + public RPCDataSource() { this(null); } @@ -51,6 +57,8 @@ public abstract class RPCDataSource<T> extends DataSource { setID(name); } setClientOnly(false); + setAutoCacheAllData(false); + setCacheAllData(false); setDataProtocol(DSProtocol.CLIENTCUSTOM); setDataFormat(DSDataFormat.CUSTOM); } @@ -128,6 +136,37 @@ public abstract class RPCDataSource<T> extends DataSource { return records; }
+ @Override + public void addField(DataSourceField field) throws IllegalStateException { + super.addField(field); + if ((field instanceof HighlightingDatasourceTextField) == false) { + return; + } + field.setHidden(true); + + hightlightingFieldNames.add(field.getName()); + + String name = field.getName() + "-highlight"; + String title = field.getTitle(); + DataSourceTextField fieldToDisplayHighlighting = new DataSourceTextField(name, title); + super.addField(fieldToDisplayHighlighting); + } + + @SuppressWarnings("unchecked") + protected void highlightFilterMatches(final DSRequest request, final ListGridRecord[] records) { + Map<String, Object> criteriaMap = request.getCriteria().getValues(); + + for (String filterName : hightlightingFieldNames) { + String filterValue = (String) criteriaMap.get(filterName); + for (ListGridRecord nextRecord : records) { + String originalData = nextRecord.getAttribute(filterName); + String decoratedData = (filterValue != null) ? ColoringUtility.highlight(originalData, filterValue) + : originalData; + nextRecord.setAttribute(filterName + "-highlight", decoratedData); + } + } + } + /** * Extensions should implement this method to retrieve data. Paging solutions should use * {@link #getPageControl(com.smartgwt.client.data.DSRequest)}. All implementations should call processResponse() @@ -182,7 +221,7 @@ public abstract class RPCDataSource<T> extends DataSource { */ public void addFields(List<DataSourceField> fields) { for (DataSourceField field : fields) { - addField(field); + addField(field); } } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/effects/ColoringUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/effects/ColoringUtility.java new file mode 100644 index 0000000..265ef0f --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/effects/ColoringUtility.java @@ -0,0 +1,92 @@ +package org.rhq.enterprise.gui.coregui.client.util.effects; + +import java.util.ArrayList; +import java.util.List; + +public class ColoringUtility { + public static String highlight(String data, String filter) { + return highlight(data, filter, "yellow"); + } + + public static String highlight(String data, String filter, String color) { + String lowerData = data.toLowerCase(); + String lowerFilter = filter.toLowerCase(); + + List<Integer> matchingIndices = new ArrayList<Integer>(); + + int startFrom = -1; + while ((startFrom = lowerData.indexOf(lowerFilter, startFrom + 1)) != -1) { + matchingIndices.add(startFrom); + } + + String style = "background-color: " + color; + for (int i = matchingIndices.size() - 1; i >= 0; i--) { + Integer nextMatchingIndex = matchingIndices.get(i); + data = decorate(data, style, nextMatchingIndex, nextMatchingIndex + filter.length()); + } + + return data; + } + + private static String decorate(String data, String style, int startIndex, int endIndex) { + if (startIndex == -1 || (startIndex == endIndex)) { + return data; // no match or zero-width match + } + + String[] words = data.split("<br/>"); + int counter = 0; + int wordIndex = 0; + int letterIndex = 0; + + StringBuilder results = new StringBuilder(); + while (counter < startIndex) { + if (wordIndex == words.length) { + break; + } + + if (letterIndex < words[wordIndex].length()) { // more letters left in the current word? + results.append(words[wordIndex].charAt(letterIndex)); // append the next char of the current word + letterIndex++; // move to the next char in the current word + counter++; // only move counter forward when we've added non-BR chars to the results + } else { // next word + results.append("<br/>"); // put the break point back in between words + letterIndex = 0; // point to the first char + wordIndex++; // of the next word + } + } + + // we're at start index, wrap all words and word fragments in the specified style up to endIndex + results.append("<span style="" + style + "">"); // seed action + while (counter < endIndex) { + if (wordIndex == words.length) { + break; + } + + if (letterIndex < words[wordIndex].length()) { // more letters left in the current word? + results.append(words[wordIndex].charAt(letterIndex)); // append the next char of the current word + letterIndex++; // move to the next char in the current word + counter++; // only move counter forward when we've added non-BR chars to the results + } else { // next word + results.append("</span>"); // close the previous word, we don't highlight breaks + results.append("<br/>"); // put the break point back in between words + letterIndex = 0; // point to the first char + wordIndex++; // of the next word + results.append("<span style="" + style + "">"); // prepare for next word + } + } + results.append("</span>"); // end last dangling span + + // append the rest of the current word fragment, if any + if (wordIndex != words.length) { + results.append(words[wordIndex].substring(letterIndex)); + } + + // append the rest of the words + while (++wordIndex < words.length) { + results.append("<br/>"); // put the break point back in between words + results.append(words[wordIndex]); + } + + return results.toString(); + } +}
commit 4e5f974a6562f178339f47f90f95065e956b7635 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 21:57:00 2010 -0400
add ability to filter EventCriteria by EntityContext object
* this is a convenience method wrapper that will automatically set other filters appropriate based on context ** if resource context, will add resourceId filter ** if group context, will add groupId filter ** if auto-group context, will add parentResourceId/resourceTypeId filters
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java index bdbccbc..f4db72d 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java @@ -29,6 +29,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.util.PageOrdering; @@ -107,11 +108,22 @@ public class EventCriteria extends Criteria { }
public void addFilterSeverities(EventSeverity... filterSeverities) { - if (filterSeverities != null) { + if (filterSeverities != null && filterSeverities.length > 0) { this.filterSeverities = Arrays.asList(filterSeverities); } }
+ public void addFilterEntityContext(EntityContext filterEntityContext) { + if (filterEntityContext.getCategory() == EntityContext.Category.Resource) { + addFilterResourceId(filterEntityContext.getResourceId()); + } else if (filterEntityContext.getCategory() == EntityContext.Category.ResourceGroup) { + addFilterResourceGroupId(filterEntityContext.getGroupId()); + } else if (filterEntityContext.getCategory() == EntityContext.Category.AutoGroup) { + addFilterAutoGroupParentResourceId(filterEntityContext.getParentResourceId()); + addFilterAutoGroupResourceTypeId(filterEntityContext.getResourceTypeId()); + } + } + public void addFilterResourceId(Integer filterResourceId) { this.filterResourceId = filterResourceId; }
commit 1cb73bc8d121d5e66795d86e794dccc0c7fce415 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 21:55:19 2010 -0400
fix bug - filtering by sourceName on EventCriteria
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java index f7dbb6a..bdbccbc 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java @@ -59,7 +59,7 @@ public class EventCriteria extends Criteria { private PageOrdering sortSeverity;
public EventCriteria() { - filterOverrides.put("sourceName", "source.eventDefinition.name like ?"); + filterOverrides.put("sourceName", "source.location like ?"); filterOverrides.put("startTime", "timestamp >= ?"); filterOverrides.put("endTime", "timestamp <= ?"); filterOverrides.put("resourceId", "source.resourceId = ?");
commit 4daa5f3a45c61581e45254aae3dad8f09df4f5d6 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 21:54:41 2010 -0400
parameterized delete/purge routines in EventManagerBean using EntityContext; add missing permission
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java index 09221d3..31b283b 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java @@ -49,6 +49,7 @@ import org.rhq.core.db.OracleDatabaseType; import org.rhq.core.db.PostgresqlDatabaseType; import org.rhq.core.db.SQLServerDatabaseType; import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.EventCriteria; import org.rhq.core.domain.event.Event; @@ -260,10 +261,29 @@ public class EventManagerBean implements EventManagerLocal, EventManagerRemote { } }
- public int deleteEvents(Subject subject, List<Integer> eventIds) { + public int deleteEventsForContext(Subject subject, EntityContext context, List<Integer> eventIds) { if (eventIds == null || eventIds.size() == 0) { return 0; // nothing to delete, thus 0 were deleted } + + if (context.category == EntityContext.Category.Resource) { + if (authorizationManager.hasResourcePermission(subject, Permission.MANAGE_EVENTS, context.resourceId) == false) { + throw new PermissionException("User [" + subject.getName() + + "] does not have permissions to delete events for resource[id=" + context.resourceId + "]"); + } + } else if (context.category == EntityContext.Category.ResourceGroup) { + if (authorizationManager.hasGroupPermission(subject, Permission.MANAGE_EVENTS, context.groupId) == false) { + throw new PermissionException("User [" + subject.getName() + + "] does not have permissions to delete events for resourceGroup[id=" + context.groupId + "]"); + } + } else if (context.category == EntityContext.Category.AutoGroup) { + if (authorizationManager.canViewAutoGroup(subject, context.parentResourceId, context.resourceTypeId) == false) { + throw new PermissionException("User [" + subject.getName() + + "] does not have permission to view event history for autoGroup[parentResourceId=" + + context.parentResourceId + ", resourceTypeId=" + context.resourceTypeId + "]"); + } + } + Query q = entityManager.createNamedQuery(Event.DELETE_BY_EVENT_IDS); q.setParameter("eventIds", eventIds); int deletedCount = q.executeUpdate(); @@ -271,18 +291,32 @@ public class EventManagerBean implements EventManagerLocal, EventManagerRemote { return deletedCount; }
- public int deleteAllEventsForResource(Subject subject, int resourceId) { - Query q = entityManager.createNamedQuery(Event.DELETE_ALL_BY_RESOURCE); - q.setParameter("resourceId", resourceId); - int deletedCount = q.executeUpdate(); + public int purgeEventsForContext(Subject subject, EntityContext context) {
- return deletedCount; - } + if (context.category == EntityContext.Category.Resource) { + if (authorizationManager.hasResourcePermission(subject, Permission.MANAGE_EVENTS, context.resourceId) == false) { + throw new PermissionException("User [" + subject.getName() + + "] does not have permissions to purge events for resource[id=" + context.resourceId + "]"); + } + } else if (context.category == EntityContext.Category.ResourceGroup) { + if (authorizationManager.hasGroupPermission(subject, Permission.MANAGE_EVENTS, context.groupId) == false) { + throw new PermissionException("User [" + subject.getName() + + "] does not have permissions to purge events for resourceGroup[id=" + context.groupId + "]"); + } + } else { + throw new IllegalArgumentException(context.getUnknownContextMessage()); + }
- public int deleteAllEventsForCompatibleGroup(Subject subject, int groupId) { - Query q = entityManager.createNamedQuery(Event.DELETE_ALL_BY_RESOURCE_GROUP); - q.setParameter("groupId", groupId); - int deletedCount = q.executeUpdate(); + Query purgeQuery = null; + if (context.category == EntityContext.Category.Resource) { + purgeQuery = entityManager.createNamedQuery(Event.DELETE_ALL_BY_RESOURCE); + purgeQuery.setParameter("resourceId", context.resourceId); + } else if (context.category == EntityContext.Category.ResourceGroup) { + purgeQuery = entityManager.createNamedQuery(Event.DELETE_ALL_BY_RESOURCE_GROUP); + purgeQuery.setParameter("groupId", context.groupId); + } + + int deletedCount = purgeQuery.executeUpdate();
return deletedCount; } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java index ac91817..03a4b21 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java @@ -85,11 +85,9 @@ public interface EventManagerLocal {
void deleteEventSourcesForDefinition(EventDefinition def);
- int deleteEvents(Subject subject, List<Integer> eventIds); + int deleteEventsForContext(Subject subject, EntityContext context, List<Integer> eventIds);
- int deleteAllEventsForResource(Subject subject, int resourceId); - - int deleteAllEventsForCompatibleGroup(Subject subject, int groupId); + int purgeEventsForContext(Subject subject, EntityContext context);
PageList<EventComposite> findEventComposites(Subject subject, EntityContext context, long begin, long end, EventSeverity[] severities, String source, String detail, PageControl pc);
commit 04725bce53b14e43ca5a9d9077a414907bee63ed Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 21:54:15 2010 -0400
add MANAGE_EVENTS permission to dbsetup routine for new installations
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml index 76e0eb7..8a92b54 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml @@ -57,6 +57,7 @@ <data ROLE_ID="1" OPERATION="9"/> <!-- Permission.MANAGE_CONTENT --> <data ROLE_ID="1" OPERATION="10"/> <!-- Permission.CONTROL --> <data ROLE_ID="1" OPERATION="11"/> <!-- Permission.CONFIGURE --> + <data ROLE_ID="1" OPERATION="14"/> <!-- Permission.MANAGE_EVENTS -->
<!-- give all-resources-role all permissions (resource perms is mainly just to show on view-role page) --> <data ROLE_ID="2" OPERATION="1"/> <!-- Permission.MANAGE_INVENTORY --> @@ -71,6 +72,7 @@ <data ROLE_ID="2" OPERATION="9"/> <!-- Permission.MANAGE_CONTENT --> <data ROLE_ID="2" OPERATION="10"/> <!-- Permission.CONTROL --> <data ROLE_ID="2" OPERATION="11"/> <!-- Permission.CONFIGURE --> + <data ROLE_ID="2" OPERATION="14"/> <!-- Permission.MANAGE_EVENTS --> </table>
</dbsetup>
commit b0cb569f309d257c65ce1ffb12bd4913ad7dc368 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 21:53:39 2010 -0400
add numeric label after each enum, for ease of reference
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java index 3b8c5fd..5ab76b6 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java @@ -39,74 +39,74 @@ public enum Permission { /** * can C/U/D users and roles (viewing is implied for everyone) */ - MANAGE_SECURITY(Target.GLOBAL), + MANAGE_SECURITY(Target.GLOBAL), // 0
/** * can C/R/U/D all resources, groups and can import auto-discovered resources */ - MANAGE_INVENTORY(Target.GLOBAL), + MANAGE_INVENTORY(Target.GLOBAL), // 1
/** * can modify the JON Server configuration and perform any server-related functionality */ - MANAGE_SETTINGS(Target.GLOBAL), + MANAGE_SETTINGS(Target.GLOBAL), // 2
/* ========= Resource Permissions ========= */
/** * can view this resource's config, metrics, and alerts */ - VIEW_RESOURCE(Target.RESOURCE), + VIEW_RESOURCE(Target.RESOURCE), // 3
/** * can modify resource name, description, and plugin config (e.g. set principal/credentials jboss-as plugin uses to access the managed JBossAS instance) */ - MODIFY_RESOURCE(Target.RESOURCE), + MODIFY_RESOURCE(Target.RESOURCE), // 4
/** * can delete this resource (which also implies deleting all its descendant resources) */ - DELETE_RESOURCE(Target.RESOURCE), + DELETE_RESOURCE(Target.RESOURCE), // 5
/** * can manually create new child servers or services */ - CREATE_CHILD_RESOURCES(Target.RESOURCE), + CREATE_CHILD_RESOURCES(Target.RESOURCE), // 6
/** * can C/U/D alert definitions (this implies {@link #VIEW_RESOURCE}, {@link #MANAGE_MEASUREMENTS}, {@link #CONTROL}) */ - MANAGE_ALERTS(Target.RESOURCE), + MANAGE_ALERTS(Target.RESOURCE), // 7
/** * can C/U/D metric schedules (this implies {@link #VIEW_RESOURCE}) */ - MANAGE_MEASUREMENTS(Target.RESOURCE), + MANAGE_MEASUREMENTS(Target.RESOURCE), // 8
/** * can C/U/D content (package bits, software updates, etc) (this implies {@link #VIEW_RESOURCE}) */ - MANAGE_CONTENT(Target.RESOURCE), + MANAGE_CONTENT(Target.RESOURCE), // 9
/** * can invoke operations that only change the "running" state of the resource (e.g. start/stop) */ - CONTROL(Target.RESOURCE), + CONTROL(Target.RESOURCE), // 10
/** * can C/U/D resource config (e.g. reconfiguring JBoss to listen for jnp on port 1199); * having this permission implies having @link {@link #CONFIGURE_READ} */ - CONFIGURE_WRITE(Target.RESOURCE), + CONFIGURE_WRITE(Target.RESOURCE), // 11
/* ========== New Bundle Global Permission ========== */
- MANAGE_BUNDLE(Target.GLOBAL), + MANAGE_BUNDLE(Target.GLOBAL), // 12
/** * can read resource configu, but can not necessarily C/U/D unless @link {@link #CONFIGURE_WRITE} is also possessed */ - CONFIGURE_READ(Target.RESOURCE); + CONFIGURE_READ(Target.RESOURCE), // 13
/** * can C/U/D events (this implies {@link #VIEW_RESOURCE})
commit f92f62432bf397854e8ef276dbc29b2011c29935 Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 21:53:23 2010 -0400
add missing MANAGE_EVENTS permission, previous event delete/purge was guarded by view resource permission
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml index 81498dc..1f4adef 100644 --- a/modules/core/dbutils/pom.xml +++ b/modules/core/dbutils/pom.xml @@ -22,7 +22,7 @@
<properties> <scm.module.path>modules/core/dbutils/</scm.module.path> - <db.schema.version>2.93.3</db.schema.version> + <db.schema.version>2.94</db.schema.version> </properties>
<dependencies> diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index 07b448b..f32e5e3 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -3192,6 +3192,24 @@ <schema-alterColumn table="RHQ_PARTITION_EVENT" column="SUBJECT_NAME" columnType="VARCHAR2" precision="100" /> </schemaSpec>
+ <schemaSpec version="2.94"> + <!-- give the 'SUPER USER' and 'ALL RESOURCES' roles permission to delete/purge events (this permission + previously did not exist, and event deletion/purging could be performed by any user with authz to + view the resource/group in question). + + a user with MANAGE_SECURITY must explicitly grant this permission to other roles after upgrade--> + <schema-directSQL> + <statement desc="Inserting MANAGE_EVENTS permission for 'Super User' role"> + INSERT INTO RHQ_PERMISSION (ROLE_ID, OPERATION) + VALUES (1, 14) + </statement> + <statement desc="Inserting MANAGE_EVENTS permission for 'All Resources' role"> + INSERT INTO RHQ_PERMISSION (ROLE_ID, OPERATION) + VALUES (2, 14) + </statement> + </schema-directSQL> + </schemaSpec> + </dbupgrade> </target> </project> diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java index e20d15b..3b8c5fd 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java @@ -109,6 +109,12 @@ public enum Permission { CONFIGURE_READ(Target.RESOURCE);
/** + * can C/U/D events (this implies {@link #VIEW_RESOURCE}) + * in the future, will also C/U/D event definitions + */ + MANAGE_EVENTS(Target.RESOURCE); // 14 + + /** * The target that a permission applies to. */ public enum Target {
commit 2f206ea7d5438596b956de476e883fcc9b723a9d Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 21:02:07 2010 -0400
sorting fix
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml index 21bbc81..2db2852 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml @@ -97,7 +97,7 @@
<rich:column style="white-space: nowrap;"> <f:facet name="header"> - <onc:sortableColumnHeader sort="ev.severity"> + <onc:sortableColumnHeader sort="severity"> <h:outputText styleClass="headerText" value="Severity" /> </onc:sortableColumnHeader> </f:facet> @@ -113,7 +113,7 @@
<rich:column rendered="#{EventHistoryUIBean.context.resourceId == -1}"> <f:facet name="header"> - <onc:sortableColumnHeader sort="res.name"> + <onc:sortableColumnHeader sort="resource.name"> <h:outputText styleClass="headerText" value="Resource" /> </onc:sortableColumnHeader> </f:facet> @@ -122,7 +122,7 @@
rich:column <f:facet name="header"> - <onc:sortableColumnHeader sort="evs.location"> + <onc:sortableColumnHeader sort="source.location"> <h:outputText styleClass="headerText" value="Source" /> </onc:sortableColumnHeader> </f:facet> @@ -144,7 +144,7 @@
rich:column <f:facet name="header"> - <onc:sortableColumnHeader sort="ev.timestamp"> + <onc:sortableColumnHeader sort="timestamp"> <h:outputText styleClass="headerText" value="Time occurred" /> </onc:sortableColumnHeader> </f:facet>
commit 3ef6b07c0db492dac1b50853a7338be2e78ab5dd Author: Joseph Marques joseph@redhat.com Date: Mon Aug 23 21:01:23 2010 -0400
move EntityContext from server/jar to core/domain, so it can be GWT-consumed
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/common/EntityContext.java b/modules/core/domain/src/main/java/org/rhq/core/domain/common/EntityContext.java new file mode 100644 index 0000000..493c4d6 --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/common/EntityContext.java @@ -0,0 +1,186 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.core.domain.common; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + * Category is assigned with the following preference assuming multiple categories can be satisfied with the available context information: + * <pre> + * ResourceGroup + * AutoGroup + * ResourceTemplate + * Resource + * <pre> + * + * @author Joseph Marques + */ +public class EntityContext implements Serializable { + + private static final long serialVersionUID = 1L; + + public enum Category { + Resource, // + ResourceTemplate, // + ResourceGroup, // + AutoGroup; + } + + // can't make these fields final because need public no-arg ctor for GWT-compile + public Category category; + public int resourceId; + public int groupId; + public int parentResourceId; + public int resourceTypeId; + + public EntityContext() { + } + + public Category getCategory() { + return category; + } + + public int getResourceId() { + return resourceId; + } + + public int getGroupId() { + return groupId; + } + + public int getParentResourceId() { + return parentResourceId; + } + + public int getResourceTypeId() { + return resourceTypeId; + } + + public EntityContext(Integer resourceId, Integer groupId, Integer parentResourceId, Integer resourceTypeId) { + int rId = (resourceId != null && resourceId > 0) ? resourceId : -1; + int gId = (groupId != null && groupId > 0) ? groupId : -1; + int prId = (parentResourceId != null && parentResourceId > 0) ? parentResourceId : -1; + int rtId = (resourceTypeId != null && resourceTypeId > 0) ? resourceTypeId : -1; + + this.resourceId = rId; + this.groupId = gId; + this.parentResourceId = prId; + this.resourceTypeId = rtId; + + if (this.groupId > 0) { + category = Category.ResourceGroup; + } else if (this.resourceTypeId > 0) { + if (this.parentResourceId > 0) { + category = Category.AutoGroup; + } else { + category = Category.ResourceTemplate; + } + } else if (this.resourceId > 0) { + category = Category.Resource; + } else { + throw new IllegalArgumentException(getUnknownContextMessage()); + } + } + + public static EntityContext forResource(int resourceId) { + return new EntityContext(resourceId, null, null, null); + } + + public static EntityContext forGroup(int groupId) { + return new EntityContext(null, groupId, null, null); + } + + public static EntityContext forAutoGroup(int parentResourceId, int resourceTypeId) { + return new EntityContext(null, null, parentResourceId, resourceTypeId); + } + + public static EntityContext forTemplate(int resourceTypeId) { + return new EntityContext(null, null, null, resourceTypeId); + } + + public static EntityContext fromCriteriaMap(Map<String, Object> criteriaMap) { + return new EntityContext(// + Integer.valueOf((String) criteriaMap.get("resourceId")), // + Integer.valueOf((String) criteriaMap.get("groupId")), // + Integer.valueOf((String) criteriaMap.get("parentResourceId")), // + Integer.valueOf((String) criteriaMap.get("resourceTypeId"))); + } + + public Map<String, String> toCriteriaMap() { + Map<String, String> criteriaMap = new HashMap<String, String>(); + + switch (category) { + case Resource: + criteriaMap.put("resourceId", String.valueOf(resourceId)); + break; + case ResourceGroup: + criteriaMap.put("groupId", String.valueOf(groupId)); + break; + case AutoGroup: + criteriaMap.put("parentResourceId", String.valueOf(parentResourceId)); + criteriaMap.put("resourceTypeId", String.valueOf(resourceTypeId)); + break; + case ResourceTemplate: + criteriaMap.put("resourceTypeId", String.valueOf(resourceTypeId)); + break; + } + + return criteriaMap; + } + + public String getLegacyKey() { + switch (category) { + case Resource: + return String.valueOf(resourceId); + case ResourceGroup: + return "cg=" + String.valueOf(groupId); + case AutoGroup: + return "ag=" + String.valueOf(parentResourceId) + ":" + String.valueOf(resourceTypeId); + default: + throw new IllegalArgumentException(getUnknownContextMessage()); + } + } + + public String getUnknownContextMessage() { + return "Unsupported EntityContext '" + this + "'"; + } + + @Override + public String toString() { + return "EntityContext[category=" + category + ",resourceId=" + resourceId + "," + "groupId=" + groupId + "," + + "parent=" + parentResourceId + "," + "type=" + resourceTypeId + "]"; + } + + public String toShortString() { + switch (category) { + case Resource: + return "resource[id=" + resourceId + "]"; + case ResourceGroup: + return "resourceGroup[groupId=" + resourceId + "]"; + case AutoGroup: + return "autoGroup[parent=" + parentResourceId + ",type=" + resourceTypeId + "]"; + case ResourceTemplate: + return "template[type=" + resourceTypeId + "]"; + default: + return toString(); + } + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java index a68baca..9760900 100755 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java @@ -29,6 +29,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.measurement.MeasurementSchedule; import org.rhq.core.domain.measurement.MeasurementUnits; @@ -40,7 +41,6 @@ import org.rhq.enterprise.gui.legacy.DefaultConstants; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java index e9f24fa..ad57e8b 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java @@ -41,6 +41,7 @@ import org.rhq.core.domain.alert.AlertPriority; import org.rhq.core.domain.alert.notification.AlertNotification; import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.configuration.ConfigurationUpdateStatus; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.measurement.AvailabilityType; @@ -58,7 +59,6 @@ import org.rhq.enterprise.gui.legacy.util.RequestUtils; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.gui.util.WebUtility; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.uibean.MetricDisplaySummary; import org.rhq.enterprise.server.plugin.pc.alert.AlertSender; import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java index 8b033d7..3b2f373 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java @@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.event.composite.EventComposite; import org.rhq.core.domain.util.PageControl; @@ -42,7 +43,6 @@ import org.rhq.enterprise.gui.common.paging.PagedListDataModel; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.event.EventException; import org.rhq.enterprise.server.event.EventManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; @@ -152,7 +152,8 @@ public class EventHistoryUIBean extends PagedDataTableUIBean { Integer[] eventIds = StringUtility.getIntegerArray(selectedEvents);
try { - int numDeleted = eventManager.deleteEvents(getSubject(), Arrays.asList(eventIds)); + int numDeleted = eventManager.deleteEventsForContext(getSubject(), context, Arrays.asList(eventIds)); + FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted " + numDeleted + " events."); } catch (Exception e) { FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Failed to delete selected events.", e); @@ -163,15 +164,7 @@ public class EventHistoryUIBean extends PagedDataTableUIBean {
public String purgeAllEvents() { try { - int numDeleted = 0; - - if (context.category == EntityContext.Category.Resource) { - numDeleted = eventManager.deleteAllEventsForResource(getSubject(), context.resourceId); - } else if (context.category == EntityContext.Category.ResourceGroup) { - numDeleted = eventManager.deleteAllEventsForCompatibleGroup(getSubject(), context.groupId); - } else { - log.error(context.getUnknownContextMessage()); - } + int numDeleted = eventManager.purgeEventsForContext(getSubject(), context);
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted " + numDeleted + " events"); } catch (Exception e) { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java index 243f7eb..9a02867 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java @@ -22,12 +22,12 @@ import java.util.List;
import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.gui.util.WebUtility; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException; import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java index 9109345..8403297 100755 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java @@ -33,6 +33,7 @@ import org.apache.struts.util.MessageResources; import org.rhq.core.clientapi.util.StringUtil; import org.rhq.core.clientapi.util.TimeUtil; import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.event.composite.EventComposite; import org.rhq.core.domain.util.PageControl; @@ -46,7 +47,6 @@ import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.action.BaseAction; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.event.EventManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java index 45f17ba..fb41aee 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java @@ -31,6 +31,7 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.event.composite.EventComposite; import org.rhq.core.domain.util.PageControl; @@ -40,7 +41,6 @@ import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.MetricsControlFormPrepareAction; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.event.EventManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java index a69fe6f..18183ac 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java @@ -33,6 +33,7 @@ import org.apache.struts.tiles.ComponentContext; import org.apache.struts.tiles.actions.TilesAction;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; import org.rhq.core.domain.resource.Resource; @@ -42,7 +43,6 @@ import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.legacy.AttrConstants; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal; import org.rhq.enterprise.server.resource.ResourceManagerLocal; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java index aa8d207..df37899 100755 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java @@ -36,6 +36,7 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.DispatchAction;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.enterprise.gui.legacy.AttrConstants; import org.rhq.enterprise.gui.legacy.KeyConstants; import org.rhq.enterprise.gui.legacy.ParamConstants; @@ -46,7 +47,6 @@ import org.rhq.enterprise.gui.legacy.util.RequestUtils; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.MetricsDisplayMode; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; import org.rhq.enterprise.server.measurement.MeasurementViewException; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java index 1e02793..4cfb664 100755 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java @@ -29,6 +29,7 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.tiles.actions.TilesAction;
import org.rhq.core.clientapi.util.TimeUtil; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.EventSeverity; import org.rhq.enterprise.gui.legacy.AttrConstants; import org.rhq.enterprise.gui.legacy.DefaultConstants; @@ -37,7 +38,6 @@ import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.beans.TimelineBean; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.event.EventManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java index c93c137..6a1177c 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java @@ -5,6 +5,7 @@ import javax.faces.model.DataModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; @@ -15,7 +16,6 @@ import org.rhq.enterprise.gui.common.paging.PagedListDataModel; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.CallTimeDataManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java index d2c9434..3958d5d 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java @@ -8,12 +8,12 @@ import org.apache.commons.logging.LogFactory; import org.rhq.core.clientapi.util.units.UnitNumber; import org.rhq.core.clientapi.util.units.UnitsConstants; import org.rhq.core.clientapi.util.units.UnitsFormat; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.enterprise.gui.legacy.DefaultConstants; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal; import org.rhq.enterprise.server.measurement.AvailabilityPoint; import org.rhq.enterprise.server.measurement.MeasurementPreferences; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java index 6b5776f..5f9fb22 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java @@ -4,13 +4,13 @@ import java.util.ArrayList; import java.util.List;
import org.rhq.core.clientapi.util.TimeUtil; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.EventSeverity; import org.rhq.enterprise.gui.legacy.DefaultConstants; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.beans.TimelineBean; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.event.EventManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java index 5dbddac..572cc88 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java @@ -18,6 +18,7 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.gui.util.FacesContextUtility; import org.rhq.enterprise.gui.legacy.AttrConstants; import org.rhq.enterprise.gui.legacy.KeyConstants; @@ -33,7 +34,6 @@ import org.rhq.enterprise.gui.util.WebUtility; import org.rhq.enterprise.server.auth.SessionNotFoundException; import org.rhq.enterprise.server.auth.SessionTimeoutException; import org.rhq.enterprise.server.authz.PermissionException; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; import org.rhq.enterprise.server.measurement.MeasurementViewException; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java index 162f23d..39004f0 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java @@ -3,6 +3,7 @@ package org.rhq.enterprise.gui.measurement.schedule.autogroup; import javax.faces.application.FacesMessage; import javax.faces.model.DataModel;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; @@ -12,7 +13,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean; import org.rhq.enterprise.gui.common.paging.PageControlView; import org.rhq.enterprise.gui.common.paging.PagedListDataModel; import org.rhq.enterprise.gui.common.time.DurationComponent; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal; import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java index 267bb07..3c2cf04 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java @@ -3,6 +3,7 @@ package org.rhq.enterprise.gui.measurement.schedule.group; import javax.faces.application.FacesMessage; import javax.faces.model.DataModel;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; @@ -12,7 +13,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean; import org.rhq.enterprise.gui.common.paging.PageControlView; import org.rhq.enterprise.gui.common.paging.PagedListDataModel; import org.rhq.enterprise.gui.common.time.DurationComponent; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal; import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java index 1a07f05..2dda70b 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java @@ -3,6 +3,7 @@ package org.rhq.enterprise.gui.measurement.schedule.resource; import javax.faces.application.FacesMessage; import javax.faces.model.DataModel;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; @@ -12,7 +13,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean; import org.rhq.enterprise.gui.common.paging.PageControlView; import org.rhq.enterprise.gui.common.paging.PagedListDataModel; import org.rhq.enterprise.gui.common.time.DurationComponent; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal; import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java index 64d695f..0b46dc1 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java @@ -26,6 +26,7 @@ import javax.faces.context.FacesContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.measurement.MeasurementSchedule; @@ -36,7 +37,6 @@ import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.util.MonitorUtils; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.gui.util.WebUtility; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementPreferences; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java index c60c2fd..072d052 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java @@ -27,6 +27,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.util.OrderingField; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageOrdering; @@ -36,7 +37,6 @@ import org.rhq.enterprise.gui.legacy.ParamConstants; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.exception.ParameterNotFoundException; import org.rhq.enterprise.gui.legacy.util.SessionUtils; -import org.rhq.enterprise.server.common.EntityContext;
/** * Utilities for the web tier. Named such so as not to clash with diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/common/EntityContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/common/EntityContext.java deleted file mode 100644 index 0330286..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/common/EntityContext.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.common; - -/** - * Category is assigned with the following preference assuming multiple categories can be satisfied with the available context information: - * <pre> - * ResourceGroup - * AutoGroup - * ResourceTemplate - * Resource - * <pre> - * - * @author Joseph Marques - */ -public class EntityContext { - - public enum Category { - Resource, // - ResourceTemplate, // - ResourceGroup, // - AutoGroup; - } - - public final Category category; - public final int resourceId; - public final int groupId; - public final int parentResourceId; - public final int resourceTypeId; - - public Category getCategory() { - return category; - } - - public int getResourceId() { - return resourceId; - } - - public int getGroupId() { - return groupId; - } - - public int getParentResourceId() { - return parentResourceId; - } - - public int getResourceTypeId() { - return resourceTypeId; - } - - public EntityContext(Integer resourceId, Integer groupId, Integer parentResourceId, Integer resourceTypeId) { - int rId = (resourceId != null && resourceId > 0) ? resourceId : -1; - int gId = (groupId != null && groupId > 0) ? groupId : -1; - int prId = (parentResourceId != null && parentResourceId > 0) ? parentResourceId : -1; - int rtId = (resourceTypeId != null && resourceTypeId > 0) ? resourceTypeId : -1; - - this.resourceId = rId; - this.groupId = gId; - this.parentResourceId = prId; - this.resourceTypeId = rtId; - - if (this.groupId > 0) { - category = Category.ResourceGroup; - } else if (this.resourceTypeId > 0) { - if (this.parentResourceId > 0) { - category = Category.AutoGroup; - } else { - category = Category.ResourceTemplate; - } - } else if (this.resourceId > 0) { - category = Category.Resource; - } else { - throw new IllegalArgumentException(getUnknownContextMessage()); - } - } - - public static EntityContext forResource(int resourceId) { - return new EntityContext(resourceId, null, null, null); - } - - public static EntityContext forGroup(int groupId) { - return new EntityContext(null, groupId, null, null); - } - - public static EntityContext forAutoGroup(int parentResourceId, int resourceTypeId) { - return new EntityContext(null, null, parentResourceId, resourceTypeId); - } - - public String getLegacyKey() { - switch (category) { - case Resource: - return String.valueOf(resourceId); - case ResourceGroup: - return "cg=" + String.valueOf(groupId); - case AutoGroup: - return "ag=" + String.valueOf(parentResourceId) + ":" + String.valueOf(resourceTypeId); - default: - throw new IllegalArgumentException(getUnknownContextMessage()); - } - } - - public String getUnknownContextMessage() { - return "Unsupported " + EntityContext.class.getSimpleName() + " '" + this + "'"; - } - - @Override - public String toString() { - return EntityContext.class.getSimpleName() + "[category=" + category + ",resourceId=" + resourceId + "," - + "groupId=" + groupId + "," + "parent=" + parentResourceId + "," + "type=" + resourceTypeId + "]"; - } - - public String toShortString() { - switch (category) { - case Resource: - return "resource[id=" + resourceId + "]"; - case ResourceGroup: - return "resourceGroup[groupId=" + resourceId + "]"; - case AutoGroup: - return "autoGroup[parent=" + parentResourceId + ",type=" + resourceTypeId + "]"; - default: - return toString(); - } - } -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java index 443625f..09221d3 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java @@ -49,6 +49,7 @@ import org.rhq.core.db.OracleDatabaseType; import org.rhq.core.db.PostgresqlDatabaseType; import org.rhq.core.db.SQLServerDatabaseType; import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.EventCriteria; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventDefinition; @@ -63,7 +64,6 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal; import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.PermissionException; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor; import org.rhq.enterprise.server.util.CriteriaQueryGenerator; import org.rhq.enterprise.server.util.CriteriaQueryRunner; diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java index 97d63bc..ac91817 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java @@ -28,6 +28,7 @@ import java.util.Set; import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.EventCriteria; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventDefinition; @@ -36,7 +37,6 @@ import org.rhq.core.domain.event.EventSource; import org.rhq.core.domain.event.composite.EventComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.server.common.EntityContext;
/** * Interface for the Event Manager diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java index 7b90d5f..0f75686 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java @@ -40,6 +40,7 @@ import org.apache.commons.logging.LogFactory; import org.jboss.annotation.ejb.TransactionTimeout;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.discovery.AvailabilityReport; import org.rhq.core.domain.measurement.Availability; import org.rhq.core.domain.measurement.AvailabilityType; @@ -57,7 +58,6 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal; import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.PermissionException; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.core.AgentManagerLocal; import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor; import org.rhq.enterprise.server.resource.ResourceAvailabilityManagerLocal; diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java index 65bf0e3..d052d88 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java @@ -49,6 +49,7 @@ import org.rhq.core.db.Postgresql83DatabaseType; import org.rhq.core.db.PostgresqlDatabaseType; import org.rhq.core.db.SQLServerDatabaseType; import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.CallTimeDataCriteria; import org.rhq.core.domain.measurement.MeasurementSchedule; import org.rhq.core.domain.measurement.calltime.CallTimeData; @@ -64,7 +65,6 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal; import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.PermissionException; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor; import org.rhq.enterprise.server.util.CriteriaQueryGenerator; import org.rhq.enterprise.server.util.CriteriaQueryRunner; diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java index 6c0180b..cf95f77 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java @@ -25,11 +25,11 @@ import java.util.Set; import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.calltime.CallTimeData; import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.server.common.EntityContext;
/** * The manager for call-time metric data. diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java index 15b5267..59f76dc 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java @@ -37,6 +37,7 @@ import org.apache.commons.logging.LogFactory; import org.jboss.annotation.IgnoreDependency;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.DisplayType; @@ -53,7 +54,6 @@ import org.rhq.enterprise.server.RHQConstants; import org.rhq.enterprise.server.alert.AlertManagerLocal; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.PermissionException; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.common.PerformanceMonitorInterceptor; import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences; import org.rhq.enterprise.server.measurement.uibean.MetricDisplayConstants; diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java index 3a5f53b..c65cc8c 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java @@ -55,6 +55,7 @@ import org.rhq.core.db.DatabaseType; import org.rhq.core.db.DatabaseTypeFactory; import org.rhq.core.db.Postgresql83DatabaseType; import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.DisplayType; @@ -83,7 +84,6 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal; import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.PermissionException; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.core.AgentManagerLocal; import org.rhq.enterprise.server.jaxb.adapter.MeasurementDataNumericHighLowCompositeAdapter; import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor; @@ -833,16 +833,16 @@ public class MeasurementDataManagerBean implements MeasurementDataManagerLocal, Map<String, Object> filterFields = generator.getFilterFields(criteria); if (!this.authorizationManager.isInventoryManager(subject)) { if (filterFields.get(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID) != null) { - generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.GROUP, - subject.getId()); + generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.GROUP, subject + .getId()); } else { generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.RESOURCE, - subject.getId()); + subject.getId()); } }
CriteriaQueryRunner<MeasurementDataTrait> queryRunner = new CriteriaQueryRunner(criteria, generator, - this.entityManager); + this.entityManager); PageList<MeasurementDataTrait> results = queryRunner.execute();
// Fetch the metric definition for each schedule, so the results include the trait names. @@ -857,7 +857,7 @@ public class MeasurementDataManagerBean implements MeasurementDataManagerLocal, result.getSchedule().getResource().getName(); } } - + return results; }
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java index 7e4d87c..5090d47 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java @@ -26,8 +26,8 @@ import java.util.Set; import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria; -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; import org.rhq.core.domain.measurement.DisplayType; import org.rhq.core.domain.measurement.MeasurementData; import org.rhq.core.domain.measurement.MeasurementDataNumeric; @@ -40,7 +40,6 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.uibean.MetricDisplaySummary;
/** @@ -161,7 +160,7 @@ public interface MeasurementDataManagerLocal { * @return the traits that match the specified {@link MeasurementDataTraitCriteria criteria}; never null */ PageList<MeasurementDataTrait> findTraitsByCriteria(Subject subject, MeasurementDataTraitCriteria criteria); - + /** * Get live metrics for a given MeasurementSchedule * diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java index bebf8a4..1e0b353 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java @@ -52,6 +52,7 @@ import org.rhq.core.db.PostgresqlDatabaseType; import org.rhq.core.db.SQLServerDatabaseType; import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; import org.rhq.core.domain.criteria.ResourceCriteria; import org.rhq.core.domain.measurement.DataType; @@ -80,7 +81,6 @@ import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.PermissionException; import org.rhq.enterprise.server.authz.RequiredPermission; import org.rhq.enterprise.server.authz.RequiredPermissions; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.common.PerformanceMonitorInterceptor; import org.rhq.enterprise.server.core.AgentManagerLocal; import org.rhq.enterprise.server.resource.ResourceManagerLocal; diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java index 1ef3012..5a6f6ad 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java @@ -24,6 +24,7 @@ import java.util.Set; import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.DisplayType; @@ -35,7 +36,6 @@ import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.server.agentclient.AgentClient; -import org.rhq.enterprise.server.common.EntityContext;
/** * A manager for {@link MeasurementSchedule}s. diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java index d8f0074..c7611cb 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java @@ -23,7 +23,7 @@ import java.util.List; import javax.ejb.Stateless;
import org.rhq.core.domain.auth.Subject; -import org.rhq.enterprise.server.common.EntityContext; +import org.rhq.core.domain.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricViewData; import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricViewsPreferences;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java index f6ce639..473269e 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java @@ -23,7 +23,7 @@ import java.util.List; import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject; -import org.rhq.enterprise.server.common.EntityContext; +import org.rhq.core.domain.common.EntityContext;
/** * @author Joseph Marques diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java index 42ce980..9968592 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java @@ -20,8 +20,8 @@ package org.rhq.enterprise.server.measurement.uibean;
import java.util.Date;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.resource.Resource; -import org.rhq.enterprise.server.common.EntityContext;
public class MetricDisplaySummary extends BaseMetricDisplay implements java.io.Serializable {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java index cae22fd..0e37e3d 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java @@ -37,12 +37,12 @@ import javax.sql.DataSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.measurement.MeasurementDataNumeric; import org.rhq.core.domain.measurement.MeasurementDataPK; import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; import org.rhq.core.util.jdbc.JDBCUtil; import org.rhq.enterprise.server.RHQConstants; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.measurement.MeasurementAggregate; import org.rhq.enterprise.server.measurement.MeasurementNotFoundException; import org.rhq.enterprise.server.util.LookupUtil; diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java index 8323299..dc708f5 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java @@ -32,6 +32,7 @@ import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventDefinition; import org.rhq.core.domain.event.EventSeverity; @@ -41,7 +42,6 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageControl; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.event.EventManagerLocal; import org.rhq.enterprise.server.test.AbstractEJB3Test; import org.rhq.enterprise.server.util.LookupUtil; diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java index 6f6ec38..3145682 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java @@ -51,6 +51,7 @@ import org.rhq.core.domain.alert.BooleanExpression; import org.rhq.core.domain.alert.notification.AlertNotificationLog; import org.rhq.core.domain.alert.notification.ResultState; import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.event.Event; import org.rhq.core.domain.event.EventDefinition; import org.rhq.core.domain.event.EventSeverity; @@ -74,7 +75,6 @@ import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.exception.ThrowableUtil; -import org.rhq.enterprise.server.common.EntityContext; import org.rhq.enterprise.server.event.EventManagerLocal; import org.rhq.enterprise.server.measurement.CallTimeDataManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
commit 3f2b2d7ab890f050e65e90508f95866a29278558 Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Sep 3 08:59:37 2010 -0400
Remove use of GWT.create() from some portlets. This uses the no-arg constructor under the covers. We want to use constructors with explicit locatorIds.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java index fe33c31..0356212 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java @@ -56,7 +56,6 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements P public static PortletViewFactory INSTANCE = new Factory();
public final Portlet getInstance(String locatorId) { - //return GWT.create(AutodiscoveryPortlet.class); return new AutodiscoveryPortlet(locatorId); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java index 5119bf1..b7eeef9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java @@ -19,7 +19,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operatio * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.form.DynamicForm; @@ -46,12 +45,6 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { private static String recentOperations = "Recent Operations"; private static String scheduledOperations = "Scheduled Operations";
- //default no-args constructor for serialization. - //TODO: spinder 9/2/10 revisit why we need to do this? - private OperationsPortlet() { - super("(unitialized)"); - } - public OperationsPortlet(String locatorId) { super(locatorId); } @@ -115,14 +108,9 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet { public static final class Factory implements PortletViewFactory { public static PortletViewFactory INSTANCE = new Factory();
- public final Portlet getInstance() { - return GWT.create(OperationsPortlet.class); - } - public final Portlet getInstance(String locatorId) { return new OperationsPortlet(locatorId); } - }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java index 9838932..f87d80d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java @@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems
import java.util.ArrayList;
-import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; @@ -61,10 +60,6 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort public static final String unlimited = "unlimited"; public static final String defaultValue = unlimited;
- private ProblemResourcesPortlet() { - super("(uninitialized)"); - } - public ProblemResourcesPortlet(String locatorId) { super(locatorId, TITLE, true);
@@ -228,11 +223,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort public static final class Factory implements PortletViewFactory { public static PortletViewFactory INSTANCE = new Factory();
- public final Portlet getInstance() { - return GWT.create(ProblemResourcesPortlet.class); - } - - public Portlet getInstance(String locatorId) { + public final Portlet getInstance(String locatorId) { return new ProblemResourcesPortlet(locatorId); } }
commit 13344f52f5e36ca340b4f246a3368c25120a66c6 Merge: 6cd1302... 0ba7c59... Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Sep 2 10:32:47 2010 -0400
Merge branch 'master' into master-jay
commit 6cd13026c279f154b4d38b10674987e5fb57a246 Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Sep 2 10:30:58 2010 -0400
Selenium Work - Administration Section work
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java index 146303a..2a7db09 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java @@ -38,8 +38,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; */ public class SubjectRoleSelector extends AbstractSelector<Role> {
- public SubjectRoleSelector(String id, Collection<Role> roles) { - super(id); + public SubjectRoleSelector(String locatorId, Collection<Role> roles) { + super(locatorId); if (roles != null) { ListGridRecord[] data = (new RolesDataSource()).buildRecords(roles); setAssigned(data); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java index 5aefeec..1a36bc7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java @@ -52,6 +52,9 @@ import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** @@ -93,7 +96,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { }
private Canvas buildSubjectEditor() { - form = new DynamicForm(); + form = new LocatableDynamicForm(this.getLocatorId()); form.setWidth100();
form.setHiliteRequiredFields(true); @@ -129,7 +132,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { TextItem departmentItem = new TextItem("department"); departmentItem.setRequired(false);
- IButton saveButton = new IButton("Save"); + IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save"); saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { if (form.validate()) { @@ -142,14 +145,14 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { } });
- IButton resetButton = new IButton("Reset"); + IButton resetButton = new LocatableIButton(this.extendLocatorId("Reset"), "Reset"); resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { form.reset(); } });
- IButton cancelButton = new IButton("Cancel"); + IButton cancelButton = new LocatableIButton(this.extendLocatorId("Cancel"), "Cancel"); cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) { if (editorWindow != null) { @@ -160,7 +163,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView { } });
- HLayout buttonLayout = new HLayout(10); + HLayout buttonLayout = new LocatableHLayout(this.extendLocatorId("Buttons"), 10); buttonLayout.setAlign(Alignment.CENTER); buttonLayout.addMember(saveButton); buttonLayout.addMember(resetButton); @@ -210,7 +213,8 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
// form.getDataSource().getField("username").setCanEdit(true );
- roleSelector = new SubjectRoleSelector("UserEditor-Roles", (Set<Role>) record.getAttributeAsObject("roles")); + roleSelector = new SubjectRoleSelector(this.extendLocatorId("Roles"), (Set<Role>) record + .getAttributeAsObject("roles")); roleSelectionItem.setCanvas(roleSelector);
try { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java index 3d09ed8..9d56dc2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java @@ -41,18 +41,15 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; -import org.rhq.enterprise.gui.coregui.client.admin.agent.install.RemoteAgentInstallView; -import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView; -import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView; import org.rhq.enterprise.gui.coregui.client.alert.AlertsView; -import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryView; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView; import org.rhq.enterprise.gui.coregui.client.report.measurement.MeasurementOOBView; import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/** * @author Greg Hinkle @@ -61,6 +58,9 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
public static final String VIEW_PATH = "Reports";
+ private static final String SECTION_INVENTORY = "Inventory"; + private static final String SECTION_REPORTS = "Reports"; + private ViewId currentSectionViewId; private ViewId currentPageViewId;
@@ -85,16 +85,14 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView contentCanvas.setWidth("*"); contentCanvas.setHeight100();
- sectionStack = new SectionStack(); + sectionStack = new LocatableSectionStack(this.getLocatorId()); sectionStack.setShowResizeBar(true); sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE); sectionStack.setWidth(250); sectionStack.setHeight100();
- treeGrids.put("Inventory", buildInventorySection()); - // treeGrids.put("Configuration", buildSystemConfigurationSection()); - // treeGrids.put("Cluster", buildManagementClusterSection()); - treeGrids.put("Reports", buildReportsSection()); + treeGrids.put(SECTION_INVENTORY, buildInventorySection()); + treeGrids.put(SECTION_REPORTS, buildReportsSection());
for (final String name : treeGrids.keySet()) { TreeGrid grid = treeGrids.get(name); @@ -128,7 +126,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
private TreeGrid buildInventorySection() {
- final TreeGrid inventoryTreeGrid = new TreeGrid(); + final TreeGrid inventoryTreeGrid = new LocatableTreeGrid(SECTION_INVENTORY); inventoryTreeGrid.setLeaveScrollbarGap(false); inventoryTreeGrid.setShowHeader(false);
@@ -154,65 +152,24 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView final TreeNode platforms = new TreeNode("Platforms"); platforms.setIcon("types/Platform_up_16.png");
- tree.setRoot(new TreeNode("inventory", tagCloud, suspectMetrics, recentConfigurationChanges, recentOperations, - recentAlerts, alertDefinitions, platforms)); + tree.setRoot(new TreeNode(SECTION_INVENTORY, tagCloud, suspectMetrics, recentConfigurationChanges, + recentOperations, recentAlerts, alertDefinitions, platforms));
inventoryTreeGrid.setData(tree);
return inventoryTreeGrid; }
- private TreeGrid buildManagementClusterSection() { - - final TreeGrid mgmtClusterTreeGrid = new TreeGrid(); - mgmtClusterTreeGrid.setLeaveScrollbarGap(false); - mgmtClusterTreeGrid.setShowHeader(false); - - Tree tree = new Tree(); - final TreeNode manageServersNode = new TreeNode("Servers"); - final TreeNode manageAgentsNode = new TreeNode("Agents"); - final TreeNode manageAffinityGroupsNode = new TreeNode("Affinity Groups"); - final TreeNode managePartitionEventsNode = new TreeNode("Partition Events"); - - tree.setRoot(new TreeNode("clustering", manageServersNode, manageAgentsNode, manageAffinityGroupsNode, - managePartitionEventsNode)); - - mgmtClusterTreeGrid.setData(tree); - - return mgmtClusterTreeGrid; - } - - private TreeGrid buildSystemConfigurationSection() { - - final TreeGrid systemConfigTreeGrid = new TreeGrid(); - systemConfigTreeGrid.setLeaveScrollbarGap(false); - systemConfigTreeGrid.setShowHeader(false); - - Tree tree = new Tree(); - final TreeNode manageSettings = new TreeNode("System Settings"); - final TreeNode manageTemplates = new TreeNode("Templates"); - final TreeNode manageDownloads = new TreeNode("Downloads"); - final TreeNode manageLicense = new TreeNode("License"); - final TreeNode managePlugins = new TreeNode("Plugins"); - - tree.setRoot(new TreeNode("System Configuration", manageSettings, manageTemplates, manageDownloads, - manageLicense, managePlugins)); - - systemConfigTreeGrid.setData(tree); - - return systemConfigTreeGrid; - } - private TreeGrid buildReportsSection() {
- final TreeGrid reportsTreeGrid = new TreeGrid(); + final TreeGrid reportsTreeGrid = new LocatableTreeGrid(SECTION_REPORTS); reportsTreeGrid.setLeaveScrollbarGap(false); reportsTreeGrid.setShowHeader(false);
Tree tree = new Tree(); final TreeNode inventorySummaryNode = new TreeNode("Inventory Summary");
- TreeNode reportsNode = new TreeNode("Reports", inventorySummaryNode); + TreeNode reportsNode = new TreeNode(SECTION_REPORTS, inventorySummaryNode); tree.setRoot(reportsNode);
reportsTreeGrid.setData(tree); @@ -244,7 +201,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView page = URL.decode(page);
Canvas content = null; - if ("Inventory".equals(section)) { + if (SECTION_INVENTORY.equals(section)) {
if ("Tag Cloud".equals(page)) { content = new TaggedView(this.extendLocatorId("TagCloud")); @@ -262,49 +219,12 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView content = new PlatformPortletView(this.extendLocatorId("Platforms")); }
- } else if ("Security".equals(section)) { - - if ("Manage Users".equals(page)) { - content = new UsersView(this.extendLocatorId("Users")); - } else if ("Manage Roles".equals(page)) { - content = new RolesView(this.extendLocatorId("Roles")); - } else if ("Auto Discovery Queue".equals(page)) { - content = new ResourceAutodiscoveryView(this.extendLocatorId("ADQ")); - } else if ("Remote Agent Install".equals(page)) { - content = new RemoteAgentInstallView(this.extendLocatorId("RemoteAgentInstall")); - } - } else if ("Configuration".equals(section)) { - - String url = null; - if ("System Settings".equals(page)) { - url = "/admin/config/Config.do?mode=edit"; - } else if ("Templates".equals(page)) { - url = "/admin/config/EditDefaults.do?mode=monitor&viewMode=all"; - } else if ("Downloads".equals(page)) { - url = "/rhq/admin/downloads-body.xhtml"; - } else if ("License".equals(page)) { - url = "/admin/license/LicenseAdmin.do?mode=view"; - } else if ("Plugins".equals(page)) { - url = "/rhq/admin/plugin/plugin-list.xhtml"; + } else if (SECTION_REPORTS.equals(section)) { + if ("Inventory Summary".equals(page)) { + // TODO + content = null; } - url = addQueryStringParam(url, "nomenu=true"); - content = new FullHTMLPane(url); - - } else if ("Cluster".equals(section)) { - String url = null; - if ("Servers".equals(page)) { - url = "/rhq/ha/listServers.xhtml"; - } else if ("Agents".equals(page)) { - url = "/rhq/ha/listAgents.xhtml"; - } else if ("Affinity Groups".equals(page)) { - url = "/rhq/ha/listAffinityGroups.xhtml"; - } else if ("Partition Events".equals(page)) { - url = "/rhq/ha/listPartitionEvents.xhtml"; - } - url = addQueryStringParam(url, "nomenu=true"); - content = new FullHTMLPane(url); } - for (String name : treeGrids.keySet()) {
TreeGrid treeGrid = treeGrids.get(name); @@ -318,12 +238,13 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView } }
- setContent(content); + if (null != content) { + setContent(content);
- if (content instanceof BookmarkableView) { - ((BookmarkableView) content).renderView(viewPath.next().next()); + if (content instanceof BookmarkableView) { + ((BookmarkableView) content).renderView(viewPath.next().next()); + } } - }
public void renderView(ViewPath viewPath) { @@ -345,9 +266,4 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView }
} - - private static String addQueryStringParam(String url, String param) { - char separatorChar = (url.indexOf('?') == -1) ? '?' : '&'; - return url + separatorChar + param; - } } \ No newline at end of file
commit 06b4a2c0fff9f975b213bc99b6f4e8efc37f3de5 Author: John Sanda jsanda@redhat.com Date: Tue Aug 24 13:54:35 2010 -0400
Updating ScriptRunner to add lib directories to script classpath
diff --git a/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy b/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy index 1c366d7..deb5001 100644 --- a/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy +++ b/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy @@ -1,7 +1,5 @@ package org.rhq.enterprise.server.plugins.groovy
-import org.codehaus.groovy.control.CompilerConfiguration - class ClasspathInitializer {
def initClasspath(String paths, String libDirs, scriptClassLoader) { diff --git a/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy b/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy index 6c9c44d..d5b1af0 100644 --- a/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy +++ b/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy @@ -53,11 +53,12 @@ class ScriptRunner implements ServerPluginComponent, ControlFacet {
def scriptName = parameters.getSimpleValue("script", null) def paths = parameters.getSimpleValue("classpath", '') + def libDirs = parameters.getSimpleValue("libDirs", '')
log.debug("Preparing to execute script, $scriptName")
def scriptClassLoader = new GroovyClassLoader(Thread.currentThread().contextClassLoader, compilerConfig) - new ClasspathInitializer().initClasspath(paths, null, scriptClassLoader) + new ClasspathInitializer().initClasspath(paths, libDirs, scriptClassLoader)
def scriptRoots = new URL[1] scriptRoots[0] = new File(scriptName).toURI().toURL()
rhq-commits@lists.fedorahosted.org