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

The following are top voted examples for showing how to use com.google.gwt.user.client.Timer. 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: HorizontalPanelWithHint.java   Source Code and License 8 votes vote down vote up
public HorizontalPanelWithHint(Widget hint) {
	super();
	iHint = new PopupPanel();
	iHint.setWidget(hint);
	iHint.setStyleName("unitime-PopupHint");
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONMOUSEMOVE);
	iShowHint = new Timer() {
		@Override
		public void run() {
			iHint.show();
		}
	};
	iHideHint = new Timer() {
		@Override
		public void run() {
			iHint.hide();
		}
	};
}
 
Example 2
Project: document-management-system   File: LogoutPopup.java   Source Code and License 7 votes vote down vote up
/**
 * logoutAfterChat();
 */
private void logoutAfterChat() {
	Timer timer = new Timer() {
		@Override
		public void run() {
			if (!Main.get().mainPanel.bottomPanel.userInfo.isPendingToClose()) {
				authService.logout(callbackLogout);
			} else {
				logoutAfterChat();
			}
		}
	};

	timer.schedule(100); // Each minute seconds refreshing connected users
	Log.debug("Logout: void");
}
 
Example 3
Project: empiria.player   File: NavigationButtonModule.java   Source Code and License 6 votes vote down vote up
@Override
public void onPlayerEvent(PlayerEvent event) {
    if (testMode) {
        return;
    }

    if (event.getType() == PAGE_LOADED) {
        Timer timer = new Timer() {
            @Override
            public void run() {
                setEnabled(!isEnd());
                setStyleName();
            }
        };
        timer.schedule(300);
    } else if (event.getType() == BEFORE_FLOW) {
        setEnabled(false);
        setStyleName();
    }
}
 
Example 4
Project: empiria.player   File: VideoControlHideTimer.java   Source Code and License 6 votes vote down vote up
@Inject
public VideoControlHideTimer(@Assisted VideoFullScreenView view, EventsBus eventsBus) {
    this.view = view;
    this.eventsBus = eventsBus;
    view.getContainer().addDomHandler(this, TouchEndEvent.getType());
    view.getContainer().addDomHandler(this, ClickEvent.getType());
    view.getContainer().addDomHandler(this, MouseMoveEvent.getType());
    controlsHideTimer = new Timer() {

        @Override
        public void run() {
            hideCotrols();
        }
    };
    controlsHideTimer.schedule(CONTROLS_SHOW_TIME);
}
 
Example 5
Project: unitimes   File: CurriculumProjectionRulesPage.java   Source Code and License 6 votes vote down vote up
public MyFlexTable() {
	super();
	setCellPadding(2);
	setCellSpacing(0);
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONCLICK);
	sinkEvents(Event.ONKEYDOWN);
	setStylePrimaryName("unitime-MainTable");
	iTimer = new Timer() {
		@Override
		public void run() {
			saveOrder();
		}
	};
}
 
Example 6
Project: unitimes   File: EventAdd.java   Source Code and License 6 votes vote down vote up
public CourseRelatedObjectsTable(AcademicSessionProvider session) {
	iSession = session;
	setStyleName("unitime-EventOwners");
	
	List<Widget> header = new ArrayList<Widget>();
	header.add(new UniTimeTableHeader(MESSAGES.colSubject()));
	header.add(new UniTimeTableHeader(MESSAGES.colCourseNumber()));
	header.add(new UniTimeTableHeader(MESSAGES.colConfigOrSubpart()));
	header.add(new UniTimeTableHeader(MESSAGES.colClassNumber()));
	header.add(new UniTimeTableHeader("&nbsp;"));
	
	addRow(null, header);
	
	iChangeTimer = new Timer() {
		@Override
		public void run() {
			List<RelatedObjectInterface> value = getValue();
			if (iLastChange != null && iLastChange.equals(value)) return;
			iLastChange = value;
			ValueChangeEvent.fire(CourseRelatedObjectsTable.this, value);
		}
	};
}
 
Example 7
Project: unitimes   File: MobileNotifications.java   Source Code and License 6 votes vote down vote up
protected void addNotification(final Notification notification) {
	for (Iterator<Notification> i = iNotifications.iterator(); i.hasNext(); ) {
		Notification n = i.next();
		if (n.getText().equals(notification.getText())) {
			i.remove();
		}
	}
	iNotifications.add(notification);
	populate("slideup");
	
	Timer timer = new Timer() {
		@Override
		public void run() {
			iNotifications.remove(notification);
			populate(null);
		}
	};
	timer.schedule(10000);
}
 
Example 8
Project: unitimes   File: UniTimePageHeader.java   Source Code and License 6 votes vote down vote up
private UniTimePageHeader() {
	iHeader = new PageHeader();

	getLeft().setCallback(new Callback() {
		@Override
		public void execute(Callback callback) {
			reloadSolverInfo(true, callback);
		}
	});

	reloadSessionInfo();
	reloadUserInfo();
	iTimer = new Timer() {
		@Override
		public void run() {
			reloadSolverInfo(getLeft().isPopupShowing(), null);
		}
	};
	iTimer.schedule(1000);
}
 
