Java Code Examples for com.google.gwt.user.client.History

The following are top voted examples for showing how to use com.google.gwt.user.client.History. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: unitimes   File: TeachingRequestsPage.java   View source code 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
Project: unitimes   File: TeachingAssignmentsPage.java   View source code 6 votes vote down vote up
void search() {
	History.newItem(iFilterBox.getValue(), false);
	InstructorCookie.getInstance().setQuery(null, iFilterBox.getValue());
	LoadingWidget.getInstance().show(MESSAGES.waitLoadingTeachingAssignments());
	final TeachingRequestsFilterRpcRequest filter = iFilterBox.getElementsRequest();
	RPC.execute(new TeachingAssignmentsPageRequest(filter), new AsyncCallback<GwtRpcResponseList<InstructorInfo>>() {
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			iFilterBox.setErrorHint(MESSAGES.failedToLoadTeachingAssignments(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingAssignments(caught.getMessage()), caught);
		}

		@Override
		public void onSuccess(GwtRpcResponseList<InstructorInfo> result) {
			LoadingWidget.getInstance().hide();
			iTable.populate(result);
			iTable.setVisible(true);
		}
	});
}
 
Example 3
Project: unitimes   File: CurriculaPage.java   View source code 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 4
Project: unitimes   File: PointInTimeDataReportsPage.java   View source code 6 votes vote down vote up
public void setBack() {
	if (iFirstField == null || !iFirstField.startsWith("__") || iTable.getRowCount() <= 1) return;
	PITDSetBackRpcRequest request = new PITDSetBackRpcRequest();
	for (int i = 1; i < iTable.getRowCount(); i++) {
		String[] row = iTable.getData(i);
		if (row != null) {
			Long id = Long.valueOf(row[0]);
			request.addId(id);
		}
	}
	request.setHistory(History.getToken());
	request.setType(iFirstField);
	RPC.execute(request, new AsyncCallback<GwtRpcResponseNull>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
		}

		@Override
		public void onSuccess(GwtRpcResponseNull result) {
		}
	});
}
 
Example 5
Project: unitimes   File: SavedHQLPage.java   View source code 6 votes vote down vote up
public void setBack() {
	if (iFirstField == null || !iFirstField.startsWith("__") || iTable.getRowCount() <= 1) return;
	HQLSetBackRpcRequest request = new HQLSetBackRpcRequest();
	for (int i = 1; i < iTable.getRowCount(); i++) {
		String[] row = iTable.getData(i);
		if (row != null) {
			Long id = Long.valueOf(row[0]);
			request.addId(id);
		}
	}
	request.setAppearance(iAppearance);
	request.setHistory(History.getToken());
	request.setType(iFirstField);
	RPC.execute(request, new AsyncCallback<GwtRpcResponseNull>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
		}

		@Override
		public void onSuccess(GwtRpcResponseNull result) {
		}
	});
}
 
Example 6
Project: x-gwt   File: Dialog.java   View source code 6 votes vote down vote up
void enableHistory() {
    if (this.historyHandlerRegistration == null) {
        this.historyHandlerRegistration = History.addValueChangeHandler(event -> overlay(hasHistoryDialogParameter(event.getValue()))
                .then(opened -> {
                    if (opened) {
                        OpenEvent.fire(Dialog.this, Dialog.this);
                    } else {
                        disableHistory();
                        CloseEvent.fire(Dialog.this, Dialog.this);
                    }
                }));
    }
    if (this.openedHandlerRegistration == null) {
        openedHandlerRegistration = p().onPropertyChange("opened", (Fn.Arg<Boolean>) opened -> {
            if (opened) {
                addDialogParameter();
            } else {
                removeDialogParameter();
            }
        });
    }
}
 
Example 7
Project: vaitools   File: ToolBrowser.java   View source code 6 votes vote down vote up
private void doSearch(String s)
{

	toolsvc.getModel(s, new AsyncCallback<ArrayList<Tool>>(){

		@Override
		public void onFailure(Throwable caught) {
			Info.display("Error",caught.getMessage());
		}

		@Override
		public void onSuccess(final ArrayList<Tool> result) {
			History.newItem("results");
			tools = result;
			showSearchResults();
		}});
}
 
