public void onClick(ClickEvent event) { long diff = System.currentTimeMillis() - lastNameFieldBlurTime; if (Math.abs(diff) < 750) { /* * This event propagation is annoying. If the threshold is set too low, then both * the name field blur event and this star image click event fire...but the blur * event fires first, which turns the star white. Then a click on a white star * triggers edit mode, re-enabling the name field. However, setting the threshold * too high will prevent the click event from being handled when the user naturally * wants to click on the star in rapid succession within the threshold time frame. * It is hoped that 750ms will strike a nice balance, and that most users will never * experienced any oddities from this trade-off. */ return; } if (starImage.getUrl().endsWith(STAR_ACTIVE_URL)) { patternNameField.setText(DEFAULT_PATTERN_NAME); patternNameField.setVisible(true); patternNameField.selectAll(); patternNameField.setFocus(true); patternNameLabel.setVisible(false); } else if (starImage.getUrl().endsWith(STAR_ON_URL)) { starImage.setUrl(STAR_ACTIVE_URL); patternNameField.setVisible(false); patternNameLabel.setVisible(false); GWTServiceLookup.getSearchService().deleteSavedSearch(currentSearchId, blackHoleCallback); } }
private void activeSavedSearchByIdOrName(Integer savedSearchId, String savedSearchName) { Subject subject = UserSessionManager.getSessionSubject(); SavedSearchCriteria criteria = new SavedSearchCriteria(); criteria.addFilterSubjectId(subject.getId()); criteria.addFilterId(savedSearchId); // null OK criteria.addFilterName(savedSearchName); // null OK GWTServiceLookup.getSearchService() .findSavedSearchesByCriteria( criteria, new AsyncCallback<List<SavedSearch>>() { @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Failure to select saved search", caught); } @Override public void onSuccess(List<SavedSearch> results) { if (results.size() != 1) { CoreGUI.getMessageCenter() .notify(new Message("Error selecting saved search", Severity.Error)); } else { SavedSearch savedSearch = results.get(0); activateSavedSearch(savedSearch); } } }); }
private void showTagInput() { TagCriteria criteria = new TagCriteria(); criteria.addSortNamespace(PageOrdering.ASC); criteria.addSortSemantic(PageOrdering.ASC); criteria.addSortName(PageOrdering.ASC); GWTServiceLookup.getTagService() .findTagsByCriteria( criteria, new AsyncCallback<PageList<Tag>>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tags_error_1(), caught); } public void onSuccess(PageList<Tag> result) { String[] values = new String[result.size()]; int i = 0; for (Tag tag : result) { values[i++] = tag.toString(); } tagInputDialog.setTagSuggestions(values); } }); tagInputDialog.show(); tagInputDialog.place(addImg); markForRedraw(); }
@Override protected void executeFetch( final DSRequest request, final DSResponse response, GenericDriftChangeSetCriteria criteria) { DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService(); DriftSnapshotRequest snapshotRequest = new DriftSnapshotRequest(driftDefId, version, null, null, true, false); driftService.getSnapshot( snapshotRequest, new AsyncCallback<DriftSnapshot>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_drift_failure_load(), caught); response.setStatus(RPCResponse.STATUS_FAILURE); processResponse(request.getRequestId(), response); } public void onSuccess(DriftSnapshot result) { Collection<DriftSnapshotDirectory> dirs = result.getDriftDirectories(); ListGridRecord[] records = buildRecords(dirs); for (Record record : records) { record.setAttribute(ATTR_DEF_ID, result.getRequest().getDriftDefinitionId()); } response.setData(records); response.setTotalRows(dirs.size()); processResponse(request.getRequestId(), response); } }); }
private void turnNameFieldIntoLabel() { String name = patternNameField.getText(); if (name.equalsIgnoreCase(DEFAULT_PATTERN_NAME)) { name = ""; } arrowImage.setVisible(true); patternNameField.setVisible(false); if (name.equals("")) { GWTServiceLookup.getSearchService().deleteSavedSearch(currentSearchId, blackHoleCallback); currentSearchId = 0; starImage.setUrl(STAR_OFF_URL); } else { // NOTE: currently do not support updated a saved search pattern if (currentSearchId == 0) { String pattern = autoCompletePatternField.getText(); createSavedSearch(name, pattern); } else { updateSavedSearchName(currentSearchId, name); } patternNameLabel.setText(elipse(name)); patternNameLabel.setVisible(true); starImage.setUrl(STAR_ON_URL); } }
class SearchSuggestOracle extends SuggestOracle { private SearchGWTServiceAsync searchService = GWTServiceLookup.getSearchService(); @Override public boolean isDisplayStringHTML() { return true; } @Override public void requestDefaultSuggestions(Request request, Callback callback) { requestSuggestions(request, callback); } @Override public void requestSuggestions(final Request request, final Callback callback) { SearchSuggestionRequest suggestionRequest = (SearchSuggestionRequest) request; String expression = suggestionRequest.getQuery(); int caretPosition = suggestionRequest.getCursorPosition(); searchService.getTabAwareSuggestions( searchBar.getSearchSubsystem(), expression, caretPosition, searchBar.getSelectedTab(), new AsyncCallback<List<SearchSuggestion>>() { public void onSuccess(List<SearchSuggestion> results) { adaptAndHandle(results.toArray(new SearchSuggestion[results.size()])); } public void onFailure(Throwable caught) { SearchSuggestion errorInform = new SearchSuggestion( Kind.InstructionalTextComment, MSG.view_searchBar_instructional_failSuggest()); adaptAndHandle(errorInform); } private void adaptAndHandle(SearchSuggestion... searchSuggestionResults) { List<SearchSuggestionOracleAdapter> adaptedResults = new java.util.ArrayList<SearchSuggestionOracleAdapter>(); for (SearchSuggestion next : searchSuggestionResults) { adaptedResults.add(new SearchSuggestionOracleAdapter(next)); } if (adaptedResults.isEmpty()) { adaptedResults.add( new SearchSuggestionOracleAdapter( new SearchSuggestion( Kind.InstructionalTextComment, MSG.view_searchBar_instructional_noSuggest()))); } SuggestOracle.Response response = new SuggestOracle.Response(adaptedResults); callback.onSuggestionsReady(request, response); } }); } }
public void cancel() { // delete a newly created deployment but only if it's status is failure and it has // no deployments. This should be rare, or maybe impossible, but in an odd case that // the deployment fails and they user wants to Cancel as opposed to Finish, let's // clean up as best as possible. if ((null != getNewDeployment()) && (0 < getNewDeployment().getId())) { BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService(); BundleDeploymentCriteria c = new BundleDeploymentCriteria(); c.addFilterId(getNewDeployment().getId()); c.fetchResourceDeployments(true); bundleServer.findBundleDeploymentsByCriteria( c, // new AsyncCallback<PageList<BundleDeployment>>() { public void onSuccess(PageList<BundleDeployment> newDeploymentList) { if (!newDeploymentList.isEmpty()) { BundleDeployment newDeployment = newDeploymentList.get(0); boolean isFailedToLaunch = BundleDeploymentStatus.FAILURE.equals(newDeployment.getStatus()) || BundleDeploymentStatus.PENDING.equals(newDeployment.getStatus()); boolean hasNoResourceDeployments = ((null == newDeployment.getResourceDeployments()) || newDeployment.getResourceDeployments().isEmpty()); // go ahead and delete it if it hasn't really done anything but get created. // otherwise, let folks inspect via the ui and take further action. // if the deployment can't be deleted then don't try to delete the destination, // it's now in use by the deployment if (isFailedToLaunch && hasNoResourceDeployments) { BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService(); bundleServer.deleteBundleDeployment( newDeployment.getId(), // new AsyncCallback<Void>() { public void onSuccess(Void voidReturn) { deleteNewDestination(); } public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError(MSG.view_bundle_deployWizard_error_1(), caught); } }); } } } public void onFailure(Throwable caught) { // should not really get here CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deployWizard_error_1(), caught); deleteNewDestination(); } }); } else { deleteNewDestination(); } }
public void showContextMenu(final Tree tree, final ResourceGroupEnhancedTreeNode node) { if (node.isAutoClusterNode()) { final ClusterKey clusterKey = (ClusterKey) node.getAttributeAsObject("key"); GWTServiceLookup.getClusterService() .createAutoClusterBackingGroup( clusterKey, true, new AsyncCallback<ResourceGroup>() { @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError( MSG.view_tree_group_error_updateAutoCluster(clusterKey.getKey()), caught); } @Override public void onSuccess(ResourceGroup result) { showContextMenu(tree, node, result); } }); } else if (node.isCompatibleGroupTopNode()) { ResourceGroupCriteria criteria = new ResourceGroupCriteria(); criteria.addFilterId(Integer.parseInt(node.getAttribute("id"))); GWTServiceLookup.getResourceGroupService() .findResourceGroupsByCriteria( criteria, new AsyncCallback<PageList<ResourceGroup>>() { @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError(MSG.view_tree_common_contextMenu_loadFail_group(), caught); } @Override public void onSuccess(PageList<ResourceGroup> result) { showContextMenu(tree, node, result.get(0)); } }); } }
private void updateSavedSearchName(final int savedSearchId, final String newName) { GWTServiceLookup.getSearchService() .updateSavedSearchName( savedSearchId, newName, new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean hadUpdates) { // no message bar to send update message to if hadUpdates } @Override public void onFailure(Throwable caught) {} }); }
private void createSavedSearch(final String name, final String pattern) { Subject subject = UserSessionManager.getSessionSubject(); SavedSearch newSavedSearch = new SavedSearch(searchSubsystem, name, pattern, subject); GWTServiceLookup.getSearchService() .createSavedSearch( newSavedSearch, new AsyncCallback<Integer>() { @Override public void onSuccess(Integer newSavedSearchId) { currentSearchId = newSavedSearchId; } @Override public void onFailure(Throwable caught) {} }); }
private void deleteNewDestination() { if (this.isNewDestination() && (null != this.getDestination())) { BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService(); bundleServer.deleteBundleDestination( this.getDestination().getId(), // new AsyncCallback<Void>() { public void onSuccess(Void voidReturn) { CoreGUI.refresh(); } public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deployWizard_error_2(), caught); } }); } }
public void save(final AsyncCallback<Dashboard> callback) { // a variety of edits (dragResize, add/remove column, etc) can cause column width changes. // Update them // prior to every save. updatePortalColumnWidths(); // since we reset storedDashboard after the async update completes, block modification of the // dashboard // during that interval. DashboardView.this.disable(); GWTServiceLookup.getDashboardService() .storeDashboard( storedDashboard, new AsyncCallback<Dashboard>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_dashboardManager_error(), caught); DashboardView.this.enable(); if (null != callback) { callback.onFailure(caught); } } public void onSuccess(Dashboard result) { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_dashboardManager_saved(result.getName()), Message.Severity.Info)); // The portlet definitions have been merged and updated, reset the portlet windows // with the // up to date portlets. updatePortletWindows(result); storedDashboard = result; if (null != callback) { callback.onSuccess(result); } DashboardView.this.enable(); } }); }
public void handleSelection( final int rowIndex, final int columnIndex, final SavedSearch savedSearch) { Log.debug( "SavedSearchesEventHandler.handleSelection(" + rowIndex + "," + columnIndex + "," + savedSearch + ")"); if (columnIndex == 1) { GWTServiceLookup.getSearchService() .deleteSavedSearch( savedSearch.getId(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) {} @Override public void onSuccess(Void result) { if (currentSearchId == savedSearch.getId()) { currentSearchId = 0; patternNameField.setValue("", true); patternNameField.setVisible(false); patternNameLabel.setText(""); patternNameLabel.setVisible(false); autoCompletePatternField.setFocus(true); starImage.setUrl(STAR_OFF_URL); savedSearchesPanel.hide(); } // is user deleting the one and only element in the list? if (savedSearchesGrid.size() == 1) { savedSearchesPanel.hide(); } savedSearchesGrid.removeRow(rowIndex); } }); } else { activateSavedSearch(savedSearch); // activating the saved search also clicks the button } }
public void delete() { if (null != this.storedDashboard && this.storedDashboard.getId() > 0) { GWTServiceLookup.getDashboardService() .removeDashboard( this.storedDashboard.getId(), new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError(MSG.view_dashboardManager_deleteFail(), caught); } public void onSuccess(Void result) { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_dashboardManager_deleted(storedDashboard.getName()), Message.Severity.Info)); } }); } }
public void executeFetch(final DSRequest request, final DSResponse response) { long ctime = -1; int maxItems = -1; // retrieve current portlet display settings if ((this.portlet != null) && (this.portlet instanceof RecentlyAddedResourcesPortlet)) { RecentlyAddedResourcesPortlet recentAdditionsPortlet = (RecentlyAddedResourcesPortlet) this.portlet; if (recentAdditionsPortlet != null) { if (getMaximumRecentlyAddedToDisplay() > 0) { maxItems = getMaximumRecentlyAddedToDisplay(); } // define the time window if (getMaximumRecentlyAddedWithinHours() > 0) { ctime = System.currentTimeMillis() - (getMaximumRecentlyAddedWithinHours() * MeasurementUtility.HOURS); setOldestDate(ctime); } } } // 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 // if logged in then proceed making server side calls if (UserSessionManager.isLoggedIn()) { GWTServiceLookup.getResourceService() .findRecentlyAddedResources( ctime, maxItems, new AsyncCallback<List<RecentlyAddedResourceComposite>>() { public void onFailure(Throwable throwable) { CoreGUI.getErrorHandler() .handleError(MSG.view_portlet_recentlyAdded_error1(), throwable); } public void onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) { List<RecentlyAddedResourceComposite> list = new ArrayList<RecentlyAddedResourceComposite>(); for (RecentlyAddedResourceComposite recentlyAdded : recentlyAddedList) { list.add(recentlyAdded); list.addAll(recentlyAdded.getChildren()); } response.setData(buildNodes(list)); response.setTotalRows(list.size()); processResponse(request.getRequestId(), response); } }); } else { // Log.debug("user is not logged in. Not fetching recently added resource now."); // answer the datasource response.setTotalRows(0); processResponse(request.getRequestId(), response); } }
/** * The content pane for the resource Summary>Activity subtab. * * @author Jay Shaughnessy */ public class ActivityView extends LocatableVLayout implements DashboardContainer, InitializableView { private static final String DASHBOARD_NAME_PREFIX = "ResourceDashboard_"; private ResourceComposite resourceComposite; private DashboardGWTServiceAsync dashboardService = GWTServiceLookup.getDashboardService(); private DashboardView dashboardView; private LocatableToolStrip footer; private IButton editButton; private IButton resetButton; // Capture the user's global permissions for use by any dashboard or portlet that may need it for // rendering. private Set<Permission> globalPermissions; private boolean editMode = false; private boolean isInitialized = false; public ActivityView(String locatorId, ResourceComposite resourceComposite) { super(locatorId); this.resourceComposite = resourceComposite; } @Override protected void onInit() { if (!isInitialized()) { super.onInit(); // first async call to get global permissions new PermissionsLoader() .loadExplicitGlobalPermissions( new PermissionsLoadedListener() { public void onPermissionsLoaded(Set<Permission> permissions) { globalPermissions = permissions; // now make async call to look for customized dash for this user and entity DashboardCriteria criteria = new DashboardCriteria(); criteria.addFilterCategory(DashboardCategory.RESOURCE); criteria.addFilterResourceId(resourceComposite.getResource().getId()); dashboardService.findDashboardsByCriteria( criteria, new AsyncCallback<PageList<Dashboard>>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError(MSG.view_dashboardsManager_error1(), caught); } public void onSuccess(final PageList<Dashboard> result) { Dashboard dashboard = result.isEmpty() ? getDefaultDashboard() : result.get(0); setDashboard(dashboard); isInitialized = true; // draw() may be done since onInit finishes asynchronously, if so redraw if (isDrawn()) { markForRedraw(); } } }); } }); } } private void setDashboard(Dashboard dashboard) { Canvas[] members = getMembers(); removeMembers(members); // pass in the resource information dashboardView = new DashboardView( extendLocatorId(dashboard.getName()), this, dashboard, EntityContext.forResource(resourceComposite.getResource().getId()), resourceComposite); addMember(dashboardView); footer = new LocatableToolStrip(extendLocatorId("Footer")); footer.setPadding(5); footer.setWidth100(); footer.setMembersMargin(15); editButton = new LocatableIButton( footer.extendLocatorId("Mode"), editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode()); editButton.setAutoFit(true); editButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { editMode = !editMode; editButton.setTitle( editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode()); dashboardView.setEditMode(editMode); } }); resetButton = new LocatableIButton(footer.extendLocatorId("Reset"), MSG.common_button_reset()); resetButton.setAutoFit(true); resetButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { String message = MSG.view_summaryDashboard_resetConfirm(); SC.ask( message, new BooleanCallback() { public void execute(Boolean confirmed) { if (confirmed) { dashboardView.delete(); setDashboard(getDefaultDashboard()); markForRedraw(); } } }); } }); footer.addMember(editButton); footer.addMember(resetButton); addMember(footer); } protected Dashboard getDefaultDashboard() { Subject sessionSubject = UserSessionManager.getSessionSubject(); Resource resource = resourceComposite.getResource(); Dashboard dashboard = new Dashboard(); dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_" + resource.getId()); dashboard.setCategory(DashboardCategory.RESOURCE); dashboard.setResource(resource); dashboard.setColumns(2); // TODO, add real portlets // set leftmost column and let the rest be equally divided dashboard.setColumnWidths("40%"); dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3")); // figure out which portlets to display and how HashMap<String, String> resKeyNameMap = DashboardView.processPortletNameMapForResource(resourceComposite); int colLeft = 0; int colRight = 1; int rowLeft = 0; int rowRight = 0; // Left Column if (resKeyNameMap.containsKey( ResourceMetricsPortlet.KEY)) { // measurments top left if available DashboardPortlet measurements = new DashboardPortlet(ResourceMetricsPortlet.NAME, ResourceMetricsPortlet.KEY, 220); dashboard.addPortlet(measurements, colLeft, rowLeft++); resKeyNameMap.remove(ResourceMetricsPortlet.KEY); } // right Column(approx 60%. As larger more room to display table and N rows.) if (resKeyNameMap.containsKey(ResourceAlertsPortlet.KEY)) { // alerts top right if available DashboardPortlet alerts = new DashboardPortlet(ResourceAlertsPortlet.NAME, ResourceAlertsPortlet.KEY, 220); dashboard.addPortlet(alerts, colRight, rowRight++); resKeyNameMap.remove(ResourceAlertsPortlet.KEY); } if (resKeyNameMap.containsKey(ResourceOperationsPortlet.KEY)) { // operations if available DashboardPortlet ops = new DashboardPortlet(ResourceOperationsPortlet.NAME, ResourceOperationsPortlet.KEY, 220); dashboard.addPortlet(ops, colRight, rowRight++); resKeyNameMap.remove(ResourceOperationsPortlet.KEY); } if (resKeyNameMap.containsKey( ResourceConfigurationUpdatesPortlet.KEY)) { // configuration if available DashboardPortlet ops = new DashboardPortlet( ResourceConfigurationUpdatesPortlet.NAME, ResourceConfigurationUpdatesPortlet.KEY, 220); dashboard.addPortlet(ops, colRight, rowRight++); resKeyNameMap.remove(ResourceConfigurationUpdatesPortlet.KEY); } // Fill out left column(typically smaller portlets) then alternate cols with remaining boolean displayLeft = false; for (String key : resKeyNameMap.keySet()) { DashboardPortlet portlet = new DashboardPortlet(resKeyNameMap.get(key), key, 100); if (rowLeft < 4) { dashboard.addPortlet(portlet, colLeft, rowLeft++); } else { // alternate if (!displayLeft) { dashboard.addPortlet(portlet, colRight, rowRight++); } else { dashboard.addPortlet(portlet, colLeft, rowLeft++); } // toggle displayLeft = !displayLeft; } } return dashboard; } @Override public boolean isInitialized() { return isInitialized; } public Set<Permission> getGlobalPermissions() { return globalPermissions; } /** * name update not supported because the name is derived from the entity id. * * @return */ public boolean supportsDashboardNameEdit() { return false; } public void updateDashboardNames() { return; } @Override public boolean isValidDashboardName(String name) { return ((name != null) && (dashboardView != null) && name.equals(dashboardView.getDashboard().getName())); } @Override public void refresh() { if (isInitialized()) { dashboardView.rebuild(); } } }
@Override protected void onDraw() { super.onDraw(); GWTServiceLookup.getSystemService() .getSystemSettings( new AsyncCallback<SystemSettings>() { @Override public void onSuccess(SystemSettings result) { canvas.addMember(getServerDetails()); Configuration config = new Configuration(); for (Map.Entry<String, String> entry : result.getSystemConfiguration().entrySet()) { String name = entry.getKey(); String value = (entry.getValue() == null) ? "" : entry.getValue(); // some of our properties are actually different values on the server than how // they are to be // visualized in the UI. // -- JAASProvider is a boolean in the UI but is "LDAP" if it was true and "JDBC" // if it was false // -- LDAPProtocol is a boolean in the UI but is "ssl" if true and "" if it was // false // -- some other numerical values need to be converted from milliseconds if (Constant.JAASProvider.equals(name)) { value = Boolean.toString(value.equals(Constant.LDAPJAASProvider)); } else if (Constant.LDAPProtocol.equals(name)) { value = Boolean.toString(value.equalsIgnoreCase("ssl")); } else if (Constant.AgentMaxQuietTimeAllowed.equals(name)) { value = convertMillisToMinutes(value); } else if (Constant.DataMaintenance.equals(name)) { value = convertMillisToHours(value); } else if (Constant.AvailabilityPurge.equals(name) || Constant.AlertPurge.equals(name) || Constant.TraitPurge.equals(name) || Constant.RtDataPurge.equals(name) || Constant.EventPurge.equals(name) || Constant.DriftFilePurge.equals(name) || Constant.BaselineFrequency.equals(name) || Constant.BaselineDataSet.equals(name)) { value = convertMillisToDays(value); } else if (Constant.EnableAgentAutoUpdate.equals(name)) { if (value.trim().length() == 0) { value = "false"; // if, for some reason, this value was empty, use false - let the // user explicitly enable it } } else if (Constant.EnableDebugMode.equals(name)) { if (value.trim().length() == 0) { value = "false"; } } else if (Constant.EnableExperimentalFeatures.equals(name)) { if (value.trim().length() == 0) { value = "false"; } } else if (Constant.DataReindex.equals(name)) { if (value.trim().length() == 0) { value = "true"; } } PropertySimple prop = new PropertySimple(name, value); config.put(prop); } // build our config definition and populate our config editor editor = new ConfigurationEditor( extendLocatorId("configEditor"), getSystemSettingsDefinition(config, result.getDriftPlugins()), config); editor.addPropertyValueChangeListener(SystemSettingsView.this); canvas.addMember(editor); ToolStrip toolStrip = new ToolStrip(); toolStrip.setWidth100(); toolStrip.setMembersMargin(5); toolStrip.setLayoutMargin(5); saveButton = new LocatableIButton(extendLocatorId("Save"), MSG.common_button_save()); saveButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { save(); } }); toolStrip.addMember(saveButton); canvas.addMember(toolStrip); } @Override public void onFailure(Throwable t) { CoreGUI.getErrorHandler() .handleError(MSG.view_admin_systemSettings_cannotLoadSettings(), t); } }); }
private void save() { if (editor.validate()) { Map<String, PropertySimple> simpleProperties = editor.getConfiguration().getSimpleProperties(); HashMap<String, String> props = new HashMap<String, String>(); for (PropertySimple simple : simpleProperties.values()) { String value = (simple.getStringValue() != null) ? simple.getStringValue() : ""; // some of our properties actually need different values on the server than how they were // visualized in the UI. // -- JAASProvider is a boolean in the UI but must be "LDAP" if it was true and "JDBC" if it // was false // -- LDAPProtocol is a boolean in the UI but must be "ssl" if true and "" if it was false // -- some other numerical values need to be converted to milliseconds if (Constant.JAASProvider.equals(simple.getName())) { if (Boolean.parseBoolean(value)) { value = Constant.LDAPJAASProvider; } else { value = Constant.JDBCJAASProvider; } } else if (Constant.LDAPProtocol.equals(simple.getName())) { if (Boolean.parseBoolean(value)) { value = "ssl"; } else { value = ""; } } else if (Constant.AgentMaxQuietTimeAllowed.equals(simple.getName())) { value = convertMinutesToMillis(value); } else if (Constant.DataMaintenance.equals(simple.getName())) { value = convertHoursToMillis(value); } else if (Constant.AvailabilityPurge.equals(simple.getName()) || Constant.AlertPurge.equals(simple.getName()) || Constant.TraitPurge.equals(simple.getName()) || Constant.RtDataPurge.equals(simple.getName()) || Constant.EventPurge.equals(simple.getName()) || Constant.DriftFilePurge.equals(simple.getName()) || Constant.BaselineFrequency.equals(simple.getName()) || Constant.BaselineDataSet.equals(simple.getName())) { value = convertDaysToMillis(value); } props.put(simple.getName(), value); } GWTServiceLookup.getSystemService() .setSystemConfiguration( props, false, new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_admin_systemSettings_savedSettings(), Message.Severity.Info)); } @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError(MSG.view_admin_systemSettings_saveFailure(), caught); } }); } else { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_admin_systemSettings_fixBeforeSaving(), Severity.Warning, EnumSet.of(Message.Option.Transient))); } }
private DynamicForm getServerDetails() { final DynamicForm form = new LocatableDynamicForm(extendLocatorId("serverDetails")); form.setWidth100(); form.setExtraSpace(15); form.setIsGroup(true); form.setGroupTitle(MSG.view_admin_systemSettings_serverDetails()); final StaticTextItem productName = new StaticTextItem("productname", MSG.common_title_name()); final StaticTextItem productVersion = new StaticTextItem("productversion", MSG.common_title_version()); final StaticTextItem productBuildNumber = new StaticTextItem( "productbuild", MSG.view_admin_systemSettings_serverDetails_buildNumber()); final StaticTextItem serverTimezone = new StaticTextItem("timezone", MSG.view_admin_systemSettings_serverDetails_tz()); final StaticTextItem serverTime = new StaticTextItem("localtime", MSG.view_admin_systemSettings_serverDetails_time()); final StaticTextItem serverInstallDir = new StaticTextItem("installdir", MSG.view_admin_systemSettings_serverDetails_installDir()); final StaticTextItem dbUrl = new StaticTextItem("dbUrl", MSG.view_admin_systemSettings_serverDetails_dbUrl()); final StaticTextItem dbProductName = new StaticTextItem("dbProductName", MSG.view_admin_systemSettings_serverDetails_dbName()); final StaticTextItem dbProductVersion = new StaticTextItem( "dbProductVersion", MSG.view_admin_systemSettings_serverDetails_dbVersion()); final StaticTextItem dbDriverName = new StaticTextItem( "dbDriverName", MSG.view_admin_systemSettings_serverDetails_dbDriverName()); final StaticTextItem dbDriverVersion = new StaticTextItem( "dbDriverVersion", MSG.view_admin_systemSettings_serverDetails_dbDriverVersion()); final StaticTextItem currentMeasRawTable = new StaticTextItem( "currentMeasRawTable", MSG.view_admin_systemSettings_serverDetails_currentTable()); final StaticTextItem nextMeasTableRotation = new StaticTextItem( "nextMeasTableRotation", MSG.view_admin_systemSettings_serverDetails_nextRotation()); productName.setWrapTitle(false); productVersion.setWrapTitle(false); productBuildNumber.setWrapTitle(false); serverTimezone.setWrapTitle(false); serverTime.setWrapTitle(false); serverInstallDir.setWrapTitle(false); dbUrl.setWrapTitle(false); dbProductName.setWrapTitle(false); dbProductVersion.setWrapTitle(false); dbDriverName.setWrapTitle(false); dbDriverVersion.setWrapTitle(false); currentMeasRawTable.setWrapTitle(false); nextMeasTableRotation.setWrapTitle(false); form.setItems( productName, productVersion, productBuildNumber, serverTimezone, serverTime, serverInstallDir, dbUrl, dbProductName, dbProductVersion, dbDriverName, dbDriverVersion, currentMeasRawTable, nextMeasTableRotation); GWTServiceLookup.getSystemService() .getServerDetails( new AsyncCallback<ServerDetails>() { @Override public void onSuccess(ServerDetails result) { ProductInfo productInfo = result.getProductInfo(); form.setValue(productName.getName(), productInfo.getName()); form.setValue(productVersion.getName(), productInfo.getVersion()); form.setValue(productBuildNumber.getName(), productInfo.getBuildNumber()); Map<Detail, String> details = result.getDetails(); form.setValue( serverTimezone.getName(), details.get(ServerDetails.Detail.SERVER_TIMEZONE)); form.setValue( serverTime.getName(), details.get(ServerDetails.Detail.SERVER_LOCAL_TIME)); form.setValue( serverInstallDir.getName(), details.get(ServerDetails.Detail.SERVER_INSTALL_DIR)); form.setValue( dbUrl.getName(), details.get(ServerDetails.Detail.DATABASE_CONNECTION_URL)); form.setValue( dbProductName.getName(), details.get(ServerDetails.Detail.DATABASE_PRODUCT_NAME)); form.setValue( dbProductVersion.getName(), details.get(ServerDetails.Detail.DATABASE_PRODUCT_VERSION)); form.setValue( dbDriverName.getName(), details.get(ServerDetails.Detail.DATABASE_DRIVER_NAME)); form.setValue( dbDriverVersion.getName(), details.get(ServerDetails.Detail.DATABASE_DRIVER_VERSION)); form.setValue( currentMeasRawTable.getName(), details.get(ServerDetails.Detail.CURRENT_MEASUREMENT_TABLE)); form.setValue( nextMeasTableRotation.getName(), details.get(ServerDetails.Detail.NEXT_MEASUREMENT_TABLE_ROTATION)); } @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError(MSG.view_admin_systemSettings_cannotLoadServerDetails(), caught); } }); return form; }