Java Code Examples for com.google.gwt.user.client.Cookies#setCookie()

The following examples show how to use com.google.gwt.user.client.Cookies#setCookie() . 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 File: ThemeManager.java    From gwt-material-demo with Apache License 2.0 6 votes vote down vote up
public static void setColor(Color color, Color darkerColor, Color lighterColor) {
    final long DURATION = 1000 * 60 * 60 * 24 * 14; //duration remembering login - 2 weeks
    Date expires = new Date(System.currentTimeMillis() + DURATION);
    Cookies.setCookie(COLOR, color.getCssName(), expires, null, "/", false);

    for (MaterialWidget w : map.keySet()) {
        switch (map.get(w)) {
            case REGULAR_SHADE:
                w.setBackgroundColor(color);
                break;
            case DARKER_SHADE:
                w.setBackgroundColor(darkerColor);
                break;
            case LIGHTER_SHADE:
                w.setBackgroundColor(lighterColor);
                break;
            default:
                break;
        }
    }
}
 
Example 2
Source File: Html5ApplicationCache.java    From gwt-appcache with Apache License 2.0 6 votes vote down vote up
@Override
public boolean removeCache()
{
  Cookies.setCookie( DISABLE_MANIFEST_COOKIE_NAME, DISABLE_MANIFEST_COOKIE_VALUE );

  // Register handlers for every terminal event so we can ensure that we remove the cookie.
  // All of these may be required due to; network failure, intermediate cache not passing
  // back to server, overlapping requests etc.
  final ArrayList<HandlerRegistration> registrations = new ArrayList<>();
  registrations.add( addErrorHandler( e -> cacheRemovalCleanup( registrations ) ) );
  registrations.add( addObsoleteHandler( e -> cacheRemovalCleanup( registrations ) ) );
  registrations.add( addNoUpdateHandler( e -> cacheRemovalCleanup( registrations ) ) );
  registrations.add( addUpdateReadyHandler( e -> cacheRemovalCleanup( registrations ) ) );
  registrations.add( addCachedHandler( e -> cacheRemovalCleanup( registrations ) ) );
  try
  {
    update0();
    return true;
  }
  catch ( final Throwable t )
  {
    cacheRemovalCleanup( registrations );
    return false;
  }
}
 
Example 3
Source File: UniTimeMobileMenu.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void saveState() {
	List<String> nodes = new ArrayList<String>();
	nodes.add(iStackPanel.getStackText(iStackPanel.getSelectedIndex()));
	for (int i = 0; i < iStackPanel.getWidgetCount(); i++) {
		if (iStackPanel.getWidget(i) instanceof Tree) {
			Tree t = (Tree)iStackPanel.getWidget(i);
			for (int j = 0; j < t.getItemCount(); j++) {
				openedNodes(nodes, t.getItem(j), iStackPanel.getStackText(i));
			}
		}
	}
	String sideBarCookie = "";
	for (String node: nodes) {
		if (!sideBarCookie.isEmpty()) sideBarCookie += "|";
		sideBarCookie += node;
	}
	Cookies.setCookie("UniTime:MobileMenu", sideBarCookie);
}
 
Example 4
Source File: SolverCookie.java    From unitime with Apache License 2.0 6 votes vote down vote up
private void save() {
	String cookie = iLogLevel + "|" + (iTimeGridFilter ? "1" : "0")
			+ "|" + (iAssignedClassesFilter ? "1" : "0") + "|" + iAssignedClassesSort
			+ "|" + (iNotAssignedClassesFilter ? "1" : "0") + "|" + iNotAssignedClassesSort
			+ "|" + iSelectedAssignmentsSort + "|" + iConflictingAssignmentsSort
			+ "|" + iSuggestionsSort + "|" + iPlacementsSort
			+ "|" + (iShowSuggestions ? "1" : "0")
			+ "|" + (iShowConflicts ? "1" : "0") + "|" + iConflictsSort
			+ "|" + (iShowAllStudentConflicts ? "1" : "0") + "|" + (iShowAllDistributionConflicts ? "1" : "0")
			+ "|" + (iShowCBS ? "1" : "0") + "|" + (iShowCBSFilter ? "1" : "0")
			+ "|" + (iSolutionChangesFilter ? "1" : "0") + "|" + iSolutionChangesSort
			+ "|" + (iAssignmentHistoryFilter ? "1" : "0") + "|" + iAssignmentHistorySort
			+ "|" + iListSolutionsSort
			+ "|" + (iSuggestionsFilter == null ? "" : iSuggestionsFilter);
	Date expires = new Date(new Date().getTime() + 604800000l); // expires in 7 days
	Cookies.setCookie("UniTime:Solver", cookie, expires);
}
 
