use of com.biglybt.ui.swt.components.LinkLabel in project BiglyBT by BiglySoftware.
the class BuddyPluginViewBetaChat method buildSupport2.
private void buildSupport2(Composite parent) {
boolean public_chat = !chat.isPrivateChat();
if (chat.getViewType() == BuddyPluginBeta.VIEW_TYPE_DEFAULT || chat.isReadOnly()) {
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
parent.setLayout(layout);
GridData grid_data = new GridData(GridData.FILL_BOTH);
Utils.setLayoutData(parent, grid_data);
Composite sash_area = new Composite(parent, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
sash_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_BOTH);
grid_data.horizontalSpan = 2;
Utils.setLayoutData(sash_area, grid_data);
final SashForm sash = new SashForm(sash_area, SWT.HORIZONTAL);
grid_data = new GridData(GridData.FILL_BOTH);
Utils.setLayoutData(sash, grid_data);
final Composite lhs = new Composite(sash, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginTop = 4;
layout.marginLeft = 4;
lhs.setLayout(layout);
grid_data = new GridData(GridData.FILL_BOTH);
grid_data.widthHint = 300;
Utils.setLayoutData(lhs, grid_data);
buildStatus(parent, lhs);
Composite log_holder = buildFTUX(lhs, SWT.BORDER);
// LOG panel
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 4;
log_holder.setLayout(layout);
// grid_data = new GridData(GridData.FILL_BOTH );
// grid_data.horizontalSpan = 2;
// Utils.setLayoutData(log_holder, grid_data);
log = new StyledText(log_holder, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP | SWT.NO_FOCUS);
grid_data = new GridData(GridData.FILL_BOTH);
grid_data.horizontalSpan = 1;
// grid_data.horizontalIndent = 4;
Utils.setLayoutData(log, grid_data);
// log.setIndent( 4 );
log.setEditable(false);
log_holder.setBackground(log.getBackground());
final Menu log_menu = new Menu(log);
log.setMenu(log_menu);
log.addMenuDetectListener(new MenuDetectListener() {
@Override
public void menuDetected(MenuDetectEvent e) {
e.doit = false;
boolean handled = false;
for (MenuItem mi : log_menu.getItems()) {
mi.dispose();
}
try {
Point mapped = log.getDisplay().map(null, log, new Point(e.x, e.y));
int offset = log.getOffsetAtLocation(mapped);
final StyleRange sr = log.getStyleRangeAtOffset(offset);
if (sr != null) {
Object data = sr.data;
if (data instanceof ChatParticipant) {
ChatParticipant cp = (ChatParticipant) data;
List<ChatParticipant> cps = new ArrayList<>();
cps.add(cp);
buildParticipantMenu(log_menu, cps);
handled = true;
} else if (data instanceof String) {
String url_str = (String) sr.data;
String str = url_str;
if (str.length() > 50) {
str = str.substring(0, 50) + "...";
}
if (chat.isAnonymous() && url_str.toLowerCase(Locale.US).startsWith("magnet:")) {
String[] magnet_uri = { url_str };
Set<String> networks = UrlUtils.extractNetworks(magnet_uri);
String i2p_only_uri = magnet_uri[0] + "&net=" + UrlUtils.encode(AENetworkClassifier.AT_I2P);
String i2p_only_str = i2p_only_uri;
if (i2p_only_str.length() > 50) {
i2p_only_str = i2p_only_str.substring(0, 50) + "...";
}
i2p_only_str = lu.getLocalisedMessageText("azbuddy.dchat.open.i2p.magnet") + ": " + i2p_only_str;
final MenuItem mi_open_i2p_vuze = new MenuItem(log_menu, SWT.PUSH);
mi_open_i2p_vuze.setText(i2p_only_str);
mi_open_i2p_vuze.setData(i2p_only_uri);
mi_open_i2p_vuze.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String url_str = (String) mi_open_i2p_vuze.getData();
if (url_str != null) {
TorrentOpener.openTorrent(url_str);
}
}
});
if (networks.size() == 1 && networks.iterator().next() == AENetworkClassifier.AT_I2P) {
// already done above
} else {
str = lu.getLocalisedMessageText("azbuddy.dchat.open.magnet") + ": " + str;
final MenuItem mi_open_vuze = new MenuItem(log_menu, SWT.PUSH);
mi_open_vuze.setText(str);
mi_open_vuze.setData(url_str);
mi_open_vuze.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String url_str = (String) mi_open_vuze.getData();
if (url_str != null) {
TorrentOpener.openTorrent(url_str);
}
}
});
}
} else {
str = lu.getLocalisedMessageText("azbuddy.dchat.open.in.vuze") + ": " + str;
final MenuItem mi_open_vuze = new MenuItem(log_menu, SWT.PUSH);
mi_open_vuze.setText(str);
mi_open_vuze.setData(url_str);
mi_open_vuze.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String url_str = (String) mi_open_vuze.getData();
if (url_str != null) {
String lc_url_str = url_str.toLowerCase(Locale.US);
if (lc_url_str.startsWith("chat:")) {
try {
beta.handleURI(url_str, true);
} catch (Throwable f) {
Debug.out(f);
}
} else {
TorrentOpener.openTorrent(url_str);
}
}
}
});
}
final MenuItem mi_open_ext = new MenuItem(log_menu, SWT.PUSH);
mi_open_ext.setText(lu.getLocalisedMessageText("azbuddy.dchat.open.in.browser"));
mi_open_ext.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String url_str = (String) mi_open_ext.getData();
Utils.launch(url_str);
}
});
new MenuItem(log_menu, SWT.SEPARATOR);
if (chat.isAnonymous() && url_str.toLowerCase(Locale.US).startsWith("magnet:")) {
String[] magnet_uri = { url_str };
Set<String> networks = UrlUtils.extractNetworks(magnet_uri);
String i2p_only_uri = magnet_uri[0] + "&net=" + UrlUtils.encode(AENetworkClassifier.AT_I2P);
final MenuItem mi_copy_i2p_clip = new MenuItem(log_menu, SWT.PUSH);
mi_copy_i2p_clip.setText(lu.getLocalisedMessageText("azbuddy.dchat.copy.i2p.magnet"));
mi_copy_i2p_clip.setData(i2p_only_uri);
mi_copy_i2p_clip.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String url_str = (String) mi_copy_i2p_clip.getData();
if (url_str != null) {
ClipboardCopy.copyToClipBoard(url_str);
}
}
});
if (networks.size() == 1 && networks.iterator().next() == AENetworkClassifier.AT_I2P) {
// already done above
} else {
final MenuItem mi_copy_clip = new MenuItem(log_menu, SWT.PUSH);
mi_copy_clip.setText(lu.getLocalisedMessageText("azbuddy.dchat.copy.magnet"));
mi_copy_clip.setData(url_str);
mi_copy_clip.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String url_str = (String) mi_copy_clip.getData();
if (url_str != null) {
ClipboardCopy.copyToClipBoard(url_str);
}
}
});
}
} else {
final MenuItem mi_copy_clip = new MenuItem(log_menu, SWT.PUSH);
mi_copy_clip.setText(lu.getLocalisedMessageText("label.copy.to.clipboard"));
mi_copy_clip.setData(url_str);
mi_copy_clip.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String url_str = (String) mi_copy_clip.getData();
if (url_str != null) {
ClipboardCopy.copyToClipBoard(url_str);
}
}
});
}
if (url_str.toLowerCase().startsWith("http")) {
mi_open_ext.setData(url_str);
mi_open_ext.setEnabled(true);
} else {
mi_open_ext.setEnabled(false);
}
handled = true;
} else {
if (Constants.isCVSVersion()) {
if (sr instanceof MyStyleRange) {
final MyStyleRange msr = (MyStyleRange) sr;
MenuItem item = new MenuItem(log_menu, SWT.NONE);
item.setText(MessageText.getString("label.copy.to.clipboard"));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ClipboardCopy.copyToClipBoard(msr.message.getMessage());
}
});
handled = true;
}
}
}
}
} catch (Throwable f) {
}
if (!handled) {
final String text = log.getSelectionText();
if (text != null && text.length() > 0) {
MenuItem item = new MenuItem(log_menu, SWT.NONE);
item.setText(MessageText.getString("label.copy.to.clipboard"));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ClipboardCopy.copyToClipBoard(text);
}
});
handled = true;
}
}
if (handled) {
e.doit = true;
}
}
});
log.addListener(SWT.MouseDoubleClick, new Listener() {
@Override
public void handleEvent(Event e) {
try {
final int offset = log.getOffsetAtLocation(new Point(e.x, e.y));
for (int i = 0; i < log_styles.length; i++) {
StyleRange sr = log_styles[i];
Object data = sr.data;
if (data != null && offset >= sr.start && offset < sr.start + sr.length) {
boolean anon_chat = chat.isAnonymous();
if (data instanceof String) {
final String url_str = (String) data;
String lc_url_str = url_str.toLowerCase(Locale.US);
if (lc_url_str.startsWith("chat:")) {
if (anon_chat && !lc_url_str.startsWith("chat:anon:")) {
return;
}
try {
beta.handleURI(url_str, true);
} catch (Throwable f) {
Debug.out(f);
}
} else {
if (anon_chat) {
try {
String host = new URL(lc_url_str).getHost();
if (AENetworkClassifier.categoriseAddress(host) == AENetworkClassifier.AT_PUBLIC) {
return;
}
} catch (Throwable f) {
return;
}
}
if (lc_url_str.contains(".torrent") || UrlUtils.parseTextForMagnets(url_str) != null) {
TorrentOpener.openTorrent(url_str);
} else {
if (url_str.toLowerCase(Locale.US).startsWith("http")) {
// without this backoff we end up with the text widget
// being left in a 'mouse down' state when returning to it :(
Utils.execSWTThreadLater(100, new Runnable() {
@Override
public void run() {
Utils.launch(url_str);
}
});
} else {
TorrentOpener.openTorrent(url_str);
}
}
}
log.setSelection(offset);
e.doit = false;
} else if (data instanceof ChatParticipant) {
ChatParticipant participant = (ChatParticipant) data;
addNickString(participant);
}
}
}
} catch (Throwable f) {
}
}
});
log.addMouseTrackListener(new MouseTrackListener() {
private StyleRange old_range;
private StyleRange temp_range;
private int temp_index;
@Override
public void mouseHover(MouseEvent e) {
boolean active = false;
try {
int offset = log.getOffsetAtLocation(new Point(e.x, e.y));
for (int i = 0; i < log_styles.length; i++) {
StyleRange sr = log_styles[i];
Object data = sr.data;
if (data != null && offset >= sr.start && offset < sr.start + sr.length) {
if (old_range != null) {
if (temp_index < log_styles.length && log_styles[temp_index] == temp_range) {
log_styles[temp_index] = old_range;
old_range = null;
}
}
sr = log_styles[i];
String tt_extra = "";
if (data instanceof String) {
try {
URL url = new URL((String) data);
String query = url.getQuery();
if (query != null) {
String[] bits = query.split("&");
int seeds = -1;
int leechers = -1;
for (String bit : bits) {
String[] temp = bit.split("=");
String lhs = temp[0];
if (lhs.equals("_s")) {
seeds = Integer.parseInt(temp[1]);
} else if (lhs.equals("_l")) {
leechers = Integer.parseInt(temp[1]);
}
}
if (seeds != -1 && leechers != -1) {
tt_extra = ": seeds=" + seeds + ", leechers=" + leechers;
}
}
} catch (Throwable f) {
}
}
log.setToolTipText(MessageText.getString("label.right.click.for.options") + tt_extra);
StyleRange derp;
if (sr instanceof MyStyleRange) {
derp = new MyStyleRange((MyStyleRange) sr);
} else {
derp = new StyleRange(sr);
}
derp.start = sr.start;
derp.length = sr.length;
derp.borderStyle = SWT.BORDER_DASH;
old_range = sr;
temp_range = derp;
temp_index = i;
log_styles[i] = derp;
log.setStyleRanges(log_styles);
active = true;
break;
}
}
} catch (Throwable f) {
}
if (!active) {
log.setToolTipText("");
if (old_range != null) {
if (temp_index < log_styles.length && log_styles[temp_index] == temp_range) {
log_styles[temp_index] = old_range;
old_range = null;
log.setStyleRanges(log_styles);
}
}
}
}
@Override
public void mouseExit(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEnter(MouseEvent e) {
// TODO Auto-generated method stub
}
});
log.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
int key = event.character;
if (key <= 26 && key > 0) {
key += 'a' - 1;
}
if (key == 'a' && event.stateMask == SWT.MOD1) {
event.doit = false;
log.selectAll();
}
}
});
Composite rhs = new Composite(sash, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginTop = 4;
layout.marginRight = 4;
rhs.setLayout(layout);
grid_data = new GridData(GridData.FILL_VERTICAL);
int rhs_width = Constants.isWindows ? 150 : 160;
grid_data.widthHint = rhs_width;
Utils.setLayoutData(rhs, grid_data);
// options
Composite top_right = buildHelp(rhs);
// nick name
Composite nick_area = new Composite(top_right, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 4;
layout.marginHeight = 0;
layout.marginWidth = 0;
if (!Constants.isWindows) {
layout.horizontalSpacing = 2;
layout.verticalSpacing = 2;
}
nick_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 3;
Utils.setLayoutData(nick_area, grid_data);
Label label = new Label(nick_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("azbuddy.dchat.nick"));
grid_data = new GridData();
// grid_data.horizontalIndent=4;
Utils.setLayoutData(label, grid_data);
nickname = new Text(nick_area, SWT.BORDER);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 1;
Utils.setLayoutData(nickname, grid_data);
nickname.setText(chat.getNickname(false));
nickname.setMessage(chat.getDefaultNickname());
label = new Label(nick_area, SWT.NULL);
label.setText(lu.getLocalisedMessageText("label.shared"));
label.setToolTipText(lu.getLocalisedMessageText("azbuddy.dchat.shared.tooltip"));
shared_nick_button = new Button(nick_area, SWT.CHECK);
shared_nick_button.setSelection(chat.isSharedNickname());
shared_nick_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
boolean shared = shared_nick_button.getSelection();
chat.setSharedNickname(shared);
}
});
nickname.addListener(SWT.FocusOut, new Listener() {
@Override
public void handleEvent(Event event) {
String nick = nickname.getText().trim();
if (chat.isSharedNickname()) {
if (chat.getNetwork() == AENetworkClassifier.AT_PUBLIC) {
beta.setSharedPublicNickname(nick);
} else {
beta.setSharedAnonNickname(nick);
}
} else {
chat.setInstanceNickname(nick);
}
}
});
table_header_left = new BufferedLabel(top_right, SWT.DOUBLE_BUFFERED);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 2;
if (!Constants.isWindows) {
grid_data.horizontalIndent = 2;
}
Utils.setLayoutData(table_header_left, grid_data);
table_header_left.setText(MessageText.getString("PeersView.state.pending"));
LinkLabel link = new LinkLabel(top_right, "Views.plugins.azbuddy.title", new Runnable() {
@Override
public void run() {
if (!plugin.isClassicEnabled()) {
plugin.setClassicEnabled(true);
}
beta.selectClassicTab();
}
});
// table
buddy_table = new Table(rhs, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
String[] headers = { "azbuddy.ui.table.name" };
int[] sizes = { rhs_width - 10 };
int[] aligns = { SWT.LEFT };
for (int i = 0; i < headers.length; i++) {
TableColumn tc = new TableColumn(buddy_table, aligns[i]);
tc.setWidth(Utils.adjustPXForDPI(sizes[i]));
Messages.setLanguageText(tc, headers[i]);
}
buddy_table.setHeaderVisible(true);
grid_data = new GridData(GridData.FILL_BOTH);
// grid_data.heightHint = buddy_table.getHeaderHeight() * 3;
Utils.setLayoutData(buddy_table, grid_data);
buddy_table.addListener(SWT.SetData, new Listener() {
@Override
public void handleEvent(Event event) {
TableItem item = (TableItem) event.item;
setItemData(item);
}
});
final Menu menu = new Menu(buddy_table);
buddy_table.setMenu(menu);
menu.addMenuListener(new MenuListener() {
@Override
public void menuShown(MenuEvent e) {
MenuItem[] items = menu.getItems();
for (int i = 0; i < items.length; i++) {
items[i].dispose();
}
final TableItem[] selection = buddy_table.getSelection();
List<ChatParticipant> participants = new ArrayList<>(selection.length);
for (int i = 0; i < selection.length; i++) {
TableItem item = selection[i];
ChatParticipant participant = (ChatParticipant) item.getData();
if (participant == null) {
// item data won't be set yet for items that haven't been
// visible...
participant = setItemData(item);
}
if (participant != null) {
participants.add(participant);
}
}
buildParticipantMenu(menu, participants);
}
@Override
public void menuHidden(MenuEvent e) {
}
});
buddy_table.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
int key = event.character;
if (key <= 26 && key > 0) {
key += 'a' - 1;
}
if (key == 'a' && event.stateMask == SWT.MOD1) {
event.doit = false;
buddy_table.selectAll();
}
}
});
buddy_table.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
TableItem[] selection = buddy_table.getSelection();
if (selection.length != 1) {
return;
}
TableItem item = selection[0];
ChatParticipant participant = (ChatParticipant) item.getData();
addNickString(participant);
}
});
Utils.maintainSashPanelWidth(sash, rhs, new int[] { 700, 300 }, "azbuddy.dchat.ui.sash.pos");
/*
Listener sash_listener=
new Listener()
{
private int lhs_weight;
private int lhs_width;
public void
handleEvent(
Event ev )
{
if ( ev.widget == lhs ){
int[] weights = sash.getWeights();
if ( lhs_weight != weights[0] ){
// sash has moved
lhs_weight = weights[0];
// keep track of the width
lhs_width = lhs.getBounds().width;
}
}else{
// resize
if ( lhs_width > 0 ){
int width = sash.getClientArea().width;
double ratio = (double)lhs_width/width;
lhs_weight = (int)(ratio*1000 );
sash.setWeights( new int[]{ lhs_weight, 1000 - lhs_weight });
}
}
}
};
lhs.addListener(SWT.Resize, sash_listener );
sash.addListener(SWT.Resize, sash_listener );
*/
// bottom area
Composite bottom_area = new Composite(parent, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
bottom_area.setLayout(layout);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 2;
bottom_area.setLayoutData(grid_data);
// Text
input_area = new Text(bottom_area, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
grid_data.horizontalSpan = 1;
grid_data.heightHint = 30;
grid_data.horizontalIndent = 4;
Utils.setLayoutData(input_area, grid_data);
// input_area.setIndent( 4 );
input_area.setTextLimit(MAX_MSG_OVERALL_LENGTH);
input_area.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent ev) {
if (ev.text.equals("\t")) {
ev.doit = false;
}
}
});
input_area.addKeyListener(new KeyListener() {
private LinkedList<String> history = new LinkedList<>();
private int history_pos = -1;
private String buffered_message = "";
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
e.doit = false;
if ((e.stateMask & SWT.ALT) != 0) {
input_area.insert("\n");
return;
}
String message = input_area.getText().trim();
if (message.length() > 0) {
sendMessage(message, true);
history.addFirst(message);
if (history.size() > 32) {
history.removeLast();
}
history_pos = -1;
buffered_message = "";
input_area.setText("");
text_cache.put(chat.getNetAndKey(), "");
}
} else if (e.keyCode == SWT.ARROW_UP) {
history_pos++;
if (history_pos < history.size()) {
if (history_pos == 0) {
buffered_message = input_area.getText().trim();
}
String msg = history.get(history_pos);
input_area.setText(msg);
input_area.setSelection(msg.length());
} else {
history_pos = history.size() - 1;
}
e.doit = false;
} else if (e.keyCode == SWT.ARROW_DOWN) {
history_pos--;
if (history_pos >= 0) {
String msg = history.get(history_pos);
input_area.setText(msg);
input_area.setSelection(msg.length());
} else {
if (history_pos == -1) {
input_area.setText(buffered_message);
if (buffered_message.length() > 0) {
input_area.setSelection(buffered_message.length());
buffered_message = "";
}
} else {
history_pos = -1;
}
}
e.doit = false;
} else {
if (e.stateMask == SWT.MOD1) {
int key = e.character;
if (key <= 26 && key > 0) {
key += 'a' - 1;
}
if (key == 'a') {
input_area.selectAll();
} else if (key == 'b' || key == 'i') {
String emp = key == 'b' ? "**" : "*";
String sel = input_area.getSelectionText();
Point p = input_area.getSelection();
while (sel.endsWith(" ")) {
sel = sel.substring(0, sel.length() - 1);
p.y--;
}
if (!sel.isEmpty()) {
/*
int[] range = input_area.getSelectionRanges();
int emp_len = emp.length();
if ( sel.startsWith( emp ) && sel.endsWith( emp ) && sel.length() >= emp_len * 2 ){
input_area.replaceTextRange( range[0], range[1], sel.substring(emp_len, sel.length() - emp_len ));
input_area.setSelection( range[0], range[0] + range[1] - emp_len*2 );
}else{
input_area.replaceTextRange( range[0], range[1], emp + sel + emp );
input_area.setSelection( range[0], range[0] + range[1] + emp_len*2 );
}
*/
int emp_len = emp.length();
String text = input_area.getText();
if (sel.startsWith(emp) && sel.endsWith(emp) && sel.length() >= emp_len * 2) {
input_area.setText(text.substring(0, p.x) + sel.substring(emp_len, sel.length() - emp_len) + text.substring(p.y));
p.y -= emp_len * 2;
} else {
input_area.setText(text.substring(0, p.x) + emp + sel + emp + text.substring(p.y));
p.y += emp_len * 2;
}
input_area.setSelection(p);
}
}
}
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
input_area.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) {
if (input_area != null) {
String text = input_area.getText();
text_cache.put(chat.getNetAndKey(), text);
}
}
});
String cached_text = text_cache.get(chat.getNetAndKey());
if (cached_text != null && !cached_text.isEmpty()) {
input_area.setText(cached_text);
input_area.setSelection(cached_text.length());
}
Composite button_area = new Composite(bottom_area, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginRight = 4;
button_area.setLayout(layout);
buildRSSButton(button_area);
hookFTUXListener();
if (chat.isReadOnly()) {
input_area.setText(MessageText.getString("azbuddy.dchat.ro"));
}
setInputAvailability(true);
if (!chat.isReadOnly()) {
drop_targets = new DropTarget[] { new DropTarget(log, DND.DROP_COPY), new DropTarget(input_area, DND.DROP_COPY) };
for (DropTarget drop_target : drop_targets) {
drop_target.setTransfer(new Transfer[] { FixedURLTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
drop_target.addDropListener(new DropTargetAdapter() {
@Override
public void dropAccept(DropTargetEvent event) {
event.currentDataType = FixedURLTransfer.pickBestType(event.dataTypes, event.currentDataType);
}
@Override
public void dragEnter(DropTargetEvent event) {
}
@Override
public void dragOperationChanged(DropTargetEvent event) {
}
@Override
public void dragOver(DropTargetEvent event) {
if ((event.operations & DND.DROP_LINK) > 0)
event.detail = DND.DROP_LINK;
else if ((event.operations & DND.DROP_COPY) > 0)
event.detail = DND.DROP_COPY;
else if ((event.operations & DND.DROP_DEFAULT) > 0)
event.detail = DND.DROP_COPY;
event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
}
@Override
public void dragLeave(DropTargetEvent event) {
}
@Override
public void drop(DropTargetEvent event) {
handleDrop(event.data, new DropAccepter() {
@Override
public void accept(String link) {
input_area.setText(input_area.getText() + link);
}
});
}
});
}
}
Control[] focus_controls = { log, input_area, buddy_table, nickname, shared_nick_button };
Listener focus_listener = new Listener() {
@Override
public void handleEvent(Event event) {
activate();
}
};
for (Control c : focus_controls) {
c.addListener(SWT.FocusIn, focus_listener);
}
BuddyPluginBeta.ChatParticipant[] existing_participants = chat.getParticipants();
synchronized (participants) {
participants.addAll(Arrays.asList(existing_participants));
}
table_resort_required = true;
updateTable(false);
BuddyPluginBeta.ChatMessage[] history = chat.getHistory();
logChatMessages(history);
boolean can_popout = shell == null && public_chat;
if (can_popout && !ftux_ok && !auto_ftux_popout_done) {
auto_ftux_popout_done = true;
try {
createChatWindow(view, plugin, chat.getClone(), true);
} catch (Throwable e) {
}
}
} else {
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
parent.setLayout(layout);
GridData grid_data = new GridData(GridData.FILL_BOTH);
Utils.setLayoutData(parent, grid_data);
Composite status_area = new Composite(parent, SWT.NULL);
grid_data = new GridData(GridData.FILL_HORIZONTAL);
status_area.setLayoutData(grid_data);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginTop = 4;
layout.marginLeft = 4;
status_area.setLayout(layout);
buildStatus(parent, status_area);
buildHelp(status_area);
Composite ftux_parent = new Composite(parent, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
ftux_parent.setLayout(layout);
grid_data = new GridData(GridData.FILL_BOTH);
grid_data.horizontalSpan = 2;
ftux_parent.setLayoutData(grid_data);
Composite share_area_holder = buildFTUX(ftux_parent, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
share_area_holder.setLayout(layout);
Canvas share_area = new Canvas(share_area_holder, SWT.NO_BACKGROUND);
grid_data = new GridData(GridData.FILL_BOTH);
share_area.setLayoutData(grid_data);
share_area.setBackground(Colors.white);
share_area.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setAdvanced(true);
gc.setAntialias(SWT.ON);
Rectangle bounds = share_area.getBounds();
int width = bounds.width;
int height = bounds.height;
gc.setBackground(Colors.white);
gc.fillRectangle(0, 0, width, height);
Rectangle text_area = new Rectangle(50, 50, width - 100, height - 100);
gc.setLineWidth(8);
gc.setLineStyle(SWT.LINE_DOT);
gc.setForeground(Colors.light_grey);
gc.drawRoundRectangle(40, 40, width - 80, height - 80, 25, 25);
gc.setForeground(Colors.dark_grey);
gc.setFont(big_font);
String msg = MessageText.getString("dchat.share.dnd.info", new String[] { MessageText.getString(chat.getNetwork() == AENetworkClassifier.AT_PUBLIC ? "label.publicly" : "label.anonymously"), chat.getName() });
GCStringPrinter p = new GCStringPrinter(gc, msg, text_area, 0, SWT.CENTER | SWT.WRAP);
p.printString();
}
});
input_area = new Text(share_area, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
input_area.setVisible(false);
hookFTUXListener();
drop_targets = new DropTarget[] { new DropTarget(share_area, DND.DROP_COPY) };
for (DropTarget drop_target : drop_targets) {
drop_target.setTransfer(new Transfer[] { FixedURLTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
drop_target.addDropListener(new DropTargetAdapter() {
@Override
public void dropAccept(DropTargetEvent event) {
event.currentDataType = FixedURLTransfer.pickBestType(event.dataTypes, event.currentDataType);
}
@Override
public void dragEnter(DropTargetEvent event) {
}
@Override
public void dragOperationChanged(DropTargetEvent event) {
}
@Override
public void dragOver(DropTargetEvent event) {
if ((event.operations & DND.DROP_LINK) > 0)
event.detail = DND.DROP_LINK;
else if ((event.operations & DND.DROP_COPY) > 0)
event.detail = DND.DROP_COPY;
else if ((event.operations & DND.DROP_DEFAULT) > 0)
event.detail = DND.DROP_COPY;
event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
}
@Override
public void dragLeave(DropTargetEvent event) {
}
@Override
public void drop(DropTargetEvent event) {
if (!chat_available) {
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("dchat.share.dnd.wait.title"), MessageText.getString("dchat.share.dnd.wait.text"));
mb.setButtons(0, new String[] { MessageText.getString("Button.ok") }, new Integer[] { 0 });
mb.open(null);
return;
}
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("dchat.share.dnd.prompt.title"), MessageText.getString("dchat.share.dnd.prompt.text", new String[] { MessageText.getString(chat.getNetwork() == AENetworkClassifier.AT_PUBLIC ? "label.publicly" : "label.anonymously"), chat.getName() }));
mb.setRemember("chat.dnd." + chat.getKey(), false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
mb.setButtons(0, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, new Integer[] { 0, 1 });
mb.setRememberOnlyIfButton(0);
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (result == 0) {
handleDrop(event.data, new DropAccepter() {
@Override
public void accept(String link) {
link = link.trim();
sendMessage(link, false);
String rendered = renderMessage(link);
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("dchat.share.dnd.shared.title"), MessageText.getString("dchat.share.dnd.shared.text", new String[] { rendered }));
mb.setButtons(0, new String[] { MessageText.getString("Button.ok") }, new Integer[] { 0 });
mb.open(null);
checkSubscriptions(false);
}
});
}
}
});
}
});
}
}
}
use of com.biglybt.ui.swt.components.LinkLabel 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.components.LinkLabel in project BiglyBT by BiglySoftware.
the class ConfigSectionInterfaceDisplay method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
int userMode = COConfigurationManager.getIntParameter("User Mode");
boolean isAZ3 = COConfigurationManager.getStringParameter("ui").equals("az3");
Label label;
GridLayout layout;
GridData gridData;
Composite cSection = new Composite(parent, SWT.NULL);
Utils.setLayoutData(cSection, new GridData(GridData.FILL_BOTH));
layout = new GridLayout();
layout.numColumns = 1;
cSection.setLayout(layout);
// various stuff
Group gVarious = new Group(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 1;
gVarious.setLayout(layout);
Utils.setLayoutData(gVarious, new GridData(GridData.FILL_HORIZONTAL));
gVarious.setText(MessageText.getString("label.various"));
new BooleanParameter(gVarious, "Show Download Basket", "ConfigView.section.style.showdownloadbasket");
new BooleanParameter(gVarious, "suppress_file_download_dialog", "ConfigView.section.interface.display.suppress.file.download.dialog");
new BooleanParameter(gVarious, "Suppress Sharing Dialog", "ConfigView.section.interface.display.suppress.sharing.dialog");
new BooleanParameter(gVarious, "show_torrents_menu", "Menu.show.torrent.menu");
if (!Constants.isUnix) {
// TextWithHistory issues on Linux
new BooleanParameter(gVarious, "mainwindow.search.history.enabled", "search.history.enable");
}
if (Constants.isWindowsXP) {
final Button enableXPStyle = new Button(gVarious, SWT.CHECK);
Messages.setLanguageText(enableXPStyle, "ConfigView.section.style.enableXPStyle");
boolean enabled = false;
boolean valid = false;
try {
File f = new File(System.getProperty("java.home") + "\\bin\\javaw.exe.manifest");
if (f.exists()) {
enabled = true;
}
f = FileUtil.getApplicationFile("javaw.exe.manifest");
if (f.exists()) {
valid = true;
}
} catch (Exception e) {
Debug.printStackTrace(e);
valid = false;
}
enableXPStyle.setEnabled(valid);
enableXPStyle.setSelection(enabled);
enableXPStyle.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event arg0) {
// In case we enable the XP Style
if (enableXPStyle.getSelection()) {
try {
File fDest = new File(System.getProperty("java.home") + "\\bin\\javaw.exe.manifest");
File fOrigin = new File("javaw.exe.manifest");
if (!fDest.exists() && fOrigin.exists()) {
FileUtil.copyFile(fOrigin, fDest);
}
} catch (Exception e) {
Debug.printStackTrace(e);
}
} else {
try {
File fDest = new File(System.getProperty("java.home") + "\\bin\\javaw.exe.manifest");
fDest.delete();
} catch (Exception e) {
Debug.printStackTrace(e);
}
}
}
});
}
if (Constants.isOSX) {
new BooleanParameter(gVarious, "enable_small_osx_fonts", "ConfigView.section.style.osx_small_fonts");
}
// Reuse the labels of the other menu actions.
if (PlatformManagerFactory.getPlatformManager().hasCapability(PlatformManagerCapabilities.ShowFileInBrowser)) {
BooleanParameter bp = new BooleanParameter(gVarious, "MyTorrentsView.menu.show_parent_folder_enabled", "ConfigView.section.style.use_show_parent_folder");
Messages.setLanguageText(bp.getControl(), "ConfigView.section.style.use_show_parent_folder", new String[] { MessageText.getString("MyTorrentsView.menu.open_parent_folder"), MessageText.getString("MyTorrentsView.menu.explore") });
if (Constants.isOSX) {
new BooleanParameter(gVarious, "FileBrowse.usePathFinder", "ConfigView.section.style.usePathFinder");
}
}
if (userMode > 0) {
final BooleanParameter paramEnableForceDPI = new BooleanParameter(gVarious, "enable.ui.forceDPI", "ConfigView.section.style.forceDPI");
paramEnableForceDPI.setLayoutData(new GridData());
IntParameter forceDPI = new IntParameter(gVarious, "Force DPI", 0, Integer.MAX_VALUE);
forceDPI.setLayoutData(new GridData());
paramEnableForceDPI.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(forceDPI.getControl()));
}
// toolbar
{
Group gToolBar = new Group(cSection, SWT.NULL);
Messages.setLanguageText(gToolBar, "MainWindow.menu.view.iconbar");
int gToolBarSpan = 6 + (isAZ3 ? 1 : 2);
layout = new GridLayout();
layout.numColumns = gToolBarSpan;
gToolBar.setLayout(layout);
Utils.setLayoutData(gToolBar, new GridData(GridData.FILL_HORIZONTAL));
BooleanParameter enabled = null;
if (!isAZ3) {
enabled = new BooleanParameter(gToolBar, "IconBar.enabled", "ConfigView.section.style.showiconbar");
GridData gd = new GridData();
gd.horizontalSpan = gToolBarSpan;
enabled.setLayoutData(gd);
}
if (isAZ3) {
new BooleanParameter(gToolBar, "IconBar.visible.play", "iconBar.stream");
}
new BooleanParameter(gToolBar, "IconBar.visible.run", "iconBar.run");
if (!isAZ3) {
new BooleanParameter(gToolBar, "IconBar.visible.top", "iconBar.top");
}
new BooleanParameter(gToolBar, "IconBar.visible.up", "iconBar.up");
new BooleanParameter(gToolBar, "IconBar.visible.down", "iconBar.down");
if (!isAZ3) {
new BooleanParameter(gToolBar, "IconBar.visible.bottom", "iconBar.bottom");
}
new BooleanParameter(gToolBar, "IconBar.visible." + TorrentUtil.TU_ITEM_RECHECK, "MyTorrentsView.menu.recheck");
new BooleanParameter(gToolBar, "IconBar.visible." + TorrentUtil.TU_ITEM_CHECK_FILES, "MyTorrentsView.menu.checkfilesexist");
BooleanParameter sss = new BooleanParameter(gToolBar, "IconBar.start.stop.separate", "ConfigView.section.style.start.stop.separate");
GridData gd = new GridData();
gd.horizontalSpan = gToolBarSpan;
sss.setLayoutData(gd);
}
if (isAZ3) {
Group gSideBar = new Group(cSection, SWT.NULL);
Messages.setLanguageText(gSideBar, "v3.MainWindow.menu.view.sidebar");
layout = new GridLayout();
layout.numColumns = 2;
gSideBar.setLayout(layout);
Utils.setLayoutData(gSideBar, new GridData(GridData.FILL_HORIZONTAL));
new BooleanParameter(gSideBar, "Show Side Bar", "sidebar.show");
label = new Label(gSideBar, SWT.NULL);
label = new Label(gSideBar, SWT.NULL);
Messages.setLanguageText(label, "sidebar.top.level.gap");
new IntParameter(gSideBar, "Side Bar Top Level Gap", 0, 5);
new BooleanParameter(gSideBar, "Show Options In Side Bar", "sidebar.show.options");
label = new Label(gSideBar, SWT.NULL);
BooleanParameter showNew = new BooleanParameter(gSideBar, "Show New In Side Bar", "sidebar.show.new");
label = new Label(gSideBar, SWT.NULL);
showNew.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
if (showNew.isSelected()) {
UIFunctionsManager.getUIFunctions().getMDI().loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY_UNOPENED, false);
} else {
UIFunctionsManager.getUIFunctions().getMDI().closeEntry(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY_UNOPENED);
}
}
});
BooleanParameter showDL = new BooleanParameter(gSideBar, "Show Downloading In Side Bar", "sidebar.show.downloading");
label = new Label(gSideBar, SWT.NULL);
showDL.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
if (showDL.isSelected()) {
UIFunctionsManager.getUIFunctions().getMDI().loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY_DL, false);
} else {
UIFunctionsManager.getUIFunctions().getMDI().closeEntry(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY_DL);
}
}
});
}
// status bar
Group cStatusBar = new Group(cSection, SWT.NULL);
Messages.setLanguageText(cStatusBar, "ConfigView.section.style.status");
layout = new GridLayout();
layout.numColumns = 1;
cStatusBar.setLayout(layout);
Utils.setLayoutData(cStatusBar, new GridData(GridData.FILL_HORIZONTAL));
new BooleanParameter(cStatusBar, "Status Area Show SR", "ConfigView.section.style.status.show_sr");
new BooleanParameter(cStatusBar, "Status Area Show NAT", "ConfigView.section.style.status.show_nat");
new BooleanParameter(cStatusBar, "Status Area Show DDB", "ConfigView.section.style.status.show_ddb");
new BooleanParameter(cStatusBar, "Status Area Show IPF", "ConfigView.section.style.status.show_ipf");
new BooleanParameter(cStatusBar, "status.rategraphs", "ConfigView.section.style.status.show_rategraphs");
if (userMode > 0) {
Group cUnits = new Group(cSection, SWT.NULL);
Messages.setLanguageText(cUnits, "ConfigView.section.style.units");
layout = new GridLayout();
layout.numColumns = 1;
cUnits.setLayout(layout);
Utils.setLayoutData(cUnits, new GridData(GridData.FILL_HORIZONTAL));
new BooleanParameter(cUnits, "config.style.useSIUnits", "ConfigView.section.style.useSIUnits");
new BooleanParameter(cUnits, "config.style.forceSIValues", "ConfigView.section.style.forceSIValues");
new BooleanParameter(cUnits, "config.style.useUnitsRateBits", "ConfigView.section.style.useUnitsRateBits");
new BooleanParameter(cUnits, "config.style.doNotUseGB", "ConfigView.section.style.doNotUseGB");
new BooleanParameter(cUnits, "config.style.dataStatsOnly", "ConfigView.section.style.dataStatsOnly");
new BooleanParameter(cUnits, "config.style.separateProtDataStats", "ConfigView.section.style.separateProtDataStats");
new BooleanParameter(cUnits, "ui.scaled.graphics.binary.based", "ConfigView.section.style.scaleBinary");
}
if (userMode > 0) {
Group formatters_group = new Group(cSection, SWT.NULL);
Messages.setLanguageText(formatters_group, "ConfigView.label.general.formatters");
layout = new GridLayout();
formatters_group.setLayout(layout);
Utils.setLayoutData(formatters_group, new GridData(GridData.FILL_HORIZONTAL));
StringAreaParameter formatters = new StringAreaParameter(formatters_group, "config.style.formatOverrides");
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.heightHint = formatters.getPreferredHeight(3);
formatters.setLayoutData(gridData);
Composite format_info = new Composite(formatters_group, SWT.NULL);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 3;
format_info.setLayout(layout);
Utils.setLayoutData(format_info, new GridData(GridData.FILL_HORIZONTAL));
new LinkLabel(format_info, "ConfigView.label.general.formatters.link", MessageText.getString("ConfigView.label.general.formatters.link.url"));
label = new Label(format_info, SWT.NULL);
Messages.setLanguageText(label, "GeneralView.label.status");
InfoParameter info_param = new InfoParameter(format_info, "config.style.formatOverrides.status");
gridData = new GridData(GridData.FILL_HORIZONTAL);
info_param.setLayoutData(gridData);
}
if (userMode > 0) {
Group gExternalBrowser = new Group(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 1;
gExternalBrowser.setLayout(layout);
Utils.setLayoutData(gExternalBrowser, new GridData(GridData.FILL_HORIZONTAL));
gExternalBrowser.setText(MessageText.getString("config.external.browser"));
label = new Label(gExternalBrowser, SWT.WRAP);
Messages.setLanguageText(label, "config.external.browser.info1");
Utils.setLayoutData(label, Utils.getWrappableLabelGridData(1, 0));
label = new Label(gExternalBrowser, SWT.WRAP);
Messages.setLanguageText(label, "config.external.browser.info2");
Utils.setLayoutData(label, Utils.getWrappableLabelGridData(1, 0));
// browser selection
final java.util.List<String[]> browser_choices = new ArrayList<>();
browser_choices.add(new String[] { "system", MessageText.getString("external.browser.system") });
browser_choices.add(new String[] { "manual", MessageText.getString("external.browser.manual") });
java.util.List<PluginInterface> pis = CoreFactory.getSingleton().getPluginManager().getPluginsWithMethod("launchURL", new Class[] { URL.class, boolean.class, Runnable.class });
String pi_names = "";
for (PluginInterface pi : pis) {
String pi_name = pi.getPluginName();
pi_names += (pi_names.length() == 0 ? "" : "/") + pi_name;
browser_choices.add(new String[] { "plugin:" + pi.getPluginID(), pi_name });
}
final Composite cEBArea = new Composite(gExternalBrowser, SWT.WRAP);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(cEBArea, gridData);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
cEBArea.setLayout(layout);
label = new Label(cEBArea, SWT.WRAP);
Messages.setLanguageText(label, "config.external.browser.select");
final Composite cEB = new Group(cEBArea, SWT.WRAP);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(cEB, gridData);
layout = new GridLayout();
layout.numColumns = browser_choices.size();
layout.marginHeight = 0;
cEB.setLayout(layout);
java.util.List<Button> buttons = new ArrayList<>();
for (int i = 0; i < browser_choices.size(); i++) {
Button button = new Button(cEB, SWT.RADIO);
button.setText(browser_choices.get(i)[1]);
button.setData("index", String.valueOf(i));
buttons.add(button);
}
String existing = COConfigurationManager.getStringParameter("browser.external.id", browser_choices.get(0)[0]);
int existing_index = -1;
for (int i = 0; i < browser_choices.size(); i++) {
if (browser_choices.get(i)[0].equals(existing)) {
existing_index = i;
break;
}
}
if (existing_index == -1) {
existing_index = 0;
COConfigurationManager.setParameter("browser.external.id", browser_choices.get(0)[0]);
}
buttons.get(existing_index).setSelection(true);
Messages.setLanguageText(new Label(cEBArea, SWT.WRAP), "config.external.browser.prog");
Composite manualArea = new Composite(cEBArea, SWT.NULL);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
manualArea.setLayout(layout);
Utils.setLayoutData(manualArea, new GridData(GridData.FILL_HORIZONTAL));
final Parameter manualProg = new FileParameter(manualArea, "browser.external.prog", "", new String[] {});
manualProg.setEnabled(existing_index == 1);
Listener radioListener = new Listener() {
@Override
public void handleEvent(Event event) {
Button button = (Button) event.widget;
if (button.getSelection()) {
Control[] children = cEB.getChildren();
for (int j = 0; j < children.length; j++) {
Control child = children[j];
if (child != button && child instanceof Button) {
Button b = (Button) child;
b.setSelection(false);
}
}
int index = Integer.parseInt((String) button.getData("index"));
COConfigurationManager.setParameter("browser.external.id", browser_choices.get(index)[0]);
manualProg.setEnabled(index == 1);
}
}
};
for (Button b : buttons) {
b.addListener(SWT.Selection, radioListener);
}
if (pis.size() > 0) {
Composite nonPubArea = new Composite(gExternalBrowser, SWT.NULL);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
nonPubArea.setLayout(layout);
Utils.setLayoutData(nonPubArea, new GridData(GridData.FILL_HORIZONTAL));
String temp = MessageText.getString("config.external.browser.non.pub", new String[] { pi_names });
BooleanParameter non_pub = new BooleanParameter(nonPubArea, "browser.external.non.pub", true, "!" + temp + "!");
}
// test launch
Composite testArea = new Composite(gExternalBrowser, SWT.NULL);
layout = new GridLayout(4, false);
layout.marginHeight = 0;
testArea.setLayout(layout);
Utils.setLayoutData(testArea, new GridData(GridData.FILL_HORIZONTAL));
label = new Label(testArea, SWT.WRAP);
Messages.setLanguageText(label, "config.external.browser.test");
final Button test_button = new Button(testArea, SWT.PUSH);
Messages.setLanguageText(test_button, "configureWizard.nat.test");
final Text test_url = new Text(testArea, SWT.BORDER);
Utils.setLayoutData(test_url, new GridData(GridData.FILL_HORIZONTAL));
test_url.setText("http://www.vuze.com/");
test_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
test_button.setEnabled(false);
final String url_str = test_url.getText().trim();
new AEThread2("async") {
@Override
public void run() {
try {
Utils.launch(url_str, true);
} finally {
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
if (!test_button.isDisposed()) {
test_button.setEnabled(true);
}
}
});
}
}
}.start();
}
});
label = new Label(testArea, SWT.NULL);
Utils.setLayoutData(label, new GridData(GridData.FILL_HORIZONTAL));
}
if (userMode > 1) {
Group gInternalBrowser = new Group(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 1;
gInternalBrowser.setLayout(layout);
Utils.setLayoutData(gInternalBrowser, new GridData(GridData.FILL_HORIZONTAL));
gInternalBrowser.setText(MessageText.getString("config.internal.browser"));
label = new Label(gInternalBrowser, SWT.WRAP);
gridData = Utils.getWrappableLabelGridData(1, GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "config.internal.browser.info1");
final BooleanParameter intbrow_disable = new BooleanParameter(gInternalBrowser, "browser.internal.disable", "config.browser.internal.disable");
label = new Label(gInternalBrowser, SWT.WRAP);
gridData = Utils.getWrappableLabelGridData(1, GridData.FILL_HORIZONTAL);
gridData.horizontalIndent = 15;
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "config.browser.internal.disable.info");
label = new Label(gInternalBrowser, SWT.WRAP);
gridData = Utils.getWrappableLabelGridData(1, GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "config.internal.browser.info3");
java.util.List<PluginInterface> pis = AEProxyFactory.getPluginHTTPProxyProviders(true);
final java.util.List<String[]> proxy_choices = new ArrayList<>();
proxy_choices.add(new String[] { "none", MessageText.getString("label.none") });
for (PluginInterface pi : pis) {
proxy_choices.add(new String[] { "plugin:" + pi.getPluginID(), pi.getPluginName() });
}
final Composite cIPArea = new Composite(gInternalBrowser, SWT.WRAP);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(cIPArea, gridData);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
cIPArea.setLayout(layout);
label = new Label(cIPArea, SWT.WRAP);
gridData = Utils.getWrappableLabelGridData(1, GridData.FILL_HORIZONTAL);
Utils.setLayoutData(label, gridData);
Messages.setLanguageText(label, "config.internal.browser.proxy.select");
final Composite cIP = new Group(cIPArea, SWT.WRAP);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(cIP, gridData);
layout = new GridLayout();
layout.numColumns = proxy_choices.size();
layout.marginHeight = 0;
cIP.setLayout(layout);
java.util.List<Button> buttons = new ArrayList<>();
for (int i = 0; i < proxy_choices.size(); i++) {
Button button = new Button(cIP, SWT.RADIO);
button.setText(proxy_choices.get(i)[1]);
button.setData("index", String.valueOf(i));
buttons.add(button);
}
String existing = COConfigurationManager.getStringParameter("browser.internal.proxy.id", proxy_choices.get(0)[0]);
int existing_index = -1;
for (int i = 0; i < proxy_choices.size(); i++) {
if (proxy_choices.get(i)[0].equals(existing)) {
existing_index = i;
break;
}
}
if (existing_index == -1) {
existing_index = 0;
COConfigurationManager.setParameter("browser.internal.proxy.id", proxy_choices.get(0)[0]);
}
buttons.get(existing_index).setSelection(true);
Listener radioListener = new Listener() {
@Override
public void handleEvent(Event event) {
Button button = (Button) event.widget;
if (button.getSelection()) {
Control[] children = cIP.getChildren();
for (int j = 0; j < children.length; j++) {
Control child = children[j];
if (child != button && child instanceof Button) {
Button b = (Button) child;
b.setSelection(false);
}
}
int index = Integer.parseInt((String) button.getData("index"));
COConfigurationManager.setParameter("browser.internal.proxy.id", proxy_choices.get(index)[0]);
}
}
};
for (Button b : buttons) {
b.addListener(SWT.Selection, radioListener);
}
}
// refresh
Group gRefresh = new Group(cSection, SWT.NULL);
gRefresh.setText(MessageText.getString("upnp.refresh.button"));
layout = new GridLayout();
layout.numColumns = 2;
gRefresh.setLayout(layout);
Utils.setLayoutData(gRefresh, new GridData(GridData.FILL_HORIZONTAL));
label = new Label(gRefresh, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.style.guiUpdate");
int[] values = { 10, 25, 50, 100, 250, 500, 1000, 2000, 5000, 10000, 15000 };
String[] labels = { "10 ms", "25 ms", "50 ms", "100 ms", "250 ms", "500 ms", "1 s", "2 s", "5 s", "10 s", "15 s" };
new IntListParameter(gRefresh, "GUI Refresh", 1000, labels, values);
label = new Label(gRefresh, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.style.inactiveUpdate");
gridData = new GridData();
IntParameter inactiveUpdate = new IntParameter(gRefresh, "Refresh When Inactive", 1, Integer.MAX_VALUE);
inactiveUpdate.setLayoutData(gridData);
label = new Label(gRefresh, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.style.graphicsUpdate");
gridData = new GridData();
IntParameter graphicUpdate = new IntParameter(gRefresh, "Graphics Update", 1, Integer.MAX_VALUE);
graphicUpdate.setLayoutData(gridData);
return cSection;
}
use of com.biglybt.ui.swt.components.LinkLabel in project BiglyBT by BiglySoftware.
the class ConfigSectionConnection method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
Label label;
GridData gridData;
GridLayout layout;
Composite cMiniArea;
int userMode = COConfigurationManager.getIntParameter("User Mode");
Composite cSection = new Composite(parent, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
Utils.setLayoutData(cSection, gridData);
layout = new GridLayout();
cSection.setLayout(layout);
// /////////////////////
cMiniArea = new Composite(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
cMiniArea.setLayout(layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(cMiniArea, gridData);
final boolean separate_ports = userMode > 1 || COConfigurationManager.getIntParameter("TCP.Listen.Port") != COConfigurationManager.getIntParameter("UDP.Listen.Port");
label = new Label(cMiniArea, SWT.NULL);
Messages.setLanguageText(label, separate_ports ? "ConfigView.label.tcplistenport" : "ConfigView.label.serverport");
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
Utils.setLayoutData(label, gridData);
final IntParameter tcplisten = new IntParameter(cMiniArea, "TCP.Listen.Port", 1, 65535);
gridData = new GridData();
tcplisten.setLayoutData(gridData);
tcplisten.addChangeListener(new ParameterChangeAdapter() {
@Override
public void intParameterChanging(Parameter p, int toValue) {
if (toValue == Constants.INSTANCE_PORT) {
toValue = Constants.INSTANCE_PORT + 1;
tcplisten.setValue(toValue);
}
if (!separate_ports) {
COConfigurationManager.setParameter("UDP.Listen.Port", toValue);
COConfigurationManager.setParameter("UDP.NonData.Listen.Port", toValue);
}
}
});
if (separate_ports) {
label = new Label(cMiniArea, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.udplistenport");
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
Utils.setLayoutData(label, gridData);
final IntParameter udp_listen = new IntParameter(cMiniArea, "UDP.Listen.Port", 1, 65535);
gridData = new GridData();
udp_listen.setLayoutData(gridData);
final boolean MULTI_UDP = COConfigurationManager.ENABLE_MULTIPLE_UDP_PORTS && userMode > 1;
udp_listen.addChangeListener(new ParameterChangeAdapter() {
@Override
public void intParameterChanging(Parameter p, int toValue) {
if (toValue == Constants.INSTANCE_PORT) {
toValue = Constants.INSTANCE_PORT + 1;
udp_listen.setValue(toValue);
}
if (!MULTI_UDP) {
COConfigurationManager.setParameter("UDP.NonData.Listen.Port", toValue);
}
}
});
if (MULTI_UDP) {
Composite cNonDataUDPArea = new Composite(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
cNonDataUDPArea.setLayout(layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(cNonDataUDPArea, gridData);
final BooleanParameter commonUDP = new BooleanParameter(cNonDataUDPArea, "UDP.NonData.Listen.Port.Same", "ConfigView.section.connection.nondata.udp.same");
gridData = new GridData();
gridData.horizontalIndent = 16;
commonUDP.setLayoutData(gridData);
final IntParameter non_data_udp_listen = new IntParameter(cNonDataUDPArea, "UDP.NonData.Listen.Port");
non_data_udp_listen.addChangeListener(new ParameterChangeAdapter() {
@Override
public void intParameterChanging(Parameter p, int toValue) {
if (toValue == Constants.INSTANCE_PORT) {
toValue = Constants.INSTANCE_PORT + 1;
non_data_udp_listen.setValue(toValue);
}
}
});
udp_listen.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
if (commonUDP.isSelected()) {
int udp_listen_port = udp_listen.getValue();
if (udp_listen_port != Constants.INSTANCE_PORT) {
COConfigurationManager.setParameter("UDP.NonData.Listen.Port", udp_listen_port);
non_data_udp_listen.setValue(udp_listen_port);
}
}
}
});
gridData = new GridData();
non_data_udp_listen.setLayoutData(gridData);
commonUDP.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(non_data_udp_listen.getControls(), true));
commonUDP.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
if (commonUDP.isSelected()) {
int udp_listen_port = COConfigurationManager.getIntParameter("UDP.Listen.Port");
if (COConfigurationManager.getIntParameter("UDP.NonData.Listen.Port") != udp_listen_port) {
COConfigurationManager.setParameter("UDP.NonData.Listen.Port", udp_listen_port);
non_data_udp_listen.setValue(udp_listen_port);
}
}
}
});
final BooleanParameter enable_tcp = new BooleanParameter(cNonDataUDPArea, "TCP.Listen.Port.Enable", "ConfigView.section.connection.tcp.enable");
gridData = new GridData();
enable_tcp.setLayoutData(gridData);
label = new Label(cNonDataUDPArea, SWT.NULL);
final BooleanParameter enable_udp = new BooleanParameter(cNonDataUDPArea, "UDP.Listen.Port.Enable", "ConfigView.section.connection.udp.enable");
gridData = new GridData();
enable_udp.setLayoutData(gridData);
label = new Label(cNonDataUDPArea, SWT.NULL);
enable_tcp.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(tcplisten));
enable_udp.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(udp_listen));
}
}
if (userMode > 0) {
Composite cRandPortArea = new Composite(cMiniArea, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 4;
layout.marginHeight = 0;
layout.marginWidth = 0;
cRandPortArea.setLayout(layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
Utils.setLayoutData(cRandPortArea, gridData);
BooleanParameter rand_enable = new BooleanParameter(cRandPortArea, "Listen.Port.Randomize.Enable", "ConfigView.section.connection.port.rand.enable");
label = new Label(cRandPortArea, SWT.NULL);
label.setText(MessageText.getString("ConfigView.section.connection.port.rand.range"));
gridData = new GridData();
gridData.horizontalIndent = 20;
Utils.setLayoutData(label, gridData);
StringParameter rand_range = new StringParameter(cRandPortArea, "Listen.Port.Randomize.Range");
gridData = new GridData();
gridData.widthHint = 100;
rand_range.setLayoutData(gridData);
BooleanParameter rand_together = new BooleanParameter(cRandPortArea, "Listen.Port.Randomize.Together", "ConfigView.section.connection.port.rand.together");
rand_enable.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(label));
rand_enable.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(new Parameter[] { rand_range, rand_together }));
}
if (userMode > 1) {
final BooleanParameter prefer_udp = new BooleanParameter(cMiniArea, "peercontrol.prefer.udp", "ConfigView.section.connection.prefer.udp");
gridData = new GridData();
gridData.horizontalSpan = 2;
prefer_udp.setLayoutData(gridData);
}
if (userMode < 2) {
// wiki link
label = new Label(cSection, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
label.setText(MessageText.getString("Utils.link.visit") + ":");
final Label linkLabel = new Label(cSection, SWT.NULL);
linkLabel.setText(MessageText.getString("ConfigView.section.connection.serverport.wiki"));
linkLabel.setData(Constants.URL_WIKI + "w/Why_ports_like_6881_are_no_good_choice");
linkLabel.setCursor(linkLabel.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
linkLabel.setForeground(Colors.blue);
gridData = new GridData();
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);
}
if (userMode > 0) {
// ///////////////////// HTTP ///////////////////
Group http_group = new Group(cSection, SWT.NULL);
Messages.setLanguageText(http_group, "ConfigView.section.connection.group.http");
GridLayout http_layout = new GridLayout();
http_layout.numColumns = 2;
http_group.setLayout(http_layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
http_group.setLayoutData(gridData);
label = new Label(http_group, SWT.WRAP);
Messages.setLanguageText(label, "ConfigView.section.connection.group.http.info");
new LinkLabel(http_group, "ConfigView.label.please.visit.here", Constants.URL_WIKI + "w/HTTP_Seeding");
final BooleanParameter enable_http = new BooleanParameter(http_group, "HTTP.Data.Listen.Port.Enable", "ConfigView.section.connection.http.enable");
gridData = new GridData();
gridData.horizontalSpan = 2;
enable_http.setLayoutData(gridData);
label = new Label(http_group, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.connection.http.port");
IntParameter http_port = new IntParameter(http_group, "HTTP.Data.Listen.Port");
gridData = new GridData();
http_port.setLayoutData(gridData);
label = new Label(http_group, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.connection.http.portoverride");
IntParameter http_port_override = new IntParameter(http_group, "HTTP.Data.Listen.Port.Override");
gridData = new GridData();
http_port_override.setLayoutData(gridData);
enable_http.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(http_port));
enable_http.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(http_port_override));
}
if (userMode > 0) {
// ///////////////////// WebSeeds ///////////////////
Group ws_group = new Group(cSection, SWT.NULL);
Messages.setLanguageText(ws_group, "ConfigView.section.connection.group.webseed");
GridLayout ws_layout = new GridLayout();
ws_layout.numColumns = 2;
ws_group.setLayout(ws_layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(ws_group, gridData);
new BooleanParameter(ws_group, "webseed.activation.uses.availability", "ConfigView.section.connection.webseed.act.on.avail");
}
if (userMode > 0) {
// ///////////////////// PEER SOURCES GROUP ///////////////////
Group peer_sources_group = new Group(cSection, SWT.NULL);
Messages.setLanguageText(peer_sources_group, "ConfigView.section.connection.group.peersources");
GridLayout peer_sources_layout = new GridLayout();
peer_sources_group.setLayout(peer_sources_layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(peer_sources_group, gridData);
label = new Label(peer_sources_group, SWT.WRAP);
Messages.setLanguageText(label, "ConfigView.section.connection.group.peersources.info");
gridData = new GridData();
Utils.setLayoutData(label, gridData);
for (int i = 0; i < PEPeerSource.PS_SOURCES.length; i++) {
String p = PEPeerSource.PS_SOURCES[i];
String config_name = "Peer Source Selection Default." + p;
String msg_text = "ConfigView.section.connection.peersource." + p;
BooleanParameter peer_source = new BooleanParameter(peer_sources_group, config_name, msg_text);
gridData = new GridData();
peer_source.setLayoutData(gridData);
}
if (userMode > 1) {
// ///////////////////// NETWORKS GROUP ///////////////////
Group networks_group = new Group(cSection, SWT.NULL);
Messages.setLanguageText(networks_group, "ConfigView.section.connection.group.networks");
GridLayout networks_layout = new GridLayout();
networks_group.setLayout(networks_layout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
Utils.setLayoutData(networks_group, gridData);
label = new Label(networks_group, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.connection.group.networks.info");
gridData = new GridData();
Utils.setLayoutData(label, gridData);
for (int i = 0; i < AENetworkClassifier.AT_NETWORKS.length; i++) {
String nn = AENetworkClassifier.AT_NETWORKS[i];
String config_name = "Network Selection Default." + nn;
String msg_text = "ConfigView.section.connection.networks." + nn;
BooleanParameter network = new BooleanParameter(networks_group, config_name, msg_text);
gridData = new GridData();
network.setLayoutData(gridData);
}
label = new Label(networks_group, SWT.NULL);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
BooleanParameter network_prompt = new BooleanParameter(networks_group, "Network Selection Prompt", "ConfigView.section.connection.networks.prompt");
gridData = new GridData();
network_prompt.setLayoutData(gridData);
}
// end userMode>1
}
return cSection;
}
use of com.biglybt.ui.swt.components.LinkLabel in project BiglyBT by BiglySoftware.
the class ConfigSectionConnectionAdvanced method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
GridData gridData;
Composite cSection = new Composite(parent, SWT.NULL);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL + GridData.VERTICAL_ALIGN_FILL);
Utils.setLayoutData(cSection, gridData);
GridLayout advanced_layout = new GridLayout();
cSection.setLayout(advanced_layout);
int userMode = COConfigurationManager.getIntParameter("User Mode");
if (userMode < REQUIRED_MODE) {
Label label = new Label(cSection, SWT.WRAP);
gridData = new GridData();
Utils.setLayoutData(label, gridData);
final String[] modeKeys = { "ConfigView.section.mode.beginner", "ConfigView.section.mode.intermediate", "ConfigView.section.mode.advanced" };
String param1, param2;
if (REQUIRED_MODE < modeKeys.length)
param1 = MessageText.getString(modeKeys[REQUIRED_MODE]);
else
param1 = String.valueOf(REQUIRED_MODE);
if (userMode < modeKeys.length)
param2 = MessageText.getString(modeKeys[userMode]);
else
param2 = String.valueOf(userMode);
label.setText(MessageText.getString("ConfigView.notAvailableForMode", new String[] { param1, param2 }));
return cSection;
}
new LinkLabel(cSection, gridData, "ConfigView.section.connection.advanced.info.link", MessageText.getString("ConfigView.section.connection.advanced.url"));
// ///////////////////// ADVANCED SOCKET SETTINGS GROUP //////////
Group gSocket = new Group(cSection, SWT.NULL);
Messages.setLanguageText(gSocket, "ConfigView.section.connection.advanced.socket.group");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL);
Utils.setLayoutData(gSocket, gridData);
GridLayout glayout = new GridLayout();
glayout.numColumns = 3;
gSocket.setLayout(glayout);
// max simultaneous
Label lmaxout = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lmaxout, "ConfigView.section.connection.network.max.simultaneous.connect.attempts");
gridData = new GridData();
Utils.setLayoutData(lmaxout, gridData);
IntParameter max_connects = new IntParameter(gSocket, "network.max.simultaneous.connect.attempts", 1, 100);
gridData = new GridData();
gridData.horizontalSpan = 2;
max_connects.setLayoutData(gridData);
// // max pending
Label lmaxpout = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lmaxpout, "ConfigView.section.connection.network.max.outstanding.connect.attempts");
gridData = new GridData();
Utils.setLayoutData(lmaxpout, gridData);
IntParameter max_pending_connects = new IntParameter(gSocket, "network.tcp.max.connections.outstanding", 1, 65536);
gridData = new GridData();
gridData.horizontalSpan = 2;
max_pending_connects.setLayoutData(gridData);
// bind ip
Label lbind = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lbind, "ConfigView.label.bindip");
gridData = new GridData();
Utils.setLayoutData(lbind, gridData);
StringParameter bindip = new StringParameter(gSocket, "Bind IP", "", false);
gridData = new GridData();
gridData.widthHint = 100;
gridData.horizontalSpan = 2;
bindip.setLayoutData(gridData);
Text lbind2 = new Text(gSocket, SWT.READ_ONLY | SWT.MULTI);
lbind2.setTabs(8);
Messages.setLanguageText(lbind2, "ConfigView.label.bindip.details", new String[] { "\t" + NetworkAdmin.getSingleton().getNetworkInterfacesAsString().replaceAll("\\\n", "\n\t") });
gridData = new GridData();
gridData.horizontalSpan = 3;
Utils.setLayoutData(lbind2, gridData);
BooleanParameter check_bind = new BooleanParameter(gSocket, "Check Bind IP On Start", "network.check.ipbinding");
gridData = new GridData();
gridData.horizontalSpan = 3;
check_bind.setLayoutData(gridData);
BooleanParameter force_bind = new BooleanParameter(gSocket, "Enforce Bind IP", "network.enforce.ipbinding");
gridData = new GridData();
gridData.horizontalSpan = 3;
force_bind.setLayoutData(gridData);
BooleanParameter bind_icon = new BooleanParameter(gSocket, "Show IP Bindings Icon", "network.ipbinding.icon.show");
gridData = new GridData();
gridData.horizontalSpan = 3;
bind_icon.setLayoutData(gridData);
BooleanParameter vpn_guess_enable = new BooleanParameter(gSocket, "network.admin.maybe.vpn.enable", "network.admin.maybe.vpn.enable");
gridData = new GridData();
gridData.horizontalSpan = 3;
vpn_guess_enable.setLayoutData(gridData);
Label lpbind = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lpbind, "ConfigView.section.connection.advanced.bind_port");
final IntParameter port_bind = new IntParameter(gSocket, "network.bind.local.port", 0, 65535);
gridData = new GridData();
gridData.horizontalSpan = 2;
port_bind.setLayoutData(gridData);
Label lmtu = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lmtu, "ConfigView.section.connection.advanced.mtu");
final IntParameter mtu_size = new IntParameter(gSocket, "network.tcp.mtu.size");
mtu_size.setMaximumValue(512 * 1024);
gridData = new GridData();
gridData.horizontalSpan = 2;
mtu_size.setLayoutData(gridData);
// sndbuf
Label lsend = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lsend, "ConfigView.section.connection.advanced.SO_SNDBUF");
final IntParameter SO_SNDBUF = new IntParameter(gSocket, "network.tcp.socket.SO_SNDBUF");
gridData = new GridData();
SO_SNDBUF.setLayoutData(gridData);
final Label lsendcurr = new Label(gSocket, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalIndent = 10;
Utils.setLayoutData(lsendcurr, gridData);
// rcvbuf
Label lreceiv = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lreceiv, "ConfigView.section.connection.advanced.SO_RCVBUF");
final IntParameter SO_RCVBUF = new IntParameter(gSocket, "network.tcp.socket.SO_RCVBUF");
gridData = new GridData();
SO_RCVBUF.setLayoutData(gridData);
final Label lreccurr = new Label(gSocket, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalIndent = 10;
Utils.setLayoutData(lreccurr, gridData);
final Runnable buff_updater = new Runnable() {
@Override
public void run() {
SocketChannel sc = null;
int snd_val = 0;
int rec_val = 0;
try {
sc = SocketChannel.open();
Socket socket = sc.socket();
if (SO_SNDBUF.getValue() == 0) {
snd_val = socket.getSendBufferSize();
}
if (SO_RCVBUF.getValue() == 0) {
rec_val = socket.getReceiveBufferSize();
}
} catch (Throwable e) {
} finally {
try {
sc.close();
} catch (Throwable e) {
}
}
if (snd_val == 0) {
lsendcurr.setText("");
} else {
Messages.setLanguageText(lsendcurr, "label.current.equals", new String[] { String.valueOf(snd_val) });
}
if (rec_val == 0) {
lreccurr.setText("");
} else {
Messages.setLanguageText(lreccurr, "label.current.equals", new String[] { String.valueOf(rec_val) });
}
}
};
buff_updater.run();
ParameterChangeAdapter buff_listener = new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
buff_updater.run();
}
};
SO_RCVBUF.addChangeListener(buff_listener);
SO_SNDBUF.addChangeListener(buff_listener);
Label ltos = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(ltos, "ConfigView.section.connection.advanced.IPDiffServ");
final StringParameter IPDiffServ = new StringParameter(gSocket, "network.tcp.socket.IPDiffServ");
gridData = new GridData();
gridData.widthHint = 100;
gridData.horizontalSpan = 2;
IPDiffServ.setLayoutData(gridData);
// do simple input verification, and registry key setting for TOS field
IPDiffServ.addChangeListener(new ParameterChangeAdapter() {
final Color obg = IPDiffServ.getControl().getBackground();
final Color ofg = IPDiffServ.getControl().getForeground();
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
String raw = IPDiffServ.getValue();
int value = -1;
try {
value = Integer.decode(raw).intValue();
} catch (Throwable t) {
}
if (value < 0 || value > 255) {
// invalid or no value entered
ConfigurationManager.getInstance().removeParameter("network.tcp.socket.IPDiffServ");
if (raw != null && raw.length() > 0) {
// error state
IPDiffServ.getControl().setBackground(Colors.red);
IPDiffServ.getControl().setForeground(Colors.white);
} else {
// no value state
IPDiffServ.getControl().setBackground(obg);
IPDiffServ.getControl().setForeground(ofg);
}
// disable registry setting if necessary
enableTOSRegistrySetting(false);
} else {
// passes test
IPDiffServ.getControl().setBackground(obg);
IPDiffServ.getControl().setForeground(ofg);
// enable registry setting if necessary
enableTOSRegistrySetting(true);
}
}
});
// read select
Label lreadsel = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lreadsel, "ConfigView.section.connection.advanced.read_select", new String[] { String.valueOf(COConfigurationManager.getDefault("network.tcp.read.select.time")) });
final IntParameter read_select = new IntParameter(gSocket, "network.tcp.read.select.time", 10, 250);
gridData = new GridData();
gridData.horizontalSpan = 2;
read_select.setLayoutData(gridData);
Label lreadselmin = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lreadselmin, "ConfigView.section.connection.advanced.read_select_min", new String[] { String.valueOf(COConfigurationManager.getDefault("network.tcp.read.select.min.time")) });
final IntParameter read_select_min = new IntParameter(gSocket, "network.tcp.read.select.min.time", 0, 100);
gridData = new GridData();
gridData.horizontalSpan = 2;
read_select_min.setLayoutData(gridData);
// write select
Label lwritesel = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lwritesel, "ConfigView.section.connection.advanced.write_select", new String[] { String.valueOf(COConfigurationManager.getDefault("network.tcp.write.select.time")) });
final IntParameter write_select = new IntParameter(gSocket, "network.tcp.write.select.time", 10, 250);
gridData = new GridData();
gridData.horizontalSpan = 2;
write_select.setLayoutData(gridData);
Label lwriteselmin = new Label(gSocket, SWT.NULL);
Messages.setLanguageText(lwriteselmin, "ConfigView.section.connection.advanced.write_select_min", new String[] { String.valueOf(COConfigurationManager.getDefault("network.tcp.write.select.min.time")) });
final IntParameter write_select_min = new IntParameter(gSocket, "network.tcp.write.select.min.time", 0, 100);
gridData = new GridData();
gridData.horizontalSpan = 2;
write_select_min.setLayoutData(gridData);
new BooleanParameter(cSection, "IPV6 Enable Support", "network.ipv6.enable.support");
new BooleanParameter(cSection, "IPV6 Prefer Addresses", "network.ipv6.prefer.addresses");
if (Constants.isWindowsVistaOrHigher && Constants.isJava7OrHigher) {
new BooleanParameter(cSection, "IPV4 Prefer Stack", "network.ipv4.prefer.stack");
}
return cSection;
}
Aggregations