Package org.gudy.azureus2.core3.disk

Examples of org.gudy.azureus2.core3.disk.DiskManagerFileInfo


        ci.out.println("> Command 'hack': Not enough parameters for subcommand 'file'.");
        return false;
      }
      try {
        DiskManager disk = dm.getDiskManager();
        DiskManagerFileInfo files[] = disk.getFiles();
        int file = Integer.parseInt((String) args.get(0));
        String c = (String) args.get(1);
        if (c.equalsIgnoreCase("normal") || c.equalsIgnoreCase("n")) {
          files[file - 1].setSkipped(false);
          files[file - 1].setPriority(0);
View Full Code Here


    public void refresh(TableCell cell) {
      refresh(cell, false);
    }

    public void refresh(TableCell cell, boolean sortOnly) {
      final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
      int percentDone = 0;
      if (fileInfo != null && fileInfo.getLength() != 0)
        percentDone = (int) ((1000 * fileInfo.getDownloaded()) / fileInfo.getLength());
      cell.setSortValue(percentDone);
      if (sortOnly)
      {
        dispose(cell);
        return;
      }
     
      //Compute bounds ...
      int newWidth = cell.getWidth();
      if (newWidth <= 0)
        return;
      final int newHeight = cell.getHeight();
      final int x1 = newWidth - borderWidth - 1;
      final int y1 = newHeight - borderWidth - 1;
     
      if (x1 < 10 || y1 < 3)
        return;
     
      final DiskManager manager = fileInfo.getDiskManager();
      // we want to run through the image part once one the transition from with a disk manager (running)
      // to without a disk manager (stopped) in order to clear the pieces view
      boolean running = manager != null;
      boolean hasGraphic = false;
      Graphic graphic = cell.getGraphic();
      if (graphic instanceof UISWTGraphic) {
        Image img = ((UISWTGraphic) graphic).getImage();
        hasGraphic = img != null && !img.isDisposed();
      }
      final boolean bImageBufferValid = (lastPercentDone == percentDone)
          && cell.isValid() && bNoRed && running == was_running && hasGraphic;
     
      if (bImageBufferValid)
        return;
     
      was_running = running;
      lastPercentDone = percentDone;
      Image piecesImage = null;
     
      if (graphic instanceof UISWTGraphic)
        piecesImage = ((UISWTGraphic) graphic).getImage();
      if (piecesImage != null && !piecesImage.isDisposed())
        piecesImage.dispose();
     
      if (!running) {
        cell.setGraphic(null);
        return;
      }
     
      piecesImage = new Image(SWTThread.getInstance().getDisplay(), newWidth, newHeight);
      final GC gcImage = new GC(piecesImage);
     
      // dm may be null if this is a skeleton file view
      DownloadManager download_manager = fileInfo.getDownloadManager();
      PEPeerManager peer_manager = download_manager == null ? null : download_manager.getPeerManager();
      PEPiece[] pe_pieces = peer_manager == null ? null : peer_manager.getPieces();
      final long now = SystemTime.getCurrentTime();
     
      if (fileInfo != null && manager != null)
      {
        if (percentDone == 1000)
        {
          gcImage.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
          gcImage.setBackground(Colors.blues[Colors.BLUES_DARKEST]);
          gcImage.fillRectangle(1, 1, newWidth - 2, newHeight - 2);
        } else
        {
          final int firstPiece = fileInfo.getFirstPieceNumber();
          final int nbPieces = fileInfo.getNbPieces();
          final DiskManagerPiece[] dm_pieces = manager.getPieces();
          bNoRed = true;
          for (int i = 0; i < newWidth; i++)
          {
            final int a0 = (i * nbPieces) / newWidth;
View Full Code Here

     
      int firstFile = findFirstFileWithPieceN(firstPiece, files);
     
      for(int i = firstFile;i<files.length;i++)
      {
        DiskManagerFileInfo currentFile = files[i];
        if(currentFile.getLastPieceNumber() < firstPiece)
          continue;
        if(currentFile.getIndex() == file.getIndex())
          continue;
        if(currentFile.getFirstPieceNumber() > lastPiece)
          break;
        if(currentFile.getFirstPieceNumber() <= firstPiece && firstPiece <= currentFile.getLastPieceNumber())
          firstPieceShared |= !currentFile.isSkipped();
        if(currentFile.getFirstPieceNumber() <= lastPiece && lastPiece <= currentFile.getLastPieceNumber())
          lastPieceShared |= !currentFile.isSkipped();
      }
     
      if(firstPieceShared)
        firstPiece++;
View Full Code Here

    int firstFile = findFirstFileWithPieceN(firstPiece, files);
   
    // we must sweep over the files, as any number of files could share the first/last piece of the file we're probing
    for (int i = firstFile; i < files.length && !sharesAnyNeededPieces; i++)
    {
      DiskManagerFileInfo currentFile = files[i];
      if(currentFile.getLastPieceNumber() < firstPiece)
        continue;
      if (currentFile.getIndex() == file.getIndex() && resumePieces != null && file.getStorageType() != DiskManagerFileInfo.ST_COMPACT && file.getStorageType() != DiskManagerFileInfo.ST_REORDER_COMPACT)
        for (int j = firstPiece; j <= lastPiece && !sharesAnyNeededPieces; j++)
          sharesAnyNeededPieces |= resumePieces[j] != PIECE_NOT_DONE;
      if (currentFile.getFirstPieceNumber() > lastPiece)
        break;
      if (currentFile.getFirstPieceNumber() <= firstPiece && firstPiece <= currentFile.getLastPieceNumber())
        sharesAnyNeededPieces |= !currentFile.isSkipped();
      if (currentFile.getFirstPieceNumber() <= lastPiece && lastPiece <= currentFile.getLastPieceNumber())
        sharesAnyNeededPieces |= !currentFile.isSkipped();
    }

    return sharesAnyNeededPieces;
  }
View Full Code Here

    Object[] dataSources = tv.getSelectedDataSources(true);
    List<SelectedContent> listSelected = new ArrayList<SelectedContent>(
        dataSources.length);
    for (Object ds : dataSources) {
      if (ds instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
        listSelected.add(new SelectedContent(fileInfo.getDownloadManager(),
            fileInfo.getIndex()));
      }
    }
    SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(),
        listSelected.toArray(new SelectedContent[0]), tv);
  }
View Full Code Here

  }

 
  // @see com.aelitis.azureus.ui.common.table.TableSelectionListener#defaultSelected(com.aelitis.azureus.ui.common.table.TableRowCore[])
  public void defaultSelected(TableRowCore[] rows, int stateMask) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) tv.getFirstSelectedDataSource();
   
    if ( fileInfo == null ){
      return;
    }
   
    AZ3Functions.provider az3 = AZ3Functions.getProvider();
   
    if ( az3 != null ){
     
      DownloadManager dm = fileInfo.getDownloadManager();
     
      if ( az3.canPlay(dm, fileInfo.getIndex()) || (stateMask & SWT.CONTROL) > 0 ){
       
        az3.play( dm, fileInfo.getIndex() );
       
        return;
      }
    }
   
    if ( fileInfo.getAccessMode() == DiskManagerFileInfo.READ ){
     
      Utils.launch(fileInfo);
    }
  }
