use of com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance in project BiglyBT by BiglySoftware.
the class BuddyPluginView method buildMenu.
private void buildMenu(final Set<ChatInstance> current_instances) {
if (menu_items.size() == 0 || !menu_latest_instances.equals(current_instances)) {
for (MenuItem mi : menu_items) {
mi.remove();
}
menu_items.clear();
final MenuManager menu_manager = plugin.getPluginInterface().getUIManager().getMenuManager();
MenuContext mc = beta_status.getMenuContext();
for (final ChatInstance chat : sortChats(current_instances)) {
String short_name = chat.getShortName();
MenuItem mi = menu_manager.addMenuItem(mc, "!" + short_name + "!");
mi.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
try {
openChat(chat.getClone());
} catch (Throwable e) {
Debug.out(e);
}
}
});
menu_items.add(mi);
}
boolean need_sep = true;
if (current_instances.size() > 1) {
MenuItem mi = menu_manager.addMenuItem(mc, "sep1");
need_sep = false;
mi.setStyle(MenuItem.STYLE_SEPARATOR);
menu_items.add(mi);
mi = menu_manager.addMenuItem(mc, "label.open.all");
mi.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
for (ChatInstance chat : current_instances) {
try {
openChat(chat.getClone());
} catch (Throwable e) {
Debug.out(e);
}
}
}
});
menu_items.add(mi);
}
if (need_sep) {
MenuItem mi = menu_manager.addMenuItem(mc, "sep2");
mi.setStyle(MenuItem.STYLE_SEPARATOR);
menu_items.add(mi);
}
// create channel
MenuItem mi = menu_manager.addMenuItem(mc, "chat.view.create.chat");
mi.setStyle(MenuItem.STYLE_MENU);
menu_items.add(mi);
mi.addFillListener(new com.biglybt.pif.ui.menus.MenuItemFillListener() {
@Override
public void menuWillBeShown(MenuItem menu, Object data) {
menu.removeAllChildItems();
MenuItem mi = menu_manager.addMenuItem(menu, "!" + MessageText.getString("label.public") + "...!");
mi.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("chat.view.enter.key.title", "chat.view.enter.key.msg");
entryWindow.prompt(new UIInputReceiverListener() {
@Override
public void UIInputReceiverClosed(UIInputReceiver receiver) {
if (!receiver.hasSubmittedInput()) {
return;
}
String key = receiver.getSubmittedInput().trim();
BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_PUBLIC, key, null);
}
});
}
});
mi = menu_manager.addMenuItem(menu, "!" + MessageText.getString("label.anon") + "...!");
mi.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
if (plugin.getBeta().isI2PAvailable()) {
SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("chat.view.enter.key.title", "chat.view.enter.key.msg");
entryWindow.prompt(new UIInputReceiverListener() {
@Override
public void UIInputReceiverClosed(UIInputReceiver receiver) {
if (!receiver.hasSubmittedInput()) {
return;
}
String key = receiver.getSubmittedInput().trim();
BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_I2P, key, null);
}
});
} else {
I2PHelpers.installI2PHelper(null, null, null);
}
}
});
if (I2PHelpers.isInstallingI2PHelper()) {
mi.setEnabled(false);
mi.setText(mi.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
}
}
});
// chat overview
mi = menu_manager.addMenuItem(mc, "!" + MessageText.getString("chats.view.heading") + "...!");
mi.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif != null) {
uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CHAT);
}
}
});
menu_items.add(mi);
mi = menu_manager.addMenuItem(mc, "sep3");
mi.setStyle(MenuItem.STYLE_SEPARATOR);
menu_items.add(mi);
// options
mi = menu_manager.addMenuItem(mc, "MainWindow.menu.view.configuration");
mi.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
ui_instance.openView(UISWTInstance.VIEW_MAIN, VIEW_ID, null);
}
});
menu_items.add(mi);
menu_latest_instances = current_instances;
}
}
use of com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance in project BiglyBT by BiglySoftware.
the class BuddyPluginView method buildView.
@Override
public View buildView(Map<String, Object> properties, ViewListener listener) {
boolean is_swt = Utils.isSWTThread();
AERunnableObject runnable = new AERunnableObject() {
public Object runSupport() {
Composite swt_composite = (Composite) properties.get(BuddyPluginViewInterface.VP_SWT_COMPOSITE);
try {
ChatInstance chat = (ChatInstance) properties.get(BuddyPluginViewInterface.VP_CHAT);
if (chat != null) {
final BuddyPluginViewBetaChat view = new BuddyPluginViewBetaChat(BuddyPluginView.this, plugin, chat, swt_composite);
return (new View() {
@Override
public void activate() {
view.activate();
}
@Override
public void handleDrop(String drop) {
view.handleExternalDrop(drop);
}
@Override
public void destroy() {
view.close();
}
});
} else {
BetaSubViewHolder view = new BetaSubViewHolder();
DownloadAdapter download = (DownloadAdapter) properties.get(BuddyPluginViewInterface.VP_DOWNLOAD);
view.initialise(swt_composite, download, listener);
return (view);
}
} finally {
if (!is_swt) {
Utils.relayout(swt_composite);
}
}
}
};
Object result = is_swt ? runnable.runSupport() : Utils.execSWTThreadWithObject("chatbuild", runnable, 10 * 1000);
return ((View) result);
}
use of com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance in project BiglyBT by BiglySoftware.
the class BuddyPluginView method addBetaSubviews.
private void addBetaSubviews(boolean enable) {
String[] views = { TableManager.TABLE_MYTORRENTS_ALL_BIG, TableManager.TABLE_MYTORRENTS_INCOMPLETE, TableManager.TABLE_MYTORRENTS_INCOMPLETE_BIG, TableManager.TABLE_MYTORRENTS_COMPLETE, "TagsView" };
if (enable) {
taggableLifecycleAdapter = new TaggableLifecycleAdapter() {
@Override
public void taggableTagged(TagType tag_type, Tag tag, Taggable taggable) {
if (tag_type.getTagType() == TagType.TT_DOWNLOAD_MANUAL) {
DownloadManager dm = (DownloadManager) taggable;
for (BetaSubViewHolder h : beta_subviews.values()) {
h.tagsUpdated(dm);
}
}
}
@Override
public void taggableUntagged(TagType tag_type, Tag tag, Taggable taggable) {
if (tag_type.getTagType() == TagType.TT_DOWNLOAD_MANUAL) {
DownloadManager dm = (DownloadManager) taggable;
for (BetaSubViewHolder h : beta_subviews.values()) {
h.tagsUpdated(dm);
}
}
}
};
TagManagerFactory.getTagManager().addTaggableLifecycleListener(Taggable.TT_DOWNLOAD, taggableLifecycleAdapter);
UISWTViewEventListener listener = new UISWTViewEventListener() {
@Override
public boolean eventOccurred(UISWTViewEvent event) {
UISWTView currentView = event.getView();
switch(event.getType()) {
case UISWTViewEvent.TYPE_CREATE:
{
beta_subviews.put(currentView, new BetaSubViewHolder());
currentView.setDestroyOnDeactivate(false);
break;
}
case UISWTViewEvent.TYPE_INITIALIZE:
{
BetaSubViewHolder subview = beta_subviews.get(currentView);
if (subview != null) {
subview.initialise(event.getView(), (Composite) event.getData());
}
break;
}
case UISWTViewEvent.TYPE_DATASOURCE_CHANGED:
{
BetaSubViewHolder subview = beta_subviews.get(currentView);
if (subview != null) {
subview.setDataSource(event.getData());
}
break;
}
case UISWTViewEvent.TYPE_FOCUSGAINED:
{
BetaSubViewHolder subview = beta_subviews.get(currentView);
if (subview != null) {
subview.gotFocus();
}
break;
}
case UISWTViewEvent.TYPE_FOCUSLOST:
{
BetaSubViewHolder subview = beta_subviews.get(currentView);
if (subview != null) {
subview.lostFocus();
}
break;
}
case UISWTViewEvent.TYPE_DESTROY:
{
BetaSubViewHolder subview = beta_subviews.remove(currentView);
if (subview != null) {
subview.destroy();
}
break;
}
}
return true;
}
};
for (String table_id : views) {
ui_instance.addView(table_id, "azbuddy.ui.menu.chat", listener);
}
TableManager table_manager = plugin.getPluginInterface().getUIManager().getTableManager();
TableCellRefreshListener msg_refresh_listener = new TableCellRefreshListener() {
@Override
public void refresh(TableCell _cell) {
TableCellSWT cell = (TableCellSWT) _cell;
Download dl = (Download) cell.getDataSource();
if (dl == null) {
return;
}
List<ChatInstance> instances = BuddyPluginUtils.peekChatInstances(dl);
boolean is_pending = false;
for (ChatInstance instance : instances) {
if (instance.getMessageOutstanding()) {
is_pending = true;
}
}
Image graphic;
String tooltip;
int sort_order;
if (is_pending) {
graphic = bs_chat_gray_text;
tooltip = MessageText.getString("TableColumn.header.chat.msg.out");
sort_order = 1;
} else {
graphic = null;
tooltip = MessageText.getString("label.no.messages");
sort_order = 0;
}
cell.setMarginHeight(0);
cell.setGraphic(graphic);
cell.setToolTip(tooltip);
cell.setSortValue(sort_order);
cell.setCursorID(graphic == null ? SWT.CURSOR_ARROW : SWT.CURSOR_HAND);
}
};
TableCellMouseListener msg_mouse_listener = new TableCellMouseListener() {
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
if (event.eventType == TableCellMouseEvent.EVENT_MOUSEUP) {
TableCell cell = event.cell;
Download dl = (Download) cell.getDataSource();
if (dl != null) {
List<ChatInstance> instances = BuddyPluginUtils.peekChatInstances(dl);
for (ChatInstance instance : instances) {
if (instance.getMessageOutstanding()) {
try {
BuddyPluginUtils.getBetaPlugin().showChat(instance);
} catch (Throwable e) {
Debug.out(e);
}
}
}
}
}
}
};
columnMessagePending = new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn result) {
result.setAlignment(TableColumn.ALIGN_CENTER);
result.setPosition(TableColumn.POSITION_LAST);
result.setWidth(32);
result.setRefreshInterval(TableColumn.INTERVAL_INVALID_ONLY);
result.setType(TableColumn.TYPE_GRAPHIC);
result.addCellRefreshListener(msg_refresh_listener);
result.addCellMouseListener(msg_mouse_listener);
result.setIconReference("dchat_gray", true);
synchronized (columns) {
columns.add(result);
}
}
};
table_manager.registerColumn(Download.class, "azbuddy.ui.column.msgpending", columnMessagePending);
} else {
for (String table_id : views) {
ui_instance.removeViews(table_id, "azbuddy.ui.menu.chat");
}
for (UISWTView entry : new ArrayList<>(beta_subviews.keySet())) {
entry.closeView();
}
if (taggableLifecycleAdapter != null) {
TagManagerFactory.getTagManager().removeTaggableLifecycleListener(Taggable.TT_DOWNLOAD, taggableLifecycleAdapter);
taggableLifecycleAdapter = null;
}
beta_subviews.clear();
if (columnMessagePending != null) {
TableManager table_manager = plugin.getPluginInterface().getUIManager().getTableManager();
table_manager.unregisterColumn(Download.class, "azbuddy.ui.column.msgpending", columnMessagePending);
columnMessagePending = null;
synchronized (columns) {
columns.clear();
}
}
}
}
use of com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance in project BiglyBT by BiglySoftware.
the class MainMDISetup method setupSideBar.
public static void setupSideBar(final MultipleDocumentInterfaceSWT mdi, final MdiListener l) {
if (Utils.isAZ2UI()) {
setupSidebarClassic(mdi);
} else {
setupSidebarVuzeUI(mdi);
}
SBC_TorrentDetailsView.TorrentDetailMdiEntry.register(mdi);
PluginInterface pi = PluginInitializer.getDefaultInterface();
pi.getUIManager().addUIListener(new UIManagerListener2() {
@Override
public void UIDetached(UIInstance instance) {
}
@Override
public void UIAttached(UIInstance instance) {
}
@Override
public void UIAttachedComplete(UIInstance instance) {
PluginInitializer.getDefaultInterface().getUIManager().removeUIListener(this);
MdiEntry currentEntry = mdi.getCurrentEntry();
if (currentEntry != null) {
// User or another plugin selected an entry
return;
}
final String CFG_STARTTAB = "v3.StartTab";
final String CFG_STARTTAB_DS = "v3.StartTab.ds";
String startTab;
String datasource = null;
boolean showWelcome = false;
if (showWelcome) {
startTab = SideBar.SIDEBAR_SECTION_WELCOME;
} else {
if (!COConfigurationManager.hasParameter(CFG_STARTTAB, true)) {
COConfigurationManager.setParameter(CFG_STARTTAB, SideBar.SIDEBAR_SECTION_LIBRARY);
}
startTab = COConfigurationManager.getStringParameter(CFG_STARTTAB);
datasource = COConfigurationManager.getStringParameter(CFG_STARTTAB_DS, null);
}
if (!mdi.loadEntryByID(startTab, true, false, datasource)) {
mdi.showEntryByID(SideBar.SIDEBAR_SECTION_LIBRARY);
}
if (l != null) {
mdi.addListener(l);
}
}
});
configBetaEnabledListener = new ParameterListener() {
@Override
public void parameterChanged(String parameterName) {
boolean enabled = COConfigurationManager.getBooleanParameter("Beta Programme Enabled");
if (enabled) {
boolean closed = COConfigurationManager.getBooleanParameter("Beta Programme Sidebar Closed");
if (!closed) {
mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_BETAPROGRAM, false);
}
}
}
};
COConfigurationManager.addAndFireParameterListener("Beta Programme Enabled", configBetaEnabledListener);
mdi.registerEntry(StatsView.VIEW_ID, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS, new StatsView(), id, true, null, null);
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_ALLPEERS, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, new PeersSuperView(), id, true, null, null);
entry.setImageLeftID("image.sidebar.allpeers");
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_LOGGER, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS, new LoggerView(), id, true, null, null);
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_TAGS, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromSkinRef(MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, id, "tagsview", "{tags.view.heading}", null, null, true, null);
entry.setImageLeftID("image.sidebar.tag-overview");
entry.setDefaultExpanded(true);
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_TAG_DISCOVERY, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromSkinRef(MultipleDocumentInterface.SIDEBAR_SECTION_TAGS, id, "tagdiscoveryview", "{mdi.entry.tagdiscovery}", null, null, true, null);
entry.setImageLeftID("image.sidebar.tag-overview");
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_CHAT, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
final ViewTitleInfo title_info = new ViewTitleInfo() {
@Override
public Object getTitleInfoProperty(int propertyID) {
BuddyPluginBeta bp = BuddyPluginUtils.getBetaPlugin();
if (bp == null) {
return (null);
}
if (propertyID == TITLE_INDICATOR_TEXT) {
int num = 0;
for (ChatInstance chat : bp.getChats()) {
if (chat.getMessageOutstanding()) {
num++;
}
}
if (num > 0) {
return (String.valueOf(num));
} else {
return (null);
}
} else if (propertyID == TITLE_INDICATOR_COLOR) {
for (ChatInstance chat : bp.getChats()) {
if (chat.getMessageOutstanding()) {
if (chat.hasUnseenMessageWithNick()) {
return (SBC_ChatOverview.COLOR_MESSAGE_WITH_NICK);
}
}
}
}
return null;
}
};
MdiEntry mdi_entry = mdi.createEntryFromSkinRef(MultipleDocumentInterface.SIDEBAR_HEADER_DISCOVERY, MultipleDocumentInterface.SIDEBAR_SECTION_CHAT, "chatsview", "{mdi.entry.chatsoverview}", title_info, null, true, null);
mdi_entry.setImageLeftID("image.sidebar.chat-overview");
final TimerEventPeriodic timer = SimpleTimer.addPeriodicEvent("sb:chatup", 5 * 1000, new TimerEventPerformer() {
private String last_text;
private int[] last_colour;
@Override
public void perform(TimerEvent event) {
String text = (String) title_info.getTitleInfoProperty(ViewTitleInfo.TITLE_INDICATOR_TEXT);
int[] colour = (int[]) title_info.getTitleInfoProperty(ViewTitleInfo.TITLE_INDICATOR_COLOR);
boolean changed = text != last_text && (text == null || last_text == null || !text.equals(last_text));
if (!changed) {
changed = colour != last_colour && (colour == null || last_colour == null || !Arrays.equals(colour, last_colour));
}
if (changed) {
last_text = text;
last_colour = colour;
mdi_entry.redraw();
}
ViewTitleInfoManager.refreshTitleInfo(title_info);
}
});
mdi_entry.addListener(new MdiCloseListener() {
@Override
public void mdiEntryClosed(MdiEntry entry, boolean userClosed) {
timer.cancel();
}
});
return mdi_entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_ARCHIVED_DOWNLOADS, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
final com.biglybt.pif.download.DownloadManager download_manager = PluginInitializer.getDefaultInterface().getDownloadManager();
final ViewTitleInfo title_info = new ViewTitleInfo() {
@Override
public Object getTitleInfoProperty(int propertyID) {
if (propertyID == TITLE_INDICATOR_TEXT) {
int num = download_manager.getDownloadStubCount();
return (String.valueOf(num));
}
return null;
}
};
MdiEntry entry = mdi.createEntryFromSkinRef(MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, MultipleDocumentInterface.SIDEBAR_SECTION_ARCHIVED_DOWNLOADS, "archivedlsview", "{mdi.entry.archiveddownloadsview}", title_info, null, true, null);
entry.setImageLeftID("image.sidebar.archive");
final DownloadStubListener stub_listener = new DownloadStubListener() {
@Override
public void downloadStubEventOccurred(DownloadStubEvent event) {
ViewTitleInfoManager.refreshTitleInfo(title_info);
}
};
download_manager.addDownloadStubListener(stub_listener, false);
entry.addListener(new MdiCloseListener() {
@Override
public void mdiEntryClosed(MdiEntry entry, boolean userClosed) {
download_manager.removeDownloadStubListener(stub_listener);
}
});
entry.addListener(new MdiEntryDropListener() {
@Override
public boolean mdiEntryDrop(MdiEntry entry, Object data) {
if (data instanceof String) {
String str = (String) data;
if (str.startsWith("DownloadManager\n")) {
String[] bits = str.split("\n");
com.biglybt.pif.download.DownloadManager dm = PluginInitializer.getDefaultInterface().getDownloadManager();
List<Download> downloads = new ArrayList<>();
boolean failed = false;
for (int i = 1; i < bits.length; i++) {
byte[] hash = Base32.decode(bits[i]);
try {
Download download = dm.getDownload(hash);
if (download.canStubbify()) {
downloads.add(download);
} else {
failed = true;
}
} catch (Throwable e) {
}
}
final boolean f_failed = failed;
ManagerUtils.moveToArchive(downloads, new ManagerUtils.ArchiveCallback() {
boolean error = f_failed;
@Override
public void failed(DownloadStub original, Throwable e) {
error = true;
}
@Override
public void completed() {
if (error) {
String title = MessageText.getString("archive.failed.title");
String text = MessageText.getString("archive.failed.text");
MessageBoxShell prompter = new MessageBoxShell(title, text, new String[] { MessageText.getString("Button.ok") }, 0);
prompter.setAutoCloseInMS(0);
prompter.open(null);
}
}
});
}
return (true);
}
return false;
}
});
return entry;
}
});
// download history
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_DOWNLOAD_HISTORY, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
final DownloadHistoryManager history_manager = (DownloadHistoryManager) CoreFactory.getSingleton().getGlobalManager().getDownloadHistoryManager();
final ViewTitleInfo title_info = new ViewTitleInfo() {
@Override
public Object getTitleInfoProperty(int propertyID) {
if (propertyID == TITLE_INDICATOR_TEXT) {
if (history_manager == null) {
return (null);
} else if (history_manager.isEnabled()) {
int num = history_manager.getHistoryCount();
return (String.valueOf(num));
} else {
return (MessageText.getString("label.disabled"));
}
}
return null;
}
};
MdiEntry entry = mdi.createEntryFromSkinRef(MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, MultipleDocumentInterface.SIDEBAR_SECTION_DOWNLOAD_HISTORY, "downloadhistoryview", "{mdi.entry.downloadhistoryview}", title_info, null, true, null);
entry.setImageLeftID("image.sidebar.logview");
if (history_manager != null) {
final DownloadHistoryListener history_listener = new DownloadHistoryListener() {
@Override
public void downloadHistoryEventOccurred(DownloadHistoryEvent event) {
ViewTitleInfoManager.refreshTitleInfo(title_info);
}
};
history_manager.addListener(history_listener, false);
entry.addListener(new MdiCloseListener() {
@Override
public void mdiEntryClosed(MdiEntry entry, boolean userClosed) {
history_manager.removeListener(history_listener);
}
});
}
return entry;
}
});
// torrent options
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_OPTIONS, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, TorrentOptionsView.class, MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_OPTIONS, true, null, null);
entry.setImageLeftID("image.sidebar.torrentoptions");
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_MY_SHARES, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, MySharesView.class, MultipleDocumentInterface.SIDEBAR_SECTION_MY_SHARES, true, null, null);
entry.setImageLeftID("image.sidebar.myshares");
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_MY_TRACKER, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, MyTrackerView.class, MultipleDocumentInterface.SIDEBAR_SECTION_MY_TRACKER, true, null, null);
entry.setImageLeftID("image.sidebar.mytracker");
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_CLIENT_STATS, new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
MdiEntry entry = mdi.createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS, ClientStatsView.class, MultipleDocumentInterface.SIDEBAR_SECTION_CLIENT_STATS, true, null, null);
entry.setImageLeftID("image.sidebar.clientstats");
return entry;
}
});
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, new MdiEntryCreationListener2() {
@Override
public MdiEntry createMDiEntry(MultipleDocumentInterface mdi, String id, Object datasource, Map<?, ?> params) {
String section = (datasource instanceof String) ? ((String) datasource) : null;
boolean uiClassic = COConfigurationManager.getStringParameter("ui").equals("az2");
if (uiClassic || COConfigurationManager.getBooleanParameter("Show Options In Side Bar")) {
MdiEntry entry = ((MultipleDocumentInterfaceSWT) mdi).createEntryFromEventListener(MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS, ConfigView.class, MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, true, null, null);
entry.setImageLeftID("image.sidebar.config");
return entry;
}
ConfigShell.getInstance().open(section);
return null;
}
});
try {
if (!COConfigurationManager.getBooleanParameter("my.shares.view.auto.open.done", false)) {
final ShareManager share_manager = pi.getShareManager();
if (share_manager.getShares().length > 0) {
// stop showing this by default
// mdi.showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_MY_SHARES);
} else {
shareManagerListener = new ShareManagerListener() {
boolean done = false;
@Override
public void resourceModified(ShareResource old_resource, ShareResource new_resource) {
}
@Override
public void resourceDeleted(ShareResource resource) {
}
@Override
public void resourceAdded(ShareResource resource) {
if (done) {
return;
}
done = true;
share_manager.removeListener(this);
COConfigurationManager.setParameter("my.shares.view.auto.open.done", true);
mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_MY_SHARES, false);
}
@Override
public void reportProgress(int percent_complete) {
}
@Override
public void reportCurrentTask(String task_description) {
}
};
share_manager.addListener(shareManagerListener);
}
}
} catch (Throwable t) {
}
try {
if (!COConfigurationManager.getBooleanParameter("my.tracker.view.auto.open.done", false)) {
// Load Tracker View on first host of file
TRHost trackerHost = CoreFactory.getSingleton().getTrackerHost();
trackerHostListener = new TRHostListener() {
boolean done = false;
@Override
public void torrentRemoved(TRHostTorrent t) {
}
@Override
public void torrentChanged(TRHostTorrent t) {
}
@Override
public void torrentAdded(TRHostTorrent t) {
if (done) {
return;
}
done = true;
trackerHost.removeListener(this);
COConfigurationManager.setParameter("my.tracker.view.auto.open.done", true);
mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_MY_TRACKER, false);
}
@Override
public boolean handleExternalRequest(InetSocketAddress client_address, String user, String url, URL absolute_url, String header, InputStream is, OutputStream os, AsyncController async) throws IOException {
return false;
}
};
trackerHost.addListener(trackerHostListener);
}
} catch (Throwable t) {
}
UIManager uim = pi.getUIManager();
if (uim != null) {
MenuItem menuItem = uim.getMenuManager().addMenuItem(MenuManager.MENU_MENUBAR, "tags.view.heading");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TAGS);
}
});
menuItem = uim.getMenuManager().addMenuItem(MenuManager.MENU_MENUBAR, "tag.discovery.view.heading");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TAG_DISCOVERY);
}
});
menuItem = uim.getMenuManager().addMenuItem(MenuManager.MENU_MENUBAR, "chats.view.heading");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CHAT);
}
});
menuItem = uim.getMenuManager().addMenuItem(MenuManager.MENU_MENUBAR, "archivedlsview.view.heading");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_ARCHIVED_DOWNLOADS);
}
});
menuItem = uim.getMenuManager().addMenuItem(MenuManager.MENU_MENUBAR, "downloadhistoryview.view.heading");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_DOWNLOAD_HISTORY);
}
});
}
// System.out.println("Activate sidebar " + startTab + " took "
// + (SystemTime.getCurrentTime() - startTime) + "ms");
// startTime = SystemTime.getCurrentTime();
}
use of com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance in project BiglyBT by BiglySoftware.
the class MenuBuildUtils method addCommunityChatMenu.
public static void addCommunityChatMenu(Menu menu) {
final Menu chat_menu = new Menu(menu.getShell(), SWT.DROP_DOWN);
final org.eclipse.swt.widgets.MenuItem chat_item = new org.eclipse.swt.widgets.MenuItem(menu, SWT.CASCADE);
Messages.setLanguageText(chat_item, MainMenuV3.MENU_ID_COMMUNITY_CHAT);
chat_item.setMenu(chat_menu);
chat_menu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
for (org.eclipse.swt.widgets.MenuItem mi : chat_menu.getItems()) {
mi.dispose();
}
if (!BuddyPluginUtils.isBetaChatAvailable()) {
return;
}
// BiglyBT
{
org.eclipse.swt.widgets.MenuItem chat_pub = new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.PUSH);
Messages.setLanguageText(chat_pub, "label.public");
chat_pub.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
pub_chat_pending.set(true);
BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_PUBLIC, BuddyPluginBeta.COMMUNITY_CHAT_KEY, new BuddyPluginUtils.CreateChatCallback() {
@Override
public void complete(ChatInstance chat) {
pub_chat_pending.set(false);
}
});
}
});
if (pub_chat_pending.get()) {
chat_pub.setEnabled(false);
chat_pub.setText(chat_pub.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
}
if (BuddyPluginUtils.isBetaChatAnonAvailable()) {
org.eclipse.swt.widgets.MenuItem chat_priv = new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.PUSH);
Messages.setLanguageText(chat_priv, "label.anon");
chat_priv.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
anon_chat_pending.set(true);
BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_I2P, BuddyPluginBeta.COMMUNITY_CHAT_KEY, new BuddyPluginUtils.CreateChatCallback() {
@Override
public void complete(ChatInstance chat) {
anon_chat_pending.set(false);
}
});
}
});
if (anon_chat_pending.get()) {
chat_priv.setEnabled(false);
chat_priv.setText(chat_priv.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
}
} else {
org.eclipse.swt.widgets.MenuItem chat_priv = new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.PUSH);
chat_priv.setText(MessageText.getString("label.anon") + "...");
chat_priv.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
I2PHelpers.installI2PHelper(null, null, null);
}
});
if (I2PHelpers.isInstallingI2PHelper()) {
chat_priv.setEnabled(false);
chat_priv.setText(chat_priv.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
}
}
// country chat
final ChatInstance cc = BuddyPluginUtils.getCountryChat();
org.eclipse.swt.widgets.MenuItem chat_cc = new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.PUSH);
if (cc != null) {
String cc_text = MessageText.getString("menu.your.country", new String[] { (String) cc.getUserData(BuddyPluginUtils.CK_CC) });
chat_cc.setText(cc_text);
chat_cc.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
try {
BuddyPluginUtils.getBetaPlugin().showChat(cc);
} catch (Throwable e) {
Debug.out(e);
}
}
});
} else {
String cc_text = MessageText.getString("menu.your.country", new String[] { "..." });
chat_cc.setText(cc_text);
chat_cc.setEnabled(false);
}
// language chat
final ChatInstance lang = BuddyPluginUtils.getLanguageChat();
org.eclipse.swt.widgets.MenuItem chat_lang = new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.PUSH);
if (lang != null) {
String lang_text = MessageText.getString("menu.your.language", new String[] { (String) lang.getUserData(BuddyPluginUtils.CK_LANG) });
chat_lang.setText(lang_text);
chat_lang.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
try {
BuddyPluginUtils.getBetaPlugin().showChat(lang);
} catch (Throwable e) {
Debug.out(e);
}
}
});
} else {
String lang_text = MessageText.getString("menu.your.language", new String[] { "..." });
chat_lang.setText(lang_text);
chat_lang.setEnabled(false);
}
}
new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.SEPARATOR);
// Vuze
{
org.eclipse.swt.widgets.MenuItem chat_pub = new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.PUSH);
chat_pub.setText(MessageText.getString("ConfigView.section.interface.legacy") + " " + MessageText.getString("label.public"));
chat_pub.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
pub_chat_pending.set(true);
BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_PUBLIC, BuddyPluginBeta.LEGACY_COMMUNITY_CHAT_KEY, new BuddyPluginUtils.CreateChatCallback() {
@Override
public void complete(ChatInstance chat) {
pub_chat_pending.set(false);
}
});
}
});
if (pub_chat_pending.get()) {
chat_pub.setEnabled(false);
chat_pub.setText(chat_pub.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
}
if (BuddyPluginUtils.isBetaChatAnonAvailable()) {
org.eclipse.swt.widgets.MenuItem chat_priv = new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.PUSH);
chat_priv.setText(MessageText.getString("ConfigView.section.interface.legacy") + " " + MessageText.getString("label.anon"));
chat_priv.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
anon_chat_pending.set(true);
BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_I2P, BuddyPluginBeta.LEGACY_COMMUNITY_CHAT_KEY, new BuddyPluginUtils.CreateChatCallback() {
@Override
public void complete(ChatInstance chat) {
anon_chat_pending.set(false);
}
});
}
});
if (anon_chat_pending.get()) {
chat_priv.setEnabled(false);
chat_priv.setText(chat_priv.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
}
} else {
org.eclipse.swt.widgets.MenuItem chat_priv = new org.eclipse.swt.widgets.MenuItem(chat_menu, SWT.PUSH);
chat_priv.setText(MessageText.getString("label.anon") + "...");
chat_priv.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
I2PHelpers.installI2PHelper(null, null, null);
}
});
if (I2PHelpers.isInstallingI2PHelper()) {
chat_priv.setEnabled(false);
chat_priv.setText(chat_priv.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
}
}
}
}
});
}
Aggregations