pieces = new boolean[manager.getNbPieces()];
this.display = parent.getDisplay();
gFile = new Composite(genComposite, SWT.SHADOW_OUT);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gFile.setLayoutData(gridData);
GridLayout fileLayout = new GridLayout();
fileLayout.marginHeight = 0;
fileLayout.marginWidth = 10;
fileLayout.numColumns = 3;
gFile.setLayout(fileLayout);
Label piecesInfo = new Label(gFile, SWT.LEFT);
Messages.setLanguageText(piecesInfo, "GeneralView.section.downloaded");
gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
piecesInfo.setLayoutData(gridData);
piecesImage = new Canvas(gFile, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.widthHint = 150;
gridData.heightHint = 25;
piecesImage.setLayoutData(gridData);
piecesPercent = new BufferedLabel(gFile, SWT.RIGHT);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
gridData.widthHint = 50;
piecesPercent.setLayoutData(gridData);
Label availabilityInfo = new Label(gFile, SWT.LEFT);
Messages.setLanguageText(availabilityInfo, "GeneralView.section.availability");
gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
availabilityInfo.setLayoutData(gridData);
availabilityImage = new Canvas(gFile, SWT.NULL);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.widthHint = 150;
gridData.heightHint = 25;
availabilityImage.setLayoutData(gridData);
Messages.setLanguageText(availabilityImage, "GeneralView.label.status.pieces_available.tooltip");
availabilityPercent = new BufferedLabel(gFile, SWT.RIGHT);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
gridData.widthHint = 50;
availabilityPercent.setLayoutData(gridData);
Messages.setLanguageText(availabilityPercent.getWidget(), "GeneralView.label.status.pieces_available.tooltip");
gTransfer = new Group(genComposite, SWT.SHADOW_OUT);
Messages.setLanguageText(gTransfer, "GeneralView.section.transfer"); //$NON-NLS-1$
gridData = new GridData(GridData.FILL_HORIZONTAL);
gTransfer.setLayoutData(gridData);
GridLayout layoutTransfer = new GridLayout();
layoutTransfer.numColumns = 6;
gTransfer.setLayout(layoutTransfer);
Label label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.timeelapsed"); //$NON-NLS-1$
timeElapsed = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
timeElapsed.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.remaining"); //$NON-NLS-1$
timeRemaining = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
timeRemaining.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT); //$NON-NLS-1$
Messages.setLanguageText(label, "GeneralView.label.shareRatio");
shareRatio = new BufferedLabel(gTransfer, SWT.LEFT); //$NON-NLS-1$
gridData = new GridData(GridData.FILL_HORIZONTAL);
shareRatio.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.downloaded"); //$NON-NLS-1$
download = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
download.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.downloadspeed"); //$NON-NLS-1$
downloadSpeed = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
downloadSpeed.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT); //$NON-NLS-1$
Messages.setLanguageText(label, "GeneralView.label.hashfails");
hashFails = new BufferedLabel(gTransfer, SWT.LEFT); //$NON-NLS-1$
gridData = new GridData(GridData.FILL_HORIZONTAL);
hashFails.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.uploaded"); //$NON-NLS-1$
upload = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
upload.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.uploadspeed"); //$NON-NLS-1$
uploadSpeed = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
uploadSpeed.setLayoutData(gridData);
// blah
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.seeds");
seeds = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
seeds.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.peers");
peers = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
peers.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.completed");
completedLbl = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
completedLbl.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.totalspeed");
totalSpeed = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
totalSpeed.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.swarm_average_completion");
ave_completion = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
ave_completion.setLayoutData(gridData);
label = new Label(gTransfer, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.distributedCopies");
distributedCopies = new BufferedLabel(gTransfer, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
distributedCopies.setLayoutData(gridData);
////////////////////////
gInfo = new Group(genComposite, SWT.SHADOW_OUT);
Messages.setLanguageText(gInfo, "GeneralView.section.info");
gridData = new GridData(GridData.FILL_BOTH);
gInfo.setLayoutData(gridData);
GridLayout layoutInfo = new GridLayout();
layoutInfo.numColumns = 4;
gInfo.setLayout(layoutInfo);
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.filename"); //$NON-NLS-1$
fileName = new BufferedLabel(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
fileName.setLayoutData(gridData);
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.status"); //$NON-NLS-1$
torrentStatus = new BufferedLabel(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
torrentStatus.setLayoutData(gridData);
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.savein"); //$NON-NLS-1$
saveIn = new BufferedLabel(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
saveIn.setLayoutData(gridData);
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.totalsize"); //$NON-NLS-1$
fileSize = new BufferedLabel(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
fileSize.setLayoutData(gridData);
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.numberofpieces"); //$NON-NLS-1$
pieceNumber = new BufferedLabel(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
pieceNumber.setLayoutData(gridData);
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.hash"); //$NON-NLS-1$
hash = new BufferedLabel(gInfo, SWT.LEFT);
Messages.setLanguageText(hash.getWidget(), "GeneralView.label.hash.tooltip", true);
gridData = new GridData(GridData.FILL_HORIZONTAL);
hash.setLayoutData(gridData);
// click on hash -> copy to clipboard
hash.setCursor(display.getSystemCursor(SWT.CURSOR_HAND));
hash.setForeground(Colors.blue);
label.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent arg0) {
String hash_str = hash.getText();
if(hash_str != null && hash_str.length() != 0)
new Clipboard(display).setContents(new Object[] {hash_str.replaceAll(" ","")}, new Transfer[] {TextTransfer.getInstance()});
}
public void mouseDown(MouseEvent arg0) {
String hash_str = hash.getText();
if(hash_str != null && hash_str.length() != 0)
new Clipboard(display).setContents(new Object[] {hash_str.replaceAll(" ","")}, new Transfer[] {TextTransfer.getInstance()});
}
});
hash.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent arg0) {
String hash_str = hash.getText();
if(hash_str != null && hash_str.length() != 0)
new Clipboard(display).setContents(new Object[] {hash_str.replaceAll(" ","")}, new Transfer[] {TextTransfer.getInstance()});
}
public void mouseDown(MouseEvent arg0) {
String hash_str = hash.getText();
if(hash_str != null && hash_str.length() != 0)
new Clipboard(display).setContents(new Object[] {hash_str.replaceAll(" ","")}, new Transfer[] {TextTransfer.getInstance()});
}
});
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.size");
pieceSize = new BufferedLabel(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
pieceSize.setLayoutData(gridData);
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.creationdate");
creation_date = new BufferedLabel(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
creation_date.setLayoutData(gridData);
label = new Label(gInfo, SWT.LEFT);
Messages.setLanguageText(label, "GeneralView.label.private");
privateStatus = new BufferedLabel(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
privateStatus.setLayoutData(gridData);
// empty row
label = new Label(gInfo, SWT.LEFT);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
label.setLayoutData(gridData);
label = new Label(gInfo, SWT.LEFT);
label.setCursor(display.getSystemCursor(SWT.CURSOR_HAND));
label.setForeground(Colors.blue);
Messages.setLanguageText(label, "GeneralView.label.user_comment");
try {
user_comment = new Link(gInfo, SWT.LEFT | SWT.WRAP);
((Link)user_comment).addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Utils.launch(e.text);
}
});
} catch (Throwable e) {
user_comment = new Label(gInfo, SWT.LEFT | SWT.WRAP);
}
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
user_comment.setLayoutData(gridData);
label.addMouseListener(new MouseAdapter() {
private void editComment() {
TorrentUtil.promptUserForComment(new DownloadManager[] {manager});
}
public void mouseDoubleClick(MouseEvent arg0) {editComment();}
public void mouseDown(MouseEvent arg0) {editComment();}
});
label = new Label(gInfo, SWT.LEFT);
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
label.setLayoutData(gridData);
Messages.setLanguageText(label, "GeneralView.label.comment");
try {
lblComment = new Link(gInfo, SWT.LEFT | SWT.WRAP);
((Link)lblComment).addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Utils.launch(e.text);
}
});
} catch (Throwable e) {
lblComment = new Label(gInfo, SWT.LEFT | SWT.WRAP);
}
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 3;
lblComment.setLayoutData(gridData);
piecesImage.addListener(SWT.Paint, new Listener() {