@Override public void onSuccess(CComponentTypeRegistry[] result) { CComponentTypeNode[] ds = new CComponentTypeNode[result.length]; int index = 0; for (CComponentTypeRegistry registry : result) { ds[index++] = new CComponentTypeNode(registry); if (PROCESSOR_SECTION_ID.equals(sectionID)) WebClientController.componentManager.registerProcessor(registry); else if (DATASOURCE_SECTION_ID.equals(sectionID)) WebClientController.componentManager.registerDataSource(registry); } TreeNode root = new TreeNode("ComponentRoot", ds); Tree dataSourceTree = new Tree(); dataSourceTree.setModelType(TreeModelType.CHILDREN); dataSourceTree.setNameProperty(COMPONENT_NAME); dataSourceTree.setRoot(root); // group tree grid TreeGridField connectorsField = new TreeGridField("ComponentField"); connectorsField.setShowHover(false); connectorsField.setCellFormatter( new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return record.getAttributeAsString(COMPONENT_NAME); } }); treeGrid.setData(dataSourceTree); treeGrid.setFields(connectorsField); }
public void setRoot(String pid) { if (rootPid == null ? pid == null : rootPid.equals(pid)) { return; } rootPid = pid; if (pid == null) { treeSelector.setData(new TreeNode[0]); return; } treeSelector.fetchData(new Criteria(RelationDataSource.FIELD_ROOT, pid)); }
/** * When a layer deselection event comes in, the LayerTree must also deselect the correct node in * the tree, update the selected layer text, and update all buttons icons. * * @since 1.6.0 */ @Api public void onDeselectLayer(LayerDeselectedEvent event) { ListGridRecord selected = treeGrid.getSelectedRecord(); if (selected != null) { treeGrid.deselectRecord(selected); } selectedLayerTreeNode = null; htmlSelectedLayer.setContents( I18nProvider.getLayerTree().activeLayer(I18nProvider.getLayerTree().none())); Canvas[] toolStripMembers = toolStrip.getMembers(); updateButtonIconsAndStates(toolStripMembers); }
private void selectAndExpandRootNode(DataArrivedEvent event) { // first event contains parent node that is root node of TreeGrid // and it is a synthetic node without attributes TreeNode parentNode = event.getParentNode(); Tree tree = treeSelector.getTree(); TreeNode[] children = tree.getChildren(parentNode); if (children.length > 0 && children[0].getAttribute(RelationDataSource.FIELD_PARENT) == null) { // select real root node and expand it TreeNode realRootNode = children[0]; treeSelector.selectRecord(realRootNode); tree.openFolder(realRootNode); } }
FileLocationComponentImpl(final UploadComponentOptions uploadOptions) { this.options = uploadOptions; final TreeOptions treeOptions = new TreeOptions(); final String extension = uploadOptions.getExtension(); treeOptions.setSelectionType( uploadOptions.isAllowMultiple() ? SelectionType.MULTIPlE : SelectionType.SINGLE); treeOptions.setInitialItems(locationFactory.getTropixObjectSourceRootItems(null)); treeOptions.setShowPredicate( LocationPredicates.getTropixFileTreeItemPredicate(extension, true)); treeOptions.setSelectionPredicate( LocationPredicates.getTropixFileTreeItemPredicate(extension, false)); treeComponent = treeComponentFactory.get(treeOptions); treeComponent.addSelectionListener( new Listener<TreeItem>() { public void onEvent(final TreeItem location) {} }); final TreeGrid treeGrid = treeComponent.get(); treeGrid.setWidth100(); treeGrid.setHeight100(); super.setWidget(treeGrid); }
/** * When a layer selection event comes in, the LayerTree must also select the correct node in the * tree, update the selected layer text, and update all buttons icons. * * @since 1.6.0 */ @Api public void onSelectLayer(LayerSelectedEvent event) { for (TreeNode node : tree.getAllNodes()) { if (node.getName().equals(event.getLayer().getLabel())) { selectedLayerTreeNode = (LayerTreeTreeNode) node; treeGrid.selectRecord(selectedLayerTreeNode); htmlSelectedLayer.setContents( I18nProvider.getLayerTree().activeLayer(selectedLayerTreeNode.getLayer().getLabel())); Canvas[] toolStripMembers = toolStrip.getMembers(); updateButtonIconsAndStates(toolStripMembers); } } }
@Override protected void onDraw() { super.onDraw(); final TreeGrid treeGrid = new CustomResourceTypeTreeGrid(); treeGrid.setHeight100(); treeGrid.setTitle(MSG.view_type_resourceTypes()); treeGrid.setAnimateFolders(false); treeGrid.setResizeFieldsInRealTime(true); final TreeGridField name, plugin, category; name = new TreeGridField("name"); plugin = new TreeGridField("plugin"); category = new TreeGridField("category"); treeGrid.setFields(name, plugin, category); addMember(treeGrid); ResourceTypeCriteria criteria = new ResourceTypeCriteria(); criteria.addFilterIgnored((showIgnoredResourceTypes ? (Boolean) null : Boolean.FALSE)); criteria.fetchParentResourceTypes(true); criteria.setPageControl(PageControl.getUnlimitedInstance()); resourceTypeService.findResourceTypesByCriteria( criteria, new AsyncCallback<PageList<ResourceType>>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.widget_typeTree_loadFail(), caught); } public void onSuccess(PageList<ResourceType> result) { treeGrid.getTree().linkNodes(ResourceTypePluginTreeDataSource.buildNodes(result)); } }); }
/** * Builds up the tree showing the layers * * @param mapModel The mapModel containing the layerTree */ private void buildTree(MapModel mapModel) { treeGrid.setWidth100(); treeGrid.setHeight100(); treeGrid.setShowHeader(false); tree = new RefreshableTree(); final TreeNode nodeRoot = new TreeNode("ROOT"); tree.setRoot(nodeRoot); // invisible ROOT node (ROOT node is required) ClientLayerTreeInfo layerTreeInfo = mapModel.getMapInfo().getLayerTree(); if (layerTreeInfo != null) { ClientLayerTreeNodeInfo treeNode = layerTreeInfo.getTreeNode(); processNode(treeNode, nodeRoot, tree, mapModel, false); } treeGrid.setData(tree); treeGrid.addLeafClickHandler(this); treeGrid.addFolderClickHandler(this); // -- add event listeners to layers for (Layer<?> layer : mapModel.getLayers()) { registrations.add( layer.addLayerChangedHandler( new LayerChangedHandler() { public void onLabelChange(LayerLabeledEvent event) {} public void onVisibleChange(LayerShownEvent event) { for (TreeNode node : tree.getAllNodes()) { if (node.getName().equals(event.getLayer().getLabel())) { if (node instanceof LayerTreeTreeNode) { ((LayerTreeTreeNode) node).updateIcon(); } } } } })); } }
public Canvas getViewPanel() { Tree employeeTree = new Tree(); employeeTree.setModelType(TreeModelType.PARENT); employeeTree.setIdField("EmployeeId"); employeeTree.setParentIdField("ReportsTo"); employeeTree.setNameProperty("Name"); employeeTree.setRootValue(1); employeeTree.setData(employeeData); TreeGrid employeeTreeGrid = new TreeGrid(); employeeTreeGrid.setWidth(500); employeeTreeGrid.setHeight(400); employeeTreeGrid.setNodeIcon("icons/16/person.png"); employeeTreeGrid.setFolderIcon("icons/16/person.png"); employeeTreeGrid.setShowOpenIcons(false); employeeTreeGrid.setShowDropIcons(false); employeeTreeGrid.setClosedIconSuffix(""); employeeTreeGrid.setFields(new TreeGridField("Name")); employeeTreeGrid.setData(employeeTree); employeeTreeGrid.getData().openAll(); return employeeTreeGrid; }
public void onModuleLoad() { topTabSet = new TabSet(); topTabSet.setTabBarPosition(Side.TOP); topTabSet.setWidth(1024); topTabSet.setHeight(768); topTabSet.setTabBarThickness(50); Tab tTab1 = new Tab("Menu", "assets/mainMenu.png"); Img tImg1 = new Img("pieces/48/pawn_blue.png", 96, 96); topTabSet.addTab(tTab1); Tab lTab1 = new Tab(); lTab1.setIcon("pieces/16/pawn_blue.png", 16); Img lImg1 = new Img("pieces/48/pawn_blue.png", 48, 48); lTab1.setPane(lImg1); HLayout buttons = new HLayout(); buttons.setMembersMargin(15); VLayout vLayout = new VLayout(); vLayout.setMembersMargin(15); vLayout.addMember(topTabSet); vLayout.addMember(buttons); // vLayout.addMember(leftTabSet); vLayout.setHeight("*"); vLayout.draw(); final HLayout hLayout = new HLayout(); hLayout.setWidth100(); hLayout.setHeight100(); hLayout.setLayoutMargin(20); // tree menu TreeGrid tree = new TreeGrid(); tree.setShowConnectors(true); tree.setShowResizeBar(true); Tree dataTree = new Tree(); dataTree.setModelType(TreeModelType.CHILDREN); dataTree.setRoot( new TreeNode( "root", new TreeNode("Aluno"), new TreeNode("Funcionario"), new TreeNode("Contato"), new TreeNode("Veiculo"), new TreeNode("Disciplina"))); tree.setData(dataTree); TreeGridField fieldTree = new TreeGridField("Navegacao"); fieldTree.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return record.getAttribute("name"); } }); tree.setFields(fieldTree); // layout esquerda SectionStack leftSideLayout = new SectionStack(); leftSideLayout.setWidth(200); leftSideLayout.setShowResizeBar(true); leftSideLayout.setVisibilityMode(VisibilityMode.MULTIPLE); leftSideLayout.setAnimateSections(true); leftSideLayout.setMembers(tree); // UIs final AlunoUI alunoUI = new AlunoUI(); final FuncionarioUI funcionarioUI = new FuncionarioUI(); final ContatoUI contatoUI = new ContatoUI(); final VeiculoUI veiculoUI = new VeiculoUI(); final DisciplinaUI disciplinaUI = new DisciplinaUI(); // layout direita final SectionStack rightSideLayout = new SectionStack(); rightSideLayout.setVisibilityMode(VisibilityMode.MULTIPLE); rightSideLayout.setAnimateSections(true); grid = alunoUI.getGrid(); formBotoes = alunoUI.getFormBotoes(); menuItens = new DynamicForm(); menuItens.setWidth(100); menuItens.setAlign(Alignment.RIGHT); ButtonItem aluno = new ButtonItem("Aluno"); aluno.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { newTabCustomAluno("Aluno"); } }); ButtonItem disc = new ButtonItem("Disciplina"); disc.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { newTabCustomDisciplina("Disciplina"); } }); ButtonItem curso = new ButtonItem("Curso"); curso.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { newTabCustomCurso("Curso"); } }); ButtonItem matric = new ButtonItem("Matricula"); matric.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { newTabCustomMatricula("Matricula"); } }); menuItens.setFields(aluno, disc, curso, matric); rightSideLayout.setMembers(menuItens); rightSideLayout.setWidth(200); // seleciona tree tree.addNodeClickHandler( new NodeClickHandler() { public void onNodeClick(NodeClickEvent event) { String node = event.getNode().getAttribute("name"); if (node.equals("Aluno")) { // rightSideLayout.removeMembers(formBotoes,grid); // Tab tab = new Tab(node); newTabCustomAluno(node); } else { if (node.equals("Disciplina")) { newTabCustomDisciplina(node); } else { if (node.equals("Curso")) { // newTabCustom(node); } else { if (node.equals("Matricula")) { // newTabCustom(node); } else { if (node.equals("Disciplina")) { rightSideLayout.removeMembers(formBotoes, grid); grid = disciplinaUI.getGrid(); formBotoes = disciplinaUI.getFormBotoes(); rightSideLayout.setMembers(formBotoes, grid); } } } } } } }); // hLayout hLayout.addMember(leftSideLayout); hLayout.addMember(rightSideLayout); hLayout.draw(); tTab1.setPane(hLayout); }
public void setModels(Map<?, ?> valueMap) { ListGridField field = treeSelector.getField(RelationDataSource.FIELD_MODEL); field.setValueMap(valueMap); }
public Canvas getViewPanel() { DataSource employeeDS = EmployeeXmlDS.getInstance(); final TreeGrid treeGrid = new TreeGrid(); treeGrid.setLoadDataOnDemand(false); treeGrid.setWidth(500); treeGrid.setHeight(400); treeGrid.setDataSource(employeeDS); treeGrid.setNodeIcon("icons/16/person.png"); treeGrid.setFolderIcon("icons/16/person.png"); treeGrid.setShowOpenIcons(false); treeGrid.setShowDropIcons(false); treeGrid.setClosedIconSuffix(""); treeGrid.setAutoFetchData(true); TreeGridField field = new TreeGridField(); field.setName("Name"); field.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return record.getAttribute("Job") + ": " + value; } }); treeGrid.setFields(field); treeGrid.addDataArrivedHandler( new DataArrivedHandler() { public void onDataArrived(DataArrivedEvent event) { treeGrid.getData().openAll(); } }); return treeGrid; }
public Canvas getViewPanel() { EmployeeXmlDS employeesDS = EmployeeXmlDS.getInstance(); TreeGrid treeGrid = new TreeGrid(); treeGrid.setCanEdit(true); treeGrid.setLoadDataOnDemand(false); treeGrid.setWidth(500); treeGrid.setHeight(400); treeGrid.setDataSource(employeesDS); treeGrid.setNodeIcon("icons/16/person.png"); treeGrid.setFolderIcon("icons/16/person.png"); treeGrid.setShowOpenIcons(false); treeGrid.setShowDropIcons(false); treeGrid.setClosedIconSuffix(""); treeGrid.setAutoFetchData(true); TreeGridField nameField = new TreeGridField("Name"); TreeGridField jobField = new TreeGridField("Job"); TreeGridField salaryField = new TreeGridField("Salary"); salaryField.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value != null) { NumberFormat nf = NumberFormat.getFormat("#,##0"); try { return "$" + nf.format(((Number) value).longValue()); } catch (Exception e) { return value.toString(); } } else { return null; } } }); treeGrid.setFields(nameField, jobField, salaryField); return treeGrid; }
public Canvas getViewPanel() { Tree employeeTree = new Tree(); employeeTree.setModelType(TreeModelType.PARENT); employeeTree.setRootValue(1); employeeTree.setNameProperty("Name"); employeeTree.setIdField("EmployeeId"); employeeTree.setParentIdField("ReportsTo"); employeeTree.setOpenProperty("isOpen"); employeeTree.setData(employeeData); TreeGridField formattedField = new TreeGridField("Name"); formattedField.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return record.getAttributeAsString("Job") + ": " + value; } }); TreeGrid employeeTreeGrid = new TreeGrid(); employeeTreeGrid.setWidth(500); employeeTreeGrid.setHeight(400); employeeTreeGrid.setNodeIcon("icons/16/person.png"); employeeTreeGrid.setFolderIcon("icons/16/person.png"); employeeTreeGrid.setCanReorderRecords(true); employeeTreeGrid.setCanAcceptDroppedRecords(true); employeeTreeGrid.setShowOpenIcons(false); employeeTreeGrid.setDropIconSuffix("into"); employeeTreeGrid.setClosedIconSuffix(""); employeeTreeGrid.setData(employeeTree); employeeTreeGrid.setFields(formattedField); return employeeTreeGrid; }
@Override public void refresh() { treeSelector.invalidateCache(); }
public AddressbookTree() { super(); SectionStackSection section = new SectionStackSection(); section.setCanCollapse(false); section.setExpanded(true); section.setResizeable(true); TreeGrid tree = new TreeGrid(); tree.setWidth100(); tree.setHeight100(); tree.setAnimateFolderTime(100); tree.setAnimateFolders(true); tree.setAnimateFolderSpeed(1000); tree.setShowSortArrow(SortArrow.CORNER); tree.setShowAllRecords(true); tree.setLoadDataOnDemand(false); tree.setCanSort(false); tree.setCellHeight(17); tree.setShowHeader(false); TreeGridField field = new TreeGridField(); field.setCanFilter(true); field.setName("name"); field.setTitle("<b>SmartGWT Showcase</b>"); tree.setFields(field); Tree treeData = new Tree(); treeData.setModelType(TreeModelType.PARENT); treeData.setNameProperty("name"); treeData.setOpenProperty("isOpen"); treeData.setIdField("nodeID"); treeData.setParentIdField("parentNodeID"); treeData.setRootValue("root"); treeData.setData(DemoData.getAddressBookTreeData()); tree.setData(treeData); section.setItems(tree); setSections(section); }
@Override public Record[] getSelection() { return treeSelector.getSelectedRecords(true); }
private void init(final ListGridRecord sampleRecord, final boolean add) { final Form form = new Form(nameItem, mudpitItem, categoryItem); form.setWrapItemTitles(false); nameItem.setValue(sampleRecord.getAttributeAsString("Name")); nameItem.addChangedHandler( new ChangedHandler() { public void onChanged(final ChangedEvent event) { checkOk(); } }); mudpitItem.setValue(sampleRecord.getAttributeAsBoolean("Mudpit")); categoryItem.setValue(sampleRecord.getAttributeAsString("Category")); final Label label = new Label(CONSTANTS.scaffoldWizardSampleSearchLabel()); label.setWidth100(); label.setHeight(12); final TreeOptions treeOptions = new TreeOptions(); treeOptions.setInitialItems( locationFactory.getTropixObjectSourceRootItems(TropixObjectTreeItemExpanders.get(types))); treeOptions.setShowPredicate(getShowItemPredicate()); treeOptions.setSelectionPredicate(LocationPredicates.getTropixObjectNotFolderPredicate()); treeOptions.setSelectionType(SelectionType.MULTIPlE); @SuppressWarnings("unchecked") final Collection<TreeItem> selectedItems = (Collection<TreeItem>) sampleRecord.getAttributeAsObject("Selection"); treeOptions.setExpandIds(Locations.getAncestorIds(selectedItems)); treeOptions.setSelectedItems(selectedItems); final TreeComponent tree = treeComponentFactory.get(treeOptions); tree.addMultiSelectionListener(this); final TreeGrid treeGrid = tree.get(); treeGrid.setTooltip("Hold the control key to select multiple items."); final VLayout layout = new VLayout(); layout.addMember(form); layout.addMember(label); layout.addMember(treeGrid); layout.setSize("500px", "500px"); okButton = SmartUtils.getButton( add ? "Add" : "Update", null, new Command() { public void execute() { sampleRecord.setAttribute("Name", (String) nameItem.getValue()); sampleRecord.setAttribute("Category", (String) categoryItem.getValue()); sampleRecord.setAttribute("Mudpit", (Boolean) mudpitItem.getValue()); sampleRecord.setAttribute("Selection", selection); if (add) { dataSource.addData(sampleRecord); records.add(sampleRecord); } listGrid.markForRedraw(); get().markForDestroy(); checkValid(); } }); final Button cancelButton = SmartUtils.getCancelButton(this); final Layout opsLayout = new CanvasWithOpsLayout<VLayout>(layout, okButton, cancelButton); final Window window = PopOutWindowBuilder.titled((add ? "Add" : "Update") + " Sample") .withContents(opsLayout) .autoSized() .get(); setWidget(window); checkOk(); get().draw(); }
private TreeGrid createTreeSelector() { TreeGrid treeGrid = new TreeGrid(); treeGrid.setCanSort(false); treeGrid.setDataSource(RelationDataSource.getInstance()); TreeGridField parentId = new TreeGridField(RelationDataSource.FIELD_PARENT); TreeGridField label = new TreeGridField( RelationDataSource.FIELD_LABEL, i18n.DigitalObjectSearchView_ListHeaderLabel_Title()); TreeGridField model = new TreeGridField( RelationDataSource.FIELD_MODEL, i18n.DigitalObjectSearchView_ListHeaderModel_Title(), 150); model.setAlign(Alignment.CENTER); TreeGridField pid = new TreeGridField( RelationDataSource.FIELD_PID, i18n.DigitalObjectSearchView_ListHeaderPid_Title(), 100); pid.setAlign(Alignment.CENTER); TreeGridField created = new TreeGridField( RelationDataSource.FIELD_CREATED, i18n.DigitalObjectSearchView_ListHeaderCreated_Title(), 100); created.setAlign(Alignment.CENTER); TreeGridField modified = new TreeGridField( RelationDataSource.FIELD_MODIFIED, i18n.DigitalObjectSearchView_ListHeaderModified_Title(), 100); modified.setAlign(Alignment.CENTER); TreeGridField owner = new TreeGridField( RelationDataSource.FIELD_OWNER, i18n.DigitalObjectSearchView_ListHeaderOwner_Title(), 100); TreeGridField export = new TreeGridField( SearchDataSource.FIELD_EXPORT, i18n.DigitalObjectSearchView_ListHeaderExport_Title(), 100); export.setCellFormatter( new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return value == null || "0".equals(value) ? i18nSmartGwt.dialog_NoButtonTitle() : i18nSmartGwt.dialog_YesButtonTitle(); } }); treeGrid.setFields(parentId, label, model, pid, created, modified, owner, export); treeGrid.setTitleField(RelationDataSource.FIELD_LABEL); treeGrid.setShowConnectors(true); treeGrid.setEmptyMessage(i18n.DigitalObjectTreeView_EmptySelection_Msg()); treeGrid.setAlternateRecordStyles(true); treeGrid.setSelectionType(SelectionStyle.SINGLE); treeGrid.setContextMenu(Actions.createMenu()); treeGrid.addDataArrivedHandler( new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { selectAndExpandRootNode(event); } }); return treeGrid; }