use of com.biglybt.ui.mdi.MdiCloseListener in project BiglyBT by BiglySoftware.
the class SubscriptionMDIEntry method setupMdiEntry.
private void setupMdiEntry() {
if (mdiEntry == null) {
return;
}
mdiEntry.setViewTitleInfo(this);
mdiEntry.setImageLeftID("image.sidebar.subscriptions");
warningImage = mdiEntry.addVitalityImage(ALERT_IMAGE_ID);
spinnerImage = mdiEntry.addVitalityImage("image.sidebar.vitality.dots");
if (spinnerImage != null) {
spinnerImage.setVisible(false);
}
setWarning();
setupMenus(subs, new Runnable() {
@Override
public void run() {
SubscriptionMDIEntry.this.refreshView();
}
});
subs.addListener(this);
mdiEntry.addAcceleratorListener((character, mask) -> {
if ((character == 'c' || character == 'C') && mask == MdiAcceleratorListener.SHIFT) {
subs.getHistory().markAllResultsRead();
return (true);
} else {
return (false);
}
});
mdiEntry.addListener(new MdiCloseListener() {
@Override
public void mdiEntryClosed(MdiEntry entry, boolean userClosed) {
subs.removeListener(SubscriptionMDIEntry.this);
}
});
}
use of com.biglybt.ui.mdi.MdiCloseListener in project BiglyBT by BiglySoftware.
the class ChatMDIEntry method setupMdiEntry.
private void setupMdiEntry() {
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();
}
});
/*
UIManager ui_manager = PluginInitializer.getDefaultInterface().getUIManager();
MenuManager menu_manager = ui_manager.getMenuManager();
MenuItem menu_item;
menu_item = menu_manager.addMenuItem( "sidebar." + mdi_entry.getId(), "dasd.ad.ad." );
menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menu_item.addListener(
new MenuItemListener()
{
@Override
public void
selected(
MenuItem menu, Object target )
{
}
});
*/
mdi_entry.setImageLeftID("image.sidebar.chat-overview");
chat.addListener(adapter);
}
use of com.biglybt.ui.mdi.MdiCloseListener in project BiglyBT by BiglySoftware.
the class SBC_ChatOverview method createChatMdiEntry.
private static MdiEntry createChatMdiEntry(final ChatInstance chat) {
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi == null) {
return (null);
}
try {
String key = "Chat_" + chat.getNetwork() + ":" + Base32.encode(chat.getKey().getBytes("UTF-8"));
MdiEntry existing = mdi.getEntry(key);
if (existing != null) {
chat.destroy();
return (existing);
}
BuddyPluginBeta bp = BuddyPluginUtils.getBetaPlugin();
TreeMap<ChatInstance, String> name_map = new TreeMap<>(new Comparator<ChatInstance>() {
@Override
public int compare(ChatInstance o1, ChatInstance o2) {
return (o1.getName().compareTo(o2.getName()));
}
});
name_map.put(chat, key);
List<ChatInstance> all_chats = bp.getChats();
for (ChatInstance c : all_chats) {
try {
String k = "Chat_" + c.getNetwork() + ":" + Base32.encode(c.getKey().getBytes("UTF-8"));
if (mdi.getEntry(k) != null) {
name_map.put(c, k);
}
} catch (Throwable e) {
}
}
String prev_id = null;
for (String this_id : name_map.values()) {
if (this_id == key) {
break;
}
prev_id = this_id;
}
if (prev_id == null && name_map.size() > 1) {
Iterator<String> it = name_map.values().iterator();
it.next();
prev_id = "~" + it.next();
}
MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_SECTION_CHAT, new UISWTViewEventListenerHolder(key, ChatView.class, chat, null), key, true, chat, prev_id);
ChatMDIEntry entry_info = new ChatMDIEntry(chat, entry);
chat.setUserData(MDI_KEY, entry_info);
entry.addListener(new MdiCloseListener() {
@Override
public void mdiEntryClosed(MdiEntry entry, boolean userClosed) {
chat.setUserData(MDI_KEY, null);
}
});
return (entry);
} catch (Throwable e) {
Debug.out(e);
return (null);
}
}
use of com.biglybt.ui.mdi.MdiCloseListener 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