Example 9
Project: optashift-employee-rostering   File: Calendar.java   Source Code and License 6 votes vote down vote up
private Calendar(Integer tenantId, Fetchable<Collection<I>> dataProvider, Fetchable<List<G>> groupProvider,
        DataProvider<G,
                I> instanceCreator, SyncBeanManager beanManager) {
    this.beanManager = beanManager;
    this.tenantId = tenantId;

    shifts = new HashMap<>();
    didTenantChange = true;

    setInstanceCreator(instanceCreator);
    setGroupProvider(groupProvider);
    setDataProvider(dataProvider);

    timer = new Timer() {

        @Override
        public void run() {
            forceUpdate();
        }
    };

    refresh();

}
 
Example 10
Project: appinventor-extensions   File: EditorManager.java   Source Code and License 6 votes vote down vote up
/**
 * Creates the editor manager.
 */
public EditorManager() {
  openProjectEditors = Maps.newHashMap();

  dirtyProjectSettings = new HashSet<ProjectSettings>();
  dirtyFileEditors = new HashSet<FileEditor>();

  autoSaveTimer = new Timer() {
    @Override
    public void run() {
      // When the timer goes off, save all dirtyProjectSettings and
      // dirtyFileEditors.
      Ode.getInstance().lockScreens(true); // Lock out changes
      saveDirtyEditors(new Command() {
          @Override
          public void execute() {
            Ode.getInstance().lockScreens(false); // I/O finished, unlock
          }
        });
    }
  };
}
 
Example 11
Project: gwt-promptly   File: DemoUI.java   Source Code and License 6 votes vote down vote up
private void executeCommandPause(final PromptlyPanel panel) {
   panel.setBlockingHyperlinks(true);
   panel.append("Pausing for 3 seconds (all input ignored) ....");
   panel.setCommandLineMode(false /* is command line mode */, false /* is collect key events */, false /* is collect mouse events */);

   Timer t = new Timer() {
      
      @Override
      public void run() {
         panel.append("... and we are back !");
         panel.setBlockingHyperlinks(false);
         panel.setCommandLineMode(true /* is command line mode */, true /* is collect key events */, true /* is collect mouse events */);
      }
   };
   
   t.schedule(3000);
}
 
Example 12
Project: gwt-history   File: HistoryTest.java   Source Code and License 6 votes vote down vote up
/** Verify that no events are issued via newItem if there were not reqeuested. */
public void testNoEvents() {
  delayTestFinish(5000);

  addHistoryListenerImpl(event -> fail("onHistoryChanged should not have been called"));

  History.newItem("testNoEvents", false);

  timer =
      new Timer() {
        @Override
        public void run() {
          finishTest();
        }
      };
  timer.schedule(500);
}
 
Example 13
Project: gwt-history   File: HistoryTest.java   Source Code and License 6 votes vote down vote up
/**
 * Test to make sure that there is no double unescaping of hash values. See
 * https://bugzilla.mozilla.org/show_bug.cgi?id=483304
 */
@DoNotRunWith(Platform.HtmlUnitUnknown)
public void testNoDoubleTokenUnEscaping() {
  final String shouldBeEncoded = "abc%20abc";

  delayTestFinish(5000);

  History.newItem(shouldBeEncoded);
  History.newItem("someOtherToken");
  History.back();
  // allow browser to update the url
  timer =
      new Timer() {
        @Override
        public void run() {
          // make sure that value in url actually matches the original token
          assertEquals(shouldBeEncoded, History.getToken());
          finishTest();
        }
      };
  timer.schedule(200);
}
 
Example 14
Project: LAS   File: Print.java   Source Code and License 6 votes vote down vote up
public static void it(String html) {
try {
    buildFrame(html);

    if (USE_TIMER) {
	Timer timer	= new Timer() {
		public void run() {
		    printFrame();
		}
	    };
	timer.schedule(TIMER_DELAY * 1000);
    } else {
	DeferredCommand.addCommand(new Command() {
		public void execute() {
		    printFrame();
		}
	    });
    }

} catch (Throwable exc) {
    Window.alert(exc.getMessage());
}
   }
 
Example 15
Project: gwt-material-patterns   File: GoogleDriveView.java   Source Code and License 6 votes vote down vote up
@Inject
GoogleDriveView(Binder uiBinder) {
    initWidget(uiBinder.createAndBindUi(this));
    splash.show();
    Timer t = new Timer() {
        @Override
        public void run() {
            splash.hide();
        }
    };
    t.schedule(5000);
    search.addCloseHandler(event -> {
        appNav.setVisible(true);
        searchNav.setVisible(false);
    });
    search.addKeyUpHandler(event -> {
        List<DriveDTO> filteredFiles = DataHelper.getAllDrives().stream().filter(dto -> dto.getFileName().toLowerCase().contains(search.getText().toLowerCase())).collect(Collectors.toList());
        populateFiles(filteredFiles);
    });
    populateFiles(DataHelper.getAllDrives());
}
 