Example 8
Project: vaitools   File: ToolBrowser.java   View source code 6 votes vote down vote up
private void showSearchResults()
{
	resultsFlow.clear();
	for(int i = 0; i<tools.size();i++)
	{
		ModelView t = new  ModelView(tools.get(i),true);
		final int j = i;
		t.addClickHandler(new ClickHandler(){

			@Override
			public void onClick(ClickEvent event) {
				History.newItem("" + j);
			}});
		resultsFlow.add(t);
	}
}
 
Example 9
Project: Wiab.pro   File: HistoryChangeListener.java   View source code 6 votes vote down vote up
/**
 * Commonly we start to listen history changes when webclient starts calling this
 * method. If you are using wave client integrated with other different GWT application
 * and with a different History management, you can avoid to use this and just
 * call to the {@link WaveSelectionEvent} events (for example) or other uses.
 */
public static void init() {
  History.addValueChangeHandler(
      new ValueChangeHandler<String>() {
        
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
          String encodedToken = event.getValue();
          if (encodedToken == null || encodedToken.length() == 0) {
            return;
          }
          WaveRef waveRef;
          try {
            waveRef = GwtWaverefEncoder.decodeWaveRefFromPath(encodedToken);
          } catch (InvalidWaveRefException e) {
            LOG.error().log("History token contains invalid path: " + encodedToken);
            return;
          }
          LOG.trace().log("Changing selected wave based on history event to " + waveRef.toString());
          ClientEvents.get().fireEvent(
              new WaveSelectionEvent(waveRef, false, false));
        }
      });
}
 
Example 10
Project: Wiab.pro   File: EventPreviewAutoHiderRegistrar.java   View source code 6 votes vote down vote up
@Override
public void registerAutoHider(final AutoHider autoHider) {
  autoHider.setRegistered(true);
  autoHiders.add(autoHider);

  if (eventPreviewRegistration == null) {
    eventPreviewRegistration = Event.addNativePreviewHandler(this);
  }

  if (onResizeRegistration == null) {
    onResizeRegistration = Window.addResizeHandler(this);
  }

  if (onHistoryRegistration == null) {
    onHistoryRegistration = History.addValueChangeHandler(this);
  }
}
 
Example 11
Project: x-cure-chat   File: MessagesStackNavigator.java   View source code 6 votes vote down vote up
/**
 * Allows to notify the ForumManager about the current latest stack element.
 * This is needed for managing the "New topic" <=> "Reply here" button handling
 * Also, this method updates the browser history. NOTE: does not update the
 * history token if the site section is not selected and the new set search
 * item is the same as in the history token! When the history token is set
 * the history-change event is suppressed!
 */
private void notifyAboutCurrentStackElement( ) {
	if( messageStack.size() > 0 ) {
		final MessageStackElement element = messageStack.get( messageStack.size() - 1 );
		//Set the appropriate action
		searchPanel.setNewActionType( element.getMessageData() );
		//Mark sure the proper topic ID is set
		searchPanel.setCurrTopicMessageID( ShortForumMessageData.getTopicMessageID( element.getMessageData() ) );
		final String currentHistoryToken = History.getToken();
		if( ( currentHistoryToken == null || ! currentHistoryToken.equals( serializeTopStackElement( false ) ) ) && isSiteSetionSelected ) {
			//Since we were added here, this means that the forum search
			//was performed and a new element was set, here we update History
			History.newItem( serializeTopStackElement( false ), false );
		}
	}
	//Scroll to the last stack element
	scrollToLastStackElement();
}
 
Example 12
Project: x-cure-chat   File: SiteNavigator.java   View source code 6 votes vote down vote up
/**
 * This is a simple constructor that has to be provided with a simple panel that will store the main site body
 * @param siteBodyPanel the panel that will store the site body
 */
