use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.
the class SBC_TagsOverview method toolBarItemActivated.
// @see com.biglybt.pif.ui.toolbar.UIToolBarActivationListener#toolBarItemActivated(ToolBarItem, long, java.lang.Object)
@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
// Send to active view. mostly works
// except MyTorrentsSubView always takes focus after tag is selected..
boolean isTableSelected = false;
if (tv instanceof TableViewImpl) {
isTableSelected = ((TableViewImpl) tv).isTableSelected();
}
if (!isTableSelected) {
UISWTViewCore active_view = getActiveView();
if (active_view != null) {
UIPluginViewToolBarListener l = active_view.getToolBarListener();
if (l != null && l.toolBarItemActivated(item, activationType, datasource)) {
return true;
}
}
return false;
}
if (tv == null || !tv.isVisible()) {
return (false);
}
if (item.getID().equals("remove")) {
Object[] datasources = tv.getSelectedDataSources().toArray();
if (datasources.length > 0) {
for (Object object : datasources) {
if (object instanceof Tag) {
final Tag tag = (Tag) object;
if (tag.getTagType().getTagType() != TagType.TT_DOWNLOAD_MANUAL) {
continue;
}
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("message.confirm.delete.title"), MessageText.getString("message.confirm.delete.text", new String[] { tag.getTagName(true) }), new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 1);
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int result) {
if (result == 0) {
tag.removeTag();
}
}
});
}
}
return true;
}
}
return false;
}
use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.
the class SideBar method updateUI.
// @see com.biglybt.ui.swt.utils.UIUpdatable#updateUI()
@Override
public void updateUI() {
Object[] views = pluginViews.toArray();
for (int i = 0; i < views.length; i++) {
try {
UISWTViewCore view = (UISWTViewCore) views[i];
Composite composite = view.getComposite();
if (composite == null) {
continue;
}
if (composite.isDisposed()) {
pluginViews.remove(view);
continue;
}
if (composite.isVisible()) {
view.triggerEvent(UISWTViewEvent.TYPE_REFRESH, null);
}
} catch (Exception e) {
Debug.out(e);
}
}
if (tree.getSelectionCount() == 0) {
return;
}
super.updateUI();
}
use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.
the class MyTorrentsView method refreshToolBarItems.
@Override
public void refreshToolBarItems(Map<String, Long> list) {
ISelectedContent[] datasource = SelectedContentManager.getCurrentlySelectedContent();
if (!isTableFocus()) {
UISWTViewCore active_view = getActiveView();
if (active_view != null) {
UIPluginViewToolBarListener l = active_view.getToolBarListener();
if (l != null) {
Map<String, Long> activeViewList = new HashMap<>();
l.refreshToolBarItems(activeViewList);
if (activeViewList.size() > 0) {
list.putAll(activeViewList);
return;
}
}
}
}
}
use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.
the class MyTorrentsView method toolBarItemActivated.
@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
boolean isTableSelected = false;
if (tv instanceof TableViewImpl) {
isTableSelected = ((TableViewImpl) tv).isTableSelected();
}
if (!isTableSelected) {
UISWTViewCore active_view = getActiveView();
if (active_view != null) {
UIPluginViewToolBarListener l = active_view.getToolBarListener();
if (l != null && l.toolBarItemActivated(item, activationType, datasource)) {
return true;
}
}
return false;
}
String itemKey = item.getID();
if (activationType == UIToolBarActivationListener.ACTIVATIONTYPE_HELD) {
if (itemKey.equals("up")) {
moveSelectedTorrentsTop();
return true;
}
if (itemKey.equals("down")) {
moveSelectedTorrentsEnd();
return true;
}
return false;
}
if (activationType != UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL) {
return false;
}
if (itemKey.equals("top")) {
moveSelectedTorrentsTop();
return true;
}
if (itemKey.equals("bottom")) {
moveSelectedTorrentsEnd();
return true;
}
if (itemKey.equals("up")) {
moveSelectedTorrentsUp();
return true;
}
if (itemKey.equals("down")) {
moveSelectedTorrentsDown();
return true;
}
if (itemKey.equals("run")) {
TorrentUtil.runDataSources(tv.getSelectedDataSources().toArray());
return true;
}
if (itemKey.equals("start")) {
TorrentUtil.queueDataSources(tv.getSelectedDataSources().toArray(), true);
return true;
}
if (itemKey.equals("stop")) {
TorrentUtil.stopDataSources(tv.getSelectedDataSources().toArray());
return true;
}
if (itemKey.equals("startstop")) {
TorrentUtil.stopOrStartDataSources(tv.getSelectedDataSources().toArray());
return true;
}
if (itemKey.equals("remove")) {
TorrentUtil.removeDataSources(tv.getSelectedDataSources().toArray());
return true;
}
return false;
}
use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.
the class PeersGraphicView method initialize.
protected void initialize(Composite composite) {
display = composite.getDisplay();
panel = new Canvas(composite, SWT.NO_BACKGROUND);
panel.addListener(SWT.MouseHover, new Listener() {
@Override
public void handleEvent(Event event) {
int x = event.x;
int y = event.y;
String tt = "";
synchronized (dm_data_lock) {
for (ManagerData data : dm_data) {
DownloadManager manager = data.manager;
if (x >= data.me_hit_x && x <= data.me_hit_x + OWN_SIZE && y >= data.me_hit_y && y <= data.me_hit_y + OWN_SIZE) {
if (dm_data.length > 1) {
tt = manager.getDisplayName() + "\r\n";
}
tt += DisplayFormatters.formatDownloadStatus(manager) + ", " + DisplayFormatters.formatPercentFromThousands(manager.getStats().getCompleted());
break;
} else {
PEPeer target = null;
for (Map.Entry<PEPeer, int[]> entry : data.peer_hit_map.entrySet()) {
int[] loc = entry.getValue();
int loc_x = loc[0];
int loc_y = loc[1];
if (x >= loc_x && x <= loc_x + PEER_SIZE && y >= loc_y && y <= loc_y + PEER_SIZE) {
target = entry.getKey();
break;
}
}
if (target != null) {
PEPeerStats stats = target.getStats();
String[] details = PeerUtils.getCountryDetails(target);
String dstr = (details == null || details.length < 2) ? "" : (" - " + details[0] + "/" + details[1]);
/*
if ( dm_map.size() > 1 ){
tt = manager.getDisplayName() + "\r\n";
}
*/
tt = target.getIp() + dstr + ", " + DisplayFormatters.formatPercentFromThousands(target.getPercentDoneInThousandNotation()) + "\r\n" + "Up=" + DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataSendRate() + stats.getProtocolSendRate()) + ", " + "Down=" + DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataReceiveRate() + stats.getProtocolReceiveRate());
break;
}
}
}
}
panel.setToolTipText(tt);
}
});
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent event) {
if (event.button == 3) {
int x = event.x;
int y = event.y;
PEPeer target = null;
DownloadManager target_manager = null;
synchronized (dm_data_lock) {
for (ManagerData data : dm_data) {
DownloadManager manager = data.manager;
for (Map.Entry<PEPeer, int[]> entry : data.peer_hit_map.entrySet()) {
int[] loc = entry.getValue();
int loc_x = loc[0];
int loc_y = loc[1];
if (x >= loc_x && x <= loc_x + PEER_SIZE && y >= loc_y && y <= loc_y + PEER_SIZE) {
target = entry.getKey();
target_manager = manager;
break;
}
}
if (target != null) {
break;
}
}
}
if (target == null) {
return;
}
Menu menu = panel.getMenu();
if (menu != null && !menu.isDisposed()) {
menu.dispose();
}
menu = new Menu(panel);
PeersViewBase.fillMenu(menu, target, target_manager);
final Point cursorLocation = Display.getCurrent().getCursorLocation();
menu.setLocation(cursorLocation.x, cursorLocation.y);
menu.setVisible(true);
}
}
@Override
public void mouseDoubleClick(MouseEvent event) {
int x = event.x;
int y = event.y;
synchronized (dm_data_lock) {
for (ManagerData data : dm_data) {
DownloadManager manager = data.manager;
if (x >= data.me_hit_x && x <= data.me_hit_x + OWN_SIZE && y >= data.me_hit_y && y <= data.me_hit_y + OWN_SIZE) {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, manager);
}
} else {
for (Map.Entry<PEPeer, int[]> entry : data.peer_hit_map.entrySet()) {
int[] loc = entry.getValue();
int loc_x = loc[0];
int loc_y = loc[1];
if (x >= loc_x && x <= loc_x + PEER_SIZE && y >= loc_y && y <= loc_y + PEER_SIZE) {
PEPeer target = entry.getKey();
try {
String dm_id = "DMDetails_" + Base32.encode(manager.getTorrent().getHash());
MdiEntry mdi_entry = UIFunctionsManager.getUIFunctions().getMDI().getEntry(dm_id);
if (mdi_entry != null) {
mdi_entry.setDatasource(new Object[] { manager, target });
}
Composite comp = panel.getParent();
while (comp != null) {
if (comp instanceof CTabFolder) {
CTabFolder tf = (CTabFolder) comp;
CTabItem[] items = tf.getItems();
for (CTabItem item : items) {
UISWTViewCore view = (UISWTViewCore) item.getData("TabbedEntry");
UISWTViewEventListener listener = view.getEventListener();
if (listener instanceof UISWTViewEventListenerHolder) {
listener = ((UISWTViewEventListenerHolder) listener).getDelegatedEventListener(view);
}
if (listener instanceof PeersView) {
tf.setSelection(item);
Event ev = new Event();
ev.item = item;
// manual setSelection doesn't file selection event - derp
tf.notifyListeners(SWT.Selection, ev);
((PeersView) listener).selectPeer(target);
return;
}
}
}
comp = comp.getParent();
}
} catch (Throwable e) {
}
break;
}
}
}
}
}
}
});
// without this we get a transient blank when mousing in and out of the tab folder on OSX :(
panel.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
doRefresh();
}
});
}
Aggregations