use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.
the class ViewQuickNotifications method refresh.
private void refresh() {
Object[] temp = ActivitiesManager.getMostRecentUnseen();
ActivitiesEntry entry = (ActivitiesEntry) temp[0];
String old_text = (String) notification_text.getData();
if (entry == null) {
notification_icon.setImage(null);
if (old_text.length() > 0) {
notification_text.setData("");
notification_text.redraw();
}
more_text.setText("");
} else {
String cur_text = entry.getText();
if (!old_text.equals(cur_text)) {
notification_text.setData(cur_text);
notification_text.redraw();
}
String icon_id = entry.getIconID();
if (icon_id != null) {
String existing = (String) notification_icon.getData();
if (existing == null || notification_icon.getImage() == null || !existing.equals(icon_id)) {
ImageLoader imageLoader = ImageLoader.getInstance();
if (existing != null) {
imageLoader.releaseImage(existing);
}
Image image = imageLoader.getImage(icon_id);
notification_icon.setImage(image);
notification_icon.setData(icon_id);
}
} else {
notification_icon.setImage(null);
}
int num = (Integer) temp[1];
if (num <= 1) {
more_text.setText("");
} else {
more_text.setText(MessageText.getString("popup.more.waiting", new String[] { String.valueOf(num - 1) }));
}
}
}
use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.
the class ColumnActivityActions method cellMouseTrigger.
// @see com.biglybt.pif.ui.tables.TableCellMouseListener#cellMouseTrigger(com.biglybt.pif.ui.tables.TableCellMouseEvent)
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
ActivitiesEntry entry = (ActivitiesEntry) event.cell.getDataSource();
String tooltip = null;
boolean invalidateAndRefresh = false;
Rectangle bounds = ((TableCellSWT) event.cell).getBounds();
String text = (String) event.cell.getTableRow().getData("text");
if (text == null) {
return;
}
GCStringPrinter sp = null;
GC gc = new GC(Display.getDefault());
try {
if (font != null) {
gc.setFont(font);
}
Rectangle drawBounds = getDrawBounds((TableCellSWT) event.cell);
sp = new GCStringPrinter(gc, text, drawBounds, true, true, SWT.WRAP | SWT.CENTER);
sp.calculateMetrics();
} catch (Exception e) {
Debug.out(e);
} finally {
gc.dispose();
}
if (sp != null) {
URLInfo hitUrl = sp.getHitUrl(event.x + bounds.x, event.y + bounds.y);
int newCursor;
if (hitUrl != null) {
if (event.eventType == TableCellMouseEvent.EVENT_MOUSEUP) {
if (hitUrl.url.equals("download")) {
String referal = null;
Object ds = event.cell.getDataSource();
if (ds instanceof ActivitiesEntry) {
referal = DLReferals.DL_REFERAL_DASHACTIVITY + "-" + ((ActivitiesEntry) ds).getTypeID();
}
TorrentListViewsUtils.downloadDataSource(ds, false, referal);
} else if (hitUrl.url.equals("play")) {
String referal = null;
Object ds = event.cell.getDataSource();
if (ds instanceof ActivitiesEntry) {
referal = DLReferals.DL_REFERAL_PLAYDASHACTIVITY + "-" + ((ActivitiesEntry) ds).getTypeID();
}
TorrentListViewsUtils.playOrStreamDataSource(ds, referal, false, true);
} else if (hitUrl.url.equals("launch")) {
// run via play or stream so we get the security warning
Object ds = event.cell.getDataSource();
TorrentListViewsUtils.playOrStreamDataSource(ds, DLReferals.DL_REFERAL_LAUNCH, false, true);
} else if (hitUrl.url.startsWith("action:")) {
entry.invokeCallback(hitUrl.url.substring(7));
} else if (!UrlFilter.getInstance().urlCanRPC(hitUrl.url)) {
Utils.launch(hitUrl.url);
} else {
UIFunctionsSWT uif = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uif != null) {
String target = hitUrl.target;
if (target == null) {
target = SkinConstants.VIEWID_BROWSER_BROWSE;
}
uif.viewURL(hitUrl.url, target, "column.activity.action");
return;
}
}
}
Object ds = event.cell.getDataSource();
newCursor = SWT.CURSOR_HAND;
if (UrlFilter.getInstance().urlCanRPC(hitUrl.url)) {
tooltip = hitUrl.title;
} else {
tooltip = hitUrl.url;
}
} else {
newCursor = SWT.CURSOR_ARROW;
}
int oldCursor = ((TableCellSWT) event.cell).getCursorID();
if (oldCursor != newCursor) {
invalidateAndRefresh = true;
((TableCellSWT) event.cell).setCursorID(newCursor);
}
}
Object o = event.cell.getToolTip();
if ((o == null) || (o instanceof String)) {
String oldTooltip = (String) o;
if (!StringCompareUtils.equals(oldTooltip, tooltip)) {
invalidateAndRefresh = true;
event.cell.setToolTip(tooltip);
}
}
if (invalidateAndRefresh) {
event.cell.invalidate();
((TableCellSWT) event.cell).redraw();
}
}
use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.
the class ColumnActivityActions method cellPaint.
// @see com.biglybt.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, com.biglybt.ui.swt.views.table.TableCellSWT)
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();
if (entry == null) {
return;
}
TableRow row = cell.getTableRow();
if (row == null) {
return;
}
String text = (String) row.getData("text");
if (text != null && text.length() > 0) {
if (font == null) {
FontData[] fontData = gc.getFont().getFontData();
fontData[0].setStyle(SWT.BOLD);
font = new Font(gc.getDevice(), fontData);
}
gc.setFont(font);
Rectangle bounds = getDrawBounds(cell);
GCStringPrinter sp = new GCStringPrinter(gc, text, bounds, true, true, SWT.WRAP | SWT.CENTER);
sp.calculateMetrics();
if (sp.hasHitUrl()) {
URLInfo[] hitUrlInfo = sp.getHitUrlInfo();
for (int i = 0; i < hitUrlInfo.length; i++) {
URLInfo info = hitUrlInfo[i];
// handle fake row when showing in column editor
info.urlUnderline = cell.getTableRow() == null || cell.getTableRow().isSelected();
if (info.urlUnderline) {
info.urlColor = null;
} else {
info.urlColor = colorLinkNormal;
}
}
int[] mouseOfs = cell.getMouseOffset();
if (mouseOfs != null) {
Rectangle realBounds = cell.getBounds();
URLInfo hitUrl = sp.getHitUrl(mouseOfs[0] + realBounds.x, mouseOfs[1] + realBounds.y);
if (hitUrl != null) {
hitUrl.urlColor = colorLinkHover;
}
}
}
sp.printString();
}
}
use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.
the class ColumnActivityNew method refresh.
// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();
boolean isRead = entry.getReadOn() > 0;
int sortVal = isRead ? 1 : 0;
if (cell.setSortValue(sortVal)) {
cell.invalidate();
}
}
use of com.biglybt.activities.ActivitiesEntry in project BiglyBT by BiglySoftware.
the class ColumnActivityText method cellMouseTrigger.
// @see com.biglybt.pif.ui.tables.TableCellMouseListener#cellMouseTrigger(com.biglybt.pif.ui.tables.TableCellMouseEvent)
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
String tooltip = null;
boolean invalidateAndRefresh = false;
ActivitiesEntry entry = (ActivitiesEntry) event.cell.getDataSource();
// Rectangle bounds = getDrawBounds((TableCellSWT) event.cell);
Rectangle bounds = ((TableCellSWT) event.cell).getBounds();
String text = entry.getText();
GC gc = new GC(Display.getDefault());
GCStringPrinter sp = null;
try {
sp = setupStringPrinter(gc, (TableCellSWT) event.cell);
} catch (Exception e) {
Debug.out(e);
} finally {
gc.dispose();
}
if (sp != null) {
URLInfo hitUrl = sp.getHitUrl(event.x + bounds.x, event.y + bounds.y);
int newCursor;
if (hitUrl != null) {
String url = hitUrl.url;
boolean ourUrl = UrlFilter.getInstance().urlCanRPC(url) || url.startsWith("/") || url.startsWith("#");
if (event.eventType == TableCellMouseEvent.EVENT_MOUSEDOWN && event.button == 1) {
if (!ourUrl) {
if (UrlUtils.isInternalProtocol(url)) {
try {
UIFunctionsManagerSWT.getUIFunctionsSWT().doSearch(url);
} catch (Throwable e) {
Debug.out(e);
}
} else {
Utils.launch(url);
}
} else {
UIFunctionsSWT uif = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uif != null) {
String target = hitUrl.target;
if (target == null) {
target = SkinConstants.VIEWID_BROWSER_BROWSE;
}
uif.viewURL(hitUrl.url, target, "column.activity.text");
return;
}
}
}
newCursor = SWT.CURSOR_HAND;
if (ourUrl) {
try {
tooltip = hitUrl.title == null ? null : URLDecoder.decode(hitUrl.title, "utf-8");
} catch (UnsupportedEncodingException e) {
}
} else {
tooltip = hitUrl.url;
}
} else {
newCursor = SWT.CURSOR_ARROW;
}
int oldCursor = ((TableCellSWT) event.cell).getCursorID();
if (oldCursor != newCursor) {
invalidateAndRefresh = true;
((TableCellSWT) event.cell).setCursorID(newCursor);
}
}
Object o = event.cell.getToolTip();
if ((o == null) || (o instanceof String)) {
String oldTooltip = (String) o;
if (!StringCompareUtils.equals(oldTooltip, tooltip)) {
invalidateAndRefresh = true;
event.cell.setToolTip(tooltip);
}
}
if (invalidateAndRefresh) {
event.cell.invalidate();
((TableCellSWT) event.cell).redraw();
}
}
Aggregations