public SiteNavigator( final SimplePanel siteBodyPanel ) {
	//Initialize the site navigator with the required elements:
	
	//Add the chat section of the site
	registerNewSiteSection( new ChatNavigatorElement( true, siteBodyPanel, this, UserStatusType.FREE_FOR_CHAT ), false );
	//Add the site forum section
	registerNewSiteSection( new ForumNavigatorElement( false, siteBodyPanel, this, UserStatusType.ANOTHER_SITE_SECTION ), false );
	//Add the site top10 section
	registerNewSiteSection( new Top10NavigatorElement( false, siteBodyPanel, this, UserStatusType.ANOTHER_SITE_SECTION ), false );
	//Add the site introduction section
	registerNewSiteSection( new IntroNavigatorElement( false, siteBodyPanel, this, UserStatusType.ANOTHER_SITE_SECTION ), false );
	//Add the site news section. The main section is the default site section.
	registerNewSiteSection( new NewNavigatorElement( false, siteBodyPanel, this, UserStatusType.ANOTHER_SITE_SECTION ), true );
	
	//Initialize the composite widget
	flowPanel.setWidth("100%");
	wrapperPanel.add( flowPanel );
	initWidget( wrapperPanel );
	
	//Add the history change handler
	History.addValueChangeHandler( this );
}
 
Example 13
Project: x-cure-chat   File: RoomsManagerUI.java   View source code 6 votes vote down vote up
@Override
public void onAfterComponentIsAdded() {
	//1. Scroll down all of the chat message panels, i.e. for all of the open chat rooms
	//2. Update the chat room UI elements to prevent size breaking after viewing the
	//   forum or other site sections
	for( ChatRoomUI roomUI : openRoomIdToChatRoomUI.values() ) {
		roomUI.scrollMessagesPanelDown();
		roomUI.updateUIElements();
	}
	//Update the current history item with the selected section item
	History.newItem( siteSectionPrefix, false );
	
	//Update the UI elements of the send-chat-message UI
	SendChatMessageManager.getInstance().updateUIElements();
	
	//Needed for Opera, because it resets the UI font settings
	SendChatMessageManager.getInstance().restoreChatMessageFonts();
}
 
Example 14
Project: ontobrowser   File: HyperlinkCell.java   View source code 6 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public void onBrowserEvent(Context context,
		Element parent, InlineHyperlink value, NativeEvent nativeEvent,
		ValueUpdater<InlineHyperlink> valueUpdater) {
	super.onBrowserEvent(context, parent, value, nativeEvent, valueUpdater);
	Event event = Event.as(nativeEvent);
	if(DOM.eventGetType(event) == Event.ONCLICK && impl.handleAsClick(event)) {
		Element target = Element.as(event.getEventTarget());
		Element child = parent.getFirstChildElement();
		if(child.isOrHasChild(target)) {
			History.newItem(value.getTargetHistoryToken());
			DOM.eventPreventDefault(event);
		}
	}
}
 
Example 15
Project: ontobrowser   File: CodeListView.java   View source code 6 votes vote down vote up
public CodeListView(EventBus eventBus, OntoBrowserServiceAsync service) {
	super(eventBus,service);
	
	Image emptyListWidget = new Image(ImageResources.INSTANCE.spinner());
	emptyListWidget.setStyleName("float-right");
	list.setEmptyListWidget(emptyListWidget);
	list.setKeyboardPagingPolicy(KeyboardPagingPolicy.CURRENT_PAGE);
	list.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
	list.setSelectionModel(selection);
	selection.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
		public void onSelectionChange(SelectionChangeEvent event) {
			Term selected = selection.getSelectedObject();
			if(selected != null) {
				History.newItem(selected.getReferenceId());
			}
		}
	});
			
	codelistContainer.add(list);
	
	initWidget(codelistContainer);
	addStyleName("padded-border vert-scroll");
	eventBus.addHandler(ViewTermEvent.TYPE, this);
}
 
Example 16
Project: ontobrowser   File: SVGView.java   View source code 6 votes vote down vote up
@Override
public void onClick(ClickEvent event) {
	NativeEvent nativeEvent = event.getNativeEvent();
	Element element = Element.as(nativeEvent.getEventTarget());
	String href = null;
	for(Element parent = element; 
			!svgContainer.getElement().equals(parent); 
			parent = parent.getParentElement()) {
		if("a".equalsIgnoreCase(parent.getNodeName())) {
			href = parent.getAttribute("xlink:href");
			break;
		}
	}
	if(href != null && impl.handleAsClick(Event.as(nativeEvent))) {
		int i = href.lastIndexOf('#');
		if(i >= 0) {
			History.newItem(href.substring(i + 1));
			DOM.eventPreventDefault(Event.as(nativeEvent));
		}
	}
}
 
