public void dragGestureRecognized(DragGestureEvent event) {
    if (folderPanel.getMainFrame().getNoEventsMode()) return;

    FileTable fileTable = folderPanel.getFileTable();
    FileTableModel tableModel = fileTable.getFileTableModel();

    // Return (do not initiate drag) if mouse button2 or button3 was used
    if ((event.getTriggerEvent().getModifiers()
            & (InputEvent.BUTTON2_MASK | InputEvent.BUTTON3_MASK))
        != 0) return;

    // Do not use that to retrieve the current selected file as it is inaccurate: the selection
    // could have changed since the
    // the mouse was clicked.
    //        AbstractFile selectedFile = fileTable.getSelectedFile(false);
    //        // Return if selected file is null (could happen if '..' is selected)
    //        if(selectedFile==null)
    //            return;

    // Find out which row was clicked
    int clickedRow = fileTable.rowAtPoint(event.getDragOrigin());
    // Return (do not initiate drag) if the selected file is the parent folder '..'
    if (clickedRow == -1 || fileTable.isParentFolder(clickedRow)) return;

    // Retrieve the file corresponding to the clicked row
    AbstractFile selectedFile = tableModel.getFileAtRow(clickedRow);

    // Find out which files are to be dragged, based on the selected file and currenlty marked
    // files.
    // If there are some files marked, drag marked files only if the selected file is one of the
    // marked files.
    // In any other case, only drag the selected file.
    FileSet markedFiles;
    FileSet draggedFiles;
    if (tableModel.getNbMarkedFiles() > 0
        && (markedFiles = fileTable.getSelectedFiles()).contains(selectedFile)) {
      draggedFiles = markedFiles;
    } else {
      draggedFiles = new FileSet(fileTable.getCurrentFolder(), selectedFile);
    }

    // Set initial DnDContext information
    DnDContext.setDragInitiatedByMucommander(true);
    DnDContext.setDragInitiator(folderPanel);
    DnDContext.setDragGestureModifiersEx(event.getTriggerEvent().getModifiersEx());

    // Start dragging
    DragSource.getDefaultDragSource()
        .startDrag(event, null, new TransferableFileSet(draggedFiles), this);
    //        DragSource.getDefaultDragSource().startDrag(createCustomDragGestureEvent(event,
    // DnDConstants.ACTION_MOVE), null, new TransferableFileSet(draggedFiles), this);
  }
  /**
   * Checks if current file table's folder has changed and if it hasn't, checks if current folder's
   * date has changed and if it has, refresh the file table.
   *
   * @return <code>true</code> if the folder was refreshed.
   */
  private synchronized boolean checkAndRefresh() {
    if (paused || disableAutoRefreshFilter.match(currentFolder)) {
      return false;
    }

    // Update time average next loop
    long timeStamp = System.currentTimeMillis();

    // Check folder's date
    long date = currentFolder.getDate();

    totalCheckTime += System.currentTimeMillis() - timeStamp;
    nbSamples++;

    // Has date changed ?
    // Note that date will be 0 if the folder is no longer available, and thus yield a refresh: this
    // is exactly
    // what we want (the folder will be changed to a 'workable' folder).
    if (date != currentFolderDate) {
      LOGGER.debug(
          this
              + " ("
              + currentFolder.getName()
              + ") Detected changes in current folder, refreshing table!");

      // Try and refresh current folder in a separate thread as to not lock monitor thread
      folderPanel.tryRefreshCurrentFolder();
    }

    if (!forceRefreshFilePath.isEmpty()) {
      synchronized (forceRefreshFilePath) {
        String folderPath = currentFolder.getAbsolutePath();
        for (String path : forceRefreshFilePath) {
          if (path.startsWith(folderPath)) {
            forceRefreshFilePath.remove(path);
            folderPanel.tryRefreshCurrentFolder();
            break;
          }
        }
      }
    }

    return false;
  }
Esempio n. 3
0
 @Override
 protected void show(final int tabIndex) {
   folderPanel.tryChangeCurrentFolderInternal(
       getTab(tabIndex).getLocation(),
       new Callback() {
         public void call() {
           fireActiveTabChanged();
         }
       });
 };
  public FolderChangeMonitor(FolderPanel folderPanel) {
    this.folderPanel = folderPanel;

    // Listen to folder changes to know when a folder is being / has been changed
    folderPanel.getLocationManager().addLocationListener(this);

    this.currentFolder = folderPanel.getCurrentFolder();
    this.currentFolderDate = currentFolder.getDate();

    // Folder contents is up-to-date let's wait before checking it for changes
    this.lastCheckTimestamp = System.currentTimeMillis();
    this.waitBeforeCheckTime = waitAfterRefresh;

    folderPanel.getMainFrame().addWindowListener(this);

    instances.add(this);

    // create and start the monitor thread on first FolderChangeMonitor instance
    if (monitorThread == null && checkPeriod >= 0) {
      monitorThread = new Thread(this, getClass().getName());
      monitorThread.setDaemon(true);
      monitorThread.start();
    }
  }
Esempio n. 5
0
  public FileTableTabs(
      MainFrame mainFrame, FolderPanel folderPanel, ConfFileTableTab[] initialTabs) {
    super(
        new FileTableTabsWithoutHeadersViewerFactory(folderPanel),
        new FileTableTabsWithHeadersViewerFactory(mainFrame, folderPanel));

    this.folderPanel = folderPanel;

    defaultTabsFactory = new DefaultFileTableTabFactory(folderPanel);
    clonedTabsFactory = new ClonedFileTableTabFactory(folderPanel);

    // Register to location change events
    folderPanel.getLocationManager().addLocationListener(this);

    // Add the initial folders
    for (FileTableTab tab : initialTabs) addTab(clonedTabsFactory.createTab(tab));
  }
Esempio n. 6
0
 public void locationFailed(LocationEvent locationEvent) {
   updateTabLocation(folderPanel.getCurrentFolder().getURL());
 }