Example 5
Source File: CurriculumCookie.java    From unitime with Apache License 2.0 6 votes vote down vote up
private void save() {
	String cookie = 
		(iType == null ? "" : iType.name()) + ":" +
		(iMode == null ? "" : iMode.name()) + ":" +
		(iPercent ? "T": "F") + ":" +
		(iRulesPercent ? "T" : "F") + ":" +
		(iRulesShowLastLike ? "T" : "F") + ":" +
		(iCourseDetails ? "T": "F") + ":" +
		iCurMode.toString() + ":" +
		(iShowLast ? "T" : "F") + ":" +
		(iShowProjected ? "T" : "F") + ":" +
		(iShowExpected ? "T" : "F") + ":" +
		(iShowEnrolled ? "T" : "F") + ":" +
		(iShowRequested ? "T" : "F") + ":" + 
		(iShowSnapshotExpected ? "T" : "F") + ":" +
		(iShowSnapshotProjected ? "T" : "F") + ":" +
		iSortBy;
		;
	Cookies.setCookie("UniTime:Curriculum", cookie);
}
 
Example 6
Source File: RoomCookie.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void save() {
	String cookie = iSortRoomsBy + "|" + iSortRoomGroupsBy + "|" + iSortRoomFeaturesBy + "|" + getOrientation() + "|" + iDeptMode;
	for (int i = 0; i < iFlags.length; i++) {
		cookie += "|" + iFlags[i] + "|" + (iHash[i] == null ? "" : iHash[i]);
	}
	for (Map.Entry<Long, Integer> e: iFutures.entrySet()) {
		cookie += "|" + e.getKey() + ":" + e.getValue();
	}
	Date expires = new Date(new Date().getTime() + 604800000l); // expires in 7 days
	Cookies.setCookie("UniTime:Room", cookie, expires);
}
 
Example 7
Source File: InstructorCookie.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void save() {
	String cookie = iSortAttributesBy + "|" + iSortInstructorsBy +
			"|" + iSortTeachingRequestsBy[0] + "|" + iSortTeachingRequestsBy[1] + "|" + iSortTeachingRequestsBy[2] +
			"|" + iTeachingRequestsColumns[0] + "|" + iTeachingRequestsColumns[1] + "|" + iTeachingRequestsColumns[2] +
			"|" + iSortTeachingAssignmentsBy + "|" + iTeachingAssignmentsColumns +
			"|" + iAssignmentChangesBase + "|" + iSortAssignmentChangesBy + "|" + iAssignmentChangesColumns +
			"|" + (iShowTeachingRequests ? "T" : "F") +
			"|" + (iShowTeachingAssignments ? "T" : "F") +
			"|" + (iQuery[0] == null ? "" : iQuery[0]) + "|" + (iQuery[1] == null ? "" : iQuery[1]) + "|" + (iQuery[2] == null ? "" : iQuery[2]);
	Date expires = new Date(new Date().getTime() + 604800000l); // expires in 7 days
	Cookies.setCookie("UniTime:Instructor", cookie, expires);
}
 
Example 8
Source File: FilterBox.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void save() {
	String cookie = "";
	for (String cmd: iCommands)
		cookie += (cookie.isEmpty() ? "" : "|") + cmd;
	Date expires = new Date(new Date().getTime() + 604800000l); // expires in 7 days
	Cookies.setCookie("UniTime:FilterCarrots", cookie, expires);
}
 
Example 9
Source File: EventCookie.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void save() {
	String cookie = String.valueOf(iFlags) + 
			"|" + (iShowDeltedMeetings ? "T": "F") +
			"|" + iSortRoomsBy +
			"|" + (iRoomsHorizontal ? "T" : "F") +
			"|" + (iExpandRoomConflicts ? "T" : "F") +
			"|" + (iAutomaticallyApproveNewMeetings ? "T": "F") +
			"|" + (iHideDuplicitiesForMeetings ? "T" : "F");
	for (Map.Entry<String, String> entry: iHash.entrySet())
		cookie += "|" + entry.getKey() + ":" + entry.getValue();
	Date expires = new Date(new Date().getTime() + 604800000l); // expires in 7 days
	Cookies.setCookie("UniTime:Event", cookie, expires);
}
 
Example 10
Source File: SectioningCookie.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void save() {
	String cookie = 
		(iCourseDetails ? "T": "F") + ":" +
		(iShowClassNumbers ? "T": "F") + ":" + iRelatedSortBy + ":" + iEnrollmentFilter.ordinal() + ":" + iEnrollmentSortBy + ":" + iEnrollmentSortBySubpart +
		":" + (iAllChoices ? "T" : "F") + 
		":" + (iShowAllChanges ? "T" : "F") + ":" + (iRequestOverridesOpened ? "T" : "F") + ":" + iSolutionsSortBy + ":" + iEnrollmentSortByGroup;
	Cookies.setCookie("UniTime:Sectioning", cookie);
}
 
