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);
}
});
}
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);
}
});
}
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();
}
}
});
}
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);
}
});
}
Aggregations