use of com.biglybt.ui.swt.shells.MessageBoxShell in project BiglyBT by BiglySoftware.
the class SBC_DownloadHistoryView method resetHistory.
private void resetHistory() {
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("downloadhistoryview.reset.title"), MessageText.getString("downloadhistoryview.reset.text"));
mb.setButtons(0, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, new Integer[] { 0, 1 });
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (result == 0) {
dh_manager.resetHistory();
}
}
});
}
use of com.biglybt.ui.swt.shells.MessageBoxShell in project BiglyBT by BiglySoftware.
the class ConfigSectionMode method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
GridData gridData;
GridLayout layout;
/*
final String[] messTexts =
{ "ConfigView.section.mode.beginner.wiki.definitions",
"ConfigView.section.mode.intermediate.wiki.host",
"ConfigView.section.mode.advanced.wiki.main",
};
*/
final String[] links = { Constants.URL_WIKI + "w/Mode#Beginner", Constants.URL_WIKI + "w/Mode#Intermediate", Constants.URL_WIKI + "w/Mode#Advanced" };
int userMode = COConfigurationManager.getIntParameter("User Mode");
final Composite cMode = new Composite(parent, SWT.WRAP);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
cMode.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 4;
layout.marginHeight = 0;
cMode.setLayout(layout);
gridData = new GridData();
gridData.horizontalSpan = 4;
final Group gRadio = new Group(cMode, SWT.WRAP);
Messages.setLanguageText(gRadio, "ConfigView.section.mode.title");
gRadio.setLayoutData(gridData);
Utils.setLayout(gRadio, new RowLayout(SWT.HORIZONTAL));
Button button0 = new Button(gRadio, SWT.RADIO);
Messages.setLanguageText(button0, "ConfigView.section.mode.beginner");
button0.setData("iMode", "0");
button0.setData("sMode", "beginner.text");
Button button1 = new Button(gRadio, SWT.RADIO);
Messages.setLanguageText(button1, "ConfigView.section.mode.intermediate");
button1.setData("iMode", "1");
button1.setData("sMode", "intermediate.text");
Button button2 = new Button(gRadio, SWT.RADIO);
Messages.setLanguageText(button2, "ConfigView.section.mode.advanced");
button2.setData("iMode", "2");
button2.setData("sMode", "advanced.text");
final Button[] selected_button = { null };
if (userMode == 0) {
selected_button[0] = button0;
button0.setSelection(true);
} else if (userMode == 1) {
selected_button[0] = button1;
button1.setSelection(true);
} else {
selected_button[0] = button2;
button2.setSelection(true);
}
gridData = new GridData(GridData.FILL_HORIZONTAL);
final Label label = new Label(cMode, SWT.WRAP);
gridData.horizontalSpan = 4;
gridData.horizontalIndent = 10;
Utils.setLayoutData(label, gridData);
final Label linkLabel = new Label(cMode, SWT.NULL);
linkLabel.setText(MessageText.getString("ConfigView.label.please.visit.here"));
linkLabel.setData(links[userMode]);
linkLabel.setCursor(linkLabel.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
linkLabel.setForeground(Colors.blue);
gridData = new GridData(GridData.FILL_HORIZONTAL);
// gridData.horizontalIndent = 10;
Utils.setLayoutData(linkLabel, gridData);
linkLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
@Override
public void mouseUp(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
});
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
Utils.setLayoutData(linkLabel, gridData);
ClipboardCopy.addCopyToClipMenu(linkLabel);
final Runnable setModeText = new Runnable() {
@Override
public void run() {
String key = "ConfigView.section.mode." + selected_button[0].getData("sMode");
if (MessageText.keyExists(key + "1")) {
key = key + "1";
}
label.setText("-> " + MessageText.getString(key));
}
};
setModeText.run();
/*
final Label linkLabel1 = new Label(gWiki, SWT.NULL);
linkLabel1.setText( (userMode == 1)?MessageText.getString(messTexts[3]):"");
linkLabel1.setData( links[3] );
linkLabel1.setCursor(linkLabel1.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
linkLabel1.setForeground(Colors.blue);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalIndent = 10;
Utils.setLayoutData(linkLabel1, gridData );
linkLabel1.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
public void mouseUp(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
});
*/
Listener radioGroup = new Listener() {
@Override
public void handleEvent(Event event) {
Control[] children = gRadio.getChildren();
for (int j = 0; j < children.length; j++) {
Control child = children[j];
if (child instanceof Button) {
Button button = (Button) child;
if ((button.getStyle() & SWT.RADIO) != 0)
button.setSelection(false);
}
}
Button button = (Button) event.widget;
button.setSelection(true);
int mode = Integer.parseInt((String) button.getData("iMode"));
selected_button[0] = button;
setModeText.run();
// linkLabel.setText( MessageText.getString(messTexts[mode]) );
linkLabel.setData(links[mode]);
/*
if(mode == 1){
linkLabel1.setText( MessageText.getString(messTexts[3]) );
linkLabel1.setData( links[3] );
} else{
linkLabel1.setText( "" );
linkLabel1.setData( "" );
}
*/
COConfigurationManager.setParameter("User Mode", Integer.parseInt((String) button.getData("iMode")));
}
};
button0.addListener(SWT.Selection, radioGroup);
button1.addListener(SWT.Selection, radioGroup);
button2.addListener(SWT.Selection, radioGroup);
Label padding = new Label(cMode, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 3;
Utils.setLayoutData(padding, gridData);
// reset to defaults
Label blank = new Label(cMode, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
Utils.setLayoutData(blank, gridData);
Composite gReset = new Composite(cMode, SWT.WRAP);
gridData = new GridData();
gridData.horizontalSpan = 4;
Utils.setLayoutData(gReset, gridData);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
gReset.setLayout(layout);
Label reset_label = new Label(gReset, SWT.NULL);
Messages.setLanguageText(reset_label, "ConfigView.section.mode.resetdefaults");
Button reset_button = new Button(gReset, SWT.PUSH);
Messages.setLanguageText(reset_button, "Button.reset");
reset_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_WARNING | SWT.OK | SWT.CANCEL, MessageText.getString("resetconfig.warn.title"), MessageText.getString("resetconfig.warn"));
mb.setDefaultButtonUsingStyle(SWT.CANCEL);
mb.setParent(parent.getShell());
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int returnVal) {
if (returnVal != SWT.OK) {
return;
}
RememberedDecisionsManager.ensureLoaded();
COConfigurationManager.resetToDefaults();
}
});
}
});
padding = new Label(gReset, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(padding, gridData);
return cMode;
}
use of com.biglybt.ui.swt.shells.MessageBoxShell in project BiglyBT by BiglySoftware.
the class ConfigSectionStats method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
ImageLoader imageLoader = ImageLoader.getInstance();
Image imgOpenFolder = imageLoader.getImage("openFolderButton");
GridData gridData;
GridLayout layout;
Composite gOutter = new Composite(parent, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gOutter.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 1;
gOutter.setLayout(layout);
// general
Group gGeneral = new Group(gOutter, SWT.NULL);
Messages.setLanguageText(gGeneral, "ConfigView.section.general");
layout = new GridLayout(2, false);
gGeneral.setLayout(layout);
gGeneral.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label lSmooth = new Label(gGeneral, SWT.NULL);
Messages.setLanguageText(lSmooth, "stats.general.smooth_secs");
IntParameter smooth_secs = new IntParameter(gGeneral, "Stats Smoothing Secs", 30, 30 * 60);
// display
Group gDisplay = new Group(gOutter, SWT.NULL);
Messages.setLanguageText(gDisplay, "stats.display.group");
layout = new GridLayout(1, false);
gDisplay.setLayout(layout);
gDisplay.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
gridData = new GridData();
BooleanParameter graph_dividers = new BooleanParameter(gDisplay, "Stats Graph Dividers", "ConfigView.section.stats.graph_update_dividers");
graph_dividers.setLayoutData(gridData);
// snapshots
Group gSnap = new Group(gOutter, SWT.NULL);
Messages.setLanguageText(gSnap, "stats.snapshot.group");
layout = new GridLayout(3, false);
gSnap.setLayout(layout);
gSnap.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// row
gridData = new GridData();
gridData.horizontalSpan = 3;
BooleanParameter enableStats = new BooleanParameter(gSnap, "Stats Enable", "ConfigView.section.stats.enable");
enableStats.setLayoutData(gridData);
Control[] controls = new Control[13];
// row
Label lStatsPath = new Label(gSnap, SWT.NULL);
// $NON-NLS-1$
Messages.setLanguageText(lStatsPath, "ConfigView.section.stats.defaultsavepath");
gridData = new GridData();
gridData.widthHint = 150;
// $NON-NLS-1$ //$NON-NLS-2$
final StringParameter pathParameter = new StringParameter(gSnap, "Stats Dir", "");
pathParameter.setLayoutData(gridData);
controls[0] = lStatsPath;
controls[1] = pathParameter.getControl();
Button browse = new Button(gSnap, SWT.PUSH);
browse.setImage(imgOpenFolder);
imgOpenFolder.setBackground(browse.getBackground());
browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));
controls[2] = browse;
browse.addListener(SWT.Selection, new Listener() {
/* (non-Javadoc)
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
*/
@Override
public void handleEvent(Event event) {
DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.APPLICATION_MODAL);
dialog.setFilterPath(pathParameter.getValue());
// $NON-NLS-1$
dialog.setText(MessageText.getString("ConfigView.section.stats.choosedefaultsavepath"));
String path = dialog.open();
if (path != null) {
pathParameter.setValue(path);
}
}
});
// row
Label lSaveFile = new Label(gSnap, SWT.NULL);
// $NON-NLS-1$
Messages.setLanguageText(lSaveFile, "ConfigView.section.stats.savefile");
controls[3] = lSaveFile;
gridData = new GridData();
gridData.widthHint = 150;
final StringParameter fileParameter = new StringParameter(gSnap, "Stats File", StatsWriterPeriodic.DEFAULT_STATS_FILE_NAME);
fileParameter.setLayoutData(gridData);
controls[4] = fileParameter.getControl();
new Label(gSnap, SWT.NULL);
// row
Label lxslFile = new Label(gSnap, SWT.NULL);
// $NON-NLS-1$
Messages.setLanguageText(lxslFile, "ConfigView.section.stats.xslfile");
controls[5] = lxslFile;
gridData = new GridData();
gridData.widthHint = 150;
final StringParameter xslParameter = new StringParameter(gSnap, "Stats XSL File", "");
xslParameter.setLayoutData(gridData);
controls[6] = xslParameter.getControl();
Label lxslDetails = new Label(gSnap, SWT.NULL);
// $NON-NLS-1$
Messages.setLanguageText(lxslDetails, "ConfigView.section.stats.xslfiledetails");
final String linkFAQ = Constants.PLUGINS_WEB_SITE + "faq.php#20";
lxslDetails.setCursor(lxslDetails.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
lxslDetails.setForeground(Colors.blue);
lxslDetails.setData(linkFAQ);
lxslDetails.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch(linkFAQ);
}
@Override
public void mouseDown(MouseEvent arg0) {
Utils.launch(linkFAQ);
}
});
ClipboardCopy.addCopyToClipMenu(lxslDetails);
controls[7] = lxslDetails;
// row
Label lSaveFreq = new Label(gSnap, SWT.NULL);
Messages.setLanguageText(lSaveFreq, "ConfigView.section.stats.savefreq");
controls[8] = lSaveFreq;
final String[] spLabels = new String[statsPeriods.length];
final int[] spValues = new int[statsPeriods.length];
for (int i = 0; i < statsPeriods.length; i++) {
int num = statsPeriods[i];
if (num % 3600 == 0)
spLabels[i] = " " + (statsPeriods[i] / 3600) + " " + MessageText.getString("ConfigView.section.stats.hours");
else if (num % 60 == 0)
spLabels[i] = " " + (statsPeriods[i] / 60) + " " + MessageText.getString("ConfigView.section.stats.minutes");
else
spLabels[i] = " " + statsPeriods[i] + " " + MessageText.getString("ConfigView.section.stats.seconds");
spValues[i] = statsPeriods[i];
}
controls[9] = lSaveFreq;
controls[10] = new IntListParameter(gSnap, "Stats Period", defaultStatsPeriod, spLabels, spValues).getControl();
new Label(gSnap, SWT.NULL);
// ROW
gridData = new GridData();
gridData.horizontalSpan = 3;
BooleanParameter exportPeers = new BooleanParameter(gSnap, "Stats Export Peer Details", "ConfigView.section.stats.exportpeers");
exportPeers.setLayoutData(gridData);
controls[11] = exportPeers.getControl();
// ROW
gridData = new GridData();
gridData.horizontalSpan = 3;
BooleanParameter exportFiles = new BooleanParameter(gSnap, "Stats Export File Details", "ConfigView.section.stats.exportfiles");
exportFiles.setLayoutData(gridData);
controls[12] = exportFiles.getControl();
// control stuff
enableStats.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(controls));
// xfer
Group gXfer = new Group(gOutter, SWT.NULL);
Messages.setLanguageText(gXfer, "ConfigView.section.transfer");
layout = new GridLayout(3, false);
gXfer.setLayout(layout);
gXfer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
List<Button> buttons = new ArrayList<>();
// set mark
Label set_mark_label = new Label(gXfer, SWT.NULL);
Messages.setLanguageText(set_mark_label, "ConfigView.section.transfer.setmark");
Button set_mark_button = new Button(gXfer, SWT.PUSH);
buttons.add(set_mark_button);
Messages.setLanguageText(set_mark_button, "Button.set");
set_mark_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
OverallStats stats = StatsFactory.getStats();
stats.setMark();
}
});
Button clear_mark_button = new Button(gXfer, SWT.PUSH);
buttons.add(clear_mark_button);
Messages.setLanguageText(clear_mark_button, "Button.clear");
clear_mark_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
OverallStats stats = StatsFactory.getStats();
stats.clearMark();
}
});
// long term
Group gLong = new Group(gOutter, SWT.NULL);
Messages.setLanguageText(gLong, "stats.longterm.group");
layout = new GridLayout(2, false);
gLong.setLayout(layout);
gLong.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// row
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter enableLongStats = new BooleanParameter(gLong, "long.term.stats.enable", "ConfigView.section.stats.enable");
enableLongStats.setLayoutData(gridData);
// week start
Label lWeekStart = new Label(gLong, SWT.NULL);
Messages.setLanguageText(lWeekStart, "stats.long.weekstart");
final String[] wsLabels = new String[7];
final int[] wsValues = new int[7];
Calendar cal = new GregorianCalendar();
SimpleDateFormat format = new SimpleDateFormat("E");
for (int i = 0; i < 7; i++) {
// sun = 1 etc
int dow = i + 1;
cal.set(Calendar.DAY_OF_WEEK, dow);
wsLabels[i] = format.format(cal.getTime());
wsValues[i] = i + 1;
}
IntListParameter week_start = new IntListParameter(gLong, "long.term.stats.weekstart", Calendar.SUNDAY, wsLabels, wsValues);
// month start
Label lMonthStart = new Label(gLong, SWT.NULL);
Messages.setLanguageText(lMonthStart, "stats.long.monthstart");
IntParameter month_start = new IntParameter(gLong, "long.term.stats.monthstart", 1, 28);
enableLongStats.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(new Control[] { lWeekStart, lMonthStart }));
enableLongStats.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(week_start, month_start));
// reset
Label lt_reset_label = new Label(gLong, SWT.NULL);
Messages.setLanguageText(lt_reset_label, "ConfigView.section.transfer.lts.reset");
Button lt_reset_button = new Button(gLong, SWT.PUSH);
buttons.add(lt_reset_button);
Messages.setLanguageText(lt_reset_button, "Button.clear");
lt_reset_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_WARNING | SWT.OK | SWT.CANCEL, MessageText.getString("ConfigView.section.security.resetcerts.warning.title"), MessageText.getString("ConfigView.section.transfer.ltsreset.warning.msg"));
mb.setDefaultButtonUsingStyle(SWT.CANCEL);
mb.setParent(parent.getShell());
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int returnVal) {
if (returnVal != SWT.OK) {
return;
}
Utils.getOffOfSWTThread(new AERunnable() {
@Override
public void runSupport() {
StatsFactory.clearLongTermStats();
}
});
}
});
}
});
Utils.makeButtonsEqualWidth(buttons);
return gOutter;
}
Aggregations