Skip to content

Commit 1488dc2

Browse files
Migrate: existing code
0 parents  commit 1488dc2

84 files changed

Lines changed: 5578 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
46+
[Dd]ebug/
47+
[Rr]elease/
48+
x64/
49+
build/
50+
[Bb]in/
51+
[Oo]bj/
52+
53+
# MSTest test Results
54+
[Tt]est[Rr]esult*/
55+
[Bb]uild[Ll]og.*
56+
57+
*_i.c
58+
*_p.c
59+
*.ilk
60+
*.meta
61+
*.obj
62+
*.pch
63+
*.pdb
64+
*.pgc
65+
*.pgd
66+
*.rsp
67+
*.sbr
68+
*.tlb
69+
*.tli
70+
*.tlh
71+
*.tmp
72+
*.tmp_proj
73+
*.log
74+
*.vspscc
75+
*.vssscc
76+
.builds
77+
*.pidb
78+
*.log
79+
*.scc
80+
81+
# Visual C++ cache files
82+
ipch/
83+
*.aps
84+
*.ncb
85+
*.opensdf
86+
*.sdf
87+
*.cachefile
88+
89+
# Visual Studio profiler
90+
*.psess
91+
*.vsp
92+
*.vspx
93+
94+
# Guidance Automation Toolkit
95+
*.gpState
96+
97+
# ReSharper is a .NET coding add-in
98+
_ReSharper*/
99+
*.[Rr]e[Ss]harper
100+
101+
# TeamCity is a build add-in
102+
_TeamCity*
103+
104+
# DotCover is a Code Coverage Tool
105+
*.dotCover
106+
107+
# NCrunch
108+
*.ncrunch*
109+
.*crunch*.local.xml
110+
111+
# Installshield output folder
112+
[Ee]xpress/
113+
114+
# DocProject is a documentation generator add-in
115+
DocProject/buildhelp/
116+
DocProject/Help/*.HxT
117+
DocProject/Help/*.HxC
118+
DocProject/Help/*.hhc
119+
DocProject/Help/*.hhk
120+
DocProject/Help/*.hhp
121+
DocProject/Help/Html2
122+
DocProject/Help/html
123+
124+
# Click-Once directory
125+
publish/
126+
127+
# Publish Web Output
128+
*.Publish.xml
129+
*.pubxml
130+
*.publishproj
131+
132+
# NuGet Packages Directory
133+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
134+
#packages/
135+
136+
# Windows Azure Build Output
137+
csx
138+
*.build.csdef
139+
140+
# Windows Store app package directory
141+
AppPackages/
142+
143+
# Others
144+
sql/
145+
*.Cache
146+
ClientBin/
147+
[Ss]tyle[Cc]op.*
148+
~$*
149+
*~
150+
*.dbmdl
151+
*.[Pp]ublish.xml
152+
*.pfx
153+
*.publishsettings
154+
155+
# RIA/Silverlight projects
156+
Generated_Code/
157+
158+
# Backup & report files from converting an old project file to a newer
159+
# Visual Studio version. Backup files are not needed, because we have git ;-)
160+
_UpgradeReport_Files/
161+
Backup*/
162+
UpgradeLog*.XML
163+
UpgradeLog*.htm
164+
165+
# SQL Server files
166+
App_Data/*.mdf
167+
App_Data/*.ldf
168+
169+
#############
170+
## Windows detritus
171+
#############
172+
173+
# Windows image file caches
174+
Thumbs.db
175+
ehthumbs.db
176+
177+
# Folder config file
178+
Desktop.ini
179+
180+
# Recycle Bin used on file shares
181+
$RECYCLE.BIN/
182+
183+
# Mac crap
184+
.DS_Store
185+
186+
187+
#############
188+
## Python
189+
#############
190+
191+
*.py[cod]
192+
193+
# Packages
194+
*.egg
195+
*.egg-info
196+
dist/
197+
build/
198+
eggs/
199+
parts/
200+
var/
201+
sdist/
202+
develop-eggs/
203+
.installed.cfg
204+
205+
# Installer logs
206+
pip-log.txt
207+
208+
# Unit test / coverage reports
209+
.coverage
210+
.tox
211+
212+
#Translations
213+
*.mo
214+
215+
#Mr Developer
216+
.mr.developer.cfg

NetMessenger.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:\Progra~1\Java\jre1.8.0_71\bin\javaw -jar NetMessenger.jar

NetMessenger.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java -jar NetMessenger.jar

lib/json.jar

92.1 KB
Binary file not shown.

lib/log4j-1.2.17.jar

478 KB
Binary file not shown.

log4j.properties

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
log4j.rootLogger=DEBUG, stdout, R
2+
3+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
# Pattern to output the caller's file name and line number.
6+
#log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
7+
# Print the date in ISO 8601 format
8+
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
9+
10+
log4j.appender.R=org.apache.log4j.RollingFileAppender
11+
log4j.appender.R.File=./log/application.log
12+
log4j.appender.R.MaxFileSize=10MB
13+
# Keep one backup file
14+
#log4j.appender.R.MaxBackupIndex=1
15+
log4j.appender.R.layout=org.apache.log4j.PatternLayout
16+
log4j.appender.R.layout.ConversionPattern=%d %p %t %c - %m%n
17+
18+
# Print only messages of level WARN or above in the package com.foo.
19+
#log4j.logger.com.foo=WARN

src/com/netmessenger/Main.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.netmessenger;
2+
3+
import javax.swing.JFrame;
4+
import javax.swing.SwingUtilities;
5+
import javax.swing.UIManager;
6+
import javax.swing.UnsupportedLookAndFeelException;
7+
8+
import org.apache.log4j.Logger;
9+
import org.apache.log4j.PropertyConfigurator;
10+
11+
import com.netmessenger.ui.MainFrame;
12+
13+
public class Main {
14+
15+
private static final Logger LOGGER = Logger.getLogger(Main.class.getSimpleName());
16+
17+
public static void main(String[] args) {
18+
PropertyConfigurator.configure("log4j.properties");
19+
20+
try {
21+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
22+
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
23+
| UnsupportedLookAndFeelException ex) {
24+
LOGGER.error("Set look and feel failed.", ex);
25+
}
26+
27+
SwingUtilities.invokeLater(new Runnable() {
28+
29+
@Override
30+
public void run() {
31+
JFrame mainFrame = new MainFrame();
32+
mainFrame.setVisible(true);
33+
}
34+
});
35+
36+
}
37+
38+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.netmessenger.concurrent;
2+
3+
/**
4+
* Saves final status of {@link Task}.
5+
*
6+
* @param <S> The status type updated by {@link Task}.
7+
*/
8+
class FinalStatus<S> implements Updatable<S> {
9+
10+
private volatile S value;
11+
12+
@Override
13+
public void update(S value) {
14+
this.value = value;
15+
}
16+
17+
@Override
18+
public S get() {
19+
return value;
20+
}
21+
22+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.netmessenger.concurrent;
2+
3+
/**
4+
* A abstract class to perform monitoring status and task result of {@link TaskExecutor}.
5+
*
6+
* @param <K> The key type used to retrieve {@link Task}.
7+
* @param <V> The result type returned by {@link Task}.
8+
* @param <S> The status type updated by {@link Task}.
9+
*/
10+
public abstract class Monitor<K, V, S> {
11+
12+
abstract void wakeup();
13+
14+
protected abstract void onDone(ResultReport<K, V> report);
15+
16+
protected abstract void onStatusUpdated(StatusReport<K, S> report);
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.netmessenger.concurrent;
2+
3+
/**
4+
* Report is information generated by {@link Task}, and collected by {@link TaskExecutor}.
5+
*
6+
* @param <K> The key type used to retrieve {@link Task}.
7+
*/
8+
public class Report<K> {
9+
private K key;
10+
11+
public Report(K key) {
12+
this.key = key;
13+
}
14+
15+
public K getKey() {
16+
return key;
17+
}
18+
}

0 commit comments

Comments
 (0)