Skip to content

Commit

Permalink
Added row-details viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
parg committed Dec 28, 2024
1 parent d316cbe commit c769fc9
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 122 deletions.
2 changes: 2 additions & 0 deletions core/src/com/biglybt/internat/MessagesBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5580,6 +5580,8 @@ direct.memory.too.small=Memory allocation failed, insufficient "Direct Memory" s
ConfigView.section.file.showopentorrentoptions.always.sidebar=Always show dialog sidebar
webui.reverse.proxy=Service is behind a reverse proxy
ConfigView.section.file.altloc.dnd=Move files not selected for download to an alternative location
label.row.details=Row Details
MyTorrentsView.menu.row.details={label.row.details}...

#
#
Expand Down
17 changes: 16 additions & 1 deletion uis/src/com/biglybt/ui/swt/TorrentMenuFancy.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import com.biglybt.ui.swt.sharing.ShareUtils;
import com.biglybt.ui.swt.views.FilesViewMenuUtil;
import com.biglybt.ui.swt.views.columnsetup.TableColumnSetupWindow;
import com.biglybt.ui.swt.views.table.TableRowViewer;
import com.biglybt.ui.swt.views.table.TableSelectedRowsListener;
import com.biglybt.ui.swt.views.table.TableViewSWT;
import com.biglybt.ui.common.table.impl.TableContextMenuManager;
Expand Down Expand Up @@ -2102,6 +2103,20 @@ public void handleEvent(Event event) {
});
}

// row details

createRow(detailArea, "MyTorrentsView.menu.row.details", null, new Listener() {
@Override
public void handleEvent(Event event) {
TableRowCore focusedRow = tv.getFocusedRow();
if (focusedRow == null || focusedRow.isRowDisposed()) {
focusedRow = tv.getRow(0);
}
String tableID = tv.getTableID();
new TableRowViewer(tv.getDataSourceType(), tableID, focusedRow );
}
});

createRow(detailArea, "MyTorrentsView.menu.editTableColumns", "columns", new Listener() {
@Override
public void handleEvent(Event event) {
Expand All @@ -2111,7 +2126,7 @@ public void handleEvent(Event event) {
}
String tableID = tv.getTableID();
new TableColumnSetupWindow(tv.getDataSourceType(), tableID, column, focusedRow,
TableStructureEventDispatcher.getInstance(tableID));
TableStructureEventDispatcher.getInstance(tableID), false );
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion uis/src/com/biglybt/ui/swt/shells/main/MainMenuV3.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public void handleEvent(Event event) {
}
String tableID = tv.getTableID();
new TableColumnSetupWindow(tv.getDataSourceType(), tableID, null, focusedRow,
TableStructureEventDispatcher.getInstance(tableID));
TableStructureEventDispatcher.getInstance(tableID), false );
}
});

Expand Down
66 changes: 34 additions & 32 deletions uis/src/com/biglybt/ui/swt/views/columnsetup/ColumnTC_NameInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,39 +136,41 @@ public void cellPaint(GC gc, TableCellSWT cell) {
gc.setAlpha(alpha);
}