Example 16
Project: gwt-material-patterns   File: GoogleContactsView.java   Source Code and License 6 votes vote down vote up
@Inject
GoogleContactsView(Binder uiBinder) {
    initWidget(uiBinder.createAndBindUi(this));
    splash.show();
    Timer t = new Timer() {
        @Override
        public void run() {
            splash.hide();
        }
    };
    t.schedule(5000);
    search.addCloseHandler(event -> {
        appNav.setVisible(true);
        searchNav.setVisible(false);
    });
    search.addKeyUpHandler(event -> {
        List<UserDTO> filteredUser = DataHelper.getAllUsers().stream().filter(dto -> dto.getName().toLowerCase().contains(search.getText().toLowerCase())).collect(Collectors.toList());
        populateUsers(filteredUser);
    });
    populateUsers(DataHelper.getAllUsers());
}
 
Example 17
Project: document-management-system   File: TabFolderWorkflow.java   Source Code and License 6 votes vote down vote up
@Override
public void onChange(FolderEventConstant event) {
	if (event.equals(HasFolderEvent.FOLDER_CHANGED)) {
		Workflow.get().setTabFolderSelected();
		workflowManager.findProcessInstancesByNode(Workflow.get().getUuid());
	} else if (event.equals(HasFolderEvent.TAB_CHANGED)) {
		if (TabFolderComunicator.isWidgetExtensionVisible(this)) {
			Timer timer = new Timer() {
				@Override
				public void run() {
					workflowManager.fillWidth();
				}
			};
			timer.schedule(100);
		}
	}
}
 
Example 18
Project: document-management-system   File: TabDocumentWorkflow.java   Source Code and License 6 votes vote down vote up
@Override
public void onChange(DocumentEventConstant event) {
	if (event.equals(HasDocumentEvent.DOCUMENT_CHANGED)) {
		Workflow.get().setTabDocumentSelected();
		workflowManager.findProcessInstancesByNode(Workflow.get().getUuid());
	} else if (event.equals(HasDocumentEvent.TAB_CHANGED)) {
		if (TabDocumentComunicator.isWidgetExtensionVisible(this)) {
			Timer timer = new Timer() {
				@Override
				public void run() {
					workflowManager.fillWidth();
				}
			};
			timer.schedule(100);
		}
	}
}
 
Example 19
Project: document-management-system   File: TabMailWorkflow.java   Source Code and License 6 votes vote down vote up
@Override
public void onChange(MailEventConstant event) {
	if (event.equals(HasMailEvent.MAIL_CHANGED)) {
		Workflow.get().setTabMailSelected();
		workflowManager.findProcessInstancesByNode(Workflow.get().getUuid());
	} else if (event.equals(HasMailEvent.TAB_CHANGED)) {
		if (TabMailComunicator.isWidgetExtensionVisible(this)) {
			Timer timer = new Timer() {
				@Override
				public void run() {
					workflowManager.fillWidth();
				}
			};
			timer.schedule(100);
		}
	}
}
 
Example 20
Project: document-management-system   File: MsgPopup.java   Source Code and License 6 votes vote down vote up
/**
 * logout
 */
private void logout(final HTML countDown, final int seconds) {
	Timer timer = new Timer() {
		@Override
		public void run() {
			countDown.setHTML(Main.i18n("ui.logout") + " " + secondsToHTML(seconds));

			if (seconds > 1) {
				logout(countDown, seconds - 1);
			} else {
				hide();
				Main.get().logoutPopup.logout();
			}
		}
	};

	timer.schedule(1000);
}
 
Example 21
Project: document-management-system   File: ChatRoomPopup.java   Source Code and License 6 votes vote down vote up
/**
 * refreshUsersInRoom()
 */
private void refreshUsersInRoom(final String room) {
	if (chatRoomActive) {
		chatService.usersInRoom(room, new AsyncCallback<String>() {

			@Override
			public void onSuccess(String result) {
				usersInRoomText.setHTML("(" + result + ") " + Main.i18n("chat.users.in.room"));
				Timer timer = new Timer() {
					@Override
					public void run() {
						refreshUsersInRoom(room);
					}
				};

				timer.schedule(DELAY_USERS_IN_ROOM);
			}

			@Override
			public void onFailure(Throwable caught) {
				Main.get().showError("UsersInRoom", caught);
			}
		});
	}
}
 
Example 22
Project: document-management-system   File: FuturamaWalking.java   Source Code and License 6 votes vote down vote up
/**
 * Evaluate
 */
public void evaluate(String name) {
	if (name.equals("futurama")) {
		left = -180;
		top = Window.getClientHeight() - 80 - 21;
		show();
		setPopupPosition(left, top);

		move = new Timer() {
			public void run() {
				left += 2;
				setPopupPosition(left, top);

				if (left < Window.getClientWidth() + 180) {
					move.schedule(40);
				} else {
					move.cancel();
					hide();
				}
			}
		};

		move.schedule(40);
	}
}
 
Example 23
Project: cuba   File: CubaFileDownloaderConnector.java   Source Code and License 6 votes vote down vote up
public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();

        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);

        iframe.setFrameBorder(0);
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);

        Timer removeTimer = new Timer() {
            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}
 
