-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from 22hours/PC-Client-GUI
Pc client gui
- Loading branch information
Showing
81 changed files
with
5,023 additions
and
474 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
dev/Client(PC)/System-Monitor-Init/src/PCClient/Http/PCPost.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package PCClient.Http; | ||
|
||
import java.io.IOException; | ||
import java.io.UnsupportedEncodingException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.apache.http.HttpEntity; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.NameValuePair; | ||
import org.apache.http.client.ClientProtocolException; | ||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.entity.UrlEncodedFormEntity; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.impl.client.HttpClientBuilder; | ||
import org.apache.http.message.BasicNameValuePair; | ||
import org.apache.http.util.EntityUtils; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParser; | ||
|
||
public class PCPost { | ||
private static PCPost instance; | ||
|
||
private PCPost() { | ||
|
||
} | ||
|
||
public static PCPost getInstance() { | ||
if (instance == null) { | ||
instance = new PCPost(); | ||
} | ||
return instance; | ||
} | ||
|
||
// 다시 사용하기 (연장신청 대비) | ||
public void PostMethod(String pid, String classId ,int x, int y) throws URISyntaxException, ClientProtocolException, IOException { | ||
URI uri = new URI("http://13.125.208.19/pc/"+pid+"/data"); | ||
System.out.println("PostMethod URI = " + uri); | ||
HttpClient httpClient = HttpClientBuilder.create().build(); | ||
HttpPost postRequest = new HttpPost(uri); | ||
JsonObject json = new JsonObject(); | ||
json.addProperty("classId", classId); | ||
json.addProperty("id", pid); | ||
json.addProperty("name", "Favian"); | ||
json.addProperty("posR", x); | ||
json.addProperty("posC", y); | ||
json.addProperty("powerStatus", "OFF"); | ||
json.addProperty("startTime", "11"); | ||
json.addProperty("endTime", "11"); | ||
json.addProperty("cpuData", "7"); | ||
json.addProperty("ramData", "7"); | ||
json.addProperty("type", "PC"); | ||
postRequest.setEntity(new StringEntity(json.toString(), "UTF-8")); | ||
postRequest.addHeader("Content-type", "application/json"); | ||
System.out.println(json.toString()); | ||
try { | ||
HttpResponse response = httpClient.execute(postRequest); | ||
HttpEntity entity = response.getEntity(); | ||
String content = EntityUtils.toString(entity); | ||
System.out.println("=====Post Response====="); | ||
System.out.println(content); | ||
} catch (ClientProtocolException e) { | ||
System.out.println("-----Post Response 오류!-----"); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
138 changes: 138 additions & 0 deletions
138
dev/Client(PC)/System-Monitor-Init/src/PCClient/JavaSwing/PCGUI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package PCClient.JavaSwing; | ||
|
||
import java.awt.BorderLayout; | ||
import java.awt.Color; | ||
import java.awt.Desktop; | ||
import java.awt.Dialog; | ||
import java.awt.EventQueue; | ||
import java.awt.Font; | ||
import java.awt.Graphics; | ||
import java.awt.GraphicsDevice; | ||
import java.awt.GraphicsEnvironment; | ||
import java.awt.Image; | ||
import java.awt.Panel; | ||
import java.awt.Rectangle; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.awt.event.WindowAdapter; | ||
import java.awt.event.WindowEvent; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.Box; | ||
import javax.swing.BoxLayout; | ||
import javax.swing.DefaultListCellRenderer; | ||
import javax.swing.ImageIcon; | ||
import javax.swing.JButton; | ||
import javax.swing.JComboBox; | ||
import javax.swing.JDialog; | ||
import javax.swing.JFrame; | ||
import javax.swing.JLabel; | ||
import javax.swing.JOptionPane; | ||
import javax.swing.JPanel; | ||
import javax.swing.JPasswordField; | ||
import javax.swing.JProgressBar; | ||
import javax.swing.JTextField; | ||
import javax.swing.JToolBar; | ||
import javax.swing.UIManager; | ||
import javax.swing.WindowConstants; | ||
import javax.swing.border.Border; | ||
import javax.swing.border.TitledBorder; | ||
import javax.swing.plaf.ColorUIResource; | ||
|
||
import PCClient.Http.PCPost; | ||
import PCClient.Module.GetMACAddress; | ||
import sun.applet.Main; | ||
import sun.reflect.ReflectionFactory.GetReflectionFactoryAction; | ||
|
||
import javax.swing.SwingConstants; | ||
|
||
public class PCGUI { | ||
|
||
private JFrame frame; | ||
ExecutorService executorService = Executors.newFixedThreadPool(10); | ||
|
||
/** | ||
* Launch the application. | ||
*/ | ||
public static void main(String[] args) { | ||
EventQueue.invokeLater(new Runnable() { | ||
public void run() { | ||
try { | ||
PCGUI window = new PCGUI(); | ||
// window.frame.setVisible(true); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Create the application. | ||
*/ | ||
public PCGUI() { | ||
initialize(); | ||
} | ||
|
||
private WindowAdapter getWindowAdapter() { | ||
return new WindowAdapter() { | ||
@Override | ||
public void windowClosing(WindowEvent we) {// overrode to show message | ||
super.windowClosing(we); | ||
} | ||
|
||
@Override | ||
public void windowIconified(WindowEvent we) { | ||
frame.setState(JFrame.NORMAL); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Initialize the contents of the frame. | ||
*/ | ||
private void initialize() { | ||
|
||
GetMACAddress MAC = new GetMACAddress(); | ||
String pid = MAC.getLocalMacAddress(); | ||
JTextField zField = new JTextField(5); | ||
JTextField xField = new JTextField(5); | ||
JTextField yField = new JTextField(5); | ||
JTextField wField = new JTextField(5); | ||
|
||
JPanel myPanel = new JPanel(); | ||
myPanel.add(new JLabel("Id:")); | ||
myPanel.add(wField); | ||
myPanel.add(new JLabel("classId:")); | ||
myPanel.add(zField); | ||
myPanel.add(Box.createHorizontalStrut(15)); // a spacer | ||
myPanel.add(new JLabel("posR:")); | ||
myPanel.add(xField); | ||
myPanel.add(Box.createHorizontalStrut(15)); // a spacer | ||
myPanel.add(new JLabel("posC:")); | ||
myPanel.add(yField); | ||
|
||
int result = JOptionPane.showConfirmDialog(null, myPanel, pid, JOptionPane.OK_CANCEL_OPTION); | ||
if (result == JOptionPane.OK_OPTION) { | ||
String Id = wField.getText(); | ||
String classId = zField.getText(); | ||
int x = Integer.parseInt(xField.getText()); | ||
int y = Integer.parseInt(yField.getText()); | ||
try { | ||
PCPost.getInstance().PostMethod(Id, classId, x, y); | ||
} catch (URISyntaxException | IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.