use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class UIFunctionsImpl method hasDetailViews.
// @see UIFunctionsSWT#hasDetailViews()
@Override
public boolean hasDetailViews() {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi == null) {
return false;
}
MdiEntry[] sideBarEntries = mdi.getEntries();
for (int i = 0; i < sideBarEntries.length; i++) {
MdiEntry entry = sideBarEntries[i];
String id = entry.getId();
if (id != null && id.startsWith("DMDetails_")) {
return true;
}
}
return false;
}
use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class UIFunctionsImpl method closeAllDetails.
// @see UIFunctionsSWT#closeAllDetails()
@Override
public void closeAllDetails() {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi == null) {
return;
}
MdiEntry[] sideBarEntries = mdi.getEntries();
for (int i = 0; i < sideBarEntries.length; i++) {
MdiEntry entry = sideBarEntries[i];
String id = entry.getId();
if (id != null && id.startsWith("DMDetails_")) {
mdi.closeEntry(id);
}
}
}
use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class UIFunctionsImpl method closePluginView.
/* (non-Javadoc)
* @see UIFunctionsSWT#closePluginView(com.biglybt.ui.swt.pifimpl.UISWTViewCore)
*/
@Override
public void closePluginView(UISWTViewCore view) {
try {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi == null) {
return;
}
String id;
if (view instanceof UISWTViewImpl) {
id = ((UISWTViewImpl) view).getViewID();
} else {
id = view.getClass().getName();
int i = id.lastIndexOf('.');
if (i > 0) {
id = id.substring(i + 1);
}
}
mdi.closeEntry(id);
} catch (Exception e) {
Logger.log(new LogEvent(LOGID, "closePluginView", e));
}
}
use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class UIFunctionsImpl method showURL.
/**
* @param url
* @param target
*/
private void showURL(final String url, String target) {
if ("_blank".equalsIgnoreCase(target)) {
Utils.launch(url);
return;
}
if (target.startsWith("tab-")) {
target = target.substring(4);
}
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
// by the caller
if (mdi == null || !mdi.showEntryByID(target)) {
Utils.launch(url);
return;
}
MdiEntry entry = mdi.getEntry(target);
entry.addListener(new MdiEntryOpenListener() {
@Override
public void mdiEntryOpen(MdiEntry entry) {
entry.removeListener(this);
mainWindow.setVisible(true, true);
if (!(entry instanceof SideBarEntrySWT)) {
return;
}
SideBarEntrySWT entrySWT = (SideBarEntrySWT) entry;
SWTSkinObjectBrowser soBrowser = SWTSkinUtils.findBrowserSO(entrySWT.getSkinObject());
if (soBrowser != null) {
// ((SWTSkinObjectBrowser) skinObject).getBrowser().setVisible(false);
if (url == null || url.length() == 0) {
soBrowser.restart();
} else {
soBrowser.setURL(url);
}
}
}
});
}
use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.
the class MainMenuV3 method buildSimpleViewMenu.
/**
* @param viewMenu
*
* @since 4.5.0.3
*/
private void buildSimpleViewMenu(final Menu viewMenu, int accelerator) {
try {
MenuFactory.addMenuItem(viewMenu, SWT.CHECK, PREFIX_V3 + ".view.sidebar", new Listener() {
@Override
public void handleEvent(Event event) {
SideBar sidebar = (SideBar) SkinViewManager.getByClass(SideBar.class);
if (sidebar != null) {
sidebar.flipSideBarVisibility();
}
}
});
if (COConfigurationManager.getIntParameter("User Mode") > 1) {
SWTSkin skin = SWTSkinFactory.getInstance();
SWTSkinObject plugin_bar = skin.getSkinObject(SkinConstants.VIEWID_PLUGINBAR);
if (plugin_bar != null) {
MenuItem mi = MainMenuV3.createViewMenuItem(skin, viewMenu, "v3.MainWindow.menu.view." + SkinConstants.VIEWID_PLUGINBAR, SkinConstants.VIEWID_PLUGINBAR + ".visible", SkinConstants.VIEWID_PLUGINBAR, true, -1);
if (accelerator != -1 && mi.getAccelerator() == accelerator) {
Listener[] listeners = mi.getListeners(SWT.Selection);
for (Listener l : listeners) {
try {
l.handleEvent(null);
} catch (Throwable e) {
}
}
}
}
}
MenuFactory.addViewToolbarMenuItem(viewMenu);
// ///////
MenuItem itemStatusBar = MenuFactory.createTopLevelMenuItem(viewMenu, "v3.MainWindow.menu.view.statusbar");
itemStatusBar.setText(itemStatusBar.getText());
Menu menuStatusBar = itemStatusBar.getMenu();
final String[] statusAreaLangs = { "ConfigView.section.style.status.show_sr", "ConfigView.section.style.status.show_nat", "ConfigView.section.style.status.show_ddb", "ConfigView.section.style.status.show_ipf" };
final String[] statusAreaConfig = { "Status Area Show SR", "Status Area Show NAT", "Status Area Show DDB", "Status Area Show IPF" };
for (int i = 0; i < statusAreaConfig.length; i++) {
final String configID = statusAreaConfig[i];
String langID = statusAreaLangs[i];
final MenuItem item = new MenuItem(menuStatusBar, SWT.CHECK);
Messages.setLanguageText(item, langID);
item.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
COConfigurationManager.setParameter(configID, !COConfigurationManager.getBooleanParameter(configID));
}
});
menuStatusBar.addListener(SWT.Show, new Listener() {
@Override
public void handleEvent(Event event) {
item.setSelection(COConfigurationManager.getBooleanParameter(configID));
}
});
}
if (Constants.isWindows) {
MenuFactory.addSeparatorMenuItem(viewMenu);
}
boolean needsSep = false;
boolean enabled = COConfigurationManager.getBooleanParameter("Beta Programme Enabled");
if (enabled) {
MenuFactory.addMenuItem(viewMenu, SWT.CHECK, PREFIX_V2 + ".view.beta", new Listener() {
@Override
public void handleEvent(Event event) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
mdi.showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_BETAPROGRAM);
}
}
});
needsSep = true;
}
if (needsSep) {
MenuFactory.addSeparatorMenuItem(viewMenu);
}
needsSep = PluginsMenuHelper.getInstance().buildViewMenu(viewMenu, viewMenu.getShell());
if (COConfigurationManager.getBooleanParameter("Library.EnableSimpleView")) {
if (needsSep) {
MenuFactory.addSeparatorMenuItem(viewMenu);
}
// Ubuntu Unity (14.04) with SWT 4508 crashes when global View menu triggered as it appears
// that radio menu items aren't supported
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=419729#c9
int simple_advanced_menu_type = Constants.isLinux ? SWT.CHECK : SWT.RADIO;
MenuFactory.addMenuItem(viewMenu, simple_advanced_menu_type, PREFIX_V3 + ".view.asSimpleList", new Listener() {
@Override
public void handleEvent(Event event) {
UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
if (tb != null) {
UIToolBarItem item = tb.getToolBarItem("modeBig");
if (item != null) {
item.triggerToolBarItem(UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL, SelectedContentManager.convertSelectedContentToObject(null));
}
}
}
});
MenuFactory.addMenuItem(viewMenu, simple_advanced_menu_type, PREFIX_V3 + ".view.asAdvancedList", new Listener() {
@Override
public void handleEvent(Event event) {
UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
if (tb != null) {
UIToolBarItem item = tb.getToolBarItem("modeSmall");
if (item != null) {
item.triggerToolBarItem(UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL, SelectedContentManager.convertSelectedContentToObject(null));
}
}
}
});
}
viewMenu.addMenuListener(new MenuListener() {
@Override
public void menuShown(MenuEvent e) {
MenuItem sidebarMenuItem = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.sidebar");
if (sidebarMenuItem != null) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
sidebarMenuItem.setSelection(mdi.isVisible());
}
}
if (COConfigurationManager.getBooleanParameter("Library.EnableSimpleView")) {
MenuItem itemShowAsSimple = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.asSimpleList");
if (itemShowAsSimple != null) {
UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
if (tb != null) {
UIToolBarItem item = tb.getToolBarItem("modeBig");
long state = item == null ? 0 : item.getState();
itemShowAsSimple.setEnabled((state & UIToolBarItem.STATE_ENABLED) > 0);
itemShowAsSimple.setSelection((state & UIToolBarItem.STATE_DOWN) > 0);
}
}
MenuItem itemShowAsAdv = MenuFactory.findMenuItem(viewMenu, PREFIX_V3 + ".view.asAdvancedList");
if (itemShowAsAdv != null) {
UIToolBarManager tb = UIToolBarManagerImpl.getInstance();
if (tb != null) {
UIToolBarItem item = tb.getToolBarItem("modeSmall");
long state = item == null ? 0 : item.getState();
itemShowAsAdv.setEnabled((state & UIToolBarItem.STATE_ENABLED) > 0);
itemShowAsAdv.setSelection((state & UIToolBarItem.STATE_DOWN) > 0);
}
}
}
}
@Override
public void menuHidden(MenuEvent e) {
}
});
} catch (Exception e) {
Debug.out("Error creating View Menu", e);
}
}
Aggregations