Example 24
Project: Wiab.pro   File: SearchPresenter.java   Source Code and License 6 votes vote down vote up
SearchPresenter(TimerService scheduler, Search search,
    SearchesService searchPatternsService,
    SearchPanelView searchUi, WaveActionHandler actionHandler,
    SearchesModifyHandler searchesModifyHandler) {
  this.search = search;
  this.searchesService = searchPatternsService;
  this.searchUi = searchUi;
  this.scheduler = scheduler;
  this.actionHandler = actionHandler;
  this.searchesModifyHandler = searchesModifyHandler;

  digestsUpdateTimer = new Timer() {

    @Override
    public void run() {
      digestUis.each(new IdentityMap.ProcV<DigestView, Digest>() {
        
        @Override
        public void apply(DigestView digestView, Digest digest) {
          digestView.update();
        }
      });
    }
  };
}
 
Example 25
Project: ontobrowser   File: HistoryPopup.java   Source Code and License 6 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
	int keyCode = event.getNativeKeyCode();
	if((keyCode == KEY_BACKSPACE || keyCode >= KEY_DELETE) 
			&& keyCode != 91 && keyCode != 93) { // Command/Window keyboard keys
		cancelTimer();
		timer = new Timer() {
			public void run() {
				dataProvider.setFilter(filterTextBox.getValue());
			}
		};

		timer.schedule(TIMEOUT);
	} else if(keyCode == KEY_ENTER) {
		cancelTimer();
		dataProvider.setFilter(filterTextBox.getValue());
	}
}
 
Example 26
Project: ontobrowser   File: ApproveRejectComposite.java   Source Code and License 6 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
	int keyCode = event.getNativeKeyCode();
	if((keyCode == KEY_BACKSPACE || keyCode >= KEY_DELETE) 
			&& keyCode != 91 && keyCode != 93) { // Command/Window keyboard keys
		cancelTimer();
		timer = new Timer() {
			public void run() {
				dataProvider.setFilter(filterTextBox.getValue());
			}
		};

		timer.schedule(TIMEOUT);
	} else if(keyCode == KEY_ENTER) {
		cancelTimer();
		dataProvider.setFilter(filterTextBox.getValue());
	}
}
 
Example 27
Project: umlet   File: Notification.java   Source Code and License 6 votes vote down vote up
private static void fade(final Element element, final float startOpacity, final float endOpacity, final int totalTimeMillis) {
	final int numberOfSteps = 30;
	int stepLengthMillis = totalTimeMillis / numberOfSteps;
	stepCount = 0;
	final float deltaOpacity = (endOpacity - startOpacity) / numberOfSteps;
	timerFader = new Timer() {
		@Override
		public void run() {
			float opacity = startOpacity + stepCount * deltaOpacity;
			DOM.setStyleAttribute(element, "opacity", Float.toString(opacity));

			stepCount++;
			if (stepCount == numberOfSteps) {
				DOM.setStyleAttribute(element, "opacity", Float.toString(endOpacity));
				cancel();
			}
		}
	};
	timerFader.scheduleRepeating(stepLengthMillis);
}
 
Example 28
Project: playn   File: WebGLDemo.java   Source Code and License 6 votes vote down vote up
@Override
public void onModuleLoad() {
  canvas = Document.get().createElement("canvas").cast();
  Document.get().getBody().appendChild(canvas);
  canvas.setWidth(CANVAS_WIDTH);
  canvas.setHeight(CANVAS_HEIGHT);

  gl = WebGLRenderingContext.getContext(canvas);
  gl.viewport(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);

  init();

  new Timer() {
    @Override
    public void run() {
      draw();
    }
  }.scheduleRepeating(100);
}
 
Example 29
Project: firefly   File: IrsaCatalogTask.java   Source Code and License 6 votes vote down vote up
private void handleBackgrounding(final MonitorItem monItem) {
    DefaultWorkingWidget working= new DefaultWorkingWidget((ClickHandler)null);
    working.setText("Backgrounding...");
    final MaskPane maskPane = new MaskPane(getMaskWidget(), working);
    maskPane.show();
    Timer t= new Timer() {
        @Override
        public void run() {
            BackgroundMonitor monitor= Application.getInstance().getBackgroundMonitor();
            if (doAnimation) {
                Application.getInstance().getBackgroundManager().animateToManager(_animationX, _animationY, 1300);
            }
            monItem.setWatchable(true);
            monItem.setImmediately(showImmediately);
            monitor.addItem(monItem);
            _response.status(CatalogSearchResponse.RequestStatus.BACKGROUNDING);
            maskPane.hide();
        }
    };
    t.schedule(1000);
}
 
Example 30
Project: listmaker   File: ItemsTable.java   Source Code and License 6 votes vote down vote up
protected void expando(final FlowPanel div2, final DivElement[] notes)
{
	Timer t = new Timer()
	{
		int i = 0;
		final int last = notes.length;

		@Override
		public void run()
		{
			if (i >= last)
				this.cancel();
			else
				div2.getElement().appendChild(notes[i++]);
		}
	};
	// Eye candy
	t.scheduleRepeating(10);
}
 
