private DisplayMode getCurrentMode() {
   String actionText = changeModeAction.getAction().getText();
   for (DisplayMode aMode : DisplayMode.values()) {
     if (aMode.getText().equals(actionText)) return aMode;
   }
   return null;
 }
Example #2
0
 /**
  * Returns whether the two display modes are equal.
  *
  * @return whether the two display modes are equal
  */
 public boolean equals(DisplayMode dm) {
   if (dm == null) {
     return false;
   }
   return (getHeight() == dm.getHeight()
       && getWidth() == dm.getWidth()
       && getBitDepth() == dm.getBitDepth()
       && getRefreshRate() == dm.getRefreshRate());
 }
Example #3
0
  /** Render the events for every cells. */
  public void drawEvents() {
    final int rows = displayMode.getRows() + displayHeaders;
    final int columns = displayMode.getColumns() + (displayWeekNumber ? 1 : 0);

    Date date = displayMode.getStartDate(startDate, firstDayOfWeek);

    for (int y = displayHeaders; y < rows; y++) {
      for (int x = displayWeekNumber ? 1 : 0; x < columns; x++) {
        drawEvents(y, x, date);
        date.setDate(date.getDate() + 1);
      }
    }
  }
Example #4
0
 MacOSXFrame(
     DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y)
     throws LWJGLException {
   setResizable(false);
   addWindowListener(this);
   addComponentListener(this);
   canvas = new MacOSXGLCanvas();
   canvas.setFocusTraversalKeysEnabled(false);
   add(canvas, BorderLayout.CENTER);
   boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
   setUndecorated(fullscreen || undecorated);
   if (fullscreen) {
     try {
       AccessController.doPrivileged(
           new PrivilegedExceptionAction() {
             public Object run() throws Exception {
               getDevice().setFullScreenWindow(MacOSXFrame.this);
               getDevice().setDisplayMode(requested_mode);
               java.awt.DisplayMode real_mode = getDevice().getDisplayMode();
               /**
                * For some strange reason, the display mode is sometimes silently capped even
                * though the mode is reported as supported
                */
               if (requested_mode.getWidth() != real_mode.getWidth()
                   || requested_mode.getHeight() != real_mode.getHeight()) {
                 getDevice().setFullScreenWindow(null);
                 if (isDisplayable()) dispose();
                 throw new LWJGLException(
                     "AWT capped mode: requested mode = "
                         + requested_mode.getWidth()
                         + "x"
                         + requested_mode.getHeight()
                         + " but got "
                         + real_mode.getWidth()
                         + " "
                         + real_mode.getHeight());
               }
               return null;
             }
           });
     } catch (PrivilegedActionException e) {
       throw new LWJGLException(e);
     }
   }
   pack();
   resize(x, y, mode.getWidth(), mode.getHeight());
   setVisible(true);
   requestFocus();
   canvas.requestFocus();
   updateBounds();
 }
