use of com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo in project BiglyBT by BiglySoftware.
the class SubscriptionManagerUI method setupHeader.
private void setupHeader(MultipleDocumentInterface mdi, final MdiEntry headerEntry) {
MdiEntryVitalityImage addSub = headerEntry.addVitalityImage("image.sidebar.subs.add");
if (addSub != null) {
addSub.setToolTip(MessageText.getString("subscriptions.add.tooltip"));
addSub.addListener(new MdiEntryVitalityImageListener() {
@Override
public void mdiEntryVitalityImage_clicked(int x, int y) {
new SubscriptionWizard();
COConfigurationManager.setParameter("subscriptions.wizard.shown", true);
refreshTitles(mdiEntryOverview);
}
});
}
final MdiEntryVitalityImage warnSub = headerEntry.addVitalityImage(ALERT_IMAGE_ID);
if (warnSub != null) {
warnSub.setVisible(false);
}
final MdiEntryVitalityImage infoSub = headerEntry.addVitalityImage(INFO_IMAGE_ID);
if (infoSub != null) {
infoSub.setVisible(false);
}
headerEntry.setViewTitleInfo(new ViewTitleInfo() {
private long last_avail_calc = -1;
private int last_avail;
@Override
public Object getTitleInfoProperty(int propertyID) {
Object result = null;
if (propertyID == TITLE_INDICATOR_TEXT) {
// boolean expanded = headerEntry.isExpanded();
// always treat as collasped - due to various sidebar restructuring this had effectively been
// the case for quite a while and people complained when it reverted to the original way of working
// http://forum.vuze.com/Thread-Total-subscription-results-gone-in-Beta-19
boolean expanded = false;
SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
Subscription[] subs = subs_man.getSubscriptions(true);
if (expanded) {
if (warnSub != null) {
warnSub.setVisible(false);
}
} else {
int total = 0;
boolean warn = false;
String error_str = "";
for (Subscription s : subs) {
SubscriptionHistory history = s.getHistory();
total += history.getNumUnread();
String last_error = history.getLastError();
if (last_error != null && last_error.length() > 0) {
boolean auth_fail = history.isAuthFail();
if (history.getConsecFails() >= 3 || auth_fail) {
warn = true;
if (error_str.length() > 128) {
if (!error_str.endsWith(", ...")) {
error_str += ", ...";
}
} else {
error_str += (error_str.length() == 0 ? "" : ", ") + last_error;
}
}
}
}
if (warnSub != null) {
warnSub.setVisible(warn);
warnSub.setToolTip(error_str);
}
if (total > 0) {
result = String.valueOf(total);
}
}
if (infoSub != null) {
if (subs.length == 0 && !COConfigurationManager.getBooleanParameter("subscriptions.wizard.shown", false)) {
long now = SystemTime.getMonotonousTime();
if (last_avail_calc == -1 || now - last_avail_calc > 60 * 1000) {
last_avail = subs_man.getKnownSubscriptionCount();
last_avail_calc = now;
}
if (last_avail > 0) {
infoSub.setVisible(true);
infoSub.setToolTip(MessageText.getString("subscriptions.info.avail", new String[] { String.valueOf(last_avail) }));
}
} else {
infoSub.setVisible(false);
}
}
}
return (result);
}
});
}
use of com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo 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.common.viewtitleinfo.ViewTitleInfo in project BiglyBT by BiglySoftware.
the class SB_Dashboard method setupMDIEntry.
public MdiEntry setupMDIEntry() {
ViewTitleInfo title_info = new ViewTitleInfo() {
@Override
public Object getTitleInfoProperty(int propertyID) {
if (propertyID == TITLE_INDICATOR_TEXT) {
return (String.valueOf(items.size()));
}
if (propertyID == TITLE_INDICATOR_TEXT_TOOLTIP) {
return (null);
}
return null;
}
};
mdi_entry = mdi.createEntryFromSkinRef("", MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD, "dashboard", "{sidebar.header.dashboard}", title_info, null, false, null);
mdi_entry.setImageLeftID("image.sidebar.dashboard");
MdiEntryVitalityImage cog = mdi_entry.addVitalityImage("image.sidebar.cog");
cog.setToolTip(MessageText.getString("configure.dashboard"));
final long[] cog_click_time = { 0 };
cog.addListener(new MdiEntryVitalityImageListener() {
@Override
public void mdiEntryVitalityImage_clicked(int x, int y) {
synchronized (items) {
cog_click_time[0] = SystemTime.getMonotonousTime();
new DBConfigWindow(new ArrayList<DashboardItem>(items));
}
}
});
cog.setVisible(true);
mdi.addListener(new MdiListener() {
@Override
public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
if (mdi_entry == newEntry && mdi_entry == oldEntry) {
SimpleTimer.addEvent("changed", SystemTime.getOffsetTime(250), new TimerEventPerformer() {
@Override
public void perform(TimerEvent event) {
synchronized (items) {
if (SystemTime.getMonotonousTime() - cog_click_time[0] < 250) {
return;
}
}
fireChanged();
}
});
}
}
public void mdiDisposed(MultipleDocumentInterface mdi) {
}
});
return (mdi_entry);
}
use of com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo in project BiglyBT by BiglySoftware.
the class SB_Transfers method createDownloadingEntry.
protected MdiEntry createDownloadingEntry(MultipleDocumentInterface mdi) {
final MdiEntry[] entry_holder = { null };
ViewTitleInfo titleInfoDownloading = new ViewTitleInfo() {
private long max_incomp_dl_time;
@Override
public Object getTitleInfoProperty(int propertyID) {
if (propertyID == TITLE_INDICATOR_TEXT) {
if (COConfigurationManager.getBooleanParameter("Request Attention On New Download")) {
if (coreCreateTime > 0) {
if (max_incomp_dl_time == 0) {
max_incomp_dl_time = coreCreateTime;
}
if (statsNoLowNoise.newestIncompleteDownloadTime > max_incomp_dl_time) {
MdiEntry entry = entry_holder[0];
if (entry != null) {
max_incomp_dl_time = statsNoLowNoise.newestIncompleteDownloadTime;
entry.requestAttention();
}
}
}
}
int current = statsNoLowNoise.numIncomplete;
if (current > 0) {
// + " of " + numIncomplete;
return current + "";
}
} else if (propertyID == TITLE_INDICATOR_TEXT_TOOLTIP) {
return MessageText.getString("sidebar.LibraryDL.tooltip", new String[] { "" + statsNoLowNoise.numIncomplete, "" + statsNoLowNoise.numDownloading });
} else if (propertyID == TITLE_INDICATOR_COLOR) {
if (COConfigurationManager.getBooleanParameter("LibraryDL.UseDefaultIndicatorColor")) {
return (null);
} else {
if (statsNoLowNoise.numDownloading > 0) {
return (new int[] { 96, 160, 96 });
} else if (statsNoLowNoise.numErrorInComplete > 0) {
return (new int[] { 132, 16, 58 });
} else {
return (null);
}
}
}
return null;
}
};
MdiEntry entry = mdi.createEntryFromSkinRef(SideBar.SIDEBAR_HEADER_TRANSFERS, SideBar.SIDEBAR_SECTION_LIBRARY_DL, "library", "{sidebar.LibraryDL}", titleInfoDownloading, null, true, null);
entry_holder[0] = entry;
entry.setImageLeftID("image.sidebar.downloading");
entry.addListener(new MdiCloseListener() {
@Override
public void mdiEntryClosed(MdiEntry entry, boolean userClosed) {
if (userClosed) {
COConfigurationManager.setParameter("Show Downloading In Side Bar", false);
}
}
});
MdiEntryVitalityImage vitalityImage = entry.addVitalityImage(ID_VITALITY_ACTIVE);
vitalityImage.setVisible(false);
vitalityImage = entry.addVitalityImage(ID_VITALITY_ALERT);
vitalityImage.setVisible(false);
String parentID = "sidebar." + SideBar.SIDEBAR_SECTION_LIBRARY_DL;
MenuManager menu_manager = PluginInitializer.getDefaultInterface().getUIManager().getMenuManager();
MenuItem mi = menu_manager.addMenuItem(parentID, "menu.use.default.indicator.color");
mi.setDisposeWithUIDetach(UIInstance.UIT_SWT);
mi.setStyle(MenuItem.STYLE_CHECK);
mi.setData(COConfigurationManager.getBooleanParameter("LibraryDL.UseDefaultIndicatorColor"));
mi.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem mi, Object target) {
COConfigurationManager.setParameter("LibraryDL.UseDefaultIndicatorColor", mi.isSelected());
entry.redraw();
}
});
return entry;
}
use of com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo in project BiglyBT by BiglySoftware.
the class SB_Transfers method createUnopenedEntry.
protected MdiEntry createUnopenedEntry(MultipleDocumentInterface mdi) {
MdiEntry infoLibraryUn = mdi.createEntryFromSkinRef(SideBar.SIDEBAR_HEADER_TRANSFERS, SideBar.SIDEBAR_SECTION_LIBRARY_UNOPENED, "library", "{sidebar.LibraryUnopened}", null, null, true, SideBar.SIDEBAR_SECTION_LIBRARY);
infoLibraryUn.setImageLeftID("image.sidebar.unopened");
addMenuUnwatched(SideBar.SIDEBAR_SECTION_LIBRARY_UNOPENED);
infoLibraryUn.setViewTitleInfo(new ViewTitleInfo() {
@Override
public Object getTitleInfoProperty(int propertyID) {
if (propertyID == TITLE_INDICATOR_TEXT && statsNoLowNoise.numUnOpened > 0) {
return "" + statsNoLowNoise.numUnOpened;
}
return null;
}
});
infoLibraryUn.addListener(new MdiCloseListener() {
@Override
public void mdiEntryClosed(MdiEntry entry, boolean userClosed) {
if (userClosed) {
COConfigurationManager.setParameter("Show New In Side Bar", false);
}
}
});
return infoLibraryUn;
}
Aggregations