Java Code Examples for com.google.gwt.user.client.History#newItem()

The following examples show how to use com.google.gwt.user.client.History#newItem() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: unitime   File: TeachingRequestsPage.java    License: Apache License 2.0 6 votes vote down vote up
void search() {
	History.newItem(iFilterBox.getValue(), false);
	InstructorCookie.getInstance().setQuery(iAssigned, iFilterBox.getValue());
	LoadingWidget.getInstance().show(MESSAGES.waitLoadingTeachingRequests());
	final TeachingRequestsFilterRpcRequest filter = iFilterBox.getElementsRequest();
	RPC.execute(new TeachingRequestsPageRequest(filter), new AsyncCallback<GwtRpcResponseList<TeachingRequestInfo>>() {
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			iFilterBox.setErrorHint(MESSAGES.failedToLoadTeachingRequests(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingRequests(caught.getMessage()), caught);
		}

		@Override
		public void onSuccess(GwtRpcResponseList<TeachingRequestInfo> result) {
			LoadingWidget.getInstance().hide();
			iTable.populate(result, filter);
			iTable.setVisible(true);
		}
	});
}
 
Example 2
Source Project: unitime   File: CurriculaPage.java    License: Apache License 2.0 6 votes vote down vote up
private void loadCurricula() {
	if (!iSearch.isEnabled()) return;
	iSearch.setEnabled(false);
	iPrint.setEnabled(false);
	iCurriculaTable.getOperations().setEnabled(false);
	final boolean newEnabled = iNew.isEnabled();
	if (newEnabled)
		iNew.setEnabled(false);
	History.newItem(iFilter.getValue(), false);
	iCurriculaTable.query(iFilter.getElementsRequest(), new AsyncCallback<TreeSet<CurriculumInterface>>() {
		@Override
		public void onFailure(Throwable caught) {
		}

		@Override
		public void onSuccess(TreeSet<CurriculumInterface> result) {
			iCurriculaTable.setVisible(true);
			iSearch.setEnabled(true);
			iPrint.setEnabled(true);
			iCurriculaTable.getOperations().setEnabled(true);
			if (newEnabled)
				iNew.setEnabled(true);
		}
	});
}
 
Example 3
Source Project: caja   File: Playground.java    License: Apache License 2.0 6 votes vote down vote up
public void loadSource(String base, String url) {
  gui.setLoading(true);
  gui.setUrl(url);
  if (!url.equals(History.getToken())) {
    History.newItem(url);
  }
  cajolingService.fetch(base, url, new AsyncCallback<String>() {
    public void onFailure(Throwable caught) {
      gui.setLoading(false);
      gui.addRuntimeMessage(caught.getMessage());
      gui.selectTab(PlaygroundView.Tabs.RUNTIME_WARNINGS);
    }

    public void onSuccess(String result) {
      gui.setLoading(false);
      gui.setOriginalSource(result);
      gui.selectTab(PlaygroundView.Tabs.SOURCE);
    }
  });
}
 
Example 4
Source Project: EasyML   File: AppController.java    License: Apache License 2.0 5 votes vote down vote up
public void go(final HasWidgets container) {
	logger.info("app view going...");
	this.container = container;

	if ("".equals(History.getToken())) {
		History.newItem("monitor");
	} else {
		History.fireCurrentHistoryState();
	}
}
 
Example 5
Source Project: appinventor-extensions   File: Ode.java    License: Apache License 2.0 5 votes vote down vote up
public void openYoungAndroidProjectInDesigner(final Project project) {
  ProjectRootNode projectRootNode = project.getRootNode();
  if (projectRootNode == null) {
    // The project nodes haven't been loaded yet.
    // Add a ProjectChangeListener so we'll be notified when they have been loaded.
    project.addProjectChangeListener(new ProjectChangeAdapter() {
      @Override
      public void onProjectLoaded(Project glass) {
        project.removeProjectChangeListener(this);
        openYoungAndroidProjectInDesigner(project);
      }
    });
    project.loadProjectNodes();

  } else {
    // The project nodes have been loaded. Tell the viewer to open
    // the project. This will cause the projects source files to be fetched
    // asynchronously, and loaded into file editors.
    ViewerBox.getViewerBox().show(projectRootNode);
    // Note: we can't call switchToDesignView until the Screen1 file editor
    // finishes loading. We leave that to setCurrentFileEditor(), which
    // will get called at the appropriate time.
    String projectIdString = Long.toString(project.getProjectId());
    if (!History.getToken().equals(projectIdString)) {
      // insert token into history but do not trigger listener event
      History.newItem(projectIdString, false);
    }
    if (assetManager == null) {
      assetManager = AssetManager.getInstance();
    }
    assetManager.loadAssets(project.getProjectId());
  }
  getTopToolbar().updateFileMenuButtons(1);
}
 