Example 17
Project: dataworks-zeus   File: WordPresenterImpl.java   View source code 6 votes vote down vote up
@Override
public void go(HasWidgets hasWidgets) {
	hasWidgets.add(getWordView().asWidget());
	context.getPlatformBus().addHandler(OpenFileEvent.TYPE, new OpenFileEvent.OpenFileHandler(){
		@Override
		public void onOpenFile(OpenFileEvent event) {
			FileModel model=event.getModel();
			if(!model.isFolder()){
				open(model.getId(), null);
				if(model.getOwner().equals(context.getUser().getUid())){
					History.newItem(new PlacePath().toApp(App.Document)
							.toDocType(DocType.MyDoc)
							.toDocId(model.getId()).create().getToken(), false);
				}else{
					History.newItem(new PlacePath().toApp(App.Document)
							.toDocType(DocType.SharedDoc)
							.toDocId(model.getId())
							.create().getToken(), false);
				}
			}
		}
	});
	
}
 
Example 18
Project: gwt-chronoscope   File: GwtView.java   View source code 6 votes vote down vote up
public GwtView() {
  if (GWT.isClient()) {
    DateFormatterFactory.setDateFormatterFactory(new DateFormatterFactory() {
          private DateFormatter blankFormatter = new GWTDateFormatter("");
          private DateFormatter previousFormatter;
          private String previous = ""; // look back at last one

          public DateFormatter getDateFormatter(String format) {
            if (null == format || "".equals(format) || "undefined".equals(format) || "null".equals(format)) {
              return blankFormatter;
            }
            if (!previous.equals(format)) {
              previous = format;
              previousFormatter = new GWTDateFormatter(format);
            }
            return previousFormatter;
          }
        });
    HistoryManager.setHistoryManagerImpl(new HistoryManager.HistoryManagerImpl() {
      public void push(String historyToken) {
        History.newItem(historyToken);
      }
    });
  }
}
 
Example 19
Project: gwt-backbone   File: AbstractPushStateTest.java   View source code 6 votes vote down vote up
@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();

    // no need for push state emulation on ie8 & ie9 (since they really don't support push state)
    if (!GQuery.browser.ie8 && !GQuery.browser.ie9) {

        if (states == null) {
            ExporterUtil.exportAll();
            states = new Stack<State>();
            GWT.create(History.class);
        }

        statesOnTestStart = states.size();
    }
}
 
Example 20
Project: onecmdb   File: NewTransformScreen.java   View source code 6 votes vote down vote up
public void save() {
	control.commit(new AsyncCallback() {

		public void onFailure(Throwable caught) {
			setErrorText("Failure:" + caught);
			
		}

		public void onSuccess(Object result) {
			if (result instanceof GWT_RfcResult) {
				GWT_RfcResult rfcResult = (GWT_RfcResult)result;
				if (rfcResult.isRejected()) {
					setErrorText("Rejected cause: " + rfcResult.getRejectCause());
				} else {
					History.back();
				}
			}
			
		}
		
	});
	
}
 
Example 21
Project: ontosoft   File: SoftwareListView.java   View source code 6 votes vote down vote up
private void submitPublishForm() {
  String label = softwarelabel.getValue();
  if(softwarelabel.validate(true)) {
    Software tmpsw = new Software();
    tmpsw.setLabel(label);
    this.api.publishSoftware(tmpsw, new Callback<Software, Throwable>() {
      public void onSuccess(Software sw) {
        // Add item to list
        SoftwareSummary newsw = new SoftwareSummary(sw);
        newsw.setExternalRepositoryId(SoftwareREST.LOCAL);
        addToList(newsw);
        updateList();
        
        // Go to the new item
        History.newItem(NameTokens.publish + "/" + sw.getName());
        
        publishdialog.hide();
        softwarelabel.setValue(null);
      }
      @Override
      public void onFailure(Throwable exception) { }
    });
  } 
}
 
