use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.
the class DownloadManagerImpl method stubbify.
protected DownloadStub stubbify(DownloadImpl download) throws DownloadException, DownloadRemovalVetoException {
if (!canStubbify(download)) {
throw (new DownloadException("Download not in stubbifiable state"));
}
DownloadManager core_dm = PluginCoreUtils.unwrap(download);
Map<String, Object> gm_data = global_manager.exportDownloadStateToMap(core_dm);
try {
gm_data = BDecoder.decode(BEncoder.encode(gm_data));
} catch (IOException e) {
Debug.out(e);
}
String[] manual_tags = null;
if (tag_manager.isEnabled()) {
List<Tag> tag_list = tag_manager.getTagType(TagType.TT_DOWNLOAD_MANUAL).getTagsForTaggable(core_dm);
if (tag_list != null && tag_list.size() > 0) {
// hack to remove the restored tag name here as auto-added during restore
String restored_tag_name = MessageText.getString("label.restored");
tag_list = new ArrayList<>(tag_list);
Iterator<Tag> it = tag_list.iterator();
while (it.hasNext()) {
Tag t = it.next();
if (t.isTagAuto()[0]) {
// ignore auto_add tags
it.remove();
} else if (t.getTagName(true).equals(restored_tag_name)) {
it.remove();
}
}
if (tag_list.size() > 0) {
manual_tags = new String[tag_list.size()];
for (int i = 0; i < manual_tags.length; i++) {
manual_tags[i] = tag_list.get(i).getTagName(true);
}
Arrays.sort(manual_tags);
}
}
}
DownloadStubImpl stub = new DownloadStubImpl(this, download, manual_tags, gm_data);
try {
informAdded(stub, true);
} finally {
stub.setStubbified();
}
boolean added = false;
try {
core_dm.getDownloadState().exportState(ARCHIVE_DIR);
download.remove(false, false);
synchronized (download_stubs) {
download_stubs.add(stub);
download_stub_map.put(stub.getTorrentHash(), stub);
writeStubConfig();
}
added = true;
informAdded(stub, false);
} finally {
if (!added) {
// inform that the 'will be added' failed
informRemoved(stub, true);
}
}
return (stub);
}
use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.
the class Show method printTorrentDetails.
/**
* prints out the full details of a particular torrent
* @param out
* @param dm
* @param torrentNum
*/
private static void printTorrentDetails(PrintStream out, DownloadManager dm, int torrentNum, List<String> args) {
String name = dm.getDisplayName();
if (name == null)
name = "?";
out.println("> -----");
out.println("Info on Torrent #" + torrentNum + " (" + name + ")");
out.println("- General Info -");
String[] health = { "- no info -", "stopped", "no remote connections", "no tracker", "OK", "ko" };
try {
out.println("Health: " + health[dm.getHealthStatus()]);
} catch (Exception e) {
out.println("Health: " + health[0]);
}
out.println("State: " + Integer.toString(dm.getState()));
if (dm.getState() == DownloadManager.STATE_ERROR)
out.println("Error: " + dm.getErrorDetails());
out.println("Hash: " + TorrentUtils.nicePrintTorrentHash(dm.getTorrent(), true));
out.println("- Torrent file -");
out.println("Torrent Filename: " + dm.getTorrentFileName());
out.println("Saving to: " + dm.getSaveLocation());
out.println("Created By: " + dm.getTorrentCreatedBy());
out.println("Comment: " + dm.getTorrentComment());
Category cat = dm.getDownloadState().getCategory();
if (cat != null) {
out.println("Category: " + cat.getName());
}
List<Tag> tags = TagManagerFactory.getTagManager().getTagsForTaggable(TagType.TT_DOWNLOAD_MANUAL, dm);
String tags_str;
if (tags.size() == 0) {
tags_str = "None";
} else {
tags_str = "";
for (Tag t : tags) {
tags_str += (tags_str.length() == 0 ? "" : ",") + t.getTagName(true);
}
}
out.println("Tags: " + tags_str);
out.println("- Tracker Info -");
TRTrackerAnnouncer trackerclient = dm.getTrackerClient();
if (trackerclient != null) {
out.println("URL: " + trackerclient.getTrackerURL());
String timestr;
try {
int time = trackerclient.getTimeUntilNextUpdate();
if (time < 0) {
timestr = MessageText.getString("GeneralView.label.updatein.querying");
} else {
int minutes = time / 60;
int seconds = time % 60;
String strSeconds = "" + seconds;
if (seconds < 10) {
// $NON-NLS-1$
strSeconds = "0" + seconds;
}
timestr = minutes + ":" + strSeconds;
}
} catch (Exception e) {
timestr = "unknown";
}
out.println("Time till next Update: " + timestr);
out.println("Status: " + trackerclient.getStatusString());
} else
out.println(" Not available");
out.println("- Files Info -");
DiskManagerFileInfo[] files = dm.getDiskManagerFileInfo();
if (files != null) {
for (int i = 0; i < files.length; i++) {
out.print(((i < 9) ? " " : " ") + Integer.toString(i + 1) + " (");
String tmp = ">";
if (files[i].getPriority() > 0)
tmp = "+";
if (files[i].isSkipped())
tmp = "!";
out.print(tmp + ") ");
if (files[i] != null) {
long fLen = files[i].getLength();
if (fLen > 0) {
DecimalFormat df = new DecimalFormat("000.0%");
out.print(df.format(files[i].getDownloaded() * 1.0 / fLen));
out.println("\t" + files[i].getFile(true).getName());
} else
out.println("Info not available.");
} else
out.println("Info not available.");
}
} else {
out.println(" Info not available.");
}
for (String arg : args) {
arg = arg.toLowerCase();
if (arg.startsWith("pie")) {
out.println("Pieces");
PEPeerManager pm = dm.getPeerManager();
if (pm != null) {
PiecePicker picker = pm.getPiecePicker();
PEPiece[] pieces = pm.getPieces();
String line = "";
for (int i = 0; i < pieces.length; i++) {
String str = picker.getPieceString(i);
line += (line.length() == 0 ? (i + " ") : ",") + str;
PEPiece piece = pieces[i];
if (piece != null) {
line += ":" + piece.getString();
}
if ((i + 1) % 10 == 0) {
out.println(line);
line = "";
}
}
if (line.length() > 0) {
out.println(line);
}
}
} else if (arg.startsWith("pee")) {
out.println("Peers");
PEPeerManager pm = dm.getPeerManager();
if (pm != null) {
List<PEPeer> peers = pm.getPeers();
out.println("\tConnected to " + peers.size() + " peers");
for (PEPeer peer : peers) {
PEPeerStats stats = peer.getStats();
System.out.println("\t\t" + peer.getIp() + ", in=" + (peer.isIncoming() ? "Y" : "N") + ", prot=" + peer.getProtocol() + ", choked=" + (peer.isChokingMe() ? "Y" : "N") + ", up=" + DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataSendRate() + stats.getProtocolSendRate()) + ", down=" + DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataReceiveRate() + stats.getProtocolReceiveRate()) + ", in_req=" + peer.getIncomingRequestCount() + ", out_req=" + peer.getOutgoingRequestCount());
}
}
}
}
out.println("> -----");
}
use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.
the class SBC_LibraryView method skinObjectInitialShow.
// @see SkinView#showSupport(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(final SWTSkinObject skinObject, Object params) {
selectedContentListener = new SelectedContentListener() {
@Override
public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewId) {
selection_count = currentContent.length;
long total_size = 0;
long total_done = 0;
ArrayList<DownloadManager> dms = new ArrayList<>(currentContent.length);
for (ISelectedContent sc : currentContent) {
DownloadManager dm = sc.getDownloadManager();
if (dm != null) {
dms.add(dm);
int file_index = sc.getFileIndex();
if (file_index == -1) {
DiskManagerFileInfo[] file_infos = dm.getDiskManagerFileInfoSet().getFiles();
for (DiskManagerFileInfo file_info : file_infos) {
if (!file_info.isSkipped()) {
total_size += file_info.getLength();
total_done += file_info.getDownloaded();
}
}
} else {
DiskManagerFileInfo file_info = dm.getDiskManagerFileInfoSet().getFiles()[file_index];
if (!file_info.isSkipped()) {
total_size += file_info.getLength();
total_done += file_info.getDownloaded();
}
}
}
}
selection_size = total_size;
selection_done = total_done;
selection_dms = dms.toArray(new DownloadManager[dms.size()]);
SB_Transfers transfers = MainMDISetup.getSb_transfers();
if (transfers != null) {
transfers.triggerCountRefreshListeners();
}
}
};
SelectedContentManager.addCurrentlySelectedContentListener(selectedContentListener);
soWait = null;
try {
soWait = getSkinObject("library-wait");
soWaitProgress = getSkinObject("library-wait-progress");
soWaitTask = (SWTSkinObjectText) getSkinObject("library-wait-task");
if (soWaitProgress != null) {
soWaitProgress.getControl().addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
assert e != null;
Control c = (Control) e.widget;
Point size = c.getSize();
e.gc.setBackground(ColorCache.getColor(e.display, "#23a7df"));
int breakX = size.x * waitProgress / 100;
e.gc.fillRectangle(0, 0, breakX, size.y);
e.gc.setBackground(ColorCache.getColor(e.display, "#cccccc"));
e.gc.fillRectangle(breakX, 0, size.x - breakX, size.y);
}
});
}
soLibraryInfo = (SWTSkinObjectText) getSkinObject("library-info");
if (soLibraryInfo != null) {
MainMDISetup.getSb_transfers().addCountRefreshListener(new SB_Transfers.countRefreshListener() {
final Map<Composite, ExtraInfoProvider> extra_info_map = new HashMap<>();
{
soLibraryInfo.getControl().getParent().setData("ViewUtils:ViewTitleExtraInfo", new ViewUtils.ViewTitleExtraInfo() {
@Override
public void update(Composite reporter, int count, int active) {
ExtraInfoProvider provider = getProvider(reporter);
if (provider == null) {
return;
}
if (provider.value != count || provider.active != active) {
provider.value = count;
provider.active = active;
if (viewMode == provider.view_mode && provider.enabled) {
MainMDISetup.getSb_transfers().triggerCountRefreshListeners();
}
}
}
@Override
public void setEnabled(Composite reporter, boolean enabled) {
ExtraInfoProvider provider = getProvider(reporter);
if (provider == null) {
return;
}
if (provider.enabled != enabled) {
provider.enabled = enabled;
if (viewMode == provider.view_mode) {
MainMDISetup.getSb_transfers().triggerCountRefreshListeners();
}
}
}
private ExtraInfoProvider getProvider(Composite reporter) {
synchronized (extra_info_map) {
ExtraInfoProvider provider = extra_info_map.get(reporter);
if (provider != null) {
return (provider);
}
Composite temp = reporter;
while (temp != null) {
Integer vm = (Integer) temp.getData("SBC_LibraryView:ViewMode");
if (vm != null) {
provider = new ExtraInfoProvider(vm);
extra_info_map.put(reporter, provider);
return (provider);
}
temp = temp.getParent();
}
Debug.out("No view mode found for " + reporter);
return (null);
}
}
});
}
// @see SBC_LibraryView.countRefreshListener#countRefreshed(SBC_LibraryView.stats, SBC_LibraryView.stats)
@Override
public void countRefreshed(SB_Transfers.stats statsWithLowNoise, SB_Transfers.stats statsNoLowNoise) {
SB_Transfers.stats stats = viewMode == MODE_SMALLTABLE ? statsWithLowNoise : statsNoLowNoise;
String s;
if (torrentFilterMode == TORRENTS_ALL || (datasource instanceof Tag)) {
if (datasource instanceof Category) {
Category cat = (Category) datasource;
String id = "library.category.header";
s = MessageText.getString(id, new String[] { (cat.getType() != Category.TYPE_USER) ? MessageText.getString(cat.getName()) : cat.getName() });
} else if (datasource instanceof Tag) {
Tag tag = (Tag) datasource;
String id = "library.tag.header";
s = MessageText.getString(id, new String[] { tag.getTagName(true) });
String desc = tag.getDescription();
if (desc != null) {
s += " - " + desc;
}
} else {
String id = "library.all.header";
if (stats.numComplete + stats.numIncomplete != 1) {
id += ".p";
}
s = MessageText.getString(id, new String[] { String.valueOf(stats.numComplete + stats.numIncomplete), String.valueOf(stats.numSeeding + stats.numDownloading) });
if (stats.numQueued > 0) {
s += ", " + MessageText.getString("label.num_queued", new String[] { String.valueOf(stats.numQueued) });
}
}
} else if (torrentFilterMode == TORRENTS_INCOMPLETE) {
String id = "library.incomplete.header";
if (stats.numDownloading != 1) {
id += ".p";
}
int numWaiting = Math.max(stats.numIncomplete - stats.numDownloading, 0);
s = MessageText.getString(id, new String[] { String.valueOf(stats.numDownloading), String.valueOf(numWaiting) });
} else if (torrentFilterMode == TORRENTS_UNOPENED || torrentFilterMode == TORRENTS_COMPLETE) {
// complete filtering currently uses same display text as unopened
String id = "library.unopened.header";
if (stats.numUnOpened != 1) {
id += ".p";
}
s = MessageText.getString(id, new String[] { String.valueOf(stats.numUnOpened) });
} else {
s = "";
}
synchronized (extra_info_map) {
int filter_total = 0;
int filter_active = 0;
boolean filter_enabled = false;
for (ExtraInfoProvider provider : extra_info_map.values()) {
if (viewMode == provider.view_mode) {
if (provider.enabled) {
filter_enabled = true;
filter_total += provider.value;
filter_active += provider.active;
}
}
}
if (filter_enabled) {
String extra = MessageText.getString("filter.header.matches2", new String[] { String.valueOf(filter_total), String.valueOf(filter_active) });
s += " " + extra;
}
}
SB_Transfers transfers = MainMDISetup.getSb_transfers();
if (selection_count > 1) {
s += ", " + MessageText.getString("label.num_selected", new String[] { String.valueOf(selection_count) });
String size_str = null;
String rate_str = null;
if (selection_size > 0) {
if (selection_size == selection_done) {
size_str = DisplayFormatters.formatByteCountToKiBEtc(selection_size);
} else {
size_str = DisplayFormatters.formatByteCountToKiBEtc(selection_done) + "/" + DisplayFormatters.formatByteCountToKiBEtc(selection_size);
}
}
DownloadManager[] dms = selection_dms;
if (transfers.header_show_rates && dms.length > 1) {
long total_data_up = 0;
long total_prot_up = 0;
long total_data_down = 0;
long total_prot_down = 0;
for (DownloadManager dm : dms) {
DownloadManagerStats dm_stats = dm.getStats();
total_prot_up += dm_stats.getProtocolSendRate();
total_data_up += dm_stats.getDataSendRate();
total_prot_down += dm_stats.getProtocolReceiveRate();
total_data_down += dm_stats.getDataReceiveRate();
}
rate_str = MessageText.getString("ConfigView.download.abbreviated") + DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(total_data_down, total_prot_down) + " " + MessageText.getString("ConfigView.upload.abbreviated") + DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(total_data_up, total_prot_up);
}
if (size_str != null || rate_str != null) {
String temp;
if (size_str == null) {
temp = rate_str;
} else if (rate_str == null) {
temp = size_str;
} else {
temp = size_str + "; " + rate_str;
}
s += " (" + temp + ")";
}
}
if (transfers.header_show_uptime && transfers.totalStats != null) {
long up_secs = (transfers.totalStats.getSessionUpTime() / 60) * 60;
String op;
if (up_secs < 60) {
up_secs = 60;
op = "<";
} else {
op = " ";
}
String up_str = TimeFormatter.format2(up_secs, false);
if (s.equals("")) {
Debug.out("eh");
}
s += "; " + MessageText.getString("label.uptime_coarse", new String[] { op, up_str });
}
soLibraryInfo.setText(s);
}
class ExtraInfoProvider {
int view_mode;
boolean enabled;
int value;
int active;
private ExtraInfoProvider(int vm) {
view_mode = vm;
}
}
});
}
} catch (Exception ignored) {
}
// Core core = CoreFactory.getSingleton();
if (!CoreFactory.isCoreRunning()) {
if (soWait != null) {
soWait.setVisible(true);
// soWait.getControl().getParent().getParent().getParent().layout(true, true);
}
final Initializer initializer = Initializer.getLastInitializer();
if (initializer != null) {
initializer.addListener(new InitializerListener() {
@Override
public void reportPercent(final int percent) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
if (soWaitProgress != null && !soWaitProgress.isDisposed()) {
waitProgress = percent;
soWaitProgress.getControl().redraw();
soWaitProgress.getControl().update();
}
}
});
if (percent > 100) {
initializer.removeListener(this);
}
}
@Override
public void reportCurrentTask(String currentTask) {
if (soWaitTask != null && !soWaitTask.isDisposed()) {
soWaitTask.setText(currentTask);
}
}
});
}
}
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(final Core core) {
PluginInterface pi = PluginInitializer.getDefaultInterface();
final UIManager uim = pi.getUIManager();
uim.addUIListener(new UIManagerListener() {
@Override
public void UIDetached(UIInstance instance) {
}
@Override
public void UIAttached(UIInstance instance) {
if (instance instanceof UISWTInstance) {
uim.removeUIListener(this);
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
if (soWait != null) {
soWait.setVisible(false);
}
if (!skinObject.isDisposed()) {
setupView(core, skinObject);
}
}
});
}
}
});
}
});
return null;
}
use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.
the class ConfigSectionStartShutdown method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
GridData gridData;
GridLayout layout;
Label label;
final Composite cDisplay = new Composite(parent, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
Utils.setLayoutData(cDisplay, gridData);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginWidth = 0;
layout.marginHeight = 0;
cDisplay.setLayout(layout);
final PlatformManager platform = PlatformManagerFactory.getPlatformManager();
int userMode = COConfigurationManager.getIntParameter("User Mode");
// ***** start group
boolean can_ral = platform.hasCapability(PlatformManagerCapabilities.RunAtLogin);
if (can_ral || userMode > 0) {
Group gStartStop = new Group(cDisplay, SWT.NULL);
Messages.setLanguageText(gStartStop, "ConfigView.label.start");
layout = new GridLayout(2, false);
gStartStop.setLayout(layout);
Utils.setLayoutData(gStartStop, new GridData(GridData.FILL_HORIZONTAL));
if (can_ral) {
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter start_on_login = new BooleanParameter(gStartStop, "Start On Login", "ConfigView.label.start.onlogin");
try {
start_on_login.setSelected(platform.getRunAtLogin());
start_on_login.addChangeListener(new ParameterChangeAdapter() {
@Override
public void booleanParameterChanging(Parameter p, boolean toValue) {
try {
platform.setRunAtLogin(toValue);
} catch (Throwable e) {
Debug.out(e);
}
}
});
} catch (Throwable e) {
start_on_login.setEnabled(false);
Debug.out(e);
}
start_on_login.setLayoutData(gridData);
}
if (userMode > 0) {
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter start_in_lr_mode = new BooleanParameter(gStartStop, "Start In Low Resource Mode", "ConfigView.label.start.inlrm");
start_in_lr_mode.setLayoutData(gridData);
Composite lr_comp = new Composite(gStartStop, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 2;
gridData.horizontalIndent = 20;
Utils.setLayoutData(lr_comp, gridData);
layout = new GridLayout(3, false);
lr_comp.setLayout(layout);
BooleanParameter lr_ui = new BooleanParameter(lr_comp, "LRMS UI", "lrms.deactivate.ui");
BooleanParameter lr_udp_net = new BooleanParameter(lr_comp, "LRMS UDP Peers", "lrms.udp.peers");
BooleanParameter lr_dht_sleep = new BooleanParameter(lr_comp, "LRMS DHT Sleep", "lrms.dht.sleep");
// start_in_lr_mode.setAdditionalActionPerformer( new ChangeSelectionActionPerformer( lr_ui ));
// this must always be selected as it is coming out of the deactivated UI mode that enable the others as well
lr_ui.setEnabled(false);
start_in_lr_mode.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(lr_udp_net));
start_in_lr_mode.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(lr_dht_sleep));
}
}
if (platform.hasCapability(PlatformManagerCapabilities.PreventComputerSleep)) {
Group gSleep = new Group(cDisplay, SWT.NULL);
Messages.setLanguageText(gSleep, "ConfigView.label.sleep");
layout = new GridLayout(2, false);
gSleep.setLayout(layout);
Utils.setLayoutData(gSleep, new GridData(GridData.FILL_HORIZONTAL));
gridData = new GridData();
gridData.horizontalSpan = 2;
label = new Label(gSleep, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.sleep.info");
Utils.setLayoutData(label, gridData);
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter no_sleep_dl = new BooleanParameter(gSleep, "Prevent Sleep Downloading", "ConfigView.label.sleep.download");
no_sleep_dl.setLayoutData(gridData);
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter no_sleep_se = new BooleanParameter(gSleep, "Prevent Sleep FP Seeding", "ConfigView.label.sleep.fpseed");
no_sleep_se.setLayoutData(gridData);
TagManager tm = TagManagerFactory.getTagManager();
if (tm.isEnabled()) {
List<Tag> tag_list = tm.getTagType(TagType.TT_DOWNLOAD_MANUAL).getTags();
String[] tags = new String[tag_list.size() + 1];
tags[0] = "";
for (int i = 0; i < tag_list.size(); i++) {
tags[i + 1] = tag_list.get(i).getTagName(true);
}
label = new Label(gSleep, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.sleep.tag");
new StringListParameter(gSleep, "Prevent Sleep Tag", "", tags, tags);
}
}
if (userMode > 0) {
Group gPR = new Group(cDisplay, SWT.NULL);
Messages.setLanguageText(gPR, "ConfigView.label.pauseresume");
layout = new GridLayout(2, false);
gPR.setLayout(layout);
Utils.setLayoutData(gPR, new GridData(GridData.FILL_HORIZONTAL));
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter pauseOnExit = new BooleanParameter(gPR, "Pause Downloads On Exit", "ConfigView.label.pause.downloads.on.exit");
pauseOnExit.setLayoutData(gridData);
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter resumeOnStart = new BooleanParameter(gPR, "Resume Downloads On Start", "ConfigView.label.resume.downloads.on.start");
resumeOnStart.setLayoutData(gridData);
}
if (userMode >= 0) {
Group gStop = new Group(cDisplay, SWT.NULL);
Messages.setLanguageText(gStop, "ConfigView.label.stop");
layout = new GridLayout(5, false);
gStop.setLayout(layout);
Utils.setLayoutData(gStop, new GridData(GridData.FILL_HORIZONTAL));
// done downloading
addDoneDownloadingOption(gStop, true);
// done seeding
addDoneSeedingOption(gStop, true);
// reset on trigger
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter resetOnTrigger = new BooleanParameter(gStop, "Stop Triggers Auto Reset", "!" + MessageText.getString("ConfigView.label.stop.autoreset", new String[] { MessageText.getString("ConfigView.label.stop.Nothing") }) + "!");
resetOnTrigger.setLayoutData(gridData);
// prompt to allow abort
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter enablePrompt = new BooleanParameter(gStop, "Prompt To Abort Shutdown", "ConfigView.label.prompt.abort");
enablePrompt.setLayoutData(gridData);
}
if (userMode > 0) {
Group gRestart = new Group(cDisplay, SWT.NULL);
Messages.setLanguageText(gRestart, "label.restart");
layout = new GridLayout(2, false);
gRestart.setLayout(layout);
Utils.setLayoutData(gRestart, new GridData(GridData.FILL_HORIZONTAL));
label = new Label(gRestart, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.restart.auto");
new IntParameter(gRestart, "Auto Restart When Idle", 0, 100000);
}
if (userMode > 0 && platform.hasCapability(PlatformManagerCapabilities.AccessExplicitVMOptions)) {
Group gJVM = new Group(cDisplay, SWT.NULL);
Messages.setLanguageText(gJVM, "ConfigView.label.jvm");
layout = new GridLayout(2, false);
gJVM.setLayout(layout);
Utils.setLayoutData(gJVM, new GridData(GridData.FILL_HORIZONTAL));
// wiki link
gridData = new GridData();
gridData.horizontalSpan = 2;
LinkLabel link = new LinkLabel(gJVM, gridData, "ConfigView.label.please.visit.here", Constants.URL_WIKI + "w/Java_VM_memory_usage");
// info
label = new Label(gJVM, SWT.NULL);
Messages.setLanguageText(label, "jvm.info");
gridData = new GridData();
gridData.horizontalSpan = 2;
Utils.setLayoutData(label, gridData);
try {
final File option_file = platform.getVMOptionFile();
final Group gJVMOptions = new Group(gJVM, SWT.NULL);
layout = new GridLayout(3, false);
gJVMOptions.setLayout(layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
Utils.setLayoutData(gJVMOptions, gridData);
buildOptions(cDisplay, platform, gJVMOptions, false);
// show option file
label = new Label(gJVM, SWT.NULL);
Messages.setLanguageText(label, "jvm.show.file", new String[] { option_file.getAbsolutePath() });
Button show_folder_button = new Button(gJVM, SWT.PUSH);
Messages.setLanguageText(show_folder_button, "MyTorrentsView.menu.explore");
show_folder_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ManagerUtils.open(option_file);
}
});
label = new Label(gJVM, SWT.NULL);
Messages.setLanguageText(label, "jvm.reset");
Button reset_button = new Button(gJVM, SWT.PUSH);
Messages.setLanguageText(reset_button, "Button.reset");
reset_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
try {
platform.setExplicitVMOptions(new String[0]);
buildOptions(cDisplay, platform, gJVMOptions, true);
} catch (Throwable e) {
Debug.out(e);
}
}
});
} catch (Throwable e) {
Debug.out(e);
label = new Label(gJVM, SWT.NULL);
Messages.setLanguageText(label, "jvm.error", new String[] { Debug.getNestedExceptionMessage(e) });
gridData = new GridData();
gridData.horizontalSpan = 2;
Utils.setLayoutData(label, gridData);
}
}
return cDisplay;
}
use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.
the class SBC_LibraryView method setupView.
private void setupView(Core core, SWTSkinObject skinObject) {
torrentFilter = skinObject.getSkinObjectID();
if (torrentFilter.equalsIgnoreCase(SideBar.SIDEBAR_SECTION_LIBRARY_DL)) {
torrentFilterMode = TORRENTS_INCOMPLETE;
} else if (torrentFilter.equalsIgnoreCase(SideBar.SIDEBAR_SECTION_LIBRARY_CD)) {
torrentFilterMode = TORRENTS_COMPLETE;
} else if (torrentFilter.equalsIgnoreCase(SideBar.SIDEBAR_SECTION_LIBRARY_UNOPENED)) {
torrentFilterMode = TORRENTS_UNOPENED;
}
if (datasource instanceof Tag) {
Tag tag = (Tag) datasource;
TagType tagType = tag.getTagType();
if (tagType.getTagType() == TagType.TT_DOWNLOAD_STATE) {
// see GlobalManagerImp.tag_*
int tagID = tag.getTagID();
if (tagID == 1 || tagID == 3 || tagID == 11) {
torrentFilterMode = TORRENTS_INCOMPLETE;
} else if (tagID == 2 || tagID == 4 || tagID == 10) {
torrentFilterMode = TORRENTS_COMPLETE;
}
}
}
soListArea = getSkinObject(ID + "-area");
soListArea.getControl().setData("TorrentFilterMode", new Long(torrentFilterMode));
soListArea.getControl().setData("DataSource", datasource);
setViewMode(COConfigurationManager.getIntParameter(torrentFilter + ".viewmode"), false);
SWTSkinObject so;
so = getSkinObject(ID + "-button-smalltable");
if (so != null) {
btnSmallTable = new SWTSkinButtonUtility(so);
btnSmallTable.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
setViewMode(MODE_SMALLTABLE, true);
}
});
}
so = getSkinObject(ID + "-button-bigtable");
if (so != null) {
btnBigTable = new SWTSkinButtonUtility(so);
btnBigTable.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
setViewMode(MODE_BIGTABLE, true);
}
});
}
SB_Transfers sb_t = MainMDISetup.getSb_transfers();
if (sb_t != null) {
sb_t.setupViewTitleWithCore(core);
}
}
Aggregations