Example #5
0
  /**
   * Enumeration providing semantically-meaningful names for the various display modes supported by
   * both scoreboard activities and the Game's own HTML rendering functions.
   */
  public enum DisplayMode {
    BOXSCORES(0),
    TOTALS(1);

    public static int size() {
      return 2;
    }

    private int m_zValue;

    DisplayMode(int z) {
      m_zValue = z;
    }

    public int value() {
      return m_zValue;
    }

    // This is cached for efficiency.
    public static final DisplayMode[] VALUES = DisplayMode.values();

    public String toString() {
      return Integer.toString(m_zValue);
    }
  }
  private int getActivitiesUpdatedNum(boolean hasRefresh) {
    if (this.postActivity) {
      resetCookies();
      this.postActivity = false;

      return 0;
    }

    //
    UIActivitiesLoader activitiesLoader = getChild(UIActivitiesLoader.class);
    ActivitiesRealtimeListAccess activitiesListAccess =
        (ActivitiesRealtimeListAccess) activitiesLoader.getActivityListAccess();

    String mode = DisplayMode.ALL_ACTIVITIES.toString();
    ActivityFilterType.ACTIVITY_FEED
        .oldFromSinceTime(Utils.getLastVisited(Utils.OLD_FROM, mode))
        .fromSinceTime(Utils.getLastVisited(Utils.FROM, mode))
        .toSinceTime(Utils.getLastVisited(Utils.TO, mode))
        .lastNumberOfUpdated(getLastUpdatedNum(mode));

    //
    mode = DisplayMode.CONNECTIONS.toString();
    ActivityFilterType.CONNECTIONS_ACTIVITIES
        .oldFromSinceTime(Utils.getLastVisited(Utils.OLD_FROM, mode))
        .fromSinceTime(Utils.getLastVisited(Utils.FROM, mode))
        .toSinceTime(Utils.getLastVisited(Utils.TO, mode))
        .lastNumberOfUpdated(getLastUpdatedNum(mode));

    //
    mode = DisplayMode.MY_ACTIVITIES.toString();
    ActivityFilterType.USER_ACTIVITIES
        .oldFromSinceTime(Utils.getLastVisited(Utils.OLD_FROM, mode))
        .fromSinceTime(Utils.getLastVisited(Utils.FROM, mode))
        .toSinceTime(Utils.getLastVisited(Utils.TO, mode))
        .lastNumberOfUpdated(getLastUpdatedNum(mode));

    //
    mode = DisplayMode.MY_SPACE.toString();
    ActivityFilterType.USER_SPACE_ACTIVITIES
        .oldFromSinceTime(Utils.getLastVisited(Utils.OLD_FROM, mode))
        .fromSinceTime(Utils.getLastVisited(Utils.FROM, mode))
        .toSinceTime(Utils.getLastVisited(Utils.TO, mode))
        .lastNumberOfUpdated(getLastUpdatedNum(mode));

    ActivityUpdateFilter updatedFilter = new ActivityUpdateFilter(hasRefresh);

    int gotNumber = activitiesListAccess.getNumberOfUpdated(updatedFilter);

    //
    if (gotNumber == 0 && hasRefresh) {
      // only in case lastUpdatedNumber > 0 then reset cookies
      long lastNumber = getLastUpdatedNum(selectedDisplayMode.toString());
      if (lastNumber > 0) {
        resetCookies();
      }
    }

    return gotNumber;
  }
 public void setSelectedDisplayMode(String selectedDisplayMode) {
   DisplayMode[] displayModes = DisplayMode.values();
   for (int i = 0; i < displayModes.length; ++i) {
     if (displayModes[i].name().equals(selectedDisplayMode)) {
       setSelectedDisplayMode(displayModes[i]);
       break;
     }
   }
 }
 public void setSelectedDisplayMode(DisplayMode displayMode) {
   selectedDisplayMode = displayMode;
   getChild(UIDropDownControl.class).setValue(selectedDisplayMode.toString());
   try {
     // init();
   } catch (Exception e) {
     LOG.error("Failed to init()");
   }
 }
Example #9
0
 @Override
 protected void onRestoreInstanceState(Parcelable state) {
   final SavedState ss = (SavedState) state;
   super.onRestoreInstanceState(ss.getSuperState());
   setPattern(DisplayMode.Correct, LockPatternUtils.stringToPattern(ss.getSerializedPattern()));
   mPatternDisplayMode = DisplayMode.values()[ss.getDisplayMode()];
   mInputEnabled = ss.isInputEnabled();
   mInStealthMode = ss.isInStealthMode();
   mEnableHapticFeedback = ss.isTactileFeedbackEnabled();
 }
Example #10
0
 @Override
 protected Parcelable onSaveInstanceState() {
   Parcelable superState = super.onSaveInstanceState();
   return new SavedState(
       superState,
       patternToString(),
       patternDisplayMode.ordinal(),
       inputEnabled,
       inStealthMode,
       enableHapticFeedback);
 }
Example #11
0
 @Override
 protected Parcelable onSaveInstanceState() {
   Parcelable superState = super.onSaveInstanceState();
   return new SavedState(
       superState,
       LockPatternUtils.patternToString(mPattern),
       mPatternDisplayMode.ordinal(),
       mInputEnabled,
       mInStealthMode,
       mEnableHapticFeedback);
 }