Example 31
Project: gwt-material   File: MaterialToastTest.java   Source Code and License 6 votes vote down vote up
public void testToastWithCallback() {
    final boolean[] isCallbackFired = new boolean[1];
    new MaterialToast(() -> {
        isCallbackFired[0] = true;
    }).toast("callback", 1000);
    Timer t = new Timer() {
        @Override
        public void run() {
            assertTrue(isCallbackFired[0]);
        }
    };
    t.schedule(1000);
    Element toastContainer = $("body").find("#toast-container").asElement();
    assertNotNull(toastContainer);
    toastContainer.setInnerHTML("");
}
 
Example 32
Project: forplay   File: WebGLDemo.java   Source Code and License 6 votes vote down vote up
@Override
public void onModuleLoad() {
  canvas = Document.get().createElement("canvas").cast();
  Document.get().getBody().appendChild(canvas);
  canvas.setWidth(CANVAS_WIDTH);
  canvas.setHeight(CANVAS_HEIGHT);

  gl = WebGLRenderingContext.getContext(canvas);
  gl.viewport(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);

  init();

  new Timer() {
    @Override
    public void run() {
      draw();
    }
  }.scheduleRepeating(100);
}
 
Example 33
Project: guava-libraries   File: MapMaker.java   Source Code and License 6 votes vote down vote up
private void scheduleRemoval(final K key, final V value) {
  // from MapMaker
  /*
   * TODO: Keep weak reference to map, too. Build a priority queue out of the entries themselves
   * instead of creating a task per entry. Then, we could have one recurring task per map (which
   * would clean the entire map and then reschedule itself depending upon when the next
   * expiration comes). We also want to avoid removing an entry prematurely if the entry was set
   * to the same value again.
   */
  Timer timer = new Timer() {
    @Override
    public void run() {
      remove(key, value);
    }
  };
  timer.schedule((int) expirationMillis);
}
 
Example 34
Project: wbi   File: SeriesView.java   Source Code and License 6 votes vote down vote up
/**
 * Set whether scrollbars are enabled.
 *
 * @param enabled Whether scrollbars are enabled.
 */
public void setScrollEnabled(final boolean enabled) {
    final Element element = getElement();
    boolean scrollEnabled = element.hasClassName(CLASS_NAME_SCROLL);

    if ((scrollEnabled && !enabled) || (!scrollEnabled && enabled)) {
        if (enabled) {
            (new Timer() {
                @Override
                public void run() {
                    element.addClassName(CLASS_NAME_SCROLL);
                }
            }).schedule(SCROLL_DELAY);
        } else {
            element.removeClassName(CLASS_NAME_SCROLL);
        }
    }
}
 
Example 35
Project: che   File: DelayableWebSocketConnection.java   Source Code and License 6 votes vote down vote up
@Override
public void open() {
  final int delay = propertyManager.getConnectionDelay(url);

  if (isClosed() || isClosing()) {
    if (delay == 0) {
      webSocketJsoWrapper = WebSocketJsoWrapper.connect(url, endpoint);
    } else {
      new Timer() {
        @Override
        public void run() {
          webSocketJsoWrapper = WebSocketJsoWrapper.connect(url, endpoint);
        }
      }.schedule(delay);
    }
  } else {
    Log.warn(getClass(), "Opening already opened or connecting web socket.");
  }
}
 
Example 36
Project: che   File: PopupLoaderImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void setSuccess() {
  // Stop animation timer
  playTimer.cancel();

  // Start hide animation
  getElement().addClassName("outDown");

  // Remove from the parent
  new Timer() {
    @Override
    public void run() {
      removeFromParent();
    }
  }.schedule(1000);
}
 
Example 37
Project: che   File: TooltipHint.java   Source Code and License 6 votes vote down vote up
private void close() {
  opacity = 10;

  // Hide animation
  new Timer() {
    @Override
    public void run() {
      opacity--;
      if (opacity <= 0) {
        cancel();
        getElement().getParentElement().removeChild(getElement());
      } else {
        getElement().getStyle().setProperty("opacity", "0." + opacity);
      }
    }
  }.scheduleRepeating(50);
}
 
Example 38
Project: che   File: FullTextSearchViewImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void showDialog() {
  acceptButton.setEnabled(false);
  isUseFileMask.setValue(false);
  filesMask.setEnabled(false);
  isUseDirectory.setValue(false);
  wholeWordsOnly.setValue(false);
  directory.setEnabled(false);
  selectPathButton.setEnabled(false);
  directory.setText("");
  filesMask.setText("*.*");
  directory.setText("/");
  errLabel.setText("");

  new Timer() {
    @Override
    public void run() {
      text.setFocus(true);
    }
  }.schedule(100);

  super.show();
}
 
Example 39
Project: che   File: OpenFileAction.java   Source Code and License 6 votes vote down vote up
private void scrollToLine(EditorPartPresenter editor, String lineParam) {
  if (!(editor instanceof TextEditor)) {
    return;
  }
  new Timer() {
    @Override
    public void run() {
      try {
        int lineNumber = parseInt(lineParam);
        TextEditor textEditor = (TextEditor) editor;
        textEditor.getDocument().setCursorPosition(new TextPosition(lineNumber - 1, 0));
      } catch (NumberFormatException e) {
        Log.error(getClass(), localization.fileToOpenLineIsNotANumber());
      }
    }
  }.schedule(300);
}
 