Rectangle hitArea;
TableView<?> tv = ((TableCellCore) cell).getTableRowCore().getView();
TableColumnSetupWindow tvs = (TableColumnSetupWindow) tv.getParentDataSource();
if (tvs.isColumnAdded(column)) {
hitArea = Utils.EMPTY_RECT;
} else {
int x = bounds.x + titleSize.x + 15;
int y = bounds.y - 1;
int h = 15;

String textAdd = MessageText.getString("Button.add");
GCStringPrinter sp2 = new GCStringPrinter(gc, textAdd,
new Rectangle(x, y, 500, h), true, false, SWT.CENTER);
sp2.calculateMetrics();
int w = sp2.getCalculatedSize().x + 12;

gc.setAdvanced(true);
gc.setAntialias(SWT.ON);
gc.setBackground(ColorCache.getColor(gc.getDevice(), 255, 255, 255));
gc.fillRoundRectangle(x, y, w, h, 15, h);
gc.setBackground(ColorCache.getColor(gc.getDevice(), 215, 215, 215));
gc.fillRoundRectangle(x + 2, y + 2, w, h, 15, h);
gc.setForeground(ColorCache.getColor(gc.getDevice(), 145, 145, 145));
gc.drawRoundRectangle(x, y, w, h, 15, h);

gc.setForeground(ColorCache.getColor(gc.getDevice(), 50, 50, 50));
hitArea = new Rectangle(x, y, w + 2, h);
sp2.printString(gc, hitArea, SWT.CENTER);
bounds = cell.getBounds();
hitArea.x -= bounds.x;
hitArea.y -= bounds.y;
if ( cell.getTableID().equals( TableColumnSetupWindow.TABLEID_AVAIL )){
Rectangle hitArea;
TableView<?> tv = ((TableCellCore) cell).getTableRowCore().getView();
TableColumnSetupWindow tvs = (TableColumnSetupWindow) tv.getParentDataSource();
if (tvs.isColumnAdded(column)) {
hitArea = Utils.EMPTY_RECT;
} else {
int x = bounds.x + titleSize.x + 15;
int y = bounds.y - 1;
int h = 15;

String textAdd = MessageText.getString("Button.add");
GCStringPrinter sp2 = new GCStringPrinter(gc, textAdd,
new Rectangle(x, y, 500, h), true, false, SWT.CENTER);
sp2.calculateMetrics();
int w = sp2.getCalculatedSize().x + 12;

gc.setAdvanced(true);
gc.setAntialias(SWT.ON);
//gc.setBackground(ColorCache.getColor(gc.getDevice(), 255, 255, 255));
//gc.fillRoundRectangle(x, y, w, h, 15, h);
gc.setBackground(ColorCache.getColor(gc.getDevice(), 215, 215, 215));
gc.fillRoundRectangle(x + 2, y + 2, w, h, 15, h);
gc.setForeground(ColorCache.getColor(gc.getDevice(), 145, 145, 145));
gc.drawRoundRectangle(x+2, y+2, w, h, 15, h);

gc.setForeground(ColorCache.getColor(gc.getDevice(), 50, 50, 50));
hitArea = new Rectangle(x+2, y+2, w + 2, h);
sp2.printString(gc, hitArea, SWT.CENTER);
bounds = cell.getBounds();
hitArea.x -= bounds.x;
hitArea.y -= bounds.y;
}
cell.getTableRowCore().setData("AddHitArea", hitArea);
}
cell.getTableRowCore().setData("AddHitArea", hitArea);
}

// @see com.biglybt.pif.ui.tables.TableCellMouseListener#cellMouseTrigger(com.biglybt.pif.ui.tables.TableCellMouseEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;

import com.biglybt.core.internat.MessageText;
import com.biglybt.core.util.AERunnable;
import com.biglybt.core.util.Debug;
import com.biglybt.pif.ui.tables.*;
Expand All @@ -53,6 +54,13 @@ public ColumnTC_Sample(String tableID) {
setPosition(POSITION_INVISIBLE);
setRefreshInterval(INTERVAL_LIVE);
setWidth(120);

if ( tableID.equals( TableColumnSetupWindow.TABLEID_ROW_DETAILS )){
String existing = getNameOverride();
if ( existing == null || existing.isEmpty()){
setNameOverride(MessageText.getString( "label.value" ));
}
}
}

// @see com.biglybt.pif.ui.tables.TableCellAddedListener#cellAdded(com.biglybt.pif.ui.tables.TableCell)
Expand All @@ -76,7 +84,7 @@ public void runSupport() {

private static class Cell
implements TableCellRefreshListener, TableCellSWTPaintListener,
TableCellVisibilityListener, TableCellDisposeListener
TableCellVisibilityListener, TableCellDisposeListener, TableCellClipboardListener
{
private final TableColumnCore column;
private FakeTableCell sampleCell;
Expand Down Expand Up @@ -111,6 +119,8 @@ public void cellPaint(GC gc, TableCellSWT cell) {
return;
}
Rectangle bounds = cell.getBounds();
bounds.x += 2;
bounds.width -=4;
sampleCell.setCellArea(bounds);
try {
sampleCell.refresh();
Expand All @@ -136,6 +146,16 @@ public void cellVisibilityChanged(TableCell cell, int visibility) {
}
}

@Override
public String getClipboardText(TableCell cell){
FakeTableCell sampleCell = this.sampleCell;

if (sampleCell == null) {
return( null );
}
return( sampleCell.getClipboardText());
}

// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
Expand Down
Loading

0 comments on commit c769fc9

Please sign in to comment.