Example #12
0
  /** Render the whole calendar but do not render the events. */
  public void drawEmptyCells() {
    final FlexTable grid = (FlexTable) getWidget();

    final int rows = displayMode.getRows() + displayHeaders;
    final int columns = displayMode.getColumns() + (displayWeekNumber ? 1 : 0);

    Date date = displayMode.getStartDate(startDate, firstDayOfWeek);

    // Column headers
    if (displayHeaders != NO_HEADERS) {
      if (displayHeaders == ALL_HEADERS) {
        // Header of the calendar
        final Label calendarHeader = new Label(getHeading());
        calendarHeader.addStyleName("calendar-header");
        grid.setWidget(0, 0, calendarHeader);
        grid.getFlexCellFormatter().setColSpan(0, 0, columns + (displayWeekNumber ? 1 : 0));
      }

      final Date currentHeader = new Date(date.getTime());
      for (int x = displayWeekNumber ? 1 : 0; x < columns; x++) {
        final Label columnHeader = new Label(headerFormatter.format(currentHeader));
        columnHeader.addStyleName("calendar-column-header");
        grid.setWidget(displayHeaders == ALL_HEADERS ? 1 : 0, x, columnHeader);

        currentHeader.setDate(currentHeader.getDate() + 1);
      }
    }

    int currentMonth = startDate.getMonth();
    for (int y = displayHeaders; y < rows; y++) {
      if (displayWeekNumber) {
        grid.getCellFormatter().addStyleName(y, 0, "calendar-row-header");
        grid.setText(y, 0, Integer.toString(getWeekNumber(date, firstDayOfWeek)));
      }

      for (int x = displayWeekNumber ? 1 : 0; x < columns; x++) {
        drawCell(y, x, date, currentMonth);
        date.setDate(date.getDate() + 1);
      }
    }
  }
Example #13
0
  /**
   * @param dim
   * @param mode
   * @param fullscreen
   * @return enum rserr_t
   */
  public int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) {

    // TODO: jgw
    fullscreen = false;

    GlState.gl.log("GLimp_SetMode");

    Dimension newDim = new Dimension(dim.width, dim.height);

    /*
     * fullscreen handling
     */

    GlState.gl.log("determining old display mode");
    if (GlState.oldDisplayMode == null) {
      GlState.oldDisplayMode = getDisplayMode();
    }

    // destroy the existing window
    GlState.gl.shutdow();

    GlState.gl.log("searching new display mode");
    DisplayMode displayMode = DisplayModes.findDisplayMode(newDim);
    GlState.gl.log("copying w/h");
    newDim.width = displayMode.getWidth();
    newDim.height = displayMode.getHeight();

    GlState.gl.log("setting mode: " + displayMode);

    this.width = newDim.width;
    this.height = newDim.height;

    GlState.gl.log("storing mode");
    GlState.vid.width = newDim.width;
    GlState.vid.height = newDim.height;

    // let the sound and input subsystems know about the new window
    GlState.gl.log("newWindow notification");
    Window.NewWindow(GlState.vid.width, GlState.vid.height);
    return GlConstants.rserr_ok;
  }
  private long getLastUpdatedNum(String mode) {
    String cookieKey =
        String.format(Utils.LAST_UPDATED_ACTIVITIES_NUM, mode, Utils.getViewerRemoteId());
    String strValue = Utils.getCookies(cookieKey);
    boolean refreshPage = Utils.isRefreshPage();

    if (strValue == null || (refreshPage == false && mode.equals(selectedDisplayMode.toString()))) {
      return 0;
    }

    return Long.parseLong(strValue);
  }
Example #15
0
  /**
   * Defines the display mode of the calendar and perform a redraw.
   *
   * @param displayMode Style of the calendar (day, week or month).
   * @see CalendarWidget.DisplayMode
   */
  public void setDisplayMode(DisplayMode displayMode) {
    final FlexTable grid = (FlexTable) getWidget();

    clear();

    // Resetting the CSS style
    grid.removeStyleName(this.displayMode.getStyleName());

    this.displayMode = displayMode;

    // Applying the CSS style associated with the new display mode
    grid.addStyleName(displayMode.getStyleName());

    refresh();
  }
