public void saveState() { List<String> nodes = new ArrayList<String>(); nodes.add(iStackPanel.getStackText(iStackPanel.getSelectedIndex())); for (int i = 0; i < iStackPanel.getWidgetCount(); i++) { if (iStackPanel.getWidget(i) instanceof Tree) { Tree t = (Tree)iStackPanel.getWidget(i); for (int j = 0; j < t.getItemCount(); j++) { openedNodes(nodes, t.getItem(j), iStackPanel.getStackText(i)); } } } String sideBarCookie = ""; for (String node: nodes) { if (!sideBarCookie.isEmpty()) sideBarCookie += "|"; sideBarCookie += node; } Cookies.setCookie("UniTime:MobileMenu", sideBarCookie); }
public void restoreState() { Set<String> nodes = new HashSet<String>(); String sideBarCookie = Cookies.getCookie("UniTime:MobileMenu"); if (sideBarCookie != null) for (String node: sideBarCookie.split("\\|")) nodes.add(node); for (int i = 0 ; i < iStackPanel.getWidgetCount(); i++) { if (nodes.contains(iStackPanel.getStackText(i))) { iStackPanel.showStack(i); } if (iStackPanel.getWidget(i) instanceof Tree) { Tree t = (Tree)iStackPanel.getWidget(i); for (int j = 0; j < t.getItemCount(); j++) { openNodes(nodes, t.getItem(j), iStackPanel.getStackText(i)); } } } }
public void restoreState() { Set<String> nodes = new HashSet<String>(); String sideBarCookie = Cookies.getCookie("UniTime:SideBar"); if (sideBarCookie != null) for (String node: sideBarCookie.split("\\|")) nodes.add(node); iDisclosurePanel.setOpen(nodes.contains("Root") || sideBarCookie == null); if (iUseStackPanel) for (int i = 0 ; i < iStackPanel.getWidgetCount(); i++) { if (nodes.contains(iStackPanel.getStackText(i))) { iStackPanel.showStack(i); } if (iStackPanel.getWidget(i) instanceof Tree) { Tree t = (Tree)iStackPanel.getWidget(i); for (int j = 0; j < t.getItemCount(); j++) { openNodes(nodes, t.getItem(j), iStackPanel.getStackText(i)); } } } else for (int i = 0; i < iTree.getItemCount(); i++) { openNodes(nodes, iTree.getItem(i), null); } }
/** * This is the entry point method. */ public void onModuleLoad() { HorizontalPanel mainPanel = new HorizontalPanel(); final MiddlePanel mPanel = new MiddlePanel(); Tree menu = new Tree(); menu.addSelectionHandler(new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { mPanel.set((MenuItem) event.getSelectedItem()); } }); initMenu(menu); mainPanel.add(menu); mainPanel.add(mPanel); menu.setSelectedItem(menu.getItem(0)); mainPanel.setStyleName("mvp4gshowcase"); RootPanel.get() .add(mainPanel); }
/** * @param wadlXmlString */ public void parse(String wadlXmlString) { // remove unnecessary whitespaces wadlXmlString = wadlXmlString.replaceAll(">\\s*<", "><"); // remove <!-- comment nodes --> wadlXmlString = wadlXmlString.replaceAll("<!--.*?-->", ""); try { // reset the application GuiFactory.resetApplication(); Document wadl = XMLParser.parse(wadlXmlString); if (startParsing(wadl)) { uploadDialogBox.setVisible(true); uploadDialogBox.hide(); // if the parsing succeeded render a tree from the parsed wadl WadlTreeRoot wadlTreeRoot = new WadlTreeRoot(); Tree wadlTree = wadlTreeRoot.buildTree(application); WadlPanel.wadlArea.setWidget(wadlTree); GuiFactory.toggleButtonsEnabled(true); WadlPanel.fullscreenButton.click(); } } catch (DOMParseException e) { alertInvalidWadlAndRetry(GuiFactory.strings.invalidWadl()); } }
private void addItemToParent(UIObject parentNode) { if (parentNode instanceof Tree) { ((Tree) parentNode).addItem(this); } else if (parentNode instanceof TreeItem) { TreeItem parentNodeItem = (TreeItem) parentNode; int childCount = parentNodeItem.getChildCount(); int nodeDepth = 0; for (TreeItem ancestor = parentNodeItem; ancestor != null; ancestor = ancestor.getParentItem()) { nodeDepth++; } parentNodeItem.addItem(this); String colors[] = { "#F5F5F2", "#DBDAD8", "#F9F8F6", "#E7E7E3" }; int colorIndex = ((nodeDepth % 2) + (childCount % 2)) % 2; getElement().getStyle().setBackgroundColor(colors[colorIndex]); } }
public void saveState() { List<String> nodes = new ArrayList<String>(); if (iUseStackPanel) { nodes.add(iStackPanel.getStackText(iStackPanel.getSelectedIndex())); for (int i = 0; i < iStackPanel.getWidgetCount(); i++) { if (iStackPanel.getWidget(i) instanceof Tree) { Tree t = (Tree)iStackPanel.getWidget(i); for (int j = 0; j < t.getItemCount(); j++) { openedNodes(nodes, t.getItem(j), iStackPanel.getStackText(i)); } } } } else { for (int i = 0; i < iTree.getItemCount(); i++) { openedNodes(nodes, iTree.getItem(i), null); } } String sideBarCookie = ""; if (iDisclosurePanel.isOpen()) sideBarCookie += "Root"; for (String node: nodes) { if (!sideBarCookie.isEmpty()) sideBarCookie += "|"; sideBarCookie += node; } sideBarCookie += "|W:" + iPanel.getElement().getClientWidth(); Cookies.setCookie("UniTime:SideBar", sideBarCookie); resizeWideTables(); }
/** * Folder Tree */ public FolderSelectTree() { tree = new Tree(); rootItem.setStyleName("okm-TreeItem"); rootItem.setUserObject(new GWTFolder()); rootItem.setSelected(true); rootItem.setState(true); tree.setStyleName("okm-Tree"); tree.addItem(rootItem); tree.addSelectionHandler(new SelectionHandler<TreeItem>() { @Override public void onSelection(SelectionEvent<TreeItem> event) { boolean refresh = true; TreeItem item = event.getSelectedItem(); // Case that not refreshing tree and file browser ( right click ) if (actualItem.equals(item)) { refresh = false; } else { // Disables actual item because on changing active node by // application this it's not changed automatically if (!actualItem.equals(item)) { actualItem.setSelected(false); actualItem = item; } else { refresh = false; } } if (refresh) { refresh(true); } } }); actualItem = tree.getItem(0); initWidget(tree); }
/** * Allows to retrieve the tree item by name * @param tree the tree to take the item from * @param itemText the text of the item we want to get the sate of * @return the tree item with the given text, or null if there is no such item */ private static TreeItem getTreeItem( final Tree tree, final String itemText ) { if( tree != null ) { for( int i = 0; i < tree.getItemCount(); i++ ) { TreeItem oldTreeItem = tree.getItem( i ); if( oldTreeItem.getText().equals( itemText ) ) { return oldTreeItem; } } } return null; }
/** * Allows to retrieve the tree item state * @param tree the tree to take the item from * @param itemText the text of the item we want to get the sate of * @return true if the item does not exist, or it exists and its state is true */ private static boolean getItemState( final Tree tree, final String itemText ) { TreeItem treeItem = getTreeItem( tree, itemText ); if( treeItem != null ) { return treeItem.getState(); } return true; }
/** * Instantiates a new expression view. */ public ExpressionView() { super(); setSpacing(5); Button btnRefresh = new Button("Refresh"); btnRefresh.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { refreshButtonPressed(); } }); add(btnRefresh); HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setSpacing(10); add(horizontalPanel); horizontalPanel.setSize("517px", "279px"); Tree tree = new Tree(); tree.addSelectionHandler(this); horizontalPanel.add(tree); trtmByPerson = new TreeItem(SafeHtmlUtils.fromString("By Person")); tree.addItem(trtmByPerson); trtmByTable = new TreeItem(SafeHtmlUtils.fromString("By Table")); tree.addItem(trtmByTable); trtmByTarget = new TreeItem(SafeHtmlUtils.fromString("By Target")); tree.addItem(trtmByTarget); verticalPanel = new VerticalPanel(); horizontalPanel.add(verticalPanel); }
public FiltersDataPanel(FilterSubTab parentPanel) { this.parentSubTab = parentPanel; getElement().setId("filters_container"); FlowPanel panel = new FlowPanel(); // panel.add( new HTML("<h2 id=\"filter_header\">" + HtmlConsts.SPACE + "Filters</h2>")); FlexTable filterGroupButtons = new FlexTable(); filterGroupButtons.setWidget(0, 0, new SaveFilterGroupButton(parentSubTab)); copyButton = new SaveAsFilterGroupButton(parentSubTab); filterGroupButtons.setWidget(0, 1, copyButton); removeButton = new RemoveFilterGroupButton(parentSubTab); filterGroupButtons.setWidget(0, 2, removeButton); panel.add(filterGroupButtons); HTML filterText = new HTML("<h2 id=\"filter_header\">Filters Applied</h2>"); filterText.getElement().setId("filter_desc_title"); VerticalPanel filterGlobal = new VerticalPanel(); FlexTable paginationTable = new FlexTable(); paginationTable.setHTML(0, 0, "<p id=\"filter_header\">Submissions per page</p>"); paginationTable.setWidget(0, 1, new PaginationNumTextBox(parentSubTab)); filterGlobal.add(paginationTable); filterGlobal.add(filterText); panel.add(filterGlobal); // Filters applied header filterHeader = new FlowPanel(); panel.add(filterHeader); // create tree filtersTree = new Tree(); panel.add(filtersTree); // create the root as the new filter button addFilter = new AddFilterButton(parentPanel); add(panel); }
private Tree createTree() { Tree tree = new Tree(); /*TreeItem widgets =*/ tree.addItem("Widgets"); /*TreeItem lists =*/ tree.addItem("Lists and Menus"); TreeItem popups = tree.addItem("Popups"); popups.addItem(createTreeItem("Message Box", new CwMessageBox())); /*TreeItem tables =*/ tree.addItem("Tables"); return tree; }
/** {@inheritDoc} */ @Override public void setTreeOfChanges(final RefactoringPreview changes) { showDiffPanel(false); final SelectionModel<RefactoringPreview> selectionModel = new SingleSelectionModel<>(); selectionModel.addSelectionChangeHandler( event -> { RefactoringPreview selectedNode = (RefactoringPreview) ((SingleSelectionModel) selectionModel).getSelectedObject(); delegate.onSelectionChanged(selectedNode); }); Tree tree = new Tree(); tree.getElement().setId("tree-of-changes"); for (RefactoringPreview parentChange : changes.getChildrens()) { TreeItem treeItem = new TreeItem(); containerChanges.put(treeItem, parentChange); createTreeElement(treeItem, parentChange.getText(), parentChange.getChildrens()); tree.addItem(treeItem); } tree.addSelectionHandler( event -> { if (selectedElement != null) { selectedElement.getStyle().setProperty("background", "transparent"); } selectedElement = event.getSelectedItem().getWidget().getElement(); selectedElement.getStyle().setProperty("background", getEditorSelectionColor()); }); treePanel.add(tree); }
private TreeItem addItem(Tree tree, ScreenMenuItem widget) { TreeItem childItem = new TreeItem(); childItem.setWidget(widget); tree.addItem(childItem); widget.addClickListener(this); return(childItem); }
@PostConstruct private void initUI() { initWidget(mainPanel); Tree tree = initNavigationTree(); tree.setWidth("150px"); Style leftStyle = mainPanel.getElement().getStyle(); leftStyle.setPropertyPx("margin", 5); mainPanel.add(tree); }
private Tree initNavigationTree() { Tree navTree = new Tree(); List<GalleryTreeNode> mainNodes = galleryTree.getMainNodes(); populateNavigationTree(mainNodes, navTree); navTree.addSelectionHandler(new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { TreeItem ti = event.getSelectedItem(); GalleryTreeNode node = (GalleryTreeNode) ti.getUserObject(); treeItemClicked(ti, node); } }); return navTree; }
/** * To listen to the root tree item we need to add id,uuid,events etc to the root item label. * RendererHelper.fillIn method is doing addDimension to the label which is not needed for us. * If addDimension is done the tree alignment will go wrong based on width and height. * So this method calls all other fillIn except the addDimension(); */ private void fillInRootItemLabel(String uuid, String parent, String context, Tree uiObject, ComponentGVO gvo, Label mainItemLabel) { RendererHelper.addId(gvo, mainItemLabel, uuid, parent, context, true); RendererHelper.addUUID(gvo, mainItemLabel, uuid); RendererHelper.addWindowID(gvo, uiObject, uuid); RendererHelper.addDisabledInfo(gvo, mainItemLabel); RendererHelper.addStyle(gvo, mainItemLabel); RendererHelper.addEvents(gvo, mainItemLabel, uuid); RendererHelper.addVisibleInfo(gvo, mainItemLabel); RendererHelper.addTooltip(gvo, mainItemLabel); }
/** * Separates the line break separated request strings and starts the analysis * * @param requestStrings The line break separated uri strings */ private static void processRequestStrings(String requestStrings) { GuiFactory.resetApplication(); String[] separatedRequestStrings = requestStrings.split("\n"); for (int i = 0; i < separatedRequestStrings.length; i++) { separatedRequestStrings[i] = separatedRequestStrings[i].trim(); if (separatedRequestStrings[i].length() > 0) { separatedRequestStrings[i] = separatedRequestStrings[i].replaceAll("\\s\\s*", " "); // make sure the uri starts with a http method name if (!separatedRequestStrings[i].startsWith(MethodItem.delete) && !separatedRequestStrings[i].startsWith(MethodItem.get) && !separatedRequestStrings[i].startsWith(MethodItem.head) && !separatedRequestStrings[i].startsWith(MethodItem.post) && !separatedRequestStrings[i].startsWith(MethodItem.put)) { separatedRequestStrings[i] = MethodItem.get + " " + separatedRequestStrings[i]; } } } ApplicationNode application = null; for(int i = 0; i < separatedRequestStrings.length; i++) { RequestUriTree requestUriTree = new RequestUriTree(separatedRequestStrings[i]); RequestUriPanel.uriTree.addItem(requestUriTree); Analyzer analyzer = new Analyzer(separatedRequestStrings[i]); application = analyzer.analyze(); } WadlTreeRoot wadlTreeRoot = new WadlTreeRoot(); Tree wadlTree = wadlTreeRoot.buildTree(application); WadlPanel.wadlArea.setWidget(wadlTree); GuiFactory.toggleButtonsEnabled(true); }
@Inject public SimpleUI( final ApplicationController applicationController, final EntityChangeBroker broker ) { broker.addChangeListener( this ); final VerticalPanel panel = new VerticalPanel(); panel.setWidth( "100%" ); panel.add( applicationController ); final HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setWidth( "100%" ); horizontalPanel.setHeight( "200px" ); _resourceList = new FlexTable(); _resourceList.setWidth( "100%" ); _resourceList.setHeight( "100%" ); _tree = new Tree(); _tree.setHeight( "100%" ); _tree.setWidth( "100%" ); _tree.setScrollOnSelectEnabled( true ); horizontalPanel.add( _tree ); horizontalPanel.add( _resourceList ); panel.add( horizontalPanel ); initWidget( panel ); }
public LayerSelectorTree(LayerSelectionHandler layerHandler, String firstText, boolean showRefreshButton, HTML titleLabel) { super(); this.layerSelectionHandler = layerHandler; layerIdWmsUrlToTitle = new HashMap<String, String>(); layerIdWmsUrlToMenuEntry = new HashMap<String, LayerMenuItem>(); this.titleLabel = titleLabel; this.titleLabel.setHTML(firstText); this.titleLabel.setStylePrimaryName("hiddenButton"); this.titleLabel.addStyleDependentName("title"); if (showRefreshButton) { PushButton button = new PushButton("Refresh"); button.addStyleDependentName("CentreAndMargin"); button.setTitle("Click to refresh the layers list"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { layerSelectionHandler.refreshLayerList(); } }); add(button); } tree = new Tree(); add(tree); }
private static Iterable<Widget> iter(final HasTreeItems tree) { if (tree instanceof Tree) { return (Tree) tree; } else if (tree instanceof TreeItem) { return new TreeItemIterator((TreeItem) tree); } else { throw new AssertionError("should never happen! tree is neither a" + " TreeItem nor a Iterable: " + tree); } }