use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class MyTorrentsSubView method parameterChanged.
/* (non-Javadoc)
* @see com.biglybt.ui.swt.views.MyTorrentsView#parameterChanged(java.lang.String)
*/
@Override
public void parameterChanged(String parameterName) {
if ("TorrentTags.Any".equals(parameterName)) {
anyTorrentTags = COConfigurationManager.getBooleanParameter(parameterName);
if (btnAnyTags != null && !btnAnyTags.isDisposed()) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
if (btnAnyTags != null && !btnAnyTags.isDisposed()) {
btnAnyTags.setSelection(anyTorrentTags);
}
}
});
}
setCurrentTagsAny(anyTorrentTags);
}
super.parameterChanged(parameterName);
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class PeersGraphicView method dataSourceChanged.
protected void dataSourceChanged(Object newDataSource) {
if (!comp_focused) {
focus_pending_ds = newDataSource;
return;
}
if (my_flag == null) {
InetAddress ia = NetworkAdmin.getSingleton().getDefaultPublicAddress();
if (ia != null) {
my_flag = ImageRepository.getCountryFlag(ia, false);
}
}
List<DownloadManager> existing = new ArrayList<>();
synchronized (dm_data_lock) {
for (ManagerData data : dm_data) {
existing.add(data.manager);
}
}
List<DownloadManager> newManagers = ViewUtils.getDownloadManagersFromDataSource(newDataSource, existing);
synchronized (dm_data_lock) {
Map<DownloadManager, ManagerData> map = new IdentityHashMap<>();
for (ManagerData data : dm_data) {
map.put(data.manager, data);
}
ManagerData[] new_data = new ManagerData[newManagers.size()];
boolean changed = new_data.length != dm_data.length;
for (int i = 0; i < new_data.length; i++) {
DownloadManager dm = newManagers.get(i);
ManagerData existing_data = map.remove(dm);
if (existing_data != null) {
new_data[i] = existing_data;
if (i < dm_data.length && dm_data[i] != existing_data) {
changed = true;
}
} else {
new_data[i] = new ManagerData(dm);
changed = true;
}
}
if (map.size() > 0) {
changed = true;
for (ManagerData data : map.values()) {
data.delete();
}
}
if (!changed) {
return;
}
Arrays.sort(new_data, (a, b) -> {
return (Long.compare(a.getAddTime(), b.getAddTime()));
});
dm_data = new_data;
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
synchronized (dm_data_lock) {
if (dm_data.length > 0) {
Utils.disposeComposite(canvas, false);
} else {
ViewUtils.setViewRequiresOneDownload(canvas);
}
}
}
});
}
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class TopBarView method skinObjectInitialShow.
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
this.skin = skinObject.getSkin();
skin.addListener("topbar-plugins", new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
skin.removeListener("topbar-plugins", this);
// building needs UISWTInstance, which needs core.
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
Utils.execSWTThreadLater(0, new AERunnable() {
@Override
public void runSupport() {
buildTopBarViews();
}
});
}
});
}
return null;
}
});
// trigger autobuild and hook in events
skin.getSkinObject("topbar-area-plugin").addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == SWTSkinObjectListener.EVENT_SHOW) {
if (activeTopBar != null) {
activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
}
} else if (eventType == SWTSkinObjectListener.EVENT_HIDE) {
if (activeTopBar != null) {
activeTopBar.triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null);
}
}
return (null);
}
});
return null;
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class NetworkAdminSWTImpl method updateStatus.
private void updateStatus() {
if (!is_visible) {
return;
}
Image icon;
String tip;
Object[] bs_status = network_admin.getBindingStatus();
int bs_state = (Integer) bs_status[0];
tip = (String) bs_status[1];
if (bs_state == NetworkAdminImpl.BS_INACTIVE) {
icon = icon_grey;
} else if (bs_state == NetworkAdminImpl.BS_OK) {
icon = icon_green;
} else if (bs_state == NetworkAdminImpl.BS_WARNING) {
icon = icon_yellow;
} else {
icon = icon_red;
}
if (last_icon != icon || !tip.equals(last_tip)) {
final Image f_icon = icon;
final String f_tip = tip;
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
last_icon = f_icon;
last_tip = f_tip;
status.setImage(f_icon);
Utils.setTT(status, f_tip);
}
});
}
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class AEProxySelectorSWTImpl method updateStatus.
private void updateStatus() {
if (!is_visible) {
return;
}
Image icon;
String tip_key;
Proxy active_proxy = proxy_selector.getActiveProxy();
long now = SystemTime.getMonotonousTime();
if (active_proxy == null) {
icon = icon_grey;
tip_key = "label.inactive";
} else {
long last_con = proxy_selector.getLastConnectionTime();
long last_fail = proxy_selector.getLastFailTime();
long con_ago = now - last_con;
long fail_ago = now - last_fail;
if (last_fail < 0) {
icon = icon_green;
tip_key = "PeerManager.status.ok";
} else {
if (fail_ago > 60 * 1000) {
if (con_ago < fail_ago) {
icon = icon_green;
tip_key = "PeerManager.status.ok";
} else {
icon = icon_grey;
tip_key = "PeersView.state.pending";
}
} else {
icon = icon_yellow;
tip_key = "label.con_prob";
}
}
}
if (flag_incoming) {
boolean bad_incoming = false;
if (now - last_bad_peer_update > 15 * 1000) {
last_bad_peer_update = now;
List<DownloadManager> dms = core.getGlobalManager().getDownloadManagers();
for (DownloadManager dm : dms) {
PEPeerManager pm = dm.getPeerManager();
if (pm != null) {
if (pm.getNbRemoteTCPConnections() + pm.getNbRemoteUDPConnections() + pm.getNbRemoteUTPConnections() > 0) {
List<PEPeer> peers = pm.getPeers();
for (PEPeer peer : peers) {
if (peer.isIncoming()) {
if (!peer.isLANLocal()) {
try {
if (InetAddress.getByAddress(HostNameToIPResolver.hostAddressToBytes(peer.getIp())).isLoopbackAddress()) {
continue;
}
} catch (Throwable e) {
}
bad_incoming = true;
break;
}
}
}
}
}
if (bad_incoming) {
break;
}
}
} else if (last_icon == icon_red) {
bad_incoming = true;
}
if (bad_incoming) {
icon = icon_red;
tip_key = "proxy.socks.bad.incoming";
}
}
if (last_icon != icon) {
final Image f_icon = icon;
final String f_key = tip_key;
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
last_icon = f_icon;
status.setImage(f_icon);
Utils.setTT(status, MessageText.getString("proxy.socks.ui.icon.tip", new String[] { MessageText.getString(f_key) }));
}
});
}
}
Aggregations