Example 40
Project: viaja-facil   File: M.java   Source Code and License 6 votes vote down vote up
private void showSelectFromMap() {
	if(!showedSelectFromMapOnce) {
		showedSelectFromMapOnce = true;
		final DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true);
	    simplePopup.setWidth("150px");
	    simplePopup.setWidget(new HTML(CONSTANTS.selectFromMap()));
	    simplePopup.addStyleName("popup");
	    simplePopup.center();
	    Timer t = new Timer() {
			public void run() {
				simplePopup.hide();
			}
		};
		t.schedule(2000);
	}
}
 
Example 41
Project: firefly   File: MiniPlotWidget.java   Source Code and License 6 votes vote down vote up
public void setActive(boolean active) {
    _active= active;
    AllPlots.getInstance().setStatus(this, active ?  AllPlots.PopoutStatus.Enabled : AllPlots.PopoutStatus.Disabled);

    if (active) {
        Vis.init(this, new Vis.InitComplete() {
            public void done() {
                Timer t= new Timer() {
                    @Override
                    public void run() {
                        _plotView.refreshDisplay();
                    }
                };
                t.schedule(1000);
            }
        });
    }

}
 
Example 42
Project: che   File: CommandEditorViewImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void addPage(IsWidget page, String title) {
  page.asWidget().addStyleName(resources.editorCss().section());
  pagesPanel.insert(page, 0);

  if (!title.isEmpty()) {
    Label label = new Label(title);
    label.addStyleName(resources.editorCss().sectionLabel());
    pagesPanel.insert(label, 0);
  }

  // editor must be scrolled to the top immediately after opening
  new Timer() {
    @Override
    public void run() {
      scrollPanel.scrollToTop();
    }
  }.schedule(1000);
}
 
Example 43
Project: firefly   File: MaskPane.java   Source Code and License 6 votes vote down vote up
public void showWhenUncovered() {
    waitingToMask= true;
    final Application app= Application.getInstance();
    final ToolbarDropdown dropdown= (app.getToolBar()!=null) ? app.getToolBar().getDropdown() : null;
    if (dropdown==null) {
        show();
    }
    else if (GwtUtil.isParentOf(maskElement, dropdown.getElement())) {
        show();
    }
    else {
        Timer t= new Timer() {
            @Override
            public void run() {
                if (waitingToMask) {
                    if (dropdown.isOpen()) hide();
                    else                   show();
                    if (!isShowing()) schedule(500);
                }
            }
        };
        t.schedule(100);
    }
}
 
Example 44
Project: unitime   File: CurriculumProjectionRulesPage.java   Source Code and License 6 votes vote down vote up
public MyFlexTable() {
	super();
	setCellPadding(2);
	setCellSpacing(0);
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONCLICK);
	sinkEvents(Event.ONKEYDOWN);
	setStylePrimaryName("unitime-MainTable");
	iTimer = new Timer() {
		@Override
		public void run() {
			saveOrder();
		}
	};
}
 
Example 45
Project: appformer   File: WorkbenchLayoutImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void resizeTo(int width,
                     int height) {
    root.setPixelSize(width,
                      height);

    // The dragBoundary can't be a LayoutPanel, so it doesn't support ProvidesResize/RequiresResize.
    // We start the cascade of onResize() calls at its immediate child.
    perspectiveRootContainer.onResize();

    new Timer() {
        @Override
        public void run() {
            updateMaximizedPanelSizes();
        }
    }.schedule(5);
}
 
Example 46
Project: che   File: RenameViewImpl.java   Source Code and License 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void show() {
  newName.getElement().setAttribute("spellcheck", "false");
  newName.addStyleName(javaResources.css().errorBorder());
  updateDelegateUpdating.setValue(false);
  updateMarkDeprecated.setValue(false);
  updateMarkDeprecated.setEnabled(false);

  super.show();

  new Timer() {
    @Override
    public void run() {
      setFocus();
    }
  }.schedule(100);
}
 
Example 47
Project: che   File: PomEditorReconciler.java   Source Code and License 6 votes vote down vote up
public void reconcilePoms(final List<String> updatedProjects) {
  new Timer() {

    @Override
    public void run() {
      Set<String> pomPaths = getPomPath(updatedProjects);
      List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors();
      for (EditorPartPresenter openedEditor : openedEditors) {
        String path = openedEditor.getEditorInput().getFile().getLocation().toString();
        if (pomPaths.contains(path)) {
          serverService.reconcilePom(path);
        }
      }
    }
  }.schedule(2000);
}
 
Example 48
Project: firefly   File: CollapsiblePanel.java   Source Code and License 6 votes vote down vote up
private void handleCallback() {
        if (disclosurePanel.isAnimationEnabled()) {
            if (disclosurePanel.getContent() != null && disclosurePanel.getContent().getParent() != null) {
                Timer t = new Timer(){
                    int tries = 0;
                    public void run() {
                            tries++;
                            String h = DOM.getStyleAttribute(disclosurePanel.getContent().getParent().getElement(), "height");
                            if (tries > 20 || h == null || h.equals("auto") || h.equals("")) {
                                postAction();
//                        GWT.log("#tries: " + tries, null);
                                cancel();
                            }
                        }
                };
                t.scheduleRepeating(250);
                return;
            }
        }
        postAction();
    }
 