Example #16
0
  public CalendarWidget(
      int displayHeaders, boolean displayWeekNumber, Authentication authentication) {
    this.calendars = new ArrayList<Calendar>();
    this.displayHeaders = displayHeaders;
    this.displayWeekNumber = displayWeekNumber;
    this.authentication = authentication;

    // final SimplePanel container;

    final FlexTable grid = new FlexTable();
    grid.addStyleName("calendar");
    grid.addStyleName(displayMode.getStyleName());

    initWidget(grid);

    final Date now = new Date();
    today = new Date(now.getYear(), now.getMonth(), now.getDate());
    startDate = new Date(0, 0, 0);

    today();
  }
  /**
   * initialize
   *
   * @throws Exception
   */
  public void init() throws Exception {
    Validate.notNull(ownerName, "ownerName must not be null.");
    Validate.notNull(viewerName, "viewerName must not be null.");
    //
    synchronized (locker) {
      removeChild(UIActivitiesLoader.class);
      activitiesLoader = addChild(UIActivitiesLoader.class, null, "UIActivitiesLoader");
    }
    //
    String activityId = Utils.getActivityID();
    if (activityId != null && activityId.length() > 0) {
      activitiesLoader.setPostContext(PostContext.SINGLE);
    } else {
      activitiesLoader.setPostContext(PostContext.USER);
    }

    // Check if current display page is My Activity Stream
    String currentUserName = URLUtils.getCurrentUser();
    if (currentUserName != null) {
      selectedDisplayMode = DisplayMode.OWNER_STATUS;
    }

    activitiesLoader.setLoadingCapacity(ACTIVITY_PER_PAGE);
    activitiesLoader.setOwnerName(ownerName);
    activitiesLoader.setSelectedDisplayMode(selectedDisplayMode.toString());

    //
    //    UIActivitiesContainer activitiesContainer =
    // activitiesLoader.getChild(UIActivitiesContainer.class);

    //
    Identity ownerIdentity =
        Utils.getIdentityManager()
            .getOrCreateIdentity(OrganizationIdentityProvider.NAME, ownerName, false);

    ActivityManager activityManager = Utils.getActivityManager();
    ListAccess<ExoSocialActivity> activitiesListAccess = null;

    switch (this.selectedDisplayMode) {
      case MY_ACTIVITIES:
        activitiesListAccess = activityManager.getActivitiesWithListAccess(ownerIdentity);
        activitiesLoader.setActivityListAccess(activitiesListAccess);
        break;
      case OWNER_STATUS:
        if (isActivityStreamOwner == false) {
          Identity viewerIdentity =
              Utils.getIdentityManager()
                  .getOrCreateIdentity(OrganizationIdentityProvider.NAME, viewerName, false);
          activitiesListAccess =
              activityManager.getActivitiesWithListAccess(ownerIdentity, viewerIdentity);
          activitiesLoader.setActivityListAccess(activitiesListAccess);
        } else {
          activitiesListAccess = activityManager.getActivitiesWithListAccess(ownerIdentity);
          activitiesLoader.setActivityListAccess(activitiesListAccess);
        }

        break;
      case CONNECTIONS:
        activitiesListAccess =
            activityManager.getActivitiesOfConnectionsWithListAccess(ownerIdentity);
        activitiesLoader.setActivityListAccess(activitiesListAccess);
        break;
      case MY_SPACE:
        activitiesListAccess =
            activityManager.getActivitiesOfUserSpacesWithListAccess(ownerIdentity);
        activitiesLoader.setActivityListAccess(activitiesListAccess);
        break;
      default:
        activitiesListAccess = activityManager.getActivityFeedWithListAccess(ownerIdentity);
        activitiesLoader.setActivityListAccess(activitiesListAccess);
        break;
    }

    //
    String lastVisitedModeCookieKey =
        String.format(Utils.ACTIVITY_STREAM_TAB_SELECTED_COOKIED, Utils.getViewerRemoteId());
    String lastVisitedMode = Utils.getCookies(lastVisitedModeCookieKey);

    this.notChangedMode =
        lastVisitedMode == null
            ? true
            : this.selectedDisplayMode.toString().equals(lastVisitedMode.trim());

    // setNumberOfUpdatedActivities(getActivigetActivitiesUpdatedNumtiesUpdatedNum(notChangedMode));
    setNumberOfUpdatedActivities(0);

    //
    activitiesLoader.init();
  }
Example #18
0
 public void previous() {
   displayMode.previousDate(startDate);
   refresh();
 }
Example #19
0
 public void next() {
   displayMode.nextDate(startDate);
   refresh();
 }
Example #20
0
 public final void today() {
   displayMode.firstDay(startDate, today, firstDayOfWeek);
   refresh();
 }
 private void setSelectedMode(UIDropDownControl uiDropDownControl) {
   if (selectedDisplayMode != null) {
     uiDropDownControl.setValue(selectedDisplayMode.toString());
   }
 }