List of usage examples for com.google.gwt.user.client.ui DialogBox setHTML
public void setHTML(String html)
From source file:com.ponysdk.core.terminal.ui.PTDialogBox.java
License:Apache License
@Override public boolean update(final ReaderBuffer buffer, final BinaryModel binaryModel) { final ServerToClientModel model = binaryModel.getModel(); if (ServerToClientModel.POPUP_CAPTION == model) { final DialogBox dialogBox = uiObject; dialogBox.setHTML(binaryModel.getStringValue()); return true; } else if (ServerToClientModel.DRAGGABLE == model) { draggable = binaryModel.getBooleanValue(); return true; } else {/*w w w . j av a 2 s. c om*/ return super.update(buffer, binaryModel); } }
From source file:com.ponysdk.ui.terminal.ui.PTDialogBox.java
License:Apache License
@Override public void update(final PTInstruction update, final UIService uiService) { final DialogBox dialogBox = cast(); if (update.containsKey(PROPERTY.POPUP_CAPTION)) { dialogBox.setHTML(update.getString(PROPERTY.POPUP_CAPTION)); } else {/*from w w w. j a v a 2 s .co m*/ super.update(update, uiService); } }
From source file:org.gss_project.gss.admin.client.ui.UsersTable.java
License:Open Source License
public DialogBox createDialogBox(UserDTO m, StatsDTO s) { // Create a dialog box and set the caption text final DialogBox dialogBox = new DialogBox(); dialogBox.setHTML("User Details: " + m.getUsername()); // Create a table to layout the content VerticalPanel dialogVPanel = new VerticalPanel(); dialogBox.setSize("50%", "50%"); ClickHandler cancelHandler = new ClickHandler() { @Override// w w w .j a va 2s . co m public void onClick(ClickEvent event) { dialogBox.hide(); } }; dialogBox.setWidget(dialogVPanel); dialogVPanel.add(new Label("Username: " + m.getUsername())); dialogVPanel.add(new Label("Email: " + m.getEmail())); dialogVPanel.add(new Label("Name: " + m.getName())); if (m.getUserClass() != null) dialogVPanel.add(new Label("Quota: " + m.getUserClass().getQuotaAsString())); dialogVPanel.add(new Label("File Count: " + s.getFileCount())); dialogVPanel.add(new Label("File Size: " + s.getFileSizeAsString())); dialogVPanel.add(new Label("Quota Left: " + s.getQuotaLeftAsString())); Button close = new Button("Close"); close.addClickHandler(cancelHandler); dialogVPanel.add(close); // Return the dialog box return dialogBox; }
From source file:org.pentaho.mantle.client.solutionbrowser.filelist.FilesListPanel.java
License:Open Source License
public void populateFilesList(SolutionBrowserPanel perspective, SolutionTree solutionTree, TreeItem item, JsArrayString filters) {/*from w w w . ja v a 2 s . co m*/ filesList.clear(); List<RepositoryFile> files; if (item == solutionTree.getTrashItem()) { // If we're populating from the trash then files = solutionTree.getTrashItems(); } else { files = new ArrayList<RepositoryFile>(); // Get the user object. RepositoryFileTree tree = (RepositoryFileTree) item.getUserObject(); // Since we are only listing the files here. Get to each item of the tree and get the file from it for (RepositoryFileTree treeItem : tree.getChildren()) { String fileName = treeItem.getFile().getName(); if (filters != null) { for (int i = 0; i < filters.length(); i++) { if (fileName.endsWith(filters.get(i))) { files.add(treeItem.getFile()); } } } } } // let's sort this list based on localized name Collections.sort(files, new RepositoryFileComparator()); // BISERVER-9599 - Custom Sort if (files != null) { int rowCounter = 0; for (RepositoryFile file : files) { if ((item == solutionTree.getTrashItem()) || (!file.isFolder() && (isShowHiddenFiles() || !file.isHidden()))) { // TODO Currently Old solution repository stores url type files. New repository does not have that // concept. What do we need to do here //String url = fileElement.getAttribute("url"); //$NON-NLS-1$ ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(file.getName()); String icon = null; if (plugin != null) { icon = plugin.getFileIcon(); } if (item == solutionTree.getTrashItem() && file.isFolder()) { icon = "mantle/images/folderIcon.png"; //$NON-NLS-1$ } final FileItem fileLabel = new FileItem(file, this, PluginOptionsHelper.getEnabledOptions(file.getName()), true, icon); // BISERVER-2317: Request for more IDs for Mantle UI elements // set element id as the filename fileLabel.getElement().setId(file.getPath()); //$NON-NLS-1$ fileLabel.addFileSelectionChangedListener(toolbar); fileLabel.setWidth("100%"); //$NON-NLS-1$ try { perspective.getDragController().makeDraggable(fileLabel); } catch (Throwable e) { Throwable throwable = e; String text = "Uncaught exception: "; while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int ii = 0; ii < stackTraceElements.length; ii++) { text += " at " + stackTraceElements[ii] + "\n"; } throwable = throwable.getCause(); if (throwable != null) { text += "Caused by: "; } } DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); System.err.print(text); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); } fileLabel.setRepositoryFile(file); filesList.setWidget(rowCounter++, 0, fileLabel); if (selectedFileItems != null && selectedFileItems.size() > 0) { for (FileItem fileItem : selectedFileItems) { if (fileItem.getRepositoryFile().equals(fileLabel.getRepositoryFile())) { if (file.isHidden()) { fileLabel.setStyleName("hiddenFileLabelSelected"); } else { fileLabel.setStyleName("fileLabelSelected"); //$NON-NLS-1$ } selectedFileItems.add(fileLabel); // if we do not break this loop, it will go forever! (we added an item) break; } } } else { if (file.isHidden()) { fileLabel.setStyleName("hiddenFileLabel"); //$NON-NLS-1$ } else { fileLabel.setStyleName("fileLabel"); //$NON-NLS-1$ } } } } } }
From source file:org.vectomatic.svg.edit.client.SvgrealApp.java
License:Open Source License
public void onModuleLoad() { instance = this; GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable throwable) { GWT.log("Uncaught exception", throwable); if (!GWT.isScript()) { String text = "Uncaught exception: "; while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int i = 0; i < stackTraceElements.length; i++) { text += " at " + stackTraceElements[i] + "\n"; }// w ww . j av a2 s.c o m throwable = throwable.getCause(); if (throwable != null) { text += "Caused by: "; } } DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); System.err.print(text); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); } } }); AppBundle.INSTANCE.css().ensureInjected(); // Create graphical context OMSVGDocument doc = OMSVGParser.currentDocument(); SVGElement element = doc.createSVGPathElement().getElement().cast(); element.getStyle().setProperty(SVGConstants.CSS_FILL_PROPERTY, SVGConstants.CSS_LIGHTBLUE_VALUE); element.getStyle().setProperty(SVGConstants.CSS_STROKE_PROPERTY, SVGConstants.CSS_BLACK_VALUE); SVGNamedElementModel.createTitleDesc(element, AppConstants.INSTANCE.graphicalContext()); cssContext = new CssContextModel(element); svgWindows = new ArrayList<SVGWindow>(); viewport = new ViewportExt(); viewport.setLayout(new BorderLayout()); HBoxLayout hboxLayout = new HBoxLayout(); hboxLayout.setHBoxLayoutAlign(HBoxLayoutAlign.TOP); LayoutContainer menuBarContainer = new LayoutContainer(hboxLayout); HBoxLayoutData layoutData = new HBoxLayoutData(); layoutData.setFlex(1); menuBarContainer.add(createMenuBar(), layoutData); menuBarContainer.add(createLanguageBar(), new HBoxLayoutData()); viewport.add(menuBarContainer, new BorderLayoutData(LayoutRegion.NORTH, getWindowBarHeight())); viewport.setStyleAttribute("background-color", SVGConstants.CSS_BEIGE_VALUE); commandToolBar = new CommandFactoryToolBar(CommandFactories.getAllFactoriesStore(), getCommandFactorySelector()); ContentPanel commandPanel = new ContentPanel(); commandPanel.setHeaderVisible(false); commandPanel.setBottomComponent(commandToolBar); viewport.add(commandPanel, new BorderLayoutData(LayoutRegion.SOUTH, getWindowBarHeight())); update(); fileUpload = new FileUploadExt(); Style style = fileUpload.getElement().getStyle(); style.setVisibility(Visibility.HIDDEN); style.setWidth(0, Unit.PX); style.setHeight(0, Unit.PX); fileUpload.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { processFiles(fileUpload.getFiles()); } }); RootPanel.get().add(viewport); RootPanel.get().add(fileUpload); ImageLoader loader = new ImageLoader(); loader.addInitializeHandler(new InitializeHandler() { @Override public void onInitialize(InitializeEvent event) { ImageLoader loader = (ImageLoader) event.getSource(); imageCache = new DecoratedImageCache(loader.getImages()); init(); } }); loader.loadImages(new ImageResource[] { AppBundle.INSTANCE.altGlyphDef(), AppBundle.INSTANCE.altGlyphItem(), AppBundle.INSTANCE.altGlyph(), AppBundle.INSTANCE.animateColor(), AppBundle.INSTANCE.animateMotion(), AppBundle.INSTANCE.animate(), AppBundle.INSTANCE.animateTransform(), AppBundle.INSTANCE.circle(), AppBundle.INSTANCE.clipPath(), AppBundle.INSTANCE.colorProfile(), AppBundle.INSTANCE.cursor(), AppBundle.INSTANCE.defs(), AppBundle.INSTANCE.desc(), AppBundle.INSTANCE.ellipse(), AppBundle.INSTANCE.feBlend(), AppBundle.INSTANCE.feColorMatrix(), AppBundle.INSTANCE.feComponentTransfer(), AppBundle.INSTANCE.feComposite(), AppBundle.INSTANCE.feConvolveMatrix(), AppBundle.INSTANCE.feDiffuseLighting(), AppBundle.INSTANCE.feDisplacementMap(), AppBundle.INSTANCE.feDistantLight(), AppBundle.INSTANCE.feFlood(), AppBundle.INSTANCE.feFuncA(), AppBundle.INSTANCE.feFuncB(), AppBundle.INSTANCE.feFuncG(), AppBundle.INSTANCE.feFuncR(), AppBundle.INSTANCE.feGaussianBlur(), AppBundle.INSTANCE.feMergeNode(), AppBundle.INSTANCE.feMerge(), AppBundle.INSTANCE.feMorphology(), AppBundle.INSTANCE.feOffset(), AppBundle.INSTANCE.fePointLight(), AppBundle.INSTANCE.feSpecularLight(), AppBundle.INSTANCE.feSpotLight(), AppBundle.INSTANCE.feTile(), AppBundle.INSTANCE.feTurbulence(), AppBundle.INSTANCE.filter(), AppBundle.INSTANCE.fontFaceFormat(), AppBundle.INSTANCE.fontFaceName(), AppBundle.INSTANCE.fontFace(), AppBundle.INSTANCE.fontFaceSrc(), AppBundle.INSTANCE.fontFaceUri(), AppBundle.INSTANCE.font(), AppBundle.INSTANCE.foreignObject(), AppBundle.INSTANCE.glyph(), AppBundle.INSTANCE.glyphRef(), AppBundle.INSTANCE.g(), AppBundle.INSTANCE.hkern(), AppBundle.INSTANCE.image(), AppBundle.INSTANCE.linearGradient(), AppBundle.INSTANCE.line(), AppBundle.INSTANCE.marker(), AppBundle.INSTANCE.mask(), AppBundle.INSTANCE.metadata(), AppBundle.INSTANCE.missingGlyph(), AppBundle.INSTANCE.mpath(), AppBundle.INSTANCE.path(), AppBundle.INSTANCE.pattern(), AppBundle.INSTANCE.polygon(), AppBundle.INSTANCE.polyline(), AppBundle.INSTANCE.radialGradient(), AppBundle.INSTANCE.rect(), AppBundle.INSTANCE.script(), AppBundle.INSTANCE.set(), AppBundle.INSTANCE.stop(), AppBundle.INSTANCE.style(), AppBundle.INSTANCE.svg(), AppBundle.INSTANCE.switch_(), AppBundle.INSTANCE.symbol(), AppBundle.INSTANCE.textPath(), AppBundle.INSTANCE.text(), AppBundle.INSTANCE.title(), AppBundle.INSTANCE.tref(), AppBundle.INSTANCE.tspan(), AppBundle.INSTANCE.use(), AppBundle.INSTANCE.view(), AppBundle.INSTANCE.vkern(), AppBundle.INSTANCE.error(), AppBundle.INSTANCE.warning(), }); }
From source file:org.vectomatic.svg.edit.client.VectomaticApp2.java
License:Open Source License
public void onModuleLoad() { APP = this;/*from ww w .j a v a 2 s . c om*/ GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable throwable) { GWT.log("Uncaught exception", throwable); if (!GWT.isScript()) { String text = "Uncaught exception: "; while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int i = 0; i < stackTraceElements.length; i++) { text += " at " + stackTraceElements[i] + "\n"; } throwable = throwable.getCause(); if (throwable != null) { text += "Caused by: "; } } DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); System.err.print(text); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); } } }); AppBundle.INSTANCE.css().ensureInjected(); windows = new ArrayList<SVGWindow>(); viewPort = new Viewport(); Menu fileMenu = new Menu(); final MenuItem openUrlItem = new MenuItem(AppConstants.INSTANCE.openUrlMenuItem()); fileMenu.add(openUrlItem); final MenuItem openRssFeedItem = new MenuItem(AppConstants.INSTANCE.openRssFeedMenuItem()); fileMenu.add(openRssFeedItem); MenuItem recentDocumentsItem = new MenuItem(AppConstants.INSTANCE.recentDocumentsMenuItem()); recentDocsMenu = new Menu(); recentDocumentsItem.setSubMenu(recentDocsMenu); fileMenu.add(recentDocumentsItem); Menu windowMenu = new Menu(); resetViewItem = new MenuItem(AppConstants.INSTANCE.resetViewMenuItem()); windowMenu.add(resetViewItem); windowMenu.add(new SeparatorMenuItem()); tileWindowsItem = new MenuItem(AppConstants.INSTANCE.tileWindowsMenuItem()); windowMenu.add(tileWindowsItem); stackWindowsItem = new MenuItem(AppConstants.INSTANCE.stackWindowsMenuItem()); windowMenu.add(stackWindowsItem); windowMenu.add(new SeparatorMenuItem()); closeWindowItem = new MenuItem(AppConstants.INSTANCE.closeWindowMenuItem()); windowMenu.add(closeWindowItem); Menu aboutMenu = new Menu(); final MenuItem aboutItem = new MenuItem(AppConstants.INSTANCE.aboutMenuItem()); aboutMenu.add(aboutItem); menuBar = new MenuBar(); menuBar.setBorders(true); menuBar.setStyleAttribute("borderTop", "none"); menuBar.add(new MenuBarItem(AppConstants.INSTANCE.fileMenu(), fileMenu)); menuBar.add(new MenuBarItem(AppConstants.INSTANCE.windowMenu(), windowMenu)); menuBar.add(new MenuBarItem(AppConstants.INSTANCE.aboutMenu(), aboutMenu)); dispatcher = new SelectionListener<MenuEvent>() { @Override public void componentSelected(MenuEvent me) { MenuItem item = (MenuItem) me.getItem(); if (item.getParentMenu() == recentDocsMenu) { openRecent(item.getText()); } else if (item == openUrlItem) { openUrl(); } else if (item == openRssFeedItem) { openRssFeed(); } else if (item == resetViewItem) { resetView(); } else if (item == tileWindowsItem) { tileWindows(); } else if (item == stackWindowsItem) { stackWindows(); } else if (item == closeWindowItem) { closeWindow(activeWindow); } else if (item == aboutItem) { about(); } } }; openUrlItem.addSelectionListener(dispatcher); openRssFeedItem.addSelectionListener(dispatcher); resetViewItem.addSelectionListener(dispatcher); tileWindowsItem.addSelectionListener(dispatcher); stackWindowsItem.addSelectionListener(dispatcher); closeWindowItem.addSelectionListener(dispatcher); aboutItem.addSelectionListener(dispatcher); viewPort.add(menuBar); addWindow(AppBundle.INSTANCE.fish().getSvg(), "fish.svg"); addWindow(AppBundle.INSTANCE.fries().getSvg(), "fries.svg"); viewPort.setStyleAttribute("background-color", SVGConstants.CSS_BEIGE_VALUE); update(); RootPanel.get().add(viewPort); }
From source file:org.vectomatic.svg.edu.client.commons.Utils.java
License:Open Source License
public static void handleFatalError(Throwable throwable) { String text = "Uncaught exception: "; GWT.log(text, throwable);//from w w w .j av a 2s . c o m while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int i = 0; i < stackTraceElements.length; i++) { text += " at " + stackTraceElements[i] + "\n"; } throwable = throwable.getCause(); if (throwable != null) { text += "Caused by: "; } } DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); System.err.print(text); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); }
From source file:org.vectomatic.svg.edu.client.Intro.java
License:Open Source License
@Override public void onModuleLoad() { final String debugParam = Window.Location.getParameter("debug"); GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable throwable) { if (!GWT.isScript() || debugParam != null) { String text = "Uncaught exception: "; while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int i = 0; i < stackTraceElements.length; i++) { text += " at " + stackTraceElements[i] + "\n"; }/* ww w. j a v a 2s .com*/ throwable = throwable.getCause(); if (throwable != null) { text += "Caused by: "; } } DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); System.err.print(text); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); } } }); // use a deferred command so that the handler catches onModuleLoad2() // exceptions DeferredCommand.addCommand(new Command() { @Override public void execute() { onModuleLoad2(); } }); }
From source file:org.vectomatic.svg.samples.client.Main.java
License:Open Source License
@Override public void onModuleLoad() { GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable throwable) { String text = "Uncaught exception: "; while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int i = 0; i < stackTraceElements.length; i++) { text += " at " + stackTraceElements[i] + "\n"; }//from w ww . j av a2 s. c om throwable = throwable.getCause(); if (throwable != null) { text += "Caused by: "; } } DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); System.err.print(text); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); } }); mainBundle.css().ensureInjected(); // Generate the source code for the examples GWT.create(GeneratorInfo.class); SplitLayoutPanel panel = binder.createAndBindUi(this); // Populate the sample tree TreeItem shapesSample = tree .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " shapes"); shapesSample.setUserObject(new ShapesSample()); TreeItem eventSample = tree .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " events"); eventSample.setUserObject(new EventSample()); TreeItem parserSample = tree .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " parser"); parserSample.setUserObject(new ParserSample()); TreeItem featuresSample = tree .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " features"); featuresSample.setUserObject(new FeaturesSample()); TreeItem widgetsSample = tree .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " widgets"); widgetsSample.setUserObject(new WidgetsSample()); TreeItem smilSample = tree .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " SMIL animation"); smilSample.setUserObject(new SmilSample()); TreeItem xpathSample = tree .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " XPath"); xpathSample.setUserObject(new XPathSample()); TreeItem about = tree.addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " about"); about.setUserObject(new AboutSample()); tree.addSelectionHandler(new SelectionHandler<TreeItem>() { @Override public void onSelection(SelectionEvent<TreeItem> event) { SampleBase currentSample = (SampleBase) event.getSelectedItem().getUserObject(); selectSample(currentSample.getPanel()); } }); tree.setSelectedItem(shapesSample); RootLayoutPanel.get().add(panel); }
From source file:thothbot.parallax.demo.client.Demo.java
License:Open Source License
public void onModuleLoad() { GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable throwable) { Log.error("Uncaught exception", throwable); if (!GWT.isScript()) { String text = "Uncaught exception: "; while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int i = 0; i < stackTraceElements.length; i++) text += " at " + stackTraceElements[i] + "\n"; throwable = throwable.getCause(); if (throwable != null) text += "Caused by: "; }// w w w .jav a 2 s . c om DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); } } }); // Generate the source code for examples GWT.create(GenerateSourceSignal.class); // Generate the demo file GWT.create(GenerateFacebookSignal.class); resources.css().ensureInjected(); // Create the application shell. final SingleSelectionModel<ContentWidget> selectionModel = new SingleSelectionModel<ContentWidget>(); final DataModel treeModel = new DataModel(selectionModel); Set<ContentWidget> contentWidgets = treeModel.getAllContentWidgets(); index = new Index(); // Hide loading panel RootPanel.get("loading").getElement().getStyle().setVisibility(Visibility.HIDDEN); // Attach index panel RootLayoutPanel.get().add(index); index.getTabIndex().addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { displayIndex(); } }); indexWidget = new IndexWidget(treeModel); shell = new DemoShell(treeModel, index); // Prefetch examples when opening the Category tree nodes. final List<Category> prefetched = new ArrayList<Category>(); final CellTree mainMenu = shell.getMainMenu(); mainMenu.addOpenHandler(new OpenHandler<TreeNode>() { public void onOpen(OpenEvent<TreeNode> event) { Object value = event.getTarget().getValue(); if (!(value instanceof Category)) return; Category category = (Category) value; if (!prefetched.contains(category)) { prefetched.add(category); Prefetcher.prefetch(category.getSplitPoints()); } } }); // Always prefetch. Prefetcher.start(); // Change the history token when a main menu item is selected. selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { ContentWidget selected = selectionModel.getSelectedObject(); if (selected != null) { index.setContentWidget(shell); History.newItem("!" + selected.getContentWidgetToken(), true); } } }); // Setup a history handler to reselect the associate menu item. final ValueChangeHandler<String> historyHandler = new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { // Get the content widget associated with the history token. ContentWidget contentWidget = treeModel .getContentWidgetForToken(event.getValue().replaceFirst("!", "")); if (contentWidget == null) return; // Expand the tree node associated with the content. Category category = treeModel.getCategoryForContentWidget(contentWidget); TreeNode node = mainMenu.getRootTreeNode(); int childCount = node.getChildCount(); for (int i = 0; i < childCount; i++) { if (node.getChildValue(i) == category) { node.setChildOpen(i, true, true); break; } } // Display the content widget. displayContentWidget(contentWidget); //Add GA statistics trackPageview(Window.Location.getHref()); // Select the node in the tree. selectionModel.setSelected(contentWidget, true); } }; History.addValueChangeHandler(historyHandler); // Show the initial example. if (History.getToken().length() > 0) History.fireCurrentHistoryState(); // Use the first token available. else displayIndex(); // Generate a site map. createSiteMap(contentWidgets); }