Example 49
Project: unitime   File: EventAdd.java   Source Code and License 6 votes vote down vote up
public CourseRelatedObjectsTable(AcademicSessionProvider session) {
	iSession = session;
	setStyleName("unitime-EventOwners");
	
	List<Widget> header = new ArrayList<Widget>();
	header.add(new UniTimeTableHeader(MESSAGES.colSubject()));
	header.add(new UniTimeTableHeader(MESSAGES.colCourseNumber()));
	header.add(new UniTimeTableHeader(MESSAGES.colConfigOrSubpart()));
	header.add(new UniTimeTableHeader(MESSAGES.colClassNumber()));
	header.add(new UniTimeTableHeader("&nbsp;"));
	
	addRow(null, header);
	
	iChangeTimer = new Timer() {
		@Override
		public void run() {
			List<RelatedObjectInterface> value = getValue();
			if (iLastChange != null && iLastChange.equals(value)) return;
			iLastChange = value;
			ValueChangeEvent.fire(CourseRelatedObjectsTable.this, value);
		}
	};
}
 
Example 50
Project: gwt-material-demo   File: MaterialBarChart.java   Source Code and License 6 votes vote down vote up
private void setLoop() {

		Timer timer = new Timer() {

			public void run() {
				if (isLoop) {
					drawChart(values);
					isLoop = false;
				}
				else {
					drawChart(valuesInitial);
					isLoop = true;
				}

			}
		};
		timer.scheduleRepeating(1000);
	}
 
Example 51
Project: empiria.player   File: ScrollbarPanel.java   Source Code and License 5 votes vote down vote up
public ScrollbarPanel() {
    initWidget(uiBinder.createAndBindUi(this));

    scrollbarTimer = new Timer() {

        @Override
        public void run() {
            hideScrollBar();
        }
    };
}
 
Example 52
Project: empiria.player   File: PicturePlayerFullscreenDelay.java   Source Code and License 5 votes vote down vote up
private Timer createFullscreenDelay(final LightBox lightBox, final String pictureSrc, final Widget title) {
    return new Timer() {
        @Override
        public void run() {
            lightBox.openImage(pictureSrc, title);
        }
    };
}
 
Example 53
Project: empiria.player   File: ExplorableImgContentPresenter.java   Source Code and License 5 votes vote down vote up
private Timer initializeZoomInTimer() {
    Timer zoomTimer = new Timer() {

        @Override
        public void run() {
            zoomIn();
        }
    };
    return zoomTimer;
}
 
Example 54
Project: empiria.player   File: ExplorableImgContentPresenter.java   Source Code and License 5 votes vote down vote up
private Timer initializeZoomOutTimer() {
    Timer zoomTimer = new Timer() {

        @Override
        public void run() {
            zoomOut();
        }
    };

    return zoomTimer;
}
 
Example 55
Project: empiria.player   File: PanelWithScrollbars.java   Source Code and License 5 votes vote down vote up
public PanelWithScrollbars() {
    uiBinder.createAndBindUi(this);

    fadeoutTimer = new Timer() {

        @Override
        public void run() {
            fadeOutElement(verticalScrollPanel.getElement(), 200);
            fadeOutElement(horizontalScrollPanel.getElement(), 200);
        }
    };
}
 
Example 56
Project: che-archetypes   File: NewXFileViewImpl.java   Source Code and License 5 votes vote down vote up
@Override
public void showDialog() {
  nameField.setText("");
  headerField.setText("");
  show();
  new Timer() {
    @Override
    public void run() {
      nameField.setFocus(true);
    }
  }.schedule(300);
}
 
Example 57
Project: rxgwt-tips   File: Tips.java   Source Code and License 5 votes vote down vote up
private void schedulers() {
    // GWT Schedulers, various callbacks, not easy to combine or specify timing operations like a timeout!
    gwtScheduler().scheduleDeferred((ScheduledCommand) () -> L.log("one time command done!"));
    gwtScheduler().scheduleIncremental((RepeatingCommand) () -> {L.log("repeating command done!"); return false;});
    // to use RX first just wrap the task in a RX type, for example a log call into a Completable
    Completable rxTask = Completable.fromAction(() -> L.log("one time command done!")); // by default synchronous
    // with RX you can specify in which scheduler do you want to execute the task
    rxTask.subscribeOn(GwtSchedulers.deferredScheduler()); // async using a deferred scheduler
    rxTask.subscribeOn(GwtSchedulers.incrementalScheduler()); // async using a incremental scheduler
    rxTask.subscribeOn(Schedulers.io()); // GWT agnostic, but yep, this is mapped to deferred
    rxTask.subscribeOn(Schedulers.computation()); // and this one to is mapped to incremental
    // remember that this is a chained description, so you should save the instance, like this
    rxTask.subscribeOn(Schedulers.io()).subscribe(() -> L.log("task executed async!"));

    // for repeating tasks like a timer
    new Timer() { public void run() { L.log("whOOt? inheritance instead of composition?!");} }.schedule(100);
    // you should generate stream of ticks, called 'interval' (timer exists, but just emmit 1 tick)
    interval(100, MILLISECONDS).flatMapCompletable(n -> rxTask);

    // and a final example, if the web is online (and stop if not) do a task each 5min
    online().switchMap(online -> online ? interval(5, MINUTES) : Observable.never())
            // fetching a big list of data, so big that need to be reduced incrementally to no block the
            // main loop, as our API is RX friendly, just observe each result item in the computation scheduler
            .flatMapSingle(refresh -> requestData().observeOn(computation())
                    // and reduce each item here, until the whole response is processed
                    .<Set<String>>reduceWith(HashSet::new, (acc,n) -> { acc.add(n); return acc; }))
            // at this point the response has been processed incrementally!
            .doOnNext(result -> GWT.log("save the processed result: " + result))
            // if something goes wrong, wait 1 minute and try again, the try will reconnect the whole observable
            // so if the web is offline, it will not try to process again until it get online!
            .retryWhen(at -> at.flatMapSingle(ex -> { GWT.log("updater error", ex); return timer(1, MINUTES); }))
            .subscribe(); // eventually we'll see that subscribe responsibility can be delegated! (safer!)
}
 
