Compare commits

...

20 Commits

Author SHA1 Message Date
Zlatin Balevsky
82eaafc2c3 Release 0.5.6 2019-10-31 23:22:13 +00:00
Zlatin Balevsky
a3fc1a62e7 format the I2P bandwidths 2019-10-31 21:52:22 +00:00
Zlatin Balevsky
2fd8f45107 update text in cli 2019-10-31 21:22:50 +00:00
Zlatin Balevsky
2429bbf59e Add update notification window 2019-10-31 20:51:09 +00:00
Zlatin Balevsky
f7e28e04f6 add a system status panel 2019-10-31 14:14:14 +00:00
Zlatin Balevsky
cc0188f20e show used memory, not free memory 2019-10-31 13:46:16 +00:00
Zlatin Balevsky
af9b4f4679 change package name for cli 2019-10-31 13:05:42 +00:00
Zlatin Balevsky
625a559d02 change package name 2019-10-31 13:02:44 +00:00
Zlatin Balevsky
6e20193d57 properly set Xmx 2019-10-31 07:15:54 +00:00
Zlatin Balevsky
88ac267f99 show java version and ram usage in cli 2019-10-31 07:14:52 +00:00
Zlatin Balevsky
9b3a7473d1 limit Xmx on cli-lanterna too 2019-10-31 06:52:56 +00:00
Zlatin Balevsky
5b0180280e fix changing font and size on metal lnf 2019-10-30 22:20:27 +00:00
Zlatin Balevsky
d0462034fc enforce comment length in cli as well 2019-10-30 21:51:16 +00:00
Zlatin Balevsky
f3e4098107 refresh gui when processing a sidecar file 2019-10-30 21:45:38 +00:00
Zlatin Balevsky
26e7ca0b21 enforce maximum comment length in the gui 2019-10-30 21:22:08 +00:00
Zlatin Balevsky
11007e5f19 allow up to exact max comment length 2019-10-30 21:20:09 +00:00
Zlatin Balevsky
ae651cb6bd implement sidecar files 2019-10-30 21:07:59 +00:00
Zlatin Balevsky
cad3a88517 Xmx256M by default 2019-10-30 21:06:33 +00:00
Zlatin Balevsky
29c81646af word-wrap the comment views 2019-10-30 19:52:37 +00:00
Zlatin Balevsky
8a0257927b Link to CLI configuration options 2019-10-30 19:43:51 +00:00
30 changed files with 437 additions and 41 deletions

View File