Example 22
Project: ontosoft   File: SoftwareListView.java   View source code 6 votes vote down vote up
@UiHandler("comparebutton")
void onCompareButtonClick(ClickEvent event) {
  String idtext = "";
  if(selections.size() < 2)
    Window.alert("Select atleast 2 software to compare.\n\n"
        + "Click on the checkbox next to the compare button.\n"
        + "Then select software using checkboxes in each row");
  else if(selections.size() > 10)
    Window.alert("Cannot compare more than 10 at a time");    
  else {
    int i=0;
    for(SoftwareSummary summary : selections) {
      if(i > 0) idtext += ",";
      if(!summary.getExternalRepositoryId().equals(SoftwareREST.LOCAL))
        idtext += summary.getExternalRepositoryId()+":";
      idtext += summary.getName();
      i++;
    }
    History.newItem(NameTokens.compare + "/" + idtext);
  }
}
 
Example 23
Project: ontosoft   File: UserView.java   View source code 6 votes vote down vote up
@UiHandler("deletebutton")
public void onDelete(ClickEvent event) {
  final String name = this.username;
  if (Window.confirm("Are you sure you want to delete user " + name + "?")) {
    UserREST.deleteUser(name, new Callback<Void, Throwable>() {
      @Override
      public void onFailure(Throwable reason) {
        AppNotification.notifyFailure("Could not delete: "+reason.getMessage());
      }
      @Override
      public void onSuccess(Void result) {
        AppNotification.notifySuccess(name + " deleted", 1000);
        History.replaceItem(History.getToken());
      }
    });
  }
}
 
Example 24
Project: gerrit   File: CreateGroupScreen.java   View source code 6 votes vote down vote up
private void doCreateGroup() {
  final String newName = addTxt.getText();
  if (newName == null || newName.length() == 0) {
    return;
  }

  addNew.setEnabled(false);
  GroupApi.createGroup(
      newName,
      new GerritCallback<GroupInfo>() {
        @Override
        public void onSuccess(GroupInfo result) {
          History.newItem(Dispatcher.toGroup(result.getGroupId(), AccountGroupScreen.MEMBERS));
        }

        @Override
        public void onFailure(Throwable caught) {
          super.onFailure(caught);
          addNew.setEnabled(true);
        }
      });
}
 
Example 25
Project: unitime   File: TeachingRequestsPage.java   View source code 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 26
Project: unitime   File: TeachingAssignmentsPage.java   View source code 6 votes vote down vote up
void search() {
	History.newItem(iFilterBox.getValue(), false);
	InstructorCookie.getInstance().setQuery(null, iFilterBox.getValue());
	LoadingWidget.getInstance().show(MESSAGES.waitLoadingTeachingAssignments());
	final TeachingRequestsFilterRpcRequest filter = iFilterBox.getElementsRequest();
	RPC.execute(new TeachingAssignmentsPageRequest(filter), new AsyncCallback<GwtRpcResponseList<InstructorInfo>>() {
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			iFilterBox.setErrorHint(MESSAGES.failedToLoadTeachingAssignments(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingAssignments(caught.getMessage()), caught);
		}

		@Override
		public void onSuccess(GwtRpcResponseList<InstructorInfo> result) {
			LoadingWidget.getInstance().hide();
			iTable.populate(result);
			iTable.setVisible(true);
		}
	});
}
 
Example 27
Project: unitime   File: CurriculaPage.java   View source code 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 28
Project: unitime   File: PointInTimeDataReportsPage.java   View source code 6 votes vote down vote up
public void setBack() {
	if (iFirstField == null || !iFirstField.startsWith("__") || iTable.getRowCount() <= 1) return;
	PITDSetBackRpcRequest request = new PITDSetBackRpcRequest();
	for (int i = 1; i < iTable.getRowCount(); i++) {
		String[] row = iTable.getData(i);
		if (row != null) {
			Long id = Long.valueOf(row[0]);
			request.addId(id);
		}
	}
	request.setHistory(History.getToken());
	request.setType(iFirstField);
	RPC.execute(request, new AsyncCallback<GwtRpcResponseNull>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
		}

		@Override
		public void onSuccess(GwtRpcResponseNull result) {
		}
	});
}
 
