use of com.biglybt.ui.swt.shells.MessageBoxShell in project BiglyBT by BiglySoftware.
the class SBC_TagsOverview method toolBarItemActivated.
// @see com.biglybt.pif.ui.toolbar.UIToolBarActivationListener#toolBarItemActivated(ToolBarItem, long, java.lang.Object)
@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
// Send to active view. mostly works
// except MyTorrentsSubView always takes focus after tag is selected..
boolean isTableSelected = false;
if (tv instanceof TableViewImpl) {
isTableSelected = ((TableViewImpl) tv).isTableSelected();
}
if (!isTableSelected) {
UISWTViewCore active_view = getActiveView();
if (active_view != null) {
UIPluginViewToolBarListener l = active_view.getToolBarListener();
if (l != null && l.toolBarItemActivated(item, activationType, datasource)) {
return true;
}
}
return false;
}
if (tv == null || !tv.isVisible()) {
return (false);
}
if (item.getID().equals("remove")) {
Object[] datasources = tv.getSelectedDataSources().toArray();
if (datasources.length > 0) {
for (Object object : datasources) {
if (object instanceof Tag) {
final Tag tag = (Tag) object;
if (tag.getTagType().getTagType() != TagType.TT_DOWNLOAD_MANUAL) {
continue;
}
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("message.confirm.delete.title"), MessageText.getString("message.confirm.delete.text", new String[] { tag.getTagName(true) }), new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 1);
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (result == 0) {
tag.removeTag();
}
}
});
}
}
return true;
}
}
return false;
}
use of com.biglybt.ui.swt.shells.MessageBoxShell in project BiglyBT by BiglySoftware.
the class ConfigSectionSecurity method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
int userMode = COConfigurationManager.getIntParameter("User Mode");
java.util.List<Button> buttons = new ArrayList<>();
GridData gridData;
Composite gSecurity = new Composite(parent, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gSecurity.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
gSecurity.setLayout(layout);
// row
Label cert_label = new Label(gSecurity, SWT.NULL);
Messages.setLanguageText(cert_label, "ConfigView.section.tracker.createcert");
Button cert_button = new Button(gSecurity, SWT.PUSH);
buttons.add(cert_button);
Messages.setLanguageText(cert_button, "ConfigView.section.tracker.createbutton");
cert_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
new CertificateCreatorWindow();
}
});
new Label(gSecurity, SWT.NULL);
// row
Label reset_certs_label = new Label(gSecurity, SWT.NULL);
Messages.setLanguageText(reset_certs_label, "ConfigView.section.security.resetcerts");
Button reset_certs_button = new Button(gSecurity, SWT.PUSH);
buttons.add(reset_certs_button);
Messages.setLanguageText(reset_certs_button, "Button.reset");
reset_certs_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.security.resetcerts.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;
}
if (SESecurityManager.resetTrustStore(false)) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_INFORMATION | SWT.OK, MessageText.getString("ConfigView.section.security.restart.title"), MessageText.getString("ConfigView.section.security.restart.msg"));
mb.setParent(parent.getShell());
mb.open(null);
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.dispose(true, false);
}
} else {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetcerts.error.title"), MessageText.getString("ConfigView.section.security.resetcerts.error.msg"));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
}
});
reset_certs_button.setEnabled(SESecurityManager.resetTrustStore(true));
new Label(gSecurity, SWT.NULL);
// row
gridData = new GridData();
gridData.horizontalSpan = 3;
new BooleanParameter(gSecurity, "security.cert.auto.install", "security.cert.auto.install").setLayoutData(gridData);
// row
Label info_label = new Label(gSecurity, SWT.WRAP);
Messages.setLanguageText(info_label, "ConfigView.section.security.toolsinfo");
info_label.setLayoutData(Utils.getWrappableLabelGridData(3, 0));
// row
Label lStatsPath = new Label(gSecurity, SWT.NULL);
// $NON-NLS-1$
Messages.setLanguageText(lStatsPath, "ConfigView.section.security.toolsdir");
ImageLoader imageLoader = ImageLoader.getInstance();
Image imgOpenFolder = imageLoader.getImage("openFolderButton");
gridData = new GridData();
gridData.widthHint = 150;
// $NON-NLS-1$ //$NON-NLS-2$
final StringParameter pathParameter = new StringParameter(gSecurity, "Security.JAR.tools.dir", "");
pathParameter.setLayoutData(gridData);
Button browse = new Button(gSecurity, SWT.PUSH);
browse.setImage(imgOpenFolder);
imgOpenFolder.setBackground(browse.getBackground());
browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));
browse.addListener(SWT.Selection, new Listener() {
@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.security.choosetoolssavedir"));
String path = dialog.open();
if (path != null) {
pathParameter.setValue(path);
}
}
});
// row
Label pw_label = new Label(gSecurity, SWT.NULL);
Messages.setLanguageText(pw_label, "ConfigView.section.security.clearpasswords");
Button pw_button = new Button(gSecurity, SWT.PUSH);
buttons.add(pw_button);
Messages.setLanguageText(pw_button, "ConfigView.section.security.clearpasswords.button");
pw_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
SESecurityManager.clearPasswords();
CryptoManagerFactory.getSingleton().clearPasswords();
}
});
new Label(gSecurity, SWT.NULL);
if (userMode >= 2) {
final CryptoManager crypt_man = CryptoManagerFactory.getSingleton();
final Group crypto_group = new Group(gSecurity, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
crypto_group.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 3;
crypto_group.setLayout(layout);
Messages.setLanguageText(crypto_group, "ConfigView.section.security.group.crypto");
// wiki link
final Label linkLabel = new Label(crypto_group, SWT.NULL);
linkLabel.setText(MessageText.getString("ConfigView.label.please.visit.here"));
linkLabel.setData(Constants.URL_WIKI + "w/Public_Private_Keys");
linkLabel.setCursor(linkLabel.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
linkLabel.setForeground(Colors.blue);
gridData = new GridData();
gridData.horizontalSpan = 3;
linkLabel.setLayoutData(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);
// publick key display
byte[] public_key = crypt_man.getECCHandler().peekPublicKey();
Label public_key_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(public_key_label, "ConfigView.section.security.publickey");
final Label public_key_value = new Label(crypto_group, SWT.NULL);
if (public_key == null) {
Messages.setLanguageText(public_key_value, "ConfigView.section.security.publickey.undef");
} else {
public_key_value.setText(Base32.encode(public_key));
}
Messages.setLanguageText(public_key_value, "ConfigView.copy.to.clipboard.tooltip", true);
public_key_value.setCursor(public_key_value.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
public_key_value.setForeground(Colors.blue);
public_key_value.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
copyToClipboard();
}
@Override
public void mouseDown(MouseEvent arg0) {
copyToClipboard();
}
protected void copyToClipboard() {
new Clipboard(parent.getDisplay()).setContents(new Object[] { public_key_value.getText() }, new Transfer[] { TextTransfer.getInstance() });
}
});
final CryptoManagerKeyListener cryptoManagerKeyListener = new CryptoManagerKeyListener() {
@Override
public void keyChanged(final CryptoHandler handler) {
final CryptoManagerKeyListener me = this;
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
if (public_key_value.isDisposed()) {
crypt_man.removeKeyListener(me);
} else {
if (handler.getType() == CryptoManager.HANDLER_ECC) {
byte[] public_key = handler.peekPublicKey();
if (public_key == null) {
Messages.setLanguageText(public_key_value, "ConfigView.section.security.publickey.undef");
} else {
public_key_value.setText(Base32.encode(public_key));
}
crypto_group.layout();
}
}
}
});
}
@Override
public void keyLockStatusChanged(CryptoHandler handler) {
}
};
crypt_man.addKeyListener(cryptoManagerKeyListener);
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (cryptoManagerKeyListener != null) {
CryptoManagerFactory.getSingleton().removeKeyListener(cryptoManagerKeyListener);
}
}
});
new Label(crypto_group, SWT.NULL);
// manage keys
/*
gridData = new GridData();
gridData.horizontalSpan = 3;
final BooleanParameter manage_keys = new BooleanParameter(
crypto_group, "crypto.keys.system.managed.temp",
"ConfigView.section.security.system.managed");
manage_keys.setLayoutData( gridData );
final ClientCryptoManager crypto_man = CryptoManagerFactory.getSingleton();
final CryptoHandler ecc_handler = crypto_man.getECCHandler();
manage_keys.setSelected(
ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM );
manage_keys.addChangeListener(
new ParameterChangeAdapter ()
{
public void
parameterChanged(
Parameter p,
boolean caused_internally )
{
boolean existing_value = ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM;
if ( existing_value == manage_keys.isSelected()){
return;
}
String error = null;
int new_type = manage_keys.isSelected()?CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM:CryptoManagerPasswordHandler.HANDLER_TYPE_USER;
try{
ecc_handler.setDefaultPasswordHandlerType( new_type );
error = null;
}catch( CryptoManagerPasswordException e ){
if ( e.wasIncorrect()){
error = MessageText.getString( "ConfigView.section.security.unlockkey.error" );
}else{
if ( existing_value || !ecc_handler.isUnlocked()){
error = MessageText.getString( "Torrent.create.progress.cancelled" );
}else{
error = MessageText.getString( "ConfigView.section.security.vuze.login" );
}
}
}catch( Throwable e ){
error = Debug.getNestedExceptionMessage( e );
}
if ( error != null ){
MessageBoxShell mb = new MessageBoxShell(
SWT.ICON_ERROR | SWT.OK,
MessageText.getString("ConfigView.section.security.op.error.title"),
MessageText.getString("ConfigView.section.security.op.error",
new String[] { error }));
mb.setParent(parent.getShell());
mb.open(null);
}
boolean new_value = ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM;
if ( new_value != manage_keys.isSelected()){
manage_keys.setSelected( new_value );
}
}
});
*/
// reset keys
Label reset_key_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(reset_key_label, "ConfigView.section.security.resetkey");
Button reset_key_button = new Button(crypto_group, SWT.PUSH);
buttons.add(reset_key_button);
Messages.setLanguageText(reset_key_button, "ConfigView.section.security.clearpasswords.button");
reset_key_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.resetkey.warning.title"), MessageText.getString("ConfigView.section.security.resetkey.warning"));
mb.setDefaultButtonUsingStyle(SWT.CANCEL);
mb.setParent(parent.getShell());
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int returnVal) {
if (returnVal != SWT.OK) {
return;
}
try {
crypt_man.getECCHandler().resetKeys("Manual key reset");
} catch (Throwable e) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
}
});
new Label(crypto_group, SWT.NULL);
// unlock
Label priv_key_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(priv_key_label, "ConfigView.section.security.unlockkey");
Button priv_key_button = new Button(crypto_group, SWT.PUSH);
buttons.add(priv_key_button);
Messages.setLanguageText(priv_key_button, "ConfigView.section.security.unlockkey.button");
priv_key_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
try {
crypt_man.getECCHandler().getEncryptedPrivateKey("Manual unlock");
} catch (Throwable e) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
new Label(crypto_group, SWT.NULL);
// backup
Label backup_keys_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(backup_keys_label, "ConfigView.section.security.backupkeys");
final Button backup_keys_button = new Button(crypto_group, SWT.PUSH);
buttons.add(backup_keys_button);
Messages.setLanguageText(backup_keys_button, "ConfigView.section.security.backupkeys.button");
backup_keys_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
FileDialog dialog = new FileDialog(backup_keys_button.getShell(), SWT.APPLICATION_MODAL);
String target = dialog.open();
if (target != null) {
try {
String keys = crypt_man.getECCHandler().exportKeys();
PrintWriter pw = new PrintWriter(new FileWriter(target));
pw.println(keys);
pw.close();
} catch (Throwable e) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.op.error.title"), MessageText.getString("ConfigView.section.security.op.error", new String[] { getError(e) }));
mb.setParent(parent.getShell());
mb.open(null);
}
}
}
});
new Label(crypto_group, SWT.NULL);
// restore
Label restore_keys_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(restore_keys_label, "ConfigView.section.security.restorekeys");
final Button restore_keys_button = new Button(crypto_group, SWT.PUSH);
buttons.add(restore_keys_button);
Messages.setLanguageText(restore_keys_button, "ConfigView.section.security.restorekeys.button");
restore_keys_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
FileDialog dialog = new FileDialog(backup_keys_button.getShell(), SWT.APPLICATION_MODAL);
String target = dialog.open();
if (target != null) {
try {
LineNumberReader reader = new LineNumberReader(new FileReader(target));
String str = "";
try {
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
str += line + "\r\n";
}
} finally {
reader.close();
}
boolean restart = crypt_man.getECCHandler().importKeys(str);
if (restart) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_INFORMATION | SWT.OK, MessageText.getString("ConfigView.section.security.restart.title"), MessageText.getString("ConfigView.section.security.restart.msg"));
mb.setParent(parent.getShell());
mb.open(null);
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.dispose(true, false);
}
}
} catch (Throwable e) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.op.error.title"), MessageText.getString("ConfigView.section.security.op.error", new String[] { getError(e) }));
mb.setParent(parent.getShell());
mb.open(null);
}
}
}
});
new Label(crypto_group, SWT.NULL);
}
Utils.makeButtonsEqualWidth(buttons);
return gSecurity;
}
use of com.biglybt.ui.swt.shells.MessageBoxShell in project BiglyBT by BiglySoftware.
the class ConfigSectionStartShutdown method buildOptions.
private void buildOptions(final Composite parent, final PlatformManager platform, final Composite area, boolean rebuild) throws PlatformManagerException {
if (rebuild) {
Control[] kids = area.getChildren();
for (Control k : kids) {
k.dispose();
}
}
String[] options = platform.getExplicitVMOptions();
{
// max mem
long max_mem = AEJavaManagement.getJVMLongOption(options, "-Xmx");
final int MIN_MAX_JVM = 32 * 1024 * 1024;
GridData gridData = new GridData();
Label label = new Label(area, SWT.NULL);
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "jvm.max.mem", new String[] { encodeDisplayLong(MIN_MAX_JVM) });
gridData = new GridData();
gridData.widthHint = 125;
final StringParameter max_vm = new StringParameter(area, "jvm.max.mem", "", false);
max_vm.setLayoutData(gridData);
max_vm.setValue(max_mem == -1 ? "" : encodeDisplayLong(max_mem));
max_vm.addChangeListener(new ParameterChangeAdapter() {
private String last_value;
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
if (max_vm.isDisposed()) {
max_vm.removeChangeListener(this);
return;
}
String val = max_vm.getValue();
if (last_value != null && last_value.equals(val)) {
return;
}
last_value = val;
try {
long max_mem = decodeDisplayLong(val);
if (max_mem < MIN_MAX_JVM) {
throw (new Exception("Min=" + encodeDisplayLong(MIN_MAX_JVM)));
}
String[] options = platform.getExplicitVMOptions();
options = AEJavaManagement.setJVMLongOption(options, "-Xmx", max_mem);
long min_mem = AEJavaManagement.getJVMLongOption(options, "-Xms");
if (min_mem == -1 || min_mem > max_mem) {
options = AEJavaManagement.setJVMLongOption(options, "-Xms", max_mem);
}
platform.setExplicitVMOptions(options);
buildOptions(parent, platform, area, true);
} catch (Throwable e) {
String param_name = MessageText.getString("jvm.max.mem");
int pos = param_name.indexOf('[');
if (pos != -1) {
param_name = param_name.substring(0, pos).trim();
}
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.invalid.value.title"), MessageText.getString("ConfigView.section.invalid.value", new String[] { val, param_name, Debug.getNestedExceptionMessage(e) }));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
label = new Label(area, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, gridData);
Long max_heap_mb = AEJavaManagement.getMaxHeapMB();
if (max_heap_mb > 0) {
Messages.setLanguageText(label, "jvm.max.mem.current", new String[] { DisplayFormatters.formatByteCountToKiBEtc(max_heap_mb * 1024 * 1024, true) });
}
}
{
// min mem
final int MIN_MIN_JVM = 8 * 1024 * 1024;
long min_mem = AEJavaManagement.getJVMLongOption(options, "-Xms");
GridData gridData = new GridData();
Label label = new Label(area, SWT.NULL);
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "jvm.min.mem", new String[] { encodeDisplayLong(MIN_MIN_JVM) });
gridData = new GridData();
gridData.widthHint = 125;
final StringParameter min_vm = new StringParameter(area, "jvm.min.mem", "", false);
min_vm.setLayoutData(gridData);
min_vm.setValue(min_mem == -1 ? "" : encodeDisplayLong(min_mem));
min_vm.addChangeListener(new ParameterChangeAdapter() {
private String last_value;
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
if (min_vm.isDisposed()) {
min_vm.removeChangeListener(this);
return;
}
String val = min_vm.getValue();
if (last_value != null && last_value.equals(val)) {
return;
}
last_value = val;
try {
long min_mem = decodeDisplayLong(val);
if (min_mem < MIN_MIN_JVM) {
throw (new Exception("Min=" + encodeDisplayLong(MIN_MIN_JVM)));
}
String[] options = platform.getExplicitVMOptions();
options = AEJavaManagement.setJVMLongOption(options, "-Xms", min_mem);
long max_mem = AEJavaManagement.getJVMLongOption(options, "-Xmx");
if (max_mem == -1 || max_mem < min_mem) {
options = AEJavaManagement.setJVMLongOption(options, "-Xmx", min_mem);
}
platform.setExplicitVMOptions(options);
buildOptions(parent, platform, area, true);
} catch (Throwable e) {
String param_name = MessageText.getString("jvm.min.mem");
int pos = param_name.indexOf('[');
if (pos != -1) {
param_name = param_name.substring(0, pos).trim();
}
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.invalid.value.title"), MessageText.getString("ConfigView.section.invalid.value", new String[] { val, param_name, Debug.getNestedExceptionMessage(e) }));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
label = new Label(area, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, gridData);
}
{
// max DIRECT mem
final int MIN_DIRECT_JVM = 32 * 1024 * 1024;
final String OPTION_KEY = "-XX:MaxDirectMemorySize=";
long max_direct = AEJavaManagement.getJVMLongOption(options, OPTION_KEY);
GridData gridData = new GridData();
Label label = new Label(area, SWT.NULL);
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "jvm.max.direct.mem", new String[] { encodeDisplayLong(MIN_DIRECT_JVM) });
gridData = new GridData();
gridData.widthHint = 125;
final StringParameter max_direct_vm = new StringParameter(area, "jvm.max.direct.mem", "", false);
max_direct_vm.setLayoutData(gridData);
max_direct_vm.setValue(max_direct == -1 ? "" : encodeDisplayLong(max_direct));
max_direct_vm.addChangeListener(new ParameterChangeAdapter() {
private String last_value;
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
if (max_direct_vm.isDisposed()) {
max_direct_vm.removeChangeListener(this);
return;
}
String val = max_direct_vm.getValue();
if (last_value != null && last_value.equals(val)) {
return;
}
last_value = val;
try {
long max_direct = decodeDisplayLong(val);
if (max_direct < MIN_DIRECT_JVM) {
throw (new Exception("Min=" + encodeDisplayLong(MIN_DIRECT_JVM)));
}
String[] options = platform.getExplicitVMOptions();
options = AEJavaManagement.setJVMLongOption(options, OPTION_KEY, max_direct);
platform.setExplicitVMOptions(options);
buildOptions(parent, platform, area, true);
} catch (Throwable e) {
String param_name = MessageText.getString("jvm.max.direct.mem");
int pos = param_name.indexOf('[');
if (pos != -1) {
param_name = param_name.substring(0, pos).trim();
}
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.invalid.value.title"), MessageText.getString("ConfigView.section.invalid.value", new String[] { val, param_name, Debug.getNestedExceptionMessage(e) }));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
label = new Label(area, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "jvm.max.direct.mem.info");
}
// all options
Label label = new Label(area, SWT.NULL);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "jvm.options.summary");
for (String option : options) {
label = new Label(area, SWT.NULL);
label.setText(option);
gridData = new GridData();
gridData.horizontalSpan = 3;
gridData.horizontalIndent = 20;
Utils.setLayoutData(label, gridData);
}
if (rebuild) {
parent.layout(true, true);
}
}
use of com.biglybt.ui.swt.shells.MessageBoxShell in project BiglyBT by BiglySoftware.
the class TorrentListViewsUtils method handleNoFileExists.
/**
* @param dm
*
* @since 3.0.0.7
*/
private static void handleNoFileExists(final DownloadManager dm) {
final UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (functionsSWT == null) {
return;
}
ManagerUtils.start(dm);
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("v3.mb.PlayFileNotFound.title"), MessageText.getString("v3.mb.PlayFileNotFound.text", new String[] { dm.getDisplayName() }), new String[] { MessageText.getString("v3.mb.PlayFileNotFound.button.remove"), MessageText.getString("v3.mb.PlayFileNotFound.button.redownload"), MessageText.getString("Button.cancel") }, 2);
mb.setRelatedObject(dm);
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int i) {
if (i == 0) {
ManagerUtils.asyncStopDelete(dm, DownloadManager.STATE_STOPPED, true, false, null);
} else if (i == 1) {
dm.forceRecheck(new ForceRecheckListener() {
@Override
public void forceRecheckComplete(DownloadManager dm) {
ManagerUtils.start(dm);
}
});
}
}
});
}
use of com.biglybt.ui.swt.shells.MessageBoxShell in project BiglyBT by BiglySoftware.
the class SubscriptionsView method removeSubs.
private void removeSubs(final Subscription[] toRemove, final int startIndex) {
if (toRemove == null || startIndex >= toRemove.length) {
return;
}
if (toRemove[startIndex] == null) {
int nextIndex = startIndex + 1;
if (nextIndex < toRemove.length) {
removeSubs(toRemove, nextIndex);
}
return;
}
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("message.confirm.delete.title"), MessageText.getString("message.confirm.delete.text", new String[] { toRemove[startIndex].getName() }));
if (startIndex == toRemove.length - 1) {
mb.setButtons(0, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, new Integer[] { 0, 1 });
} else {
mb.setButtons(1, new String[] { MessageText.getString("Button.removeAll"), MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, new Integer[] { 2, 0, 1 });
}
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (result == 0) {
toRemove[startIndex].remove();
} else if (result == 2) {
for (int i = startIndex; i < toRemove.length; i++) {
if (toRemove[i] != null) {
toRemove[i].remove();
}
}
return;
}
int nextIndex = startIndex + 1;
if (nextIndex < toRemove.length) {
removeSubs(toRemove, nextIndex);
}
}
});
}
Aggregations