@@ -4,7 +4,7 @@ MuWire is an easy to use file-sharing program which offers anonymity using [I2P
It is inspired by the LimeWire Gnutella client and developped by a former LimeWire developer.
The current stable release - 0.5.3 is avaiable for download at https://muwire.com. You can find technical documentation in the "doc" folder.
The current stable release - 0.5.5 is avaiable for download at https://muwire.com. You can find technical documentation in the "doc" folder.
### Building
@@ -31,7 +31,7 @@ If you have an I2P router running on the same machine that is all you need to do
### Running the CLI
Look inside `cli-lanterna/build/distributions`. Untar/unzip one of the `shadow` files and then run the jar contained inside by typing `java -jar cli-lanterna-x.y.z.jar` in a terminal. The CLI will ask you about the router host and port on startup, no need to edit any files.
Look inside `cli-lanterna/build/distributions`. Untar/unzip one of the `shadow` files and then run the jar contained inside by typing `java -jar cli-lanterna-x.y.z.jar` in a terminal. The CLI will ask you about the router host and port on startup, no need to edit any files. However, the CLI does not have an options window yet, so if you need to change any options you will need to edit the configuration files. The CLI options are documented here https://github.com/zlatinb/muwire/wiki/CLI-Configuration-Options
The CLI is under active development and doesn't have all the features of the GUI.

View File

@@ -11,10 +11,14 @@ buildscript {
}
apply plugin : 'application'
mainClassName = 'com.muwire.clilanterna.CliLanterna'
application {
mainClassName = 'com.muwire.clilanterna.CliLanterna'
applicationDefaultJvmArgs = ['-Djava.util.logging.config.file=logging.properties','-Xmx256M']
applicationName = 'MuWire-cli'
}
apply plugin : 'com.github.johnrengelman.shadow'
applicationDefaultJvmArgs = ['-Djava.util.logging.config.file=logging.properties']
dependencies {
compile project(":core")

View File

@@ -3,6 +3,8 @@ package com.muwire.clilanterna
import com.googlecode.lanterna.gui2.TextBox
import com.googlecode.lanterna.gui2.TextGUI
import com.googlecode.lanterna.gui2.Window
import com.googlecode.lanterna.gui2.dialogs.MessageDialog
import com.googlecode.lanterna.gui2.dialogs.MessageDialogButton
import com.googlecode.lanterna.TerminalSize
import com.googlecode.lanterna.gui2.BasicWindow
import com.googlecode.lanterna.gui2.Button
@@ -10,6 +12,7 @@ import com.googlecode.lanterna.gui2.GridLayout
import com.googlecode.lanterna.gui2.GridLayout.Alignment
import com.googlecode.lanterna.gui2.LayoutData
import com.googlecode.lanterna.gui2.Panel
import com.muwire.core.Constants
import com.muwire.core.Core
import com.muwire.core.SharedFile
import com.muwire.core.files.UICommentEvent
@@ -49,11 +52,16 @@ class AddCommentView extends BasicWindow {
Button saveButton = new Button("Save", {
String newComment = textBox.getText()
newComment = Base64.encode(DataUtil.encodei18nString(newComment))
String encodedOldComment = sharedFile.getComment()
sharedFile.setComment(newComment)
core.eventBus.publish(new UICommentEvent(sharedFile : sharedFile, oldComment : encodedOldComment))
close()
if (newComment.length() > Constants.MAX_COMMENT_LENGTH) {
String error = "Your comment is too long - ${newComment.length()} bytes. Maximum is $Constants.MAX_COMMENT_LENGTH bytes"
MessageDialog.showMessageDialog(textGUI, "Comment Too Long", error, MessageDialogButton.Close)
} else {
newComment = Base64.encode(DataUtil.encodei18nString(newComment))
String encodedOldComment = sharedFile.getComment()
sharedFile.setComment(newComment)
core.eventBus.publish(new UICommentEvent(sharedFile : sharedFile, oldComment : encodedOldComment))
close()
}
})
Button cancelButton = new Button("Cancel", {close()})

View File

@@ -32,7 +32,7 @@ import com.muwire.core.UILoadedEvent
import com.muwire.core.files.AllFilesLoadedEvent
class CliLanterna {
private static final String MW_VERSION = "0.5.5"
private static final String MW_VERSION = "0.5.6"
private static volatile Core core

View File

@@ -30,6 +30,7 @@ import com.muwire.core.update.UpdateAvailableEvent
import com.muwire.core.update.UpdateDownloadedEvent
import net.i2p.data.Base64
import net.i2p.data.DataHelper
class MainWindowView extends BasicWindow {
@@ -49,6 +50,7 @@ class MainWindowView extends BasicWindow {
private final Label sharedFiles
private final Label timesBrowsed
private final Label updateStatus
private final Label usedRam, totalRam, maxRam
public MainWindowView(String title, Core core, TextGUI textGUI, Screen screen, CliSettings props) {
super(title);
@@ -130,6 +132,9 @@ class MainWindowView extends BasicWindow {
sharedFiles = new Label("0")
timesBrowsed = new Label("0")
updateStatus = new Label("Unknown")
usedRam = new Label("0")
maxRam = new Label("0")
totalRam = new Label("0")
statusPanel.with {
addComponent(new Label("Incoming Connections: "), layoutData)
@@ -148,6 +153,14 @@ class MainWindowView extends BasicWindow {
addComponent(timesBrowsed, layoutData)
addComponent(new Label("Update Status: "), layoutData)
addComponent(updateStatus, layoutData)
addComponent(new Label("Java Version: "), layoutData)
addComponent(new Label(System.getProperty("java.vendor")+ " " + System.getProperty("java.version")), layoutData)
addComponent(new Label("Used Memory: "), layoutData)
addComponent(usedRam, layoutData)
addComponent(new Label("Total Memory: "), layoutData)
addComponent(totalRam, layoutData)
addComponent(new Label("Maximum Memory: "), layoutData)
addComponent(maxRam, layoutData)
}
refreshStats()
@@ -204,8 +217,11 @@ class MainWindowView extends BasicWindow {
textGUI.getGUIThread().invokeLater {
String label = "$e.version is available with hash $e.infoHash"
updateStatus.setText(label)
String message = "Version $e.version is available from $e.signer, search for $e.infoHash"
MessageDialog.showMessageDialog(textGUI, "Update Available", message, MessageDialogButton.OK)
String message = "Version $e.version is available, with hash $e.infoHash . Show details?"
def button = MessageDialog.showMessageDialog(textGUI, "Update Available", message, MessageDialogButton.Yes, MessageDialogButton.No)
if (button == MessageDialogButton.No)
return
textGUI.addWindowAndWait(new UpdateTextView(e.text, sizeForTables()))
}
}
@@ -213,8 +229,11 @@ class MainWindowView extends BasicWindow {
textGUI.getGUIThread().invokeLater {
String label = "$e.version downloaded"
updateStatus.setText(label)
String message = "Version $e.version from $e.signer has been downloaded. You can update now."
MessageDialog.showMessageDialog(textGUI, "Update Available", message, MessageDialogButton.OK)
String message = "MuWire version $e.version has been downloaded. Show details?."
def button = MessageDialog.showMessageDialog(textGUI, "Update Available", message, MessageDialogButton.Yes, MessageDialogButton.No)
if (button == MessageDialogButton.No)
return
textGUI.addWindowAndWait(new UpdateTextView(e.text, sizeForTables()))
}
}
@@ -266,6 +285,17 @@ class MainWindowView extends BasicWindow {
int hopelessHosts = core.hostCache.countHopelessHosts()
int shared = core.fileManager.fileToSharedFile.size()
int browsed = core.connectionAcceptor.browsed
long freeMemL = Runtime.getRuntime().freeMemory()
long totalMemL = Runtime.getRuntime().totalMemory()
String usedMem = DataHelper.formatSize2Decimal(freeMemL, false) + "B"
String totalMem = DataHelper.formatSize2Decimal(totalMemL, false)+"B"
String maxMem
long maxMemL = Runtime.getRuntime().maxMemory()
if (maxMemL >= Long.MAX_VALUE / 2)
maxMem = "Unlimited"
else
maxMem = DataHelper.formatSize2Decimal(maxMemL, false) + "B"
incoming.setText(String.valueOf(inCon))
outgoing.setText(String.valueOf(outCon))
@@ -274,5 +304,8 @@ class MainWindowView extends BasicWindow {
hopeless.setText(String.valueOf(hopelessHosts))
sharedFiles.setText(String.valueOf(shared))
timesBrowsed.setText(String.valueOf(browsed))
usedRam.setText(usedMem)
totalRam.setText(totalMem)
maxRam.setText(maxMem)
}
}

View File

@@ -0,0 +1,34 @@
package com.muwire.clilanterna
import com.googlecode.lanterna.TerminalSize
import com.googlecode.lanterna.gui2.BasicWindow
import com.googlecode.lanterna.gui2.Button
import com.googlecode.lanterna.gui2.GridLayout
import com.googlecode.lanterna.gui2.GridLayout.Alignment
import com.googlecode.lanterna.gui2.LayoutData
import com.googlecode.lanterna.gui2.Panel
import com.googlecode.lanterna.gui2.TextBox
import com.googlecode.lanterna.gui2.Window
class UpdateTextView extends BasicWindow {
private final TextBox textBox
private final LayoutData layoutData = GridLayout.createLayoutData(Alignment.CENTER, Alignment.CENTER)
UpdateTextView(String text, TerminalSize terminalSize) {
super("Update Details")
setHints([Window.Hint.CENTERED])
Panel contentPanel = new Panel()
contentPanel.setLayoutManager(new GridLayout(1))
TerminalSize boxSize = new TerminalSize((terminalSize.getColumns() / 2).toInteger(), (terminalSize.getRows() / 2).toInteger())
textBox = new TextBox(boxSize, text, TextBox.Style.MULTI_LINE)
contentPanel.addComponent(textBox, layoutData)
Button closeButton = new Button("Close", {close()})
contentPanel.addComponent(closeButton, layoutData)
setComponent(contentPanel)
}
}

View File

@@ -28,6 +28,7 @@ import com.muwire.core.files.FileSharedEvent
import com.muwire.core.files.FileUnsharedEvent
import com.muwire.core.files.HasherService
import com.muwire.core.files.PersisterService
import com.muwire.core.files.SideCarFileEvent
import com.muwire.core.files.UICommentEvent
import com.muwire.core.files.UIPersistFilesEvent
import com.muwire.core.files.AllFilesLoadedEvent
@@ -221,6 +222,7 @@ public class Core {
eventBus.register(SearchEvent.class, fileManager)
eventBus.register(DirectoryUnsharedEvent.class, fileManager)
eventBus.register(UICommentEvent.class, fileManager)
eventBus.register(SideCarFileEvent.class, fileManager)
log.info("initializing mesh manager")
MeshManager meshManager = new MeshManager(fileManager, home, props)
@@ -380,7 +382,7 @@ public class Core {
}
}
Core core = new Core(props, home, "0.5.5")
Core core = new Core(props, home, "0.5.6")
core.startServices()
// ... at the end, sleep or execute script

View File

@@ -25,6 +25,7 @@ class FileManager {
final Map<String, Set<File>> commentToFile = new HashMap<>()
final SearchIndex index = new SearchIndex()
final FileTree negativeTree = new FileTree()
final Set<File> sideCarFiles = new HashSet<>()
FileManager(EventBus eventBus, MuWireSettings settings) {
this.settings = settings
@@ -36,8 +37,15 @@ class FileManager {
}
void onFileHashedEvent(FileHashedEvent e) {
if (e.sharedFile != null)
addToIndex(e.sharedFile)
if (e.sharedFile == null)
return
File f = e.sharedFile.getFile()
if (sideCarFiles.remove(f)) {
File sideCar = new File(f.getParentFile(), f.getName() + ".mwcomment")
if (sideCar.exists())
e.sharedFile.setComment(Base64.encode(DataUtil.encodei18nString(sideCar.text)))
}
addToIndex(e.sharedFile)
}
void onFileLoadedEvent(FileLoadedEvent e) {
@@ -49,6 +57,21 @@ class FileManager {
addToIndex(e.downloadedFile)
}
}
void onSideCarFileEvent(SideCarFileEvent e) {
String name = e.file.getName()
name = name.substring(0, name.length() - ".mwcomment".length())
File target = new File(e.file.getParentFile(), name)
SharedFile existing = fileToSharedFile.get(target)
if (existing == null) {
sideCarFiles.add(target)
return
}
String comment = Base64.encode(DataUtil.encodei18nString(e.file.text))
String oldComment = existing.getComment()
existing.setComment(comment)
eventBus.publish(new UICommentEvent(oldComment : oldComment, sharedFile : existing))
}
private void addToIndex(SharedFile sf) {
log.info("Adding shared file " + sf.getFile())

View File

@@ -3,6 +3,7 @@ package com.muwire.core.files
import java.util.concurrent.Executor
import java.util.concurrent.Executors
import com.muwire.core.Constants
import com.muwire.core.EventBus
import com.muwire.core.MuWireSettings
import com.muwire.core.SharedFile
@@ -33,7 +34,9 @@ class HasherService {
return
if (fileManager.fileToSharedFile.containsKey(canonical))
return
if (hashed.add(canonical))
if (canonical.getName().endsWith(".mwcomment") && canonical.length() <= Constants.MAX_COMMENT_LENGTH)
eventBus.publish(new SideCarFileEvent(file : canonical))
else if (hashed.add(canonical))
executor.execute( { -> process(canonical) } as Runnable)
}

View File

@@ -0,0 +1,7 @@
package com.muwire.core.files
import com.muwire.core.Event
class SideCarFileEvent extends Event {
File file
}

View File

@@ -7,4 +7,5 @@ class UpdateAvailableEvent extends Event {
String version
String signer
String infoHash
String text
}

View File

@@ -40,6 +40,8 @@ class UpdateClient {
private volatile InfoHash updateInfoHash
private volatile String version, signer
private volatile boolean updateDownloading
private volatile String text
UpdateClient(EventBus eventBus, I2PSession session, String myVersion, MuWireSettings settings, FileManager fileManager, Persona me) {
this.eventBus = eventBus
@@ -75,7 +77,7 @@ class UpdateClient {
if (e.downloadedFile.infoHash != updateInfoHash)
return
updateDownloading = false
eventBus.publish(new UpdateDownloadedEvent(version : version, signer : signer))
eventBus.publish(new UpdateDownloadedEvent(version : version, signer : signer, text : text))
}
private void checkUpdate() {
@@ -147,15 +149,16 @@ class UpdateClient {
} else
infoHash = payload[settings.updateType]
text = payload.text
if (!settings.autoDownloadUpdate) {
log.info("new version $payload.version available, publishing event")
eventBus.publish(new UpdateAvailableEvent(version : payload.version, signer : payload.signer, infoHash : infoHash))
eventBus.publish(new UpdateAvailableEvent(version : payload.version, signer : payload.signer, infoHash : infoHash, text : text))
} else {
log.info("new version $payload.version available")
updateInfoHash = new InfoHash(Base64.decode(infoHash))
if (fileManager.rootToFiles.containsKey(updateInfoHash))
eventBus.publish(new UpdateDownloadedEvent(version : payload.version, signer : payload.signer))
eventBus.publish(new UpdateDownloadedEvent(version : payload.version, signer : payload.signer, text : text))
else {
updateDownloading = false
version = payload.version

View File

@@ -5,4 +5,5 @@ import com.muwire.core.Event
class UpdateDownloadedEvent extends Event {
String version
String signer
String text
}

View File

@@ -10,4 +10,6 @@ public class Constants {
public static final int MAX_HEADERS = 16;
public static final int MAX_RESULTS = 0x1 << 16;
public static final int MAX_COMMENT_LENGTH = 0x1 << 15;
}

View File

@@ -1,5 +1,5 @@
group = com.muwire
version = 0.5.5
version = 0.5.6
i2pVersion = 0.9.43
groovyVersion = 2.4.15
slf4jVersion = 1.7.25

View File

@@ -40,8 +40,11 @@ griffon {
]
}
mainClassName = 'com.muwire.gui.Launcher'
applicationDefaultJvmArgs = ['-Djava.util.logging.config.file=logging.properties']
application {
mainClassName = 'com.muwire.gui.Launcher'
applicationDefaultJvmArgs = ['-Djava.util.logging.config.file=logging.properties','-Xmx256M']
applicationName = 'MuWire'
}
apply from: 'gradle/publishing.gradle'
// apply from: 'gradle/code-coverage.gradle'

View File

@@ -41,6 +41,11 @@ mvcGroups {
view = 'com.muwire.gui.I2PStatusView'
controller = 'com.muwire.gui.I2PStatusController'
}
'system-status' {
model = 'com.muwire.gui.SystemStatusModel'
view = 'com.muwire.gui.SystemStatusView'
controller = 'com.muwire.gui.SystemStatusController'
}
'trust-list' {
model = 'com.muwire.gui.TrustListModel'
view = 'com.muwire.gui.TrustListView'
@@ -71,4 +76,9 @@ mvcGroups {
view = 'com.muwire.gui.CloseWarningView'
controller = 'com.muwire.gui.CloseWarningController'
}
'update' {
model = 'com.muwire.gui.UpdateModel'
view = 'com.muwire.gui.UpdateView'
controller = 'com.muwire.gui.UpdateController'
}
}

View File

@@ -7,7 +7,9 @@ import griffon.metadata.ArtifactProviderFor
import net.i2p.data.Base64
import javax.annotation.Nonnull
import javax.swing.JOptionPane
import com.muwire.core.Constants
import com.muwire.core.Core
import com.muwire.core.files.UICommentEvent
import com.muwire.core.util.DataUtil
@@ -24,6 +26,11 @@ class AddCommentController {
@ControllerAction
void save() {
String comment = view.textarea.getText()
if (comment.length() > Constants.MAX_COMMENT_LENGTH ) {
JOptionPane.showMessageDialog(null, "Your comment is too long - ${comment.length()} bytes. The maximum size is $Constants.MAX_COMMENT_LENGTH bytes",
"Comment Too Long", JOptionPane.WARNING_MESSAGE)
return
}
if (comment.trim().length() == 0)
comment = null
else

View File

@@ -0,0 +1,34 @@
package com.muwire.gui
import griffon.core.artifact.GriffonController
import griffon.core.controller.ControllerAction
import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor
import javax.annotation.Nonnull
@ArtifactProviderFor(GriffonController)
class SystemStatusController {
@MVCMember @Nonnull
SystemStatusModel model
@MVCMember @Nonnull
SystemStatusView view
@ControllerAction
void refresh() {
long totalRam = Runtime.getRuntime().totalMemory()
long usedRam = totalRam - Runtime.getRuntime().freeMemory()
model.usedRam = usedRam
model.totalRam = totalRam
model.maxRam = Runtime.getRuntime().maxMemory()
model.javaVendor = System.getProperty("java.vendor")
model.javaVersion = System.getProperty("java.version")
}
@ControllerAction
void close() {
view.dialog.setVisible(false)
mvcGroup.destroy()
}
}

View File

@@ -0,0 +1,27 @@
package com.muwire.gui
import griffon.core.artifact.GriffonController
import griffon.core.controller.ControllerAction
import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor
import javax.annotation.Nonnull
@ArtifactProviderFor(GriffonController)
class UpdateController {
@MVCMember @Nonnull
UpdateView view
@MVCMember @Nonnull
UpdateModel model
@ControllerAction
void close() {
view.dialog.setVisible(false)
mvcGroup.destroy()
}
@ControllerAction
void search() {
mvcGroup.parentGroup.controller.search(model.available.infoHash, "MuWire update")
close()
}
}

View File

@@ -156,8 +156,10 @@ class Initialize extends AbstractLifecycleHandler {
while(keys.hasMoreElements()) {
def key = keys.nextElement()
def value = lnf.getDefaults().get(key)
if (value instanceof FontUIResource)
if (value instanceof FontUIResource) {
lnf.getDefaults().put(key, font)
UIManager.put(key, font)
}
}
}
} else {

View File

@@ -1,3 +1,4 @@
package com.muwire.gui
import java.util.concurrent.ConcurrentHashMap
@@ -35,6 +36,7 @@ import com.muwire.core.files.FileHashingEvent
import com.muwire.core.files.FileLoadedEvent
import com.muwire.core.files.FileSharedEvent
import com.muwire.core.files.FileUnsharedEvent
import com.muwire.core.files.SideCarFileEvent
import com.muwire.core.search.QueryEvent
import com.muwire.core.search.SearchEvent
import com.muwire.core.search.UIResultBatchEvent
@@ -189,6 +191,7 @@ class MainFrameModel {
core.eventBus.register(ConnectionEvent.class, this)
core.eventBus.register(DisconnectionEvent.class, this)
core.eventBus.register(FileHashedEvent.class, this)
core.eventBus.register(SideCarFileEvent.class, this)
core.eventBus.register(FileHashingEvent.class, this)
core.eventBus.register(FileLoadedEvent.class, this)
core.eventBus.register(UploadEvent.class, this)
@@ -262,8 +265,10 @@ class MainFrameModel {
void onUpdateDownloadedEvent(UpdateDownloadedEvent e) {
runInsideUIAsync {
JOptionPane.showMessageDialog(null, "MuWire $e.version has been downloaded. You can update now",
"Update Downloaded", JOptionPane.INFORMATION_MESSAGE)
Map<String, Object> args = new HashMap<>()
args['available'] = null
args['downloaded'] = e
mvcGroup.createMVCGroup("update", "update", args)
}
}
@@ -527,13 +532,10 @@ class MainFrameModel {
void onUpdateAvailableEvent(UpdateAvailableEvent e) {
runInsideUIAsync {
int option = JOptionPane.showConfirmDialog(null,
"MuWire $e.version is available from $e.signer. You have "+ metadata["application.version"]+" Update?",
"New MuWire version availble", JOptionPane.OK_CANCEL_OPTION)
if (option == JOptionPane.CANCEL_OPTION)
return
controller.search(e.infoHash,"MuWire update")
Map<String, Object> args = new HashMap<>()
args['available'] = e
args['downloaded'] = null
mvcGroup.createMVCGroup("update", "update", args)
}
}
@@ -559,6 +561,12 @@ class MainFrameModel {
}
}
void onSideCarFileEvent(SideCarFileEvent e) {
runInsideUIAsync {
view.refreshSharedFiles()
}
}
private void insertIntoTree(SharedFile file) {
List<File> parents = new ArrayList<>()
File tmp = file.file.getParentFile()

View File

@@ -0,0 +1,24 @@
package com.muwire.gui
import javax.annotation.Nonnull
import griffon.core.artifact.GriffonModel
import griffon.inject.MVCMember
import griffon.transform.Observable
import griffon.metadata.ArtifactProviderFor
@ArtifactProviderFor(GriffonModel)
class SystemStatusModel {
@MVCMember @Nonnull
SystemStatusController controller
@Observable String javaVendor
@Observable String javaVersion
@Observable long usedRam
@Observable long totalRam
@Observable long maxRam
void mvcGroupInit(Map<String,String> args) {
controller.refresh()
}
}

View File

@@ -0,0 +1,14 @@
package com.muwire.gui
import com.muwire.core.update.UpdateAvailableEvent
import com.muwire.core.update.UpdateDownloadedEvent
import griffon.core.artifact.GriffonModel
import griffon.transform.Observable
import griffon.metadata.ArtifactProviderFor
@ArtifactProviderFor(GriffonModel)
class UpdateModel {
UpdateAvailableEvent available
UpdateDownloadedEvent downloaded
}

View File

@@ -43,7 +43,7 @@ class AddCommentView {
borderLayout()
panel (constraints : BorderLayout.CENTER) {
scrollPane {
textarea = textArea(text : comment, rows : 20, columns : 100, editable : true)
textarea = textArea(text : comment, rows : 20, columns : 100, editable : true, lineWrap:true, wrapStyleWord:true)
}
}
panel (constraints : BorderLayout.SOUTH) {

View File

@@ -3,6 +3,7 @@ package com.muwire.gui
import griffon.core.artifact.GriffonView
import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor
import net.i2p.data.DataHelper
import javax.swing.JDialog
import javax.swing.JPanel
@@ -64,10 +65,10 @@ class I2PStatusView {
panel(border : titledBorder(title : "Bandwidth", border : etchedBorder(), titlePosition : TitledBorder.TOP),
constraints : gbc(gridx: 0, gridy: 3, fill : GridBagConstraints.HORIZONTAL, weightx: 100)) {
gridBagLayout()
label(text : "Receive Bps (15 seconds)", constraints : gbc(gridx:0, gridy:0, anchor: GridBagConstraints.LINE_START, weightx: 100))
label(text : bind {model.receiveBps}, constraints : gbc(gridx: 1, gridy:0, anchor : GridBagConstraints.LINE_END))
label(text : "Send Bps (15 seconds)", constraints : gbc(gridx:0, gridy:1, anchor: GridBagConstraints.LINE_START, weightx: 100))
label(text : bind {model.sendBps}, constraints : gbc(gridx: 1, gridy:1, anchor : GridBagConstraints.LINE_END))
label(text : "Receive (15 seconds)", 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 : "Send (15 seconds)", 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))
}
}

View File

@@ -100,6 +100,7 @@ class MainFrameView {
menuItem("MuWire", actionPerformed : {mvcGroup.createMVCGroup("mu-wire-status")})
MuWireSettings muSettings = application.context.get("muwire-settings")
menuItem("I2P", enabled : bind {model.routerPresent}, actionPerformed: {mvcGroup.createMVCGroup("i-2-p-status")})
menuItem("System", actionPerformed : {mvcGroup.createMVCGroup("system-status")})
}
}
borderLayout()

View File

@@ -37,7 +37,7 @@ class ShowCommentView {
borderLayout()
panel (constraints : BorderLayout.CENTER) {
scrollPane {
textArea(text : model.result.comment, rows : 20, columns : 100, editable : false)
textArea(text : model.result.comment, rows : 20, columns : 100, editable : false, lineWrap : true, wrapStyleWord : true)
}
}
panel (constraints : BorderLayout.SOUTH) {

View File

@@ -0,0 +1,83 @@
package com.muwire.gui
import griffon.core.artifact.GriffonView
import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor
import net.i2p.data.DataHelper
import javax.swing.JDialog
import javax.swing.JPanel
import javax.swing.SwingConstants
import javax.swing.border.TitledBorder
import java.awt.BorderLayout
import java.awt.GridBagConstraints
import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent
import javax.annotation.Nonnull
@ArtifactProviderFor(GriffonView)
class SystemStatusView {
@MVCMember @Nonnull
FactoryBuilderSupport builder
@MVCMember @Nonnull
SystemStatusModel model
def mainFrame
def dialog
def panel
def buttonsPanel
void initUI() {
mainFrame = application.windowManager.findWindow("main-frame")
dialog = new JDialog(mainFrame, "System Status", true)
panel = builder.panel {
gridBagLayout()
panel(border : titledBorder(title : "Java", border : etchedBorder(), titlePosition : TitledBorder.TOP),
constraints : gbc(gridx : 0, gridy: 0, fill : GridBagConstraints.HORIZONTAL, weightx: 100)) {
gridBagLayout()
label(text : "Vendor ", constraints : gbc(gridx:0, gridy:0, anchor : GridBagConstraints.LINE_START, weightx : 100))
label(text : bind {model.javaVendor}, constraints : gbc(gridx:1, gridy:0, anchor : GridBagConstraints.LINE_END))
label(text : "Version", constraints : gbc(gridx:0, gridy:1, anchor : GridBagConstraints.LINE_START, weightx : 100))
label(text : bind {model.javaVersion}, constraints : gbc(gridx:1, gridy:1, anchor : GridBagConstraints.LINE_END))
}
panel(border : titledBorder(title : "Memory", border : etchedBorder(), titlePosition : TitledBorder.TOP),
constraints : gbc(gridx : 0, gridy: 1, fill : GridBagConstraints.HORIZONTAL, weightx: 100)) {
gridBagLayout()
label(text : "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 : "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 : "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))
}
buttonsPanel = builder.panel {
gridBagLayout()
button(text : "Refresh", constraints: gbc(gridx: 0, gridy: 0), refreshAction)
button(text : "Close", constraints : gbc(gridx : 1, gridy :0), closeAction)
}
}
}
void mvcGroupInit(Map<String,String> args) {
JPanel statusPanel = new JPanel()
statusPanel.setLayout(new BorderLayout())
statusPanel.add(panel, BorderLayout.CENTER)
statusPanel.add(buttonsPanel, BorderLayout.SOUTH)
dialog.getContentPane().add(statusPanel)
dialog.pack()
dialog.setResizable(false)
dialog.setLocationRelativeTo(mainFrame)
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
dialog.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
mvcGroup.destroy()
}
})
dialog.show()
}
}

View File

@@ -0,0 +1,61 @@
package com.muwire.gui
import griffon.core.artifact.GriffonView
import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor
import javax.swing.JDialog
import javax.swing.SwingConstants
import java.awt.BorderLayout
import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent
import javax.annotation.Nonnull
@ArtifactProviderFor(GriffonView)
class UpdateView {
@MVCMember @Nonnull
FactoryBuilderSupport builder
@MVCMember @Nonnull
UpdateModel model
def mainFrame
def dialog
def p
void initUI() {
mainFrame = application.windowManager.findWindow("main-frame")
String title = model.downloaded != null ? "Update Downloaded" : "Update Available"
dialog = new JDialog(mainFrame, title, true)
dialog.setResizable(true)
p = builder.panel {
borderLayout()
panel (constraints : BorderLayout.CENTER) {
scrollPane {
def text = model.downloaded != null ? model.downloaded.text : model.available.text
textArea(text : text, rows : 20, columns : 50, editable : false, lineWrap : true, wrapStyleWord : true)
}
}
panel (constraints : BorderLayout.SOUTH) {
if (model.available != null)
button(text : "Find", searchAction)
button(text : "Close", closeAction)
}
}
}
void mvcGroupInit(Map<String,String> args) {
dialog.getContentPane().add(p)
dialog.pack()
dialog.setLocationRelativeTo(mainFrame)
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
dialog.addWindowListener( new WindowAdapter() {
public void windowClosed(WindowEvent e) {
mvcGroup.destroy()
}
})
dialog.show()
}
}