View Full Code Here

    try {
      refreshing = true;
      if (tv.isDisposed())
        return;
 
      DiskManagerFileInfo files[] = getFileInfo();

      if (files != null && (this.force_refresh || !doAllExist(files))) {
        this.force_refresh = false;

        List<DiskManagerFileInfo> datasources = tv.getDataSources();
        if(datasources.size() == files.length)
        {
          // check if we actually have to replace anything
          ArrayList<DiskManagerFileInfo> toAdd = new ArrayList<DiskManagerFileInfo>(Arrays.asList(files));
          ArrayList<DiskManagerFileInfo> toRemove = new ArrayList<DiskManagerFileInfo>();
          for(int i = 0;i < datasources.size();i++)
          {
            DiskManagerFileInfo info = datasources.get(i);
           
            if(files[info.getIndex()] == info)
              toAdd.set(info.getIndex(), null);
            else
              toRemove.add(info);
          }
          tv.removeDataSources(toRemove.toArray(new DiskManagerFileInfo[toRemove.size()]));
          tv.addDataSources(toAdd.toArray(new DiskManagerFileInfo[toAdd.size()]));
          ((TableViewSWTImpl)tv).tableInvalidate();
        } else
        {
          tv.removeAllTableRows();
         
          DiskManagerFileInfo filesCopy[] = new DiskManagerFileInfo[files.length];
          System.arraycopy(files, 0, filesCopy, 0, files.length);

          tv.addDataSources(filesCopy);
        }
View Full Code Here

   *
   * @since 3.0.0.7
   */
  private boolean doAllExist(DiskManagerFileInfo[] files) {
    for (int i = 0; i < files.length; i++) {
      DiskManagerFileInfo fileinfo = files[i];

      // We can't just use tv.dataSourceExists(), since it does a .equals()
      // comparison, and we want a reference comparison
      TableRowCore row = tv.getRow(fileinfo);
      if (row == null) {
View Full Code Here

            // by the time dragSetData occurs
            Object[] selectedDownloads = tv.getSelectedDataSources().toArray();
            eventData = "DiskManagerFileInfo\n";
            TOTorrent torrent = manager.getTorrent();
            for (int i = 0; i < selectedDownloads.length; i++) {
              DiskManagerFileInfo fi = (DiskManagerFileInfo) selectedDownloads[i];
             
              try {
                eventData += torrent.getHashWrapper().toBase32String() + ";"
                    + fi.getIndex() + "\n";
              } catch (Exception e) {
              }
            }
          }
View Full Code Here

                try{
                  state.suppressStateSave(true);
                                 
                  for ( int i=0; i<fileInfos.length; i++ ){
                   
                    DiskManagerFileInfo fileInfo = fileInfos[i];
                   
                    File base_file = fileInfo.getFile( false );
                   
                    File existing_link = state.getFileLink( base_file );
                   
                    if ( existing_link == null && base_file.exists()){
                     
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.disk.DiskManagerFileInfo

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.