Search in sources :

Example 21 with ActivitiesEntry

use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.

the class SBC_ActivityTableView method removeEntries.

private void removeEntries(final ActivitiesEntry[] toRemove, final int startIndex) {
    final ActivitiesEntry entry = toRemove[startIndex];
    if (entry == null || ActivitiesConstants.TYPEID_HEADER.equals(entry.getTypeID())) {
        int nextIndex = startIndex + 1;
        if (nextIndex < toRemove.length) {
            removeEntries(toRemove, nextIndex);
        }
        return;
    }
    MessageBoxShell mb = new MessageBoxShell(MessageText.getString("v3.activity.remove.title"), MessageText.getString("v3.activity.remove.text", new String[] { entry.getText() }));
    mb.setRemember(tableID + "-Remove", false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
    if (startIndex == toRemove.length - 1) {
        mb.setButtons(0, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, new Integer[] { 0, 1 });
        mb.setRememberOnlyIfButton(0);
    } else {
        mb.setButtons(1, new String[] { MessageText.getString("Button.removeAll"), MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, new Integer[] { 2, 0, 1 });
        mb.setRememberOnlyIfButton(1);
    }
    mb.setHandleHTML(false);
    mb.open(new UserPrompterResultListener() {

        @Override
        public void prompterClosed(int result) {
            if (result == 2) {
                int numToRemove = toRemove.length - startIndex;
                ActivitiesEntry[] toGroupRemove = new ActivitiesEntry[numToRemove];
                System.arraycopy(toRemove, startIndex, toGroupRemove, 0, numToRemove);
                ActivitiesManager.removeEntries(toGroupRemove);
                return;
            } else if (result == 0) {
                ActivitiesManager.removeEntries(new ActivitiesEntry[] { entry });
            }
            int nextIndex = startIndex + 1;
            if (nextIndex < toRemove.length) {
                removeEntries(toRemove, nextIndex);
            }
        }
    });
}
Also used : UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell)

Aggregations

ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)21 GCStringPrinter (com.biglybt.ui.swt.shells.GCStringPrinter)4 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)4 List (java.util.List)4 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)3 URLInfo (com.biglybt.ui.swt.shells.GCStringPrinter.URLInfo)3 Image (org.eclipse.swt.graphics.Image)3 DownloadManager (com.biglybt.core.download.DownloadManager)2 TOTorrent (com.biglybt.core.torrent.TOTorrent)2 DiskManagerFileInfo (com.biglybt.pif.disk.DiskManagerFileInfo)2 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)2 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)2 TableCellSWT (com.biglybt.ui.swt.views.table.TableCellSWT)2 ArrayList (java.util.ArrayList)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 ActivitiesListener (com.biglybt.activities.ActivitiesListener)1 TranscodeFile (com.biglybt.core.devices.TranscodeFile)1 TranscodeJob (com.biglybt.core.devices.TranscodeJob)1 GlobalManager (com.biglybt.core.global.GlobalManager)1 PlatformMessage (com.biglybt.core.messenger.PlatformMessage)1