private void setupTestDetailsTree() { CellTree.Resources res = GWT.create(CellTree.BasicResources.class); final MultiSelectionModel<PlotNameDto> selectionModel = new MultiSelectionModel<PlotNameDto>(); taskDetailsTree = new CellTree(new TaskDataTreeViewModel(selectionModel, getResources()), null, res); taskDetailsTree.addStyleName(getResources().css().taskDetailsTree()); }
/* (non-Javadoc) * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#editNode(java.lang.String, java.lang.String) */ @Override public void editNode(String name, String label) { if (selectedNode != null) { selectedNode.setName(name); selectedNode.setLabel(label); closeParentOpenNodes(cellTree.getRootTreeNode()); } }
/* (non-Javadoc) * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#removeNode() */ @Override public void removeNode() { if (selectedNode != null) { CellTreeNode parent = selectedNode.getParent(); parent.removeChild(selectedNode); closeParentOpenNodes(cellTree.getRootTreeNode()); selectionModel.setSelected(parent, true); } }
/* (non-Javadoc) * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#paste() */ @Override public void paste() { if (selectedNode != null) { CellTreeNode pasteNode = copiedNode.cloneNode(); selectedNode.appendChild(pasteNode); closeSelectedOpenNodes(cellTree.getRootTreeNode()); selectionModel.setSelected(selectedNode, true); copiedNode = pasteNode; } }
/* (non-Javadoc) * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#addNode(java.lang.String, java.lang.String, short) */ @Override public CellTreeNode addNode(String value, String label, short nodeType) { CellTreeNode childNode = null; if ((selectedNode != null) && (value != null) && (value.trim().length() > 0)) { // if nodeTex textbox is not empty childNode = selectedNode.createChild(value, label, nodeType); closeSelectedOpenNodes(cellTree.getRootTreeNode()); selectionModel.setSelected(selectedNode, true); } return childNode; }
/** Selection Handler, Tree Open and Close Handlers Defined. */ private void cellTreeHandlers() { selectionModel.addSelectionChangeHandler( new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { // assigning the selected object to the selectedNode variable. selectedNode = selectionModel.getSelectedObject(); } }); /** * This handler is implemented to save the open state of the Celltree in CellTreeNode Object Set * to isOpen boolean in CellTreeNode. After adding/removing/editing a node to the celltree * Manually we have to close and open all nodes to see the new node, so using this boolean we * will know which node was already in opened state and closed state. */ cellTree.addOpenHandler( new OpenHandler<TreeNode>() { @Override public void onOpen(OpenEvent<TreeNode> event) { CellTreeNode node = (CellTreeNode) event.getTarget().getValue(); node.setOpen(true); clearMessages(); } }); cellTree.addCloseHandler( new CloseHandler<TreeNode>() { @Override public void onClose(CloseEvent<TreeNode> event) { CellTreeNode node = (CellTreeNode) event.getTarget().getValue(); setOpenToFalse( node); // when a node is closed set all the child nodes isOpen boolean to false. node.setOpen(false); clearMessages(); } }); }
public void updatePlace(TrendsPlace place) { if (this.place != null) return; this.place = place; final TrendsPlace finalPlace = this.place; if (place.getSelectedSessionIds().isEmpty()) { sessionsDataGrid .getSelectionModel() .addSelectionChangeHandler(new SessionSelectChangeHandler()); selectTests = true; testDataGrid.getSelectionModel().addSelectionChangeHandler(new TestSelectChangeHandler()); TaskDataTreeViewModel viewModel = (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel(); viewModel .getSelectionModel() .addSelectionChangeHandler(new TaskPlotSelectionChangedHandler()); metricPanel.addSelectionListener(new MetricsSelectionChangedHandler()); chooseTab(place.getToken()); return; } SessionDataService.Async.getInstance() .getBySessionIds( 0, place.getSelectedSessionIds().size(), place.getSelectedSessionIds(), new AsyncCallback<PagedSessionDataDto>() { @Override public void onFailure(Throwable caught) { caught.printStackTrace(); } @Override public void onSuccess(PagedSessionDataDto result) { for (SessionDataDto session : result.getSessionDataDtoList()) { sessionsDataGrid.getSelectionModel().setSelected(session, true); } sessionsDataGrid .getSelectionModel() .addSelectionChangeHandler(new SessionSelectChangeHandler()); sessionsDataGrid .getSelectionModel() .setSelected(result.getSessionDataDtoList().iterator().next(), true); chooseTab(finalPlace.getToken()); } }); History.newItem(NameTokens.EMPTY); }
/* (non-Javadoc) * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#editNode(boolean, mat.client.clause.clauseworkspace.model.CellTreeNode, com.google.gwt.user.cellview.client.TreeNode) */ @Override public void editNode(boolean isValideNodeValue, CellTreeNode node, TreeNode subTree) { node.setValidNode(isValideNodeValue); selectedNode = node; closeParentOpenNodes(cellTree.getRootTreeNode()); }
/* (non-Javadoc) * @see com.google.gwt.event.dom.client.KeyDownHandler#onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent) */ @Override public void onKeyDown(KeyDownEvent event) { // System.out.println(event.getNativeKeyCode()); int keyCode = event.getNativeKeyCode(); if (selectedNode != null) { short nodeType = selectedNode.getNodeType(); if (event.isControlKeyDown()) { if (keyCode == ClauseConstants.COPY_C) { // COPY if ((nodeType != CellTreeNode.MASTER_ROOT_NODE) && (nodeType != CellTreeNode.ROOT_NODE)) { popupPanel.hide(); copy(); } } else if (keyCode == ClauseConstants.PASTE_V) { // PASTE boolean canPaste = false; popupPanel.hide(); if (copiedNode != null) { switch (selectedNode.getNodeType()) { case CellTreeNode.ROOT_NODE: if (selectedNode.equals(copiedNode.getParent())) { clauseWorkspaceContextMenu.pasteRootNodeTypeItem(); isDirty = true; } break; case CellTreeNode.LOGICAL_OP_NODE: case CellTreeNode.FUNCTIONS_NODE: if (copiedNode.getNodeType() != CellTreeNode.CLAUSE_NODE) { canPaste = true; } break; case CellTreeNode.TIMING_NODE: if ((copiedNode.getNodeType() != CellTreeNode.CLAUSE_NODE) && ((selectedNode.getChilds() == null) || (selectedNode.getChilds().size() < 2))) { canPaste = true; } break; default: break; } if (canPaste) { paste(); isDirty = true; } } } else if (keyCode == ClauseConstants.CUT_X) { // CUT popupPanel.hide(); if ((selectedNode.getNodeType() != CellTreeNode.MASTER_ROOT_NODE) && (selectedNode.getNodeType() != CellTreeNode.CLAUSE_NODE) && (selectedNode.getNodeType() != CellTreeNode.ROOT_NODE) && (selectedNode.getParent().getNodeType() != CellTreeNode.CLAUSE_NODE)) { copy(); removeNode(); isDirty = true; } } } else if (keyCode == ClauseConstants.DELETE_DELETE) { // DELETE popupPanel.hide(); if (((selectedNode.getNodeType() != CellTreeNode.MASTER_ROOT_NODE) && (selectedNode.getNodeType() != CellTreeNode.ROOT_NODE) && (selectedNode.getParent().getNodeType() != CellTreeNode.CLAUSE_NODE) && (selectedNode.getNodeType() != CellTreeNode.CLAUSE_NODE)) || ((selectedNode.getNodeType() == CellTreeNode.CLAUSE_NODE) && (selectedNode.getParent().getChilds().size() > 1))) { removeNode(); isDirty = true; } } } if ((event.isShiftKeyDown() && ((keyCode == ClauseConstants.PLUS_FF) || (keyCode == ClauseConstants.PLUS_IE)))) { // EXPAND/COLLAPSE (+(Shift +) Expand| - Collapse) popupPanel.hide(); openAllNodes(cellTree.getRootTreeNode()); } else if ((event.isShiftKeyDown() && ((keyCode == ClauseConstants.MINUS_FF) || (keyCode == ClauseConstants.MINUS_IE)))) { popupPanel.hide(); closeNodes(cellTree.getRootTreeNode()); } /*if(event.isControlKeyDown() && event.isAltKeyDown() && keyCode == 83){ saveBtn.getElement().focus(); saveBtn.click(); }*/ }
/* (non-Javadoc) * @see mat.client.clause.clauseworkspace.presenter.XmlTreeDisplay#refreshCellTreeAfterAdding(mat.client.clause.clauseworkspace.model.CellTreeNode) */ @Override public void refreshCellTreeAfterAdding(CellTreeNode selectedNode) { closeSelectedOpenNodes(cellTree.getRootTreeNode()); selectionModel.setSelected(selectedNode, true); }
@UiHandler("getHyperlink") void getHyperlink(ClickEvent event) { MultiSelectionModel<SessionDataDto> sessionModel = (MultiSelectionModel) sessionsDataGrid.getSelectionModel(); MultiSelectionModel<TaskDataDto> testModel = (MultiSelectionModel) testDataGrid.getSelectionModel(); Set<SessionDataDto> sessions = sessionModel.getSelectedSet(); Set<TaskDataDto> tests = testModel.getSelectedSet(); Set<MetricNameDto> metrics = metricPanel.getSelected(); TaskDataTreeViewModel taskDataTreeViewModel = (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel(); Set<PlotNameDto> trends = taskDataTreeViewModel.getSelectionModel().getSelectedSet(); HashSet<String> sessionsIds = new HashSet<String>(); HashSet<TestsMetrics> testsMetricses = new HashSet<TestsMetrics>(tests.size()); HashMap<String, TestsMetrics> map = new HashMap<String, TestsMetrics>(tests.size()); for (SessionDataDto session : sessions) { sessionsIds.add(session.getSessionId()); } for (TaskDataDto taskDataDto : tests) { TestsMetrics testsMetrics = new TestsMetrics(taskDataDto.getTaskName(), new HashSet<String>(), new HashSet<String>()); testsMetricses.add(testsMetrics); map.put(taskDataDto.getTaskName(), testsMetrics); } for (MetricNameDto metricNameDto : metrics) { map.get(metricNameDto.getTests().getTaskName()).getMetrics().add(metricNameDto.getName()); } for (PlotNameDto plotNameDto : trends) { map.get(plotNameDto.getTest().getTaskName()).getTrends().add(plotNameDto.getPlotName()); } TrendsPlace newPlace = new TrendsPlace( mainTabPanel.getSelectedIndex() == 0 ? NameTokens.SUMMARY : mainTabPanel.getSelectedIndex() == 1 ? NameTokens.TRENDS : NameTokens.METRICS); newPlace.setSelectedSessionIds(sessionsIds); newPlace.setSelectedTestsMetrics(testsMetricses); newPlace.setSessionTrends(sessionPlotPanel.getSelected()); String linkText = Window.Location.getHost() + Window.Location.getPath() + Window.Location.getQueryString() + "#" + new JaggerPlaceHistoryMapper().getToken(newPlace); linkText = URL.encode(linkText); // create a dialog for copy link final DialogBox dialog = new DialogBox(false, true); dialog.setText("Share link"); dialog.setModal(true); dialog.setAutoHideEnabled(true); dialog.setPopupPosition(event.getClientX(), event.getClientY()); final TextArea textArea = new TextArea(); textArea.setText(linkText); textArea.setWidth("300px"); textArea.setHeight("40px"); // select text Scheduler.get() .scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { textArea.setVisible(true); textArea.setFocus(true); textArea.selectAll(); } }); dialog.add(textArea); dialog.show(); }