List of usage examples for com.google.common.util.concurrent ListeningScheduledExecutorService scheduleAtFixedRate
@Override ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit);
From source file:org.eclipse.osee.executor.admin.internal.ExecutorAdminImpl.java
@Override @SuppressWarnings("unchecked") public <T> Future<T> scheduleAtFixedRate(String id, final Callable<T> callable, long startAfter, long executionRate, TimeUnit timeUnit) { ListeningScheduledExecutorService executor = getScheduledExecutor(id); Runnable runnable = asRunnable(callable); ScheduledFuture<?> scheduledFuture = executor.scheduleAtFixedRate(runnable, startAfter, executionRate, timeUnit);/*w ww . j a v a2 s. co m*/ return (Future<T>) scheduledFuture; }
From source file:pl.otros.logview.gui.LogViewMainFrame.java
public LogViewMainFrame(DataConfiguration c) throws InitializationException { super();/*from w ww . j ava 2s . c om*/ this.configuration = c; this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); String title = "OtrosLogViewer"; try { title += ' ' + VersionUtil.getRunningVersion(); } catch (Exception e) { LOGGER.warning("Can't load version of running OLV"); } this.setTitle(title); try { String iconPath = "img/otros/logo16.png"; if (System.getProperty("os.name").contains("Linux")) { iconPath = "img/otros/logo64.png"; } BufferedImage icon = ImageIO.read(this.getClass().getClassLoader().getResourceAsStream(iconPath)); this.setIconImage(icon); } catch (Exception e1) { LOGGER.warning("Can't load icon: " + e1.getMessage()); } Exception modalDisplayException = null; // If non-terminal load problem occurs, queue to display for user on // top of the app UI. try { OtrosSplash.setMessage("Loading plugins"); LvDynamicLoader.getInstance().setStatusObserver(OtrosSplash.getSplashStatusObserver()); LvDynamicLoader.getInstance().loadAll(); OtrosSplash.setMessage("Loading plugins loaded"); } catch (IOException e) { LOGGER.severe("Problem with loading automatic markers, filter or log importers: " + e.getMessage()); modalDisplayException = e; } catch (InitializationException ie) { // Details should have been logged at lower level modalDisplayException = ie; } OtrosSplash.setMessage("Initializing GUI"); allPluginables = AllPluginables.getInstance(); logImportersContainer = allPluginables.getLogImportersContainer(); messageColorizercontainer = allPluginables.getMessageColorizers(); searchResultColorizer = (SearchResultColorizer) messageColorizercontainer .getElement(SearchResultColorizer.class.getName()); cardLayout = new CardLayout(); cardLayoutPanel = new JPanel(cardLayout); JLabel statusLabel = new JLabel(" "); observer = new JLabelStatusObserver(statusLabel); logsTabbedPane = new JTabbedPane(); enableDisableComponetsForTabs = new EnableDisableComponetsForTabs(logsTabbedPane); logsTabbedPane.addChangeListener(enableDisableComponetsForTabs); otrosApplication = new OtrosApplication(); otrosApplication.setAllPluginables(AllPluginables.getInstance()); otrosApplication.setApplicationJFrame(this); otrosApplication.setConfiguration(configuration); otrosApplication.setjTabbedPane(logsTabbedPane); otrosApplication.setStatusObserver(observer); otrosApplication.setOtrosVfsBrowserDialog(new JOtrosVfsBrowserDialog(getVfsFavoritesConfiguration())); otrosApplication.setServices(new ServicesImpl(otrosApplication)); SingleInstanceRequestResponseDelegate.getInstance().setOtrosApplication(otrosApplication); ToolTipManager.sharedInstance().setDismissDelay(5000); JProgressBar heapBar = new JProgressBar(); heapBar.setPreferredSize(new Dimension(190, 15)); new Thread(new MemoryUsedStatsUpdater(heapBar, 1500), "MemoryUsedUpdater").start(); JPanel statusPanel = new JPanel(new MigLayout("fill", "[fill, push, grow][right][right]", "[]")); statusPanel.add(statusLabel); final JButton ideConnectedLabel = new JButton(Ide.IDEA.getIconDiscounted()); statusPanel.add(ideConnectedLabel); statusPanel.add(new JButton(new SwitchAutoJump(otrosApplication))); statusPanel.add(heapBar); initMenu(); initToolbar(); addEmptyViewListener(); addMenuBarReloadListener(); otrosApplication.setSearchField(searchField); cardLayoutPanel.add(logsTabbedPane, CARD_LAYOUT_LOGS_TABLE); EmptyViewPanel emptyViewPanel = new EmptyViewPanel(otrosApplication); final JScrollPane jScrollPane = new JScrollPane(emptyViewPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jScrollPane.getVerticalScrollBar().setValue(0); } }); cardLayoutPanel.add(jScrollPane, CARD_LAYOUT_EMPTY); cardLayout.show(cardLayoutPanel, CARD_LAYOUT_EMPTY); enableDisableComponetsForTabs.stateChanged(null); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); cp.add(toolBar, BorderLayout.NORTH); cp.add(cardLayoutPanel, BorderLayout.CENTER); cp.add(statusPanel, BorderLayout.SOUTH); initGlobalHotKeys(); initPosition(); if (configuration.getBoolean(ConfKeys.LOAD_EXPERIMENTAL_FEATURES, false)) { initExperimental(); } setTransferHandler(new DragAndDropFilesHandler(otrosApplication)); initPlugins(); OtrosSplash.hide(); setVisible(true); if (modalDisplayException != null) JOptionPane.showMessageDialog(this, "Problem with loading automatic markers," + "filter or log importers:\n" + modalDisplayException.getMessage(), "Initialization Error", JOptionPane.ERROR_MESSAGE); // Check new version on start if (c.getBoolean(ConfKeys.VERSION_CHECK_ON_STARTUP, true)) { new ChekForNewVersionOnStartupAction(otrosApplication).actionPerformed(null); } new TipOfTheDay(c).showTipOfTheDayIfNotDisabled(this); Toolkit.getDefaultToolkit().getSystemEventQueue().push(new EventQueueProxy()); ListUncaughtExceptionHandlers listUncaughtExceptionHandlers = new ListUncaughtExceptionHandlers(// new LoggingExceptionHandler(), // new ShowErrorDialogExceptionHandler(otrosApplication), // new StatusObserverExceptionHandler(observer)); Thread.setDefaultUncaughtExceptionHandler(listUncaughtExceptionHandlers); ListeningScheduledExecutorService listeningScheduledExecutorService = otrosApplication.getServices() .getTaskSchedulerService().getListeningScheduledExecutorService(); listeningScheduledExecutorService.scheduleAtFixedRate( new IdeAvailabilityCheck(ideConnectedLabel, otrosApplication.getServices().getJumpToCodeService()), 5, 5, TimeUnit.SECONDS); ideConnectedLabel.addActionListener(new IdeIntegrationConfigAction(otrosApplication)); }