List of usage examples for com.google.gwt.user.client.ui TreeItem getChild
public TreeItem getChild(int index)
From source file:org.openxdata.designer.client.view.FormsTreeView.java
/** * Checks if the selected form is valid for saving. * //from www .j ava 2 s . com * @return true if valid, else false. */ public boolean isValidForm() { TreeItem parent = getSelectedItemRoot(tree.getSelectedItem()); if (parent == null) return true; Map<String, String> pageNos = new HashMap<String, String>(); Map<String, QuestionDef> bindings = new HashMap<String, QuestionDef>(); int count = parent.getChildCount(); for (int index = 0; index < count; index++) { TreeItem child = parent.getChild(index); PageDef pageDef = (PageDef) child.getUserObject(); String pageNo = String.valueOf(pageDef.getPageNo()); if (pageNos.containsKey(pageNo)) { tree.setSelectedItem(child); tree.ensureSelectedItemVisible(); Window.alert(i18n.selectedPage() + pageDef.getName() + i18n.shouldNotSharePageBinding() + pageNos.get(pageNo) + "]"); return false; } else pageNos.put(pageNo, pageDef.getName()); if (!isValidQuestionList(child, bindings)) return false; } return true; }
From source file:org.openxdata.designer.client.view.FormsTreeView.java
private boolean isValidQuestionList(TreeItem parent, Map<String, QuestionDef> bindings) { int count = parent.getChildCount(); for (int index = 0; index < count; index++) { TreeItem child = parent.getChild(index); QuestionDef questionDef = (QuestionDef) child.getUserObject(); String variableName = questionDef.getBinding(); if (bindings.containsKey( variableName) /*&& questionDef.getParent() == bindings.get(variableName).getParent()*/) { tree.setSelectedItem(child); tree.ensureSelectedItemVisible(); Window.alert(i18n.selectedQuestion() + questionDef.getText() + i18n.shouldNotShareQuestionBinding() + bindings.get(variableName).getDisplayText() + "]"); return false; } else//from ww w . j ava2 s .c om bindings.put(variableName, questionDef); if (questionDef.getDataType() == QuestionType.REPEAT) { if (!isValidQuestionList(child, bindings)) return false; } else if (questionDef.getDataType() == QuestionType.LIST_EXCLUSIVE || questionDef.getDataType() == QuestionType.LIST_MULTIPLE) { if (!isValidOptionList(child)) return false; } } return true; }
From source file:org.openxdata.designer.client.view.FormsTreeView.java
private boolean isValidOptionList(TreeItem parent) { Map<String, String> bindings = new HashMap<String, String>(); int count = parent.getChildCount(); for (int index = 0; index < count; index++) { TreeItem child = parent.getChild(index); OptionDef optionDef = (OptionDef) child.getUserObject(); String variableName = optionDef.getVariableName(); if (bindings.containsKey(variableName)) { tree.setSelectedItem(child); tree.ensureSelectedItemVisible(); Window.alert(i18n.selectedOption() + optionDef.getText() + i18n.shouldNotShareOptionBinding() + bindings.get(variableName) + "]"); return false; } else/*w w w . ja v a 2s .c o m*/ bindings.put(variableName, optionDef.getText()); } return true; }
From source file:org.openxdata.designer.client.view.FormsTreeView.java
/** * @see org.openxdata.designer.client.controller.IFormActionListener#moveUp() *//*from w w w . ja v a 2 s. c om*/ public void moveUp() { TreeItem item = tree.getSelectedItem(); if (item == null) return; int index; TreeItem parent = item.getParentItem(); if (parent == null) { index = getRootItemIndex(parent); if (index == 0) return; tree.setSelectedItem(tree.getItem(index - 1)); } else { index = parent.getChildIndex(item); if (index == 0) return; tree.setSelectedItem(parent.getChild(index - 1)); } }
From source file:org.openxdata.designer.client.view.FormsTreeView.java
/** * @see org.openxdata.designer.client.controller.IFormActionListener#moveDown() *//*from www . ja v a 2s .c o m*/ public void moveDown() { TreeItem item = tree.getSelectedItem(); if (item == null) return; int index; TreeItem parent = item.getParentItem(); if (parent == null) { index = getRootItemIndex(parent); if (index == tree.getItemCount() - 1) return; tree.setSelectedItem(tree.getItem(index + 1)); } else { index = parent.getChildIndex(item); if (index == parent.getChildCount() - 1) return; tree.setSelectedItem(parent.getChild(index + 1)); } }
From source file:org.openxdata.designer.client.view.FormsTreeView.java
/** * Selects the child of the selected item. *//*from w ww. j a va 2s. co m*/ public void moveToChild() { TreeItem item = tree.getSelectedItem(); if (item == null) return; if (item.getChildCount() == 0) { addNewChildItem(false); return; } TreeItem child = item.getChild(0); tree.setSelectedItem(child); tree.ensureSelectedItemVisible(); }
From source file:org.optaplanner.workbench.screens.solver.client.editor.TerminationConfigForm.java
License:Apache License
private void insertTreeItem(TreeItem treeItem, TreeItem nestedTreeItem, TerminationConfigOption terminationConfigOption) { if (treeItem.getChildCount() == 0) { treeItem.addItem(nestedTreeItem); } else {/*from w ww .j a v a 2 s.c o m*/ for (int i = 0; i < treeItem.getChildCount(); i++) { TerminationTreeItemContent childTreeItemContent = (TerminationTreeItemContent) treeItem.getChild(i) .getUserObject(); if (terminationConfigOption.ordinal() < childTreeItemContent.getTerminationConfigOption() .ordinal()) { treeItem.insertItem(i, nestedTreeItem); break; } if (i == treeItem.getChildCount() - 1) { treeItem.addItem(nestedTreeItem); break; } } } }
From source file:org.optaplanner.workbench.screens.solver.client.editor.TerminationConfigForm.java
License:Apache License
private void initTerminationTreeItemHierarchy(TerminationConfigModel terminationConfigModel, TreeItem treeItem) { TerminationTreeItemContent terminationTreeItemContent = createTerminationTreeItemContent( TerminationConfigOption.NESTED, treeItem, terminationConfigModel); TerminationConfigOption timeSpentTerminationOption = null; boolean timeSpentInserted = false; boolean unimprovedTimeSpentInserted = false; outer: for (TerminationConfigOption terminationConfigOption : TerminationConfigOption.values()) { timeSpentTerminationOption = null; Object terminationValue = getTerminationValue(terminationConfigModel, terminationConfigOption); if (terminationConfigOption == TerminationConfigOption.TERMINATION_COMPOSITION_STYLE) { TerminationTreeItemContent parentTreeItemContent = (TerminationTreeItemContent) treeItem .getUserObject();//from ww w . ja va 2 s . c om parentTreeItemContent.setExistingValue(terminationValue, TerminationConfigOption.TERMINATION_COMPOSITION_STYLE); continue; } if (terminationValue != null) { if (timeSpentInserted && (terminationConfigOption == TerminationConfigOption.MILLISECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.SECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.MINUTES_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.HOURS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.DAYS_SPENT_LIMIT)) { for (int i = 0; i < treeItem.getChildCount(); i++) { TerminationTreeItemContent treeItemContent = (TerminationTreeItemContent) treeItem .getChild(i).getUserObject(); if (treeItemContent .getTerminationConfigOption() == TerminationConfigOption.MILLISECONDS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.SECONDS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.MINUTES_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.HOURS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.DAYS_SPENT_LIMIT) { treeItemContent .setTerminationConfigOption(TerminationConfigOption.MILLISECONDS_SPENT_LIMIT); treeItemContent.setExistingValue(terminationValue, TerminationConfigOption.MILLISECONDS_SPENT_LIMIT); continue outer; } } } else { if (terminationConfigOption == TerminationConfigOption.MILLISECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.SECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.MINUTES_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.HOURS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.DAYS_SPENT_LIMIT) { timeSpentTerminationOption = TerminationConfigOption.MILLISECONDS_SPENT_LIMIT; timeSpentInserted = true; } } } if (terminationValue != null) { if (unimprovedTimeSpentInserted && (terminationConfigOption == TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_SECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_MINUTES_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_HOURS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_DAYS_SPENT_LIMIT)) { for (int i = 0; i < treeItem.getChildCount(); i++) { TerminationTreeItemContent treeItemContent = (TerminationTreeItemContent) treeItem .getChild(i).getUserObject(); if (treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_SECONDS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_MINUTES_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_HOURS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_DAYS_SPENT_LIMIT) { treeItemContent.setTerminationConfigOption( TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT); treeItemContent.setExistingValue(terminationValue, TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT); continue outer; } } } else { if (terminationConfigOption == TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_SECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_MINUTES_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_HOURS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_DAYS_SPENT_LIMIT) { timeSpentTerminationOption = TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT; unimprovedTimeSpentInserted = true; } } } if (terminationValue != null && !TerminationConfigOption.NESTED.equals(terminationConfigOption)) { TreeItem nestedTreeItem = new TreeItem(); if (timeSpentTerminationOption != null) { terminationConfigOption = timeSpentTerminationOption; } insertTreeItem(treeItem, nestedTreeItem, terminationConfigOption); terminationTreeItemContent.removeDropDownOption(terminationConfigOption); TerminationTreeItemContent nestedTerminationTreeItemContent = createTerminationTreeItemContent( terminationConfigOption, nestedTreeItem, terminationConfigModel); nestedTerminationTreeItemContent.setExistingValue(terminationValue, terminationConfigOption); } } if (terminationConfigModel.getTerminationConfigList() != null) { for (TerminationConfigModel nestedTerminationConfigModel : terminationConfigModel .getTerminationConfigList()) { TreeItem nestedTreeItem = new TreeItem(); treeItem.addItem(nestedTreeItem); initTerminationTreeItemHierarchy(nestedTerminationConfigModel, nestedTreeItem); nestedTreeItem.setState(true); } } }
From source file:org.pentaho.gwt.widgets.client.filechooser.FileChooser.java
License:Open Source License
public Widget buildFilesList(TreeItem parentTreeItem) { VerticalPanel filesListPanel = new VerticalPanel(); filesListPanel.setWidth("100%"); //$NON-NLS-1$ ScrollPanel filesScroller = new ScrollPanel(); filesScroller.setStyleName("fileChooser-scrollPanel"); //$NON-NLS-1$ FlexTable filesListTable = new FlexTable(); filesListTable.setWidth("100%"); //$NON-NLS-1$ filesListTable.setCellSpacing(0);//from ww w . j a v a2s. c o m Label nameLabel = new Label(FileChooserEntryPoint.messages.getString("name"), false); //$NON-NLS-1$ nameLabel.setStyleName("fileChooserHeader"); //$NON-NLS-1$ Label typeLabel = new Label(FileChooserEntryPoint.messages.getString("type"), false); //$NON-NLS-1$ typeLabel.setStyleName("fileChooserHeader"); //$NON-NLS-1$ Label dateLabel = new Label(FileChooserEntryPoint.messages.getString("dateModified"), false); //$NON-NLS-1$ dateLabel.setStyleName("fileChooserHeader"); //$NON-NLS-1$ ElementUtils.preventTextSelection(nameLabel.getElement()); ElementUtils.preventTextSelection(typeLabel.getElement()); ElementUtils.preventTextSelection(dateLabel.getElement()); filesListTable.setWidget(0, 0, nameLabel); filesListTable.getCellFormatter().setWidth(0, 0, "100%"); //$NON-NLS-1$ filesListTable.setWidget(0, 1, typeLabel); filesListTable.setWidget(0, 2, dateLabel); List<TreeItem> treeItems = new ArrayList<TreeItem>(); for (int i = 0; i < parentTreeItem.getChildCount(); i++) { treeItems.add(parentTreeItem.getChild(i)); } Collections.sort(treeItems, new TreeItemComparator()); // BISERVER-9599 - custom sort int row = 0; for (final TreeItem childItem : treeItems) { RepositoryFileTree repositoryFileTree = (RepositoryFileTree) childItem.getUserObject(); RepositoryFile repositoryFile = repositoryFileTree.getFile(); if (repositoryFile.isFolder() && !(repositoryFile.getName() != null && repositoryFile.getName().equals(ETC_FOLDER))) { addFileToList(repositoryFileTree, childItem, filesListTable, row++); } } for (final TreeItem childItem : treeItems) { RepositoryFileTree repositoryFileTree = (RepositoryFileTree) childItem.getUserObject(); RepositoryFile repositoryFile = repositoryFileTree.getFile(); if (!repositoryFile.isFolder()) { addFileToList(repositoryFileTree, childItem, filesListTable, row++); } } filesListTable.setWidth("100%"); //$NON-NLS-1$ filesScroller.setWidget(filesListTable); filesListTable.setWidth("100%"); //$NON-NLS-1$ filesListPanel.add(filesScroller); return filesListPanel; }
From source file:org.pentaho.gwt.widgets.client.filechooser.FileChooser.java
License:Open Source License
public TreeItem getTreeItem(List<String> pathSegments) { // find the tree node whose location matches the pathSegment paths TreeItem selectedItem = repositoryTree.getItem(0); for (String segment : pathSegments) { for (int i = 0; i < selectedItem.getChildCount(); i++) { TreeItem item = selectedItem.getChild(i); RepositoryFileTree tree = (RepositoryFileTree) item.getUserObject(); if (segment.equals(tree.getFile().getName())) { selectedItem = item;//from w w w . j a v a 2 s.c o m } } } return selectedItem; }