Example 29
Project: unitime   File: SavedHQLPage.java   View source code 6 votes vote down vote up
public void setBack() {
	if (iFirstField == null || !iFirstField.startsWith("__") || iTable.getRowCount() <= 1) return;
	HQLSetBackRpcRequest request = new HQLSetBackRpcRequest();
	for (int i = 1; i < iTable.getRowCount(); i++) {
		String[] row = iTable.getData(i);
		if (row != null) {
			Long id = Long.valueOf(row[0]);
			request.addId(id);
		}
	}
	request.setAppearance(iAppearance);
	request.setHistory(History.getToken());
	request.setType(iFirstField);
	RPC.execute(request, new AsyncCallback<GwtRpcResponseNull>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
		}

		@Override
		public void onSuccess(GwtRpcResponseNull result) {
		}
	});
}
 
Example 30
Project: wbi   File: HistoryManager.java   View source code 6 votes vote down vote up
/**
 * Handle browser history state changes.
 */
@Override
public void onValueChange(ValueChangeEvent<String> event) {
    HistoryState state = HistoryState.fromHistoryToken(event.getValue());

    if (state != null && !state.isEmpty()) {
        // Update the current {@code HistoryState}
        currentState.replace(state);

        // Re-generate the current history token
        History.replaceItem(currentState.getHistoryToken(), false);

        // Call listeners
        for (Listener listener : listeners) {
            listener.onChange(currentState);
        }
    }
}
 
Example 31
Project: fullmetalgalaxy   File: MAppGameCreation.java   View source code 6 votes vote down vote up
@Override
public void onClick(ClickEvent p_event)
{
  if( p_event.getSource() == m_btnCreateGame )
  {
    AppMain.instance().startLoading();
    if( GameEngine.model().getGame().isTrancient() )
    {
      createGame();
    }
    else
    {
      saveGame();
    }
  }
  else if( p_event.getSource() == m_btnCancel )
  {
    GameEngine.model().getGame().reinit();
    History.back();
  }
}
 
Example 32
Project: caja   File: Playground.java   View source code 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 33
Project: caja   File: Playground.java   View source code 6 votes vote down vote up
public void onModuleLoad() {
  gui = new PlaygroundView(this);
  gui.setLoading(true);
  cajolingService.getBuildInfo(new AsyncCallback<String>() {
    public void onFailure(Throwable caught) {
      gui.setLoading(false);
      gui.addRuntimeMessage(caught.getMessage());
      gui.setVersion("Unknown");
    }

    public void onSuccess(String result) {
      gui.setLoading(false);
      gui.setVersion(result);
    }
  });
  History.addValueChangeHandler(this);
  History.fireCurrentHistoryState();
}
 
Example 34
Project: EasyML   File: AppController.java   View source code 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 35
Project: unitimes   File: MobileUniTimeFrameDialogImpl.java   View source code 5 votes vote down vote up
@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 36
Project: unitimes   File: EventResourceTimetable.java   View source code 5 votes vote down vote up
public HistoryToken(PageType type) {
	iType = type.name();
	
	// 1. take page type defaults --> DEFAULTS
	if (type.getParams() != null)
		for (int i = 0; 1 + i < type.getParams().length; i += 2)
			iDefaults.put(type.getParams()[i], type.getParams()[i + 1]);

	// 2. take page parameters --> DEFAULTS (on top of the page type defaults)
	for (Map.Entry<String, List<String>> params: Window.Location.getParameterMap().entrySet())
		iDefaults.put(params.getKey(), params.getValue().get(0));
	
	// 3. take cookie --> PARAMS (override defaults)
	String cookie = EventCookie.getInstance().getHash(iType);
	if (cookie != null) {
		for (String pair: cookie.split("\\&")) {
			int idx = pair.indexOf('=');
			if (idx >= 0) {
				String key = pair.substring(0, idx);
				if (Location.getParameter(key) == null)
					iParams.put(key, URL.decodeQueryString(pair.substring(idx + 1)));
			}
		}
	}			
	
	// 4. take page token (hash) --> PARAMS (override cookie)
	parse(History.getToken());
}
 
