Search in sources :

Example 26 with UIInputReceiverListener

use of com.biglybt.pif.ui.UIInputReceiverListener in project BiglyBT by BiglySoftware.

the class TableViewPainted method openFilterDialog.

@Override
public void openFilterDialog() {
    if (filter == null) {
        return;
    }
    SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow();
    entryWindow.initTexts("MyTorrentsView.dialog.setFilter.title", null, "MyTorrentsView.dialog.setFilter.text", new String[] { MessageText.getString(getTableID() + "View" + ".header") });
    entryWindow.setPreenteredText(filter.text, false);
    entryWindow.prompt(new UIInputReceiverListener() {

        @Override
        public void UIInputReceiverClosed(UIInputReceiver entryWindow) {
            if (!entryWindow.hasSubmittedInput()) {
                return;
            }
            String message = entryWindow.getSubmittedInput();
            if (message == null) {
                message = "";
            }
            setFilterText(message);
        }
    });
}
Also used : SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener)

Example 27 with UIInputReceiverListener

use of com.biglybt.pif.ui.UIInputReceiverListener in project BiglyBT by BiglySoftware.

the class TorrentUtil method repositionManual.

public static void repositionManual(final TableView tv, final DownloadManager[] dms, final Shell shell, final boolean isSeedingView) {
    SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("MyTorrentsView.dialog.setPosition.title", "MyTorrentsView.dialog.setPosition.text");
    entryWindow.prompt(new UIInputReceiverListener() {

        @Override
        public void UIInputReceiverClosed(UIInputReceiver entryWindow) {
            if (!entryWindow.hasSubmittedInput()) {
                return;
            }
            String sReturn = entryWindow.getSubmittedInput();
            if (sReturn == null)
                return;
            int newPosition = -1;
            try {
                newPosition = Integer.valueOf(sReturn).intValue();
            } catch (NumberFormatException er) {
            // Ignore
            }
            Core core = CoreFactory.getSingleton();
            if (core == null) {
                return;
            }
            int size = core.getGlobalManager().downloadManagerCount(isSeedingView);
            if (newPosition > size)
                newPosition = size;
            if (newPosition <= 0) {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setText(MessageText.getString("MyTorrentsView.dialog.NumberError.title"));
                mb.setMessage(MessageText.getString("MyTorrentsView.dialog.NumberError.text"));
                mb.open();
                return;
            }
            moveSelectedTorrentsTo(tv, dms, newPosition);
        }
    });
}
Also used : UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) Core(com.biglybt.core.Core) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Example 28 with UIInputReceiverListener

use of com.biglybt.pif.ui.UIInputReceiverListener in project BiglyBT by BiglySoftware.

the class TorrentUtil method promptUserForDescription.

public static void promptUserForDescription(final DownloadManager[] dms) {
    if (dms.length == 0) {
        return;
    }
    DownloadManager dm = dms[0];
    String desc = null;
    try {
        desc = PlatformTorrentUtils.getContentDescription(dm.getTorrent());
        if (desc == null) {
            desc = "";
        }
    } catch (Throwable e) {
    }
    String msg_key_prefix = "MyTorrentsView.menu.edit_description.enter.";
    SimpleTextEntryWindow text_entry = new SimpleTextEntryWindow();
    text_entry.setTitle(msg_key_prefix + "title");
    text_entry.setMessage(msg_key_prefix + "message");
    text_entry.setPreenteredText(desc, false);
    text_entry.setMultiLine(true);
    text_entry.setWidthHint(500);
    text_entry.setLineHeight(16);
    text_entry.prompt(new UIInputReceiverListener() {

        @Override
        public void UIInputReceiverClosed(UIInputReceiver text_entry) {
            if (text_entry.hasSubmittedInput()) {
                String value = text_entry.getSubmittedInput();
                final String value_to_set = (value.length() == 0) ? null : value;
                ListenerDMTask task = new ListenerDMTask(dms) {

                    @Override
                    public void run(DownloadManager dm) {
                        PlatformTorrentUtils.setContentDescription(dm.getTorrent(), value_to_set);
                    }
                };
                task.go();
            }
        }
    });
}
Also used : UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 29 with UIInputReceiverListener

use of com.biglybt.pif.ui.UIInputReceiverListener in project BiglyBT by BiglySoftware.

the class TorrentUtil method pauseDownloadsFor.

protected static void pauseDownloadsFor(DownloadManager[] dms) {
    final List<DownloadManager> dms_to_pause = new ArrayList<>();
    for (int i = 0; i < dms.length; i++) {
        DownloadManager dm = dms[i];
        if (ManagerUtils.isPauseable(dm)) {
            dms_to_pause.add(dm);
        }
    }
    if (dms_to_pause.size() == 0) {
        return;
    }
    String text = MessageText.getString("dialog.pause.for.period.text");
    SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("dialog.pause.for.period.title", "!" + text + "!");
    int def = COConfigurationManager.getIntParameter("pause.for.period.default", 10);
    entryWindow.setPreenteredText(String.valueOf(def), false);
    entryWindow.prompt(new UIInputReceiverListener() {

        @Override
        public void UIInputReceiverClosed(UIInputReceiver entryWindow) {
            if (!entryWindow.hasSubmittedInput()) {
                return;
            }
            String sReturn = entryWindow.getSubmittedInput();
            if (sReturn == null) {
                return;
            }
            int mins = -1;
            try {
                mins = Integer.valueOf(sReturn).intValue();
            } catch (NumberFormatException er) {
            // Ignore
            }
            if (mins <= 0) {
                MessageBox mb = new MessageBox(Utils.findAnyShell(), SWT.ICON_ERROR | SWT.OK);
                mb.setText(MessageText.getString("MyTorrentsView.dialog.NumberError.title"));
                mb.setMessage(MessageText.getString("MyTorrentsView.dialog.NumberError.text"));
                mb.open();
                return;
            }
            COConfigurationManager.setParameter("pause.for.period.default", mins);
            ManagerUtils.asyncPauseForPeriod(dms_to_pause, mins * 60);
        }
    });
}
Also used : UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

UIInputReceiver (com.biglybt.pif.ui.UIInputReceiver)29 UIInputReceiverListener (com.biglybt.pif.ui.UIInputReceiverListener)29 SimpleTextEntryWindow (com.biglybt.ui.swt.SimpleTextEntryWindow)21 DownloadManager (com.biglybt.core.download.DownloadManager)8 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)8 CoreRunningListener (com.biglybt.core.CoreRunningListener)7 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)6 TrackerEditorListener (com.biglybt.ui.swt.maketorrent.TrackerEditorListener)6 DisposeEvent (org.eclipse.swt.events.DisposeEvent)6 DisposeListener (org.eclipse.swt.events.DisposeListener)6 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)5 List (java.util.List)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)3 MenuBuildUtils (com.biglybt.ui.swt.MenuBuildUtils)3 Core (com.biglybt.core.Core)2 MessageText (com.biglybt.core.internat.MessageText)2 PEPeer (com.biglybt.core.peer.PEPeer)2 PEPeerManager (com.biglybt.core.peer.PEPeerManager)2 TagProperty (com.biglybt.core.tag.TagFeatureProperties.TagProperty)2