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); }
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; }
/** * Instantiates a new side nav input tree. * * @param dispatcher the dispatcher * @param lang */ private InputQueueTree( final DispatchAsync dispatcher, final LangConstants lang, final EventBus eventBus) { this.lang = lang; setWidth100(); setHeight100(); setCustomIconProperty("icon"); setAnimateFolderTime(100); setAnimateFolders(true); setAnimateFolderSpeed(1000); setNodeIcon("silk/application_view_list.png"); setFolderIcon("silk/folder.png"); setShowOpenIcons(true); setShowDropIcons(false); setShowSortArrow(SortArrow.CORNER); setShowConnectors(true); setShowAllRecords(true); setLoadDataOnDemand(true); setCanSort(true); setAutoFetchData(true); setShowRoot(false); setSelectionType(SelectionStyle.SINGLE); setShowRollOverCanvas(true); MenuItem showItem = new MenuItem(lang.show(), "icons/16/structure.png"); final Menu showMenu = new Menu(); showMenu.setShowShadow(true); showMenu.setShadowDepth(10); showMenu.setItems(showItem); createItem = new MenuItem(lang.create(), "icons/16/structure_into.png"); final Menu editMenu = new Menu(); editMenu.setShowShadow(true); editMenu.setShadowDepth(10); setContextMenu(editMenu); dispatcher.execute( new HasUserRightsAction(new EDITOR_RIGHTS[] {EDITOR_RIGHTS.LONG_RUNNING_PROCESS}), new DispatchCallback<HasUserRightsResult>() { @Override public void callback(HasUserRightsResult result) { canLongProcess = result.getOk()[0]; } }); addCellContextClickHandler( new CellContextClickHandler() { @Override public void onCellContextClick(CellContextClickEvent event) { ListGridRecord record = event.getRecord(); final String path = record.getAttribute(Constants.ATTR_ID); if (path != null && path.length() > 1 && path.substring(1).contains("/")) { // String model = path.substring(1, path.substring(1).indexOf("/") + 1); String id = path.substring(path.substring(1).indexOf("/") + 2); if (id.contains("/")) { id = id.substring(0, id.indexOf("/")); } MenuItem quartz = new MenuItem(lang.addToScheduler(), "icons/16/clock.png"); quartz.addClickHandler( new ClickHandler() { @Override public void onClick(MenuItemClickEvent event) { String msg = event.getMenu().getEmptyMessage(); // duplicate code String model = msg.substring(0, msg.indexOf("/")); String path = msg.substring(msg.indexOf("/") + 1); QuartzConvertImagesAction action = new QuartzConvertImagesAction(model, path); DispatchCallback<QuartzConvertImagesResult> quartzConvertCallback = new DispatchCallback<QuartzConvertImagesResult>() { @Override public void callback(QuartzConvertImagesResult result) { if (result.getNumberOfImages() != null) { SC.say( result.getNumberOfImages().toString() + " images will be converted"); } else { SC.say("No images found"); } } }; dispatcher.execute(action, quartzConvertCallback); } }); if (record.getAttributeAsBoolean(Constants.ATTR_INGEST_INFO)) { MenuItem ingestInfo = new MenuItem(lang.ingestInfo(), "icons/16/export1.png"); ingestInfo.addClickHandler( new ClickHandler() { @Override public void onClick(MenuItemClickEvent event) { getIngestInfo(path, dispatcher, eventBus); } }); if (canLongProcess) { editMenu.setItems(createItem, ingestInfo, quartz); } else { editMenu.setItems(createItem, ingestInfo); } } else { if (canLongProcess) { editMenu.setItems(createItem, quartz); } else { editMenu.setItems(createItem); } } editMenu.setEmptyMessage(path.substring(1, path.length())); editMenu.showContextMenu(); } else { showMenu.showContextMenu(); } } }); addShowContextMenuHandler( new ShowContextMenuHandler() { @Override public void onShowContextMenu(ShowContextMenuEvent event) { event.cancel(); } }); eventBus.addHandler( RefreshTreeEvent.getType(), new RefreshTreeEvent.RefreshTreeHandler() { @Override public void onRefreshTree(RefreshTreeEvent event) { if (event.getTree() == NAME_OF_TREE.INPUT_QUEUE) refreshTree(); } }); TreeGridField field1 = new TreeGridField(); field1.setCanFilter(true); field1.setName(Constants.ATTR_BARCODE); field1.setTitle("ID"); field1.setCellFormatter( new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { boolean ingestInfo = record.getAttributeAsBoolean(Constants.ATTR_INGEST_INFO); if (ingestInfo) { return record.getAttribute(Constants.ATTR_BARCODE) + HTML_TICK_CODE; } else { return record.getAttribute(Constants.ATTR_BARCODE); } } }); ListGridField nameField = new ListGridField(); nameField.setCanFilter(true); nameField.setName(Constants.ATTR_NAME); nameField.setTitle(lang.name()); setFields(field1, nameField); setDataSource(new InputTreeGwtRPCDS(dispatcher, lang)); }