diff --git a/gui/griffon-app/views/com/muwire/gui/CollectionWizardView.groovy b/gui/griffon-app/views/com/muwire/gui/CollectionWizardView.groovy index 4ecdd80e..e5ff0f76 100644 --- a/gui/griffon-app/views/com/muwire/gui/CollectionWizardView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/CollectionWizardView.groovy @@ -13,7 +13,6 @@ import java.awt.event.WindowEvent import griffon.inject.MVCMember import griffon.metadata.ArtifactProviderFor -import net.i2p.data.DataHelper import javax.swing.JComponent import javax.swing.JDialog @@ -78,7 +77,7 @@ class CollectionWizardView { gridLayout(rows : 1, cols :3) panel { label(text : trans("COLLECTION_TOTAL_FILES") + ":" + model.files.size()) - label(text : trans("COLLECTION_TOTAL_SIZE") + ":" + DataHelper.formatSize2Decimal(model.totalSize(), false) + trans("BYTES_SHORT")) + label(text : trans("COLLECTION_TOTAL_SIZE") + ":" + formatSize(model.totalSize())) } panel { label(text : trans("COLLECTION_DND")) @@ -209,4 +208,12 @@ class CollectionWizardView { } } } + + private static String formatSize(long size) { + StringBuffer sb = new StringBuffer(32) + String bTrans = trans("BYTES_SHORT") + SizeFormatter.format(size,sb) + sb.append(bTrans) + sb.toString() + } } \ No newline at end of file diff --git a/gui/griffon-app/views/com/muwire/gui/I2PStatusView.groovy b/gui/griffon-app/views/com/muwire/gui/I2PStatusView.groovy index 13aac973..fc023e67 100644 --- a/gui/griffon-app/views/com/muwire/gui/I2PStatusView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/I2PStatusView.groovy @@ -4,7 +4,6 @@ import griffon.core.artifact.GriffonView import static com.muwire.gui.Translator.trans import griffon.inject.MVCMember import griffon.metadata.ArtifactProviderFor -import net.i2p.data.DataHelper import javax.swing.JDialog import javax.swing.JPanel @@ -71,9 +70,9 @@ class I2PStatusView { constraints : gbc(gridx: 0, gridy: 3, fill : GridBagConstraints.HORIZONTAL, weightx: 100)) { gridBagLayout() label(text : trans("RECEIVE_15"), constraints : gbc(gridx:0, gridy:0, anchor: GridBagConstraints.LINE_START, weightx: 100)) - label(text : bind {DataHelper.formatSize2Decimal(model.receiveBps,false)+"B"}, constraints : gbc(gridx: 1, gridy:0, anchor : GridBagConstraints.LINE_END)) + label(text : bind {formatBW(model.receiveBps)}, constraints : gbc(gridx: 1, gridy:0, anchor : GridBagConstraints.LINE_END)) label(text : trans("SEND_15"), constraints : gbc(gridx:0, gridy:1, anchor: GridBagConstraints.LINE_START, weightx: 100)) - label(text : bind {DataHelper.formatSize2Decimal(model.sendBps, false)+"B"}, constraints : gbc(gridx: 1, gridy:1, anchor : GridBagConstraints.LINE_END)) + label(text : bind {formatBW(model.sendBps)}, constraints : gbc(gridx: 1, gridy:1, anchor : GridBagConstraints.LINE_END)) } } @@ -101,4 +100,12 @@ class I2PStatusView { }) dialog.show() } + + private static String formatBW(long bw) { + StringBuffer sb = new StringBuffer(32) + String bTrans = trans("BYTES_SHORT") + SizeFormatter.format(bw,sb) + sb.append(bTrans) + sb.toString() + } } diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 32df64b6..5d09aa9d 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -273,7 +273,7 @@ class MainFrameView { closureColumn(header: trans("STATUS"), preferredWidth: 50, type: String, read : {row -> trans(row.downloader.getCurrentState().name())}) closureColumn(header: trans("PROGRESS"), preferredWidth: 70, type: Downloader, read: { row -> row.downloader }) closureColumn(header: trans("SPEED"), preferredWidth: 50, type:String, read :{row -> - DataHelper.formatSize2Decimal(row.downloader.speed(), false) + trans("B_SEC") + formatSize(row.downloader.speed(),"B_SEC") }) closureColumn(header : trans("ETA"), preferredWidth : 50, type:String, read :{ row -> def speed = row.downloader.speed() @@ -341,8 +341,7 @@ class MainFrameView { trans("YOU_CAN_DRAG_AND_DROP") } else { trans("HASHING") + ": " + - model.hashingFile.getAbsolutePath() + " (" + DataHelper.formatSize2Decimal(model.hashingFile.length(), false) + - trans("BYTES_SHORT") + ")" + model.hashingFile.getAbsolutePath() + " (" + formatSize(model.hashingFile.length(),"BYTES_SHORT") + ")" } }) } @@ -434,13 +433,13 @@ class MainFrameView { if (size >= 0 ) { totalSize = trans("PERCENT_OF", String.format("%02d", percent), - DataHelper.formatSize2Decimal(size, false)) + trans("BYTES_SHORT") + formatSize(size, "BYTES_SHORT")) } "${totalSize} ($done/$pieces".toString() + trans("PIECES_SHORT")+ ")" }) closureColumn(header : trans("SPEED"), type : String, read : { row -> int speed = row.speed() - DataHelper.formatSize2Decimal(speed, false) + trans("B_SEC") + formatSize(speed, "B_SEC") }) } } @@ -779,12 +778,12 @@ class MainFrameView { panel (constraints : gbc(gridx : 0, gridy : 0)){ borderLayout() label(icon : imageIcon('/down_arrow.png'), constraints : BorderLayout.CENTER) - label(text : bind { DataHelper.formatSize2Decimal(model.downSpeed, false) + trans("B_SEC") }, constraints : BorderLayout.EAST) + label(text : bind { formatSize(model.downSpeed, "B_SEC") }, constraints : BorderLayout.EAST) } panel (constraints : gbc(gridx: 1, gridy : 0)){ borderLayout() label(icon : imageIcon('/up_arrow.png'), constraints : BorderLayout.CENTER) - label(text : bind { DataHelper.formatSize2Decimal(model.upSpeed, false) + trans("B_SEC") }, constraints : BorderLayout.EAST) + label(text : bind { formatSize(model.upSpeed, "B_SEC") }, constraints : BorderLayout.EAST) } } panel (constraints : BorderLayout.EAST) { @@ -2087,8 +2086,16 @@ class MainFrameView { sharedFilesTree.expandRow(currentRow++) currentNode = currentNode.getChildAt(0) } - } - + } + + private static String formatSize(long size, String suffix) { + StringBuffer sb = new StringBuffer(32) + suffix = trans(suffix) + SizeFormatter.format(size, sb) + sb.append(suffix) + sb.toString() + } + private class MWTransferHandler extends TransferHandler { public boolean canImport(TransferHandler.TransferSupport support) { return support.isDataFlavorSupported(DataFlavor.javaFileListFlavor) diff --git a/gui/griffon-app/views/com/muwire/gui/SystemStatusView.groovy b/gui/griffon-app/views/com/muwire/gui/SystemStatusView.groovy index a54d1060..57175920 100644 --- a/gui/griffon-app/views/com/muwire/gui/SystemStatusView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/SystemStatusView.groovy @@ -4,7 +4,6 @@ import griffon.core.artifact.GriffonView import static com.muwire.gui.Translator.trans import griffon.inject.MVCMember import griffon.metadata.ArtifactProviderFor -import net.i2p.data.DataHelper import javax.swing.JDialog import javax.swing.JPanel @@ -49,11 +48,11 @@ class SystemStatusView { constraints : gbc(gridx : 0, gridy: 1, fill : GridBagConstraints.HORIZONTAL, weightx: 100)) { gridBagLayout() label(text : trans("USED"), constraints : gbc(gridx:0, gridy:0, anchor : GridBagConstraints.LINE_START, weightx : 100)) - label(text : bind {DataHelper.formatSize2Decimal(model.usedRam,false)+"B"}, constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END)) + label(text : bind {formatRam(model.usedRam)}, constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END)) label(text : trans("TOTAL"), constraints : gbc(gridx:0, gridy:1, anchor : GridBagConstraints.LINE_START, weightx : 100)) - label(text : bind {DataHelper.formatSize2Decimal(model.totalRam,false)+"B"}, constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END)) + label(text : bind {formatRam(model.totalRam)}, constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END)) label(text : trans("MAX"), constraints : gbc(gridx:0, gridy:2, anchor : GridBagConstraints.LINE_START, weightx : 100)) - label(text : bind {DataHelper.formatSize2Decimal(model.maxRam,false)+"B"}, constraints : gbc(gridx:1, gridy:2, anchor : GridBagConstraints.LINE_END)) + label(text : bind {formatRam(model.maxRam)}, constraints : gbc(gridx:1, gridy:2, anchor : GridBagConstraints.LINE_END)) } buttonsPanel = builder.panel { gridBagLayout() @@ -81,4 +80,12 @@ class SystemStatusView { }) dialog.show() } + + private static String formatRam(long ram) { + StringBuffer sb = new StringBuffer(32) + String bTrans = trans("BYTES_SHORT") + SizeFormatter.format(ram,sb) + sb.append(bTrans) + sb.toString() + } } \ No newline at end of file