use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class SBC_ChatOverview method fillMenu.
@Override
public void fillMenu(String sColumnName, Menu menu) {
List<Object> ds = tv.getSelectedDataSources();
final List<ChatInstance> chats = new ArrayList<>();
for (Object obj : ds) {
if (obj instanceof ChatInstance) {
chats.add((ChatInstance) obj);
}
}
// show in sidebar
MenuItem itemSiS = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemSiS, Utils.isAZ2UI() ? "label.show.in.tab" : "label.show.in.sidebar");
itemSiS.setEnabled(chats.size() > 0);
itemSiS.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
MdiEntry first_entry = null;
for (ChatInstance chat : chats) {
try {
MdiEntry entry = createChatMdiEntry(chat.getClone());
if (first_entry == null) {
first_entry = entry;
}
} catch (Throwable e) {
Debug.out(e);
}
}
if (first_entry != null) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
mdi.showEntry(first_entry);
}
}
}
});
MenuItem itemRemove = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemRemove, "MySharesView.menu.remove");
Utils.setMenuItemImage(itemRemove, "delete");
itemRemove.setEnabled(chats.size() > 0);
itemRemove.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
for (ChatInstance chat : chats) {
chat.remove();
}
}
});
new MenuItem(menu, SWT.SEPARATOR);
}
use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class SBC_ChatOverview method preInitialize.
public static void preInitialize() {
UIManager ui_manager = PluginInitializer.getDefaultInterface().getUIManager();
ui_manager.addUIListener(new UIManagerListener() {
@Override
public void UIAttached(UIInstance instance) {
final MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi == null) {
return;
}
mdi.registerEntry("Chat_.*", new MdiEntryCreationListener2() {
@Override
public MdiEntry createMDiEntry(MultipleDocumentInterface mdi, String id, Object datasource, Map<?, ?> params) {
ChatInstance chat = null;
if (datasource instanceof ChatInstance) {
chat = (ChatInstance) datasource;
try {
chat = chat.getClone();
} catch (Throwable e) {
chat = null;
Debug.out(e);
}
} else if (id.length() > 7) {
BuddyPluginBeta beta = BuddyPluginUtils.getBetaPlugin();
if (beta != null) {
try {
String[] bits = id.substring(5).split(":");
String network = AENetworkClassifier.internalise(bits[0]);
String key = new String(Base32.decode(bits[1]), "UTF-8");
chat = beta.getChat(network, key);
} catch (Throwable e) {
Debug.out(e);
}
}
}
if (chat != null) {
chat.setAutoNotify(true);
return (createChatMdiEntry(chat));
}
return (null);
}
});
}
@Override
public void UIDetached(UIInstance instance) {
}
});
}
use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class MainWindowImpl method getUsageActiveTabID.
private String getUsageActiveTabID() {
try {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
MdiEntry curEntry = mdi.getCurrentEntry();
if (curEntry == null) {
return "none";
}
String id = curEntry.getLogID();
return id == null ? "null" : id;
}
} catch (Exception e) {
String name = e.getClass().getName();
int i = name.indexOf('.');
if (i > 0) {
return name.substring(i);
}
return name;
}
return "unknown";
}
use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class MainWindowImpl method mdiEntrySelected.
// @see MdiListener#mdiEntrySelected(MdiEntry, MdiEntry)
@Override
public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
if (newEntry == null) {
return;
}
if (mapTrackUsage != null && oldEntry != null) {
oldEntry.removeListener(this);
String id2 = null;
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
id2 = oldEntry.getLogID();
}
if (id2 == null) {
id2 = oldEntry.getId();
}
updateMapTrackUsage(id2);
}
if (mapTrackUsage != null) {
newEntry.addListener(this);
}
}
use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class MainMenuV3 method addV3HelpMenu.
/**
* Creates the Help menu and all its children
*/
private void addV3HelpMenu() {
MenuItem helpItem = MenuFactory.createHelpMenuItem(menuBar);
Menu helpMenu = helpItem.getMenu();
if (!Constants.isOSX) {
/*
* The 'About' menu is on the application menu on OSX
*/
MenuFactory.addAboutMenuItem(helpMenu);
MenuFactory.addSeparatorMenuItem(helpMenu);
}
MenuFactory.addMenuItem(helpMenu, PREFIX_V3 + ".getting_started", new Listener() {
@Override
public void handleEvent(Event event) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
mdi.showEntryByID(SideBar.SIDEBAR_SECTION_WELCOME);
}
}
});
MenuFactory.addReleaseNotesMenuItem(helpMenu);
if (!SystemProperties.isJavaWebStartInstance()) {
MenuFactory.addSeparatorMenuItem(helpMenu);
MenuFactory.addCheckUpdateMenuItem(helpMenu);
MenuFactory.addBetaMenuItem(helpMenu);
}
MenuFactory.addDonationMenuItem(helpMenu);
MenuFactory.addSeparatorMenuItem(helpMenu);
MenuFactory.addConfigWizardMenuItem(helpMenu);
MenuFactory.addNatTestMenuItem(helpMenu);
MenuFactory.addNetStatusMenuItem(helpMenu);
MenuFactory.addSpeedTestMenuItem(helpMenu);
MenuFactory.addAdvancedHelpMenuItem(helpMenu);
MenuFactory.addSeparatorMenuItem(helpMenu);
MenuFactory.addDebugHelpMenuItem(helpMenu);
}
Aggregations