use of com.biglybt.ui.swt.components.LinkLabel 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;
}
Aggregations