Example 11
Source File: GwtCookieModel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void setCookie(
    String name, String value, Date expires, String domain, String path, boolean secure) {
  if (value == null) {
    removeCookie(name);
  } else {
    Cookies.setCookie(name, value, expires, domain, path, secure);
    if (cookies.put(name, value) == null) {
      listeners.cookieAdded(name, value);
    } else {
      listeners.cookieChanged(name, value);
    }
  }
}
 
Example 12
Source File: UniTimeSideBar.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void saveState() {
	List<String> nodes = new ArrayList<String>();
	if (iUseStackPanel) {
		nodes.add(iStackPanel.getStackText(iStackPanel.getSelectedIndex()));
		for (int i = 0; i < iStackPanel.getWidgetCount(); i++) {
			if (iStackPanel.getWidget(i) instanceof Tree) {
				Tree t = (Tree)iStackPanel.getWidget(i);
				for (int j = 0; j < t.getItemCount(); j++) {
					openedNodes(nodes, t.getItem(j), iStackPanel.getStackText(i));
				}
			}
		}
	} else {
		for (int i = 0; i < iTree.getItemCount(); i++) {
			openedNodes(nodes, iTree.getItem(i), null);
		}
	}
	String sideBarCookie = "";
	if (iDisclosurePanel.isOpen()) sideBarCookie += "Root";
	for (String node: nodes) {
		if (!sideBarCookie.isEmpty()) sideBarCookie += "|";
		sideBarCookie += node;
	}
	sideBarCookie += "|W:" + iPanel.getElement().getClientWidth();
	Cookies.setCookie("UniTime:SideBar", sideBarCookie);
	resizeWideTables();
}
 
Example 13
Source File: DomLogger.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a cookie value with an expiry date a year from now.
 * @param key The name of the cookie to set.
 * @param value The new value for the cookie.
 */
@SuppressWarnings("deprecation") // Calendar not supported by GWT
public static void setCookieValue(String key, String value) {
  // Only set the cookie value if it is changing:
  if (value.equals(Cookies.getCookie(key))) {
    return;
  }

  // Set the cookie to expire in one year
  Date d = new Date();
  d.setYear(d.getYear() + 1);
  Cookies.setCookie(key, value, d);
}
 
Example 14
Source File: DomLogger.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a cookie value with an expiry date a year from now.
 * @param key The name of the cookie to set.
 * @param value The new value for the cookie.
 */
@SuppressWarnings("deprecation") // Calendar not supported by GWT
public static void setCookieValue(String key, String value) {
  // Only set the cookie value if it is changing:
  if (value.equals(Cookies.getCookie(key))) {
    return;
  }

  // Set the cookie to expire in one year
  Date d = new Date();
  d.setYear(d.getYear() + 1);
  Cookies.setCookie(key, value, d);
}
 
Example 15
Source File: AdminCookie.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void save() {
	String cookie = iSortTasksBy + "|" + iSortTaskExecutionsBy;
	Date expires = new Date(new Date().getTime() + 604800000l); // expires in 7 days
	Cookies.setCookie("UniTime:Admin", cookie, expires);
}
 
Example 16
Source File: RoomNoteChanges.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void save() {
	String cookie = (iShowDetails ? "T": "F") + ":" + iSortColumn + ":" + (iSortOrder ? "T": "F") + ":" + (iMultiSession ? "T" : "F");
	Cookies.setCookie("UniTime:LastChanges", cookie);
}
 
Example 17
Source File: ServerDateTimeFormat.java    From unitime with Apache License 2.0 4 votes vote down vote up
@Override
public void onSuccess(ServerTimeZoneResponse result) {
	sServerTimeZone = TimeZone.createTimeZone(result.toJsonString());
	Cookies.setCookie("UniTime:ServerTimeZone", result.toJsonString());
}
 
Example 18
Source File: Preferences.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void set(Key key, String value)
{
    Date twoWeeks = new Date(System.currentTimeMillis()+(2*604800*1000));
    Cookies.setCookie(AS7_UI +key.getToken(), value, twoWeeks);
}
 
Example 19
Source File: ReservationCookie.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void save() {
	String cookie =  (iCourseDetails ? "T": "F") + ":" + iSortBy;
	Cookies.setCookie("UniTime:Reservations", cookie);
}
 
Example 20
Source File: CookiesManager.java    From document-management-software with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Stores the release information in the browser
 * 
 * @param info the User Interface informations
 */
public static void saveRelease(GUIInfo info) {
	Cookies.setCookie(COOKIE_VERSION, info.getRelease(), null, null, null, true);
}