Package devplugin

Examples of devplugin.ProgressMonitor


  public JLabel getLabel() {
    return mInfoLabel;
  }

  public ProgressMonitor createProgressMonitor() {
    return new ProgressMonitor(){
      public void setMaximum(int maximum) {
        mProgressBar.setMaximum(maximum);
      }

      public void setValue(int value) {
View Full Code Here


    removeAllGroups();
    TvDataServiceProxy[] services = TvDataServiceProxyManager.getInstance().getDataServices();

    ProgressMonitorGroup progressGroup = new ProgressMonitorGroup(monitor, 30);

    ProgressMonitor curMon = progressGroup.getNextProgressMonitor(10);
    curMon.setMaximum(services.length);
    for (int i = 0; i < services.length; i++) {
      ChannelGroup[] groupArr = null;
      if (services[i].supportsDynamicChannelGroups()) {
        try {
          groupArr = services[i].checkForAvailableGroups(null);
        } catch (TvBrowserException e) {
          ErrorHandler.handle(e);
        }
      } else {
        groupArr = services[i].getAvailableGroups();
      }
      if (groupArr != null) {
        for (ChannelGroup aGroupArr : groupArr) {
          addGroup(services[i], aGroupArr);
        }
      }
      curMon.setValue(i + 1);
    }

    curMon = progressGroup.getNextProgressMonitor(20);
    curMon.setMaximum(services.length);

    int channelCount = 0;

    /*
     * Call 'checkForAvailableChannels' for all groups to fetch the most recent
     * channel lists
     */
    TvDataServiceProxy[] proxies = TvDataServiceProxyManager.getInstance().getDataServices();
    for (TvDataServiceProxy proxy : proxies) {
      if (proxy.supportsDynamicChannelList()) {
        ChannelGroup[] groups = proxy.getAvailableGroups();
        int max = groups.length;
        curMon.setMaximum(max);
        for (int j = 0; j < max; j++) {
          try {
            final String channelCountString = Integer.toString(channelCount);
            final ProgressMonitor finalMonitor = curMon;
            // use a proxy progress monitor to be able to add the number of
            // channels found so far
            Channel[] channels = proxy.checkForAvailableChannels(groups[j], new ProgressMonitor() {

              @Override
              public void setValue(int value) {
                finalMonitor.setValue(value);
              }

              @Override
              public void setMessage(String msg) {
                finalMonitor.setMessage(msg + " "
                    + mLocalizer.msg("channelCount", "(Found {0} channels)", channelCountString));
              }

              @Override
              public void setMaximum(int maximum) {
                finalMonitor.setMaximum(maximum);
              }
            });
            if (channels != null) {
              channelCount += channels.length;
            }
View Full Code Here

    mUsedWeight += mCurrentMonitorWeight;

    // Remember the weight of the current monitor
    mCurrentMonitorWeight = weight;

    return new ProgressMonitor() {
      public void setMaximum(int maximum) {
        mCurrentMonitorMaximum = maximum;
      }

      public void setValue(int value) {
View Full Code Here

        Cursor cursor = comp.getCursor();

        try {
          comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
          ProgramSearcher searcher = searcherSettings.createSearcher();
          ProgressMonitor progressMonitor = null;
          if (mProgressMonitor == null && !TvDataUpdater.getInstance().isDownloading()) {
            progressMonitor = MainFrame.getInstance().getStatusBar().createProgressMonitor();
            progressMonitor.setMessage(mLocalizer.msg("searching","Searching"));
          }

          Program[] programArr = searcher.search(searcherSettings.getFieldTypes(), startDate, searcherSettings
              .getNrDays(), searcherSettings.getChannels(), true, mProgressMonitor != null ? mProgressMonitor : progressMonitor, mListModel);
View Full Code Here

    }

    if (programArr.length == 0) {
      mProgressBar = new JProgressBar();

      mProgressMonitor = new ProgressMonitor() {

        public void setMaximum(final int maximum) {
          UIThreadRunner.invokeLater(new Runnable() {
            @Override
            public void run() {
View Full Code Here

      return;
    }
   
    remove(mLabel);
    add(mProgressBar,BorderLayout.CENTER);
    final ProgressMonitor monitor=this;
    Thread thread=new Thread("Finder"){
      public void run() {
        listener.dateChanged(mDate, monitor, callback);
        stopProgress();
      }
View Full Code Here


  private void updateAllFavorites() {
    mSendPluginsTable.clear();

    ProgressMonitor monitor;

    Favorite[] favoriteArr = FavoriteTreeModel.getInstance().getFavoriteArr();

    if (favoriteArr.length > 5) {    // if we have more then 5 favorites, we show a progress bar
      try {
        monitor = MainFrame.getInstance().createProgressMonitor();
      }catch(Exception e) {e.printStackTrace();
        monitor = new NullProgressMonitor();
      }
    }
    else {
      monitor = new NullProgressMonitor();
    }
    monitor.setMaximum(favoriteArr.length);
    monitor.setMessage(mLocalizer.msg("updatingFavorites","Updating favorites"));

    for (int i=0;i<favoriteArr.length; i++) {
      monitor.setValue(i);

      try {
        favoriteArr[i].refreshBlackList();
        favoriteArr[i].updatePrograms(true,true);
      } catch (TvBrowserException e) {
        ErrorHandler.handle(e);
      }
    }
    monitor.setMessage("");
    monitor.setValue(0);

    if(!mSendPluginsTable.isEmpty()) {
      sendToPlugins();
    }
  }
View Full Code Here

    // Work on the job list
    Throwable downloadException = null;
    for (int i = 0; (i < jobArr.length) && (!mStopDownloading); i++) {
      TvDataServiceProxy dataService = jobArr[i].getDataService();
      Channel[] channelArr = jobArr[i].getChannelList();
      ProgressMonitor monitor = monitorGroup.getNextProgressMonitor(channelArr.length);
      try {
        dataService.updateTvData(updateManager, channelArr, startDate,
                                 daysToDownload, monitor);
      }
      catch (Throwable thr) {
        mLog.log(Level.WARNING, "Updating the TV data for TV data service "
          + dataService.getInfo().getName() + " failed", thr);

        downloadException = thr;
      }
    }

    // Show the exception if there was one
    if (downloadException != null) {
      String msg = mLocalizer.msg("error.1", "Couldn't download the whole program!");
      ErrorHandler.handle(msg, downloadException);
    }

    // Reset the download flag
    mIsDownloading = false;

    checkLocalDateUsingNTP();

    ProgressMonitor monitor = monitorGroup.getNextProgressMonitor(subscribedChannels.length+1);
    monitor.setMessage(mLocalizer.msg("calculateEntries","Calculating new entries in the database"));
    TvDataBase.getInstance().reCalculateTvData(daysToDownload, monitor);
    TvDataBase.getInstance().updateTvDataBase();
    MarkedProgramsList.getInstance().revalidatePrograms();

    // Inform the listeners
    fireTvDataUpdateFinished();
    monitor.setMessage("");

    checkLocalTime();

    // reset flag to avoid unnecessary favorite updates
    mTvDataWasChanged = false;
View Full Code Here

TOP

Related Classes of devplugin.ProgressMonitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.