use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class SideBar method createEntryFromEventListener.
@Override
public MdiEntry createEntryFromEventListener(String parentEntryID, String parentViewID, UISWTViewEventListener l, String id, boolean closeable, Object datasource, String preferredAfterID) {
MdiEntry oldEntry = getEntry(id);
if (oldEntry != null) {
return oldEntry;
}
SideBarEntrySWT entry = new SideBarEntrySWT(this, skin, id, parentViewID);
try {
// hack: setEventListner will create the UISWTView.
// We need to have the entry available for the view to use
// if it wants
addItem(entry);
entry.setEventListener(l, true);
entry.setParentID(parentEntryID);
entry.setDatasource(datasource);
entry.setPreferredAfterID(preferredAfterID);
setupNewEntry(entry, id, false, closeable);
if (l instanceof IViewAlwaysInitialize) {
entry.build();
}
} catch (Exception e) {
Debug.out(e);
entry.close(true);
entry = null;
}
return entry;
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class SideBar method createEntryFromSkinRef.
// @see BaseMDI#createEntryFromSkinRef(java.lang.String, java.lang.String, java.lang.String, java.lang.String, ViewTitleInfo, java.lang.Object, boolean, java.lang.String)
@Override
public MdiEntry createEntryFromSkinRef(String parentID, String id, String configID, String title, ViewTitleInfo titleInfo, Object params, boolean closeable, String preferredAfterID) {
MdiEntry oldEntry = getEntry(id);
if (oldEntry != null) {
return oldEntry;
}
SideBarEntrySWT entry = new SideBarEntrySWT(this, skin, id, null);
entry.setTitle(title);
entry.setSkinRef(configID, params);
if (parentID == null || !parentID.isEmpty()) {
entry.setParentID(parentID);
}
entry.setViewTitleInfo(titleInfo);
entry.setPreferredAfterID(preferredAfterID);
setupNewEntry(entry, id, false, closeable);
return entry;
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class SkinView method skinObjectCreated.
@Override
public Object skinObjectCreated(SWTSkinObject skinObject, Object params) {
SkinViewManager.add(this);
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
MdiEntry entry = mdi.getEntryFromSkinObject(skinObject);
if (entry != null && (this instanceof UIPluginViewToolBarListener)) {
entry.addToolbarEnabler((UIPluginViewToolBarListener) this);
}
}
return super.skinObjectCreated(skinObject, params);
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class PeersGraphicView method initialize.
protected void initialize(Composite composite) {
display = composite.getDisplay();
canvas = new Canvas(composite, SWT.NO_BACKGROUND);
canvas.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 (always_show_dm_name || 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;
}
}
}
}
Utils.setTT(canvas, tt);
}
});
canvas.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 = canvas.getMenu();
if (menu != null && !menu.isDisposed()) {
menu.dispose();
}
menu = new Menu(canvas);
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 {
MdiEntry mdi_entry = UIFunctionsManager.getUIFunctions().getMDI().getEntry(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, manager);
if (mdi_entry != null) {
mdi_entry.setDatasource(new Object[] { manager });
}
Composite comp = canvas.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 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 :(
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (img != null && !img.isDisposed()) {
Rectangle bounds = img.getBounds();
if (bounds.width >= (e.width + e.x) && bounds.height >= (e.height + e.y)) {
e.gc.drawImage(img, e.x, e.y, e.width, e.height, e.x, e.y, e.width, e.height);
}
} else {
e.gc.fillRectangle(e.x, e.y, e.width, e.height);
}
}
});
canvas.addListener(SWT.Dispose, (ev) -> {
if (img != null && !img.isDisposed()) {
img.dispose();
img = null;
}
});
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class ChatMDIEntry method setupMdiEntry.
private void setupMdiEntry(UIManager ui_manager) {
mdi_entry.setViewTitleInfo(this);
MdiEntryDropListener drop_listener = new MdiEntryDropListener() {
@Override
public boolean mdiEntryDrop(MdiEntry entry, Object payload) {
if (payload instanceof String[]) {
String[] derp = (String[]) payload;
if (derp.length > 0) {
payload = derp[0];
}
}
if (!(payload instanceof String)) {
return false;
}
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
String drop = (String) payload;
if (view == null) {
drop_outstanding = drop;
} else {
view.handleDrop(drop);
}
mdi.showEntry(mdi_entry);
return (true);
} else {
return (false);
}
}
};
mdi_entry.addListener(drop_listener);
mdi_entry.addListener(new MdiCloseListener() {
@Override
public void mdiEntryClosed(MdiEntry entry, boolean user) {
chat.removeListener(adapter);
chat.destroy();
}
});
String menu_key = "sidebar." + mdi_entry.getViewID();
MenuManager menu_manager = ui_manager.getMenuManager();
MenuItem menu_item = menu_manager.addMenuItem(menu_key, "iconBar.remove");
Utils.setMenuItemImage(menu_item, "delete");
menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menu_item.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
chat.remove();
}
});
menu_item = menu_manager.addMenuItem(menu_key, "sep");
menu_item.setStyle(MenuItem.STYLE_SEPARATOR);
mdi_entry.setImageLeftID("image.sidebar.chat-overview");
chat.addListener(adapter);
}
Aggregations