Example 6
private void setupHistory() {
	History.newItem(HISTORY_MAIN);

	// Add history listener
	History.addValueChangeHandler(new ValueChangeHandler<String>() {
		@Override
		public void onValueChange(ValueChangeEvent<String> event) {
			String token = event.getValue();
			if (!token.equals(HISTORY_MAIN)) {
				History.newItem(HISTORY_MAIN);
			}
		}
	});
}
 
Example 7
Source Project: cuba   File: HistoryGwtApi.java    License: Apache License 2.0 5 votes vote down vote up
protected void initStartState() {
    // we need to add new history tokens BEFORE ValueChangeHandler will added
    if (urlHasToken(TOP_HISTORY_TOKEN)) {
        History.newItem(PREVIOUS_HISTORY_TOKEN);
        // if init url has TOP_HISTORY_TOKEN, we inform what PREVIOUS_HISTORY_TOKEN should be fired,
        // otherwise not all state variables will have proper values
        isFireHistoryState = true;
    } else {
        History.newItem(TOP_HISTORY_TOKEN);
    }
}
 
Example 8
public void showPage(int index) {


        // notify callbacks
        for(PageCallback callback : callbacks)
            callback.onRevealPage(index);


        if(!navOnFirstPage && navigationBar!=null)
        {
            // navigation only on subsequent pages
            if(index>0)
            {

                layout.setWidgetHidden(navigationBar, false);
            }
            else
            {
                layout.setWidgetHidden(navigationBar, true);
            }
        }

         // TODO: clear history tokens
        if(index==0)
        {
            PlaceManager placeManager = Console.getPlaceManager();
            String nameToken = placeManager.getCurrentPlaceRequest().getNameToken();
            History.newItem(nameToken, false);
        }

        deck.showWidget(index);
        bar.setActive(index);
    }
 
Example 9
@Override
public void openDialog(String title, String source, String width, String height, boolean noCacheTS) {
	if (isShowing()) hideDialog();
	GwtHint.hideHint();
	
	iScrollLeft = Window.getScrollLeft(); iScrollTop = Window.getScrollTop();
	Window.scrollTo(0, 0);

	LoadingWidget.getInstance().show("Loading " + title + " ...");
	setText(title);
	if (noCacheTS) {
		String hash = null;
		int hashIdx = source.lastIndexOf('#');
		if (hashIdx >= 0) {
			hash = source.substring(hashIdx);
			source = source.substring(0, hashIdx);
		}
		iFrame.setUrl(source + (source.indexOf('?') >= 0 ? "&" : "?") + "noCacheTS=" + new Date().getTime() + (hash == null ? "" : hash));
	} else {
		iFrame.setUrl(source);
	}
	iCheckLoadingWidgetIsShowing.schedule(30000);
	
	History.newItem(title, false);
	iPopup.setPopupPosition(0, 0);
	iPopup.show();
	RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
}
 
Example 10
Source Project: unitime   File: ReservationsPage.java    License: Apache License 2.0 5 votes vote down vote up
private void loadReservations() {
	if (!iSearch.isEnabled()) return;
	iSearch.setEnabled(false);
	iPrint.setEnabled(false);
	final boolean newEnabled = iNew.isEnabled();
	if (newEnabled)
		iNew.setEnabled(false);
	History.newItem(iFilter.getValue(), false);
	LoadingWidget.getInstance().show(MESSAGES.waitLoadingReservations());
	iReservationTable.query(iFilter.getElementsRequest(), new AsyncCallback<List<ReservationInterface>>() {
		@Override
		public void onSuccess(List<ReservationInterface> result) {
			LoadingWidget.getInstance().hide();
			iSearch.setEnabled(true);
			iPrint.setEnabled(true);
			if (newEnabled)
				iNew.setEnabled(true);
			if (iLastReservationId != null) {
				iReservationTable.select(iLastReservationId);
				iReservationTable.scrollIntoView(iLastReservationId);
			}
		}
		
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			iReservationTable.setErrorMessage(MESSAGES.failedToLoadReservations(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToLoadReservations(caught.getMessage()), caught);
			ToolBox.checkAccess(caught);
		}
	});
}
 
Example 11
Source Project: gwt-ol   File: GwtOLPlayground.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void setVisible(boolean visible) {
    if (visible && !initialized) {
        Scheduler.get().scheduleDeferred(() -> example.getExample().show(example.getExample().toString()));
        initialized = true;
    }
    super.setVisible(visible);

    if (visible) {
        History.newItem(example.name());
    }
}
 
