use of com.biglybt.ui.swt.config.generic.GenericIntParameter in project BiglyBT by BiglySoftware.
the class TagSettingsView method swt_initialize.
private void swt_initialize(Composite parent) {
if (cMainComposite == null || cMainComposite.isDisposed()) {
if (parent == null || parent.isDisposed()) {
return;
}
sc = new ScrolledComposite(parent, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.getVerticalBar().setIncrement(16);
Layout parentLayout = parent.getLayout();
if (parentLayout instanceof GridLayout) {
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
Utils.setLayoutData(sc, gd);
} else if (parentLayout instanceof FormLayout) {
Utils.setLayoutData(sc, Utils.getFilledFormData());
}
cMainComposite = new Composite(sc, SWT.NONE);
sc.setContent(cMainComposite);
} else {
Utils.disposeComposite(cMainComposite, false);
}
if (tags == null) {
params = null;
cMainComposite.setLayout(new FillLayout());
Label label = new Label(cMainComposite, SWT.NONE);
label.setText(MessageText.getString("tag.settings.select.tag"));
} else {
final int numTags = tags.length;
int isTagVisible = -1;
int canBePublic = -1;
int[] tagColor = tags[0].getColor();
boolean tagsAreTagFeatureRateLimit = true;
Set<String> listTagTypes = new HashSet<>();
for (Tag tag : tags) {
TagType tt = tag.getTagType();
String s = tt.getTagTypeName(true);
listTagTypes.add(s);
if (tagsAreTagFeatureRateLimit && !(tag instanceof TagFeatureRateLimit)) {
tagsAreTagFeatureRateLimit = false;
}
isTagVisible = updateIntBoolean(tag.isVisible(), isTagVisible);
canBePublic = updateIntBoolean(tag.canBePublic(), canBePublic);
if (tagColor != null) {
int[] color = tag.getColor();
if (!Arrays.areEqual(tagColor, color)) {
tagColor = null;
}
}
}
String tagTypes = GeneralUtils.stringJoin(listTagTypes, ", ");
params = new Params();
GridData gd;
GridLayout gridLayout;
gridLayout = new GridLayout(1, false);
gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
gridLayout.marginHeight = gridLayout.marginWidth = 0;
cMainComposite.setLayout(gridLayout);
Composite cSection1 = new Composite(cMainComposite, SWT.NONE);
gridLayout = new GridLayout(4, false);
gridLayout.marginHeight = 0;
cSection1.setLayout(gridLayout);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
cSection1.setLayoutData(gd);
Composite cSection2 = new Composite(cMainComposite, SWT.NONE);
gridLayout = new GridLayout(4, false);
cSection2.setLayout(gridLayout);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
cSection2.setLayoutData(gd);
Label label;
// Field: Tag Type
label = new Label(cSection1, SWT.NONE);
FontUtils.setFontHeight(label, 12, SWT.BOLD);
gd = new GridData();
gd.horizontalSpan = 4;
Utils.setLayoutData(label, gd);
label.setText(tagTypes);
// Field: Name
label = new Label(cSection1, SWT.NONE);
Messages.setLanguageText(label, "MinimizedWindow.name");
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
Utils.setLayoutData(label, gd);
if (numTags == 1 && !tags[0].getTagType().isTagTypeAuto()) {
Text txtName = new Text(cSection1, SWT.BORDER);
params.cName = txtName;
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
Utils.setLayoutData(txtName, gd);
txtName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
try {
String newName = ((Text) e.widget).getText();
if (!tags[0].getTagName(true).equals(newName)) {
tags[0].setTagName(newName);
}
} catch (TagException e1) {
Debug.out(e1);
}
}
});
} else {
label = new Label(cSection1, SWT.WRAP);
gd = Utils.getWrappableLabelGridData(1, GridData.GRAB_HORIZONTAL);
Utils.setLayoutData(label, gd);
params.cName = label;
}
// Field: Color
label = new Label(cSection1, SWT.NONE);
Messages.setLanguageText(label, "label.color");
if (tagColor == null) {
tagColor = new int[] { 0, 0, 0 };
}
params.tagColor = new ColorParameter(cSection1, null, tagColor[0], tagColor[1], tagColor[2]) {
// @see com.biglybt.ui.swt.config.ColorParameter#newColorChosen(org.eclipse.swt.graphics.RGB)
@Override
public void newColorChosen(RGB newColor) {
for (Tag tag : tags) {
tag.setColor(new int[] { newColor.red, newColor.green, newColor.blue });
}
}
};
// Field: Visible
params.viewInSideBar = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
int isTagVisible = -1;
for (Tag tag : tags) {
isTagVisible = updateIntBoolean(tag.isVisible(), isTagVisible);
}
return isTagVisible == 2 ? null : (isTagVisible == 1);
}
@Override
public void setBooleanValue(String key, boolean value) {
for (Tag tag : tags) {
tag.setVisible(value);
}
}
}, cSection2, null, "TagSettings.viewInSideBar");
gd = new GridData();
gd.horizontalSpan = 4;
params.viewInSideBar.setLayoutData(gd);
// Field: Public
if (canBePublic == 1) {
params.isPublic = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
int val = -1;
for (Tag tag : tags) {
val = updateIntBoolean(tag.isPublic(), val);
}
return val == 2 ? null : (val == 1);
}
@Override
public void setBooleanValue(String key, boolean value) {
for (Tag tag : tags) {
tag.setPublic(value);
}
}
}, cSection2, null, "TagAddWindow.public.checkbox");
gd = new GridData();
gd.horizontalSpan = 4;
params.isPublic.setLayoutData(gd);
}
// //////////////////
Group gTransfer = new Group(cMainComposite, SWT.NONE);
gTransfer.setText(MessageText.getString("label.transfer.settings"));
gridLayout = new GridLayout(6, false);
gTransfer.setLayout(gridLayout);
gd = new GridData(SWT.FILL, SWT.NONE, false, false, 4, 1);
gTransfer.setLayoutData(gd);
if (tagsAreTagFeatureRateLimit) {
final TagFeatureRateLimit[] rls = new TagFeatureRateLimit[tags.length];
System.arraycopy(tags, 0, rls, 0, tags.length);
boolean supportsTagDownloadLimit = true;
boolean supportsTagUploadLimit = true;
boolean hasTagUploadPriority = true;
for (TagFeatureRateLimit rl : rls) {
supportsTagDownloadLimit &= rl.supportsTagDownloadLimit();
supportsTagUploadLimit &= rl.supportsTagUploadLimit();
hasTagUploadPriority &= rl.getTagUploadPriority() >= 0;
}
String k_unit = DisplayFormatters.getRateUnitBase10(DisplayFormatters.UNIT_KB).trim();
int cols_used = 0;
// Field: Download Limit
if (supportsTagDownloadLimit) {
gd = new GridData();
label = new Label(gTransfer, SWT.NULL);
Utils.setLayoutData(label, gd);
label.setText(k_unit + " " + MessageText.getString("GeneralView.label.maxdownloadspeed.tooltip"));
gd = new GridData();
// gd.horizontalSpan = 3;
params.maxDownloadSpeed = new GenericIntParameter(new GenericParameterAdapter() {
@Override
public int getIntValue(String key) {
int limit = rls[0].getTagDownloadLimit();
if (numTags > 1) {
for (int i = 1; i < rls.length; i++) {
int nextLimit = rls[i].getTagDownloadLimit();
if (nextLimit != limit) {
return 0;
}
}
}
return limit < 0 ? limit : limit / DisplayFormatters.getKinB();
}
@Override
public int getIntValue(String key, int def) {
return getIntValue(key);
}
@Override
public void setIntValue(String key, int value) {
for (TagFeatureRateLimit rl : rls) {
if (value == -1) {
rl.setTagDownloadLimit(-1);
} else {
rl.setTagDownloadLimit(value * DisplayFormatters.getKinB());
}
}
}
@Override
public boolean resetIntDefault(String key) {
return false;
}
}, gTransfer, null, -1, Integer.MAX_VALUE);
params.maxDownloadSpeed.setLayoutData(gd);
params.maxDownloadSpeed.setZeroHidden(numTags > 1);
cols_used += 2;
}
// Upload Limit
if (supportsTagUploadLimit) {
gd = new GridData();
label = new Label(gTransfer, SWT.NULL);
Utils.setLayoutData(label, gd);
label.setText(k_unit + " " + MessageText.getString("GeneralView.label.maxuploadspeed.tooltip"));
gd = new GridData();
// gd.horizontalSpan = 3;
params.maxUploadSpeed = new GenericIntParameter(new GenericParameterAdapter() {
@Override
public int getIntValue(String key) {
int limit = rls[0].getTagUploadLimit();
if (numTags > 1) {
for (int i = 1; i < rls.length; i++) {
int nextLimit = rls[i].getTagUploadLimit();
if (nextLimit != limit) {
return 0;
}
}
}
return limit < 0 ? limit : limit / DisplayFormatters.getKinB();
}
@Override
public int getIntValue(String key, int def) {
return getIntValue(key);
}
@Override
public void setIntValue(String key, int value) {
for (TagFeatureRateLimit rl : rls) {
if (value == -1) {
rl.setTagUploadLimit(value);
} else {
rl.setTagUploadLimit(value * DisplayFormatters.getKinB());
}
}
}
@Override
public boolean resetIntDefault(String key) {
return false;
}
}, gTransfer, null, -1, Integer.MAX_VALUE);
params.maxUploadSpeed.setLayoutData(gd);
params.maxUploadSpeed.setZeroHidden(numTags > 1);
cols_used += 2;
}
// Field: Upload Priority
if (hasTagUploadPriority) {
params.uploadPriority = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
int value = -1;
for (TagFeatureRateLimit rl : rls) {
value = updateIntBoolean(rl.getTagUploadPriority() > 0, value);
}
return value == 2 ? null : value == 1;
}
@Override
public void setBooleanValue(String key, boolean value) {
for (TagFeatureRateLimit rl : rls) {
rl.setTagUploadPriority(value ? 1 : 0);
}
}
}, gTransfer, null, "cat.upload.priority");
gd = new GridData();
gd.horizontalSpan = 6 - cols_used;
params.uploadPriority.setLayoutData(gd);
}
// Field: Min Share
if (numTags == 1 && rls[0].getTagMinShareRatio() >= 0) {
label = new Label(gTransfer, SWT.NONE);
Messages.setLanguageText(label, "TableColumn.header.min_sr");
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
Utils.setLayoutData(label, gd);
params.min_sr = new GenericFloatParameter(new GenericParameterAdapter() {
@Override
public float getFloatValue(String key) {
return rls[0].getTagMinShareRatio() / 1000f;
}
@Override
public void setFloatValue(String key, float value) {
rls[0].setTagMinShareRatio((int) (value * 1000));
}
}, gTransfer, null, 0, Float.MAX_VALUE, true, 3);
gd = new GridData();
// gd.horizontalSpan = 3;
gd.widthHint = 75;
params.min_sr.setLayoutData(gd);
}
// Field: Max Share
if (numTags == 1 && rls[0].getTagMaxShareRatio() >= 0) {
label = new Label(gTransfer, SWT.NONE);
Messages.setLanguageText(label, "TableColumn.header.max_sr");
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
Utils.setLayoutData(label, gd);
params.max_sr = new GenericFloatParameter(new GenericParameterAdapter() {
@Override
public float getFloatValue(String key) {
return rls[0].getTagMaxShareRatio() / 1000f;
}
@Override
public void setFloatValue(String key, float value) {
rls[0].setTagMaxShareRatio((int) (value * 1000));
updateTagSRParams(params);
}
}, gTransfer, null, 0, Float.MAX_VALUE, true, 3);
gd = new GridData();
// gd.horizontalSpan = 3;
gd.widthHint = 75;
params.max_sr.setLayoutData(gd);
// max sr action
String[] ST_ACTION_VALUES = { "" + TagFeatureRateLimit.SR_ACTION_QUEUE, "" + TagFeatureRateLimit.SR_ACTION_PAUSE, "" + TagFeatureRateLimit.SR_ACTION_STOP };
String[] ST_ACTION_LABELS = { MessageText.getString("ConfigView.section.queue"), MessageText.getString("v3.MainWindow.button.pause"), MessageText.getString("v3.MainWindow.button.stop") };
label = new Label(gTransfer, SWT.NONE);
Messages.setLanguageText(label, "label.when.exceeded");
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
Utils.setLayoutData(label, gd);
params.max_sr_action = new GenericStringListParameter(new GenericParameterAdapter() {
@Override
public String getStringListValue(String key, String def) {
return (getStringListValue(key));
}
@Override
public String getStringListValue(String key) {
return ("" + rls[0].getTagMaxShareRatioAction());
}
@Override
public void setStringListValue(String key, String value) {
rls[0].setTagMaxShareRatioAction(Integer.parseInt(value));
}
}, gTransfer, "max_sr_action", "" + TagFeatureRateLimit.SR_INDIVIDUAL_ACTION_DEFAULT, ST_ACTION_LABELS, ST_ACTION_VALUES);
}
// Field: Max Aggregate Share
if (numTags == 1 && rls[0].getTagAggregateShareRatio() >= 0) {
label = new Label(gTransfer, SWT.NONE);
Messages.setLanguageText(label, "TableColumn.header.max_aggregate_sr");
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
Utils.setLayoutData(label, gd);
params.max_aggregate_sr = new GenericFloatParameter(new GenericParameterAdapter() {
@Override
public float getFloatValue(String key) {
return rls[0].getTagMaxAggregateShareRatio() / 1000f;
}
@Override
public void setFloatValue(String key, float value) {
rls[0].setTagMaxAggregateShareRatio((int) (value * 1000));
updateTagSRParams(params);
}
}, gTransfer, null, 0, Float.MAX_VALUE, true, 3);
gd = new GridData();
// gd.horizontalSpan = 3;
gd.widthHint = 75;
params.max_aggregate_sr.setLayoutData(gd);
// max sr action
String[] ST_ACTION_VALUES = { "" + TagFeatureRateLimit.SR_ACTION_PAUSE, "" + TagFeatureRateLimit.SR_ACTION_STOP };
String[] ST_ACTION_LABELS = { MessageText.getString("v3.MainWindow.button.pause"), MessageText.getString("v3.MainWindow.button.stop") };
label = new Label(gTransfer, SWT.NONE);
Messages.setLanguageText(label, "label.when.exceeded");
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
Utils.setLayoutData(label, gd);
params.max_aggregate_sr_action = new GenericStringListParameter(new GenericParameterAdapter() {
@Override
public String getStringListValue(String key, String def) {
return (getStringListValue(key));
}
@Override
public String getStringListValue(String key) {
return ("" + rls[0].getTagMaxAggregateShareRatioAction());
}
@Override
public void setStringListValue(String key, String value) {
rls[0].setTagMaxAggregateShareRatioAction(Integer.parseInt(value));
}
}, gTransfer, "max_aggregate_sr_action", "" + TagFeatureRateLimit.SR_AGGREGATE_ACTION_DEFAULT, ST_ACTION_LABELS, ST_ACTION_VALUES);
// aggregate has priority
label = new Label(gTransfer, SWT.NONE);
Messages.setLanguageText(label, "label.aggregate.has.priority");
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
Utils.setLayoutData(label, gd);
params.max_aggregate_sr_priority = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return (rls[0].getTagMaxAggregateShareRatioHasPriority());
}
@Override
public void setBooleanValue(String key, boolean value) {
rls[0].setTagMaxAggregateShareRatioHasPriority(value);
}
}, gTransfer, "max_aggregate_sr_priority", TagFeatureRateLimit.AT_RATELIMIT_MAX_AGGREGATE_SR_PRIORITY_DEFAULT);
updateTagSRParams(params);
}
}
if (numTags == 1 && (tags[0] instanceof TagFeatureFileLocation)) {
final TagFeatureFileLocation fl = (TagFeatureFileLocation) tags[0];
if (fl.supportsTagCopyOnComplete() || fl.supportsTagInitialSaveFolder() || fl.supportsTagMoveOnComplete()) {
Group gFiles = new Group(cMainComposite, SWT.NONE);
gFiles.setText(MessageText.getString("label.file.settings"));
gridLayout = new GridLayout(6, false);
gFiles.setLayout(gridLayout);
gd = new GridData(SWT.FILL, SWT.NONE, true, false, 4, 1);
Utils.setLayoutData(gFiles, gd);
if (fl.supportsTagInitialSaveFolder()) {
params.initalSaveFolder = new folderOption(gFiles, "label.init.save.loc") {
@Override
public void setFolder(File folder) {
params.initalSaveData.setEnabled(folder != null);
params.initalSaveTorrent.setEnabled(folder != null);
fl.setTagInitialSaveFolder(folder);
}
@Override
public File getFolder() {
File result = fl.getTagInitialSaveFolder();
params.initalSaveData.setEnabled(result != null);
params.initalSaveTorrent.setEnabled(result != null);
return (result);
}
};
params.initalSaveData = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return ((fl.getTagInitialSaveOptions() & TagFeatureFileLocation.FL_DATA) != 0);
}
@Override
public void setBooleanValue(String key, boolean value) {
long flags = fl.getTagInitialSaveOptions();
if (value) {
flags |= TagFeatureFileLocation.FL_DATA;
} else {
flags &= ~TagFeatureFileLocation.FL_DATA;
}
fl.setTagInitialSaveOptions(flags);
}
}, gFiles, null, "label.move.data");
params.initalSaveTorrent = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return ((fl.getTagInitialSaveOptions() & TagFeatureFileLocation.FL_TORRENT) != 0);
}
@Override
public void setBooleanValue(String key, boolean value) {
long flags = fl.getTagInitialSaveOptions();
if (value) {
flags |= TagFeatureFileLocation.FL_TORRENT;
} else {
flags &= ~TagFeatureFileLocation.FL_TORRENT;
}
fl.setTagInitialSaveOptions(flags);
}
}, gFiles, null, "label.move.torrent");
}
if (fl.supportsTagMoveOnComplete()) {
params.moveOnCompleteFolder = new folderOption(gFiles, "label.move.on.comp") {
@Override
public void setFolder(File folder) {
params.moveOnCompleteData.setEnabled(folder != null);
params.moveOnCompleteTorrent.setEnabled(folder != null);
fl.setTagMoveOnCompleteFolder(folder);
}
@Override
public File getFolder() {
File result = fl.getTagMoveOnCompleteFolder();
params.moveOnCompleteData.setEnabled(result != null);
params.moveOnCompleteTorrent.setEnabled(result != null);
return (result);
}
};
params.moveOnCompleteData = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return ((fl.getTagMoveOnCompleteOptions() & TagFeatureFileLocation.FL_DATA) != 0);
}
@Override
public void setBooleanValue(String key, boolean value) {
long flags = fl.getTagMoveOnCompleteOptions();
if (value) {
flags |= TagFeatureFileLocation.FL_DATA;
} else {
flags &= ~TagFeatureFileLocation.FL_DATA;
}
fl.setTagMoveOnCompleteOptions(flags);
}
}, gFiles, null, "label.move.data");
params.moveOnCompleteTorrent = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return ((fl.getTagMoveOnCompleteOptions() & TagFeatureFileLocation.FL_TORRENT) != 0);
}
@Override
public void setBooleanValue(String key, boolean value) {
long flags = fl.getTagMoveOnCompleteOptions();
if (value) {
flags |= TagFeatureFileLocation.FL_TORRENT;
} else {
flags &= ~TagFeatureFileLocation.FL_TORRENT;
}
fl.setTagMoveOnCompleteOptions(flags);
}
}, gFiles, null, "label.move.torrent");
}
if (fl.supportsTagCopyOnComplete()) {
params.copyOnCompleteFolder = new folderOption(gFiles, "label.copy.on.comp") {
@Override
public void setFolder(File folder) {
params.copyOnCompleteData.setEnabled(folder != null);
params.copyOnCompleteTorrent.setEnabled(folder != null);
fl.setTagCopyOnCompleteFolder(folder);
}
@Override
public File getFolder() {
File result = fl.getTagCopyOnCompleteFolder();
params.copyOnCompleteData.setEnabled(result != null);
params.copyOnCompleteTorrent.setEnabled(result != null);
return (result);
}
};
params.copyOnCompleteData = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return ((fl.getTagCopyOnCompleteOptions() & TagFeatureFileLocation.FL_DATA) != 0);
}
@Override
public void setBooleanValue(String key, boolean value) {
long flags = fl.getTagCopyOnCompleteOptions();
if (value) {
flags |= TagFeatureFileLocation.FL_DATA;
} else {
flags &= ~TagFeatureFileLocation.FL_DATA;
}
fl.setTagCopyOnCompleteOptions(flags);
}
}, gFiles, null, "label.copy.data");
params.copyOnCompleteTorrent = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return ((fl.getTagCopyOnCompleteOptions() & TagFeatureFileLocation.FL_TORRENT) != 0);
}
@Override
public void setBooleanValue(String key, boolean value) {
long flags = fl.getTagCopyOnCompleteOptions();
if (value) {
flags |= TagFeatureFileLocation.FL_TORRENT;
} else {
flags &= ~TagFeatureFileLocation.FL_TORRENT;
}
fl.setTagCopyOnCompleteOptions(flags);
}
}, gFiles, null, "label.copy.torrent");
}
}
}
if (numTags == 1 && tags[0].getTagType().hasTagTypeFeature(TagFeature.TF_PROPERTIES) && (tags[0] instanceof TagFeatureProperties)) {
TagFeatureProperties tfp = (TagFeatureProperties) tags[0];
final TagProperty propConstraint = tfp.getProperty(TagFeatureProperties.PR_CONSTRAINT);
if (propConstraint != null) {
Group gConstraint = new Group(cMainComposite, SWT.NONE);
Messages.setLanguageText(gConstraint, "tag.property.constraint");
int columns = 6;
gridLayout = new GridLayout(columns, false);
gConstraint.setLayout(gridLayout);
gd = new GridData(SWT.FILL, SWT.NONE, true, false, 4, 1);
Utils.setLayoutData(gConstraint, gd);
params.constraints = new Text(gConstraint, SWT.WRAP | SWT.BORDER | SWT.MULTI);
gd = new GridData(SWT.FILL, SWT.NONE, true, false, columns, 1);
gd.heightHint = 40;
Utils.setLayoutData(params.constraints, gd);
params.constraints.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
params.constraints.setData("skipset", 1);
if (btnSaveConstraint != null && !btnSaveConstraint.isDisposed()) {
btnSaveConstraint.setEnabled(true);
btnResetConstraint.setEnabled(true);
}
}
});
params.constraintError = new Label(gConstraint, SWT.NULL);
params.constraintError.setForeground(Colors.colorError);
gd = new GridData(SWT.FILL, SWT.NONE, true, false, columns, 1);
Utils.setLayoutData(params.constraintError, gd);
btnSaveConstraint = new Button(gConstraint, SWT.PUSH);
btnSaveConstraint.setEnabled(false);
btnSaveConstraint.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
String constraint = params.constraints.getText().trim();
String[] old_value = propConstraint.getStringList();
if (constraint.length() == 0) {
propConstraint.setStringList(null);
} else {
String old_options = old_value.length > 1 && old_value[1] != null ? old_value[1] : "";
if (old_options.length() == 0) {
old_options = CM_ADD_REMOVE;
}
propConstraint.setStringList(new String[] { constraint, old_options });
}
if (btnSaveConstraint != null && !btnSaveConstraint.isDisposed()) {
btnSaveConstraint.setEnabled(false);
btnResetConstraint.setEnabled(false);
}
}
});
Messages.setLanguageText(btnSaveConstraint, "Button.save");
btnResetConstraint = new Button(gConstraint, SWT.PUSH);
btnResetConstraint.setEnabled(false);
btnResetConstraint.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
params.constraints.setData("skipset", null);
swt_updateFields();
if (btnSaveConstraint != null && !btnSaveConstraint.isDisposed()) {
btnSaveConstraint.setEnabled(false);
btnResetConstraint.setEnabled(false);
}
}
});
Messages.setLanguageText(btnResetConstraint, "Button.reset");
params.constraintEnabled = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return (propConstraint.isEnabled());
}
@Override
public void setBooleanValue(String key, boolean value) {
propConstraint.setEnabled(value);
}
}, gConstraint, null, "label.enabled");
Label constraintMode = new Label(gConstraint, SWT.NULL);
Messages.setLanguageText(constraintMode, "label.scope");
String[] CM_VALUES = { CM_ADD_REMOVE, CM_ADD_ONLY, CM_REMOVE_ONLY };
String[] CM_LABELS = { MessageText.getString("label.addition.and.removal"), MessageText.getString("label.addition.only"), MessageText.getString("label.removal.only") };
params.constraintMode = new GenericStringListParameter(new GenericParameterAdapter() {
@Override
public String getStringListValue(String key, String def) {
return (getStringListValue(key));
}
@Override
public String getStringListValue(String key) {
String[] list = propConstraint.getStringList();
if (list.length > 1 && list[1] != null) {
return (list[1]);
} else {
return (CM_ADD_REMOVE);
}
}
@Override
public void setStringListValue(String key, String value) {
if (value == null || value.length() == 0) {
value = CM_ADD_REMOVE;
}
String[] list = propConstraint.getStringList();
propConstraint.setStringList(new String[] { list != null && list.length > 0 ? list[0] : "", value });
}
}, gConstraint, "tag_constraint_action_mode", CM_ADD_REMOVE, CM_LABELS, CM_VALUES);
Link lblAboutConstraint = new Link(gConstraint, SWT.WRAP);
Utils.setLayoutData(lblAboutConstraint, Utils.getWrappableLabelGridData(1, GridData.GRAB_HORIZONTAL));
lblAboutConstraint.setText(MessageText.getString("tag.constraints.info"));
lblAboutConstraint.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
if (event.text != null && (event.text.startsWith("http://") || event.text.startsWith("https://"))) {
Utils.launch(event.text);
}
}
});
}
}
if (numTags == 1 && tags[0].getTagType().hasTagTypeFeature(TagFeature.TF_LIMITS)) {
final TagFeatureLimits tfl = (TagFeatureLimits) tags[0];
if (tfl.getMaximumTaggables() >= 0) {
// ///////////////////////////// limits
Group gLimits = new Group(cMainComposite, SWT.NONE);
gLimits.setText(MessageText.getString("label.limit.settings"));
gridLayout = new GridLayout(6, false);
gLimits.setLayout(gridLayout);
gd = new GridData(SWT.FILL, SWT.NONE, false, false, 4, 1);
gLimits.setLayoutData(gd);
label = new Label(gLimits, SWT.NONE);
Messages.setLanguageText(label, "TableColumn.header.max_taggables");
gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
Utils.setLayoutData(label, gd);
params.tfl_max_taggables = new GenericIntParameter(new GenericParameterAdapter() {
@Override
public int getIntValue(String key) {
return tfl.getMaximumTaggables();
}
@Override
public int getIntValue(String key, int def) {
return getIntValue(key);
}
@Override
public void setIntValue(String key, int value) {
tfl.setMaximumTaggables(value);
}
}, gLimits, null, 0, Integer.MAX_VALUE);
// we really don't want partial values to be set as the consequences may be very
// unwanted if a removal policy is already set...
params.tfl_max_taggables.disableTimedSave();
gd = new GridData();
// gd.horizontalSpan = 3;
gd.widthHint = 50;
params.tfl_max_taggables.setLayoutData(gd);
label = new Label(gLimits, SWT.NONE);
Messages.setLanguageText(label, "label.removal.policy");
params.tfl_removal_policy = new GenericStringListParameter(new GenericParameterAdapter() {
@Override
public String getStringListValue(String key) {
return (String.valueOf(tfl.getRemovalStrategy()));
}
@Override
public String getStringListValue(String key, String def) {
return (getStringListValue(key));
}
@Override
public void setStringListValue(String key, String value) {
tfl.setRemovalStrategy(value == null ? TagFeatureLimits.RS_DEFAULT : Integer.parseInt(value));
}
}, gLimits, null, new String[] { "", MessageText.getString("MyTorrentsView.menu.archive"), MessageText.getString("Button.deleteContent.fromLibrary"), MessageText.getString("Button.deleteContent.fromComputer"), MessageText.getString("label.move.to.old.tag") }, new String[] { "0", "1", "2", "3", "4" });
label = new Label(gLimits, SWT.NONE);
Messages.setLanguageText(label, "label.ordering");
params.tfl_ordering = new GenericStringListParameter(new GenericParameterAdapter() {
@Override
public String getStringListValue(String key) {
return (String.valueOf(tfl.getOrdering()));
}
@Override
public String getStringListValue(String key, String def) {
return (getStringListValue(key));
}
@Override
public void setStringListValue(String key, String value) {
tfl.setOrdering(value == null ? TagFeatureLimits.OP_DEFAULT : Integer.parseInt(value));
}
}, gLimits, null, new String[] { MessageText.getString("label.time.added.to.vuze"), MessageText.getString("label.time.added.to.tag") }, new String[] { "0", "1" });
}
}
if (numTags == 1 && tags[0].getTagType().hasTagTypeFeature(TagFeature.TF_NOTIFICATIONS)) {
final TagFeatureNotifications tfn = (TagFeatureNotifications) tags[0];
// notifications
Group gNotifications = new Group(cMainComposite, SWT.NONE);
gNotifications.setText(MessageText.getString("v3.MainWindow.tab.events"));
gridLayout = new GridLayout(6, false);
gNotifications.setLayout(gridLayout);
gd = new GridData(SWT.FILL, SWT.NONE, false, false, 4, 1);
gNotifications.setLayoutData(gd);
label = new Label(gNotifications, SWT.NONE);
label.setText(MessageText.getString("tag.notification.post") + ":");
params.notification_post_add = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return ((tfn.getPostingNotifications() & TagFeatureNotifications.NOTIFY_ON_ADD) != 0);
}
@Override
public void setBooleanValue(String key, boolean value) {
int flags = tfn.getPostingNotifications();
if (value) {
flags |= TagFeatureNotifications.NOTIFY_ON_ADD;
} else {
flags &= ~TagFeatureNotifications.NOTIFY_ON_ADD;
}
tfn.setPostingNotifications(flags);
}
}, gNotifications, null, "label.on.addition");
params.notification_post_remove = new GenericBooleanParameter(new BooleanParameterAdapter() {
@Override
public Boolean getBooleanValue(String key) {
return ((tfn.getPostingNotifications() & TagFeatureNotifications.NOTIFY_ON_REMOVE) != 0);
}
@Override
public void setBooleanValue(String key, boolean value) {
int flags = tfn.getPostingNotifications();
if (value) {
flags |= TagFeatureNotifications.NOTIFY_ON_REMOVE;
} else {
flags &= ~TagFeatureNotifications.NOTIFY_ON_REMOVE;
}
tfn.setPostingNotifications(flags);
}
}, gNotifications, null, "label.on.removal");
}
swt_updateFields();
}
cMainComposite.layout();
Rectangle r = sc.getClientArea();
sc.setMinSize(cMainComposite.computeSize(r.width, SWT.DEFAULT));
}
use of com.biglybt.ui.swt.config.generic.GenericIntParameter in project BiglyBT by BiglySoftware.
the class TorrentOptionsView method setDefaults.
protected void setDefaults() {
Iterator<?> it = ds_parameters.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
for (int i = 0; i < managers.length; i++) {
managers[i].setParameterDefault(key);
}
}
it = adhoc_parameters.values().iterator();
while (it.hasNext()) {
Object param = it.next();
if (param instanceof GenericIntParameter) {
GenericIntParameter int_param = (GenericIntParameter) param;
int_param.setValue(0, true);
} else {
Debug.out("Unknown parameter type: " + param.getClass());
}
}
}
use of com.biglybt.ui.swt.config.generic.GenericIntParameter in project BiglyBT by BiglySoftware.
the class TorrentOptionsView method parameterChanged.
/* (non-Javadoc)
* @see com.biglybt.core.download.DownloadManagerStateAttributeListener#attributeEventOccurred(com.biglybt.core.download.DownloadManager, java.lang.String, int)
*/
@Override
public void parameterChanged(DownloadManagerOptionsHandler manager) {
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
Iterator<Entry<String, Object>> it = ds_parameters.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
String key = entry.getKey();
Object param = entry.getValue();
if (param instanceof GenericIntParameter) {
GenericIntParameter int_param = (GenericIntParameter) param;
int value = manager.getIntParameter(key);
int_param.setValue(value);
} else if (param instanceof GenericBooleanParameter) {
GenericBooleanParameter bool_param = (GenericBooleanParameter) param;
boolean value = manager.getBooleanParameter(key);
bool_param.setSelected(value);
} else if (param instanceof GenericFloatParameter) {
GenericFloatParameter float_param = (GenericFloatParameter) param;
float value = manager.getIntParameter(key) / 1000f;
float_param.setValue(value);
} else {
Debug.out("Unknown parameter type: " + param.getClass());
}
}
}
}, true);
}
use of com.biglybt.ui.swt.config.generic.GenericIntParameter in project BiglyBT by BiglySoftware.
the class TorrentOptionsView method initialize.
private void initialize(Composite composite) {
this.parent = composite;
GridLayout layout;
// I don't want to waste my time :) [tux]
if (panel != null && !panel.isDisposed()) {
Utils.disposeComposite(panel, false);
} else {
panel = new Composite(composite, SWT.NULL);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 1;
panel.setLayout(layout);
Layout parentLayout = parent.getLayout();
if (parentLayout instanceof FormLayout) {
Utils.setLayoutData(panel, Utils.getFilledFormData());
} else {
Utils.setLayoutData(panel, new GridData(GridData.FILL_BOTH));
}
}
if (managers == null) {
return;
}
int userMode = COConfigurationManager.getIntParameter("User Mode");
// header
Composite cHeader = new Composite(panel, SWT.BORDER);
GridLayout configLayout = new GridLayout();
configLayout.marginHeight = 3;
configLayout.marginWidth = 0;
cHeader.setLayout(configLayout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
Utils.setLayoutData(cHeader, gridData);
Display d = panel.getDisplay();
cHeader.setBackground(Colors.getSystemColor(d, SWT.COLOR_LIST_SELECTION));
cHeader.setForeground(Colors.getSystemColor(d, SWT.COLOR_LIST_SELECTION_TEXT));
Label lHeader = new Label(cHeader, SWT.NULL);
lHeader.setBackground(Colors.getSystemColor(d, SWT.COLOR_LIST_SELECTION));
lHeader.setForeground(Colors.getSystemColor(d, SWT.COLOR_LIST_SELECTION_TEXT));
FontData[] fontData = lHeader.getFont().getFontData();
fontData[0].setStyle(SWT.BOLD);
int fontHeight = (int) (fontData[0].getHeight() * 1.2);
fontData[0].setHeight(fontHeight);
headerFont = new Font(d, fontData);
lHeader.setFont(headerFont);
if (managers.length == 1) {
if (managers[0].getDownloadManager() == null) {
lHeader.setText(" " + managers[0].getName().replaceAll("&", "&&"));
} else {
lHeader.setText(" " + MessageText.getString("authenticator.torrent") + " : " + managers[0].getName().replaceAll("&", "&&"));
}
} else {
String str = "";
for (int i = 0; i < Math.min(3, managers.length); i++) {
str += (i == 0 ? "" : ", ") + managers[i].getName().replaceAll("&", "&&");
}
if (managers.length > 3) {
str += "...";
}
lHeader.setText(" " + managers.length + " " + MessageText.getString("ConfigView.section.torrents") + " : " + str);
}
gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
Utils.setLayoutData(lHeader, gridData);
Group gTorrentOptions = new Group(panel, SWT.NULL);
Messages.setLanguageText(gTorrentOptions, "ConfigView.section.transfer");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
Utils.setLayoutData(gTorrentOptions, gridData);
layout = new GridLayout();
layout.numColumns = 2;
gTorrentOptions.setLayout(layout);
// Disabled for release. Need to convert from user-specified units to
// KB/s before restoring the following line
// String k_unit = DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB).trim()
String k_unit = DisplayFormatters.getRateUnitBase10(DisplayFormatters.UNIT_KB).trim();
// max upload speed
Label label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
label.setText(k_unit + " " + MessageText.getString("GeneralView.label.maxuploadspeed.tooltip"));
GenericIntParameter max_upload = new GenericIntParameter(adhoc_param_adapter, gTorrentOptions, MAX_UPLOAD);
adhoc_parameters.put(MAX_UPLOAD, max_upload);
gridData = new GridData();
max_upload.setLayoutData(gridData);
if (userMode > 0) {
// max upload when busy
label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "TorrentOptionsView.param.max.uploads.when.busy");
GenericIntParameter max_upload_when_busy = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_UPLOAD_WHEN_BUSY);
ds_parameters.put(DownloadManagerState.PARAM_MAX_UPLOAD_WHEN_BUSY, max_upload_when_busy);
gridData = new GridData();
max_upload_when_busy.setLayoutData(gridData);
}
// max download speed
label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
label.setText(k_unit + " " + MessageText.getString("GeneralView.label.maxdownloadspeed.tooltip"));
GenericIntParameter max_download = new GenericIntParameter(adhoc_param_adapter, gTorrentOptions, MAX_DOWNLOAD);
adhoc_parameters.put(MAX_DOWNLOAD, max_download);
gridData = new GridData();
max_download.setLayoutData(gridData);
if (userMode > 0) {
label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "TorrentOptionsView.param.max.uploads");
GenericIntParameter max_uploads = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_UPLOADS);
ds_parameters.put(DownloadManagerState.PARAM_MAX_UPLOADS, max_uploads);
max_uploads.setMinimumValue(2);
gridData = new GridData();
max_uploads.setLayoutData(gridData);
// max uploads when seeding enabled
final Composite cMaxUploadsOptionsArea = new Composite(gTorrentOptions, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
layout.marginHeight = 0;
cMaxUploadsOptionsArea.setLayout(layout);
gridData = new GridData();
gridData.horizontalIndent = 15;
gridData.horizontalSpan = 2;
Utils.setLayoutData(cMaxUploadsOptionsArea, gridData);
label = new Label(cMaxUploadsOptionsArea, SWT.NULL);
ImageLoader.getInstance().setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
Utils.setLayoutData(label, gridData);
gridData = new GridData();
GenericBooleanParameter max_uploads_when_seeding_enabled = new GenericBooleanParameter(ds_param_adapter, cMaxUploadsOptionsArea, DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING_ENABLED, false, "TorrentOptionsView.param.alternative.value.enable");
ds_parameters.put(DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING_ENABLED, max_uploads_when_seeding_enabled);
max_uploads_when_seeding_enabled.setLayoutData(gridData);
GenericIntParameter max_uploads_when_seeding = new GenericIntParameter(ds_param_adapter, cMaxUploadsOptionsArea, DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING);
ds_parameters.put(DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING, max_uploads_when_seeding);
gridData = new GridData();
max_uploads_when_seeding.setMinimumValue(2);
max_uploads_when_seeding.setLayoutData(gridData);
max_uploads_when_seeding_enabled.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(max_uploads_when_seeding.getControl()));
// max peers
label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "TorrentOptionsView.param.max.peers");
GenericIntParameter max_peers = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_PEERS);
ds_parameters.put(DownloadManagerState.PARAM_MAX_PEERS, max_peers);
gridData = new GridData();
max_peers.setLayoutData(gridData);
// max peers when seeding
final Composite cMaxPeersOptionsArea = new Composite(gTorrentOptions, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
layout.marginHeight = 0;
cMaxPeersOptionsArea.setLayout(layout);
gridData = new GridData();
gridData.horizontalIndent = 15;
gridData.horizontalSpan = 2;
Utils.setLayoutData(cMaxPeersOptionsArea, gridData);
label = new Label(cMaxPeersOptionsArea, SWT.NULL);
ImageLoader.getInstance().setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
Utils.setLayoutData(label, gridData);
gridData = new GridData();
GenericBooleanParameter max_peers_when_seeding_enabled = new GenericBooleanParameter(ds_param_adapter, cMaxPeersOptionsArea, DownloadManagerState.PARAM_MAX_PEERS_WHEN_SEEDING_ENABLED, false, "TorrentOptionsView.param.alternative.value.enable");
ds_parameters.put(DownloadManagerState.PARAM_MAX_PEERS_WHEN_SEEDING_ENABLED, max_peers_when_seeding_enabled);
max_peers_when_seeding_enabled.setLayoutData(gridData);
GenericIntParameter max_peers_when_seeding = new GenericIntParameter(ds_param_adapter, cMaxPeersOptionsArea, DownloadManagerState.PARAM_MAX_PEERS_WHEN_SEEDING);
ds_parameters.put(DownloadManagerState.PARAM_MAX_PEERS_WHEN_SEEDING, max_peers_when_seeding);
gridData = new GridData();
max_peers_when_seeding.setLayoutData(gridData);
max_peers_when_seeding_enabled.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(max_peers_when_seeding.getControl()));
// max seeds
label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "TorrentOptionsView.param.max.seeds");
GenericIntParameter max_seeds = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_SEEDS);
ds_parameters.put(DownloadManagerState.PARAM_MAX_SEEDS, max_seeds);
gridData = new GridData();
max_seeds.setLayoutData(gridData);
}
if (userMode > 0) {
label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "TorrentOptionsView.param.upload.priority");
gridData = new GridData();
GenericIntParameter upload_priority_enabled = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_UPLOAD_PRIORITY, 0, 1);
ds_parameters.put(DownloadManagerState.PARAM_UPLOAD_PRIORITY, upload_priority_enabled);
upload_priority_enabled.setLayoutData(gridData);
// min sr
label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "TableColumn.header.min_sr");
gridData = new GridData();
gridData.widthHint = 50;
GenericFloatParameter min_sr = new GenericFloatParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MIN_SHARE_RATIO, 0, Float.MAX_VALUE, true, 3);
ds_parameters.put(DownloadManagerState.PARAM_MIN_SHARE_RATIO, min_sr);
min_sr.setLayoutData(gridData);
// max sr
label = new Label(gTorrentOptions, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "TableColumn.header.max_sr");
gridData = new GridData();
gridData.widthHint = 50;
GenericFloatParameter max_sr = new GenericFloatParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_SHARE_RATIO, 0, Float.MAX_VALUE, true, 3);
ds_parameters.put(DownloadManagerState.PARAM_MAX_SHARE_RATIO, max_sr);
max_sr.setLayoutData(gridData);
}
// reset
Label reset_label = new Label(gTorrentOptions, SWT.NULL);
Messages.setLanguageText(reset_label, "TorrentOptionsView.param.reset.to.default");
Button reset_button = new Button(gTorrentOptions, SWT.PUSH);
Messages.setLanguageText(reset_button, "TorrentOptionsView.param.reset.button");
reset_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
setDefaults();
}
});
for (int i = 0; i < managers.length; i++) {
managers[i].addListener(this);
}
Group gTorrentInfo = new Group(panel, SWT.NULL);
Messages.setLanguageText(gTorrentInfo, "label.aggregate.info");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
Utils.setLayoutData(gTorrentInfo, gridData);
layout = new GridLayout();
layout.numColumns = 2;
gTorrentInfo.setLayout(layout);
// total size
label = new Label(gTorrentInfo, SWT.NULL);
label.setText(MessageText.getString("TableColumn.header.size") + ": ");
agg_size = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
agg_size.setLayoutData(gridData);
// remaining
label = new Label(gTorrentInfo, SWT.NULL);
label.setText(MessageText.getString("TableColumn.header.remaining") + ": ");
agg_remaining = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
agg_remaining.setLayoutData(gridData);
// uploaded
label = new Label(gTorrentInfo, SWT.NULL);
label.setText(MessageText.getString("MyTracker.column.uploaded") + ": ");
agg_uploaded = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
agg_uploaded.setLayoutData(gridData);
// downloaded
label = new Label(gTorrentInfo, SWT.NULL);
label.setText(MessageText.getString("MyTracker.column.downloaded") + ": ");
agg_downloaded = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
agg_downloaded.setLayoutData(gridData);
// upload speed
label = new Label(gTorrentInfo, SWT.NULL);
label.setText(MessageText.getString("SpeedView.uploadSpeed.title") + ": ");
agg_upload_speed = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
agg_upload_speed.setLayoutData(gridData);
// download speed
label = new Label(gTorrentInfo, SWT.NULL);
label.setText(MessageText.getString("SpeedView.downloadSpeed.title") + ": ");
agg_download_speed = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
agg_download_speed.setLayoutData(gridData);
// share ratio
label = new Label(gTorrentInfo, SWT.NULL);
label.setText(MessageText.getString("TableColumn.header.shareRatio") + ": ");
agg_share_ratio = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
agg_share_ratio.setLayoutData(gridData);
// reset
Label stats_reset_label = new Label(gTorrentInfo, SWT.NULL);
Messages.setLanguageText(stats_reset_label, "TorrentOptionsView.param.reset.stats");
Button stats_reset_button = new Button(gTorrentInfo, SWT.PUSH);
Messages.setLanguageText(stats_reset_button, "TorrentOptionsView.param.reset.button");
stats_reset_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
for (DownloadManagerOptionsHandler dm : managers) {
if (dm.getDownloadManager() != null) {
dm.getDownloadManager().getStats().resetTotalBytesSentReceived(0, 0);
}
}
}
});
panel.layout(true, true);
}
Aggregations