Example 58
Project: unitimes   File: Client.java   Source Code and License 5 votes vote down vote up
public void onModuleLoadDeferred() {
	// register triggers
	GWT.runAsync(new RunAsyncCallback() {
		@Override
		public void onSuccess() {
			for (Triggers t: Triggers.values())
				t.register();
			callGwtOnLoadIfExists();
		}
		@Override
		public void onFailure(Throwable reason) {
		}
	});
	
	// load page
	if (RootPanel.get("UniTimeGWT:Body") != null) {
		LoadingWidget.getInstance().show(MESSAGES.waitLoadingPage());
		Scheduler.get().scheduleDeferred(new ScheduledCommand() {
			@Override
			public void execute() {
				initPageAsync(Window.Location.getParameter("page"));
			}
		});
	}
	
	// load components
	for (final Components c: Components.values()) {
		final RootPanel p = RootPanel.get(c.id());
		if (p != null) {
			Scheduler.get().scheduleDeferred(new ScheduledCommand() {
				@Override
				public void execute() {
					initComponentAsync(p, c);
				}
			});
		}
		if (p == null && c.isMultiple()) {
			NodeList<Element> x = getElementsByName(c.id());
			if (x != null && x.getLength() > 0)
				for (int i = 0; i < x.getLength(); i++) {
					Element e = x.getItem(i);
					e.setId(DOM.createUniqueId());
					final RootPanel q = RootPanel.get(e.getId());
					Scheduler.get().scheduleDeferred(new ScheduledCommand() {
						@Override
						public void execute() {
							initComponentAsync(q, c);
						}
					});
				}
		}
	}
	
	Window.addWindowClosingHandler(new Window.ClosingHandler() {
		@Override
		public void onWindowClosing(Window.ClosingEvent event) {
			if (isLoadingDisplayed() || LoadingWidget.getInstance().isShowing()) return;
			LoadingWidget.showLoading(MESSAGES.waitPlease());
			iPageLoadingTimer = new Timer() {
				@Override
				public void run() {
					RPC.execute(new IsSessionBusyRpcRequest(), new AsyncCallback<GwtRpcResponseBoolean>() {
						@Override
						public void onFailure(Throwable caught) {
							LoadingWidget.hideLoading();
						}
						@Override
						public void onSuccess(GwtRpcResponseBoolean result) {
							if (result.getValue()) {
								iPageLoadingTimer.schedule(500);
							} else {
								LoadingWidget.hideLoading();
							}
						}
					});
				}
			};
			iPageLoadingTimer.schedule(500);
		}
	});
}
 
Example 59
Project: unitimes   File: Refresh.java   Source Code and License 5 votes vote down vote up
public static void refreshPage() {
	String url = Window.Location.getHref();
	if (url.indexOf('#') >= 0)
		url = url.substring(0, url.lastIndexOf('#'));
	url += "#" + Window.getScrollLeft() + ":" + Window.getScrollTop();
	Window.Location.assign(url);
	new Timer() {
		@Override
		public void run() {
			Window.Location.reload();
		}
	}.schedule(100);
}
 
Example 60
Project: unitimes   File: UniTimeNotifications.java   Source Code and License 5 votes vote down vote up
protected void addNotification(final Notification notification) {
	RootPanel.get().add(notification, Window.getScrollLeft() + Window.getClientWidth() - 445, Window.getScrollTop() + Window.getClientHeight());
	iAnimation.cancel();
	for (Iterator<Notification> i = iNotifications.iterator(); i.hasNext(); ) {
		Notification n = i.next();
		if (n.equals(notification)) {
			n.hide(); i.remove();
		}
	}
	move();
	iNotifications.add(0, notification);
	iAnimation.run(1000);
	Timer timer = new Timer() {
		@Override
		public void run() {
			notification.hide();
			iNotifications.remove(notification);
		}
	};
	notification.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			notification.hide();
			iNotifications.remove(notification);
			move();
		}
	});
	timer.schedule(10000);
}