use of com.biglybt.ui.UserPrompterResultListener in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method showDownloadFTUX.
protected static void showDownloadFTUX(SearchSubsResultBase entry, final UserPrompterResultListener listener) {
if (entry instanceof SBC_SubscriptionResult) {
listener.prompterClosed(0);
return;
}
if (RememberedDecisionsManager.getRememberedDecision("searchsubs.dl.ftux") == 1) {
listener.prompterClosed(0);
return;
}
final VuzeMessageBox box = new VuzeMessageBox(MessageText.getString("searchsubs.dl.ftux.title"), null, new String[] { MessageText.getString("Button.ok"), MessageText.getString("Button.cancel") }, 0);
box.setSubTitle(MessageText.getString("searchsubs.dl.ftux.heading"));
final boolean[] check_state = new boolean[] { true };
box.setListener(new VuzeMessageBoxListener() {
@Override
public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
SWTSkin skin = soExtra.getSkin();
addResourceBundle(skin, "com/biglybt/ui/swt/columns/searchsubs/", "skin3_dl_ftux");
String id = "searchsubs.dlftux.shell";
skin.createSkinObject(id, id, soExtra);
final SWTSkinObjectCheckbox cb = (SWTSkinObjectCheckbox) skin.getSkinObject("agree-checkbox");
cb.setChecked(true);
cb.addSelectionListener(new SWTSkinCheckboxListener() {
@Override
public void checkboxChanged(SWTSkinObjectCheckbox so, boolean checked) {
check_state[0] = checked;
}
});
}
});
box.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (result == 0 && check_state[0]) {
RememberedDecisionsManager.setRemembered("searchsubs.dl.ftux", 1);
}
listener.prompterClosed(result);
}
});
}
use of com.biglybt.ui.UserPrompterResultListener in project BiglyBT by BiglySoftware.
the class SimplePluginInstallWindow method open.
public void open() {
box = new VuzeMessageBox("", "", null, 0);
box.setSubTitle(MessageText.getString(resource_prefix + ".subtitle"));
box.addResourceBundle(SimplePluginInstallWindow.class, SkinPropertiesImpl.PATH_SKIN_DEFS, "skin3_dlg_register");
box.setIconResource(resource_prefix + ".image");
this.progressText = MessageText.getString(resource_prefix + ".description");
box.setListener(new VuzeMessageBoxListener() {
@Override
public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
SWTSkin skin = soExtra.getSkin();
skin.createSkinObject("dlg.register.install", "dlg.register.install", soExtra);
SWTSkinObjectContainer soProgressBar = (SWTSkinObjectContainer) skin.getSkinObject("progress-bar");
if (soProgressBar != null) {
progressBar = new ProgressBar(soProgressBar.getComposite(), SWT.HORIZONTAL);
progressBar.setMinimum(0);
progressBar.setMaximum(100);
progressBar.setLayoutData(Utils.getFilledFormData());
}
soInstallPct = (SWTSkinObjectText) skin.getSkinObject("install-pct");
soProgressText = (SWTSkinObjectText) skin.getSkinObject("progress-text");
if (soProgressText != null && progressText != null) {
soProgressText.setText(progressText);
}
}
});
box.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
installer.setListener(null);
try {
installer.cancel();
} catch (Exception e) {
Debug.out(e);
}
}
});
}
use of com.biglybt.ui.UserPrompterResultListener in project BiglyBT by BiglySoftware.
the class Initializer method run.
@Override
public void run() {
DelayedTask delayed_task = UtilitiesImpl.addDelayedTask("SWT Initialisation", new Runnable() {
@Override
public void run() {
init_task.reserve();
}
});
delayed_task.queueFirst();
// initialise the SWT locale util
long startTime = SystemTime.getCurrentTime();
new LocaleUtilSWT(core);
final Display display = Utils.getDisplay();
new UIMagnetHandler(core);
if (!STARTUP_UIFIRST) {
// Ensure colors initialized
Colors.getInstance();
UIConfigDefaultsSWT.initialize();
UIConfigDefaultsSWTv3.initialize(core);
} else {
COConfigurationManager.setBooleanDefault("Show Splash", false);
}
if (COConfigurationManager.getBooleanParameter("Show Splash")) {
display.asyncExec(new AERunnable() {
@Override
public void runSupport() {
new SplashWindow(display, Initializer.this);
}
});
}
System.out.println("Locale Initializing took " + (SystemTime.getCurrentTime() - startTime) + "ms");
startTime = SystemTime.getCurrentTime();
core.addLifecycleListener(new CoreLifecycleAdapter() {
@Override
public void componentCreated(Core core, CoreComponent component) {
Initializer.this.reportPercent(curPercent + 1);
if (component instanceof GlobalManager) {
reportCurrentTaskByKey("splash.initializePlugins");
InitialisationFunctions.earlyInitialisation(core);
} else if (component instanceof PluginInterface) {
PluginInterface pi = (PluginInterface) component;
String name = pi.getPluginName();
String version = pi.getPluginVersion();
// text says initializing, but it's actually initialized. close enough
String s = MessageText.getString("splash.plugin.init") + " " + name + (version == null ? "" : (" v" + version));
reportCurrentTask(s);
}
}
// @see com.biglybt.core.CoreLifecycleAdapter#started(com.biglybt.core.Core)
@Override
public void started(Core core) {
handleCoreStarted(core);
}
@Override
public void stopping(Core core) {
Alerts.stopInitiated();
}
@Override
public void stopped(Core core) {
}
@Override
public boolean syncInvokeRequired() {
return (true);
}
@Override
public boolean requiresPluginInitCompleteBeforeStartedEvent() {
return (false);
}
@Override
public boolean stopRequested(Core _core) throws CoreException {
return handleStopRestart(false);
}
@Override
public boolean restartRequested(final Core core) {
return handleStopRestart(true);
}
});
reportCurrentTaskByKey("splash.initializeCore");
boolean uiClassic = COConfigurationManager.getStringParameter("ui").equals("az2");
try {
new SearchUI();
} catch (Throwable e) {
Debug.printStackTrace(e);
}
try {
subscriptionManagerUI = new SubscriptionManagerUI();
} catch (Throwable e) {
Debug.printStackTrace(e);
}
if (!uiClassic) {
try {
deviceManagerUI = new DeviceManagerUI(core);
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
if (core.canStart()) {
// Other UIs could start the core before us
if (!core.isStarted()) {
core.start();
} else {
handleCoreStarted(core);
}
reportPercent(50);
System.out.println("Core Initializing took " + (SystemTime.getCurrentTime() - startTime) + "ms");
startTime = SystemTime.getCurrentTime();
reportCurrentTaskByKey("splash.initializeUIElements");
// Ensure colors initialized
Colors.getInstance();
reportPercent(curPercent + 1);
Alerts.init();
reportPercent(curPercent + 1);
ProgressWindow.register(core);
reportPercent(curPercent + 1);
new SWTNetworkSelection();
reportPercent(curPercent + 1);
new AuthenticatorWindow();
new CryptoWindow();
reportPercent(curPercent + 1);
new CertificateTrustWindow();
core.getPluginManager().getPluginInstaller().addListener(new PluginInstallerListener() {
@Override
public boolean installRequest(final String reason, final InstallablePlugin plugin) throws PluginException {
if (plugin instanceof StandardPlugin) {
Map<Integer, Object> properties = new HashMap<>();
properties.put(UpdateCheckInstance.PT_UI_EXTRA_MESSAGE, reason);
plugin.install(false, false, false, properties);
return (true);
} else {
return (false);
}
}
});
} else {
CoreWaiterSWT.startupAbandoned();
final AESemaphore sem = new AESemaphore("waiter");
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("msgbox.force.close.title"), MessageText.getString("msgbox.force.close.text", new String[] { core.getLockFile().getAbsolutePath() }), new String[] { MessageText.getString("Button.ok") }, 0);
mb.setIconResource("error");
mb.setModal(true);
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
sem.releaseForever();
}
});
}
});
sem.reserve();
SESecurityManager.exitVM(1);
}
}
use of com.biglybt.ui.UserPrompterResultListener in project BiglyBT by BiglySoftware.
the class TorrentUtil method removeDownloadStubs.
public static void removeDownloadStubs(final DownloadStubEx[] dms, final AERunnable deleteFailed, final boolean forcePrompt) {
if (dms == null) {
return;
}
for (int i = 0; i < dms.length; i++) {
DownloadStubEx dm = dms[i];
boolean deleteTorrent = COConfigurationManager.getBooleanParameter("def.deletetorrent");
int confirm = COConfigurationManager.getIntParameter("tb.confirm.delete.content");
boolean doPrompt = confirm == 0 | forcePrompt;
if (doPrompt) {
String title = MessageText.getString("deletedata.title");
String text = MessageText.getString("v3.deleteContent.message", new String[] { dm.getName() });
String[] buttons;
int defaultButtonPos;
buttons = new String[] { MessageText.getString("Button.cancel"), MessageText.getString("Button.deleteContent.fromComputer"), MessageText.getString("Button.deleteContent.fromLibrary") };
/*
int[] buttonVals = new int[] {
SWT.CANCEL,
1,
2
};
*/
defaultButtonPos = 2;
final MessageBoxShell mb = new MessageBoxShell(title, text, buttons, defaultButtonPos);
int numLeft = (dms.length - i);
if (numLeft > 1) {
mb.setRemember("na", false, MessageText.getString("v3.deleteContent.applyToAll", new String[] { "" + numLeft }));
// never store remember state
mb.setRememberOnlyIfButton(-3);
}
mb.setRelatedObject(dm);
mb.setLeftImage("image.trash");
mb.addCheckBox("deletecontent.also.deletetorrent", 2, deleteTorrent);
final int index = i;
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
ImageLoader.getInstance().releaseImage("image.trash");
removeDownloadStubsPrompterClosed(dms, index, deleteFailed, result, mb.isRemembered(), mb.getCheckBoxEnabled());
}
});
return;
} else {
boolean deleteData = confirm == 1;
removeDownloadStubsPrompterClosed(dms, i, deleteFailed, deleteData ? 1 : 2, true, deleteTorrent);
}
}
}
use of com.biglybt.ui.UserPrompterResultListener in project BiglyBT by BiglySoftware.
the class TorrentUtil method isFileTorrent.
/**
* quick check to see if a file might be a torrent
* @param torrentFile
* @return
*
* @since 3.0.2.3
*/
public static boolean isFileTorrent(String originatingLocation, File torrentFile, String torrentName, boolean warnOnError) {
String sFirstChunk = null;
try {
sFirstChunk = FileUtil.readFileAsString(torrentFile, 16384).toLowerCase();
try {
if (!sFirstChunk.startsWith("d")) {
sFirstChunk = FileUtil.readGZippedFileAsString(torrentFile, 16384).toLowerCase();
}
} catch (Throwable e) {
}
} catch (IOException e) {
Debug.out("warning", e);
}
if (sFirstChunk == null) {
sFirstChunk = "";
}
if (!sFirstChunk.startsWith("d")) {
boolean isHTML = sFirstChunk.contains("<html");
String retry_url = UrlUtils.parseTextForMagnets(torrentName);
if (retry_url == null) {
retry_url = UrlUtils.parseTextForMagnets(sFirstChunk);
}
if (retry_url != null) {
TorrentOpener.openTorrent(retry_url);
return false;
}
if (warnOnError) {
String[] buttons;
String chat_key = null;
String chat_net = null;
if (originatingLocation != null && originatingLocation.toLowerCase(Locale.US).startsWith("http")) {
try {
URL url = new URL(originatingLocation);
String host = url.getHost();
String interesting = DNSUtils.getInterestingHostSuffix(host);
if (interesting != null) {
String net = AENetworkClassifier.categoriseAddress(host);
if ((net == AENetworkClassifier.AT_PUBLIC && BuddyPluginUtils.isBetaChatAvailable()) || (net == AENetworkClassifier.AT_I2P && BuddyPluginUtils.isBetaChatAnonAvailable())) {
chat_key = "Torrent Error: " + interesting;
chat_net = net;
}
}
} catch (Throwable e) {
}
}
if (chat_key == null) {
buttons = new String[] { MessageText.getString("Button.ok") };
} else {
buttons = new String[] { MessageText.getString("label.chat"), MessageText.getString("Button.ok") };
}
MessageBoxShell boxShell = new MessageBoxShell(MessageText.getString("OpenTorrentWindow.mb.notTorrent.title"), MessageText.getString("OpenTorrentWindow.mb.notTorrent.text", new String[] { torrentName, isHTML ? "" : MessageText.getString("OpenTorrentWindow.mb.notTorrent.cannot.display") }), buttons, buttons.length - 1);
if (isHTML) {
boxShell.setHtml(sFirstChunk);
}
final String f_chat_key = chat_key;
final String f_chat_net = chat_net;
boxShell.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (f_chat_key != null && result == 0) {
BuddyPluginUtils.createBetaChat(f_chat_net, f_chat_key, new BuddyPluginUtils.CreateChatCallback() {
@Override
public void complete(ChatInstance chat) {
if (chat != null) {
chat.setInteresting(true);
}
}
});
}
}
});
}
return false;
}
return true;
}
Aggregations