Example 37
Project: unitimes   File: PointInTimeDataReportsPage.java   View source code 5 votes vote down vote up
public void loadQueries(final Long select, final boolean reload) {
	if (!LoadingWidget.getInstance().isShowing())
		LoadingWidget.getInstance().show(MESSAGES.waitLoadingReports());
	RPC.execute(new PITDQueriesRpcRequest(), new AsyncCallback<GwtRpcResponseList<Report>>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
			LoadingWidget.getInstance().hide();
		}
		@Override
		public void onSuccess(GwtRpcResponseList<Report> result) {
			String selected = (select == null ? null : select.toString());
			if (selected == null && iReportSelector.getWidget().getSelectedIndex() >= 0) {
				selected = iReportSelector.getWidget().getValue(iReportSelector.getWidget().getSelectedIndex());
			}
			iReportSelector.getWidget().clear();
			if (result.isEmpty()) {
				iHeader.setErrorMessage(MESSAGES.errorNoReportsAvailable());
			} else {
				iReportSelector.getWidget().addItem(MESSAGES.itemSelect(), "-1");
				iReports = result;
				for (int i = 0; i < result.size(); i++) {
					iReportSelector.getWidget().addItem(result.get(i).getName(), result.get(i).getId().toString());
					if (selected != null && selected.equals(result.get(i).getId().toString()))
						iReportSelector.getWidget().setSelectedIndex(1 + i);
				}
				queryChanged();
			}
			LoadingWidget.getInstance().hide();
			if (reload) reload(History.getToken());
		}
	});
}
 
Example 38
Project: unitimes   File: SectioningReports.java   View source code 5 votes vote down vote up
@Override
public void execute() {
	boolean asc = (h.getOrder() == null ? true : !h.getOrder());
	iLastSort = (asc ? 1 + col : -1 - col);
	populate(true);
	History.newItem(iLastHistory + ":" + iFirstLine + ":" + iLastSort, false);
}
 
Example 39
Project: unitimes   File: UniTimeBack.java   View source code 5 votes vote down vote up
public UniTimeBack() {
	History.addValueChangeHandler(new ValueChangeHandler<String>() {
		@Override
		public void onValueChange(ValueChangeEvent<String> event) {
			if (event.getValue() == null || event.getValue().isEmpty() || "back".equals(event.getValue())) {
				open(GWT.getHostPageBaseURL() + "back.do?uri=" + iBackUrl);
			} else {
				String uri = token2uri(event.getValue().replace("%20", " "));
				if (uri != null)
					open(GWT.getHostPageBaseURL() + "back.do?uri=" + uri);
			}
		}
	});
}
 
Example 40
Project: unitimes   File: SavedHQLPage.java   View source code 5 votes vote down vote up
public void loadQueries(final Long select, final boolean reload) {
	if (!LoadingWidget.getInstance().isShowing())
		LoadingWidget.getInstance().show(MESSAGES.waitLoadingReports());
	RPC.execute(new HQLQueriesRpcRequest(iAppearance), new AsyncCallback<GwtRpcResponseList<Query>>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
			LoadingWidget.getInstance().hide();
		}
		@Override
		public void onSuccess(GwtRpcResponseList<Query> result) {
			String selected = (select == null ? null : select.toString());
			if (selected == null && iQuerySelector.getWidget().getSelectedIndex() >= 0) {
				selected = iQuerySelector.getWidget().getValue(iQuerySelector.getWidget().getSelectedIndex());
			}
			iQuerySelector.getWidget().clear();
			if (result.isEmpty()) {
				iHeader.setErrorMessage(MESSAGES.errorNoReportsAvailable());
			} else {
				iQuerySelector.getWidget().addItem(MESSAGES.itemSelect(), "-1");
				iQueries = result;
				for (int i = 0; i < result.size(); i++) {
					iQuerySelector.getWidget().addItem(result.get(i).getName(), result.get(i).getId().toString());
					if (selected != null && selected.equals(result.get(i).getId().toString()))
						iQuerySelector.getWidget().setSelectedIndex(1 + i);
				}
				queryChanged();
			}
			LoadingWidget.getInstance().hide();
			if (reload) reload(History.getToken());
		}
	});
}