use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class SBC_ActivityTableView method setupSidebarEntry.
public static void setupSidebarEntry(final MultipleDocumentInterface mdi) {
// Put TitleInfo in another class
final ViewTitleInfo titleInfoActivityView = new ViewTitleInfo() {
boolean had_unviewed = false;
@Override
public Object getTitleInfoProperty(int propertyID) {
if (propertyID == TITLE_INDICATOR_TEXT) {
int num_unread = 0;
int num_unviewed = 0;
List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
for (ActivitiesEntry entry : allEntries) {
if (!entry.isRead()) {
num_unread++;
}
if (!entry.getViewed()) {
num_unviewed++;
}
}
if (num_unread == 0) {
num_unviewed = 0;
}
boolean has_unviewed = num_unviewed > 0;
if (has_unviewed != had_unviewed) {
if (has_unviewed) {
MdiEntry parent = mdi.getEntry(MultipleDocumentInterface.SIDEBAR_HEADER_VUZE);
if (parent != null && !parent.isExpanded()) {
parent.setExpanded(true);
}
}
had_unviewed = has_unviewed;
}
if (num_unviewed > 0) {
return (String.valueOf(num_unviewed) + (num_unread == 0 ? "" : (":" + num_unread)));
} else if (num_unread > 0) {
return (String.valueOf(num_unread));
}
return null;
} else if (propertyID == TITLE_IMAGEID) {
return "image.sidebar.activity";
} else if (propertyID == TITLE_INDICATOR_COLOR) {
boolean has_unread = false;
boolean has_unviewed = false;
List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
for (ActivitiesEntry entry : allEntries) {
if (!entry.isRead()) {
has_unread = true;
}
if (!entry.getViewed()) {
has_unviewed = true;
}
}
if (has_unread && has_unviewed) {
return (COLOR_UNVIEWED_ENTRIES);
}
}
return null;
}
};
activitiesListener = new ActivitiesListener() {
@Override
public void vuzeNewsEntryChanged(ActivitiesEntry entry) {
refresh();
}
@Override
public void vuzeNewsEntriesRemoved(ActivitiesEntry[] entries) {
refresh();
}
@Override
public void vuzeNewsEntriesAdded(ActivitiesEntry[] entries) {
refresh();
}
private void refresh() {
ViewTitleInfoManager.refreshTitleInfo(titleInfoActivityView);
if (mdi_entry != null) {
mdi_entry.redraw();
}
}
};
ActivitiesManager.addListener(activitiesListener);
MdiEntryCreationListener creationListener = new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
mdi_entry = mdi.createEntryFromSkinRef(MultipleDocumentInterface.SIDEBAR_HEADER_VUZE, MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, "activity", "{sidebar." + MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES + "}", titleInfoActivityView, null, false, null);
return (mdi_entry);
}
};
mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, creationListener);
mdi.registerEntry("activities", creationListener);
PluginInterface pi = PluginInitializer.getDefaultInterface();
UIManager uim = pi.getUIManager();
MenuManager menuManager = uim.getMenuManager();
final MenuItem menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, "v3.activity.button.readall");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
for (ActivitiesEntry entry : allEntries) {
entry.setRead(true);
}
}
});
mdi.addListener(new MdiListener() {
@Override
public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
}
@Override
public void mdiDisposed(MultipleDocumentInterface mdi) {
if (activitiesListener != null) {
ActivitiesManager.removeListener(activitiesListener);
activitiesListener = null;
}
menuItem.remove();
}
});
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class SBC_GenericBrowsePage method skinObjectInitialShow.
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
Object creationParams = skinObject.getData("CreationParams");
browserSkinObject = SWTSkinUtils.findBrowserSO(soMain);
final MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
entry = mdi.getEntryBySkinView(this);
if (entry != null) {
vitalityImage = entry.addVitalityImage("image.sidebar.vitality.dots");
vitalityImage.setVisible(false);
mdi.addListener(new MdiListener() {
long lastSelect = 0;
@Override
public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
if (entry == newEntry) {
if (entry == oldEntry) {
if (lastSelect < SystemTime.getOffsetTime(-1000)) {
if (browserSkinObject != null) {
browserSkinObject.restart();
}
}
} else {
lastSelect = SystemTime.getCurrentTime();
}
}
}
@Override
public void mdiDisposed(MultipleDocumentInterface mdi) {
}
});
}
}
browserSkinObject.addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == EVENT_SHOW) {
browserSkinObject.removeListener(this);
browserSkinObject.addListener(new BrowserContext.loadingListener() {
@Override
public void browserLoadingChanged(boolean loading, String url) {
if (vitalityImage != null) {
vitalityImage.setVisible(loading);
}
}
});
} else if (eventType == EVENT_DATASOURCE_CHANGED) {
if (params instanceof String) {
browserSkinObject.setURL((String) params);
}
}
return null;
}
});
openURL();
return null;
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class DevicesFTUX method _doInstall.
protected void _doInstall(Core core, boolean itunes) {
List<InstallablePlugin> plugins = new ArrayList<>(2);
final PluginInstaller installer = core.getPluginManager().getPluginInstaller();
StandardPlugin vuze_plugin = null;
try {
vuze_plugin = installer.getStandardPlugin("vuzexcode");
} catch (Throwable ignored) {
}
if (vuze_plugin != null && !vuze_plugin.isAlreadyInstalled()) {
plugins.add(vuze_plugin);
}
if (itunes) {
StandardPlugin itunes_plugin = null;
try {
itunes_plugin = installer.getStandardPlugin("azitunes");
} catch (Throwable ignored) {
}
if (itunes_plugin != null && !itunes_plugin.isAlreadyInstalled()) {
plugins.add(itunes_plugin);
}
}
if (plugins.size() == 0) {
close();
return;
}
InstallablePlugin[] installablePlugins = plugins.toArray(new InstallablePlugin[0]);
try {
install_area_parent.setVisible(true);
install_area_parent.moveAbove(null);
Map<Integer, Object> properties = new HashMap<>();
properties.put(UpdateCheckInstance.PT_UI_STYLE, UpdateCheckInstance.PT_UI_STYLE_SIMPLE);
properties.put(UpdateCheckInstance.PT_UI_PARENT_SWT_COMPOSITE, install_area);
properties.put(UpdateCheckInstance.PT_UI_DISABLE_ON_SUCCESS_SLIDEY, true);
installer.install(installablePlugins, false, properties, new PluginInstallationListener() {
@Override
public void completed() {
close();
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
MdiEntry entry = mdi.getEntry(SideBar.SIDEBAR_HEADER_DEVICES);
List<? extends MdiEntryVitalityImage> vitalityImages = entry.getVitalityImages();
for (MdiEntryVitalityImage vi : vitalityImages) {
if (vi.getImageID().contains("turnon")) {
vi.setVisible(false);
}
}
List<Runnable> to_fire;
synchronized (to_fire_on_complete) {
to_fire = new ArrayList<>(to_fire_on_complete);
to_fire_on_complete.clear();
}
for (Runnable r : to_fire) {
if (r != null) {
try {
Utils.execSWTThread(r);
} catch (Throwable e) {
Debug.out(e);
}
}
}
}
@Override
public void cancelled() {
close();
}
@Override
public void failed(PluginException e) {
Debug.out(e);
// Utils.openMessageBox(Utils.findAnyShell(), SWT.OK, "Error",
// e.toString());
close();
}
});
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class MenuFactory method addCloseTabMenuItem.
public static MenuItem addCloseTabMenuItem(Menu menu) {
final MenuItem menuItem = addMenuItem(menu, MENU_ID_CLOSE_TAB, new Listener() {
@Override
public void handleEvent(Event event) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
MdiEntry currentEntry = mdi.getCurrentEntry();
if (currentEntry != null && currentEntry.isCloseable()) {
mdi.closeEntry(currentEntry, true);
}
}
}
});
menu.addMenuListener(new MenuListener() {
@Override
public void menuShown(MenuEvent e) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
MdiEntry currentEntry = mdi.getCurrentEntry();
if (currentEntry != null && currentEntry.isCloseable()) {
menuItem.setEnabled(true);
return;
}
}
menuItem.setEnabled(false);
}
@Override
public void menuHidden(MenuEvent e) {
}
});
return menuItem;
}
use of com.biglybt.ui.mdi.MdiEntry in project BiglyBT by BiglySoftware.
the class TabbedMDI method showEntry.
@Override
public void showEntry(final MdiEntry _newEntry) {
if (_newEntry == null) {
return;
}
TabbedEntry newEntry = (TabbedEntry) _newEntry;
select_history.remove(newEntry);
select_history.add(newEntry);
if (select_history.size() > 64) {
select_history.removeFirst();
}
MdiEntry oldEntry = getCurrentEntry();
if (newEntry == oldEntry && oldEntry != null) {
((BaseMdiEntry) newEntry).show();
triggerSelectionListener(newEntry, newEntry);
return;
}
if (oldEntry != null) {
oldEntry.hide();
}
setCurrentEntry((MdiEntrySWT) newEntry);
if (newEntry instanceof BaseMdiEntry) {
((BaseMdiEntry) newEntry).show();
}
triggerSelectionListener(newEntry, oldEntry);
}
Aggregations