Example 12
Source Project: shortyz   File: Game.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Inject
public Game(RootPanel rootPanel, PuzzleServiceProxy service,
    Resources resources, final PuzzleListView plv, Renderer renderer) {
    this.service = service;
    this.plv = plv;
    this.renderer = renderer;
    this.css = resources.css();

    History.newItem("list", false);
    History.addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                if (event.getValue().equals("list")) {
                    if (closingRegistration != null) {
                        closingRegistration.removeHandler();
                        closingRegistration = null;
                    }

                    if (autoSaveTimer != null) {
                        autoSaveTimer.cancel();
                        autoSaveTimer.run();
                        autoSaveTimer = null;
                    }

                    mainPanel.setWidget(plv);
                    keyboardIntercept.removeKeyboardListener(l);

                    getDisplayChangeListener().onDisplayChange();
                } else if (event.getValue().startsWith("play=")) {
                    Long id = Long.parseLong(event.getValue().split("=")[1]);
                    loadPuzzle(id);
                }
            }
        });
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setWidth("100%");
    StyleInjector.inject(resources.css().getText());
    keyboardIntercept.setWidth("1px");
    keyboardIntercept.setHeight("1px");
    keyboardIntercept.setStyleName(css.keyboardIntercept());
    rootPanel.add(keyboardIntercept);

    verticalPanel.add(status);
    verticalPanel.setCellHorizontalAlignment(status,
        HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(mainPanel);
    verticalPanel.setCellHorizontalAlignment(mainPanel,
        HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(below);
    display.add(verticalPanel);
    display.setWidth("97%");
    rootPanel.add(display);
}
 
Example 13
Source Project: unitime   File: RoomsPage.java    License: Apache License 2.0 4 votes vote down vote up
public void mark() {
	String token = toString();
	if (!History.getToken().equals(token))
		History.newItem(token, false);
	RoomCookie.getInstance().setHash(iMode, toString("id"));
}
 
Example 14
Source Project: unitime   File: EventResourceTimetable.java    License: Apache License 2.0 4 votes vote down vote up
public void mark() {
	String token = toString();
	if (!History.getToken().equals(token))
		History.newItem(token, false);
	EventCookie.getInstance().setHash(iType, toString("event"));
}
 
Example 15
Source Project: unitime   File: StudentSectioningWidget.java    License: Apache License 2.0 4 votes vote down vote up
private void addHistory() {
	if (iInRestore || !iTrackHistory || iUserAuthentication.getUser() == null) return;
	iHistory.add(new HistoryItem());
	History.newItem(String.valueOf(iHistory.size() - 1), false);
}
 
Example 16
Source Project: unitime   File: SectioningReports.java    License: Apache License 2.0 4 votes vote down vote up
private void execute() {
	iHeader.setEnabled("print", false);
	
	if (iReportSelector.getWidget().getSelectedIndex() <= 0) {
		iHeader.setErrorMessage(MESSAGES.errorNoReportSelected());
		return;
	}
	
	ReportTypeInterface type = getReportType(iReportSelector.getWidget().getValue(iReportSelector.getWidget().getSelectedIndex()));
	iLastHistory = type.getReference();
	iTable.clearTable();
	iTableHeader.clearMessage();
	iHeader.clearMessage();
	LoadingWidget.getInstance().show(MESSAGES.waitExecuting(type.getName()));
	History.newItem(iLastHistory + ":" + iFirstLine + ":" + iLastSort, false);
	
	SectioningReportRpcRequest request = new SectioningReportRpcRequest();
	request.setParameter("report", type.getImplementation());
	request.setParameter("online", iOnline ? "true" : "false");
	for (int i = 0; i + 1 < type.getParameters().length; i += 2)
		request.setParameter(type.getParameters()[i], type.getParameters()[i + 1]);
	
	RPC.execute(request, new AsyncCallback<SectioningReportRpcResponse>() {
		@Override
		public void onFailure(Throwable caught) {
			iTableHeader.setErrorMessage(caught.getMessage());
			LoadingWidget.getInstance().hide();
		}
		@Override
		public void onSuccess(SectioningReportRpcResponse result) {
			iData.clear();
			RowData prev = null;
			for (int i = 0; i < result.getReport().size(); i ++) {
				String[] row = result.getReport().get(i);
				if (row.length == 0) continue;
				RowData data = new RowData(row);
				while (prev != null) {
					if (data.getNrBlanks() > prev.getNrBlanks()) break;
					prev = prev.getParent();
				}
				if (prev != null)
					data.setParent(prev);
				if (i == 0) {
					iHead = data;
				} else {
					iData.add(data);
					prev = data;
				}
			}
			populate(true);
			LoadingWidget.getInstance().hide();
		}
	});
}
 
Example 17
Source Project: mvp4g   File: DefaultHistoryProxy.java    License: Apache License 2.0 4 votes vote down vote up
public void newItem(String historyToken) {
  History.newItem(historyToken);
}
 
Example 18
Source Project: mvp4g   File: DefaultHistoryProxy.java    License: Apache License 2.0 4 votes vote down vote up
public void newItem(String historyToken,
                    boolean issueEvent) {
  History.newItem(historyToken,
                  issueEvent);
}
 
Example 19
Source Project: gwtmockito   File: GwtMockitoTest.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * {@link History} relies on a GWT.create'd implementation class, so we
 * should return a mock to avoid surprising NPEs.
 */
@Test
public void shouldNotBreakWhenCallingHistoryNewItem() {
  History.newItem("foo");
}
 
Example 20
Source Project: gwtmockito   File: GwtMockitoTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void shouldBeAbleToUseHistory() {
  History.newItem("token");
  assertEquals("token", History.getToken());
}