Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stephen
IF3230-Tugas-Besar-Sister-2015
Commits
0ded8f30
Commit
0ded8f30
authored
Apr 22, 2015
by
Darwin
Browse files
find offer
parent
7c351592
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/client/nbproject/private/private.properties
View file @
0ded8f30
...
...
@@ -18,7 +18,7 @@ user.properties.file=C:\\Users\\susanti_2\\AppData\\Roaming\\NetBeans\\8.0.2\\bu
<<<<<<<
HEAD
user.properties.file
=
C:
\\
Users
\\
susanti_2
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0.2
\\
build.properties
=======
user.properties.file
=
C:
\\
Users
\\
s
us
anti_2
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
.2
\\
build.properties
user.properties.file
=
C:
\\
Users
\\
us
er
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
\\
build.properties
>>>>>>>
f5cc2615451f416ad94e5b85c35aa84513a123d3
>>>>>>>
9b3bab9e9eefddca873933beff1cff411b869149
>>>>>>>
4425b3f14619792ceebdcdb264cb7c61d1d9d38c
...
...
src/client/nbproject/private/private.xml
View file @
0ded8f30
...
...
@@ -3,15 +3,9 @@
<editor-bookmarks
xmlns=
"http://www.netbeans.org/ns/editor-bookmarks/2"
lastBookmarkId=
"0"
/>
<open-files
xmlns=
"http://www.netbeans.org/ns/projectui-open-files/2"
>
<group>
<<<<<<
< HEAD
<file
>
file:/C:/Users/susanti_2/Documents/ITB/IF/netbeans/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/MapTableModel.java
</file>
<file>
file:/C:/Users/susanti_2/Documents/ITB/IF/netbeans/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/MainPage.java
</file>
<file>
file:/C:/Users/susanti_2/Documents/ITB/IF/netbeans/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/TCPClient.java
</file>
=======
<file>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/client/src/tcpclient/MainPage.java
</file>
<file>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/client/src/tcpclient/TCPClient.java
</file>
<file>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/client/src/tcpclient/LoginPage.java
</file>
>>>>>>> 7d12ee92a34d06c0f223c1804ac375528b1b069d
<file>
file:/E:/semester%206/Sistem%20Paralel%20dan%20Terdistribusi/SISTER/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/TCPClient.java
</file>
<file>
file:/E:/semester%206/Sistem%20Paralel%20dan%20Terdistribusi/SISTER/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/TradeboxTableModel.java
</file>
<file>
file:/E:/semester%206/Sistem%20Paralel%20dan%20Terdistribusi/SISTER/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/MainPage.java
</file>
</group>
</open-files>
</project-private>
src/client/src/tcpclient/MainPage.form
View file @
0ded8f30
...
...
@@ -1909,15 +1909,44 @@
<Layout>
<DimensionLayout
dim=
"0"
>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<EmptySpace
min=
"0"
pref=
"908"
max=
"32767"
attributes=
"0"
/>
<Group
type=
"102"
alignment=
"0"
attributes=
"0"
>
<EmptySpace
min=
"-2"
pref=
"19"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"FindOfferItemScrollPane"
min=
"-2"
pref=
"847"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
pref=
"42"
max=
"32767"
attributes=
"0"
/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout
dim=
"1"
>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<EmptySpace
min=
"0"
pref=
"540"
max=
"32767"
attributes=
"0"
/>
<Group
type=
"102"
alignment=
"1"
attributes=
"0"
>
<EmptySpace
pref=
"20"
max=
"32767"
attributes=
"0"
/>
<Component
id=
"FindOfferItemScrollPane"
min=
"-2"
pref=
"500"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
min=
"-2"
pref=
"20"
max=
"-2"
attributes=
"0"
/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container
class=
"javax.swing.JScrollPane"
name=
"FindOfferItemScrollPane"
>
<Layout
class=
"org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"
/>
<SubComponents>
<Component
class=
"javax.swing.JTable"
name=
"FindOfferItemTable"
>
<Properties>
<Property
name=
"model"
type=
"javax.swing.table.TableModel"
editor=
"org.netbeans.modules.form.RADConnectionPropertyEditor"
>
<Connection
code=
"tradeboxModel"
type=
"code"
/>
</Property>
<Property
name=
"columnModel"
type=
"javax.swing.table.TableColumnModel"
editor=
"org.netbeans.modules.form.editors2.TableColumnModelEditor"
>
<TableColumnModel
selectionModel=
"0"
/>
</Property>
<Property
name=
"tableHeader"
type=
"javax.swing.table.JTableHeader"
editor=
"org.netbeans.modules.form.editors2.JTableHeaderEditor"
>
<TableHeader
reorderingAllowed=
"true"
resizingAllowed=
"true"
/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
...
...
src/client/src/tcpclient/MainPage.java
View file @
0ded8f30
...
...
@@ -43,20 +43,22 @@ public class MainPage extends javax.swing.JFrame {
//atribut
private
TCPClient
client
;
private
TableModel
mapModel
;
private
int
MixItem1
;
private
int
MixItem2
;
private
int
OfferedItemId
;
private
int
DemandedItemId
;
private
int
FindId
;
private
int
MixItem1
=
-
1
;
private
int
MixItem2
=
-
1
;
private
int
OfferedItemId
=
-
1
;
private
int
DemandedItemId
=
-
1
;
private
int
FindId
=
-
1
;
private
Date
currentTime
;
private
Date
time
;
private
Timer
timer
;
private
TradeboxTableModel
tradeboxModel
;
private
TradeboxTableModel
FindOfferBoxModel
;
public
MainPage
()
{
mapModel
=
new
MapTableModel
();
tradeboxModel
=
new
TradeboxTableModel
();
FindOfferBoxModel
=
new
TradeboxTableModel
();
initComponents
();
//mapTable
...
...
@@ -188,6 +190,8 @@ public class MainPage extends javax.swing.JFrame {
FindIcon
=
new
javax
.
swing
.
JButton
();
Find
=
new
javax
.
swing
.
JButton
();
tradeitemPanel
=
new
javax
.
swing
.
JPanel
();
FindOfferItemScrollPane
=
new
javax
.
swing
.
JScrollPane
();
FindOfferItemTable
=
new
javax
.
swing
.
JTable
();
setDefaultCloseOperation
(
javax
.
swing
.
WindowConstants
.
EXIT_ON_CLOSE
);
...
...
@@ -1488,15 +1492,24 @@ public class MainPage extends javax.swing.JFrame {
MainPanel
.
add
(
finditemPanel
,
"FindItemCard"
);
FindOfferItemTable
.
setModel
(
tradeboxModel
);
FindOfferItemScrollPane
.
setViewportView
(
FindOfferItemTable
);
javax
.
swing
.
GroupLayout
tradeitemPanelLayout
=
new
javax
.
swing
.
GroupLayout
(
tradeitemPanel
);
tradeitemPanel
.
setLayout
(
tradeitemPanelLayout
);
tradeitemPanelLayout
.
setHorizontalGroup
(
tradeitemPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGap
(
0
,
908
,
Short
.
MAX_VALUE
)
.
addGroup
(
tradeitemPanelLayout
.
createSequentialGroup
()
.
addGap
(
19
,
19
,
19
)
.
addComponent
(
FindOfferItemScrollPane
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
847
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addContainerGap
(
42
,
Short
.
MAX_VALUE
))
);
tradeitemPanelLayout
.
setVerticalGroup
(
tradeitemPanelLayout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGap
(
0
,
540
,
Short
.
MAX_VALUE
)
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
tradeitemPanelLayout
.
createSequentialGroup
()
.
addContainerGap
(
20
,
Short
.
MAX_VALUE
)
.
addComponent
(
FindOfferItemScrollPane
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
500
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
20
,
20
,
20
))
);
MainPanel
.
add
(
tradeitemPanel
,
"TradeItemCard"
);
...
...
@@ -2191,17 +2204,9 @@ public class MainPage extends javax.swing.JFrame {
private
void
FindActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_FindActionPerformed
// TODO add your handling code here:
try
{
//JSONObject response = client.sendFind(client.token,FindId);
/*if(response.get("status").equals("ok")) {
CardLayout cl = (CardLayout) MainPanel.getLayout();
cl.show(MainPanel, "TradeItemCard");
}*/
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
generateFindOfferTable
();
CardLayout
cl
=
(
CardLayout
)
MainPanel
.
getLayout
();
cl
.
show
(
MainPanel
,
"TradeItemCard"
);
}
//GEN-LAST:event_FindActionPerformed
private
void
fieldButtonActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_fieldButtonActionPerformed
...
...
@@ -2347,6 +2352,73 @@ public class MainPage extends javax.swing.JFrame {
}
}
private
void
generateFindOfferTable
()
{
System
.
out
.
println
(
"masuk generate tradebox"
);
try
{
//ini pake client.find()
JSONObject
response
=
client
.
tradebox
();
if
(
response
.
getString
(
"status"
).
equals
(
"ok"
))
{
JSONArray
offer
=
response
.
getJSONArray
(
"offers"
);
int
dimX
=
offer
.
length
();
int
dimY
=
5
;
FindOfferBoxModel
=
new
TradeboxTableModel
(
dimX
,
dimY
);
buttons
=
new
JButton
[
dimX
];
for
(
int
i
=
0
;
i
<
offer
.
length
();
i
++)
{
ImageIcon
newPlayerIcon
=
getImage
(
offer
.
getJSONArray
(
i
).
getInt
(
0
),
100
,
100
);
FindOfferBoxModel
.
setValueAt
(
newPlayerIcon
,
i
,
0
);
FindOfferBoxModel
.
setValueAt
(
offer
.
getJSONArray
(
i
).
get
(
1
),
i
,
1
);
//newPlayerIcon = getImage(offer.getJSONArray(i).getInt(2), 100, 100);
FindOfferBoxModel
.
setValueAt
(
newPlayerIcon
,
i
,
2
);
FindOfferBoxModel
.
setValueAt
(
offer
.
getJSONArray
(
i
).
get
(
3
),
i
,
3
);
if
(
offer
.
getJSONArray
(
i
).
get
(
4
).
toString
().
equals
(
"true"
))
//avalaible
{
buttons
[
i
]
=
new
JButton
(
"Cancel"
);
String
offerToken
=
offer
.
getJSONArray
(
i
).
get
(
4
).
toString
();
buttons
[
i
].
setActionCommand
(
offerToken
);
buttons
[
i
].
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
String
offerToken
=
e
.
getActionCommand
();
cancelOffer
(
offerToken
);
}
});
}
else
{
buttons
[
i
]
=
new
JButton
(
"Fetch"
);
String
offerToken
=
offer
.
getJSONArray
(
i
).
get
(
4
).
toString
();
buttons
[
i
].
setActionCommand
(
offerToken
);
buttons
[
i
].
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
String
offerToken
=
e
.
getActionCommand
();
fetchItem
(
offerToken
);
}
});
}
FindOfferBoxModel
.
setValueAt
(
buttons
[
i
],
i
,
4
);
}
FindOfferItemTable
.
setModel
(
FindOfferBoxModel
);
FindOfferItemTable
.
setRowHeight
(
100
);
}
else
{
showMessage
(
"Tradebox Error. Try again later.."
);
}
}
catch
(
Exception
ex
)
{
showMessage
(
"Server tradebox does not respond. Please try again later.."
);
System
.
out
.
println
(
"Tradebox Exception"
);
Logger
.
getLogger
(
MainPage
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
private
ImageIcon
getImage
(
int
id
,
int
width
,
int
height
)
{
...
...
@@ -2435,6 +2507,8 @@ public class MainPage extends javax.swing.JFrame {
private
javax
.
swing
.
JButton
FindLifeElixir
;
private
javax
.
swing
.
JButton
FindManaCrystal
;
private
javax
.
swing
.
JButton
FindMineral
;
private
javax
.
swing
.
JScrollPane
FindOfferItemScrollPane
;
private
javax
.
swing
.
JTable
FindOfferItemTable
;
private
javax
.
swing
.
JButton
FindPhilosopherStone
;
private
javax
.
swing
.
JButton
FindPotion
;
private
javax
.
swing
.
JLabel
GemsIcon
;
...
...
src/server/build/classes/tcpserver/TCPServer.class
View file @
0ded8f30
No preview for this file type
src/server/nbproject/private/private.properties
View file @
0ded8f30
...
...
@@ -33,7 +33,7 @@ user.properties.file=C:\\Users\\susanti_2\\AppData\\Roaming\\NetBeans\\8.0.2\\bu
user.properties.file
=
C:
\\
Users
\\
susanti_2
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0.2
\\
build.properties
>>>>>>>
f5cc2615451f416ad94e5b85c35aa84513a123d3
=
======
user.properties.file
=
C:
\\
Users
\\
Stephen
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
.2
\\
build.properties
user.properties.file
=
C:
\\
Users
\\
user
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
\\
build.properties
>>>>>>>
7d12ee92a34d06c0f223c1804ac375528b1b069d
>>>>>>>
9b3bab9e9eefddca873933beff1cff411b869149
>>>>>>>
4425b3f14619792ceebdcdb264cb7c61d1d9d38c
...
...
src/server/nbproject/private/private.xml
View file @
0ded8f30
...
...
@@ -3,19 +3,7 @@
<editor-bookmarks
xmlns=
"http://www.netbeans.org/ns/editor-bookmarks/2"
lastBookmarkId=
"0"
/>
<open-files
xmlns=
"http://www.netbeans.org/ns/projectui-open-files/2"
>
<group>
<<<<<<
< HEAD
<file
>
file:/C:/Users/susanti_2/Documents/ITB/IF/netbeans/IF3230-Tugas-Besar-Sister-2015/src/server/src/tcpserver/TCPServer.java
</file>
=======
<<<<<<
< HEAD
<file
>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/server/src/tcpserver/TCPServer.java
</file>
<file>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/server/src/tcpserver/Host.java
</file>
<file>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/server/src/tcpserver/MySQLAccess.java
</file>
=======
<file>
file:/D:/IF3230-Tugas-Besar-Sister-2015/src/server/map.txt
</file>
<file>
file:/D:/IF3230-Tugas-Besar-Sister-2015/src/server/src/tcpserver/MySQLAccess.java
</file>
<file>
file:/D:/IF3230-Tugas-Besar-Sister-2015/src/server/src/tcpserver/TCPServer.java
</file>
>>>>>>> f5cc2615451f416ad94e5b85c35aa84513a123d3
>>>>>>> 7d12ee92a34d06c0f223c1804ac375528b1b069d
<file>
file:/E:/semester%206/Sistem%20Paralel%20dan%20Terdistribusi/SISTER/IF3230-Tugas-Besar-Sister-2015/src/server/src/tcpserver/TCPServer.java
</file>
</group>
</open-files>
</project-private>
src/server/src/tcpserver/TCPServer.java
View file @
0ded8f30
...
...
@@ -243,7 +243,7 @@ public class TCPServer implements Runnable {
int
count
=
1
;
do
{
try
{
//
join("192.168.1.102", 6790);
join
(
"192.168.1.102"
,
6790
);
joined
=
true
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
count
+
". Tracker not responding, retrying in 5 seconds"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment