List of usage examples for com.google.gwt.user.client.ui TreeItem getParentItem
public TreeItem getParentItem()
From source file:org.aksw.TripleCheckMate.client.widgets.EvaluationItemDialog.java
License:Apache License
private void openSubTree(long errorID) { // treeCloseAll(null); treeError.setSelectedItem(null, true); itemSelected(null);//w ww . j a v a 2 s .c o m treeOpenAll(null); // errorTree.getItem(0).setState(true); if (errorID == 0) { // Do nothing for now } else { TreeItem ti = getTreeItemWithID(null, errorID); if (ti != null) { treeError.setSelectedItem(ti); ti.setState(true, true); TreeItem p = ti.getParentItem(); while (p != null) { p.setState(true, true); p = p.getParentItem(); } } } }
From source file:org.dataconservancy.dcs.access.client.presenter.FacetedSearchPresenter.java
License:Apache License
private void displayFacets(final SearchInput searchInput, Map<String, List<String>> facets) { facetPanel.add(Util.label("Filter By", "GradientFacet")); FlexTable table = Util.createTable(); Tree tree = new Tree(); facetPanel.add(table);//from w ww . j av a2 s . c o m Iterator<Map.Entry<String, List<String>>> it = facets.entrySet().iterator(); int[] countArray = new int[10]; Map<String, List<String>> tmp = new HashMap<String, List<String>>(facets); Iterator<Map.Entry<String, List<String>>> tempIt = tmp.entrySet().iterator(); while (tempIt.hasNext()) { Map.Entry<String, List<String>> pair = (Map.Entry<String, List<String>>) tempIt.next(); if (pair.getKey() != null) { int index = Constants.order.get(pair.getKey()); countArray[index] = ((List<String>) pair.getValue()).size(); tempIt.remove(); } } int orderIndex = 0; int i = 0; while (orderIndex < Constants.displayOrder.size()) { List<String> tempFacets = facets.get(Constants.displayOrder.get(orderIndex));//pairs.getValue(); TreeItem rootItem = new TreeItem();//pairs.getKey()); // rootItem.setHTML("<b>By " +Constants.displayOrder.get(orderIndex)+"</b>"); rootItem.setHTML("<b>" + Constants.displayOrder.get(orderIndex) + "</b>"); String key = ""; Iterator tempiterator = constants.facets.entrySet().iterator(); while (tempiterator.hasNext()) { Map.Entry temppairs = (Map.Entry) tempiterator.next(); if (temppairs.getValue().equals(Constants.displayOrder.get(orderIndex))) key = (String) temppairs.getKey(); } List<String> childFacets = SeadApp.selectedItems.get(key); int childExists = 0; //get the right index int index; if (tempFacets != null) { for (int j = 0; j < tempFacets.size(); j++) { String countStr = tempFacets.get(j).substring(tempFacets.get(j).lastIndexOf('(') + 1, tempFacets.get(j).lastIndexOf(')')); int count = Integer.valueOf(countStr); if (count == 0) continue; int facetLength = searchInput.getFacetField().length + 1; int flagAddFacet = 1; for (int k = 0; k < facetLength - 1; k++) { String facetFieldKey = null; Iterator iterator = constants.facets.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry pair = (Map.Entry) iterator.next(); if (pair.getValue().equals(Constants.displayOrder.get(orderIndex))) { facetFieldKey = (String) pair.getKey(); break; } } if (searchInput.getFacetField()[k].equalsIgnoreCase(facetFieldKey) && searchInput.getFacetValue()[k].equalsIgnoreCase(tempFacets.get(j))) { flagAddFacet = 0; } } final String[] facetFieldNew; final String[] facetValueNew; if (flagAddFacet == 1) { facetFieldNew = new String[facetLength]; facetValueNew = new String[facetLength]; for (int k = 0; k < facetLength - 1; k++) { facetFieldNew[k] = searchInput.getFacetField()[k]; facetValueNew[k] = searchInput.getFacetValue()[k]; } Iterator iterator = constants.facets.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry pair = (Map.Entry) iterator.next(); if (pair.getValue().equals(Constants.displayOrder.get(orderIndex))) { facetFieldNew[facetLength - 1] = (String) pair.getKey(); break; } } facetValueNew[facetLength - 1] = tempFacets.get(j); } else { facetFieldNew = new String[facetLength - 1]; facetValueNew = new String[facetLength - 1]; for (int k = 0; k < facetLength - 1; k++) { facetFieldNew[k] = searchInput.getFacetField()[k]; facetValueNew[k] = searchInput.getFacetValue()[k]; } } CheckBox checkBox; FlexTable smallTable; Label lbl; if (Constants.displayOrder.get(orderIndex).equals("metadata standard") && tempFacets.get(j).contains("fgdc")) { String labelValue = tempFacets.get(j); labelValue = labelValue.substring(labelValue.lastIndexOf('('), labelValue.lastIndexOf(')') + 1); //labelValue = "FGDC"+labelValue;type filter text lbl = Util.label("FGDC", "FacetHyperlink"); Label countLbl = new Label(" (" + countStr + ")"); smallTable = Util.createTable(); smallTable.setWidget(0, 0, lbl); smallTable.setWidget(0, 1, countLbl); checkBox = new CheckBox("FGDC" + " (" + countStr + ")"); String facetString = tempFacets.get(j).substring(0, tempFacets.get(j).lastIndexOf('(')); if (childFacets != null) if (childFacets.contains(facetString)) checkBox.setValue(true); checkBox.setName(facetString); rootItem.addItem(checkBox); rootItem.setState(false); } else { String facetString = tempFacets.get(j).substring(0, tempFacets.get(j).lastIndexOf('(')); if (facetString.length() == 0) { continue; } lbl = Util.label(facetString, "FacetHyperlink"); Label countLbl = new Label(" (" + countStr + ")"); smallTable = Util.createTable(); smallTable.setWidget(0, 0, lbl); smallTable.setWidget(0, 1, countLbl); checkBox = new CheckBox(facetString + " (" + countStr + ")"); checkBox.setName(facetString); if (childFacets != null) if (childFacets.contains(facetString)) checkBox.setValue(true); rootItem.addItem(checkBox); rootItem.setState(false); } } tree.addItem(rootItem); } orderIndex++; //it.remove(); //change the display later } tree.addSelectionHandler(new SelectionHandler<TreeItem>() { @Override public void onSelection(SelectionEvent event) { TreeItem item = (TreeItem) event.getSelectedItem(); String key = ""; Iterator iterator = constants.facets.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry pairs = (Map.Entry) iterator.next(); String value = (String) pairs.getValue(); String itemText = item.getParentItem().getText(); if (value.equals(itemText)) key = (String) pairs.getKey(); } if (((CheckBox) item.getWidget()).getValue()) { //unselected List<String> children = SeadApp.selectedItems.get(key); children.remove(((CheckBox) item.getWidget()).getName()); if (children.size() == 0) SeadApp.selectedItems.remove(key); else SeadApp.selectedItems.put(key, children); } else { List<String> children = SeadApp.selectedItems.get(key); if (children == null) children = new ArrayList<String>(); children.add(((CheckBox) item.getWidget()).getName()); SeadApp.selectedItems.put(key, children); } int totalFacets = 0; iterator = SeadApp.selectedItems.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry pairs = (Map.Entry) iterator.next(); List<String> facetValues = (List<String>) pairs.getValue(); totalFacets += facetValues.size(); } String[] data = new String[searchInput.getUserfields().length * 2 + totalFacets * 2 + 2]; int i = 0; int index = -1; for (i = 0; i < searchInput.getUserfields().length; i += 2) { data[++index] = searchInput.getUserfields()[i].name(); data[++index] = searchInput.getUserqueries()[i]; } iterator = SeadApp.selectedItems.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry pairs = (Map.Entry) iterator.next(); List<String> facetValues = (List<String>) pairs.getValue(); for (String facetValue : facetValues) { data[++index] = (String) pairs.getKey(); data[++index] = facetValue; } } data[++index] = String.valueOf(searchInput.getOffset()); data[++index] = String.valueOf(totalFacets); History.newItem(SeadState.SEARCH.toToken(data)); } }); facetPanel.add(tree); //stop tree }
From source file:org.daxplore.presenter.client.ui.QuestionPanel.java
License:Open Source License
/** * Set a new query definition, updating which group is open and * what question is selected.//from w w w .j a v a2 s.c om * * @param queryDefinition * the new query definition */ public void setQueryDefinition(QueryDefinition queryDefinition) { Iterator<TreeItem> iter = treeRoot.treeItemIterator(); while (iter.hasNext()) { TreeItem curr = iter.next(); if (curr instanceof QuestionTreeItem) { if (((QuestionTreeItem) curr).getQuestionID().equalsIgnoreCase(queryDefinition.getQuestionID())) { treeRoot.setSelectedItem(null, false); curr.setSelected(true); selected = (QuestionTreeItem) curr; curr.getParentItem().setState(true, true); } else { curr.setSelected(false); } } } treeRoot.ensureSelectedItemVisible(); }
From source file:org.drools.brms.client.categorynav.CategoryExplorerWidget.java
License:Apache License
private String getPath(TreeItem item) { String categoryPath = (String) item.getUserObject(); TreeItem parent = item.getParentItem(); while (parent != null) { categoryPath = ((String) parent.getUserObject()) + "/" + categoryPath; parent = parent.getParentItem(); }/* w w w . ja v a2 s . c o m*/ return categoryPath; }
From source file:org.drools.guvnor.client.categorynav.CategoryExplorerWidget.java
License:Apache License
private String getPath(TreeItem item) { String categoryPath = (String) item.getUserObject(); if (categoryPath == null) return null; TreeItem parent = item.getParentItem(); while (parent.getUserObject() != null) { categoryPath = ((String) parent.getUserObject()) + "/" + categoryPath; System.out.println("categoryPath: " + categoryPath); parent = parent.getParentItem(); }// www . j av a2 s .c om return categoryPath; }
From source file:org.drools.guvnor.client.explorer.PackagesTree.java
License:Apache License
public void onSelection(SelectionEvent<TreeItem> event) { TreeItem node = event.getSelectedItem(); Object userObject = node.getUserObject(); TabOpener opener = TabOpener.getInstance(); if (userObject != null) { if (userObject instanceof PackageConfigData && !((PackageConfigData) userObject).isGlobal()) { PackageConfigData pc = (PackageConfigData) userObject; RulePackageSelector.currentlySelectedPackage = pc.name; String uuid = pc.uuid; opener.openPackageEditor(uuid, new Command() { public void execute() { // refresh the package tree. refreshTree();//from w w w . jav a 2 s.co m } }); } else if (userObject instanceof String[]) { final String[] formats = (String[]) userObject; final PackageConfigData packageConfigData = (PackageConfigData) node.getParentItem() .getUserObject(); RulePackageSelector.currentlySelectedPackage = packageConfigData.name; String key = key(formats, packageConfigData); opener.openPackageViewAssets(packageConfigData.uuid, packageConfigData.name, key, formats.length == 0 ? null : Arrays.asList(formats), formats.length == 0 ? Boolean.TRUE : null, node.getText()); } else if (userObject instanceof String) { // Ignore, there is no click event for this. } else { throw new IllegalArgumentException("The userObject (" + userObject + ") is not supported."); } } }
From source file:org.drools.guvnor.client.widgets.categorynav.CategoryExplorerWidget.java
License:Apache License
private String getPath(TreeItem item) { String categoryPath = (String) item.getUserObject(); if (categoryPath == null) return null; TreeItem parent = item.getParentItem(); while (parent.getUserObject() != null) { categoryPath = ((String) parent.getUserObject()) + "/" + categoryPath; parent = parent.getParentItem(); }/*from ww w .jav a 2 s.c om*/ return categoryPath; }
From source file:org.ebayopensource.turmeric.monitoring.client.presenter.ConsumerPresenter.java
License:Open Source License
/** * Bind.// www. ja v a 2s . c o m */ public void bind() { // listen for any uploads of the services/operations list by other tabs this.eventBus.addHandler(GetServicesEvent.TYPE, new GetServicesEventHandler() { public void onData(GetServicesEvent event) { // only fetch once? if (ConsumerPresenter.this.servicesList == null) { ConsumerPresenter.this.servicesList = event.getData(); ConsumerPresenter.this.view.setServicesMap(event.getData()); } } }); // listen for any changes from other tabs to the currently selected // service or operation this.eventBus.addHandler(ObjectSelectionEvent.TYPE, new ObjectSelectionEventHandler() { public void onSelection(ObjectSelectionEvent event) { selectionContext = new SelectionContext(); if (event.getSelection(ObjectType.ServiceName) != null) selectionContext.select(ObjectType.ServiceName, event.getSelection(ObjectType.ServiceName)); if (event.getSelection(ObjectType.OperationName) != null) selectionContext.select(ObjectType.OperationName, event.getSelection(ObjectType.OperationName)); } }); // listen for any changes from other tabs to the currently selected // dates this.eventBus.addHandler(DateFilterSelectionEvent.TYPE, new DateFilterSelectionHandler() { public void onSelection(DateFilterSelectionEvent event) { selectedDate1 = event.getDate1(); selectedDate2 = event.getDate2(); selectedDuration = event.getDuration(); view.getFilter().setHours1(Util.getAvailableHours(selectedDate1)); view.getFilter().setHour1(new Date(selectedDate1).getHours()); view.getFilter().setDate1(new Date(selectedDate1)); view.getFilter().setDate2(new Date(selectedDate2)); view.getFilter().setDuration(selectedDuration); } }); // listen for user selection of date1 this.view.addValueChangeHandlerForDate1(new ValueChangeHandler<Date>() { public void onValueChange(ValueChangeEvent<Date> event) { Date date = event.getValue(); int[] hrs = Util.getAvailableHours(date); ConsumerPresenter.this.view.getFilter().setHours1(hrs); } }); // handle user selection of some new dates and intervals to see metrics // for this.view.addFilterOptionsApplyClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // Get the date component long oldDate1 = selectedDate1; long oldDate2 = selectedDate2; selectedDate1 = ConsumerPresenter.this.view.getFilter().getDate1().getValue().getTime(); selectedDate2 = ConsumerPresenter.this.view.getFilter().getDate2().getValue().getTime(); // Get the hour component int hour1 = ConsumerPresenter.this.view.getFilter().getHour1(); int hour2 = ConsumerPresenter.this.view.getFilter().getHour1(); selectedDate1 += (Util.HRS_1_MS * hour1); selectedDate2 += (Util.HRS_1_MS * hour2); // Get the selected interval int oldDuration = selectedDuration; selectedDuration = ConsumerPresenter.this.view.getFilter().getDuration(); view.setFilterLabel(makeFilterLabel(selectedDate1, selectedDate2, selectedDuration)); // tell other interested tabs that the selected dates have // changed if ((oldDate1 != selectedDate1) || (oldDate2 != selectedDate2) || (oldDuration != selectedDuration)) { eventBus.fireEvent( new DateFilterSelectionEvent(selectedDate1, selectedDate2, selectedDuration)); } // Get which metrics are required selectedMetrics = Util.convertToEnumFromCamelCase( ConsumerPresenter.this.view.getFilter().getSelectedMetricNames(), ConsumerMetric.class); // Clean up from previous selections ConsumerPresenter.this.view.reset(); // Make a history event so the back/forward buttons work but // don't fire it as we don't // want to change pages fetchMetrics(selectedMetrics, selectionContext, selectedDate1, selectedDate2, selectedDuration); insertHistory(selectionContext, selectedDate1, selectedDate2, selectedDuration, selectedMetrics, false); } }); // handle selection of service or operation from list this.view.addTreeElementSelectionHandler(new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { TreeItem selection = event.getSelectedItem(); // get service and or operation name corresponding to // this selection selectionContext.unselect(ObjectType.ServiceName); selectionContext.unselect(ObjectType.OperationName); // If its the root, ignore it if (selection.getParentItem() != null) { // If its a leaf, its an operation if (selection.getChildCount() == 0) { selectionContext.select(ObjectType.OperationName, selection.getText()); selectionContext.select(ObjectType.ServiceName, selection.getParentItem().getText()); } else { // Its a service selectionContext.select(ObjectType.ServiceName, selection.getText()); } } view.setSelection(selectionContext.getSelections()); eventBus.fireEvent(new ObjectSelectionEvent(selectionContext.getSelections())); // Get the date component selectedDate1 = ConsumerPresenter.this.view.getFilter().getDate1().getValue().getTime(); selectedDate2 = ConsumerPresenter.this.view.getFilter().getDate2().getValue().getTime(); // Get the hour component int hour1 = ConsumerPresenter.this.view.getFilter().getHour1(); int hour2 = ConsumerPresenter.this.view.getFilter().getHour1(); selectedDate1 += (Util.HRS_1_MS * hour1); selectedDate2 += (Util.HRS_1_MS * hour2); // Get the interval selectedDuration = ConsumerPresenter.this.view.getFilter().getDuration(); // Get the metrics requested selectedMetrics = Util.convertToEnumFromCamelCase( ConsumerPresenter.this.view.getFilter().getSelectedMetricNames(), ConsumerMetric.class); view.reset(); // Fetch set of metrics for the selected // service/operation for the currently selected dates fetchMetrics(selectedMetrics, selectionContext, selectedDate1, selectedDate2, selectedDuration); // Make a history event so the back/forward buttons work // but don't fire it as we don't // want to change pages insertHistory(selectionContext, selectedDate1, selectedDate2, selectedDuration, selectedMetrics, false); } }); }
From source file:org.ebayopensource.turmeric.monitoring.client.presenter.ErrorPresenter.java
License:Open Source License
/** * Bind.//from w w w .j a v a 2s . c o m */ public void bind() { //listen for any uploads of the services/operations list by other tabs this.eventBus.addHandler(GetServicesEvent.TYPE, new GetServicesEventHandler() { public void onData(GetServicesEvent event) { //only fetch once? if (servicesList == null) { servicesList = event.getData(); view.setServicesMap(event.getData()); } } }); //listen for any changes from other tabs to the currently selected service or operation this.eventBus.addHandler(ObjectSelectionEvent.TYPE, new ObjectSelectionEventHandler() { public void onSelection(ObjectSelectionEvent event) { selectionContext = new SelectionContext(); Map<ObjectType, String> selections = event.getSelections(); if (selections != null) { for (Map.Entry<ObjectType, String> entry : selections.entrySet()) { if (entry.getValue() != null) selectionContext.select(entry.getKey(), entry.getValue()); } } } }); //listen for any changes from other tabs to the currently selected dates this.eventBus.addHandler(DateFilterSelectionEvent.TYPE, new DateFilterSelectionHandler() { public void onSelection(DateFilterSelectionEvent event) { selectedDate1 = event.getDate1(); selectedDate2 = event.getDate2(); selectedDurationHrs = event.getDuration(); view.getFilter().setHours1(Util.getAvailableHours(selectedDate1)); view.getFilter().setHour1(new Date(selectedDate1).getHours()); view.getFilter().setDate1(new Date(selectedDate1)); view.getFilter().setDate2(new Date(selectedDate2)); view.getFilter().setDuration(selectedDurationHrs); } }); //listen for user selection of date1 this.view.addValueChangeHandlerForDate1(new ValueChangeHandler<Date>() { public void onValueChange(ValueChangeEvent<Date> event) { Date date = event.getValue(); int[] hrs = Util.getAvailableHours(date); view.getFilter().setHours1(hrs); } }); //handle user selection of some new dates and intervals to see metrics for this.view.addFilterOptionsApplyClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { //Get the date component long oldDate1 = selectedDate1; long oldDate2 = selectedDate2; selectedDate1 = view.getFilter().getDate1().getValue().getTime(); selectedDate2 = view.getFilter().getDate2().getValue().getTime(); //Get the hour component int hour1 = view.getFilter().getHour1(); int hour2 = view.getFilter().getHour1(); selectedDate1 += (Util.HRS_1_MS * hour1); selectedDate2 += (Util.HRS_1_MS * hour2); //Get the selected interval int oldDuration = selectedDurationHrs; selectedDurationHrs = view.getFilter().getDuration(); view.setFilterLabel(makeFilterLabel(selectedDate1, selectedDate2, selectedDurationHrs)); //tell other interested tabs that the selected dates have changed if ((oldDate1 != selectedDate1) || (oldDate2 != selectedDate2) || (oldDuration != selectedDurationHrs)) { eventBus.fireEvent( new DateFilterSelectionEvent(selectedDate1, selectedDate2, selectedDurationHrs)); } view.setFilterLabel(makeFilterLabel(selectedDate1, selectedDate2, selectedDurationHrs)); List<String> metrics = ((Filterable.ErrorFilterable) view.getFilter()) .getSelectedCategoryViewNames(); if (metrics.isEmpty()) metrics = ((Filterable.ErrorFilterable) view.getFilter()).getSelectedSeverityViewNames(); //Get which metrics are required selectedMetrics = Util.convertToEnumFromCamelCase(metrics, ErrorMetric.class); //Clean up from previous selections view.reset(); fetchMetrics(selectedMetrics, selectionContext, selectedDate1, selectedDate2, selectedDurationHrs); //Make a history event so the back/forward buttons work but don't fire it as we don't //want to change pages insertHistory(selectionContext, selectedDate1, selectedDate2, selectedDurationHrs, selectedMetrics, false); } }); //handle selection of service or operation from list this.view.addTreeElementSelectionHandler(new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { TreeItem selection = event.getSelectedItem(); //get service and or operation name corresponding to this selection selectionContext.unselect(ObjectType.ServiceName); selectionContext.unselect(ObjectType.OperationName); selectionContext.unselect(ObjectType.ErrorId); selectionContext.unselect(ObjectType.ErrorName); if (selection.getParentItem() != null) { selectionContext = new SelectionContext(); //If its a leaf, its an operation if (selection.getChildCount() == 0) { selectionContext.select(ObjectType.OperationName, selection.getText()); selectionContext.select(ObjectType.ServiceName, selection.getParentItem().getText()); } else { //Its a service selectionContext.select(ObjectType.ServiceName, selection.getText()); } } view.setSelection(selectionContext.getSelections()); eventBus.fireEvent(new ObjectSelectionEvent(selectionContext.getSelections())); //Get the date component selectedDate1 = view.getFilter().getDate1().getValue().getTime(); selectedDate2 = view.getFilter().getDate2().getValue().getTime(); //Get the hour component int hour1 = view.getFilter().getHour1(); int hour2 = view.getFilter().getHour1(); selectedDate1 += (Util.HRS_1_MS * hour1); selectedDate2 += (Util.HRS_1_MS * hour2); //Get the interval selectedDurationHrs = view.getFilter().getDuration(); //Get the metrics requested List<String> metrics = ((Filterable.ErrorFilterable) view.getFilter()) .getSelectedCategoryViewNames(); if (metrics.isEmpty()) metrics = ((Filterable.ErrorFilterable) view.getFilter()).getSelectedSeverityViewNames(); //Get which metrics are required selectedMetrics = Util.convertToEnumFromCamelCase(metrics, ErrorMetric.class); view.reset(); //Fetch set of metrics for the selected service/operation for the currently selected dates fetchMetrics(selectedMetrics, selectionContext, selectedDate1, selectedDate2, selectedDurationHrs); //Make a history event so the back/forward buttons work but don't fire it as we don't //want to change pages insertHistory(selectionContext, selectedDate1, selectedDate2, selectedDurationHrs, selectedMetrics, false); } }); }
From source file:org.ebayopensource.turmeric.monitoring.client.presenter.ServicePresenter.java
License:Open Source License
/** * Bind./*w w w . j a v a2 s . co m*/ */ public void bind() { // listen for any changes from other tabs to the currently selected // service or operation this.eventBus.addHandler(ObjectSelectionEvent.TYPE, new ObjectSelectionEventHandler() { public void onSelection(ObjectSelectionEvent event) { selectionContext = new SelectionContext(); if (event.getSelection(ObjectType.ServiceName) != null) selectionContext.select(ObjectType.ServiceName, event.getSelection(ObjectType.ServiceName)); if (event.getSelection(ObjectType.OperationName) != null) selectionContext.select(ObjectType.OperationName, event.getSelection(ObjectType.OperationName)); } }); // listen for changes to date1 from other tabs this.view.addValueChangeHandlerForDate1(new ValueChangeHandler<Date>() { public void onValueChange(ValueChangeEvent<Date> event) { Date date = event.getValue(); int[] hrs = Util.getAvailableHours(date); ServicePresenter.this.view.getFilter().setHours1(hrs); } }); // handle user selection of some new dates and intervals to see metrics // for this.view.addFilterOptionsApplyClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (selectionContext.getSelection(ObjectType.ServiceName) == null) { view.error(ConsoleUtil.messages.selectServer()); } else { // Get the date component selectedDate1 = ServicePresenter.this.view.getFilter().getDate1().getValue().getTime(); selectedDate2 = ServicePresenter.this.view.getFilter().getDate2().getValue().getTime(); // Get the hour component int hour1 = ServicePresenter.this.view.getFilter().getHour1(); int hour2 = ServicePresenter.this.view.getFilter().getHour1(); selectedDate1 += (Util.HRS_1_MS * hour1); selectedDate2 += (Util.HRS_1_MS * hour2); // Get the selected interval selectedDurationHrs = ServicePresenter.this.view.getFilter().getDuration(); view.setFilterLabel(makeFilterLabel(selectedDate1, selectedDate2, selectedDurationHrs)); // Inform of changes to dates and durations eventBus.fireEvent( new DateFilterSelectionEvent(selectedDate1, selectedDate2, selectedDurationHrs)); // Get which metrics are required selectedMetrics = Util.convertToEnumFromCamelCase( ServicePresenter.this.view.getFilter().getSelectedMetricNames(), ServiceMetric.class); view.reset(); // Window.alert("getApplyButton().addClickHandler. Before fetchMetrics"); // Make a history event so the back/forward buttons work but // don't fire it as we don't // want to change pages fetchMetrics(selectedMetrics, selectionContext, selectedDate1, selectedDate2, selectedDurationHrs); insertHistory(selectionContext, selectedDate1, selectedDate2, selectedDurationHrs, selectedMetrics, false); } } }); // handle selection of service or operation from list this.view.addTreeElementSelectionHandler(new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { TreeItem selection = event.getSelectedItem(); // get service and or operation name corresponding to // this selection selectionContext = new SelectionContext(); // If its the root, then no service is selected if (selection.getParentItem() == null) { selectionContext.unselect(ObjectType.ServiceName); selectionContext.unselect(ObjectType.OperationName); } else { // If its a leaf, its an operation if (selection.getChildCount() == 0) { selectionContext.select(ObjectType.ServiceName, selection.getParentItem().getText()); selectionContext.select(ObjectType.OperationName, selection.getText()); } else { // Its a service selectionContext.select(ObjectType.ServiceName, selection.getText()); } } view.setSelection(selectionContext.getSelections()); // tell any interested parties the user has selected a // service or operation fireObjectSelectionEvent(selectionContext); // Get the date component selectedDate1 = ServicePresenter.this.view.getFilter().getDate1().getValue().getTime(); selectedDate2 = ServicePresenter.this.view.getFilter().getDate2().getValue().getTime(); // Get the hour component int hour1 = ServicePresenter.this.view.getFilter().getHour1(); int hour2 = ServicePresenter.this.view.getFilter().getHour1(); selectedDate1 += (Util.HRS_1_MS * hour1); selectedDate2 += (Util.HRS_1_MS * hour2); // Get the interval selectedDurationHrs = ServicePresenter.this.view.getFilter().getDuration(); // Inform of the selection of dates and duration eventBus.fireEvent(new DateFilterSelectionEvent(selectedDate1, selectedDate2, selectedDurationHrs)); // Get the metrics requested selectedMetrics = Util.convertToEnumFromCamelCase( ServicePresenter.this.view.getFilter().getSelectedMetricNames(), ServiceMetric.class); view.reset(); // If at least a service was selected, get the metrics // for the currently selected date if (selectionContext.isSelected(ObjectType.ServiceName)) fetchMetrics(selectedMetrics, selectionContext, selectedDate1, selectedDate2, selectedDurationHrs); // Make a history event so the back/forward buttons work // but don't fire it as we don't // want to change pages insertHistory(selectionContext, selectedDate1, selectedDate2, selectedDurationHrs, selectedMetrics, false); } }); }