protected void setup() { RootPanel.get().add(mainPresenter.getDisplay().asWidget()); mainPresenter.bind(); History.addValueChangeHandler(this); eventBus.addHandler( LoginSuccessfulEvent.TYPE, new LoginSuccessfulEventHandler() { @Override public void loginSuccessful(LoginSuccessfulEvent event) { History.newItem(getPreviousHistoryToken()); } }); eventBus.addHandler( LoginRequiredEvent.TYPE, new LoginRequiredEventHandler() { @Override public void loginRequired(LoginRequiredEvent event) { if (!AppPlace.HOME.equals(getPlace(History.getToken()))) { History.newItem(AppPlace.HOME.getToken()); } } }); switchSection(History.getToken()); }
@Inject public ActivityManager( ApplicationLayout layout, FlexInjector injector, ActivityMap activityMap, @Named("DefaultHistoryToken") String defaultplace, LocationInfo locationInfo) { this.injector = injector; this.activityMap = activityMap; this.defaultplace = defaultplace; this.display = layout; this.locationInfo = locationInfo; /* * We create the initial GUI elements needed for displaying activities. */ layout.go(); History.addValueChangeHandler(this); /* * If we do not have anything in the history stack de go to the default * view TODO: Decide if we should redirect like here or just show it */ if ("".equals(History.getToken())) { goHome(); } else { /* * If we have a history token we fire the change event which handles * setup of the activity */ History.fireCurrentHistoryState(); } }
public void onValueChange(ValueChangeEvent<String> event) { // get the querystring token String historyToken = History.getToken(); // send to static method that will send the __utm.gif to google's server fro tracking Track.track(historyToken); }
/** Sets up start page and initializes the history */ public void loadBaseView() { // Consistently loaded upon launch content // RootPanel.get("body").add(new HomeView()); RootPanel.get("body").add(allViews.get(ViewEnum.HOME)); if (History.getToken().length() == 0) { History.newItem("HOME"); } }
private void HistoryInitialization() { HistoryValueChangeHandler historyValueChangeHandler = new HistoryValueChangeHandler(); History.addValueChangeHandler(historyValueChangeHandler); String token = History.getToken(); if (token.isEmpty()) { History.newItem("list&1"); } else { History.fireCurrentHistoryState(); } }
/** * This will return immediately if the token passed in the event object isn't the token currently * on the History stack, or if the static back variable is true. If those aren't the case it calls * stateHandler.validateToken(token) and checks for equality with the token passed in. If they are * unequal it calls back() and adds a new item immediately after, then returns. If everything * checks out then the method cycles through the list of ClientWidget's and adds those which are * related to the page, by calling addWidget(). */ public void onValueChange(ValueChangeEvent<String> event) { String token = event.getValue(); if (back || !token.equals(History.getToken())) return; String validatedToken = stateHandler.validateToken(token); if (!stateHandler.compareTokens(token, validatedToken)) { // back(); /* Actually works in Chrome, so I can't use this trick History.newItem(validatedToken); return; } for (ClientWidget w : list) if (w.isTokenRelated(validatedToken)) w.addWidgetToRootPanel(); }
private void redraw(boolean autoScroll) { if (autoScroll) { String historyToken = History.getToken(); if (!Strings.isNullOrEmpty(historyToken)) { int top = this.affixMenu.getPinnedOffset(); Window.scrollTo(Window.getScrollLeft(), top); } else { Window.scrollTo(Window.getScrollLeft(), 0); } } }
public void onModuleLoad() { History.addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { openView(event.getValue()); } }); openView(History.getToken()); }
public void start() { evalHistoryToken(History.getToken()); if (!historyToken.isProjectIdSet()) { User user = auth.getUser(); Project project = user.getCurrentProject(); if (project == null || user.isAdmin()) { gotoProjectSelector(); } else { gotoProject(project.getId()); } } }
public ExplorerViewCenterPanel() { tp = new TabPanel(); tp.setBodyBorder(false); tp.setEnableTabScroll(true); tp.setAutoDestroy(true); tp.setResizeTabs(true); tp.setLayoutOnTabChange(true); tp.setActiveTab(0); tp.setEnableTabScroll(true); tp.setMinTabWidth(90); centerLayoutData = new BorderLayoutData(RegionPosition.CENTER); centerLayoutData.setMargins(new Margins(5, 0, 5, 5)); String tok = History.getToken(); // listener to try and stop people from forgetting to save... tp.addListener( new TabPanelListenerAdapter() { @Override public boolean doBeforeRemove(Container self, final Component component) { if (openedAssetEditors.containsKey(component.getId())) { RuleViewer rv = openedAssetEditors.get(component.getId()); if (rv.isDirty()) { component.show(); return Window.confirm( "Are you sure you want to close this item? Any unsaved changes will be lost."); } else { return true; } } return true; } }); addCloseAllButton(); openAssetByToken(tok); }
@Override public void execute() { String initialToken = History.getToken(); if (!initialToken.isEmpty() && !isBlackListed(initialToken)) { List<PlaceRequest> hierarchy = formatter.toPlaceRequestHierarchy(initialToken); final PlaceRequest placeRequest = hierarchy.get(hierarchy.size() - 1); Scheduler.get() .scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { placeManager.revealPlace(placeRequest, true); } }); bootstrapContext.setInitialPlace(placeRequest.getNameToken()); } else { placeManager.revealDefaultPlace(); } }
// This is invoked by smartgwt when the user clicks on a Tab in the TabSet, or TabSet.selectTab() // is called. It // sets the current SubTab and fires an event to notify AbstractTwoLevelTabSet that a tab/subtab // has been selected. public void onTabSelected(TabSelectedEvent tabSelectedEvent) { // if requested, ignore select tab notifications. smartgwt can generate unwanted notifications // while we manipulate the tabset (e.g. when hiding the current tab). We want to manage this at // a higher level if (isIgnoreSelectEvents()) { return; } TwoLevelTab tab = (TwoLevelTab) getSelectedTab(); SubTab currentSubTab = tab.getLayout().getCurrentSubTab(); if (null != currentSubTab) { TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent( tab.getName(), tab.getLayout().getCurrentSubTab().getName(), tabSelectedEvent.getTabNum(), tab.getLayout().getCurrentCanvas(), History.getToken()); m.fireEvent(event); } }
/** * lets use the url to show where to login at * * @param userData */ private void setLoggedOut(UserDataProxy userData) { if (userData == null) { // this shouldn't happen, b/c we need the urls return; } String url = userData.getLoginUrl(); String qs = Window.Location.getQueryString(); String token = History.getToken(); if (qs != null) { url += URL.encode(qs); } if (token != null && token.length() > 0) { url += URL.encode("#" + token); } // This is a must, always clean before draw SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder .appendHtmlConstant("<a href='" + url + "'>") .appendEscaped("Sign In") .appendHtmlConstant("</a>"); htmlUrl.setHTML(builder.toSafeHtml()); }
@Override public void onModuleLoad() { // Initialize the singleton before calling the constructors of the // various widgets that might call GSS.get(). singleton = this; parseUserCredentials(); topPanel = new TopPanel(GSS.images); topPanel.setWidth("100%"); messagePanel.setWidth("100%"); messagePanel.setVisible(false); search = new Search(images); searchStatus.add(search, DockPanel.WEST); searchStatus.add(userDetailsPanel, DockPanel.EAST); searchStatus.setCellHorizontalAlignment(userDetailsPanel, HasHorizontalAlignment.ALIGN_RIGHT); searchStatus.setCellVerticalAlignment(search, HasVerticalAlignment.ALIGN_MIDDLE); searchStatus.setCellVerticalAlignment(userDetailsPanel, HasVerticalAlignment.ALIGN_MIDDLE); searchStatus.setWidth("100%"); fileList = new FileList(images); searchResults = new SearchResults(images); // Inner contains the various lists. inner.sinkEvents(Event.ONCONTEXTMENU); inner.setAnimationEnabled(true); inner.getTabBar().addStyleName("gss-MainTabBar"); inner.getDeckPanel().addStyleName("gss-MainTabPanelBottom"); inner.add( fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true); inner.add( groups, createHeaderHTML(AbstractImagePrototype.create(images.groups()), "Groups"), true); inner.add( searchResults, createHeaderHTML(AbstractImagePrototype.create(images.search()), "Search Results"), true); // inner.add(new CellTreeView(images), // createHeaderHTML(AbstractImagePrototype.create(images.search()), "Cell tree sample"), true); inner.setWidth("100%"); inner.selectTab(0); inner.addSelectionHandler( new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { int tabIndex = event.getSelectedItem(); // TreeItem treeItem = GSS.get().getFolders().getCurrent(); switch (tabIndex) { case 0: // Files tab selected // fileList.clearSelectedRows(); fileList.updateCurrentlyShowingStats(); break; case 1: // Groups tab selected groups.updateCurrentlyShowingStats(); updateHistory("Groups"); break; case 2: // Search tab selected searchResults.clearSelectedRows(); searchResults.updateCurrentlyShowingStats(); updateHistory("Search"); break; } } }); // If the application starts with no history token, redirect to a new "Files" state String initToken = History.getToken(); if (initToken.length() == 0) History.newItem("Files"); // Add history listener to handle any history events History.addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { String tokenInput = event.getValue(); String historyToken = handleSpecialFolderNames(tokenInput); try { if (historyToken.equals("Search")) inner.selectTab(2); else if (historyToken.equals("Groups")) inner.selectTab(1); else if (historyToken.equals("Files") || historyToken.length() == 0) inner.selectTab(0); else { /*TODO: CELLTREE PopupTree popupTree = GSS.get().getFolders().getPopupTree(); TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken); SelectionEvent.fire(popupTree, treeObj); */ } } catch (IndexOutOfBoundsException e) { inner.selectTab(0); } } }); // Add the left and right panels to the split panel. splitPanel.setLeftWidget(treeView); splitPanel.setRightWidget(inner); splitPanel.setSplitPosition("25%"); splitPanel.setSize("100%", "100%"); splitPanel.addStyleName("gss-splitPanel"); // Create a dock panel that will contain the menu bar at the top, // the shortcuts to the left, the status bar at the bottom and the // right panel taking the rest. VerticalPanel outer = new VerticalPanel(); outer.add(topPanel); outer.add(searchStatus); outer.add(messagePanel); outer.add(splitPanel); outer.add(statusPanel); outer.setWidth("100%"); outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER); outer.setSpacing(4); // Hook the window resize event, so that we can adjust the UI. Window.addResizeHandler(this); // Clear out the window's built-in margin, because we want to take // advantage of the entire client area. Window.setMargin("0px"); // Finally, add the outer panel to the RootPanel, so that it will be // displayed. RootPanel.get().add(outer); // Call the window resized handler to get the initial sizes setup. Doing // this in a deferred command causes it to occur after all widgets' // sizes have been computed by the browser. DeferredCommand.addCommand( new Command() { @Override public void execute() { onWindowResized(Window.getClientHeight()); } }); }
@Override public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { ConnectorMap paintableMap = ConnectorMap.get(getConnection()); getWidget().rendering = true; getWidget().id = getConnectorId(); boolean firstPaint = getWidget().connection == null; getWidget().connection = client; getWidget().immediate = getState().immediate; getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY); String newTheme = uidl.getStringAttribute("theme"); if (getWidget().theme != null && !newTheme.equals(getWidget().theme)) { // Complete page refresh is needed due css can affect layout // calculations etc getWidget().reloadHostPage(); } else { getWidget().theme = newTheme; } // this also implicitly removes old styles String styles = ""; styles += getWidget().getStylePrimaryName() + " "; if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { styles += style + " "; } } if (!client.getConfiguration().isStandalone()) { styles += getWidget().getStylePrimaryName() + "-embedded"; } getWidget().setStyleName(styles.trim()); getWidget().makeScrollable(); clickEventHandler.handleEventHandlerRegistration(); // Process children int childIndex = 0; // Open URL:s boolean isClosed = false; // was this window closed? while (childIndex < uidl.getChildCount() && "open".equals(uidl.getChildUIDL(childIndex).getTag())) { final UIDL open = uidl.getChildUIDL(childIndex); final String url = client.translateVaadinUri(open.getStringAttribute("src")); final String target = open.getStringAttribute("name"); if (target == null) { // source will be opened to this browser window, but we may have // to finish rendering this window in case this is a download // (and window stays open). Scheduler.get() .scheduleDeferred( new Command() { @Override public void execute() { VUI.goTo(url); } }); } else if ("_self".equals(target)) { // This window is closing (for sure). Only other opens are // relevant in this change. See #3558, #2144 isClosed = true; VUI.goTo(url); } else { String options; boolean alwaysAsPopup = true; if (open.hasAttribute("popup")) { alwaysAsPopup = open.getBooleanAttribute("popup"); } if (alwaysAsPopup) { if (open.hasAttribute("border")) { if (open.getStringAttribute("border").equals("minimal")) { options = "menubar=yes,location=no,status=no"; } else { options = "menubar=no,location=no,status=no"; } } else { options = "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes"; } if (open.hasAttribute("width")) { int w = open.getIntAttribute("width"); options += ",width=" + w; } if (open.hasAttribute("height")) { int h = open.getIntAttribute("height"); options += ",height=" + h; } Window.open(url, target, options); } else { open(url, target); } } childIndex++; } if (isClosed) { // don't render the content, something else will be opened to this // browser view getWidget().rendering = false; return; } // Handle other UIDL children UIDL childUidl; while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) { String tag = childUidl.getTag().intern(); if (tag == "actions") { if (getWidget().actionHandler == null) { getWidget().actionHandler = new ShortcutActionHandler(getWidget().id, client); } getWidget().actionHandler.updateActionMap(childUidl); } else if (tag == "notifications") { for (final Iterator<?> it = childUidl.getChildIterator(); it.hasNext(); ) { final UIDL notification = (UIDL) it.next(); VNotification.showNotification(client, notification); } } } if (uidl.hasAttribute("focused")) { // set focused component when render phase is finished Scheduler.get() .scheduleDeferred( new Command() { @Override public void execute() { ComponentConnector paintable = (ComponentConnector) uidl.getPaintableAttribute("focused", getConnection()); final Widget toBeFocused = paintable.getWidget(); /* * Two types of Widgets can be focused, either implementing * GWT HasFocus of a thinner Vaadin specific Focusable * interface. */ if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; toBeFocusedWidget.setFocus(true); } else if (toBeFocused instanceof Focusable) { ((Focusable) toBeFocused).focus(); } else { VConsole.log("Could not focus component"); } } }); } // Add window listeners on first paint, to prevent premature // variablechanges if (firstPaint) { Window.addWindowClosingHandler(getWidget()); Window.addResizeHandler(getWidget()); } if (uidl.hasAttribute("scrollTo")) { final ComponentConnector connector = (ComponentConnector) uidl.getPaintableAttribute("scrollTo", getConnection()); scrollIntoView(connector); } if (uidl.hasAttribute(UIConstants.LOCATION_VARIABLE)) { String location = uidl.getStringAttribute(UIConstants.LOCATION_VARIABLE); int fragmentIndex = location.indexOf('#'); if (fragmentIndex >= 0) { getWidget().currentFragment = location.substring(fragmentIndex + 1); } if (!getWidget().currentFragment.equals(History.getToken())) { History.newItem(getWidget().currentFragment, true); } } if (firstPaint) { // Queue the initial window size to be sent with the following // request. getWidget().sendClientResized(); } getWidget().rendering = false; }
/** Activate the control. */ public void activate() { this.clear(); this.setVisible(true); Widget avatar = new AvatarWidget( Session.getInstance().getCurrentPerson().getId(), Session.getInstance().getCurrentPerson().getAvatarId(), EntityType.PERSON, Size.VerySmall, Background.White); avatar.addStyleName("avatar"); this.add(avatar); FlowPanel body = new FlowPanel(); body.addStyleName("body"); commentBox = new TextArea(); body.add(commentBox); commentBox.setFocus(true); countDown = new Label(Integer.toString(MAXLENGTH)); countDown.addStyleName("characters-remaining"); body.add(countDown); post = new Hyperlink("post", History.getToken()); post.addStyleName("post-button"); post.addStyleName("inactive"); final Label warning = new Label(); warning.addStyleName("warning hidden"); body.add(warning); Session.getInstance() .getEventBus() .addObserver( GotSystemSettingsResponseEvent.class, new Observer<GotSystemSettingsResponseEvent>() { public void update(final GotSystemSettingsResponseEvent event) { String text = event.getResponse().getContentWarningText(); if (text != null && !text.isEmpty()) { warning.removeStyleName("hidden"); warning.setText(text); } } }); SystemSettingsModel.getInstance().fetch(null, true); post.addClickHandler( new ClickHandler() { public void onClick(final ClickEvent event) { fullCollapse = false; if (!inactive) { unActivate(); CommentDTO comment = new CommentDTO(); comment.setBody(commentBox.getText()); comment.setActivityId(messageId); Session.getInstance() .getActionProcessor() .makeRequest( new ActionRequestImpl<CommentDTO>("postActivityCommentAction", comment), new AsyncCallback<CommentDTO>() { /* implement the async call back methods */ public void onFailure(final Throwable caught) {} public void onSuccess(final CommentDTO result) { Session.getInstance() .getEventBus() .notifyObservers(new CommentAddedEvent(result, messageId)); } }); } } }); body.add(post); this.add(body); commentBox.setFocus(true); nativeSetFocus(commentBox.getElement()); commentBox.addBlurHandler( new BlurHandler() { public void onBlur(final BlurEvent arg0) { TimerFactory timerFactory = new TimerFactory(); timerFactory.runTimer( BLUR_DELAY, new TimerHandler() { public void run() { if (commentBox.getText().length() == 0) { unActivate(); } } }); } }); commentBox.addKeyPressHandler( new KeyPressHandler() { public void onKeyPress(final KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ESCAPE) { unActivate(); } } }); commentBox.addKeyUpHandler( new KeyUpHandler() { public void onKeyUp(final KeyUpEvent event) { onCommentChanges(); } }); commentBox.addChangeHandler( new ChangeHandler() { public void onChange(final ChangeEvent event) { onCommentChanges(); } }); }
String getBrowserHistoryToken() { return History.getToken(); }
public GalleryPanel() { initWidget(uiBinder.createAndBindUi(this)); initUI(); String currentToken = History.getToken(); processHistoryChange(currentToken); }
public void fireCurrentPlace() { if (History.getToken() != null) { History.fireCurrentHistoryState(); } }
private void handleInitialHistoryToken() { final String token = History.getToken(); handleHistoryChange(token); }
/** * Builds the UI. * * @param inScope the scope. */ private void setupWidgets(final StreamScope inScope) { this.getElement().setAttribute("id", "post-to-stream"); this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().small()); charsRemaining = new Label(); postButton = new Hyperlink("", History.getToken()); postButton.getElement().setAttribute("tabindex", "2"); message = new PostToStreamTextboxPanel(); message.setText(postBoxDefaultText); message.setVisible(false); // Hide until post ready event. this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postToStream()); errorMsg.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formErrorBox()); errorMsg.setVisible(false); this.add(errorMsg); FlowPanel postInfoContainer = new FlowPanel(); postInfoContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postInfoContainer()); postButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postButton()); postInfoContainer.add(postButton); charsRemaining.addStyleName(StaticResourceBundle.INSTANCE.coreCss().charactersRemaining()); postInfoContainer.add(charsRemaining); AvatarWidget avatar = new AvatarWidget( Session.getInstance().getCurrentPerson(), EntityType.PERSON, Size.VerySmall); avatar.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postEntryAvatar()); Panel entryPanel = new FlowPanel(); entryPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postEntryPanel()); entryPanel.add(avatar); entryPanel.add(postInfoContainer); entryPanel.add(message); SimplePanel breakPanel = new SimplePanel(); breakPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().breakClass()); entryPanel.add(breakPanel); add(entryPanel); // below text area: links and post to on one line, then content warning below expandedPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postExpandedPanel()); postToPanel = new PostToPanel(inScope); expandedPanel.add(postToPanel); links = new AddLinkComposite(); expandedPanel.add(links); contentWarning = new FlowPanel(); contentWarningContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().contentWarning()); contentWarningContainer.add(new SimplePanel()); contentWarningContainer.add(contentWarning); expandedPanel.add(contentWarningContainer); add(expandedPanel); setVisible(false); setVisible(Session.getInstance().getCurrentPerson() != null); }
public String getCurrentPageId() { return History.getToken(); }
@Override protected void onAttach() { super.onAttach(); historyHandlerRegistration = History.addValueChangeHandler(historyChangeHandler); currentFragment = History.getToken(); }