use of com.biglybt.ui.swt.config.ParameterChangeAdapter in project BiglyBT by BiglySoftware.
the class ViewQuickConfig method initialize.
private void initialize(Composite ooparent) {
GridLayout layout = new GridLayout(1, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
ooparent.setLayout(layout);
// if you put the border on the scrolled composite parent then on every resize the computedSize
// grows by 4 pixels :( So stick in extra composite for the border
final Composite oparent = new Composite(ooparent, SWT.BORDER);
GridData gridData = new GridData(GridData.FILL_BOTH);
Utils.setLayoutData(oparent, gridData);
layout = new GridLayout(1, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
oparent.setLayout(layout);
final Composite parent = new Composite(oparent, SWT.NULL);
gridData = new GridData(GridData.FILL_BOTH);
Utils.setLayoutData(parent, gridData);
layout = new GridLayout(1, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
parent.setLayout(layout);
final ScrolledComposite sc = new ScrolledComposite(parent, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event event) {
int width = sc.getClientArea().width;
Point size = parent.computeSize(width, SWT.DEFAULT);
sc.setMinSize(size);
}
});
gridData = new GridData(GridData.FILL_BOTH);
Utils.setLayoutData(sc, gridData);
composite = new Composite(sc, SWT.NULL);
sc.setContent(composite);
gridData = new GridData(GridData.FILL_BOTH);
Utils.setLayoutData(composite, gridData);
layout = new GridLayout(4, false);
composite.setLayout(layout);
// done downloading - 2
ConfigSectionStartShutdown.addDoneDownloadingOption(composite, false);
// max simul down - 2
Label label = new Label(composite, SWT.NULL);
gridData = new GridData();
gridData.horizontalIndent = 8;
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "ConfigView.label.maxdownloads.short");
IntParameter maxDLs = new IntParameter(composite, "max downloads");
maxDLs.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
COConfigurationManager.setDirty();
}
});
addTemporaryRates(composite);
addTemporaryData(composite);
Utils.execSWTThreadLater(100, new Runnable() {
@Override
public void run() {
composite.traverse(SWT.TRAVERSE_TAB_NEXT);
}
});
}
use of com.biglybt.ui.swt.config.ParameterChangeAdapter in project BiglyBT by BiglySoftware.
the class ViewQuickConfig method addTemporaryRates.
private void addTemporaryRates(Composite composite) {
Group temp_rates = new Group(composite, SWT.NULL);
Messages.setLanguageText(temp_rates, "label.temporary.rates");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
Utils.setLayoutData(temp_rates, gridData);
GridLayout layout = new GridLayout(10, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
temp_rates.setLayout(layout);
// label = new Label(temp_rates, SWT.NULL);
// Messages.setLanguageText( label, "label.temporary.rates" );
Label label = new Label(temp_rates, SWT.NULL);
gridData = new GridData();
gridData.horizontalIndent = 4;
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "label.upload.kbps", new String[] { DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB) });
final IntParameter tempULRate = new IntParameter(temp_rates, "global.download.rate.temp.kbps", 0, Integer.MAX_VALUE);
label = new Label(temp_rates, SWT.NULL);
Messages.setLanguageText(label, "label.download.kbps", new String[] { DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB) });
final IntParameter tempDLRate = new IntParameter(temp_rates, "global.upload.rate.temp.kbps", 0, Integer.MAX_VALUE);
label = new Label(temp_rates, SWT.NULL);
Messages.setLanguageText(label, "label.duration.mins");
final IntParameter tempMins = new IntParameter(temp_rates, "global.rate.temp.min", 0, Integer.MAX_VALUE);
final Button activate = new Button(temp_rates, SWT.TOGGLE);
Messages.setLanguageText(activate, "label.activate");
final BufferedLabel remLabel = new BufferedLabel(temp_rates, SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.widthHint = 150;
Utils.setLayoutData(remLabel, gridData);
activate.addSelectionListener(new SelectionAdapter() {
private CoreLifecycleAdapter listener;
private TimerEventPeriodic event;
private boolean auto_up_enabled;
private boolean auto_up_seeding_enabled;
private boolean seeding_limits_enabled;
private int up_limit;
private int down_limit;
private long end_time;
@Override
public void widgetSelected(SelectionEvent e) {
if (activate.getSelection()) {
listener = new CoreLifecycleAdapter() {
@Override
public void stopping(Core core) {
deactivate(true);
}
};
CoreFactory.getSingleton().addLifecycleListener(listener);
Messages.setLanguageText(activate, "FileView.BlockView.Active");
tempDLRate.setEnabled(false);
tempULRate.setEnabled(false);
tempMins.setEnabled(false);
auto_up_enabled = COConfigurationManager.getBooleanParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY);
auto_up_seeding_enabled = COConfigurationManager.getBooleanParameter(TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY);
seeding_limits_enabled = COConfigurationManager.getBooleanParameter(TransferSpeedValidator.UPLOAD_SEEDING_ENABLED_CONFIGKEY);
up_limit = COConfigurationManager.getIntParameter(TransferSpeedValidator.UPLOAD_CONFIGKEY);
down_limit = COConfigurationManager.getIntParameter(TransferSpeedValidator.DOWNLOAD_CONFIGKEY);
COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY, false);
COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY, false);
COConfigurationManager.setParameter(TransferSpeedValidator.UPLOAD_SEEDING_ENABLED_CONFIGKEY, false);
COConfigurationManager.setParameter(TransferSpeedValidator.UPLOAD_CONFIGKEY, tempULRate.getValue());
COConfigurationManager.setParameter(TransferSpeedValidator.DOWNLOAD_CONFIGKEY, tempDLRate.getValue());
end_time = SystemTime.getCurrentTime() + tempMins.getValue() * 60 * 1000;
event = SimpleTimer.addPeriodicEvent("TempRates", 1000, new TimerEventPerformer() {
@Override
public void perform(TimerEvent e) {
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
if (event == null) {
return;
}
long now = SystemTime.getCurrentTime();
long rem = end_time - now;
if (rem < 1000 || composite.isDisposed()) {
deactivate(false);
} else {
remLabel.setText(MessageText.getString("TableColumn.header.remaining") + ": " + DisplayFormatters.formatTime(rem));
}
}
});
}
});
} else {
deactivate(false);
}
}
private void deactivate(boolean closing) {
COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY, auto_up_enabled);
COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY, auto_up_seeding_enabled);
COConfigurationManager.setParameter(TransferSpeedValidator.UPLOAD_SEEDING_ENABLED_CONFIGKEY, seeding_limits_enabled);
COConfigurationManager.setParameter(TransferSpeedValidator.UPLOAD_CONFIGKEY, up_limit);
COConfigurationManager.setParameter(TransferSpeedValidator.DOWNLOAD_CONFIGKEY, down_limit);
if (!closing) {
if (listener != null) {
CoreFactory.getSingleton().removeLifecycleListener(listener);
listener = null;
}
if (!composite.isDisposed()) {
Messages.setLanguageText(activate, "label.activate");
activate.setSelection(false);
tempDLRate.setEnabled(true);
tempULRate.setEnabled(true);
tempMins.setEnabled(true);
remLabel.setText("");
}
}
if (event != null) {
event.cancel();
event = null;
}
}
});
activate.setEnabled(tempMins.getValue() > 0);
tempMins.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
activate.setEnabled(tempMins.getValue() > 0);
}
});
}
use of com.biglybt.ui.swt.config.ParameterChangeAdapter in project BiglyBT by BiglySoftware.
the class ViewQuickConfig method addTemporaryData.
private void addTemporaryData(Composite composite) {
Group temp_rates = new Group(composite, SWT.NULL);
Messages.setLanguageText(temp_rates, "label.temporary.data");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
Utils.setLayoutData(temp_rates, gridData);
GridLayout layout = new GridLayout(10, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
temp_rates.setLayout(layout);
// label = new Label(temp_rates, SWT.NULL);
// Messages.setLanguageText( label, "label.temporary.rates" );
Label label = new Label(temp_rates, SWT.NULL);
gridData = new GridData();
gridData.horizontalIndent = 4;
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "label.upload.mb", new String[] { DisplayFormatters.getUnit(DisplayFormatters.UNIT_MB) });
final IntParameter tempULLimit = new IntParameter(temp_rates, "global.upload.limit.temp.mb", 0, Integer.MAX_VALUE);
label = new Label(temp_rates, SWT.NULL);
Messages.setLanguageText(label, "label.download.mb", new String[] { DisplayFormatters.getUnit(DisplayFormatters.UNIT_MB) });
final IntParameter tempDLLimit = new IntParameter(temp_rates, "global.download.limit.temp.mb", 0, Integer.MAX_VALUE);
final Button activate = new Button(temp_rates, SWT.TOGGLE);
Messages.setLanguageText(activate, "label.activate");
final BufferedLabel remLabel = new BufferedLabel(temp_rates, SWT.DOUBLE_BUFFERED);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.widthHint = 200;
Utils.setLayoutData(remLabel, gridData);
activate.addSelectionListener(new SelectionAdapter() {
private CoreLifecycleAdapter listener;
private TimerEventPeriodic event;
private long end_upload;
private long end_download;
@Override
public void widgetSelected(SelectionEvent e) {
if (activate.getSelection()) {
listener = new CoreLifecycleAdapter() {
@Override
public void stopping(Core core) {
deactivate(true);
}
};
Core core = CoreFactory.getSingleton();
core.addLifecycleListener(listener);
Messages.setLanguageText(activate, "FileView.BlockView.Active");
final GlobalManagerStats stats = core.getGlobalManager().getStats();
tempULLimit.setEnabled(false);
tempDLLimit.setEnabled(false);
long u_limit = tempULLimit.getValue();
if (u_limit > 0) {
end_upload = stats.getTotalDataProtocolBytesSent() + u_limit * DisplayFormatters.getMinB();
} else {
end_upload = 0;
}
long d_limit = tempDLLimit.getValue();
if (d_limit > 0) {
end_download = stats.getTotalDataProtocolBytesReceived() + d_limit * DisplayFormatters.getMinB();
} else {
end_download = 0;
}
event = SimpleTimer.addPeriodicEvent("TempData", 5000, new TimerEventPerformer() {
@Override
public void perform(TimerEvent e) {
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
if (event == null) {
return;
}
long rem_up = 0;
long rem_down = 0;
if (end_upload > 0) {
rem_up = end_upload - stats.getTotalDataProtocolBytesSent();
}
if (end_download > 0) {
rem_down = end_download - stats.getTotalDataProtocolBytesReceived();
}
if (end_upload > 0 && rem_up <= 0) {
java.util.List<DownloadManager> dms = core.getGlobalManager().getDownloadManagers();
for (DownloadManager dm : dms) {
if (!dm.isForceStart()) {
int state = dm.getState();
if (state != DownloadManager.STATE_STOPPED && state != DownloadManager.STATE_ERROR && !dm.isPaused()) {
ManagerUtils.stop(dm, null);
dm.setStopReason(MessageText.getString("label.temporary.data"));
}
}
}
}
if (end_download > 0 && rem_down <= 0) {
java.util.List<DownloadManager> dms = core.getGlobalManager().getDownloadManagers();
for (DownloadManager dm : dms) {
if (!dm.isForceStart()) {
int state = dm.getState();
if (state != DownloadManager.STATE_STOPPED && state != DownloadManager.STATE_ERROR && !dm.isPaused()) {
if (!dm.isDownloadComplete(false)) {
ManagerUtils.stop(dm, null);
dm.setStopReason(MessageText.getString("label.temporary.data"));
}
}
}
}
}
if ((rem_up <= 0 && rem_down <= 0) || composite.isDisposed()) {
deactivate(false);
} else {
remLabel.setText(MessageText.getString("TableColumn.header.remaining") + ": " + DisplayFormatters.formatByteCountToKiBEtc(rem_up < 0 ? 0 : rem_up) + "/" + DisplayFormatters.formatByteCountToKiBEtc(rem_down < 0 ? 0 : rem_down));
temp_rates.layout(new Control[] { remLabel.getControl() });
}
}
});
}
});
} else {
deactivate(false);
}
}
private void deactivate(boolean closing) {
if (!closing) {
if (listener != null) {
CoreFactory.getSingleton().removeLifecycleListener(listener);
listener = null;
}
if (!composite.isDisposed()) {
Messages.setLanguageText(activate, "label.activate");
activate.setSelection(false);
tempULLimit.setEnabled(true);
tempDLLimit.setEnabled(true);
remLabel.setText("");
temp_rates.layout(true);
}
}
if (event != null) {
event.cancel();
event = null;
}
}
});
activate.setEnabled(tempULLimit.getValue() > 0 || tempDLLimit.getValue() > 0);
ParameterChangeAdapter adapter = new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
activate.setEnabled(tempULLimit.getValue() > 0 || tempDLLimit.getValue() > 0);
}
};
tempULLimit.addChangeListener(adapter);
tempDLLimit.addChangeListener(adapter);
}
use of com.biglybt.ui.swt.config.ParameterChangeAdapter in project BiglyBT by BiglySoftware.
the class BuddyPluginViewInstance method createBeta.
private void createBeta(Composite main) {
Utils.disposeComposite(main, false);
final BuddyPluginBeta plugin_beta = plugin.getBeta();
GridLayout layout = new GridLayout();
layout.numColumns = 3;
main.setLayout(layout);
GridData grid_data = new GridData(GridData.FILL_BOTH);
Utils.setLayoutData(main, grid_data);
beta_enabled = plugin.isBetaEnabled();
if (!beta_enabled) {
Label control_label = new Label(main, SWT.NULL);
control_label.setText(lu.getLocalisedMessageText("azbuddy.disabled"));
Label label = new Label(main, SWT.NULL);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
label.setLayoutData(grid_data);
final Button config_button = new Button(main, SWT.NULL);
config_button.setText(lu.getLocalisedMessageText("plugins.basicview.config"));
config_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
plugin.showConfig();
}
});
return;
}
final BuddyPluginBeta beta = plugin.getBeta();
boolean i2p_enabled = plugin_beta.isI2PAvailable();
// info
Composite info_area = new Composite(main, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 4;
layout.marginHeight = 0;
layout.marginWidth = 0;
info_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 3;
Utils.setLayoutData(info_area, grid_data);
Label label = new Label(info_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.info"));
new LinkLabel(info_area, "ConfigView.label.please.visit.here", lu.getLocalisedMessageText("azbuddy.dchat.link.url"));
label = new Label(info_area, SWT.NULL);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
label.setLayoutData(grid_data);
final Button config_button = new Button(info_area, SWT.NULL);
config_button.setText(lu.getLocalisedMessageText("plugins.basicview.config"));
config_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
plugin.showConfig();
}
});
// install plugin
label = new Label(info_area, SWT.NULL);
label.setText(MessageText.getString("azmsgsync.install.text"));
plugin_install_button = new Button(info_area, SWT.NULL);
plugin_install_button.setText(MessageText.getString("UpdateWindow.columns.install"));
plugin_install_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
plugin_install_button.setEnabled(false);
new AEThread2("installer") {
@Override
public void run() {
boolean ok = false;
String msg;
try {
installMsgSyncPlugin();
msg = MessageText.getString("azmsgsync.install.ok.msg");
ok = true;
} catch (Throwable e) {
msg = MessageText.getString("azmsgsync.install.fail.msg", new String[] { Debug.getNestedExceptionMessage(e) });
} finally {
if (!checkMsgSyncPlugin()) {
if (ok) {
// something weird happened
ok = false;
msg = MessageText.getString("azmsgsync.install.fail.msg", new String[] { "Unexpected error, check logs" });
}
}
}
plugin.getPluginInterface().getUIManager().showMessageBox(ok ? "aztorplugin.browser.install.ok" : "aztorplugin.browser.install.fail", "!" + msg + "!", UIManagerEvent.MT_OK);
}
}.start();
}
});
label = new Label(info_area, SWT.NULL);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 2;
label.setLayoutData(grid_data);
checkMsgSyncPlugin();
// UI
final Group ui_area = new Group(main, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
ui_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 3;
Utils.setLayoutData(ui_area, grid_data);
ui_area.setText(lu.getLocalisedMessageText("ConfigView.section.style"));
// shared public nick
label = new Label(ui_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.public.nick"));
public_nickname = new Text(ui_area, SWT.BORDER);
grid_data = new GridData();
grid_data.widthHint = 200;
Utils.setLayoutData(public_nickname, grid_data);
public_nickname.setText(plugin_beta.getSharedPublicNickname());
public_nickname.addListener(SWT.FocusOut, new Listener() {
@Override
public void handleEvent(Event event) {
plugin_beta.setSharedPublicNickname(public_nickname.getText().trim());
}
});
label = new Label(ui_area, SWT.NULL);
// shared anon nick
label = new Label(ui_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.anon.nick"));
anon_nickname = new Text(ui_area, SWT.BORDER);
grid_data = new GridData();
grid_data.widthHint = 200;
Utils.setLayoutData(anon_nickname, grid_data);
anon_nickname.setText(plugin_beta.getSharedAnonNickname());
anon_nickname.addListener(SWT.FocusOut, new Listener() {
@Override
public void handleEvent(Event event) {
plugin_beta.setSharedAnonNickname(anon_nickname.getText().trim());
}
});
label = new Label(ui_area, SWT.NULL);
// max lines
label = new Label(ui_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.max.lines"));
final IntParameter max_lines = new IntParameter(ui_area, "azbuddy.chat.temp.ui.max.lines", 128, Integer.MAX_VALUE);
max_lines.setValue(beta.getMaxUILines());
max_lines.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
beta.setMaxUILines(max_lines.getValue());
}
});
label = new Label(ui_area, SWT.NULL);
// max chars
label = new Label(ui_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.max.kb"));
final IntParameter max_chars = new IntParameter(ui_area, "azbuddy.chat.temp.ui.max.chars", 1, 512);
max_chars.setValue(beta.getMaxUICharsKB());
max_chars.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
beta.setMaxUICharsKB(max_chars.getValue());
}
});
label = new Label(ui_area, SWT.NULL);
// hide ratings
final Button hide_ratings = new Button(ui_area, SWT.CHECK);
hide_ratings.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.hide.ratings"));
hide_ratings.setSelection(plugin_beta.getHideRatings());
hide_ratings.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setHideRatings(hide_ratings.getSelection());
}
});
label = new Label(ui_area, SWT.NULL);
grid_data = new GridData();
grid_data.horizontalSpan = 2;
Utils.setLayoutData(label, grid_data);
// hide search/subcriptions
final Button hide_search_subs = new Button(ui_area, SWT.CHECK);
hide_search_subs.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.hide.search_subs"));
hide_search_subs.setSelection(plugin_beta.getHideSearchSubs());
hide_search_subs.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setHideSearchSubs(hide_search_subs.getSelection());
}
});
label = new Label(ui_area, SWT.NULL);
grid_data = new GridData();
grid_data.horizontalSpan = 2;
Utils.setLayoutData(label, grid_data);
// standalone windows
final Button stand_alone = new Button(ui_area, SWT.CHECK);
stand_alone.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.standalone.windows"));
stand_alone.setSelection(plugin_beta.getStandAloneWindows());
stand_alone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setStandAloneWindows(stand_alone.getSelection());
}
});
label = new Label(ui_area, SWT.NULL);
grid_data = new GridData();
grid_data.horizontalSpan = 2;
Utils.setLayoutData(label, grid_data);
// popout windows -> sidebar
final Button windows_to_sidebar = new Button(ui_area, SWT.CHECK);
windows_to_sidebar.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.windows.to.sidebar"));
windows_to_sidebar.setSelection(plugin_beta.getWindowsToSidebar());
windows_to_sidebar.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setWindowsToSidebar(windows_to_sidebar.getSelection());
}
});
// notifications
final Group noti_area = new Group(main, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 4;
noti_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 3;
Utils.setLayoutData(noti_area, grid_data);
noti_area.setText(lu.getLocalisedMessageText("v3.MainWindow.tab.events"));
final Button sound_enable = new Button(noti_area, SWT.CHECK);
sound_enable.setText(lu.getLocalisedMessageText("azbuddy.dchat.noti.sound"));
boolean sound_enabled = plugin_beta.getSoundEnabled();
sound_enable.setSelection(sound_enabled);
sound_enable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setSoundEnabled(sound_enable.getSelection());
}
});
final Text noti_file = new Text(noti_area, SWT.BORDER);
grid_data = new GridData();
grid_data.widthHint = 400;
Utils.setLayoutData(noti_file, grid_data);
String sound_file = plugin_beta.getSoundFile();
if (sound_file.length() == 0) {
sound_file = "<default>";
}
noti_file.setText(sound_file);
noti_file.addListener(SWT.FocusOut, new Listener() {
@Override
public void handleEvent(Event event) {
String val = noti_file.getText().trim();
if (val.length() == 0 || val.startsWith("<")) {
noti_file.setText("<default>");
val = "";
}
if (!val.equals(plugin_beta.getSoundFile())) {
plugin_beta.setSoundFile(val);
}
}
});
final Button noti_browse = new Button(noti_area, SWT.PUSH);
final ImageLoader imageLoader = ImageLoader.getInstance();
final Image imgOpenFolder = imageLoader.getImage("openFolderButton");
noti_area.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
imageLoader.releaseImage("openFolderButton");
}
});
noti_browse.setImage(imgOpenFolder);
imgOpenFolder.setBackground(noti_browse.getBackground());
noti_browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));
noti_browse.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
FileDialog dialog = new FileDialog(noti_area.getShell(), SWT.APPLICATION_MODAL);
dialog.setFilterExtensions(new String[] { "*.wav" });
dialog.setFilterNames(new String[] { "*.wav" });
dialog.setText(MessageText.getString("ConfigView.section.interface.wavlocation"));
String path = dialog.open();
if (path != null) {
path = path.trim();
if (path.startsWith("<")) {
path = "";
}
plugin_beta.setSoundFile(path.trim());
}
view.playSound();
}
});
label = new Label(noti_area, SWT.WRAP);
label.setText(MessageText.getString("ConfigView.section.interface.wavlocation.info"));
if (!sound_enabled) {
noti_file.setEnabled(false);
noti_browse.setEnabled(false);
}
final Button flash_enable = new Button(noti_area, SWT.CHECK);
flash_enable.setText(lu.getLocalisedMessageText("azbuddy.dchat.noti.flash"));
flash_enable.setSelection(plugin_beta.getFlashEnabled());
flash_enable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setFlashEnabled(flash_enable.getSelection());
}
});
// private chats
Group private_chat_area = new Group(main, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
// layout.marginHeight = 0;
// layout.marginWidth = 0;
private_chat_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 3;
Utils.setLayoutData(private_chat_area, grid_data);
private_chat_area.setText(lu.getLocalisedMessageText("label.private.chat"));
label = new Label(private_chat_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.pc.enable"));
final Button private_chat_enable = new Button(private_chat_area, SWT.CHECK);
label = new Label(private_chat_area, SWT.NULL);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, grid_data);
private_chat_enable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setPrivateChatState(private_chat_enable.getSelection() ? BuddyPluginBeta.PRIVATE_CHAT_ENABLED : BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
}
});
final Label pc_pinned_only = new Label(private_chat_area, SWT.NULL);
pc_pinned_only.setText(lu.getLocalisedMessageText("azbuddy.dchat.pc.pinned.only"));
final Button private_chat_pinned = new Button(private_chat_area, SWT.CHECK);
label = new Label(private_chat_area, SWT.NULL);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, grid_data);
private_chat_pinned.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setPrivateChatState(private_chat_pinned.getSelection() ? BuddyPluginBeta.PRIVATE_CHAT_PINNED_ONLY : BuddyPluginBeta.PRIVATE_CHAT_ENABLED);
}
});
int pc_state = plugin_beta.getPrivateChatState();
private_chat_enable.setSelection(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
private_chat_pinned.setSelection(pc_state == BuddyPluginBeta.PRIVATE_CHAT_PINNED_ONLY);
private_chat_pinned.setEnabled(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
pc_pinned_only.setEnabled(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
// import
Group import_area = new Group(main, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
import_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 3;
Utils.setLayoutData(import_area, grid_data);
import_area.setText(lu.getLocalisedMessageText("azbuddy.dchat.cannel.import"));
label = new Label(import_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.import.data"));
final Text import_data = new Text(import_area, SWT.BORDER);
grid_data = new GridData();
grid_data.widthHint = 400;
Utils.setLayoutData(import_data, grid_data);
final Button import_button = new Button(import_area, SWT.NULL);
import_button.setText(lu.getLocalisedMessageText("br.restore"));
import_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
import_button.setEnabled(false);
final Display display = composite.getDisplay();
final String data = import_data.getText().trim();
new AEThread2("async") {
@Override
public void run() {
if (display.isDisposed()) {
return;
}
try {
final BuddyPluginBeta.ChatInstance inst = plugin_beta.importChat(data);
display.asyncExec(new Runnable() {
@Override
public void run() {
if (!display.isDisposed()) {
BuddyPluginViewBetaChat.createChatWindow(view, plugin, inst);
import_button.setEnabled(true);
}
}
});
} catch (Throwable e) {
display.asyncExec(new Runnable() {
@Override
public void run() {
if (!import_button.isDisposed()) {
import_button.setEnabled(true);
}
}
});
Debug.out(e);
}
}
}.start();
}
});
// Advanced
Group adv_area = new Group(main, SWT.NULL);
adv_area.setText(lu.getLocalisedMessageText("MyTorrentsView.menu.advancedmenu"));
layout = new GridLayout();
layout.numColumns = 3;
adv_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 3;
Utils.setLayoutData(adv_area, grid_data);
// shared endpoint
label = new Label(adv_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.anon.share.endpoint"));
final Button shared_endpoint = new Button(adv_area, SWT.CHECK);
shared_endpoint.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
plugin_beta.setSharedAnonEndpoint(shared_endpoint.getSelection());
}
});
shared_endpoint.setSelection(plugin_beta.getSharedAnonEndpoint());
label = new Label(adv_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.anon.share.endpoint.info"));
grid_data = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, grid_data);
// testing
Group test_area = new Group(main, SWT.NULL);
test_area.setText(lu.getLocalisedMessageText("br.test"));
layout = new GridLayout();
layout.numColumns = 4;
test_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 3;
Utils.setLayoutData(test_area, grid_data);
// public beta channel
label = new Label(test_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.public.beta"));
Button beta_button = new Button(test_area, SWT.NULL);
setupButton(beta_button, lu.getLocalisedMessageText("Button.open"), AENetworkClassifier.AT_PUBLIC, new String[] { BuddyPluginBeta.BETA_CHAT_KEY, BuddyPluginBeta.LEGACY_BETA_CHAT_KEY });
label = new Label(test_area, SWT.NULL);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 2;
Utils.setLayoutData(label, grid_data);
// anonymous beta channel
label = new Label(test_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.anon.beta"));
Button beta_i2p_button = new Button(test_area, SWT.NULL);
setupButton(beta_i2p_button, lu.getLocalisedMessageText("Button.open"), AENetworkClassifier.AT_I2P, new String[] { BuddyPluginBeta.BETA_CHAT_KEY, BuddyPluginBeta.LEGACY_BETA_CHAT_KEY });
beta_i2p_button.setEnabled(i2p_enabled);
label = new Label(test_area, SWT.NULL);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 2;
Utils.setLayoutData(label, grid_data);
// create custom channel
label = new Label(test_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.create.join.key"));
final Text channel_key = new Text(test_area, SWT.BORDER);
grid_data = new GridData();
grid_data.widthHint = 200;
Utils.setLayoutData(channel_key, grid_data);
final Button create_i2p_button = new Button(test_area, SWT.CHECK);
create_i2p_button.setText(lu.getLocalisedMessageText("label.anon.i2p"));
create_i2p_button.setEnabled(i2p_enabled);
final Button create_button = new Button(test_area, SWT.NULL);
create_button.setText(lu.getLocalisedMessageText("Button.open"));
create_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
create_button.setEnabled(false);
final Display display = composite.getDisplay();
final String network = create_i2p_button.getSelection() ? AENetworkClassifier.AT_I2P : AENetworkClassifier.AT_PUBLIC;
final String key = channel_key.getText().trim();
new AEThread2("async") {
@Override
public void run() {
if (display.isDisposed()) {
return;
}
try {
final BuddyPluginBeta.ChatInstance inst = plugin_beta.getChat(network, key);
display.asyncExec(new Runnable() {
@Override
public void run() {
if (!display.isDisposed()) {
BuddyPluginViewBetaChat.createChatWindow(view, plugin, inst);
create_button.setEnabled(true);
}
}
});
} catch (Throwable e) {
display.asyncExec(new Runnable() {
@Override
public void run() {
if (!create_button.isDisposed()) {
create_button.setEnabled(true);
}
}
});
Debug.out(e);
}
}
}.start();
}
});
// end of UI
List<Button> buttons = new ArrayList<>();
buttons.add(create_button);
buttons.add(beta_button);
buttons.add(beta_i2p_button);
buttons.add(import_button);
Utils.makeButtonsEqualWidth(buttons);
plugin.addListener(new BuddyPluginAdapter() {
@Override
public void updated() {
if (public_nickname.isDisposed()) {
plugin.removeListener(this);
} else {
public_nickname.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (public_nickname.isDisposed()) {
return;
}
String nick = plugin_beta.getSharedPublicNickname();
if (!public_nickname.getText().equals(nick)) {
public_nickname.setText(nick);
}
nick = plugin_beta.getSharedAnonNickname();
if (!anon_nickname.getText().equals(nick)) {
anon_nickname.setText(nick);
}
shared_endpoint.setSelection(plugin_beta.getSharedAnonEndpoint());
int pc_state = plugin_beta.getPrivateChatState();
private_chat_enable.setSelection(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
private_chat_pinned.setSelection(pc_state == BuddyPluginBeta.PRIVATE_CHAT_PINNED_ONLY);
private_chat_pinned.setEnabled(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
pc_pinned_only.setEnabled(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
String str = plugin_beta.getSoundFile();
if (str.length() == 0) {
noti_file.setText("<default>");
} else {
noti_file.setText(str);
}
boolean se = plugin_beta.getSoundEnabled();
noti_file.setEnabled(se);
noti_browse.setEnabled(se);
}
});
}
}
});
}
use of com.biglybt.ui.swt.config.ParameterChangeAdapter in project BiglyBT by BiglySoftware.
the class ConfigSectionDownloading method configSectionCreate.
@Override
public Composite configSectionCreate(Composite parent) {
// Seeding Automation Setup
GridData gridData;
GridLayout layout;
Label label;
Composite cDownloading = new Composite(parent, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
cDownloading.setLayout(layout);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
Utils.setLayoutData(cDownloading, gridData);
// wiki link
final Label linkLabel = new Label(cDownloading, SWT.NULL);
linkLabel.setText(MessageText.getString("ConfigView.label.please.visit.here"));
linkLabel.setData(Constants.URL_WIKI + "w/Downloading_Rules");
linkLabel.setCursor(linkLabel.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
linkLabel.setForeground(Colors.blue);
gridData = new GridData();
gridData.horizontalSpan = 2;
Utils.setLayoutData(linkLabel, gridData);
linkLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
@Override
public void mouseDown(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
});
ClipboardCopy.addCopyToClipMenu(linkLabel);
// sort type
label = new Label(cDownloading, SWT.NULL);
Messages.setLanguageText(label, "label.prioritize.downloads.based.on");
String[] orderLabels = { MessageText.getString("label.order"), MessageText.getString("label.seed.count"), MessageText.getString("label.reverse.seed.count"), MessageText.getString("TableColumn.header.size"), MessageText.getString("label.reverse.size"), MessageText.getString("label.speed") };
int[] orderValues = { DefaultRankCalculator.DOWNLOAD_ORDER_INDEX, DefaultRankCalculator.DOWNLOAD_ORDER_SEED_COUNT, DefaultRankCalculator.DOWNLOAD_ORDER_REVERSE_SEED_COUNT, DefaultRankCalculator.DOWNLOAD_ORDER_SIZE, DefaultRankCalculator.DOWNLOAD_ORDER_REVERSE_SIZE, DefaultRankCalculator.DOWNLOAD_ORDER_SPEED };
final IntListParameter sort_type = new IntListParameter(cDownloading, "StartStopManager_Downloading_iSortType", orderLabels, orderValues);
Group gSpeed = new Group(cDownloading, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
layout = new GridLayout();
layout.numColumns = 2;
// layout.marginHeight = 0;
gSpeed.setLayout(layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
Utils.setLayoutData(gSpeed, gridData);
gSpeed.setText(MessageText.getString("label.speed.options"));
// info
label = new Label(gSpeed, SWT.WRAP);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
gridData.widthHint = 300;
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "ConfigView.label.downloading.info");
// test time
label = new Label(gSpeed, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.downloading.testTime");
gridData = new GridData();
final IntParameter testTime = new IntParameter(gSpeed, "StartStopManager_Downloading_iTestTimeSecs");
testTime.setLayoutData(gridData);
testTime.setMinimumValue(60);
// re-test
label = new Label(gSpeed, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.downloading.reTest");
gridData = new GridData();
final IntParameter reTest = new IntParameter(gSpeed, "StartStopManager_Downloading_iRetestTimeMins");
reTest.setLayoutData(gridData);
reTest.setMinimumValue(0);
ParameterChangeListener listener = new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
boolean is_speed = ((Integer) sort_type.getValueObject()) == DefaultRankCalculator.DOWNLOAD_ORDER_SPEED;
testTime.setEnabled(is_speed);
reTest.setEnabled(is_speed);
}
};
sort_type.addChangeListener(listener);
listener.parameterChanged(null, false);
return cDownloading;
}
Aggregations