Skip to content

Commit

Permalink
Migrate: existing code
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo-Cosmos committed Dec 17, 2016
0 parents commit 1488dc2
Show file tree
Hide file tree
Showing 84 changed files with 5,578 additions and 0 deletions.
216 changes: 216 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml
*.publishproj

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

#############
## Windows detritus
#############

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store


#############
## Python
#############

*.py[cod]

# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg
1 change: 1 addition & 0 deletions NetMessenger.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Progra~1\Java\jre1.8.0_71\bin\javaw -jar NetMessenger.jar
1 change: 1 addition & 0 deletions NetMessenger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java -jar NetMessenger.jar
Binary file added lib/json.jar
Binary file not shown.
Binary file added lib/log4j-1.2.17.jar
Binary file not shown.
19 changes: 19 additions & 0 deletions log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
log4j.rootLogger=DEBUG, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
#log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
# Print the date in ISO 8601 format
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=./log/application.log
log4j.appender.R.MaxFileSize=10MB
# Keep one backup file
#log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %p %t %c - %m%n

# Print only messages of level WARN or above in the package com.foo.
#log4j.logger.com.foo=WARN
38 changes: 38 additions & 0 deletions src/com/netmessenger/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.netmessenger;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.netmessenger.ui.MainFrame;

public class Main {

private static final Logger LOGGER = Logger.getLogger(Main.class.getSimpleName());

public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties");

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException ex) {
LOGGER.error("Set look and feel failed.", ex);
}

SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
JFrame mainFrame = new MainFrame();
mainFrame.setVisible(true);
}
});

}

}
22 changes: 22 additions & 0 deletions src/com/netmessenger/concurrent/FinalStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.netmessenger.concurrent;

/**
* Saves final status of {@link Task}.
*
* @param <S> The status type updated by {@link Task}.
*/
class FinalStatus<S> implements Updatable<S> {

private volatile S value;

@Override
public void update(S value) {
this.value = value;
}

@Override
public S get() {
return value;
}

}
17 changes: 17 additions & 0 deletions src/com/netmessenger/concurrent/Monitor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.netmessenger.concurrent;

/**
* A abstract class to perform monitoring status and task result of {@link TaskExecutor}.
*
* @param <K> The key type used to retrieve {@link Task}.
* @param <V> The result type returned by {@link Task}.
* @param <S> The status type updated by {@link Task}.
*/
public abstract class Monitor<K, V, S> {

abstract void wakeup();

protected abstract void onDone(ResultReport<K, V> report);

protected abstract void onStatusUpdated(StatusReport<K, S> report);
}
18 changes: 18 additions & 0 deletions src/com/netmessenger/concurrent/Report.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.netmessenger.concurrent;

/**
* Report is information generated by {@link Task}, and collected by {@link TaskExecutor}.
*
* @param <K> The key type used to retrieve {@link Task}.
*/
public class Report<K> {
private K key;

public Report(K key) {
this.key = key;
}

public K getKey() {
return key;
}
}
Loading

0 comments on commit 1488dc2

Please sign in to comment.