public ClientMessageBusImpl() { setBusToInitializableState(); managementConsole = new ManagementConsole(this); clientId = String.valueOf(com.google.gwt.user.client.Random.nextInt(99999)) + "-" + (System.currentTimeMillis() % (com.google.gwt.user.client.Random.nextInt(99999) + 1)); IN_SERVICE_ENTRY_POINT = "in." + getClientId() + ".erraiBus"; OUT_SERVICE_ENTRY_POINT = "out." + getClientId() + ".erraiBus"; // when the window is closing, we want to stop the bus without causing any // errors (unless the server is unavailable of course) (see ERRAI-225) Window.addCloseHandler(new CloseHandler<Window>() { @Override public void onClose(final CloseEvent<Window> event) { if (state != BusState.LOCAL_ONLY) { stop(true); } } }); }
public static final void shuffle(final char[] input) { // --- Shuffle by exchanging each element randomly for (int i = 0; i < input.length; i++) { int randomPosition = Random.nextInt(input.length); char temp = input[i]; input[i] = input[randomPosition]; input[randomPosition] = temp; } }
public static final void shuffle(final int[] input) { // --- Shuffle by exchanging each element randomly for (int i = 0; i < input.length; i++) { int randomPosition = Random.nextInt(input.length); int temp = input[i]; input[i] = input[randomPosition]; input[randomPosition] = temp; } }
public static final void shuffle(final int[] input) { // --- Shuffle by exchanging each element randomly for (int i = 0; i < input.length; i++) { int randomPosition = Random.nextInt(input.length); int temp = input[i]; input[i] = input[randomPosition]; input[randomPosition] = temp; } }
public static final void shuffle(final char[] input) { // --- Shuffle by exchanging each element randomly for (int i = 0; i < input.length; i++) { int randomPosition = Random.nextInt(input.length); char temp = input[i]; input[i] = input[randomPosition]; input[randomPosition] = temp; } }
@Override int randomInt(int limit) { return Random.nextInt(limit); }
@Override int randomInt() { return Random.nextInt(); }
/** * TODO window.crypto.getRandomValues. */ @Override byte[] newUID_() { byte[] bytes = new byte[UID.LENGTH]; int n = 0; for (int i = 0; i < 4; i++) { int value = Random.nextInt(); bytes[n++] = (byte) (value >>> 0); bytes[n++] = (byte) (value >>> 8); bytes[n++] = (byte) (value >>> 16); bytes[n++] = (byte) (value >>> 24); } return bytes; }
private static String getNextFormattedRandomNumber() { String randomHex = Integer.toHexString(Random.nextInt(256)); if (randomHex.length() == 1) { // ensure two digits randomHex = "0" + randomHex; } return randomHex; }
public static String getBase62RandomInt() { int randomValue = Random.nextInt(); ByteBuffer byteBuffer = ByteBuffer.allocate(4); byteBuffer.putInt(randomValue); BigInteger bi = new BigInteger(byteBuffer.array()); return convertToBase62String(bi); }
/** * Randomly shuffle the list of objects provided. * <p> * <i>Note: {@link Collections#shuffle(List)} is not GWT compatible</i> * * @param objects * the list to shuffle */ public static final void shuffle(final List<?> objects) { for (int i = objects.size(); i > 1; i--) { swap(objects, i - 1, Random.nextInt(i)); } }
public static void runAsync(final RunAsyncCallback callback) { final int delay = Random.nextInt(50) + 1; final Throwable _trace = new Throwable(); new Timer() { @Override public void run() { trace = _trace; callback.onSuccess(); } }.schedule(delay); logger.info("simulating async load with " + delay + "ms delay."); } }
/** * Randomly shuffle the list of objects provided. * <p> * <i>Note: {@link Collections#shuffle(List)} is not GWT compatible</i> * * @param objects * the list to shuffle */ public static final void shuffle(final List<?> objects) { for (int i = objects.size(); i > 1; i--) { swap(objects, i - 1, Random.nextInt(i)); } }
/** Returns random color */ public static String getRandomColor() { String[] colors = new ColorPalette().getColors(); int i = com.google.gwt.user.client.Random.nextInt(colors.length); return colors[i]; } }
public ClientMessageBusImpl() { setBusToInitializableState(); managementConsole = new ManagementConsole(this); clientId = String.valueOf(com.google.gwt.user.client.Random.nextInt(99999)) + "-" + (System.currentTimeMillis() % (com.google.gwt.user.client.Random.nextInt(99999) + 1)); IN_SERVICE_ENTRY_POINT = "in." + getClientId() + ".erraiBus"; OUT_SERVICE_ENTRY_POINT = "out." + getClientId() + ".erraiBus"; // when the window is closing, we want to stop the bus without causing any // errors (unless the server is unavailable of course) (see ERRAI-225) Window.addCloseHandler(new CloseHandler<Window>() { @Override public void onClose(final CloseEvent<Window> event) { if (state != BusState.LOCAL_ONLY) { stop(true); } } }); }
private void init() { setStyleName("n52_sensorweb_client_imagebutton"); // int length = this.size + 2 * this.margin; // this.setWidth(length); // this.setHeight(length); String loaderId = "loader_" + (LoaderManager.getInstance().getCount() + Random.nextInt(10000)); this.loader = new LoaderImage(loaderId, "../img/mini_loader_bright.gif", this); this.setID(this.id); this.setSrc(this.icon); this.setShowHover(true); this.setShowRollOver(this.showRollOver); this.setShowDownIcon(this.showDown); this.setShowFocusedAsOver(false); this.setCursor(Cursor.POINTER); if (View.getView().isShowExtendedTooltip()) { this.setTooltip(this.extendedTooltip); } else { this.setTooltip(this.shortToolTip); } }