use of com.biglybt.ui.swt.views.skin.sidebar.SideBar in project BiglyBT by BiglySoftware.
the class DeviceManagerUI method uiAttachedAndCoreRunning.
private void uiAttachedAndCoreRunning(Core core) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
setupUI(mdi);
} else {
SkinViewManager.addListener(new SkinViewManagerListener() {
@Override
public void skinViewAdded(SkinView skinview) {
if (skinview instanceof SideBar) {
setupUI((SideBar) skinview);
SkinViewManager.RemoveListener(this);
}
}
});
}
}
});
canCloseListener = new canCloseListener() {
@Override
public boolean canClose() {
try {
if (device_manager == null) {
return (true);
}
if (!device_manager.isTranscodeManagerInitialized()) {
return true;
}
final TranscodeJob job = device_manager.getTranscodeManager().getQueue().getCurrentJob();
if (job == null || job.getState() != TranscodeJob.ST_RUNNING) {
return (true);
}
if (job.getTranscodeFile().getDevice().isHidden()) {
return (true);
}
String title = MessageText.getString("device.quit.transcoding.title");
String text = MessageText.getString("device.quit.transcoding.text", new String[] { job.getName(), job.getTarget().getDevice().getName(), String.valueOf(job.getPercentComplete()) });
MessageBoxShell mb = new MessageBoxShell(title, text, new String[] { MessageText.getString("UpdateWindow.quit"), MessageText.getString("Content.alert.notuploaded.button.abort") }, 1);
mb.open(null);
mb.waitUntilClosed();
return mb.getResult() == 0;
} catch (Throwable e) {
Debug.out(e);
return true;
}
}
};
UIExitUtilsSWT.addListener(canCloseListener);
}
use of com.biglybt.ui.swt.views.skin.sidebar.SideBar 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